[media] v4l2-subdev: add support for the new enum_frame_size 'which' field
authorHans Verkuil <hans.verkuil@cisco.com>
Wed, 4 Mar 2015 09:47:58 +0000 (01:47 -0800)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 23 Mar 2015 18:48:55 +0000 (11:48 -0700)
Support the new 'which' field in the enum_frame_size ops. Most drivers do not
need to be changed since they always returns the same enumeration regardless
of the 'which' field.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
21 files changed:
drivers/media/i2c/s5c73m3/s5c73m3-core.c
drivers/media/platform/am437x/am437x-vpfe.c
drivers/media/platform/omap3isp/ispccdc.c
drivers/media/platform/omap3isp/ispccp2.c
drivers/media/platform/omap3isp/ispcsi2.c
drivers/media/platform/omap3isp/isppreview.c
drivers/media/platform/omap3isp/ispresizer.c
drivers/media/platform/vsp1/vsp1_hsit.c
drivers/media/platform/vsp1/vsp1_lif.c
drivers/media/platform/vsp1/vsp1_lut.c
drivers/media/platform/vsp1/vsp1_rwpf.c
drivers/media/platform/vsp1/vsp1_sru.c
drivers/media/platform/vsp1/vsp1_uds.c
drivers/staging/media/davinci_vpfe/dm365_ipipe.c
drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
drivers/staging/media/davinci_vpfe/dm365_isif.c
drivers/staging/media/davinci_vpfe/dm365_resizer.c
drivers/staging/media/omap4iss/iss_csi2.c
drivers/staging/media/omap4iss/iss_ipipe.c
drivers/staging/media/omap4iss/iss_ipipeif.c
drivers/staging/media/omap4iss/iss_resizer.c

index 257a335c0ece4a091462bff9b1ce2de54646d6ce..08b234bd2962cdcfe7674b05ded5fb0fb65b096b 100644 (file)
@@ -1251,6 +1251,7 @@ static int s5c73m3_oif_enum_frame_size(struct v4l2_subdev *sd,
                                   struct v4l2_subdev_pad_config *cfg,
                                   struct v4l2_subdev_frame_size_enum *fse)
 {
+       struct s5c73m3 *state = oif_sd_to_s5c73m3(sd);
        int idx;
 
        if (fse->pad == OIF_SOURCE_PAD) {
@@ -1260,11 +1261,25 @@ static int s5c73m3_oif_enum_frame_size(struct v4l2_subdev *sd,
                switch (fse->code) {
                case S5C73M3_JPEG_FMT:
                case S5C73M3_ISP_FMT: {
-                       struct v4l2_mbus_framefmt *mf =
-                               v4l2_subdev_get_try_format(sd, cfg, OIF_ISP_PAD);
+                       unsigned w, h;
+
+                       if (fse->which == V4L2_SUBDEV_FORMAT_TRY) {
+                               struct v4l2_mbus_framefmt *mf;
+
+                               mf = v4l2_subdev_get_try_format(sd, cfg,
+                                                               OIF_ISP_PAD);
+
+                               w = mf->width;
+                               h = mf->height;
+                       } else {
+                               const struct s5c73m3_frame_size *fs;
 
-                       fse->max_width = fse->min_width = mf->width;
-                       fse->max_height = fse->min_height = mf->height;
+                               fs = state->oif_pix_size[RES_ISP];
+                               w = fs->width;
+                               h = fs->height;
+                       }
+                       fse->max_width = fse->min_width = w;
+                       fse->max_height = fse->min_height = h;
                        return 0;
                }
                default:
index 8b413be8d598f0574a9bd982e8b834b55c8829af..73fdb0d6b0929a172dc82d8f8bd22947fb8f367c 100644 (file)
@@ -1645,6 +1645,7 @@ static int vpfe_enum_size(struct file *file, void  *priv,
        fse.index = fsize->index;
        fse.pad = 0;
        fse.code = mbus.code;
+       fse.which = V4L2_SUBDEV_FORMAT_ACTIVE;
        ret = v4l2_subdev_call(sdinfo->sd, pad, enum_frame_size, NULL, &fse);
        if (ret)
                return -EINVAL;
index 818aa524edbca81f80a9139bce87f8e58c7f8a71..6e0291bca73fad5f346520bb06c69ed6342f8dca 100644 (file)
@@ -2195,7 +2195,7 @@ static int ccdc_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       ccdc_try_format(ccdc, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       ccdc_try_format(ccdc, cfg, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -2205,7 +2205,7 @@ static int ccdc_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       ccdc_try_format(ccdc, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       ccdc_try_format(ccdc, cfg, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;
 
index 1d79368c1ba6eb7a4c60d814d7f418d28ae06752..44c20fa8501a5ce0856eb0face7fe395faa4f6ad 100644 (file)
@@ -723,7 +723,7 @@ static int ccp2_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       ccp2_try_format(ccp2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       ccp2_try_format(ccp2, cfg, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -733,7 +733,7 @@ static int ccp2_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       ccp2_try_format(ccp2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       ccp2_try_format(ccp2, cfg, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;
 
index bde734cba86ec140a97741f74342a2cd5bfd040a..bbadf6653db7b517444bc364372700ba4012d01f 100644 (file)
@@ -944,7 +944,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       csi2_try_format(csi2, cfg, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -954,7 +954,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       csi2_try_format(csi2, cfg, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;
 
index 0571c57dbae077f9232ee0ba7912393a3fac8ff5..15cb254ccc39df0eba6b3f07d5e68e2245ae182b 100644 (file)
@@ -1905,7 +1905,7 @@ static int preview_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       preview_try_format(prev, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       preview_try_format(prev, cfg, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -1915,7 +1915,7 @@ static int preview_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       preview_try_format(prev, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       preview_try_format(prev, cfg, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;
 
index 02549fa8a94dc4b013920f81c2d727f972cb7621..7cfb43dc0ffd7764c89bc95eae87ac97e53271e8 100644 (file)
@@ -1451,7 +1451,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       resizer_try_format(res, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       resizer_try_format(res, cfg, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -1461,7 +1461,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       resizer_try_format(res, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       resizer_try_format(res, cfg, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;
 
index d226b3ff5e30a4dffdd8b9d2e759037414d7902d..8ffb817ae5255809498f0716a6d91604ad31880c 100644 (file)
@@ -76,9 +76,11 @@ static int hsit_enum_frame_size(struct v4l2_subdev *subdev,
                                struct v4l2_subdev_pad_config *cfg,
                                struct v4l2_subdev_frame_size_enum *fse)
 {
+       struct vsp1_hsit *hsit = to_hsit(subdev);
        struct v4l2_mbus_framefmt *format;
 
-       format = v4l2_subdev_get_try_format(subdev, cfg, fse->pad);
+       format = vsp1_entity_get_pad_format(&hsit->entity, cfg, fse->pad,
+                                           fse->which);
 
        if (fse->index || fse->code != format->code)
                return -EINVAL;
index 60f1bd85d48af1509252b46d8337f854fd64193e..39fa5ef20fbb725d79f05d3b038dda706438dfe3 100644 (file)
@@ -109,9 +109,11 @@ static int lif_enum_frame_size(struct v4l2_subdev *subdev,
                               struct v4l2_subdev_pad_config *cfg,
                               struct v4l2_subdev_frame_size_enum *fse)
 {
+       struct vsp1_lif *lif = to_lif(subdev);
        struct v4l2_mbus_framefmt *format;
 
-       format = v4l2_subdev_get_try_format(subdev, cfg, LIF_PAD_SINK);
+       format = vsp1_entity_get_pad_format(&lif->entity, cfg, LIF_PAD_SINK,
+                                           fse->which);
 
        if (fse->index || fse->code != format->code)
                return -EINVAL;
index 8aa8c111301ca670ef382f315b0092aa0ae2ef07..656ec272a414b6c0bbfb00f5cd0409d4489368d5 100644 (file)
@@ -117,9 +117,11 @@ static int lut_enum_frame_size(struct v4l2_subdev *subdev,
                               struct v4l2_subdev_pad_config *cfg,
                               struct v4l2_subdev_frame_size_enum *fse)
 {
+       struct vsp1_lut *lut = to_lut(subdev);
        struct v4l2_mbus_framefmt *format;
 
-       format = v4l2_subdev_get_try_format(subdev, cfg, fse->pad);
+       format = vsp1_entity_get_pad_format(&lut->entity, cfg,
+                                           fse->pad, fse->which);
 
        if (fse->index || fse->code != format->code)
                return -EINVAL;
index a083d85e84b4666d2a647ec8f6aa1dcad7dc10cd..fa71f4695e1684dc97d622da7d6899245c665332 100644 (file)
@@ -48,7 +48,8 @@ int vsp1_rwpf_enum_frame_size(struct v4l2_subdev *subdev,
        struct vsp1_rwpf *rwpf = to_rwpf(subdev);
        struct v4l2_mbus_framefmt *format;
 
-       format = v4l2_subdev_get_try_format(subdev, cfg, fse->pad);
+       format = vsp1_entity_get_pad_format(&rwpf->entity, cfg, fse->pad,
+                                           fse->which);
 
        if (fse->index || fse->code != format->code)
                return -EINVAL;
index 554340d4e2b33ed3b890518b9433e106c63d53cd..6310acab60e79b3d97978950ce97c3155fed2b29 100644 (file)
@@ -200,9 +200,11 @@ static int sru_enum_frame_size(struct v4l2_subdev *subdev,
                               struct v4l2_subdev_pad_config *cfg,
                               struct v4l2_subdev_frame_size_enum *fse)
 {
+       struct vsp1_sru *sru = to_sru(subdev);
        struct v4l2_mbus_framefmt *format;
 
-       format = v4l2_subdev_get_try_format(subdev, cfg, SRU_PAD_SINK);
+       format = vsp1_entity_get_pad_format(&sru->entity, cfg,
+                                           SRU_PAD_SINK, fse->which);
 
        if (fse->index || fse->code != format->code)
                return -EINVAL;
index ef4d307f80d14376888ae51506123e78e706db28..ccc8243e3493d7728167ade8486e32ebe3e48506 100644 (file)
@@ -204,9 +204,11 @@ static int uds_enum_frame_size(struct v4l2_subdev *subdev,
                               struct v4l2_subdev_pad_config *cfg,
                               struct v4l2_subdev_frame_size_enum *fse)
 {
+       struct vsp1_uds *uds = to_uds(subdev);
        struct v4l2_mbus_framefmt *format;
 
-       format = v4l2_subdev_get_try_format(subdev, cfg, UDS_PAD_SINK);
+       format = vsp1_entity_get_pad_format(&uds->entity, cfg,
+                                           UDS_PAD_SINK, fse->which);
 
        if (fse->index || fse->code != format->code)
                return -EINVAL;
index 715f1e6b8fe2c7b5671ed176c94cfa1ec1a33271..1bbb90ce00867793dc49e8622f4e4c17c94da29d 100644 (file)
@@ -1548,8 +1548,7 @@ ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       ipipe_try_format(ipipe, cfg, fse->pad, &format,
-                          V4L2_SUBDEV_FORMAT_TRY);
+       ipipe_try_format(ipipe, cfg, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -1559,8 +1558,7 @@ ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       ipipe_try_format(ipipe, cfg, fse->pad, &format,
-                          V4L2_SUBDEV_FORMAT_TRY);
+       ipipe_try_format(ipipe, cfg, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;
 
index 68a9bb04922af7a19214f16f6890198a4f8b4dc2..0495bccd517257b9adaa6bb42006acd7c0129d5c 100644 (file)
@@ -653,8 +653,7 @@ ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *c
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       ipipeif_try_format(ipipeif, cfg, fse->pad, &format,
-                          V4L2_SUBDEV_FORMAT_TRY);
+       ipipeif_try_format(ipipeif, cfg, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -664,8 +663,7 @@ ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *c
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       ipipeif_try_format(ipipeif, cfg, fse->pad, &format,
-                          V4L2_SUBDEV_FORMAT_TRY);
+       ipipeif_try_format(ipipeif, cfg, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;
 
index 02b6bdc0d7711373b5a6abe1ee6e9cca0817ef38..80907b46441294989db1a4ae4659efd49c2266fa 100644 (file)
@@ -1489,7 +1489,7 @@ isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
        format.format.code = fse->code;
        format.format.width = 1;
        format.format.height = 1;
-       format.which = V4L2_SUBDEV_FORMAT_TRY;
+       format.which = fse->which;
        isif_try_format(isif, cfg, &format);
        fse->min_width = format.format.width;
        fse->min_height = format.format.height;
@@ -1501,7 +1501,7 @@ isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
        format.format.code = fse->code;
        format.format.width = -1;
        format.format.height = -1;
-       format.which = V4L2_SUBDEV_FORMAT_TRY;
+       format.which = fse->which;
        isif_try_format(isif, cfg, &format);
        fse->max_width = format.format.width;
        fse->max_height = format.format.height;
index acd9cb56f0f3469b42d10aff0144d81e42fef3b8..fee44dd45ccd2457fd7333fcb4437b56aa5e9bf6 100644 (file)
@@ -1484,8 +1484,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       resizer_try_format(sd, cfg, fse->pad, &format,
-                           V4L2_SUBDEV_FORMAT_TRY);
+       resizer_try_format(sd, cfg, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -1495,8 +1494,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       resizer_try_format(sd, cfg, fse->pad, &format,
-                          V4L2_SUBDEV_FORMAT_TRY);
+       resizer_try_format(sd, cfg, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;
 
index 2d5079deb631aa24221462d537515ea38e2d15c3..d7ff7698a067a0f98d55a015d193c1e166eb5ba6 100644 (file)
@@ -943,7 +943,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       csi2_try_format(csi2, cfg, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -953,7 +953,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       csi2_try_format(csi2, cfg, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;
 
index fc319822a33e0a03b8d1450273a10713974ac1a3..ff1d8cf3d284737b1eae2d2ae477e016d16e322f 100644 (file)
@@ -280,7 +280,7 @@ static int ipipe_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       ipipe_try_format(ipipe, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       ipipe_try_format(ipipe, cfg, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -290,7 +290,7 @@ static int ipipe_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       ipipe_try_format(ipipe, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
+       ipipe_try_format(ipipe, cfg, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;
 
index b8e7277499d23a0b13cdf1dbaf7e3371ac958525..8000bd3bca343db725edd252f57dffa0915993a0 100644 (file)
@@ -492,8 +492,7 @@ static int ipipeif_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       ipipeif_try_format(ipipeif, cfg, fse->pad, &format,
-                          V4L2_SUBDEV_FORMAT_TRY);
+       ipipeif_try_format(ipipeif, cfg, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -503,8 +502,7 @@ static int ipipeif_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       ipipeif_try_format(ipipeif, cfg, fse->pad, &format,
-                          V4L2_SUBDEV_FORMAT_TRY);
+       ipipeif_try_format(ipipeif, cfg, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;
 
index 075b876e8e6803ab40f263eb16cdf1a382dd3b97..ded9066c64d7c116eac0b1ea84935be834013fb5 100644 (file)
@@ -554,8 +554,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = 1;
        format.height = 1;
-       resizer_try_format(resizer, cfg, fse->pad, &format,
-                          V4L2_SUBDEV_FORMAT_TRY);
+       resizer_try_format(resizer, cfg, fse->pad, &format, fse->which);
        fse->min_width = format.width;
        fse->min_height = format.height;
 
@@ -565,8 +564,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
        format.code = fse->code;
        format.width = -1;
        format.height = -1;
-       resizer_try_format(resizer, cfg, fse->pad, &format,
-                          V4L2_SUBDEV_FORMAT_TRY);
+       resizer_try_format(resizer, cfg, fse->pad, &format, fse->which);
        fse->max_width = format.width;
        fse->max_height = format.height;