hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/media/platform/exynos4-is/fimc-capture.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Samsung S5P/EXYNOS4 SoC series camera interface (camera capture) driver
34 *
45 * Copyright (C) 2010 - 2012 Samsung Electronics Co., Ltd.
56 * Sylwester Nawrocki <s.nawrocki@samsung.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118
129 #include <linux/module.h>
....@@ -24,6 +21,7 @@
2421 #include <media/v4l2-device.h>
2522 #include <media/v4l2-ioctl.h>
2623 #include <media/v4l2-mem2mem.h>
24
+#include <media/v4l2-rect.h>
2725 #include <media/videobuf2-v4l2.h>
2826 #include <media/videobuf2-dma-contig.h>
2927
....@@ -480,7 +478,7 @@
480478 goto unlock;
481479
482480 set_bit(ST_CAPT_BUSY, &fimc->state);
483
- ret = pm_runtime_get_sync(&fimc->pdev->dev);
481
+ ret = pm_runtime_resume_and_get(&fimc->pdev->dev);
484482 if (ret < 0)
485483 goto unlock;
486484
....@@ -495,17 +493,6 @@
495493
496494 ret = fimc_pipeline_call(ve, open, &ve->vdev.entity, true);
497495
498
- if (ret == 0 && vc->user_subdev_api && vc->inh_sensor_ctrls) {
499
- /*
500
- * Recreate controls of the the video node to drop
501
- * any controls inherited from the sensor subdev.
502
- */
503
- fimc_ctrls_delete(vc->ctx);
504
-
505
- ret = fimc_ctrls_create(vc->ctx);
506
- if (ret == 0)
507
- vc->inh_sensor_ctrls = false;
508
- }
509496 if (ret == 0)
510497 ve->vdev.entity.use_count++;
511498
....@@ -728,13 +715,12 @@
728715 {
729716 struct fimc_dev *fimc = video_drvdata(file);
730717
731
- __fimc_vidioc_querycap(&fimc->pdev->dev, cap, V4L2_CAP_STREAMING |
732
- V4L2_CAP_VIDEO_CAPTURE_MPLANE);
718
+ __fimc_vidioc_querycap(&fimc->pdev->dev, cap);
733719 return 0;
734720 }
735721
736
-static int fimc_cap_enum_fmt_mplane(struct file *file, void *priv,
737
- struct v4l2_fmtdesc *f)
722
+static int fimc_cap_enum_fmt(struct file *file, void *priv,
723
+ struct v4l2_fmtdesc *f)
738724 {
739725 struct fimc_fmt *fmt;
740726
....@@ -742,10 +728,7 @@
742728 f->index);
743729 if (!fmt)
744730 return -EINVAL;
745
- strncpy(f->description, fmt->name, sizeof(f->description) - 1);
746731 f->pixelformat = fmt->fourcc;
747
- if (fmt->fourcc == MEDIA_BUS_FMT_JPEG_1X8)
748
- f->flags |= V4L2_FMT_FLAG_COMPRESSED;
749732 return 0;
750733 }
751734
....@@ -1087,7 +1070,7 @@
10871070 fimc_md_graph_unlock(ve);
10881071
10891072 if (sd)
1090
- strlcpy(i->name, sd->name, sizeof(i->name));
1073
+ strscpy(i->name, sd->name, sizeof(i->name));
10911074
10921075 return 0;
10931076 }
....@@ -1250,8 +1233,11 @@
12501233 if (ret < 0)
12511234 return ret;
12521235
1253
- media_pipeline_stop(&vc->ve.vdev.entity);
1254
- vc->streaming = false;
1236
+ if (vc->streaming) {
1237
+ media_pipeline_stop(&vc->ve.vdev.entity);
1238
+ vc->streaming = false;
1239
+ }
1240
+
12551241 return 0;
12561242 }
12571243
....@@ -1283,7 +1269,7 @@
12831269 case V4L2_SEL_TGT_COMPOSE_DEFAULT:
12841270 case V4L2_SEL_TGT_COMPOSE_BOUNDS:
12851271 f = &ctx->d_frame;
1286
- /* fall through */
1272
+ fallthrough;
12871273 case V4L2_SEL_TGT_CROP_BOUNDS:
12881274 case V4L2_SEL_TGT_CROP_DEFAULT:
12891275 s->r.left = 0;
....@@ -1294,7 +1280,7 @@
12941280
12951281 case V4L2_SEL_TGT_COMPOSE:
12961282 f = &ctx->d_frame;
1297
- /* fall through */
1283
+ fallthrough;
12981284 case V4L2_SEL_TGT_CROP:
12991285 s->r.left = f->offs_h;
13001286 s->r.top = f->offs_v;
....@@ -1304,19 +1290,6 @@
13041290 }
13051291
13061292 return -EINVAL;
1307
-}
1308
-
1309
-/* Return 1 if rectangle a is enclosed in rectangle b, or 0 otherwise. */
1310
-static int enclosed_rectangle(struct v4l2_rect *a, struct v4l2_rect *b)
1311
-{
1312
- if (a->left < b->left || a->top < b->top)
1313
- return 0;
1314
- if (a->left + a->width > b->left + b->width)
1315
- return 0;
1316
- if (a->top + a->height > b->top + b->height)
1317
- return 0;
1318
-
1319
- return 1;
13201293 }
13211294
13221295 static int fimc_cap_s_selection(struct file *file, void *fh,
....@@ -1341,11 +1314,11 @@
13411314 fimc_capture_try_selection(ctx, &rect, s->target);
13421315
13431316 if (s->flags & V4L2_SEL_FLAG_LE &&
1344
- !enclosed_rectangle(&rect, &s->r))
1317
+ !v4l2_rect_enclosed(&rect, &s->r))
13451318 return -ERANGE;
13461319
13471320 if (s->flags & V4L2_SEL_FLAG_GE &&
1348
- !enclosed_rectangle(&s->r, &rect))
1321
+ !v4l2_rect_enclosed(&s->r, &rect))
13491322 return -ERANGE;
13501323
13511324 s->r = rect;
....@@ -1361,7 +1334,7 @@
13611334 static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops = {
13621335 .vidioc_querycap = fimc_cap_querycap,
13631336
1364
- .vidioc_enum_fmt_vid_cap_mplane = fimc_cap_enum_fmt_mplane,
1337
+ .vidioc_enum_fmt_vid_cap = fimc_cap_enum_fmt,
13651338 .vidioc_try_fmt_vid_cap_mplane = fimc_cap_try_fmt_mplane,
13661339 .vidioc_s_fmt_vid_cap_mplane = fimc_cap_s_fmt_mplane,
13671340 .vidioc_g_fmt_vid_cap_mplane = fimc_cap_g_fmt_mplane,
....@@ -1415,7 +1388,7 @@
14151388
14161389 vc->input = sd->grp_id;
14171390
1418
- if (vc->user_subdev_api || vc->inh_sensor_ctrls)
1391
+ if (vc->user_subdev_api)
14191392 return 0;
14201393
14211394 /* Inherit V4L2 controls from the image sensor subdev. */
....@@ -1424,7 +1397,7 @@
14241397 return 0;
14251398
14261399 return v4l2_ctrl_add_handler(&vc->ctx->ctrls.handler,
1427
- sensor->ctrl_handler, NULL);
1400
+ sensor->ctrl_handler, NULL, true);
14281401 }
14291402
14301403 static const struct media_entity_operations fimc_sd_media_ops = {
....@@ -1618,7 +1591,7 @@
16181591 switch (sel->target) {
16191592 case V4L2_SEL_TGT_COMPOSE_BOUNDS:
16201593 f = &ctx->d_frame;
1621
- /* fall through */
1594
+ fallthrough;
16221595 case V4L2_SEL_TGT_CROP_BOUNDS:
16231596 r->width = f->o_width;
16241597 r->height = f->o_height;
....@@ -1765,6 +1738,7 @@
17651738 vfd->release = video_device_release_empty;
17661739 vfd->queue = q;
17671740 vfd->lock = &fimc->lock;
1741
+ vfd->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_CAPTURE_MPLANE;
17681742
17691743 video_set_drvdata(vfd, fimc);
17701744 vid_cap = &fimc->vid_cap;
....@@ -1814,7 +1788,7 @@
18141788 if (ret)
18151789 goto err_me_cleanup;
18161790
1817
- ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);
1791
+ ret = video_register_device(vfd, VFL_TYPE_VIDEO, -1);
18181792 if (ret)
18191793 goto err_ctrl_free;
18201794
....@@ -1904,6 +1878,7 @@
19041878 return ret;
19051879
19061880 sd->entity.ops = &fimc_sd_media_ops;
1881
+ sd->entity.function = MEDIA_ENT_F_PROC_VIDEO_SCALER;
19071882 sd->internal_ops = &fimc_capture_sd_internal_ops;
19081883 v4l2_set_subdevdata(sd, fimc);
19091884 return 0;