forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/media/platform/rcar_fdp1.c
....@@ -947,7 +947,7 @@
947947 u32 rndctl;
948948
949949 pstride = q_data->format.plane_fmt[0].bytesperline
950
- << FD1_WPF_PSTRIDE_Y_SHIFT;
950
+ << FD1_WPF_PSTRIDE_Y_SHIFT;
951951
952952 if (q_data->format.num_planes > 1)
953953 pstride |= q_data->format.plane_fmt[1].bytesperline
....@@ -1141,8 +1141,8 @@
11411141 int dstbufs = 1;
11421142
11431143 dprintk(ctx->fdp1, "+ Src: %d : Dst: %d\n",
1144
- v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx),
1145
- v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx));
1144
+ v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx),
1145
+ v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx));
11461146
11471147 /* One output buffer is required for each field */
11481148 if (V4L2_FIELD_HAS_BOTH(src_q_data->format.field))
....@@ -1280,7 +1280,7 @@
12801280
12811281 fdp1_queue_field(ctx, fbuf);
12821282 dprintk(fdp1, "Queued Buffer [%d] last_field:%d\n",
1283
- i, fbuf->last_field);
1283
+ i, fbuf->last_field);
12841284 }
12851285
12861286 /* Queue as many jobs as our data provides for */
....@@ -1339,7 +1339,7 @@
13391339 fdp1_job_free(fdp1, job);
13401340
13411341 dprintk(fdp1, "curr_ctx->num_processed %d curr_ctx->translen %d\n",
1342
- ctx->num_processed, ctx->translen);
1342
+ ctx->num_processed, ctx->translen);
13431343
13441344 if (ctx->num_processed == ctx->translen ||
13451345 ctx->aborting) {
....@@ -1361,10 +1361,10 @@
13611361 static int fdp1_vidioc_querycap(struct file *file, void *priv,
13621362 struct v4l2_capability *cap)
13631363 {
1364
- strlcpy(cap->driver, DRIVER_NAME, sizeof(cap->driver));
1365
- strlcpy(cap->card, DRIVER_NAME, sizeof(cap->card));
1364
+ strscpy(cap->driver, DRIVER_NAME, sizeof(cap->driver));
1365
+ strscpy(cap->card, DRIVER_NAME, sizeof(cap->card));
13661366 snprintf(cap->bus_info, sizeof(cap->bus_info),
1367
- "platform:%s", DRIVER_NAME);
1367
+ "platform:%s", DRIVER_NAME);
13681368 return 0;
13691369 }
13701370
....@@ -1732,8 +1732,8 @@
17321732 static const struct v4l2_ioctl_ops fdp1_ioctl_ops = {
17331733 .vidioc_querycap = fdp1_vidioc_querycap,
17341734
1735
- .vidioc_enum_fmt_vid_cap_mplane = fdp1_enum_fmt_vid_cap,
1736
- .vidioc_enum_fmt_vid_out_mplane = fdp1_enum_fmt_vid_out,
1735
+ .vidioc_enum_fmt_vid_cap = fdp1_enum_fmt_vid_cap,
1736
+ .vidioc_enum_fmt_vid_out = fdp1_enum_fmt_vid_out,
17371737 .vidioc_g_fmt_vid_cap_mplane = fdp1_g_fmt,
17381738 .vidioc_g_fmt_vid_out_mplane = fdp1_g_fmt,
17391739 .vidioc_try_fmt_vid_cap_mplane = fdp1_try_fmt,
....@@ -1995,13 +1995,13 @@
19951995 /* Free smsk_data */
19961996 if (ctx->smsk_cpu) {
19971997 dma_free_coherent(ctx->fdp1->dev, ctx->smsk_size,
1998
- ctx->smsk_cpu, ctx->smsk_addr[0]);
1998
+ ctx->smsk_cpu, ctx->smsk_addr[0]);
19991999 ctx->smsk_addr[0] = ctx->smsk_addr[1] = 0;
20002000 ctx->smsk_cpu = NULL;
20012001 }
20022002
20032003 WARN(!list_empty(&ctx->fields_queue),
2004
- "Buffer queue not empty");
2004
+ "Buffer queue not empty");
20052005 } else {
20062006 /* Empty Capture queues (Jobs) */
20072007 struct fdp1_job *job;
....@@ -2023,10 +2023,10 @@
20232023 fdp1_field_complete(ctx, ctx->previous);
20242024
20252025 WARN(!list_empty(&ctx->fdp1->queued_job_list),
2026
- "Queued Job List not empty");
2026
+ "Queued Job List not empty");
20272027
20282028 WARN(!list_empty(&ctx->fdp1->hw_job_list),
2029
- "HW Job list not empty");
2029
+ "HW Job list not empty");
20302030 }
20312031 }
20322032
....@@ -2112,7 +2112,7 @@
21122112 fdp1_ctrl_deint_menu);
21132113
21142114 ctrl = v4l2_ctrl_new_std(&ctx->hdl, &fdp1_ctrl_ops,
2115
- V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, 1, 2, 1, 1);
2115
+ V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, 1, 2, 1, 1);
21162116 if (ctrl)
21172117 ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
21182118
....@@ -2121,8 +2121,7 @@
21212121
21222122 if (ctx->hdl.error) {
21232123 ret = ctx->hdl.error;
2124
- v4l2_ctrl_handler_free(&ctx->hdl);
2125
- goto done;
2124
+ goto error_ctx;
21262125 }
21272126
21282127 ctx->fh.ctrl_handler = &ctx->hdl;
....@@ -2136,20 +2135,27 @@
21362135
21372136 if (IS_ERR(ctx->fh.m2m_ctx)) {
21382137 ret = PTR_ERR(ctx->fh.m2m_ctx);
2139
-
2140
- v4l2_ctrl_handler_free(&ctx->hdl);
2141
- kfree(ctx);
2142
- goto done;
2138
+ goto error_ctx;
21432139 }
21442140
21452141 /* Perform any power management required */
2146
- pm_runtime_get_sync(fdp1->dev);
2142
+ ret = pm_runtime_resume_and_get(fdp1->dev);
2143
+ if (ret < 0)
2144
+ goto error_pm;
21472145
21482146 v4l2_fh_add(&ctx->fh);
21492147
21502148 dprintk(fdp1, "Created instance: %p, m2m_ctx: %p\n",
21512149 ctx, ctx->fh.m2m_ctx);
21522150
2151
+ mutex_unlock(&fdp1->dev_mutex);
2152
+ return 0;
2153
+
2154
+error_pm:
2155
+ v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
2156
+error_ctx:
2157
+ v4l2_ctrl_handler_free(&ctx->hdl);
2158
+ kfree(ctx);
21532159 done:
21542160 mutex_unlock(&fdp1->dev_mutex);
21552161 return ret;
....@@ -2254,7 +2260,6 @@
22542260 struct fdp1_dev *fdp1;
22552261 struct video_device *vfd;
22562262 struct device_node *fcp_node;
2257
- struct resource *res;
22582263 struct clk *clk;
22592264 unsigned int i;
22602265
....@@ -2281,17 +2286,15 @@
22812286 platform_set_drvdata(pdev, fdp1);
22822287
22832288 /* Memory-mapped registers */
2284
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2285
- fdp1->regs = devm_ioremap_resource(&pdev->dev, res);
2289
+ fdp1->regs = devm_platform_ioremap_resource(pdev, 0);
22862290 if (IS_ERR(fdp1->regs))
22872291 return PTR_ERR(fdp1->regs);
22882292
22892293 /* Interrupt service routine registration */
2290
- fdp1->irq = ret = platform_get_irq(pdev, 0);
2291
- if (ret < 0) {
2292
- dev_err(&pdev->dev, "cannot find IRQ\n");
2294
+ ret = platform_get_irq(pdev, 0);
2295
+ if (ret < 0)
22932296 return ret;
2294
- }
2297
+ fdp1->irq = ret;
22952298
22962299 ret = devm_request_irq(&pdev->dev, fdp1->irq, fdp1_irq_handler, 0,
22972300 dev_name(&pdev->dev), fdp1);
....@@ -2314,8 +2317,10 @@
23142317
23152318 /* Determine our clock rate */
23162319 clk = clk_get(&pdev->dev, NULL);
2317
- if (IS_ERR(clk))
2318
- return PTR_ERR(clk);
2320
+ if (IS_ERR(clk)) {
2321
+ ret = PTR_ERR(clk);
2322
+ goto put_dev;
2323
+ }
23192324
23202325 fdp1->clk_rate = clk_get_rate(clk);
23212326 clk_put(clk);
....@@ -2324,7 +2329,7 @@
23242329 ret = v4l2_device_register(&pdev->dev, &fdp1->v4l2_dev);
23252330 if (ret) {
23262331 v4l2_err(&fdp1->v4l2_dev, "Failed to register video device\n");
2327
- return ret;
2332
+ goto put_dev;
23282333 }
23292334
23302335 /* M2M registration */
....@@ -2341,20 +2346,22 @@
23412346 vfd->lock = &fdp1->dev_mutex;
23422347 vfd->v4l2_dev = &fdp1->v4l2_dev;
23432348 video_set_drvdata(vfd, fdp1);
2344
- strlcpy(vfd->name, fdp1_videodev.name, sizeof(vfd->name));
2349
+ strscpy(vfd->name, fdp1_videodev.name, sizeof(vfd->name));
23452350
2346
- ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
2351
+ ret = video_register_device(vfd, VFL_TYPE_VIDEO, 0);
23472352 if (ret) {
23482353 v4l2_err(&fdp1->v4l2_dev, "Failed to register video device\n");
23492354 goto release_m2m;
23502355 }
23512356
2352
- v4l2_info(&fdp1->v4l2_dev,
2353
- "Device registered as /dev/video%d\n", vfd->num);
2357
+ v4l2_info(&fdp1->v4l2_dev, "Device registered as /dev/video%d\n",
2358
+ vfd->num);
23542359
23552360 /* Power up the cells to read HW */
23562361 pm_runtime_enable(&pdev->dev);
2357
- pm_runtime_get_sync(fdp1->dev);
2362
+ ret = pm_runtime_resume_and_get(fdp1->dev);
2363
+ if (ret < 0)
2364
+ goto disable_pm;
23582365
23592366 hw_version = fdp1_read(fdp1, FD1_IP_INTDATA);
23602367 switch (hw_version) {
....@@ -2375,7 +2382,7 @@
23752382 break;
23762383 default:
23772384 dev_err(fdp1->dev, "FDP1 Unidentifiable (0x%08x)\n",
2378
- hw_version);
2385
+ hw_version);
23792386 }
23802387
23812388 /* Allow the hw to sleep until an open call puts it to use */
....@@ -2383,12 +2390,17 @@
23832390
23842391 return 0;
23852392
2393
+disable_pm:
2394
+ pm_runtime_disable(fdp1->dev);
2395
+
23862396 release_m2m:
23872397 v4l2_m2m_release(fdp1->m2m_dev);
23882398
23892399 unreg_dev:
23902400 v4l2_device_unregister(&fdp1->v4l2_dev);
23912401
2402
+put_dev:
2403
+ rcar_fcp_put(fdp1->fcp);
23922404 return ret;
23932405 }
23942406
....@@ -2400,6 +2412,7 @@
24002412 video_unregister_device(&fdp1->vfd);
24012413 v4l2_device_unregister(&fdp1->v4l2_dev);
24022414 pm_runtime_disable(&pdev->dev);
2415
+ rcar_fcp_put(fdp1->fcp);
24032416
24042417 return 0;
24052418 }