| .. | .. |
|---|
| 947 | 947 | u32 rndctl; |
|---|
| 948 | 948 | |
|---|
| 949 | 949 | pstride = q_data->format.plane_fmt[0].bytesperline |
|---|
| 950 | | - << FD1_WPF_PSTRIDE_Y_SHIFT; |
|---|
| 950 | + << FD1_WPF_PSTRIDE_Y_SHIFT; |
|---|
| 951 | 951 | |
|---|
| 952 | 952 | if (q_data->format.num_planes > 1) |
|---|
| 953 | 953 | pstride |= q_data->format.plane_fmt[1].bytesperline |
|---|
| .. | .. |
|---|
| 1141 | 1141 | int dstbufs = 1; |
|---|
| 1142 | 1142 | |
|---|
| 1143 | 1143 | 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)); |
|---|
| 1146 | 1146 | |
|---|
| 1147 | 1147 | /* One output buffer is required for each field */ |
|---|
| 1148 | 1148 | if (V4L2_FIELD_HAS_BOTH(src_q_data->format.field)) |
|---|
| .. | .. |
|---|
| 1280 | 1280 | |
|---|
| 1281 | 1281 | fdp1_queue_field(ctx, fbuf); |
|---|
| 1282 | 1282 | dprintk(fdp1, "Queued Buffer [%d] last_field:%d\n", |
|---|
| 1283 | | - i, fbuf->last_field); |
|---|
| 1283 | + i, fbuf->last_field); |
|---|
| 1284 | 1284 | } |
|---|
| 1285 | 1285 | |
|---|
| 1286 | 1286 | /* Queue as many jobs as our data provides for */ |
|---|
| .. | .. |
|---|
| 1339 | 1339 | fdp1_job_free(fdp1, job); |
|---|
| 1340 | 1340 | |
|---|
| 1341 | 1341 | dprintk(fdp1, "curr_ctx->num_processed %d curr_ctx->translen %d\n", |
|---|
| 1342 | | - ctx->num_processed, ctx->translen); |
|---|
| 1342 | + ctx->num_processed, ctx->translen); |
|---|
| 1343 | 1343 | |
|---|
| 1344 | 1344 | if (ctx->num_processed == ctx->translen || |
|---|
| 1345 | 1345 | ctx->aborting) { |
|---|
| .. | .. |
|---|
| 1361 | 1361 | static int fdp1_vidioc_querycap(struct file *file, void *priv, |
|---|
| 1362 | 1362 | struct v4l2_capability *cap) |
|---|
| 1363 | 1363 | { |
|---|
| 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)); |
|---|
| 1366 | 1366 | snprintf(cap->bus_info, sizeof(cap->bus_info), |
|---|
| 1367 | | - "platform:%s", DRIVER_NAME); |
|---|
| 1367 | + "platform:%s", DRIVER_NAME); |
|---|
| 1368 | 1368 | return 0; |
|---|
| 1369 | 1369 | } |
|---|
| 1370 | 1370 | |
|---|
| .. | .. |
|---|
| 1732 | 1732 | static const struct v4l2_ioctl_ops fdp1_ioctl_ops = { |
|---|
| 1733 | 1733 | .vidioc_querycap = fdp1_vidioc_querycap, |
|---|
| 1734 | 1734 | |
|---|
| 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, |
|---|
| 1737 | 1737 | .vidioc_g_fmt_vid_cap_mplane = fdp1_g_fmt, |
|---|
| 1738 | 1738 | .vidioc_g_fmt_vid_out_mplane = fdp1_g_fmt, |
|---|
| 1739 | 1739 | .vidioc_try_fmt_vid_cap_mplane = fdp1_try_fmt, |
|---|
| .. | .. |
|---|
| 1995 | 1995 | /* Free smsk_data */ |
|---|
| 1996 | 1996 | if (ctx->smsk_cpu) { |
|---|
| 1997 | 1997 | 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]); |
|---|
| 1999 | 1999 | ctx->smsk_addr[0] = ctx->smsk_addr[1] = 0; |
|---|
| 2000 | 2000 | ctx->smsk_cpu = NULL; |
|---|
| 2001 | 2001 | } |
|---|
| 2002 | 2002 | |
|---|
| 2003 | 2003 | WARN(!list_empty(&ctx->fields_queue), |
|---|
| 2004 | | - "Buffer queue not empty"); |
|---|
| 2004 | + "Buffer queue not empty"); |
|---|
| 2005 | 2005 | } else { |
|---|
| 2006 | 2006 | /* Empty Capture queues (Jobs) */ |
|---|
| 2007 | 2007 | struct fdp1_job *job; |
|---|
| .. | .. |
|---|
| 2023 | 2023 | fdp1_field_complete(ctx, ctx->previous); |
|---|
| 2024 | 2024 | |
|---|
| 2025 | 2025 | WARN(!list_empty(&ctx->fdp1->queued_job_list), |
|---|
| 2026 | | - "Queued Job List not empty"); |
|---|
| 2026 | + "Queued Job List not empty"); |
|---|
| 2027 | 2027 | |
|---|
| 2028 | 2028 | WARN(!list_empty(&ctx->fdp1->hw_job_list), |
|---|
| 2029 | | - "HW Job list not empty"); |
|---|
| 2029 | + "HW Job list not empty"); |
|---|
| 2030 | 2030 | } |
|---|
| 2031 | 2031 | } |
|---|
| 2032 | 2032 | |
|---|
| .. | .. |
|---|
| 2112 | 2112 | fdp1_ctrl_deint_menu); |
|---|
| 2113 | 2113 | |
|---|
| 2114 | 2114 | 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); |
|---|
| 2116 | 2116 | if (ctrl) |
|---|
| 2117 | 2117 | ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; |
|---|
| 2118 | 2118 | |
|---|
| .. | .. |
|---|
| 2121 | 2121 | |
|---|
| 2122 | 2122 | if (ctx->hdl.error) { |
|---|
| 2123 | 2123 | ret = ctx->hdl.error; |
|---|
| 2124 | | - v4l2_ctrl_handler_free(&ctx->hdl); |
|---|
| 2125 | | - goto done; |
|---|
| 2124 | + goto error_ctx; |
|---|
| 2126 | 2125 | } |
|---|
| 2127 | 2126 | |
|---|
| 2128 | 2127 | ctx->fh.ctrl_handler = &ctx->hdl; |
|---|
| .. | .. |
|---|
| 2136 | 2135 | |
|---|
| 2137 | 2136 | if (IS_ERR(ctx->fh.m2m_ctx)) { |
|---|
| 2138 | 2137 | 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; |
|---|
| 2143 | 2139 | } |
|---|
| 2144 | 2140 | |
|---|
| 2145 | 2141 | /* 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; |
|---|
| 2147 | 2145 | |
|---|
| 2148 | 2146 | v4l2_fh_add(&ctx->fh); |
|---|
| 2149 | 2147 | |
|---|
| 2150 | 2148 | dprintk(fdp1, "Created instance: %p, m2m_ctx: %p\n", |
|---|
| 2151 | 2149 | ctx, ctx->fh.m2m_ctx); |
|---|
| 2152 | 2150 | |
|---|
| 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); |
|---|
| 2153 | 2159 | done: |
|---|
| 2154 | 2160 | mutex_unlock(&fdp1->dev_mutex); |
|---|
| 2155 | 2161 | return ret; |
|---|
| .. | .. |
|---|
| 2254 | 2260 | struct fdp1_dev *fdp1; |
|---|
| 2255 | 2261 | struct video_device *vfd; |
|---|
| 2256 | 2262 | struct device_node *fcp_node; |
|---|
| 2257 | | - struct resource *res; |
|---|
| 2258 | 2263 | struct clk *clk; |
|---|
| 2259 | 2264 | unsigned int i; |
|---|
| 2260 | 2265 | |
|---|
| .. | .. |
|---|
| 2281 | 2286 | platform_set_drvdata(pdev, fdp1); |
|---|
| 2282 | 2287 | |
|---|
| 2283 | 2288 | /* 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); |
|---|
| 2286 | 2290 | if (IS_ERR(fdp1->regs)) |
|---|
| 2287 | 2291 | return PTR_ERR(fdp1->regs); |
|---|
| 2288 | 2292 | |
|---|
| 2289 | 2293 | /* 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) |
|---|
| 2293 | 2296 | return ret; |
|---|
| 2294 | | - } |
|---|
| 2297 | + fdp1->irq = ret; |
|---|
| 2295 | 2298 | |
|---|
| 2296 | 2299 | ret = devm_request_irq(&pdev->dev, fdp1->irq, fdp1_irq_handler, 0, |
|---|
| 2297 | 2300 | dev_name(&pdev->dev), fdp1); |
|---|
| .. | .. |
|---|
| 2314 | 2317 | |
|---|
| 2315 | 2318 | /* Determine our clock rate */ |
|---|
| 2316 | 2319 | 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 | + } |
|---|
| 2319 | 2324 | |
|---|
| 2320 | 2325 | fdp1->clk_rate = clk_get_rate(clk); |
|---|
| 2321 | 2326 | clk_put(clk); |
|---|
| .. | .. |
|---|
| 2324 | 2329 | ret = v4l2_device_register(&pdev->dev, &fdp1->v4l2_dev); |
|---|
| 2325 | 2330 | if (ret) { |
|---|
| 2326 | 2331 | v4l2_err(&fdp1->v4l2_dev, "Failed to register video device\n"); |
|---|
| 2327 | | - return ret; |
|---|
| 2332 | + goto put_dev; |
|---|
| 2328 | 2333 | } |
|---|
| 2329 | 2334 | |
|---|
| 2330 | 2335 | /* M2M registration */ |
|---|
| .. | .. |
|---|
| 2341 | 2346 | vfd->lock = &fdp1->dev_mutex; |
|---|
| 2342 | 2347 | vfd->v4l2_dev = &fdp1->v4l2_dev; |
|---|
| 2343 | 2348 | 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)); |
|---|
| 2345 | 2350 | |
|---|
| 2346 | | - ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); |
|---|
| 2351 | + ret = video_register_device(vfd, VFL_TYPE_VIDEO, 0); |
|---|
| 2347 | 2352 | if (ret) { |
|---|
| 2348 | 2353 | v4l2_err(&fdp1->v4l2_dev, "Failed to register video device\n"); |
|---|
| 2349 | 2354 | goto release_m2m; |
|---|
| 2350 | 2355 | } |
|---|
| 2351 | 2356 | |
|---|
| 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); |
|---|
| 2354 | 2359 | |
|---|
| 2355 | 2360 | /* Power up the cells to read HW */ |
|---|
| 2356 | 2361 | 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; |
|---|
| 2358 | 2365 | |
|---|
| 2359 | 2366 | hw_version = fdp1_read(fdp1, FD1_IP_INTDATA); |
|---|
| 2360 | 2367 | switch (hw_version) { |
|---|
| .. | .. |
|---|
| 2375 | 2382 | break; |
|---|
| 2376 | 2383 | default: |
|---|
| 2377 | 2384 | dev_err(fdp1->dev, "FDP1 Unidentifiable (0x%08x)\n", |
|---|
| 2378 | | - hw_version); |
|---|
| 2385 | + hw_version); |
|---|
| 2379 | 2386 | } |
|---|
| 2380 | 2387 | |
|---|
| 2381 | 2388 | /* Allow the hw to sleep until an open call puts it to use */ |
|---|
| .. | .. |
|---|
| 2383 | 2390 | |
|---|
| 2384 | 2391 | return 0; |
|---|
| 2385 | 2392 | |
|---|
| 2393 | +disable_pm: |
|---|
| 2394 | + pm_runtime_disable(fdp1->dev); |
|---|
| 2395 | + |
|---|
| 2386 | 2396 | release_m2m: |
|---|
| 2387 | 2397 | v4l2_m2m_release(fdp1->m2m_dev); |
|---|
| 2388 | 2398 | |
|---|
| 2389 | 2399 | unreg_dev: |
|---|
| 2390 | 2400 | v4l2_device_unregister(&fdp1->v4l2_dev); |
|---|
| 2391 | 2401 | |
|---|
| 2402 | +put_dev: |
|---|
| 2403 | + rcar_fcp_put(fdp1->fcp); |
|---|
| 2392 | 2404 | return ret; |
|---|
| 2393 | 2405 | } |
|---|
| 2394 | 2406 | |
|---|
| .. | .. |
|---|
| 2400 | 2412 | video_unregister_device(&fdp1->vfd); |
|---|
| 2401 | 2413 | v4l2_device_unregister(&fdp1->v4l2_dev); |
|---|
| 2402 | 2414 | pm_runtime_disable(&pdev->dev); |
|---|
| 2415 | + rcar_fcp_put(fdp1->fcp); |
|---|
| 2403 | 2416 | |
|---|
| 2404 | 2417 | return 0; |
|---|
| 2405 | 2418 | } |
|---|