aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2015-03-04 04:47:54 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-03-23 14:41:36 -0400
commitf7234138f14c2296c5eb6b8224abe00b507faf3f (patch)
tree947508529c06cf0c3ff36a71071725ffdb83e3b1
parent3d945be05ac1e806af075e9315bc1b3409adae2b (diff)
[media] v4l2-subdev: replace v4l2_subdev_fh by v4l2_subdev_pad_config
If a subdevice pad op is called from a bridge driver, then there is no v4l2_subdev_fh struct that can be passed to the subdevice. This made it hard to use such subdevs from a bridge driver. This patch replaces the v4l2_subdev_fh pointer by a v4l2_subdev_pad_config pointer in the pad ops. This allows bridge drivers to use the various try_ pad ops by creating a v4l2_subdev_pad_config struct and passing it along to the pad op. The v4l2_subdev_get_try_* macros had to be changed because of this, so I also took the opportunity to use the full name of the v4l2_subdev_get_try_* functions in the __V4L2_SUBDEV_MK_GET_TRY macro arguments: if you now do 'git grep v4l2_subdev_get_try_format' you will actually find the header where it is defined. One remark regarding the drivers/staging/media/davinci_vpfe patches: the *_init_formats() functions assumed that fh could be NULL. However, that's not true for this driver, it's always set. This is almost certainly a copy and paste from the omap3isp driver. I've updated the code to reflect the fact that fh is never NULL. 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: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/i2c/adv7180.c10
-rw-r--r--drivers/media/i2c/adv7511.c16
-rw-r--r--drivers/media/i2c/adv7604.c12
-rw-r--r--drivers/media/i2c/m5mols/m5mols_core.c16
-rw-r--r--drivers/media/i2c/mt9m032.c34
-rw-r--r--drivers/media/i2c/mt9p031.c36
-rw-r--r--drivers/media/i2c/mt9t001.c36
-rw-r--r--drivers/media/i2c/mt9v032.c36
-rw-r--r--drivers/media/i2c/noon010pc30.c17
-rw-r--r--drivers/media/i2c/ov9650.c16
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3-core.c51
-rw-r--r--drivers/media/i2c/s5k4ecgx.c16
-rw-r--r--drivers/media/i2c/s5k5baf.c38
-rw-r--r--drivers/media/i2c/s5k6a3.c18
-rw-r--r--drivers/media/i2c/s5k6aa.c34
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c80
-rw-r--r--drivers/media/i2c/tvp514x.c12
-rw-r--r--drivers/media/i2c/tvp7002.c14
-rw-r--r--drivers/media/platform/exynos4-is/fimc-capture.c22
-rw-r--r--drivers/media/platform/exynos4-is/fimc-isp.c28
-rw-r--r--drivers/media/platform/exynos4-is/fimc-lite.c33
-rw-r--r--drivers/media/platform/exynos4-is/mipi-csis.c16
-rw-r--r--drivers/media/platform/omap3isp/ispccdc.c82
-rw-r--r--drivers/media/platform/omap3isp/ispccp2.c44
-rw-r--r--drivers/media/platform/omap3isp/ispcsi2.c40
-rw-r--r--drivers/media/platform/omap3isp/isppreview.c70
-rw-r--r--drivers/media/platform/omap3isp/ispresizer.c78
-rw-r--r--drivers/media/platform/s3c-camif/camif-capture.c18
-rw-r--r--drivers/media/platform/vsp1/vsp1_bru.c40
-rw-r--r--drivers/media/platform/vsp1/vsp1_entity.c16
-rw-r--r--drivers/media/platform/vsp1/vsp1_entity.h4
-rw-r--r--drivers/media/platform/vsp1/vsp1_hsit.c16
-rw-r--r--drivers/media/platform/vsp1/vsp1_lif.c18
-rw-r--r--drivers/media/platform/vsp1/vsp1_lut.c18
-rw-r--r--drivers/media/platform/vsp1/vsp1_rwpf.c36
-rw-r--r--drivers/media/platform/vsp1/vsp1_rwpf.h12
-rw-r--r--drivers/media/platform/vsp1/vsp1_sru.c26
-rw-r--r--drivers/media/platform/vsp1/vsp1_uds.c26
-rw-r--r--drivers/media/v4l2-core/v4l2-subdev.c18
-rw-r--r--drivers/staging/media/davinci_vpfe/dm365_ipipe.c49
-rw-r--r--drivers/staging/media/davinci_vpfe/dm365_ipipeif.c47
-rw-r--r--drivers/staging/media/davinci_vpfe/dm365_isif.c79
-rw-r--r--drivers/staging/media/davinci_vpfe/dm365_resizer.c57
-rw-r--r--drivers/staging/media/omap4iss/iss_csi2.c40
-rw-r--r--drivers/staging/media/omap4iss/iss_ipipe.c42
-rw-r--r--drivers/staging/media/omap4iss/iss_ipipeif.c48
-rw-r--r--drivers/staging/media/omap4iss/iss_resizer.c42
-rw-r--r--include/media/v4l2-subdev.h53
48 files changed, 813 insertions, 797 deletions
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index b75878c27c2a..a493c0b0b5fe 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -582,7 +582,7 @@ static void adv7180_exit_controls(struct adv7180_state *state)
582} 582}
583 583
584static int adv7180_enum_mbus_code(struct v4l2_subdev *sd, 584static int adv7180_enum_mbus_code(struct v4l2_subdev *sd,
585 struct v4l2_subdev_fh *fh, 585 struct v4l2_subdev_pad_config *cfg,
586 struct v4l2_subdev_mbus_code_enum *code) 586 struct v4l2_subdev_mbus_code_enum *code)
587{ 587{
588 if (code->index != 0) 588 if (code->index != 0)
@@ -645,13 +645,13 @@ static int adv7180_set_field_mode(struct adv7180_state *state)
645} 645}
646 646
647static int adv7180_get_pad_format(struct v4l2_subdev *sd, 647static int adv7180_get_pad_format(struct v4l2_subdev *sd,
648 struct v4l2_subdev_fh *fh, 648 struct v4l2_subdev_pad_config *cfg,
649 struct v4l2_subdev_format *format) 649 struct v4l2_subdev_format *format)
650{ 650{
651 struct adv7180_state *state = to_state(sd); 651 struct adv7180_state *state = to_state(sd);
652 652
653 if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 653 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
654 format->format = *v4l2_subdev_get_try_format(fh, 0); 654 format->format = *v4l2_subdev_get_try_format(sd, cfg, 0);
655 } else { 655 } else {
656 adv7180_mbus_fmt(sd, &format->format); 656 adv7180_mbus_fmt(sd, &format->format);
657 format->format.field = state->field; 657 format->format.field = state->field;
@@ -661,7 +661,7 @@ static int adv7180_get_pad_format(struct v4l2_subdev *sd,
661} 661}
662 662
663static int adv7180_set_pad_format(struct v4l2_subdev *sd, 663static int adv7180_set_pad_format(struct v4l2_subdev *sd,
664 struct v4l2_subdev_fh *fh, 664 struct v4l2_subdev_pad_config *cfg,
665 struct v4l2_subdev_format *format) 665 struct v4l2_subdev_format *format)
666{ 666{
667 struct adv7180_state *state = to_state(sd); 667 struct adv7180_state *state = to_state(sd);
@@ -686,7 +686,7 @@ static int adv7180_set_pad_format(struct v4l2_subdev *sd,
686 adv7180_set_power(state, true); 686 adv7180_set_power(state, true);
687 } 687 }
688 } else { 688 } else {
689 framefmt = v4l2_subdev_get_try_format(fh, 0); 689 framefmt = v4l2_subdev_get_try_format(sd, cfg, 0);
690 *framefmt = format->format; 690 *framefmt = format->format;
691 } 691 }
692 692
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index 81736aaf0f31..03ea62f9c074 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -810,7 +810,7 @@ static int adv7511_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
810} 810}
811 811
812static int adv7511_enum_mbus_code(struct v4l2_subdev *sd, 812static int adv7511_enum_mbus_code(struct v4l2_subdev *sd,
813 struct v4l2_subdev_fh *fh, 813 struct v4l2_subdev_pad_config *cfg,
814 struct v4l2_subdev_mbus_code_enum *code) 814 struct v4l2_subdev_mbus_code_enum *code)
815{ 815{
816 if (code->pad != 0) 816 if (code->pad != 0)
@@ -842,8 +842,9 @@ static void adv7511_fill_format(struct adv7511_state *state,
842 format->field = V4L2_FIELD_NONE; 842 format->field = V4L2_FIELD_NONE;
843} 843}
844 844
845static int adv7511_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 845static int adv7511_get_fmt(struct v4l2_subdev *sd,
846 struct v4l2_subdev_format *format) 846 struct v4l2_subdev_pad_config *cfg,
847 struct v4l2_subdev_format *format)
847{ 848{
848 struct adv7511_state *state = get_adv7511_state(sd); 849 struct adv7511_state *state = get_adv7511_state(sd);
849 850
@@ -855,7 +856,7 @@ static int adv7511_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
855 if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 856 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
856 struct v4l2_mbus_framefmt *fmt; 857 struct v4l2_mbus_framefmt *fmt;
857 858
858 fmt = v4l2_subdev_get_try_format(fh, format->pad); 859 fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
859 format->format.code = fmt->code; 860 format->format.code = fmt->code;
860 format->format.colorspace = fmt->colorspace; 861 format->format.colorspace = fmt->colorspace;
861 format->format.ycbcr_enc = fmt->ycbcr_enc; 862 format->format.ycbcr_enc = fmt->ycbcr_enc;
@@ -870,8 +871,9 @@ static int adv7511_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
870 return 0; 871 return 0;
871} 872}
872 873
873static int adv7511_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 874static int adv7511_set_fmt(struct v4l2_subdev *sd,
874 struct v4l2_subdev_format *format) 875 struct v4l2_subdev_pad_config *cfg,
876 struct v4l2_subdev_format *format)
875{ 877{
876 struct adv7511_state *state = get_adv7511_state(sd); 878 struct adv7511_state *state = get_adv7511_state(sd);
877 /* 879 /*
@@ -905,7 +907,7 @@ static int adv7511_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
905 if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 907 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
906 struct v4l2_mbus_framefmt *fmt; 908 struct v4l2_mbus_framefmt *fmt;
907 909
908 fmt = v4l2_subdev_get_try_format(fh, format->pad); 910 fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
909 fmt->code = format->format.code; 911 fmt->code = format->format.code;
910 fmt->colorspace = format->format.colorspace; 912 fmt->colorspace = format->format.colorspace;
911 fmt->ycbcr_enc = format->format.ycbcr_enc; 913 fmt->ycbcr_enc = format->format.ycbcr_enc;
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index aaab9c9cebee..1e58537c3ea3 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1734,7 +1734,7 @@ static int adv76xx_s_routing(struct v4l2_subdev *sd,
1734} 1734}
1735 1735
1736static int adv76xx_enum_mbus_code(struct v4l2_subdev *sd, 1736static int adv76xx_enum_mbus_code(struct v4l2_subdev *sd,
1737 struct v4l2_subdev_fh *fh, 1737 struct v4l2_subdev_pad_config *cfg,
1738 struct v4l2_subdev_mbus_code_enum *code) 1738 struct v4l2_subdev_mbus_code_enum *code)
1739{ 1739{
1740 struct adv76xx_state *state = to_state(sd); 1740 struct adv76xx_state *state = to_state(sd);
@@ -1811,7 +1811,8 @@ static void adv76xx_setup_format(struct adv76xx_state *state)
1811 state->format->swap_cb_cr ? ADV76XX_OP_SWAP_CB_CR : 0); 1811 state->format->swap_cb_cr ? ADV76XX_OP_SWAP_CB_CR : 0);
1812} 1812}
1813 1813
1814static int adv76xx_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1814static int adv76xx_get_format(struct v4l2_subdev *sd,
1815 struct v4l2_subdev_pad_config *cfg,
1815 struct v4l2_subdev_format *format) 1816 struct v4l2_subdev_format *format)
1816{ 1817{
1817 struct adv76xx_state *state = to_state(sd); 1818 struct adv76xx_state *state = to_state(sd);
@@ -1824,7 +1825,7 @@ static int adv76xx_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1824 if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 1825 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
1825 struct v4l2_mbus_framefmt *fmt; 1826 struct v4l2_mbus_framefmt *fmt;
1826 1827
1827 fmt = v4l2_subdev_get_try_format(fh, format->pad); 1828 fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
1828 format->format.code = fmt->code; 1829 format->format.code = fmt->code;
1829 } else { 1830 } else {
1830 format->format.code = state->format->code; 1831 format->format.code = state->format->code;
@@ -1833,7 +1834,8 @@ static int adv76xx_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1833 return 0; 1834 return 0;
1834} 1835}
1835 1836
1836static int adv76xx_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1837static int adv76xx_set_format(struct v4l2_subdev *sd,
1838 struct v4l2_subdev_pad_config *cfg,
1837 struct v4l2_subdev_format *format) 1839 struct v4l2_subdev_format *format)
1838{ 1840{
1839 struct adv76xx_state *state = to_state(sd); 1841 struct adv76xx_state *state = to_state(sd);
@@ -1852,7 +1854,7 @@ static int adv76xx_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1852 if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 1854 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
1853 struct v4l2_mbus_framefmt *fmt; 1855 struct v4l2_mbus_framefmt *fmt;
1854 1856
1855 fmt = v4l2_subdev_get_try_format(fh, format->pad); 1857 fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
1856 fmt->code = format->format.code; 1858 fmt->code = format->format.code;
1857 } else { 1859 } else {
1858 state->format = info; 1860 state->format = info;
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
index 6ed16e569bbf..6404c0d93e7a 100644
--- a/drivers/media/i2c/m5mols/m5mols_core.c
+++ b/drivers/media/i2c/m5mols/m5mols_core.c
@@ -531,17 +531,17 @@ static int __find_resolution(struct v4l2_subdev *sd,
531} 531}
532 532
533static struct v4l2_mbus_framefmt *__find_format(struct m5mols_info *info, 533static struct v4l2_mbus_framefmt *__find_format(struct m5mols_info *info,
534 struct v4l2_subdev_fh *fh, 534 struct v4l2_subdev_pad_config *cfg,
535 enum v4l2_subdev_format_whence which, 535 enum v4l2_subdev_format_whence which,
536 enum m5mols_restype type) 536 enum m5mols_restype type)
537{ 537{
538 if (which == V4L2_SUBDEV_FORMAT_TRY) 538 if (which == V4L2_SUBDEV_FORMAT_TRY)
539 return fh ? v4l2_subdev_get_try_format(fh, 0) : NULL; 539 return cfg ? v4l2_subdev_get_try_format(&info->sd, cfg, 0) : NULL;
540 540
541 return &info->ffmt[type]; 541 return &info->ffmt[type];
542} 542}
543 543
544static int m5mols_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 544static int m5mols_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
545 struct v4l2_subdev_format *fmt) 545 struct v4l2_subdev_format *fmt)
546{ 546{
547 struct m5mols_info *info = to_m5mols(sd); 547 struct m5mols_info *info = to_m5mols(sd);
@@ -550,7 +550,7 @@ static int m5mols_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
550 550
551 mutex_lock(&info->lock); 551 mutex_lock(&info->lock);
552 552
553 format = __find_format(info, fh, fmt->which, info->res_type); 553 format = __find_format(info, cfg, fmt->which, info->res_type);
554 if (format) 554 if (format)
555 fmt->format = *format; 555 fmt->format = *format;
556 else 556 else
@@ -560,7 +560,7 @@ static int m5mols_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
560 return ret; 560 return ret;
561} 561}
562 562
563static int m5mols_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 563static int m5mols_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
564 struct v4l2_subdev_format *fmt) 564 struct v4l2_subdev_format *fmt)
565{ 565{
566 struct m5mols_info *info = to_m5mols(sd); 566 struct m5mols_info *info = to_m5mols(sd);
@@ -574,7 +574,7 @@ static int m5mols_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
574 if (ret < 0) 574 if (ret < 0)
575 return ret; 575 return ret;
576 576
577 sfmt = __find_format(info, fh, fmt->which, type); 577 sfmt = __find_format(info, cfg, fmt->which, type);
578 if (!sfmt) 578 if (!sfmt)
579 return 0; 579 return 0;
580 580
@@ -640,7 +640,7 @@ static int m5mols_set_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
640 640
641 641
642static int m5mols_enum_mbus_code(struct v4l2_subdev *sd, 642static int m5mols_enum_mbus_code(struct v4l2_subdev *sd,
643 struct v4l2_subdev_fh *fh, 643 struct v4l2_subdev_pad_config *cfg,
644 struct v4l2_subdev_mbus_code_enum *code) 644 struct v4l2_subdev_mbus_code_enum *code)
645{ 645{
646 if (!code || code->index >= SIZE_DEFAULT_FFMT) 646 if (!code || code->index >= SIZE_DEFAULT_FFMT)
@@ -895,7 +895,7 @@ static const struct v4l2_subdev_core_ops m5mols_core_ops = {
895 */ 895 */
896static int m5mols_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) 896static int m5mols_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
897{ 897{
898 struct v4l2_mbus_framefmt *format = v4l2_subdev_get_try_format(fh, 0); 898 struct v4l2_mbus_framefmt *format = v4l2_subdev_get_try_format(sd, fh->pad, 0);
899 899
900 *format = m5mols_default_ffmt[0]; 900 *format = m5mols_default_ffmt[0];
901 return 0; 901 return 0;
diff --git a/drivers/media/i2c/mt9m032.c b/drivers/media/i2c/mt9m032.c
index 76431223f0ff..c7747bd0cabb 100644
--- a/drivers/media/i2c/mt9m032.c
+++ b/drivers/media/i2c/mt9m032.c
@@ -317,7 +317,7 @@ static int mt9m032_setup_pll(struct mt9m032 *sensor)
317 */ 317 */
318 318
319static int mt9m032_enum_mbus_code(struct v4l2_subdev *subdev, 319static int mt9m032_enum_mbus_code(struct v4l2_subdev *subdev,
320 struct v4l2_subdev_fh *fh, 320 struct v4l2_subdev_pad_config *cfg,
321 struct v4l2_subdev_mbus_code_enum *code) 321 struct v4l2_subdev_mbus_code_enum *code)
322{ 322{
323 if (code->index != 0) 323 if (code->index != 0)
@@ -328,7 +328,7 @@ static int mt9m032_enum_mbus_code(struct v4l2_subdev *subdev,
328} 328}
329 329
330static int mt9m032_enum_frame_size(struct v4l2_subdev *subdev, 330static int mt9m032_enum_frame_size(struct v4l2_subdev *subdev,
331 struct v4l2_subdev_fh *fh, 331 struct v4l2_subdev_pad_config *cfg,
332 struct v4l2_subdev_frame_size_enum *fse) 332 struct v4l2_subdev_frame_size_enum *fse)
333{ 333{
334 if (fse->index != 0 || fse->code != MEDIA_BUS_FMT_Y8_1X8) 334 if (fse->index != 0 || fse->code != MEDIA_BUS_FMT_Y8_1X8)
@@ -345,18 +345,18 @@ static int mt9m032_enum_frame_size(struct v4l2_subdev *subdev,
345/** 345/**
346 * __mt9m032_get_pad_crop() - get crop rect 346 * __mt9m032_get_pad_crop() - get crop rect
347 * @sensor: pointer to the sensor struct 347 * @sensor: pointer to the sensor struct
348 * @fh: file handle for getting the try crop rect from 348 * @cfg: v4l2_subdev_pad_config for getting the try crop rect from
349 * @which: select try or active crop rect 349 * @which: select try or active crop rect
350 * 350 *
351 * Returns a pointer the current active or fh relative try crop rect 351 * Returns a pointer the current active or fh relative try crop rect
352 */ 352 */
353static struct v4l2_rect * 353static struct v4l2_rect *
354__mt9m032_get_pad_crop(struct mt9m032 *sensor, struct v4l2_subdev_fh *fh, 354__mt9m032_get_pad_crop(struct mt9m032 *sensor, struct v4l2_subdev_pad_config *cfg,
355 enum v4l2_subdev_format_whence which) 355 enum v4l2_subdev_format_whence which)
356{ 356{
357 switch (which) { 357 switch (which) {
358 case V4L2_SUBDEV_FORMAT_TRY: 358 case V4L2_SUBDEV_FORMAT_TRY:
359 return v4l2_subdev_get_try_crop(fh, 0); 359 return v4l2_subdev_get_try_crop(&sensor->subdev, cfg, 0);
360 case V4L2_SUBDEV_FORMAT_ACTIVE: 360 case V4L2_SUBDEV_FORMAT_ACTIVE:
361 return &sensor->crop; 361 return &sensor->crop;
362 default: 362 default:
@@ -367,18 +367,18 @@ __mt9m032_get_pad_crop(struct mt9m032 *sensor, struct v4l2_subdev_fh *fh,
367/** 367/**
368 * __mt9m032_get_pad_format() - get format 368 * __mt9m032_get_pad_format() - get format
369 * @sensor: pointer to the sensor struct 369 * @sensor: pointer to the sensor struct
370 * @fh: file handle for getting the try format from 370 * @cfg: v4l2_subdev_pad_config for getting the try format from
371 * @which: select try or active format 371 * @which: select try or active format
372 * 372 *
373 * Returns a pointer the current active or fh relative try format 373 * Returns a pointer the current active or fh relative try format
374 */ 374 */
375static struct v4l2_mbus_framefmt * 375static struct v4l2_mbus_framefmt *
376__mt9m032_get_pad_format(struct mt9m032 *sensor, struct v4l2_subdev_fh *fh, 376__mt9m032_get_pad_format(struct mt9m032 *sensor, struct v4l2_subdev_pad_config *cfg,
377 enum v4l2_subdev_format_whence which) 377 enum v4l2_subdev_format_whence which)
378{ 378{
379 switch (which) { 379 switch (which) {
380 case V4L2_SUBDEV_FORMAT_TRY: 380 case V4L2_SUBDEV_FORMAT_TRY:
381 return v4l2_subdev_get_try_format(fh, 0); 381 return v4l2_subdev_get_try_format(&sensor->subdev, cfg, 0);
382 case V4L2_SUBDEV_FORMAT_ACTIVE: 382 case V4L2_SUBDEV_FORMAT_ACTIVE:
383 return &sensor->format; 383 return &sensor->format;
384 default: 384 default:
@@ -387,20 +387,20 @@ __mt9m032_get_pad_format(struct mt9m032 *sensor, struct v4l2_subdev_fh *fh,
387} 387}
388 388
389static int mt9m032_get_pad_format(struct v4l2_subdev *subdev, 389static int mt9m032_get_pad_format(struct v4l2_subdev *subdev,
390 struct v4l2_subdev_fh *fh, 390 struct v4l2_subdev_pad_config *cfg,
391 struct v4l2_subdev_format *fmt) 391 struct v4l2_subdev_format *fmt)
392{ 392{
393 struct mt9m032 *sensor = to_mt9m032(subdev); 393 struct mt9m032 *sensor = to_mt9m032(subdev);
394 394
395 mutex_lock(&sensor->lock); 395 mutex_lock(&sensor->lock);
396 fmt->format = *__mt9m032_get_pad_format(sensor, fh, fmt->which); 396 fmt->format = *__mt9m032_get_pad_format(sensor, cfg, fmt->which);
397 mutex_unlock(&sensor->lock); 397 mutex_unlock(&sensor->lock);
398 398
399 return 0; 399 return 0;
400} 400}
401 401
402static int mt9m032_set_pad_format(struct v4l2_subdev *subdev, 402static int mt9m032_set_pad_format(struct v4l2_subdev *subdev,
403 struct v4l2_subdev_fh *fh, 403 struct v4l2_subdev_pad_config *cfg,
404 struct v4l2_subdev_format *fmt) 404 struct v4l2_subdev_format *fmt)
405{ 405{
406 struct mt9m032 *sensor = to_mt9m032(subdev); 406 struct mt9m032 *sensor = to_mt9m032(subdev);
@@ -414,7 +414,7 @@ static int mt9m032_set_pad_format(struct v4l2_subdev *subdev,
414 } 414 }
415 415
416 /* Scaling is not supported, the format is thus fixed. */ 416 /* Scaling is not supported, the format is thus fixed. */
417 fmt->format = *__mt9m032_get_pad_format(sensor, fh, fmt->which); 417 fmt->format = *__mt9m032_get_pad_format(sensor, cfg, fmt->which);
418 ret = 0; 418 ret = 0;
419 419
420done: 420done:
@@ -423,7 +423,7 @@ done:
423} 423}
424 424
425static int mt9m032_get_pad_selection(struct v4l2_subdev *subdev, 425static int mt9m032_get_pad_selection(struct v4l2_subdev *subdev,
426 struct v4l2_subdev_fh *fh, 426 struct v4l2_subdev_pad_config *cfg,
427 struct v4l2_subdev_selection *sel) 427 struct v4l2_subdev_selection *sel)
428{ 428{
429 struct mt9m032 *sensor = to_mt9m032(subdev); 429 struct mt9m032 *sensor = to_mt9m032(subdev);
@@ -432,14 +432,14 @@ static int mt9m032_get_pad_selection(struct v4l2_subdev *subdev,
432 return -EINVAL; 432 return -EINVAL;
433 433
434 mutex_lock(&sensor->lock); 434 mutex_lock(&sensor->lock);
435 sel->r = *__mt9m032_get_pad_crop(sensor, fh, sel->which); 435 sel->r = *__mt9m032_get_pad_crop(sensor, cfg, sel->which);
436 mutex_unlock(&sensor->lock); 436 mutex_unlock(&sensor->lock);
437 437
438 return 0; 438 return 0;
439} 439}
440 440
441static int mt9m032_set_pad_selection(struct v4l2_subdev *subdev, 441static int mt9m032_set_pad_selection(struct v4l2_subdev *subdev,
442 struct v4l2_subdev_fh *fh, 442 struct v4l2_subdev_pad_config *cfg,
443 struct v4l2_subdev_selection *sel) 443 struct v4l2_subdev_selection *sel)
444{ 444{
445 struct mt9m032 *sensor = to_mt9m032(subdev); 445 struct mt9m032 *sensor = to_mt9m032(subdev);
@@ -475,13 +475,13 @@ static int mt9m032_set_pad_selection(struct v4l2_subdev *subdev,
475 rect.height = min_t(unsigned int, rect.height, 475 rect.height = min_t(unsigned int, rect.height,
476 MT9M032_PIXEL_ARRAY_HEIGHT - rect.top); 476 MT9M032_PIXEL_ARRAY_HEIGHT - rect.top);
477 477
478 __crop = __mt9m032_get_pad_crop(sensor, fh, sel->which); 478 __crop = __mt9m032_get_pad_crop(sensor, cfg, sel->which);
479 479
480 if (rect.width != __crop->width || rect.height != __crop->height) { 480 if (rect.width != __crop->width || rect.height != __crop->height) {
481 /* Reset the output image size if the crop rectangle size has 481 /* Reset the output image size if the crop rectangle size has
482 * been modified. 482 * been modified.
483 */ 483 */
484 format = __mt9m032_get_pad_format(sensor, fh, sel->which); 484 format = __mt9m032_get_pad_format(sensor, cfg, sel->which);
485 format->width = rect.width; 485 format->width = rect.width;
486 format->height = rect.height; 486 format->height = rect.height;
487 } 487 }
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index e3acae9a2ec3..c56a58b47c78 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -474,7 +474,7 @@ static int mt9p031_s_stream(struct v4l2_subdev *subdev, int enable)
474} 474}
475 475
476static int mt9p031_enum_mbus_code(struct v4l2_subdev *subdev, 476static int mt9p031_enum_mbus_code(struct v4l2_subdev *subdev,
477 struct v4l2_subdev_fh *fh, 477 struct v4l2_subdev_pad_config *cfg,
478 struct v4l2_subdev_mbus_code_enum *code) 478 struct v4l2_subdev_mbus_code_enum *code)
479{ 479{
480 struct mt9p031 *mt9p031 = to_mt9p031(subdev); 480 struct mt9p031 *mt9p031 = to_mt9p031(subdev);
@@ -487,7 +487,7 @@ static int mt9p031_enum_mbus_code(struct v4l2_subdev *subdev,
487} 487}
488 488
489static int mt9p031_enum_frame_size(struct v4l2_subdev *subdev, 489static int mt9p031_enum_frame_size(struct v4l2_subdev *subdev,
490 struct v4l2_subdev_fh *fh, 490 struct v4l2_subdev_pad_config *cfg,
491 struct v4l2_subdev_frame_size_enum *fse) 491 struct v4l2_subdev_frame_size_enum *fse)
492{ 492{
493 struct mt9p031 *mt9p031 = to_mt9p031(subdev); 493 struct mt9p031 *mt9p031 = to_mt9p031(subdev);
@@ -505,12 +505,12 @@ static int mt9p031_enum_frame_size(struct v4l2_subdev *subdev,
505} 505}
506 506
507static struct v4l2_mbus_framefmt * 507static struct v4l2_mbus_framefmt *
508__mt9p031_get_pad_format(struct mt9p031 *mt9p031, struct v4l2_subdev_fh *fh, 508__mt9p031_get_pad_format(struct mt9p031 *mt9p031, struct v4l2_subdev_pad_config *cfg,
509 unsigned int pad, u32 which) 509 unsigned int pad, u32 which)
510{ 510{
511 switch (which) { 511 switch (which) {
512 case V4L2_SUBDEV_FORMAT_TRY: 512 case V4L2_SUBDEV_FORMAT_TRY:
513 return v4l2_subdev_get_try_format(fh, pad); 513 return v4l2_subdev_get_try_format(&mt9p031->subdev, cfg, pad);
514 case V4L2_SUBDEV_FORMAT_ACTIVE: 514 case V4L2_SUBDEV_FORMAT_ACTIVE:
515 return &mt9p031->format; 515 return &mt9p031->format;
516 default: 516 default:
@@ -519,12 +519,12 @@ __mt9p031_get_pad_format(struct mt9p031 *mt9p031, struct v4l2_subdev_fh *fh,
519} 519}
520 520
521static struct v4l2_rect * 521static struct v4l2_rect *
522__mt9p031_get_pad_crop(struct mt9p031 *mt9p031, struct v4l2_subdev_fh *fh, 522__mt9p031_get_pad_crop(struct mt9p031 *mt9p031, struct v4l2_subdev_pad_config *cfg,
523 unsigned int pad, u32 which) 523 unsigned int pad, u32 which)
524{ 524{
525 switch (which) { 525 switch (which) {
526 case V4L2_SUBDEV_FORMAT_TRY: 526 case V4L2_SUBDEV_FORMAT_TRY:
527 return v4l2_subdev_get_try_crop(fh, pad); 527 return v4l2_subdev_get_try_crop(&mt9p031->subdev, cfg, pad);
528 case V4L2_SUBDEV_FORMAT_ACTIVE: 528 case V4L2_SUBDEV_FORMAT_ACTIVE:
529 return &mt9p031->crop; 529 return &mt9p031->crop;
530 default: 530 default:
@@ -533,18 +533,18 @@ __mt9p031_get_pad_crop(struct mt9p031 *mt9p031, struct v4l2_subdev_fh *fh,
533} 533}
534 534
535static int mt9p031_get_format(struct v4l2_subdev *subdev, 535static int mt9p031_get_format(struct v4l2_subdev *subdev,
536 struct v4l2_subdev_fh *fh, 536 struct v4l2_subdev_pad_config *cfg,
537 struct v4l2_subdev_format *fmt) 537 struct v4l2_subdev_format *fmt)
538{ 538{
539 struct mt9p031 *mt9p031 = to_mt9p031(subdev); 539 struct mt9p031 *mt9p031 = to_mt9p031(subdev);
540 540
541 fmt->format = *__mt9p031_get_pad_format(mt9p031, fh, fmt->pad, 541 fmt->format = *__mt9p031_get_pad_format(mt9p031, cfg, fmt->pad,
542 fmt->which); 542 fmt->which);
543 return 0; 543 return 0;
544} 544}
545 545
546static int mt9p031_set_format(struct v4l2_subdev *subdev, 546static int mt9p031_set_format(struct v4l2_subdev *subdev,
547 struct v4l2_subdev_fh *fh, 547 struct v4l2_subdev_pad_config *cfg,
548 struct v4l2_subdev_format *format) 548 struct v4l2_subdev_format *format)
549{ 549{
550 struct mt9p031 *mt9p031 = to_mt9p031(subdev); 550 struct mt9p031 *mt9p031 = to_mt9p031(subdev);
@@ -555,7 +555,7 @@ static int mt9p031_set_format(struct v4l2_subdev *subdev,
555 unsigned int hratio; 555 unsigned int hratio;
556 unsigned int vratio; 556 unsigned int vratio;
557 557
558 __crop = __mt9p031_get_pad_crop(mt9p031, fh, format->pad, 558 __crop = __mt9p031_get_pad_crop(mt9p031, cfg, format->pad,
559 format->which); 559 format->which);
560 560
561 /* Clamp the width and height to avoid dividing by zero. */ 561 /* Clamp the width and height to avoid dividing by zero. */
@@ -571,7 +571,7 @@ static int mt9p031_set_format(struct v4l2_subdev *subdev,
571 hratio = DIV_ROUND_CLOSEST(__crop->width, width); 571 hratio = DIV_ROUND_CLOSEST(__crop->width, width);
572 vratio = DIV_ROUND_CLOSEST(__crop->height, height); 572 vratio = DIV_ROUND_CLOSEST(__crop->height, height);
573 573
574 __format = __mt9p031_get_pad_format(mt9p031, fh, format->pad, 574 __format = __mt9p031_get_pad_format(mt9p031, cfg, format->pad,
575 format->which); 575 format->which);
576 __format->width = __crop->width / hratio; 576 __format->width = __crop->width / hratio;
577 __format->height = __crop->height / vratio; 577 __format->height = __crop->height / vratio;
@@ -582,7 +582,7 @@ static int mt9p031_set_format(struct v4l2_subdev *subdev,
582} 582}
583 583
584static int mt9p031_get_selection(struct v4l2_subdev *subdev, 584static int mt9p031_get_selection(struct v4l2_subdev *subdev,
585 struct v4l2_subdev_fh *fh, 585 struct v4l2_subdev_pad_config *cfg,
586 struct v4l2_subdev_selection *sel) 586 struct v4l2_subdev_selection *sel)
587{ 587{
588 struct mt9p031 *mt9p031 = to_mt9p031(subdev); 588 struct mt9p031 *mt9p031 = to_mt9p031(subdev);
@@ -590,12 +590,12 @@ static int mt9p031_get_selection(struct v4l2_subdev *subdev,
590 if (sel->target != V4L2_SEL_TGT_CROP) 590 if (sel->target != V4L2_SEL_TGT_CROP)
591 return -EINVAL; 591 return -EINVAL;
592 592
593 sel->r = *__mt9p031_get_pad_crop(mt9p031, fh, sel->pad, sel->which); 593 sel->r = *__mt9p031_get_pad_crop(mt9p031, cfg, sel->pad, sel->which);
594 return 0; 594 return 0;
595} 595}
596 596
597static int mt9p031_set_selection(struct v4l2_subdev *subdev, 597static int mt9p031_set_selection(struct v4l2_subdev *subdev,
598 struct v4l2_subdev_fh *fh, 598 struct v4l2_subdev_pad_config *cfg,
599 struct v4l2_subdev_selection *sel) 599 struct v4l2_subdev_selection *sel)
600{ 600{
601 struct mt9p031 *mt9p031 = to_mt9p031(subdev); 601 struct mt9p031 *mt9p031 = to_mt9p031(subdev);
@@ -625,13 +625,13 @@ static int mt9p031_set_selection(struct v4l2_subdev *subdev,
625 rect.height = min_t(unsigned int, rect.height, 625 rect.height = min_t(unsigned int, rect.height,
626 MT9P031_PIXEL_ARRAY_HEIGHT - rect.top); 626 MT9P031_PIXEL_ARRAY_HEIGHT - rect.top);
627 627
628 __crop = __mt9p031_get_pad_crop(mt9p031, fh, sel->pad, sel->which); 628 __crop = __mt9p031_get_pad_crop(mt9p031, cfg, sel->pad, sel->which);
629 629
630 if (rect.width != __crop->width || rect.height != __crop->height) { 630 if (rect.width != __crop->width || rect.height != __crop->height) {
631 /* Reset the output image size if the crop rectangle size has 631 /* Reset the output image size if the crop rectangle size has
632 * been modified. 632 * been modified.
633 */ 633 */
634 __format = __mt9p031_get_pad_format(mt9p031, fh, sel->pad, 634 __format = __mt9p031_get_pad_format(mt9p031, cfg, sel->pad,
635 sel->which); 635 sel->which);
636 __format->width = rect.width; 636 __format->width = rect.width;
637 __format->height = rect.height; 637 __format->height = rect.height;
@@ -946,13 +946,13 @@ static int mt9p031_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
946 struct v4l2_mbus_framefmt *format; 946 struct v4l2_mbus_framefmt *format;
947 struct v4l2_rect *crop; 947 struct v4l2_rect *crop;
948 948
949 crop = v4l2_subdev_get_try_crop(fh, 0); 949 crop = v4l2_subdev_get_try_crop(subdev, fh->pad, 0);
950 crop->left = MT9P031_COLUMN_START_DEF; 950 crop->left = MT9P031_COLUMN_START_DEF;
951 crop->top = MT9P031_ROW_START_DEF; 951 crop->top = MT9P031_ROW_START_DEF;
952 crop->width = MT9P031_WINDOW_WIDTH_DEF; 952 crop->width = MT9P031_WINDOW_WIDTH_DEF;
953 crop->height = MT9P031_WINDOW_HEIGHT_DEF; 953 crop->height = MT9P031_WINDOW_HEIGHT_DEF;
954 954
955 format = v4l2_subdev_get_try_format(fh, 0); 955 format = v4l2_subdev_get_try_format(subdev, fh->pad, 0);
956 956
957 if (mt9p031->model == MT9P031_MODEL_MONOCHROME) 957 if (mt9p031->model == MT9P031_MODEL_MONOCHROME)
958 format->code = MEDIA_BUS_FMT_Y12_1X12; 958 format->code = MEDIA_BUS_FMT_Y12_1X12;
diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index f6ca636b538d..8ae99f7f254c 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.c
@@ -244,12 +244,12 @@ static int __mt9t001_set_power(struct mt9t001 *mt9t001, bool on)
244 */ 244 */
245 245
246static struct v4l2_mbus_framefmt * 246static struct v4l2_mbus_framefmt *
247__mt9t001_get_pad_format(struct mt9t001 *mt9t001, struct v4l2_subdev_fh *fh, 247__mt9t001_get_pad_format(struct mt9t001 *mt9t001, struct v4l2_subdev_pad_config *cfg,
248 unsigned int pad, enum v4l2_subdev_format_whence which) 248 unsigned int pad, enum v4l2_subdev_format_whence which)
249{ 249{
250 switch (which) { 250 switch (which) {
251 case V4L2_SUBDEV_FORMAT_TRY: 251 case V4L2_SUBDEV_FORMAT_TRY:
252 return v4l2_subdev_get_try_format(fh, pad); 252 return v4l2_subdev_get_try_format(&mt9t001->subdev, cfg, pad);
253 case V4L2_SUBDEV_FORMAT_ACTIVE: 253 case V4L2_SUBDEV_FORMAT_ACTIVE:
254 return &mt9t001->format; 254 return &mt9t001->format;
255 default: 255 default:
@@ -258,12 +258,12 @@ __mt9t001_get_pad_format(struct mt9t001 *mt9t001, struct v4l2_subdev_fh *fh,
258} 258}
259 259
260static struct v4l2_rect * 260static struct v4l2_rect *
261__mt9t001_get_pad_crop(struct mt9t001 *mt9t001, struct v4l2_subdev_fh *fh, 261__mt9t001_get_pad_crop(struct mt9t001 *mt9t001, struct v4l2_subdev_pad_config *cfg,
262 unsigned int pad, enum v4l2_subdev_format_whence which) 262 unsigned int pad, enum v4l2_subdev_format_whence which)
263{ 263{
264 switch (which) { 264 switch (which) {
265 case V4L2_SUBDEV_FORMAT_TRY: 265 case V4L2_SUBDEV_FORMAT_TRY:
266 return v4l2_subdev_get_try_crop(fh, pad); 266 return v4l2_subdev_get_try_crop(&mt9t001->subdev, cfg, pad);
267 case V4L2_SUBDEV_FORMAT_ACTIVE: 267 case V4L2_SUBDEV_FORMAT_ACTIVE:
268 return &mt9t001->crop; 268 return &mt9t001->crop;
269 default: 269 default:
@@ -327,7 +327,7 @@ static int mt9t001_s_stream(struct v4l2_subdev *subdev, int enable)
327} 327}
328 328
329static int mt9t001_enum_mbus_code(struct v4l2_subdev *subdev, 329static int mt9t001_enum_mbus_code(struct v4l2_subdev *subdev,
330 struct v4l2_subdev_fh *fh, 330 struct v4l2_subdev_pad_config *cfg,
331 struct v4l2_subdev_mbus_code_enum *code) 331 struct v4l2_subdev_mbus_code_enum *code)
332{ 332{
333 if (code->index > 0) 333 if (code->index > 0)
@@ -338,7 +338,7 @@ static int mt9t001_enum_mbus_code(struct v4l2_subdev *subdev,
338} 338}
339 339
340static int mt9t001_enum_frame_size(struct v4l2_subdev *subdev, 340static int mt9t001_enum_frame_size(struct v4l2_subdev *subdev,
341 struct v4l2_subdev_fh *fh, 341 struct v4l2_subdev_pad_config *cfg,
342 struct v4l2_subdev_frame_size_enum *fse) 342 struct v4l2_subdev_frame_size_enum *fse)
343{ 343{
344 if (fse->index >= 8 || fse->code != MEDIA_BUS_FMT_SGRBG10_1X10) 344 if (fse->index >= 8 || fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
@@ -353,18 +353,18 @@ static int mt9t001_enum_frame_size(struct v4l2_subdev *subdev,
353} 353}
354 354
355static int mt9t001_get_format(struct v4l2_subdev *subdev, 355static int mt9t001_get_format(struct v4l2_subdev *subdev,
356 struct v4l2_subdev_fh *fh, 356 struct v4l2_subdev_pad_config *cfg,
357 struct v4l2_subdev_format *format) 357 struct v4l2_subdev_format *format)
358{ 358{
359 struct mt9t001 *mt9t001 = to_mt9t001(subdev); 359 struct mt9t001 *mt9t001 = to_mt9t001(subdev);
360 360
361 format->format = *__mt9t001_get_pad_format(mt9t001, fh, format->pad, 361 format->format = *__mt9t001_get_pad_format(mt9t001, cfg, format->pad,
362 format->which); 362 format->which);
363 return 0; 363 return 0;
364} 364}
365 365
366static int mt9t001_set_format(struct v4l2_subdev *subdev, 366static int mt9t001_set_format(struct v4l2_subdev *subdev,
367 struct v4l2_subdev_fh *fh, 367 struct v4l2_subdev_pad_config *cfg,
368 struct v4l2_subdev_format *format) 368 struct v4l2_subdev_format *format)
369{ 369{
370 struct mt9t001 *mt9t001 = to_mt9t001(subdev); 370 struct mt9t001 *mt9t001 = to_mt9t001(subdev);
@@ -375,7 +375,7 @@ static int mt9t001_set_format(struct v4l2_subdev *subdev,
375 unsigned int hratio; 375 unsigned int hratio;
376 unsigned int vratio; 376 unsigned int vratio;
377 377
378 __crop = __mt9t001_get_pad_crop(mt9t001, fh, format->pad, 378 __crop = __mt9t001_get_pad_crop(mt9t001, cfg, format->pad,
379 format->which); 379 format->which);
380 380
381 /* Clamp the width and height to avoid dividing by zero. */ 381 /* Clamp the width and height to avoid dividing by zero. */
@@ -391,7 +391,7 @@ static int mt9t001_set_format(struct v4l2_subdev *subdev,
391 hratio = DIV_ROUND_CLOSEST(__crop->width, width); 391 hratio = DIV_ROUND_CLOSEST(__crop->width, width);
392 vratio = DIV_ROUND_CLOSEST(__crop->height, height); 392 vratio = DIV_ROUND_CLOSEST(__crop->height, height);
393 393
394 __format = __mt9t001_get_pad_format(mt9t001, fh, format->pad, 394 __format = __mt9t001_get_pad_format(mt9t001, cfg, format->pad,
395 format->which); 395 format->which);
396 __format->width = __crop->width / hratio; 396 __format->width = __crop->width / hratio;
397 __format->height = __crop->height / vratio; 397 __format->height = __crop->height / vratio;
@@ -402,7 +402,7 @@ static int mt9t001_set_format(struct v4l2_subdev *subdev,
402} 402}
403 403
404static int mt9t001_get_selection(struct v4l2_subdev *subdev, 404static int mt9t001_get_selection(struct v4l2_subdev *subdev,
405 struct v4l2_subdev_fh *fh, 405 struct v4l2_subdev_pad_config *cfg,
406 struct v4l2_subdev_selection *sel) 406 struct v4l2_subdev_selection *sel)
407{ 407{
408 struct mt9t001 *mt9t001 = to_mt9t001(subdev); 408 struct mt9t001 *mt9t001 = to_mt9t001(subdev);
@@ -410,12 +410,12 @@ static int mt9t001_get_selection(struct v4l2_subdev *subdev,
410 if (sel->target != V4L2_SEL_TGT_CROP) 410 if (sel->target != V4L2_SEL_TGT_CROP)
411 return -EINVAL; 411 return -EINVAL;
412 412
413 sel->r = *__mt9t001_get_pad_crop(mt9t001, fh, sel->pad, sel->which); 413 sel->r = *__mt9t001_get_pad_crop(mt9t001, cfg, sel->pad, sel->which);
414 return 0; 414 return 0;
415} 415}
416 416
417static int mt9t001_set_selection(struct v4l2_subdev *subdev, 417static int mt9t001_set_selection(struct v4l2_subdev *subdev,
418 struct v4l2_subdev_fh *fh, 418 struct v4l2_subdev_pad_config *cfg,
419 struct v4l2_subdev_selection *sel) 419 struct v4l2_subdev_selection *sel)
420{ 420{
421 struct mt9t001 *mt9t001 = to_mt9t001(subdev); 421 struct mt9t001 *mt9t001 = to_mt9t001(subdev);
@@ -447,13 +447,13 @@ static int mt9t001_set_selection(struct v4l2_subdev *subdev,
447 rect.height = min_t(unsigned int, rect.height, 447 rect.height = min_t(unsigned int, rect.height,
448 MT9T001_PIXEL_ARRAY_HEIGHT - rect.top); 448 MT9T001_PIXEL_ARRAY_HEIGHT - rect.top);
449 449
450 __crop = __mt9t001_get_pad_crop(mt9t001, fh, sel->pad, sel->which); 450 __crop = __mt9t001_get_pad_crop(mt9t001, cfg, sel->pad, sel->which);
451 451
452 if (rect.width != __crop->width || rect.height != __crop->height) { 452 if (rect.width != __crop->width || rect.height != __crop->height) {
453 /* Reset the output image size if the crop rectangle size has 453 /* Reset the output image size if the crop rectangle size has
454 * been modified. 454 * been modified.
455 */ 455 */
456 __format = __mt9t001_get_pad_format(mt9t001, fh, sel->pad, 456 __format = __mt9t001_get_pad_format(mt9t001, cfg, sel->pad,
457 sel->which); 457 sel->which);
458 __format->width = rect.width; 458 __format->width = rect.width;
459 __format->height = rect.height; 459 __format->height = rect.height;
@@ -790,13 +790,13 @@ static int mt9t001_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
790 struct v4l2_mbus_framefmt *format; 790 struct v4l2_mbus_framefmt *format;
791 struct v4l2_rect *crop; 791 struct v4l2_rect *crop;
792 792
793 crop = v4l2_subdev_get_try_crop(fh, 0); 793 crop = v4l2_subdev_get_try_crop(subdev, fh->pad, 0);
794 crop->left = MT9T001_COLUMN_START_DEF; 794 crop->left = MT9T001_COLUMN_START_DEF;
795 crop->top = MT9T001_ROW_START_DEF; 795 crop->top = MT9T001_ROW_START_DEF;
796 crop->width = MT9T001_WINDOW_WIDTH_DEF + 1; 796 crop->width = MT9T001_WINDOW_WIDTH_DEF + 1;
797 crop->height = MT9T001_WINDOW_HEIGHT_DEF + 1; 797 crop->height = MT9T001_WINDOW_HEIGHT_DEF + 1;
798 798
799 format = v4l2_subdev_get_try_format(fh, 0); 799 format = v4l2_subdev_get_try_format(subdev, fh->pad, 0);
800 format->code = MEDIA_BUS_FMT_SGRBG10_1X10; 800 format->code = MEDIA_BUS_FMT_SGRBG10_1X10;
801 format->width = MT9T001_WINDOW_WIDTH_DEF + 1; 801 format->width = MT9T001_WINDOW_WIDTH_DEF + 1;
802 format->height = MT9T001_WINDOW_HEIGHT_DEF + 1; 802 format->height = MT9T001_WINDOW_HEIGHT_DEF + 1;
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 3267c183104b..3793d317772b 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -371,12 +371,12 @@ static int __mt9v032_set_power(struct mt9v032 *mt9v032, bool on)
371 */ 371 */
372 372
373static struct v4l2_mbus_framefmt * 373static struct v4l2_mbus_framefmt *
374__mt9v032_get_pad_format(struct mt9v032 *mt9v032, struct v4l2_subdev_fh *fh, 374__mt9v032_get_pad_format(struct mt9v032 *mt9v032, struct v4l2_subdev_pad_config *cfg,
375 unsigned int pad, enum v4l2_subdev_format_whence which) 375 unsigned int pad, enum v4l2_subdev_format_whence which)
376{ 376{
377 switch (which) { 377 switch (which) {
378 case V4L2_SUBDEV_FORMAT_TRY: 378 case V4L2_SUBDEV_FORMAT_TRY:
379 return v4l2_subdev_get_try_format(fh, pad); 379 return v4l2_subdev_get_try_format(&mt9v032->subdev, cfg, pad);
380 case V4L2_SUBDEV_FORMAT_ACTIVE: 380 case V4L2_SUBDEV_FORMAT_ACTIVE:
381 return &mt9v032->format; 381 return &mt9v032->format;
382 default: 382 default:
@@ -385,12 +385,12 @@ __mt9v032_get_pad_format(struct mt9v032 *mt9v032, struct v4l2_subdev_fh *fh,
385} 385}
386 386
387static struct v4l2_rect * 387static struct v4l2_rect *
388__mt9v032_get_pad_crop(struct mt9v032 *mt9v032, struct v4l2_subdev_fh *fh, 388__mt9v032_get_pad_crop(struct mt9v032 *mt9v032, struct v4l2_subdev_pad_config *cfg,
389 unsigned int pad, enum v4l2_subdev_format_whence which) 389 unsigned int pad, enum v4l2_subdev_format_whence which)
390{ 390{
391 switch (which) { 391 switch (which) {
392 case V4L2_SUBDEV_FORMAT_TRY: 392 case V4L2_SUBDEV_FORMAT_TRY:
393 return v4l2_subdev_get_try_crop(fh, pad); 393 return v4l2_subdev_get_try_crop(&mt9v032->subdev, cfg, pad);
394 case V4L2_SUBDEV_FORMAT_ACTIVE: 394 case V4L2_SUBDEV_FORMAT_ACTIVE:
395 return &mt9v032->crop; 395 return &mt9v032->crop;
396 default: 396 default:
@@ -448,7 +448,7 @@ static int mt9v032_s_stream(struct v4l2_subdev *subdev, int enable)
448} 448}
449 449
450static int mt9v032_enum_mbus_code(struct v4l2_subdev *subdev, 450static int mt9v032_enum_mbus_code(struct v4l2_subdev *subdev,
451 struct v4l2_subdev_fh *fh, 451 struct v4l2_subdev_pad_config *cfg,
452 struct v4l2_subdev_mbus_code_enum *code) 452 struct v4l2_subdev_mbus_code_enum *code)
453{ 453{
454 if (code->index > 0) 454 if (code->index > 0)
@@ -459,7 +459,7 @@ static int mt9v032_enum_mbus_code(struct v4l2_subdev *subdev,
459} 459}
460 460
461static int mt9v032_enum_frame_size(struct v4l2_subdev *subdev, 461static int mt9v032_enum_frame_size(struct v4l2_subdev *subdev,
462 struct v4l2_subdev_fh *fh, 462 struct v4l2_subdev_pad_config *cfg,
463 struct v4l2_subdev_frame_size_enum *fse) 463 struct v4l2_subdev_frame_size_enum *fse)
464{ 464{
465 if (fse->index >= 3 || fse->code != MEDIA_BUS_FMT_SGRBG10_1X10) 465 if (fse->index >= 3 || fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
@@ -474,12 +474,12 @@ static int mt9v032_enum_frame_size(struct v4l2_subdev *subdev,
474} 474}
475 475
476static int mt9v032_get_format(struct v4l2_subdev *subdev, 476static int mt9v032_get_format(struct v4l2_subdev *subdev,
477 struct v4l2_subdev_fh *fh, 477 struct v4l2_subdev_pad_config *cfg,
478 struct v4l2_subdev_format *format) 478 struct v4l2_subdev_format *format)
479{ 479{
480 struct mt9v032 *mt9v032 = to_mt9v032(subdev); 480 struct mt9v032 *mt9v032 = to_mt9v032(subdev);
481 481
482 format->format = *__mt9v032_get_pad_format(mt9v032, fh, format->pad, 482 format->format = *__mt9v032_get_pad_format(mt9v032, cfg, format->pad,
483 format->which); 483 format->which);
484 return 0; 484 return 0;
485} 485}
@@ -509,7 +509,7 @@ static unsigned int mt9v032_calc_ratio(unsigned int input, unsigned int output)
509} 509}
510 510
511static int mt9v032_set_format(struct v4l2_subdev *subdev, 511static int mt9v032_set_format(struct v4l2_subdev *subdev,
512 struct v4l2_subdev_fh *fh, 512 struct v4l2_subdev_pad_config *cfg,
513 struct v4l2_subdev_format *format) 513 struct v4l2_subdev_format *format)
514{ 514{
515 struct mt9v032 *mt9v032 = to_mt9v032(subdev); 515 struct mt9v032 *mt9v032 = to_mt9v032(subdev);
@@ -520,7 +520,7 @@ static int mt9v032_set_format(struct v4l2_subdev *subdev,
520 unsigned int hratio; 520 unsigned int hratio;
521 unsigned int vratio; 521 unsigned int vratio;
522 522
523 __crop = __mt9v032_get_pad_crop(mt9v032, fh, format->pad, 523 __crop = __mt9v032_get_pad_crop(mt9v032, cfg, format->pad,
524 format->which); 524 format->which);
525 525
526 /* Clamp the width and height to avoid dividing by zero. */ 526 /* Clamp the width and height to avoid dividing by zero. */
@@ -536,7 +536,7 @@ static int mt9v032_set_format(struct v4l2_subdev *subdev,
536 hratio = mt9v032_calc_ratio(__crop->width, width); 536 hratio = mt9v032_calc_ratio(__crop->width, width);
537 vratio = mt9v032_calc_ratio(__crop->height, height); 537 vratio = mt9v032_calc_ratio(__crop->height, height);
538 538
539 __format = __mt9v032_get_pad_format(mt9v032, fh, format->pad, 539 __format = __mt9v032_get_pad_format(mt9v032, cfg, format->pad,
540 format->which); 540 format->which);
541 __format->width = __crop->width / hratio; 541 __format->width = __crop->width / hratio;
542 __format->height = __crop->height / vratio; 542 __format->height = __crop->height / vratio;
@@ -553,7 +553,7 @@ static int mt9v032_set_format(struct v4l2_subdev *subdev,
553} 553}
554 554
555static int mt9v032_get_selection(struct v4l2_subdev *subdev, 555static int mt9v032_get_selection(struct v4l2_subdev *subdev,
556 struct v4l2_subdev_fh *fh, 556 struct v4l2_subdev_pad_config *cfg,
557 struct v4l2_subdev_selection *sel) 557 struct v4l2_subdev_selection *sel)
558{ 558{
559 struct mt9v032 *mt9v032 = to_mt9v032(subdev); 559 struct mt9v032 *mt9v032 = to_mt9v032(subdev);
@@ -561,12 +561,12 @@ static int mt9v032_get_selection(struct v4l2_subdev *subdev,
561 if (sel->target != V4L2_SEL_TGT_CROP) 561 if (sel->target != V4L2_SEL_TGT_CROP)
562 return -EINVAL; 562 return -EINVAL;
563 563
564 sel->r = *__mt9v032_get_pad_crop(mt9v032, fh, sel->pad, sel->which); 564 sel->r = *__mt9v032_get_pad_crop(mt9v032, cfg, sel->pad, sel->which);
565 return 0; 565 return 0;
566} 566}
567 567
568static int mt9v032_set_selection(struct v4l2_subdev *subdev, 568static int mt9v032_set_selection(struct v4l2_subdev *subdev,
569 struct v4l2_subdev_fh *fh, 569 struct v4l2_subdev_pad_config *cfg,
570 struct v4l2_subdev_selection *sel) 570 struct v4l2_subdev_selection *sel)
571{ 571{
572 struct mt9v032 *mt9v032 = to_mt9v032(subdev); 572 struct mt9v032 *mt9v032 = to_mt9v032(subdev);
@@ -598,13 +598,13 @@ static int mt9v032_set_selection(struct v4l2_subdev *subdev,
598 rect.height = min_t(unsigned int, 598 rect.height = min_t(unsigned int,
599 rect.height, MT9V032_PIXEL_ARRAY_HEIGHT - rect.top); 599 rect.height, MT9V032_PIXEL_ARRAY_HEIGHT - rect.top);
600 600
601 __crop = __mt9v032_get_pad_crop(mt9v032, fh, sel->pad, sel->which); 601 __crop = __mt9v032_get_pad_crop(mt9v032, cfg, sel->pad, sel->which);
602 602
603 if (rect.width != __crop->width || rect.height != __crop->height) { 603 if (rect.width != __crop->width || rect.height != __crop->height) {
604 /* Reset the output image size if the crop rectangle size has 604 /* Reset the output image size if the crop rectangle size has
605 * been modified. 605 * been modified.
606 */ 606 */
607 __format = __mt9v032_get_pad_format(mt9v032, fh, sel->pad, 607 __format = __mt9v032_get_pad_format(mt9v032, cfg, sel->pad,
608 sel->which); 608 sel->which);
609 __format->width = rect.width; 609 __format->width = rect.width;
610 __format->height = rect.height; 610 __format->height = rect.height;
@@ -810,13 +810,13 @@ static int mt9v032_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
810 struct v4l2_mbus_framefmt *format; 810 struct v4l2_mbus_framefmt *format;
811 struct v4l2_rect *crop; 811 struct v4l2_rect *crop;
812 812
813 crop = v4l2_subdev_get_try_crop(fh, 0); 813 crop = v4l2_subdev_get_try_crop(subdev, fh->pad, 0);
814 crop->left = MT9V032_COLUMN_START_DEF; 814 crop->left = MT9V032_COLUMN_START_DEF;
815 crop->top = MT9V032_ROW_START_DEF; 815 crop->top = MT9V032_ROW_START_DEF;
816 crop->width = MT9V032_WINDOW_WIDTH_DEF; 816 crop->width = MT9V032_WINDOW_WIDTH_DEF;
817 crop->height = MT9V032_WINDOW_HEIGHT_DEF; 817 crop->height = MT9V032_WINDOW_HEIGHT_DEF;
818 818
819 format = v4l2_subdev_get_try_format(fh, 0); 819 format = v4l2_subdev_get_try_format(subdev, fh->pad, 0);
820 820
821 if (mt9v032->model->color) 821 if (mt9v032->model->color)
822 format->code = MEDIA_BUS_FMT_SGRBG10_1X10; 822 format->code = MEDIA_BUS_FMT_SGRBG10_1X10;
diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c
index 00c7b26f4823..f197b6cbd407 100644
--- a/drivers/media/i2c/noon010pc30.c
+++ b/drivers/media/i2c/noon010pc30.c
@@ -492,7 +492,7 @@ unlock:
492} 492}
493 493
494static int noon010_enum_mbus_code(struct v4l2_subdev *sd, 494static int noon010_enum_mbus_code(struct v4l2_subdev *sd,
495 struct v4l2_subdev_fh *fh, 495 struct v4l2_subdev_pad_config *cfg,
496 struct v4l2_subdev_mbus_code_enum *code) 496 struct v4l2_subdev_mbus_code_enum *code)
497{ 497{
498 if (code->index >= ARRAY_SIZE(noon010_formats)) 498 if (code->index >= ARRAY_SIZE(noon010_formats))
@@ -502,15 +502,16 @@ static int noon010_enum_mbus_code(struct v4l2_subdev *sd,
502 return 0; 502 return 0;
503} 503}
504 504
505static int noon010_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 505static int noon010_get_fmt(struct v4l2_subdev *sd,
506 struct v4l2_subdev_pad_config *cfg,
506 struct v4l2_subdev_format *fmt) 507 struct v4l2_subdev_format *fmt)
507{ 508{
508 struct noon010_info *info = to_noon010(sd); 509 struct noon010_info *info = to_noon010(sd);
509 struct v4l2_mbus_framefmt *mf; 510 struct v4l2_mbus_framefmt *mf;
510 511
511 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 512 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
512 if (fh) { 513 if (cfg) {
513 mf = v4l2_subdev_get_try_format(fh, 0); 514 mf = v4l2_subdev_get_try_format(sd, cfg, 0);
514 fmt->format = *mf; 515 fmt->format = *mf;
515 } 516 }
516 return 0; 517 return 0;
@@ -542,7 +543,7 @@ static const struct noon010_format *noon010_try_fmt(struct v4l2_subdev *sd,
542 return &noon010_formats[i]; 543 return &noon010_formats[i];
543} 544}
544 545
545static int noon010_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 546static int noon010_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
546 struct v4l2_subdev_format *fmt) 547 struct v4l2_subdev_format *fmt)
547{ 548{
548 struct noon010_info *info = to_noon010(sd); 549 struct noon010_info *info = to_noon010(sd);
@@ -557,8 +558,8 @@ static int noon010_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
557 fmt->format.field = V4L2_FIELD_NONE; 558 fmt->format.field = V4L2_FIELD_NONE;
558 559
559 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 560 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
560 if (fh) { 561 if (cfg) {
561 mf = v4l2_subdev_get_try_format(fh, 0); 562 mf = v4l2_subdev_get_try_format(sd, cfg, 0);
562 *mf = fmt->format; 563 *mf = fmt->format;
563 } 564 }
564 return 0; 565 return 0;
@@ -640,7 +641,7 @@ static int noon010_log_status(struct v4l2_subdev *sd)
640 641
641static int noon010_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) 642static int noon010_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
642{ 643{
643 struct v4l2_mbus_framefmt *mf = v4l2_subdev_get_try_format(fh, 0); 644 struct v4l2_mbus_framefmt *mf = v4l2_subdev_get_try_format(sd, fh->pad, 0);
644 645
645 mf->width = noon010_sizes[0].width; 646 mf->width = noon010_sizes[0].width;
646 mf->height = noon010_sizes[0].height; 647 mf->height = noon010_sizes[0].height;
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 2246bd5436ad..2bc473385c91 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -1067,7 +1067,7 @@ static void ov965x_get_default_format(struct v4l2_mbus_framefmt *mf)
1067} 1067}
1068 1068
1069static int ov965x_enum_mbus_code(struct v4l2_subdev *sd, 1069static int ov965x_enum_mbus_code(struct v4l2_subdev *sd,
1070 struct v4l2_subdev_fh *fh, 1070 struct v4l2_subdev_pad_config *cfg,
1071 struct v4l2_subdev_mbus_code_enum *code) 1071 struct v4l2_subdev_mbus_code_enum *code)
1072{ 1072{
1073 if (code->index >= ARRAY_SIZE(ov965x_formats)) 1073 if (code->index >= ARRAY_SIZE(ov965x_formats))
@@ -1078,7 +1078,7 @@ static int ov965x_enum_mbus_code(struct v4l2_subdev *sd,
1078} 1078}
1079 1079
1080static int ov965x_enum_frame_sizes(struct v4l2_subdev *sd, 1080static int ov965x_enum_frame_sizes(struct v4l2_subdev *sd,
1081 struct v4l2_subdev_fh *fh, 1081 struct v4l2_subdev_pad_config *cfg,
1082 struct v4l2_subdev_frame_size_enum *fse) 1082 struct v4l2_subdev_frame_size_enum *fse)
1083{ 1083{
1084 int i = ARRAY_SIZE(ov965x_formats); 1084 int i = ARRAY_SIZE(ov965x_formats);
@@ -1164,14 +1164,14 @@ static int ov965x_s_frame_interval(struct v4l2_subdev *sd,
1164 return ret; 1164 return ret;
1165} 1165}
1166 1166
1167static int ov965x_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1167static int ov965x_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1168 struct v4l2_subdev_format *fmt) 1168 struct v4l2_subdev_format *fmt)
1169{ 1169{
1170 struct ov965x *ov965x = to_ov965x(sd); 1170 struct ov965x *ov965x = to_ov965x(sd);
1171 struct v4l2_mbus_framefmt *mf; 1171 struct v4l2_mbus_framefmt *mf;
1172 1172
1173 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1173 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1174 mf = v4l2_subdev_get_try_format(fh, 0); 1174 mf = v4l2_subdev_get_try_format(sd, cfg, 0);
1175 fmt->format = *mf; 1175 fmt->format = *mf;
1176 return 0; 1176 return 0;
1177 } 1177 }
@@ -1208,7 +1208,7 @@ static void __ov965x_try_frame_size(struct v4l2_mbus_framefmt *mf,
1208 *size = match; 1208 *size = match;
1209} 1209}
1210 1210
1211static int ov965x_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1211static int ov965x_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1212 struct v4l2_subdev_format *fmt) 1212 struct v4l2_subdev_format *fmt)
1213{ 1213{
1214 unsigned int index = ARRAY_SIZE(ov965x_formats); 1214 unsigned int index = ARRAY_SIZE(ov965x_formats);
@@ -1230,8 +1230,8 @@ static int ov965x_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1230 mutex_lock(&ov965x->lock); 1230 mutex_lock(&ov965x->lock);
1231 1231
1232 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1232 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1233 if (fh != NULL) { 1233 if (cfg != NULL) {
1234 mf = v4l2_subdev_get_try_format(fh, fmt->pad); 1234 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
1235 *mf = fmt->format; 1235 *mf = fmt->format;
1236 } 1236 }
1237 } else { 1237 } else {
@@ -1361,7 +1361,7 @@ static int ov965x_s_stream(struct v4l2_subdev *sd, int on)
1361 */ 1361 */
1362static int ov965x_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) 1362static int ov965x_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1363{ 1363{
1364 struct v4l2_mbus_framefmt *mf = v4l2_subdev_get_try_format(fh, 0); 1364 struct v4l2_mbus_framefmt *mf = v4l2_subdev_get_try_format(sd, fh->pad, 0);
1365 1365
1366 ov965x_get_default_format(mf); 1366 ov965x_get_default_format(mf);
1367 return 0; 1367 return 0;
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index ee0f57e01b56..257a335c0ece 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -824,10 +824,11 @@ static const struct s5c73m3_frame_size *s5c73m3_find_frame_size(
824} 824}
825 825
826static void s5c73m3_oif_try_format(struct s5c73m3 *state, 826static void s5c73m3_oif_try_format(struct s5c73m3 *state,
827 struct v4l2_subdev_fh *fh, 827 struct v4l2_subdev_pad_config *cfg,
828 struct v4l2_subdev_format *fmt, 828 struct v4l2_subdev_format *fmt,
829 const struct s5c73m3_frame_size **fs) 829 const struct s5c73m3_frame_size **fs)
830{ 830{
831 struct v4l2_subdev *sd = &state->sensor_sd;
831 u32 code; 832 u32 code;
832 833
833 switch (fmt->pad) { 834 switch (fmt->pad) {
@@ -850,7 +851,7 @@ static void s5c73m3_oif_try_format(struct s5c73m3 *state,
850 *fs = state->oif_pix_size[RES_ISP]; 851 *fs = state->oif_pix_size[RES_ISP];
851 else 852 else
852 *fs = s5c73m3_find_frame_size( 853 *fs = s5c73m3_find_frame_size(
853 v4l2_subdev_get_try_format(fh, 854 v4l2_subdev_get_try_format(sd, cfg,
854 OIF_ISP_PAD), 855 OIF_ISP_PAD),
855 RES_ISP); 856 RES_ISP);
856 break; 857 break;
@@ -860,7 +861,7 @@ static void s5c73m3_oif_try_format(struct s5c73m3 *state,
860} 861}
861 862
862static void s5c73m3_try_format(struct s5c73m3 *state, 863static void s5c73m3_try_format(struct s5c73m3 *state,
863 struct v4l2_subdev_fh *fh, 864 struct v4l2_subdev_pad_config *cfg,
864 struct v4l2_subdev_format *fmt, 865 struct v4l2_subdev_format *fmt,
865 const struct s5c73m3_frame_size **fs) 866 const struct s5c73m3_frame_size **fs)
866{ 867{
@@ -952,7 +953,7 @@ static int s5c73m3_oif_s_frame_interval(struct v4l2_subdev *sd,
952} 953}
953 954
954static int s5c73m3_oif_enum_frame_interval(struct v4l2_subdev *sd, 955static int s5c73m3_oif_enum_frame_interval(struct v4l2_subdev *sd,
955 struct v4l2_subdev_fh *fh, 956 struct v4l2_subdev_pad_config *cfg,
956 struct v4l2_subdev_frame_interval_enum *fie) 957 struct v4l2_subdev_frame_interval_enum *fie)
957{ 958{
958 struct s5c73m3 *state = oif_sd_to_s5c73m3(sd); 959 struct s5c73m3 *state = oif_sd_to_s5c73m3(sd);
@@ -990,7 +991,7 @@ static int s5c73m3_oif_get_pad_code(int pad, int index)
990} 991}
991 992
992static int s5c73m3_get_fmt(struct v4l2_subdev *sd, 993static int s5c73m3_get_fmt(struct v4l2_subdev *sd,
993 struct v4l2_subdev_fh *fh, 994 struct v4l2_subdev_pad_config *cfg,
994 struct v4l2_subdev_format *fmt) 995 struct v4l2_subdev_format *fmt)
995{ 996{
996 struct s5c73m3 *state = sensor_sd_to_s5c73m3(sd); 997 struct s5c73m3 *state = sensor_sd_to_s5c73m3(sd);
@@ -998,7 +999,7 @@ static int s5c73m3_get_fmt(struct v4l2_subdev *sd,
998 u32 code; 999 u32 code;
999 1000
1000 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1001 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1001 fmt->format = *v4l2_subdev_get_try_format(fh, fmt->pad); 1002 fmt->format = *v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
1002 return 0; 1003 return 0;
1003 } 1004 }
1004 1005
@@ -1024,7 +1025,7 @@ static int s5c73m3_get_fmt(struct v4l2_subdev *sd,
1024} 1025}
1025 1026
1026static int s5c73m3_oif_get_fmt(struct v4l2_subdev *sd, 1027static int s5c73m3_oif_get_fmt(struct v4l2_subdev *sd,
1027 struct v4l2_subdev_fh *fh, 1028 struct v4l2_subdev_pad_config *cfg,
1028 struct v4l2_subdev_format *fmt) 1029 struct v4l2_subdev_format *fmt)
1029{ 1030{
1030 struct s5c73m3 *state = oif_sd_to_s5c73m3(sd); 1031 struct s5c73m3 *state = oif_sd_to_s5c73m3(sd);
@@ -1032,7 +1033,7 @@ static int s5c73m3_oif_get_fmt(struct v4l2_subdev *sd,
1032 u32 code; 1033 u32 code;
1033 1034
1034 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1035 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1035 fmt->format = *v4l2_subdev_get_try_format(fh, fmt->pad); 1036 fmt->format = *v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
1036 return 0; 1037 return 0;
1037 } 1038 }
1038 1039
@@ -1062,7 +1063,7 @@ static int s5c73m3_oif_get_fmt(struct v4l2_subdev *sd,
1062} 1063}
1063 1064
1064static int s5c73m3_set_fmt(struct v4l2_subdev *sd, 1065static int s5c73m3_set_fmt(struct v4l2_subdev *sd,
1065 struct v4l2_subdev_fh *fh, 1066 struct v4l2_subdev_pad_config *cfg,
1066 struct v4l2_subdev_format *fmt) 1067 struct v4l2_subdev_format *fmt)
1067{ 1068{
1068 const struct s5c73m3_frame_size *frame_size = NULL; 1069 const struct s5c73m3_frame_size *frame_size = NULL;
@@ -1072,10 +1073,10 @@ static int s5c73m3_set_fmt(struct v4l2_subdev *sd,
1072 1073
1073 mutex_lock(&state->lock); 1074 mutex_lock(&state->lock);
1074 1075
1075 s5c73m3_try_format(state, fh, fmt, &frame_size); 1076 s5c73m3_try_format(state, cfg, fmt, &frame_size);
1076 1077
1077 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1078 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1078 mf = v4l2_subdev_get_try_format(fh, fmt->pad); 1079 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
1079 *mf = fmt->format; 1080 *mf = fmt->format;
1080 } else { 1081 } else {
1081 switch (fmt->pad) { 1082 switch (fmt->pad) {
@@ -1101,7 +1102,7 @@ static int s5c73m3_set_fmt(struct v4l2_subdev *sd,
1101} 1102}
1102 1103
1103static int s5c73m3_oif_set_fmt(struct v4l2_subdev *sd, 1104static int s5c73m3_oif_set_fmt(struct v4l2_subdev *sd,
1104 struct v4l2_subdev_fh *fh, 1105 struct v4l2_subdev_pad_config *cfg,
1105 struct v4l2_subdev_format *fmt) 1106 struct v4l2_subdev_format *fmt)
1106{ 1107{
1107 const struct s5c73m3_frame_size *frame_size = NULL; 1108 const struct s5c73m3_frame_size *frame_size = NULL;
@@ -1111,13 +1112,13 @@ static int s5c73m3_oif_set_fmt(struct v4l2_subdev *sd,
1111 1112
1112 mutex_lock(&state->lock); 1113 mutex_lock(&state->lock);
1113 1114
1114 s5c73m3_oif_try_format(state, fh, fmt, &frame_size); 1115 s5c73m3_oif_try_format(state, cfg, fmt, &frame_size);
1115 1116
1116 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1117 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1117 mf = v4l2_subdev_get_try_format(fh, fmt->pad); 1118 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
1118 *mf = fmt->format; 1119 *mf = fmt->format;
1119 if (fmt->pad == OIF_ISP_PAD) { 1120 if (fmt->pad == OIF_ISP_PAD) {
1120 mf = v4l2_subdev_get_try_format(fh, OIF_SOURCE_PAD); 1121 mf = v4l2_subdev_get_try_format(sd, cfg, OIF_SOURCE_PAD);
1121 mf->width = fmt->format.width; 1122 mf->width = fmt->format.width;
1122 mf->height = fmt->format.height; 1123 mf->height = fmt->format.height;
1123 } 1124 }
@@ -1189,7 +1190,7 @@ static int s5c73m3_oif_set_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
1189} 1190}
1190 1191
1191static int s5c73m3_enum_mbus_code(struct v4l2_subdev *sd, 1192static int s5c73m3_enum_mbus_code(struct v4l2_subdev *sd,
1192 struct v4l2_subdev_fh *fh, 1193 struct v4l2_subdev_pad_config *cfg,
1193 struct v4l2_subdev_mbus_code_enum *code) 1194 struct v4l2_subdev_mbus_code_enum *code)
1194{ 1195{
1195 static const int codes[] = { 1196 static const int codes[] = {
@@ -1205,7 +1206,7 @@ static int s5c73m3_enum_mbus_code(struct v4l2_subdev *sd,
1205} 1206}
1206 1207
1207static int s5c73m3_oif_enum_mbus_code(struct v4l2_subdev *sd, 1208static int s5c73m3_oif_enum_mbus_code(struct v4l2_subdev *sd,
1208 struct v4l2_subdev_fh *fh, 1209 struct v4l2_subdev_pad_config *cfg,
1209 struct v4l2_subdev_mbus_code_enum *code) 1210 struct v4l2_subdev_mbus_code_enum *code)
1210{ 1211{
1211 int ret; 1212 int ret;
@@ -1220,7 +1221,7 @@ static int s5c73m3_oif_enum_mbus_code(struct v4l2_subdev *sd,
1220} 1221}
1221 1222
1222static int s5c73m3_enum_frame_size(struct v4l2_subdev *sd, 1223static int s5c73m3_enum_frame_size(struct v4l2_subdev *sd,
1223 struct v4l2_subdev_fh *fh, 1224 struct v4l2_subdev_pad_config *cfg,
1224 struct v4l2_subdev_frame_size_enum *fse) 1225 struct v4l2_subdev_frame_size_enum *fse)
1225{ 1226{
1226 int idx; 1227 int idx;
@@ -1247,7 +1248,7 @@ static int s5c73m3_enum_frame_size(struct v4l2_subdev *sd,
1247} 1248}
1248 1249
1249static int s5c73m3_oif_enum_frame_size(struct v4l2_subdev *sd, 1250static int s5c73m3_oif_enum_frame_size(struct v4l2_subdev *sd,
1250 struct v4l2_subdev_fh *fh, 1251 struct v4l2_subdev_pad_config *cfg,
1251 struct v4l2_subdev_frame_size_enum *fse) 1252 struct v4l2_subdev_frame_size_enum *fse)
1252{ 1253{
1253 int idx; 1254 int idx;
@@ -1260,7 +1261,7 @@ static int s5c73m3_oif_enum_frame_size(struct v4l2_subdev *sd,
1260 case S5C73M3_JPEG_FMT: 1261 case S5C73M3_JPEG_FMT:
1261 case S5C73M3_ISP_FMT: { 1262 case S5C73M3_ISP_FMT: {
1262 struct v4l2_mbus_framefmt *mf = 1263 struct v4l2_mbus_framefmt *mf =
1263 v4l2_subdev_get_try_format(fh, OIF_ISP_PAD); 1264 v4l2_subdev_get_try_format(sd, cfg, OIF_ISP_PAD);
1264 1265
1265 fse->max_width = fse->min_width = mf->width; 1266 fse->max_width = fse->min_width = mf->width;
1266 fse->max_height = fse->min_height = mf->height; 1267 fse->max_height = fse->min_height = mf->height;
@@ -1306,11 +1307,11 @@ static int s5c73m3_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1306{ 1307{
1307 struct v4l2_mbus_framefmt *mf; 1308 struct v4l2_mbus_framefmt *mf;
1308 1309
1309 mf = v4l2_subdev_get_try_format(fh, S5C73M3_ISP_PAD); 1310 mf = v4l2_subdev_get_try_format(sd, fh->pad, S5C73M3_ISP_PAD);
1310 s5c73m3_fill_mbus_fmt(mf, &s5c73m3_isp_resolutions[1], 1311 s5c73m3_fill_mbus_fmt(mf, &s5c73m3_isp_resolutions[1],
1311 S5C73M3_ISP_FMT); 1312 S5C73M3_ISP_FMT);
1312 1313
1313 mf = v4l2_subdev_get_try_format(fh, S5C73M3_JPEG_PAD); 1314 mf = v4l2_subdev_get_try_format(sd, fh->pad, S5C73M3_JPEG_PAD);
1314 s5c73m3_fill_mbus_fmt(mf, &s5c73m3_jpeg_resolutions[1], 1315 s5c73m3_fill_mbus_fmt(mf, &s5c73m3_jpeg_resolutions[1],
1315 S5C73M3_JPEG_FMT); 1316 S5C73M3_JPEG_FMT);
1316 1317
@@ -1321,15 +1322,15 @@ static int s5c73m3_oif_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1321{ 1322{
1322 struct v4l2_mbus_framefmt *mf; 1323 struct v4l2_mbus_framefmt *mf;
1323 1324
1324 mf = v4l2_subdev_get_try_format(fh, OIF_ISP_PAD); 1325 mf = v4l2_subdev_get_try_format(sd, fh->pad, OIF_ISP_PAD);
1325 s5c73m3_fill_mbus_fmt(mf, &s5c73m3_isp_resolutions[1], 1326 s5c73m3_fill_mbus_fmt(mf, &s5c73m3_isp_resolutions[1],
1326 S5C73M3_ISP_FMT); 1327 S5C73M3_ISP_FMT);
1327 1328
1328 mf = v4l2_subdev_get_try_format(fh, OIF_JPEG_PAD); 1329 mf = v4l2_subdev_get_try_format(sd, fh->pad, OIF_JPEG_PAD);
1329 s5c73m3_fill_mbus_fmt(mf, &s5c73m3_jpeg_resolutions[1], 1330 s5c73m3_fill_mbus_fmt(mf, &s5c73m3_jpeg_resolutions[1],
1330 S5C73M3_JPEG_FMT); 1331 S5C73M3_JPEG_FMT);
1331 1332
1332 mf = v4l2_subdev_get_try_format(fh, OIF_SOURCE_PAD); 1333 mf = v4l2_subdev_get_try_format(sd, fh->pad, OIF_SOURCE_PAD);
1333 s5c73m3_fill_mbus_fmt(mf, &s5c73m3_isp_resolutions[1], 1334 s5c73m3_fill_mbus_fmt(mf, &s5c73m3_isp_resolutions[1],
1334 S5C73M3_ISP_FMT); 1335 S5C73M3_ISP_FMT);
1335 return 0; 1336 return 0;
diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
index 70071314789e..97084237275d 100644
--- a/drivers/media/i2c/s5k4ecgx.c
+++ b/drivers/media/i2c/s5k4ecgx.c
@@ -531,7 +531,7 @@ static int s5k4ecgx_try_frame_size(struct v4l2_mbus_framefmt *mf,
531} 531}
532 532
533static int s5k4ecgx_enum_mbus_code(struct v4l2_subdev *sd, 533static int s5k4ecgx_enum_mbus_code(struct v4l2_subdev *sd,
534 struct v4l2_subdev_fh *fh, 534 struct v4l2_subdev_pad_config *cfg,
535 struct v4l2_subdev_mbus_code_enum *code) 535 struct v4l2_subdev_mbus_code_enum *code)
536{ 536{
537 if (code->index >= ARRAY_SIZE(s5k4ecgx_formats)) 537 if (code->index >= ARRAY_SIZE(s5k4ecgx_formats))
@@ -541,15 +541,15 @@ static int s5k4ecgx_enum_mbus_code(struct v4l2_subdev *sd,
541 return 0; 541 return 0;
542} 542}
543 543
544static int s5k4ecgx_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 544static int s5k4ecgx_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
545 struct v4l2_subdev_format *fmt) 545 struct v4l2_subdev_format *fmt)
546{ 546{
547 struct s5k4ecgx *priv = to_s5k4ecgx(sd); 547 struct s5k4ecgx *priv = to_s5k4ecgx(sd);
548 struct v4l2_mbus_framefmt *mf; 548 struct v4l2_mbus_framefmt *mf;
549 549
550 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 550 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
551 if (fh) { 551 if (cfg) {
552 mf = v4l2_subdev_get_try_format(fh, 0); 552 mf = v4l2_subdev_get_try_format(sd, cfg, 0);
553 fmt->format = *mf; 553 fmt->format = *mf;
554 } 554 }
555 return 0; 555 return 0;
@@ -581,7 +581,7 @@ static const struct s5k4ecgx_pixfmt *s5k4ecgx_try_fmt(struct v4l2_subdev *sd,
581 return &s5k4ecgx_formats[i]; 581 return &s5k4ecgx_formats[i];
582} 582}
583 583
584static int s5k4ecgx_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 584static int s5k4ecgx_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
585 struct v4l2_subdev_format *fmt) 585 struct v4l2_subdev_format *fmt)
586{ 586{
587 struct s5k4ecgx *priv = to_s5k4ecgx(sd); 587 struct s5k4ecgx *priv = to_s5k4ecgx(sd);
@@ -596,8 +596,8 @@ static int s5k4ecgx_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
596 fmt->format.field = V4L2_FIELD_NONE; 596 fmt->format.field = V4L2_FIELD_NONE;
597 597
598 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 598 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
599 if (fh) { 599 if (cfg) {
600 mf = v4l2_subdev_get_try_format(fh, 0); 600 mf = v4l2_subdev_get_try_format(sd, cfg, 0);
601 *mf = fmt->format; 601 *mf = fmt->format;
602 } 602 }
603 return 0; 603 return 0;
@@ -692,7 +692,7 @@ static int s5k4ecgx_registered(struct v4l2_subdev *sd)
692 */ 692 */
693static int s5k4ecgx_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) 693static int s5k4ecgx_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
694{ 694{
695 struct v4l2_mbus_framefmt *mf = v4l2_subdev_get_try_format(fh, 0); 695 struct v4l2_mbus_framefmt *mf = v4l2_subdev_get_try_format(sd, fh->pad, 0);
696 696
697 mf->width = s5k4ecgx_prev_sizes[0].size.width; 697 mf->width = s5k4ecgx_prev_sizes[0].size.width;
698 mf->height = s5k4ecgx_prev_sizes[0].size.height; 698 mf->height = s5k4ecgx_prev_sizes[0].size.height;
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index a3d7d0391302..96e7a4834130 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -1182,7 +1182,7 @@ static int s5k5baf_s_frame_interval(struct v4l2_subdev *sd,
1182 * V4L2 subdev pad level and video operations 1182 * V4L2 subdev pad level and video operations
1183 */ 1183 */
1184static int s5k5baf_enum_frame_interval(struct v4l2_subdev *sd, 1184static int s5k5baf_enum_frame_interval(struct v4l2_subdev *sd,
1185 struct v4l2_subdev_fh *fh, 1185 struct v4l2_subdev_pad_config *cfg,
1186 struct v4l2_subdev_frame_interval_enum *fie) 1186 struct v4l2_subdev_frame_interval_enum *fie)
1187{ 1187{
1188 if (fie->index > S5K5BAF_MAX_FR_TIME - S5K5BAF_MIN_FR_TIME || 1188 if (fie->index > S5K5BAF_MAX_FR_TIME - S5K5BAF_MIN_FR_TIME ||
@@ -1201,7 +1201,7 @@ static int s5k5baf_enum_frame_interval(struct v4l2_subdev *sd,
1201} 1201}
1202 1202
1203static int s5k5baf_enum_mbus_code(struct v4l2_subdev *sd, 1203static int s5k5baf_enum_mbus_code(struct v4l2_subdev *sd,
1204 struct v4l2_subdev_fh *fh, 1204 struct v4l2_subdev_pad_config *cfg,
1205 struct v4l2_subdev_mbus_code_enum *code) 1205 struct v4l2_subdev_mbus_code_enum *code)
1206{ 1206{
1207 if (code->pad == PAD_CIS) { 1207 if (code->pad == PAD_CIS) {
@@ -1219,7 +1219,7 @@ static int s5k5baf_enum_mbus_code(struct v4l2_subdev *sd,
1219} 1219}
1220 1220
1221static int s5k5baf_enum_frame_size(struct v4l2_subdev *sd, 1221static int s5k5baf_enum_frame_size(struct v4l2_subdev *sd,
1222 struct v4l2_subdev_fh *fh, 1222 struct v4l2_subdev_pad_config *cfg,
1223 struct v4l2_subdev_frame_size_enum *fse) 1223 struct v4l2_subdev_frame_size_enum *fse)
1224{ 1224{
1225 int i; 1225 int i;
@@ -1276,7 +1276,7 @@ static int s5k5baf_try_isp_format(struct v4l2_mbus_framefmt *mf)
1276 return pixfmt; 1276 return pixfmt;
1277} 1277}
1278 1278
1279static int s5k5baf_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1279static int s5k5baf_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1280 struct v4l2_subdev_format *fmt) 1280 struct v4l2_subdev_format *fmt)
1281{ 1281{
1282 struct s5k5baf *state = to_s5k5baf(sd); 1282 struct s5k5baf *state = to_s5k5baf(sd);
@@ -1284,7 +1284,7 @@ static int s5k5baf_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1284 struct v4l2_mbus_framefmt *mf; 1284 struct v4l2_mbus_framefmt *mf;
1285 1285
1286 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1286 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1287 mf = v4l2_subdev_get_try_format(fh, fmt->pad); 1287 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
1288 fmt->format = *mf; 1288 fmt->format = *mf;
1289 return 0; 1289 return 0;
1290 } 1290 }
@@ -1306,7 +1306,7 @@ static int s5k5baf_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1306 return 0; 1306 return 0;
1307} 1307}
1308 1308
1309static int s5k5baf_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1309static int s5k5baf_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1310 struct v4l2_subdev_format *fmt) 1310 struct v4l2_subdev_format *fmt)
1311{ 1311{
1312 struct v4l2_mbus_framefmt *mf = &fmt->format; 1312 struct v4l2_mbus_framefmt *mf = &fmt->format;
@@ -1317,7 +1317,7 @@ static int s5k5baf_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1317 mf->field = V4L2_FIELD_NONE; 1317 mf->field = V4L2_FIELD_NONE;
1318 1318
1319 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1319 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1320 *v4l2_subdev_get_try_format(fh, fmt->pad) = *mf; 1320 *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = *mf;
1321 return 0; 1321 return 0;
1322 } 1322 }
1323 1323
@@ -1369,7 +1369,7 @@ static int s5k5baf_is_bound_target(u32 target)
1369} 1369}
1370 1370
1371static int s5k5baf_get_selection(struct v4l2_subdev *sd, 1371static int s5k5baf_get_selection(struct v4l2_subdev *sd,
1372 struct v4l2_subdev_fh *fh, 1372 struct v4l2_subdev_pad_config *cfg,
1373 struct v4l2_subdev_selection *sel) 1373 struct v4l2_subdev_selection *sel)
1374{ 1374{
1375 static enum selection_rect rtype; 1375 static enum selection_rect rtype;
@@ -1389,9 +1389,9 @@ static int s5k5baf_get_selection(struct v4l2_subdev *sd,
1389 1389
1390 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { 1390 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
1391 if (rtype == R_COMPOSE) 1391 if (rtype == R_COMPOSE)
1392 sel->r = *v4l2_subdev_get_try_compose(fh, sel->pad); 1392 sel->r = *v4l2_subdev_get_try_compose(sd, cfg, sel->pad);
1393 else 1393 else
1394 sel->r = *v4l2_subdev_get_try_crop(fh, sel->pad); 1394 sel->r = *v4l2_subdev_get_try_crop(sd, cfg, sel->pad);
1395 return 0; 1395 return 0;
1396 } 1396 }
1397 1397
@@ -1460,7 +1460,7 @@ static bool s5k5baf_cmp_rect(const struct v4l2_rect *r1,
1460} 1460}
1461 1461
1462static int s5k5baf_set_selection(struct v4l2_subdev *sd, 1462static int s5k5baf_set_selection(struct v4l2_subdev *sd,
1463 struct v4l2_subdev_fh *fh, 1463 struct v4l2_subdev_pad_config *cfg,
1464 struct v4l2_subdev_selection *sel) 1464 struct v4l2_subdev_selection *sel)
1465{ 1465{
1466 static enum selection_rect rtype; 1466 static enum selection_rect rtype;
@@ -1481,9 +1481,9 @@ static int s5k5baf_set_selection(struct v4l2_subdev *sd,
1481 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { 1481 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
1482 rects = (struct v4l2_rect * []) { 1482 rects = (struct v4l2_rect * []) {
1483 &s5k5baf_cis_rect, 1483 &s5k5baf_cis_rect,
1484 v4l2_subdev_get_try_crop(fh, PAD_CIS), 1484 v4l2_subdev_get_try_crop(sd, cfg, PAD_CIS),
1485 v4l2_subdev_get_try_compose(fh, PAD_CIS), 1485 v4l2_subdev_get_try_compose(sd, cfg, PAD_CIS),
1486 v4l2_subdev_get_try_crop(fh, PAD_OUT) 1486 v4l2_subdev_get_try_crop(sd, cfg, PAD_OUT)
1487 }; 1487 };
1488 s5k5baf_set_rect_and_adjust(rects, rtype, &sel->r); 1488 s5k5baf_set_rect_and_adjust(rects, rtype, &sel->r);
1489 return 0; 1489 return 0;
@@ -1701,22 +1701,22 @@ static int s5k5baf_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1701{ 1701{
1702 struct v4l2_mbus_framefmt *mf; 1702 struct v4l2_mbus_framefmt *mf;
1703 1703
1704 mf = v4l2_subdev_get_try_format(fh, PAD_CIS); 1704 mf = v4l2_subdev_get_try_format(sd, fh->pad, PAD_CIS);
1705 s5k5baf_try_cis_format(mf); 1705 s5k5baf_try_cis_format(mf);
1706 1706
1707 if (s5k5baf_is_cis_subdev(sd)) 1707 if (s5k5baf_is_cis_subdev(sd))
1708 return 0; 1708 return 0;
1709 1709
1710 mf = v4l2_subdev_get_try_format(fh, PAD_OUT); 1710 mf = v4l2_subdev_get_try_format(sd, fh->pad, PAD_OUT);
1711 mf->colorspace = s5k5baf_formats[0].colorspace; 1711 mf->colorspace = s5k5baf_formats[0].colorspace;
1712 mf->code = s5k5baf_formats[0].code; 1712 mf->code = s5k5baf_formats[0].code;
1713 mf->width = s5k5baf_cis_rect.width; 1713 mf->width = s5k5baf_cis_rect.width;
1714 mf->height = s5k5baf_cis_rect.height; 1714 mf->height = s5k5baf_cis_rect.height;
1715 mf->field = V4L2_FIELD_NONE; 1715 mf->field = V4L2_FIELD_NONE;
1716 1716
1717 *v4l2_subdev_get_try_crop(fh, PAD_CIS) = s5k5baf_cis_rect; 1717 *v4l2_subdev_get_try_crop(sd, fh->pad, PAD_CIS) = s5k5baf_cis_rect;
1718 *v4l2_subdev_get_try_compose(fh, PAD_CIS) = s5k5baf_cis_rect; 1718 *v4l2_subdev_get_try_compose(sd, fh->pad, PAD_CIS) = s5k5baf_cis_rect;
1719 *v4l2_subdev_get_try_crop(fh, PAD_OUT) = s5k5baf_cis_rect; 1719 *v4l2_subdev_get_try_crop(sd, fh->pad, PAD_OUT) = s5k5baf_cis_rect;
1720 1720
1721 return 0; 1721 return 0;
1722} 1722}
diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c
index 91b841a1b850..bc389d5e42ae 100644
--- a/drivers/media/i2c/s5k6a3.c
+++ b/drivers/media/i2c/s5k6a3.c
@@ -99,7 +99,7 @@ static const struct v4l2_mbus_framefmt *find_sensor_format(
99} 99}
100 100
101static int s5k6a3_enum_mbus_code(struct v4l2_subdev *sd, 101static int s5k6a3_enum_mbus_code(struct v4l2_subdev *sd,
102 struct v4l2_subdev_fh *fh, 102 struct v4l2_subdev_pad_config *cfg,
103 struct v4l2_subdev_mbus_code_enum *code) 103 struct v4l2_subdev_mbus_code_enum *code)
104{ 104{
105 if (code->index >= ARRAY_SIZE(s5k6a3_formats)) 105 if (code->index >= ARRAY_SIZE(s5k6a3_formats))
@@ -123,17 +123,17 @@ static void s5k6a3_try_format(struct v4l2_mbus_framefmt *mf)
123} 123}
124 124
125static struct v4l2_mbus_framefmt *__s5k6a3_get_format( 125static struct v4l2_mbus_framefmt *__s5k6a3_get_format(
126 struct s5k6a3 *sensor, struct v4l2_subdev_fh *fh, 126 struct s5k6a3 *sensor, struct v4l2_subdev_pad_config *cfg,
127 u32 pad, enum v4l2_subdev_format_whence which) 127 u32 pad, enum v4l2_subdev_format_whence which)
128{ 128{
129 if (which == V4L2_SUBDEV_FORMAT_TRY) 129 if (which == V4L2_SUBDEV_FORMAT_TRY)
130 return fh ? v4l2_subdev_get_try_format(fh, pad) : NULL; 130 return cfg ? v4l2_subdev_get_try_format(&sensor->subdev, cfg, pad) : NULL;
131 131
132 return &sensor->format; 132 return &sensor->format;
133} 133}
134 134
135static int s5k6a3_set_fmt(struct v4l2_subdev *sd, 135static int s5k6a3_set_fmt(struct v4l2_subdev *sd,
136 struct v4l2_subdev_fh *fh, 136 struct v4l2_subdev_pad_config *cfg,
137 struct v4l2_subdev_format *fmt) 137 struct v4l2_subdev_format *fmt)
138{ 138{
139 struct s5k6a3 *sensor = sd_to_s5k6a3(sd); 139 struct s5k6a3 *sensor = sd_to_s5k6a3(sd);
@@ -141,7 +141,7 @@ static int s5k6a3_set_fmt(struct v4l2_subdev *sd,
141 141
142 s5k6a3_try_format(&fmt->format); 142 s5k6a3_try_format(&fmt->format);
143 143
144 mf = __s5k6a3_get_format(sensor, fh, fmt->pad, fmt->which); 144 mf = __s5k6a3_get_format(sensor, cfg, fmt->pad, fmt->which);
145 if (mf) { 145 if (mf) {
146 mutex_lock(&sensor->lock); 146 mutex_lock(&sensor->lock);
147 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) 147 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE)
@@ -152,13 +152,13 @@ static int s5k6a3_set_fmt(struct v4l2_subdev *sd,
152} 152}
153 153
154static int s5k6a3_get_fmt(struct v4l2_subdev *sd, 154static int s5k6a3_get_fmt(struct v4l2_subdev *sd,
155 struct v4l2_subdev_fh *fh, 155 struct v4l2_subdev_pad_config *cfg,
156 struct v4l2_subdev_format *fmt) 156 struct v4l2_subdev_format *fmt)
157{ 157{
158 struct s5k6a3 *sensor = sd_to_s5k6a3(sd); 158 struct s5k6a3 *sensor = sd_to_s5k6a3(sd);
159 struct v4l2_mbus_framefmt *mf; 159 struct v4l2_mbus_framefmt *mf;
160 160
161 mf = __s5k6a3_get_format(sensor, fh, fmt->pad, fmt->which); 161 mf = __s5k6a3_get_format(sensor, cfg, fmt->pad, fmt->which);
162 162
163 mutex_lock(&sensor->lock); 163 mutex_lock(&sensor->lock);
164 fmt->format = *mf; 164 fmt->format = *mf;
@@ -174,7 +174,7 @@ static struct v4l2_subdev_pad_ops s5k6a3_pad_ops = {
174 174
175static int s5k6a3_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) 175static int s5k6a3_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
176{ 176{
177 struct v4l2_mbus_framefmt *format = v4l2_subdev_get_try_format(fh, 0); 177 struct v4l2_mbus_framefmt *format = v4l2_subdev_get_try_format(sd, fh->pad, 0);
178 178
179 *format = s5k6a3_formats[0]; 179 *format = s5k6a3_formats[0];
180 format->width = S5K6A3_DEFAULT_WIDTH; 180 format->width = S5K6A3_DEFAULT_WIDTH;
diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
index b1c583239dab..de803a11efb4 100644
--- a/drivers/media/i2c/s5k6aa.c
+++ b/drivers/media/i2c/s5k6aa.c
@@ -996,7 +996,7 @@ static int s5k6aa_s_frame_interval(struct v4l2_subdev *sd,
996 * V4L2 subdev pad level and video operations 996 * V4L2 subdev pad level and video operations
997 */ 997 */
998static int s5k6aa_enum_frame_interval(struct v4l2_subdev *sd, 998static int s5k6aa_enum_frame_interval(struct v4l2_subdev *sd,
999 struct v4l2_subdev_fh *fh, 999 struct v4l2_subdev_pad_config *cfg,
1000 struct v4l2_subdev_frame_interval_enum *fie) 1000 struct v4l2_subdev_frame_interval_enum *fie)
1001{ 1001{
1002 struct s5k6aa *s5k6aa = to_s5k6aa(sd); 1002 struct s5k6aa *s5k6aa = to_s5k6aa(sd);
@@ -1023,7 +1023,7 @@ static int s5k6aa_enum_frame_interval(struct v4l2_subdev *sd,
1023} 1023}
1024 1024
1025static int s5k6aa_enum_mbus_code(struct v4l2_subdev *sd, 1025static int s5k6aa_enum_mbus_code(struct v4l2_subdev *sd,
1026 struct v4l2_subdev_fh *fh, 1026 struct v4l2_subdev_pad_config *cfg,
1027 struct v4l2_subdev_mbus_code_enum *code) 1027 struct v4l2_subdev_mbus_code_enum *code)
1028{ 1028{
1029 if (code->index >= ARRAY_SIZE(s5k6aa_formats)) 1029 if (code->index >= ARRAY_SIZE(s5k6aa_formats))
@@ -1034,7 +1034,7 @@ static int s5k6aa_enum_mbus_code(struct v4l2_subdev *sd,
1034} 1034}
1035 1035
1036static int s5k6aa_enum_frame_size(struct v4l2_subdev *sd, 1036static int s5k6aa_enum_frame_size(struct v4l2_subdev *sd,
1037 struct v4l2_subdev_fh *fh, 1037 struct v4l2_subdev_pad_config *cfg,
1038 struct v4l2_subdev_frame_size_enum *fse) 1038 struct v4l2_subdev_frame_size_enum *fse)
1039{ 1039{
1040 int i = ARRAY_SIZE(s5k6aa_formats); 1040 int i = ARRAY_SIZE(s5k6aa_formats);
@@ -1056,14 +1056,14 @@ static int s5k6aa_enum_frame_size(struct v4l2_subdev *sd,
1056} 1056}
1057 1057
1058static struct v4l2_rect * 1058static struct v4l2_rect *
1059__s5k6aa_get_crop_rect(struct s5k6aa *s5k6aa, struct v4l2_subdev_fh *fh, 1059__s5k6aa_get_crop_rect(struct s5k6aa *s5k6aa, struct v4l2_subdev_pad_config *cfg,
1060 enum v4l2_subdev_format_whence which) 1060 enum v4l2_subdev_format_whence which)
1061{ 1061{
1062 if (which == V4L2_SUBDEV_FORMAT_ACTIVE) 1062 if (which == V4L2_SUBDEV_FORMAT_ACTIVE)
1063 return &s5k6aa->ccd_rect; 1063 return &s5k6aa->ccd_rect;
1064 1064
1065 WARN_ON(which != V4L2_SUBDEV_FORMAT_TRY); 1065 WARN_ON(which != V4L2_SUBDEV_FORMAT_TRY);
1066 return v4l2_subdev_get_try_crop(fh, 0); 1066 return v4l2_subdev_get_try_crop(&s5k6aa->sd, cfg, 0);
1067} 1067}
1068 1068
1069static void s5k6aa_try_format(struct s5k6aa *s5k6aa, 1069static void s5k6aa_try_format(struct s5k6aa *s5k6aa,
@@ -1087,7 +1087,7 @@ static void s5k6aa_try_format(struct s5k6aa *s5k6aa,
1087 mf->field = V4L2_FIELD_NONE; 1087 mf->field = V4L2_FIELD_NONE;
1088} 1088}
1089 1089
1090static int s5k6aa_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1090static int s5k6aa_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1091 struct v4l2_subdev_format *fmt) 1091 struct v4l2_subdev_format *fmt)
1092{ 1092{
1093 struct s5k6aa *s5k6aa = to_s5k6aa(sd); 1093 struct s5k6aa *s5k6aa = to_s5k6aa(sd);
@@ -1096,7 +1096,7 @@ static int s5k6aa_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1096 memset(fmt->reserved, 0, sizeof(fmt->reserved)); 1096 memset(fmt->reserved, 0, sizeof(fmt->reserved));
1097 1097
1098 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1098 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1099 mf = v4l2_subdev_get_try_format(fh, 0); 1099 mf = v4l2_subdev_get_try_format(sd, cfg, 0);
1100 fmt->format = *mf; 1100 fmt->format = *mf;
1101 return 0; 1101 return 0;
1102 } 1102 }
@@ -1108,7 +1108,7 @@ static int s5k6aa_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1108 return 0; 1108 return 0;
1109} 1109}
1110 1110
1111static int s5k6aa_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1111static int s5k6aa_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1112 struct v4l2_subdev_format *fmt) 1112 struct v4l2_subdev_format *fmt)
1113{ 1113{
1114 struct s5k6aa *s5k6aa = to_s5k6aa(sd); 1114 struct s5k6aa *s5k6aa = to_s5k6aa(sd);
@@ -1121,8 +1121,8 @@ static int s5k6aa_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1121 s5k6aa_try_format(s5k6aa, &fmt->format); 1121 s5k6aa_try_format(s5k6aa, &fmt->format);
1122 1122
1123 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1123 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1124 mf = v4l2_subdev_get_try_format(fh, fmt->pad); 1124 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
1125 crop = v4l2_subdev_get_try_crop(fh, 0); 1125 crop = v4l2_subdev_get_try_crop(sd, cfg, 0);
1126 } else { 1126 } else {
1127 if (s5k6aa->streaming) { 1127 if (s5k6aa->streaming) {
1128 ret = -EBUSY; 1128 ret = -EBUSY;
@@ -1162,7 +1162,7 @@ static int s5k6aa_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1162} 1162}
1163 1163
1164static int s5k6aa_get_selection(struct v4l2_subdev *sd, 1164static int s5k6aa_get_selection(struct v4l2_subdev *sd,
1165 struct v4l2_subdev_fh *fh, 1165 struct v4l2_subdev_pad_config *cfg,
1166 struct v4l2_subdev_selection *sel) 1166 struct v4l2_subdev_selection *sel)
1167{ 1167{
1168 struct s5k6aa *s5k6aa = to_s5k6aa(sd); 1168 struct s5k6aa *s5k6aa = to_s5k6aa(sd);
@@ -1174,7 +1174,7 @@ static int s5k6aa_get_selection(struct v4l2_subdev *sd,
1174 memset(sel->reserved, 0, sizeof(sel->reserved)); 1174 memset(sel->reserved, 0, sizeof(sel->reserved));
1175 1175
1176 mutex_lock(&s5k6aa->lock); 1176 mutex_lock(&s5k6aa->lock);
1177 rect = __s5k6aa_get_crop_rect(s5k6aa, fh, sel->which); 1177 rect = __s5k6aa_get_crop_rect(s5k6aa, cfg, sel->which);
1178 sel->r = *rect; 1178 sel->r = *rect;
1179 mutex_unlock(&s5k6aa->lock); 1179 mutex_unlock(&s5k6aa->lock);
1180 1180
@@ -1185,7 +1185,7 @@ static int s5k6aa_get_selection(struct v4l2_subdev *sd,
1185} 1185}
1186 1186
1187static int s5k6aa_set_selection(struct v4l2_subdev *sd, 1187static int s5k6aa_set_selection(struct v4l2_subdev *sd,
1188 struct v4l2_subdev_fh *fh, 1188 struct v4l2_subdev_pad_config *cfg,
1189 struct v4l2_subdev_selection *sel) 1189 struct v4l2_subdev_selection *sel)
1190{ 1190{
1191 struct s5k6aa *s5k6aa = to_s5k6aa(sd); 1191 struct s5k6aa *s5k6aa = to_s5k6aa(sd);
@@ -1197,13 +1197,13 @@ static int s5k6aa_set_selection(struct v4l2_subdev *sd,
1197 return -EINVAL; 1197 return -EINVAL;
1198 1198
1199 mutex_lock(&s5k6aa->lock); 1199 mutex_lock(&s5k6aa->lock);
1200 crop_r = __s5k6aa_get_crop_rect(s5k6aa, fh, sel->which); 1200 crop_r = __s5k6aa_get_crop_rect(s5k6aa, cfg, sel->which);
1201 1201
1202 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 1202 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
1203 mf = &s5k6aa->preset->mbus_fmt; 1203 mf = &s5k6aa->preset->mbus_fmt;
1204 s5k6aa->apply_crop = 1; 1204 s5k6aa->apply_crop = 1;
1205 } else { 1205 } else {
1206 mf = v4l2_subdev_get_try_format(fh, 0); 1206 mf = v4l2_subdev_get_try_format(sd, cfg, 0);
1207 } 1207 }
1208 v4l_bound_align_image(&sel->r.width, mf->width, 1208 v4l_bound_align_image(&sel->r.width, mf->width,
1209 S5K6AA_WIN_WIDTH_MAX, 1, 1209 S5K6AA_WIN_WIDTH_MAX, 1,
@@ -1424,8 +1424,8 @@ static int s5k6aa_initialize_ctrls(struct s5k6aa *s5k6aa)
1424 */ 1424 */
1425static int s5k6aa_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) 1425static int s5k6aa_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1426{ 1426{
1427 struct v4l2_mbus_framefmt *format = v4l2_subdev_get_try_format(fh, 0); 1427 struct v4l2_mbus_framefmt *format = v4l2_subdev_get_try_format(sd, fh->pad, 0);
1428 struct v4l2_rect *crop = v4l2_subdev_get_try_crop(fh, 0); 1428 struct v4l2_rect *crop = v4l2_subdev_get_try_crop(sd, fh->pad, 0);
1429 1429
1430 format->colorspace = s5k6aa_formats[0].colorspace; 1430 format->colorspace = s5k6aa_formats[0].colorspace;
1431 format->code = s5k6aa_formats[0].code; 1431 format->code = s5k6aa_formats[0].code;
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index d47eff5d3101..c73deb0432d7 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -1557,7 +1557,7 @@ static int smiapp_set_stream(struct v4l2_subdev *subdev, int enable)
1557} 1557}
1558 1558
1559static int smiapp_enum_mbus_code(struct v4l2_subdev *subdev, 1559static int smiapp_enum_mbus_code(struct v4l2_subdev *subdev,
1560 struct v4l2_subdev_fh *fh, 1560 struct v4l2_subdev_pad_config *cfg,
1561 struct v4l2_subdev_mbus_code_enum *code) 1561 struct v4l2_subdev_mbus_code_enum *code)
1562{ 1562{
1563 struct i2c_client *client = v4l2_get_subdevdata(subdev); 1563 struct i2c_client *client = v4l2_get_subdevdata(subdev);
@@ -1611,13 +1611,13 @@ static u32 __smiapp_get_mbus_code(struct v4l2_subdev *subdev,
1611} 1611}
1612 1612
1613static int __smiapp_get_format(struct v4l2_subdev *subdev, 1613static int __smiapp_get_format(struct v4l2_subdev *subdev,
1614 struct v4l2_subdev_fh *fh, 1614 struct v4l2_subdev_pad_config *cfg,
1615 struct v4l2_subdev_format *fmt) 1615 struct v4l2_subdev_format *fmt)
1616{ 1616{
1617 struct smiapp_subdev *ssd = to_smiapp_subdev(subdev); 1617 struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
1618 1618
1619 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1619 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1620 fmt->format = *v4l2_subdev_get_try_format(fh, fmt->pad); 1620 fmt->format = *v4l2_subdev_get_try_format(subdev, cfg, fmt->pad);
1621 } else { 1621 } else {
1622 struct v4l2_rect *r; 1622 struct v4l2_rect *r;
1623 1623
@@ -1636,21 +1636,21 @@ static int __smiapp_get_format(struct v4l2_subdev *subdev,
1636} 1636}
1637 1637
1638static int smiapp_get_format(struct v4l2_subdev *subdev, 1638static int smiapp_get_format(struct v4l2_subdev *subdev,
1639 struct v4l2_subdev_fh *fh, 1639 struct v4l2_subdev_pad_config *cfg,
1640 struct v4l2_subdev_format *fmt) 1640 struct v4l2_subdev_format *fmt)
1641{ 1641{
1642 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 1642 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
1643 int rval; 1643 int rval;
1644 1644
1645 mutex_lock(&sensor->mutex); 1645 mutex_lock(&sensor->mutex);
1646 rval = __smiapp_get_format(subdev, fh, fmt); 1646 rval = __smiapp_get_format(subdev, cfg, fmt);
1647 mutex_unlock(&sensor->mutex); 1647 mutex_unlock(&sensor->mutex);
1648 1648
1649 return rval; 1649 return rval;
1650} 1650}
1651 1651
1652static void smiapp_get_crop_compose(struct v4l2_subdev *subdev, 1652static void smiapp_get_crop_compose(struct v4l2_subdev *subdev,
1653 struct v4l2_subdev_fh *fh, 1653 struct v4l2_subdev_pad_config *cfg,
1654 struct v4l2_rect **crops, 1654 struct v4l2_rect **crops,
1655 struct v4l2_rect **comps, int which) 1655 struct v4l2_rect **comps, int which)
1656{ 1656{
@@ -1666,12 +1666,12 @@ static void smiapp_get_crop_compose(struct v4l2_subdev *subdev,
1666 } else { 1666 } else {
1667 if (crops) { 1667 if (crops) {
1668 for (i = 0; i < subdev->entity.num_pads; i++) { 1668 for (i = 0; i < subdev->entity.num_pads; i++) {
1669 crops[i] = v4l2_subdev_get_try_crop(fh, i); 1669 crops[i] = v4l2_subdev_get_try_crop(subdev, cfg, i);
1670 BUG_ON(!crops[i]); 1670 BUG_ON(!crops[i]);
1671 } 1671 }
1672 } 1672 }
1673 if (comps) { 1673 if (comps) {
1674 *comps = v4l2_subdev_get_try_compose(fh, 1674 *comps = v4l2_subdev_get_try_compose(subdev, cfg,
1675 SMIAPP_PAD_SINK); 1675 SMIAPP_PAD_SINK);
1676 BUG_ON(!*comps); 1676 BUG_ON(!*comps);
1677 } 1677 }
@@ -1680,14 +1680,14 @@ static void smiapp_get_crop_compose(struct v4l2_subdev *subdev,
1680 1680
1681/* Changes require propagation only on sink pad. */ 1681/* Changes require propagation only on sink pad. */
1682static void smiapp_propagate(struct v4l2_subdev *subdev, 1682static void smiapp_propagate(struct v4l2_subdev *subdev,
1683 struct v4l2_subdev_fh *fh, int which, 1683 struct v4l2_subdev_pad_config *cfg, int which,
1684 int target) 1684 int target)
1685{ 1685{
1686 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 1686 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
1687 struct smiapp_subdev *ssd = to_smiapp_subdev(subdev); 1687 struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
1688 struct v4l2_rect *comp, *crops[SMIAPP_PADS]; 1688 struct v4l2_rect *comp, *crops[SMIAPP_PADS];
1689 1689
1690 smiapp_get_crop_compose(subdev, fh, crops, &comp, which); 1690 smiapp_get_crop_compose(subdev, cfg, crops, &comp, which);
1691 1691
1692 switch (target) { 1692 switch (target) {
1693 case V4L2_SEL_TGT_CROP: 1693 case V4L2_SEL_TGT_CROP:
@@ -1730,7 +1730,7 @@ static const struct smiapp_csi_data_format
1730} 1730}
1731 1731
1732static int smiapp_set_format_source(struct v4l2_subdev *subdev, 1732static int smiapp_set_format_source(struct v4l2_subdev *subdev,
1733 struct v4l2_subdev_fh *fh, 1733 struct v4l2_subdev_pad_config *cfg,
1734 struct v4l2_subdev_format *fmt) 1734 struct v4l2_subdev_format *fmt)
1735{ 1735{
1736 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 1736 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
@@ -1741,7 +1741,7 @@ static int smiapp_set_format_source(struct v4l2_subdev *subdev,
1741 unsigned int i; 1741 unsigned int i;
1742 int rval; 1742 int rval;
1743 1743
1744 rval = __smiapp_get_format(subdev, fh, fmt); 1744 rval = __smiapp_get_format(subdev, cfg, fmt);
1745 if (rval) 1745 if (rval)
1746 return rval; 1746 return rval;
1747 1747
@@ -1783,7 +1783,7 @@ static int smiapp_set_format_source(struct v4l2_subdev *subdev,
1783} 1783}
1784 1784
1785static int smiapp_set_format(struct v4l2_subdev *subdev, 1785static int smiapp_set_format(struct v4l2_subdev *subdev,
1786 struct v4l2_subdev_fh *fh, 1786 struct v4l2_subdev_pad_config *cfg,
1787 struct v4l2_subdev_format *fmt) 1787 struct v4l2_subdev_format *fmt)
1788{ 1788{
1789 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 1789 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
@@ -1795,7 +1795,7 @@ static int smiapp_set_format(struct v4l2_subdev *subdev,
1795 if (fmt->pad == ssd->source_pad) { 1795 if (fmt->pad == ssd->source_pad) {
1796 int rval; 1796 int rval;
1797 1797
1798 rval = smiapp_set_format_source(subdev, fh, fmt); 1798 rval = smiapp_set_format_source(subdev, cfg, fmt);
1799 1799
1800 mutex_unlock(&sensor->mutex); 1800 mutex_unlock(&sensor->mutex);
1801 1801
@@ -1817,7 +1817,7 @@ static int smiapp_set_format(struct v4l2_subdev *subdev,
1817 sensor->limits[SMIAPP_LIMIT_MIN_Y_OUTPUT_SIZE], 1817 sensor->limits[SMIAPP_LIMIT_MIN_Y_OUTPUT_SIZE],
1818 sensor->limits[SMIAPP_LIMIT_MAX_Y_OUTPUT_SIZE]); 1818 sensor->limits[SMIAPP_LIMIT_MAX_Y_OUTPUT_SIZE]);
1819 1819
1820 smiapp_get_crop_compose(subdev, fh, crops, NULL, fmt->which); 1820 smiapp_get_crop_compose(subdev, cfg, crops, NULL, fmt->which);
1821 1821
1822 crops[ssd->sink_pad]->left = 0; 1822 crops[ssd->sink_pad]->left = 0;
1823 crops[ssd->sink_pad]->top = 0; 1823 crops[ssd->sink_pad]->top = 0;
@@ -1825,7 +1825,7 @@ static int smiapp_set_format(struct v4l2_subdev *subdev,
1825 crops[ssd->sink_pad]->height = fmt->format.height; 1825 crops[ssd->sink_pad]->height = fmt->format.height;
1826 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) 1826 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE)
1827 ssd->sink_fmt = *crops[ssd->sink_pad]; 1827 ssd->sink_fmt = *crops[ssd->sink_pad];
1828 smiapp_propagate(subdev, fh, fmt->which, 1828 smiapp_propagate(subdev, cfg, fmt->which,
1829 V4L2_SEL_TGT_CROP); 1829 V4L2_SEL_TGT_CROP);
1830 1830
1831 mutex_unlock(&sensor->mutex); 1831 mutex_unlock(&sensor->mutex);
@@ -1878,7 +1878,7 @@ static int scaling_goodness(struct v4l2_subdev *subdev, int w, int ask_w,
1878} 1878}
1879 1879
1880static void smiapp_set_compose_binner(struct v4l2_subdev *subdev, 1880static void smiapp_set_compose_binner(struct v4l2_subdev *subdev,
1881 struct v4l2_subdev_fh *fh, 1881 struct v4l2_subdev_pad_config *cfg,
1882 struct v4l2_subdev_selection *sel, 1882 struct v4l2_subdev_selection *sel,
1883 struct v4l2_rect **crops, 1883 struct v4l2_rect **crops,
1884 struct v4l2_rect *comp) 1884 struct v4l2_rect *comp)
@@ -1926,7 +1926,7 @@ static void smiapp_set_compose_binner(struct v4l2_subdev *subdev,
1926 * result. 1926 * result.
1927 */ 1927 */
1928static void smiapp_set_compose_scaler(struct v4l2_subdev *subdev, 1928static void smiapp_set_compose_scaler(struct v4l2_subdev *subdev,
1929 struct v4l2_subdev_fh *fh, 1929 struct v4l2_subdev_pad_config *cfg,
1930 struct v4l2_subdev_selection *sel, 1930 struct v4l2_subdev_selection *sel,
1931 struct v4l2_rect **crops, 1931 struct v4l2_rect **crops,
1932 struct v4l2_rect *comp) 1932 struct v4l2_rect *comp)
@@ -2042,25 +2042,25 @@ static void smiapp_set_compose_scaler(struct v4l2_subdev *subdev,
2042} 2042}
2043/* We're only called on source pads. This function sets scaling. */ 2043/* We're only called on source pads. This function sets scaling. */
2044static int smiapp_set_compose(struct v4l2_subdev *subdev, 2044static int smiapp_set_compose(struct v4l2_subdev *subdev,
2045 struct v4l2_subdev_fh *fh, 2045 struct v4l2_subdev_pad_config *cfg,
2046 struct v4l2_subdev_selection *sel) 2046 struct v4l2_subdev_selection *sel)
2047{ 2047{
2048 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 2048 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
2049 struct smiapp_subdev *ssd = to_smiapp_subdev(subdev); 2049 struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
2050 struct v4l2_rect *comp, *crops[SMIAPP_PADS]; 2050 struct v4l2_rect *comp, *crops[SMIAPP_PADS];
2051 2051
2052 smiapp_get_crop_compose(subdev, fh, crops, &comp, sel->which); 2052 smiapp_get_crop_compose(subdev, cfg, crops, &comp, sel->which);
2053 2053
2054 sel->r.top = 0; 2054 sel->r.top = 0;
2055 sel->r.left = 0; 2055 sel->r.left = 0;
2056 2056
2057 if (ssd == sensor->binner) 2057 if (ssd == sensor->binner)
2058 smiapp_set_compose_binner(subdev, fh, sel, crops, comp); 2058 smiapp_set_compose_binner(subdev, cfg, sel, crops, comp);
2059 else 2059 else
2060 smiapp_set_compose_scaler(subdev, fh, sel, crops, comp); 2060 smiapp_set_compose_scaler(subdev, cfg, sel, crops, comp);
2061 2061
2062 *comp = sel->r; 2062 *comp = sel->r;
2063 smiapp_propagate(subdev, fh, sel->which, 2063 smiapp_propagate(subdev, cfg, sel->which,
2064 V4L2_SEL_TGT_COMPOSE); 2064 V4L2_SEL_TGT_COMPOSE);
2065 2065
2066 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) 2066 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE)
@@ -2113,7 +2113,7 @@ static int __smiapp_sel_supported(struct v4l2_subdev *subdev,
2113} 2113}
2114 2114
2115static int smiapp_set_crop(struct v4l2_subdev *subdev, 2115static int smiapp_set_crop(struct v4l2_subdev *subdev,
2116 struct v4l2_subdev_fh *fh, 2116 struct v4l2_subdev_pad_config *cfg,
2117 struct v4l2_subdev_selection *sel) 2117 struct v4l2_subdev_selection *sel)
2118{ 2118{
2119 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 2119 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
@@ -2121,7 +2121,7 @@ static int smiapp_set_crop(struct v4l2_subdev *subdev,
2121 struct v4l2_rect *src_size, *crops[SMIAPP_PADS]; 2121 struct v4l2_rect *src_size, *crops[SMIAPP_PADS];
2122 struct v4l2_rect _r; 2122 struct v4l2_rect _r;
2123 2123
2124 smiapp_get_crop_compose(subdev, fh, crops, NULL, sel->which); 2124 smiapp_get_crop_compose(subdev, cfg, crops, NULL, sel->which);
2125 2125
2126 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 2126 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
2127 if (sel->pad == ssd->sink_pad) 2127 if (sel->pad == ssd->sink_pad)
@@ -2132,15 +2132,15 @@ static int smiapp_set_crop(struct v4l2_subdev *subdev,
2132 if (sel->pad == ssd->sink_pad) { 2132 if (sel->pad == ssd->sink_pad) {
2133 _r.left = 0; 2133 _r.left = 0;
2134 _r.top = 0; 2134 _r.top = 0;
2135 _r.width = v4l2_subdev_get_try_format(fh, sel->pad) 2135 _r.width = v4l2_subdev_get_try_format(subdev, cfg, sel->pad)
2136 ->width; 2136 ->width;
2137 _r.height = v4l2_subdev_get_try_format(fh, sel->pad) 2137 _r.height = v4l2_subdev_get_try_format(subdev, cfg, sel->pad)
2138 ->height; 2138 ->height;
2139 src_size = &_r; 2139 src_size = &_r;
2140 } else { 2140 } else {
2141 src_size = 2141 src_size =
2142 v4l2_subdev_get_try_compose( 2142 v4l2_subdev_get_try_compose(
2143 fh, ssd->sink_pad); 2143 subdev, cfg, ssd->sink_pad);
2144 } 2144 }
2145 } 2145 }
2146 2146
@@ -2158,14 +2158,14 @@ static int smiapp_set_crop(struct v4l2_subdev *subdev,
2158 *crops[sel->pad] = sel->r; 2158 *crops[sel->pad] = sel->r;
2159 2159
2160 if (ssd != sensor->pixel_array && sel->pad == SMIAPP_PAD_SINK) 2160 if (ssd != sensor->pixel_array && sel->pad == SMIAPP_PAD_SINK)
2161 smiapp_propagate(subdev, fh, sel->which, 2161 smiapp_propagate(subdev, cfg, sel->which,
2162 V4L2_SEL_TGT_CROP); 2162 V4L2_SEL_TGT_CROP);
2163 2163
2164 return 0; 2164 return 0;
2165} 2165}
2166 2166
2167static int __smiapp_get_selection(struct v4l2_subdev *subdev, 2167static int __smiapp_get_selection(struct v4l2_subdev *subdev,
2168 struct v4l2_subdev_fh *fh, 2168 struct v4l2_subdev_pad_config *cfg,
2169 struct v4l2_subdev_selection *sel) 2169 struct v4l2_subdev_selection *sel)
2170{ 2170{
2171 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 2171 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
@@ -2178,13 +2178,13 @@ static int __smiapp_get_selection(struct v4l2_subdev *subdev,
2178 if (ret) 2178 if (ret)
2179 return ret; 2179 return ret;
2180 2180
2181 smiapp_get_crop_compose(subdev, fh, crops, &comp, sel->which); 2181 smiapp_get_crop_compose(subdev, cfg, crops, &comp, sel->which);
2182 2182
2183 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 2183 if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
2184 sink_fmt = ssd->sink_fmt; 2184 sink_fmt = ssd->sink_fmt;
2185 } else { 2185 } else {
2186 struct v4l2_mbus_framefmt *fmt = 2186 struct v4l2_mbus_framefmt *fmt =
2187 v4l2_subdev_get_try_format(fh, ssd->sink_pad); 2187 v4l2_subdev_get_try_format(subdev, cfg, ssd->sink_pad);
2188 2188
2189 sink_fmt.left = 0; 2189 sink_fmt.left = 0;
2190 sink_fmt.top = 0; 2190 sink_fmt.top = 0;
@@ -2220,20 +2220,20 @@ static int __smiapp_get_selection(struct v4l2_subdev *subdev,
2220} 2220}
2221 2221
2222static int smiapp_get_selection(struct v4l2_subdev *subdev, 2222static int smiapp_get_selection(struct v4l2_subdev *subdev,
2223 struct v4l2_subdev_fh *fh, 2223 struct v4l2_subdev_pad_config *cfg,
2224 struct v4l2_subdev_selection *sel) 2224 struct v4l2_subdev_selection *sel)
2225{ 2225{
2226 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 2226 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
2227 int rval; 2227 int rval;
2228 2228
2229 mutex_lock(&sensor->mutex); 2229 mutex_lock(&sensor->mutex);
2230 rval = __smiapp_get_selection(subdev, fh, sel); 2230 rval = __smiapp_get_selection(subdev, cfg, sel);
2231 mutex_unlock(&sensor->mutex); 2231 mutex_unlock(&sensor->mutex);
2232 2232
2233 return rval; 2233 return rval;
2234} 2234}
2235static int smiapp_set_selection(struct v4l2_subdev *subdev, 2235static int smiapp_set_selection(struct v4l2_subdev *subdev,
2236 struct v4l2_subdev_fh *fh, 2236 struct v4l2_subdev_pad_config *cfg,
2237 struct v4l2_subdev_selection *sel) 2237 struct v4l2_subdev_selection *sel)
2238{ 2238{
2239 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); 2239 struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
@@ -2259,10 +2259,10 @@ static int smiapp_set_selection(struct v4l2_subdev *subdev,
2259 2259
2260 switch (sel->target) { 2260 switch (sel->target) {
2261 case V4L2_SEL_TGT_CROP: 2261 case V4L2_SEL_TGT_CROP:
2262 ret = smiapp_set_crop(subdev, fh, sel); 2262 ret = smiapp_set_crop(subdev, cfg, sel);
2263 break; 2263 break;
2264 case V4L2_SEL_TGT_COMPOSE: 2264 case V4L2_SEL_TGT_COMPOSE:
2265 ret = smiapp_set_compose(subdev, fh, sel); 2265 ret = smiapp_set_compose(subdev, cfg, sel);
2266 break; 2266 break;
2267 default: 2267 default:
2268 ret = -EINVAL; 2268 ret = -EINVAL;
@@ -2841,8 +2841,8 @@ static int smiapp_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
2841 2841
2842 for (i = 0; i < ssd->npads; i++) { 2842 for (i = 0; i < ssd->npads; i++) {
2843 struct v4l2_mbus_framefmt *try_fmt = 2843 struct v4l2_mbus_framefmt *try_fmt =
2844 v4l2_subdev_get_try_format(fh, i); 2844 v4l2_subdev_get_try_format(sd, fh->pad, i);
2845 struct v4l2_rect *try_crop = v4l2_subdev_get_try_crop(fh, i); 2845 struct v4l2_rect *try_crop = v4l2_subdev_get_try_crop(sd, fh->pad, i);
2846 struct v4l2_rect *try_comp; 2846 struct v4l2_rect *try_comp;
2847 2847
2848 try_fmt->width = sensor->limits[SMIAPP_LIMIT_X_ADDR_MAX] + 1; 2848 try_fmt->width = sensor->limits[SMIAPP_LIMIT_X_ADDR_MAX] + 1;
@@ -2858,7 +2858,7 @@ static int smiapp_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
2858 if (ssd != sensor->pixel_array) 2858 if (ssd != sensor->pixel_array)
2859 continue; 2859 continue;
2860 2860
2861 try_comp = v4l2_subdev_get_try_compose(fh, i); 2861 try_comp = v4l2_subdev_get_try_compose(sd, fh->pad, i);
2862 *try_comp = *try_crop; 2862 *try_comp = *try_crop;
2863 } 2863 }
2864 2864
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index c6b3dc541cc2..1c6bc306ecdc 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -923,13 +923,13 @@ static const struct v4l2_ctrl_ops tvp514x_ctrl_ops = {
923/** 923/**
924 * tvp514x_enum_mbus_code() - V4L2 decoder interface handler for enum_mbus_code 924 * tvp514x_enum_mbus_code() - V4L2 decoder interface handler for enum_mbus_code
925 * @sd: pointer to standard V4L2 sub-device structure 925 * @sd: pointer to standard V4L2 sub-device structure
926 * @fh: file handle 926 * @cfg: pad configuration
927 * @code: pointer to v4l2_subdev_mbus_code_enum structure 927 * @code: pointer to v4l2_subdev_mbus_code_enum structure
928 * 928 *
929 * Enumertaes mbus codes supported 929 * Enumertaes mbus codes supported
930 */ 930 */
931static int tvp514x_enum_mbus_code(struct v4l2_subdev *sd, 931static int tvp514x_enum_mbus_code(struct v4l2_subdev *sd,
932 struct v4l2_subdev_fh *fh, 932 struct v4l2_subdev_pad_config *cfg,
933 struct v4l2_subdev_mbus_code_enum *code) 933 struct v4l2_subdev_mbus_code_enum *code)
934{ 934{
935 u32 pad = code->pad; 935 u32 pad = code->pad;
@@ -950,13 +950,13 @@ static int tvp514x_enum_mbus_code(struct v4l2_subdev *sd,
950/** 950/**
951 * tvp514x_get_pad_format() - V4L2 decoder interface handler for get pad format 951 * tvp514x_get_pad_format() - V4L2 decoder interface handler for get pad format
952 * @sd: pointer to standard V4L2 sub-device structure 952 * @sd: pointer to standard V4L2 sub-device structure
953 * @fh: file handle 953 * @cfg: pad configuration
954 * @format: pointer to v4l2_subdev_format structure 954 * @format: pointer to v4l2_subdev_format structure
955 * 955 *
956 * Retrieves pad format which is active or tried based on requirement 956 * Retrieves pad format which is active or tried based on requirement
957 */ 957 */
958static int tvp514x_get_pad_format(struct v4l2_subdev *sd, 958static int tvp514x_get_pad_format(struct v4l2_subdev *sd,
959 struct v4l2_subdev_fh *fh, 959 struct v4l2_subdev_pad_config *cfg,
960 struct v4l2_subdev_format *format) 960 struct v4l2_subdev_format *format)
961{ 961{
962 struct tvp514x_decoder *decoder = to_decoder(sd); 962 struct tvp514x_decoder *decoder = to_decoder(sd);
@@ -979,13 +979,13 @@ static int tvp514x_get_pad_format(struct v4l2_subdev *sd,
979/** 979/**
980 * tvp514x_set_pad_format() - V4L2 decoder interface handler for set pad format 980 * tvp514x_set_pad_format() - V4L2 decoder interface handler for set pad format
981 * @sd: pointer to standard V4L2 sub-device structure 981 * @sd: pointer to standard V4L2 sub-device structure
982 * @fh: file handle 982 * @cfg: pad configuration
983 * @format: pointer to v4l2_subdev_format structure 983 * @format: pointer to v4l2_subdev_format structure
984 * 984 *
985 * Set pad format for the output pad 985 * Set pad format for the output pad
986 */ 986 */
987static int tvp514x_set_pad_format(struct v4l2_subdev *sd, 987static int tvp514x_set_pad_format(struct v4l2_subdev *sd,
988 struct v4l2_subdev_fh *fh, 988 struct v4l2_subdev_pad_config *cfg,
989 struct v4l2_subdev_format *fmt) 989 struct v4l2_subdev_format *fmt)
990{ 990{
991 struct tvp514x_decoder *decoder = to_decoder(sd); 991 struct tvp514x_decoder *decoder = to_decoder(sd);
diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index 9233194233eb..787cdfb08749 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -846,13 +846,13 @@ static const struct v4l2_ctrl_ops tvp7002_ctrl_ops = {
846/* 846/*
847 * tvp7002_enum_mbus_code() - Enum supported digital video format on pad 847 * tvp7002_enum_mbus_code() - Enum supported digital video format on pad
848 * @sd: pointer to standard V4L2 sub-device structure 848 * @sd: pointer to standard V4L2 sub-device structure
849 * @fh: file handle for the subdev 849 * @cfg: pad configuration
850 * @code: pointer to subdev enum mbus code struct 850 * @code: pointer to subdev enum mbus code struct
851 * 851 *
852 * Enumerate supported digital video formats for pad. 852 * Enumerate supported digital video formats for pad.
853 */ 853 */
854static int 854static int
855tvp7002_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 855tvp7002_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
856 struct v4l2_subdev_mbus_code_enum *code) 856 struct v4l2_subdev_mbus_code_enum *code)
857{ 857{
858 /* Check requested format index is within range */ 858 /* Check requested format index is within range */
@@ -867,13 +867,13 @@ tvp7002_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
867/* 867/*
868 * tvp7002_get_pad_format() - get video format on pad 868 * tvp7002_get_pad_format() - get video format on pad
869 * @sd: pointer to standard V4L2 sub-device structure 869 * @sd: pointer to standard V4L2 sub-device structure
870 * @fh: file handle for the subdev 870 * @cfg: pad configuration
871 * @fmt: pointer to subdev format struct 871 * @fmt: pointer to subdev format struct
872 * 872 *
873 * get video format for pad. 873 * get video format for pad.
874 */ 874 */
875static int 875static int
876tvp7002_get_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 876tvp7002_get_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
877 struct v4l2_subdev_format *fmt) 877 struct v4l2_subdev_format *fmt)
878{ 878{
879 struct tvp7002 *tvp7002 = to_tvp7002(sd); 879 struct tvp7002 *tvp7002 = to_tvp7002(sd);
@@ -890,16 +890,16 @@ tvp7002_get_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
890/* 890/*
891 * tvp7002_set_pad_format() - set video format on pad 891 * tvp7002_set_pad_format() - set video format on pad
892 * @sd: pointer to standard V4L2 sub-device structure 892 * @sd: pointer to standard V4L2 sub-device structure
893 * @fh: file handle for the subdev 893 * @cfg: pad configuration
894 * @fmt: pointer to subdev format struct 894 * @fmt: pointer to subdev format struct
895 * 895 *
896 * set video format for pad. 896 * set video format for pad.
897 */ 897 */
898static int 898static int
899tvp7002_set_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 899tvp7002_set_pad_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
900 struct v4l2_subdev_format *fmt) 900 struct v4l2_subdev_format *fmt)
901{ 901{
902 return tvp7002_get_pad_format(sd, fh, fmt); 902 return tvp7002_get_pad_format(sd, cfg, fmt);
903} 903}
904 904
905/* V4L2 core operation handlers */ 905/* V4L2 core operation handlers */
diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c
index 8a2fd8c33d42..cfebf292e15a 100644
--- a/drivers/media/platform/exynos4-is/fimc-capture.c
+++ b/drivers/media/platform/exynos4-is/fimc-capture.c
@@ -1482,7 +1482,7 @@ void fimc_sensor_notify(struct v4l2_subdev *sd, unsigned int notification,
1482} 1482}
1483 1483
1484static int fimc_subdev_enum_mbus_code(struct v4l2_subdev *sd, 1484static int fimc_subdev_enum_mbus_code(struct v4l2_subdev *sd,
1485 struct v4l2_subdev_fh *fh, 1485 struct v4l2_subdev_pad_config *cfg,
1486 struct v4l2_subdev_mbus_code_enum *code) 1486 struct v4l2_subdev_mbus_code_enum *code)
1487{ 1487{
1488 struct fimc_fmt *fmt; 1488 struct fimc_fmt *fmt;
@@ -1495,7 +1495,7 @@ static int fimc_subdev_enum_mbus_code(struct v4l2_subdev *sd,
1495} 1495}
1496 1496
1497static int fimc_subdev_get_fmt(struct v4l2_subdev *sd, 1497static int fimc_subdev_get_fmt(struct v4l2_subdev *sd,
1498 struct v4l2_subdev_fh *fh, 1498 struct v4l2_subdev_pad_config *cfg,
1499 struct v4l2_subdev_format *fmt) 1499 struct v4l2_subdev_format *fmt)
1500{ 1500{
1501 struct fimc_dev *fimc = v4l2_get_subdevdata(sd); 1501 struct fimc_dev *fimc = v4l2_get_subdevdata(sd);
@@ -1504,7 +1504,7 @@ static int fimc_subdev_get_fmt(struct v4l2_subdev *sd,
1504 struct v4l2_mbus_framefmt *mf; 1504 struct v4l2_mbus_framefmt *mf;
1505 1505
1506 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1506 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1507 mf = v4l2_subdev_get_try_format(fh, fmt->pad); 1507 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
1508 fmt->format = *mf; 1508 fmt->format = *mf;
1509 return 0; 1509 return 0;
1510 } 1510 }
@@ -1536,7 +1536,7 @@ static int fimc_subdev_get_fmt(struct v4l2_subdev *sd,
1536} 1536}
1537 1537
1538static int fimc_subdev_set_fmt(struct v4l2_subdev *sd, 1538static int fimc_subdev_set_fmt(struct v4l2_subdev *sd,
1539 struct v4l2_subdev_fh *fh, 1539 struct v4l2_subdev_pad_config *cfg,
1540 struct v4l2_subdev_format *fmt) 1540 struct v4l2_subdev_format *fmt)
1541{ 1541{
1542 struct fimc_dev *fimc = v4l2_get_subdevdata(sd); 1542 struct fimc_dev *fimc = v4l2_get_subdevdata(sd);
@@ -1559,7 +1559,7 @@ static int fimc_subdev_set_fmt(struct v4l2_subdev *sd,
1559 mf->colorspace = V4L2_COLORSPACE_JPEG; 1559 mf->colorspace = V4L2_COLORSPACE_JPEG;
1560 1560
1561 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1561 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1562 mf = v4l2_subdev_get_try_format(fh, fmt->pad); 1562 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
1563 *mf = fmt->format; 1563 *mf = fmt->format;
1564 return 0; 1564 return 0;
1565 } 1565 }
@@ -1602,7 +1602,7 @@ static int fimc_subdev_set_fmt(struct v4l2_subdev *sd,
1602} 1602}
1603 1603
1604static int fimc_subdev_get_selection(struct v4l2_subdev *sd, 1604static int fimc_subdev_get_selection(struct v4l2_subdev *sd,
1605 struct v4l2_subdev_fh *fh, 1605 struct v4l2_subdev_pad_config *cfg,
1606 struct v4l2_subdev_selection *sel) 1606 struct v4l2_subdev_selection *sel)
1607{ 1607{
1608 struct fimc_dev *fimc = v4l2_get_subdevdata(sd); 1608 struct fimc_dev *fimc = v4l2_get_subdevdata(sd);
@@ -1628,10 +1628,10 @@ static int fimc_subdev_get_selection(struct v4l2_subdev *sd,
1628 return 0; 1628 return 0;
1629 1629
1630 case V4L2_SEL_TGT_CROP: 1630 case V4L2_SEL_TGT_CROP:
1631 try_sel = v4l2_subdev_get_try_crop(fh, sel->pad); 1631 try_sel = v4l2_subdev_get_try_crop(sd, cfg, sel->pad);
1632 break; 1632 break;
1633 case V4L2_SEL_TGT_COMPOSE: 1633 case V4L2_SEL_TGT_COMPOSE:
1634 try_sel = v4l2_subdev_get_try_compose(fh, sel->pad); 1634 try_sel = v4l2_subdev_get_try_compose(sd, cfg, sel->pad);
1635 f = &ctx->d_frame; 1635 f = &ctx->d_frame;
1636 break; 1636 break;
1637 default: 1637 default:
@@ -1657,7 +1657,7 @@ static int fimc_subdev_get_selection(struct v4l2_subdev *sd,
1657} 1657}
1658 1658
1659static int fimc_subdev_set_selection(struct v4l2_subdev *sd, 1659static int fimc_subdev_set_selection(struct v4l2_subdev *sd,
1660 struct v4l2_subdev_fh *fh, 1660 struct v4l2_subdev_pad_config *cfg,
1661 struct v4l2_subdev_selection *sel) 1661 struct v4l2_subdev_selection *sel)
1662{ 1662{
1663 struct fimc_dev *fimc = v4l2_get_subdevdata(sd); 1663 struct fimc_dev *fimc = v4l2_get_subdevdata(sd);
@@ -1675,10 +1675,10 @@ static int fimc_subdev_set_selection(struct v4l2_subdev *sd,
1675 1675
1676 switch (sel->target) { 1676 switch (sel->target) {
1677 case V4L2_SEL_TGT_CROP: 1677 case V4L2_SEL_TGT_CROP:
1678 try_sel = v4l2_subdev_get_try_crop(fh, sel->pad); 1678 try_sel = v4l2_subdev_get_try_crop(sd, cfg, sel->pad);
1679 break; 1679 break;
1680 case V4L2_SEL_TGT_COMPOSE: 1680 case V4L2_SEL_TGT_COMPOSE:
1681 try_sel = v4l2_subdev_get_try_compose(fh, sel->pad); 1681 try_sel = v4l2_subdev_get_try_compose(sd, cfg, sel->pad);
1682 f = &ctx->d_frame; 1682 f = &ctx->d_frame;
1683 break; 1683 break;
1684 default: 1684 default:
diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c
index 60c744915549..5d78f5716f3b 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp.c
+++ b/drivers/media/platform/exynos4-is/fimc-isp.c
@@ -112,7 +112,7 @@ static const struct media_entity_operations fimc_is_subdev_media_ops = {
112}; 112};
113 113
114static int fimc_is_subdev_enum_mbus_code(struct v4l2_subdev *sd, 114static int fimc_is_subdev_enum_mbus_code(struct v4l2_subdev *sd,
115 struct v4l2_subdev_fh *fh, 115 struct v4l2_subdev_pad_config *cfg,
116 struct v4l2_subdev_mbus_code_enum *code) 116 struct v4l2_subdev_mbus_code_enum *code)
117{ 117{
118 const struct fimc_fmt *fmt; 118 const struct fimc_fmt *fmt;
@@ -125,14 +125,14 @@ static int fimc_is_subdev_enum_mbus_code(struct v4l2_subdev *sd,
125} 125}
126 126
127static int fimc_isp_subdev_get_fmt(struct v4l2_subdev *sd, 127static int fimc_isp_subdev_get_fmt(struct v4l2_subdev *sd,
128 struct v4l2_subdev_fh *fh, 128 struct v4l2_subdev_pad_config *cfg,
129 struct v4l2_subdev_format *fmt) 129 struct v4l2_subdev_format *fmt)
130{ 130{
131 struct fimc_isp *isp = v4l2_get_subdevdata(sd); 131 struct fimc_isp *isp = v4l2_get_subdevdata(sd);
132 struct v4l2_mbus_framefmt *mf = &fmt->format; 132 struct v4l2_mbus_framefmt *mf = &fmt->format;
133 133
134 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 134 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
135 *mf = *v4l2_subdev_get_try_format(fh, fmt->pad); 135 *mf = *v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
136 return 0; 136 return 0;
137 } 137 }
138 138
@@ -162,7 +162,7 @@ static int fimc_isp_subdev_get_fmt(struct v4l2_subdev *sd,
162} 162}
163 163
164static void __isp_subdev_try_format(struct fimc_isp *isp, 164static void __isp_subdev_try_format(struct fimc_isp *isp,
165 struct v4l2_subdev_fh *fh, 165 struct v4l2_subdev_pad_config *cfg,
166 struct v4l2_subdev_format *fmt) 166 struct v4l2_subdev_format *fmt)
167{ 167{
168 struct v4l2_mbus_framefmt *mf = &fmt->format; 168 struct v4l2_mbus_framefmt *mf = &fmt->format;
@@ -178,7 +178,7 @@ static void __isp_subdev_try_format(struct fimc_isp *isp,
178 mf->code = MEDIA_BUS_FMT_SGRBG10_1X10; 178 mf->code = MEDIA_BUS_FMT_SGRBG10_1X10;
179 } else { 179 } else {
180 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) 180 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
181 format = v4l2_subdev_get_try_format(fh, 181 format = v4l2_subdev_get_try_format(&isp->subdev, cfg,
182 FIMC_ISP_SD_PAD_SINK); 182 FIMC_ISP_SD_PAD_SINK);
183 else 183 else
184 format = &isp->sink_fmt; 184 format = &isp->sink_fmt;
@@ -197,7 +197,7 @@ static void __isp_subdev_try_format(struct fimc_isp *isp,
197} 197}
198 198
199static int fimc_isp_subdev_set_fmt(struct v4l2_subdev *sd, 199static int fimc_isp_subdev_set_fmt(struct v4l2_subdev *sd,
200 struct v4l2_subdev_fh *fh, 200 struct v4l2_subdev_pad_config *cfg,
201 struct v4l2_subdev_format *fmt) 201 struct v4l2_subdev_format *fmt)
202{ 202{
203 struct fimc_isp *isp = v4l2_get_subdevdata(sd); 203 struct fimc_isp *isp = v4l2_get_subdevdata(sd);
@@ -209,10 +209,10 @@ static int fimc_isp_subdev_set_fmt(struct v4l2_subdev *sd,
209 __func__, fmt->pad, mf->code, mf->width, mf->height); 209 __func__, fmt->pad, mf->code, mf->width, mf->height);
210 210
211 mutex_lock(&isp->subdev_lock); 211 mutex_lock(&isp->subdev_lock);
212 __isp_subdev_try_format(isp, fh, fmt); 212 __isp_subdev_try_format(isp, cfg, fmt);
213 213
214 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 214 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
215 mf = v4l2_subdev_get_try_format(fh, fmt->pad); 215 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
216 *mf = fmt->format; 216 *mf = fmt->format;
217 217
218 /* Propagate format to the source pads */ 218 /* Propagate format to the source pads */
@@ -223,8 +223,8 @@ static int fimc_isp_subdev_set_fmt(struct v4l2_subdev *sd,
223 for (pad = FIMC_ISP_SD_PAD_SRC_FIFO; 223 for (pad = FIMC_ISP_SD_PAD_SRC_FIFO;
224 pad < FIMC_ISP_SD_PADS_NUM; pad++) { 224 pad < FIMC_ISP_SD_PADS_NUM; pad++) {
225 format.pad = pad; 225 format.pad = pad;
226 __isp_subdev_try_format(isp, fh, &format); 226 __isp_subdev_try_format(isp, cfg, &format);
227 mf = v4l2_subdev_get_try_format(fh, pad); 227 mf = v4l2_subdev_get_try_format(sd, cfg, pad);
228 *mf = format.format; 228 *mf = format.format;
229 } 229 }
230 } 230 }
@@ -236,7 +236,7 @@ static int fimc_isp_subdev_set_fmt(struct v4l2_subdev *sd,
236 isp->sink_fmt = *mf; 236 isp->sink_fmt = *mf;
237 237
238 format.pad = FIMC_ISP_SD_PAD_SRC_DMA; 238 format.pad = FIMC_ISP_SD_PAD_SRC_DMA;
239 __isp_subdev_try_format(isp, fh, &format); 239 __isp_subdev_try_format(isp, cfg, &format);
240 240
241 isp->src_fmt = format.format; 241 isp->src_fmt = format.format;
242 __is_set_frame_size(is, &isp->src_fmt); 242 __is_set_frame_size(is, &isp->src_fmt);
@@ -369,7 +369,7 @@ static int fimc_isp_subdev_open(struct v4l2_subdev *sd,
369 struct v4l2_mbus_framefmt fmt; 369 struct v4l2_mbus_framefmt fmt;
370 struct v4l2_mbus_framefmt *format; 370 struct v4l2_mbus_framefmt *format;
371 371
372 format = v4l2_subdev_get_try_format(fh, FIMC_ISP_SD_PAD_SINK); 372 format = v4l2_subdev_get_try_format(sd, fh->pad, FIMC_ISP_SD_PAD_SINK);
373 373
374 fmt.colorspace = V4L2_COLORSPACE_SRGB; 374 fmt.colorspace = V4L2_COLORSPACE_SRGB;
375 fmt.code = fimc_isp_formats[0].mbus_code; 375 fmt.code = fimc_isp_formats[0].mbus_code;
@@ -378,12 +378,12 @@ static int fimc_isp_subdev_open(struct v4l2_subdev *sd,
378 fmt.field = V4L2_FIELD_NONE; 378 fmt.field = V4L2_FIELD_NONE;
379 *format = fmt; 379 *format = fmt;
380 380
381 format = v4l2_subdev_get_try_format(fh, FIMC_ISP_SD_PAD_SRC_FIFO); 381 format = v4l2_subdev_get_try_format(sd, fh->pad, FIMC_ISP_SD_PAD_SRC_FIFO);
382 fmt.width = DEFAULT_PREVIEW_STILL_WIDTH; 382 fmt.width = DEFAULT_PREVIEW_STILL_WIDTH;
383 fmt.height = DEFAULT_PREVIEW_STILL_HEIGHT; 383 fmt.height = DEFAULT_PREVIEW_STILL_HEIGHT;
384 *format = fmt; 384 *format = fmt;
385 385
386 format = v4l2_subdev_get_try_format(fh, FIMC_ISP_SD_PAD_SRC_DMA); 386 format = v4l2_subdev_get_try_format(sd, fh->pad, FIMC_ISP_SD_PAD_SRC_DMA);
387 *format = fmt; 387 *format = fmt;
388 388
389 return 0; 389 return 0;
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index 2510f189e242..ca6261a86a5f 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -568,7 +568,7 @@ static const struct v4l2_file_operations fimc_lite_fops = {
568 */ 568 */
569 569
570static const struct fimc_fmt *fimc_lite_subdev_try_fmt(struct fimc_lite *fimc, 570static const struct fimc_fmt *fimc_lite_subdev_try_fmt(struct fimc_lite *fimc,
571 struct v4l2_subdev_fh *fh, 571 struct v4l2_subdev_pad_config *cfg,
572 struct v4l2_subdev_format *format) 572 struct v4l2_subdev_format *format)
573{ 573{
574 struct flite_drvdata *dd = fimc->dd; 574 struct flite_drvdata *dd = fimc->dd;
@@ -592,13 +592,13 @@ static const struct fimc_fmt *fimc_lite_subdev_try_fmt(struct fimc_lite *fimc,
592 struct v4l2_rect *rect; 592 struct v4l2_rect *rect;
593 593
594 if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 594 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
595 sink_fmt = v4l2_subdev_get_try_format(fh, 595 sink_fmt = v4l2_subdev_get_try_format(&fimc->subdev, cfg,
596 FLITE_SD_PAD_SINK); 596 FLITE_SD_PAD_SINK);
597 597
598 mf->code = sink_fmt->code; 598 mf->code = sink_fmt->code;
599 mf->colorspace = sink_fmt->colorspace; 599 mf->colorspace = sink_fmt->colorspace;
600 600
601 rect = v4l2_subdev_get_try_crop(fh, 601 rect = v4l2_subdev_get_try_crop(&fimc->subdev, cfg,
602 FLITE_SD_PAD_SINK); 602 FLITE_SD_PAD_SINK);
603 } else { 603 } else {
604 mf->code = sink->fmt->mbus_code; 604 mf->code = sink->fmt->mbus_code;
@@ -1047,7 +1047,7 @@ static const struct media_entity_operations fimc_lite_subdev_media_ops = {
1047}; 1047};
1048 1048
1049static int fimc_lite_subdev_enum_mbus_code(struct v4l2_subdev *sd, 1049static int fimc_lite_subdev_enum_mbus_code(struct v4l2_subdev *sd,
1050 struct v4l2_subdev_fh *fh, 1050 struct v4l2_subdev_pad_config *cfg,
1051 struct v4l2_subdev_mbus_code_enum *code) 1051 struct v4l2_subdev_mbus_code_enum *code)
1052{ 1052{
1053 const struct fimc_fmt *fmt; 1053 const struct fimc_fmt *fmt;
@@ -1060,16 +1060,17 @@ static int fimc_lite_subdev_enum_mbus_code(struct v4l2_subdev *sd,
1060} 1060}
1061 1061
1062static struct v4l2_mbus_framefmt *__fimc_lite_subdev_get_try_fmt( 1062static struct v4l2_mbus_framefmt *__fimc_lite_subdev_get_try_fmt(
1063 struct v4l2_subdev_fh *fh, unsigned int pad) 1063 struct v4l2_subdev *sd,
1064 struct v4l2_subdev_pad_config *cfg, unsigned int pad)
1064{ 1065{
1065 if (pad != FLITE_SD_PAD_SINK) 1066 if (pad != FLITE_SD_PAD_SINK)
1066 pad = FLITE_SD_PAD_SOURCE_DMA; 1067 pad = FLITE_SD_PAD_SOURCE_DMA;
1067 1068
1068 return v4l2_subdev_get_try_format(fh, pad); 1069 return v4l2_subdev_get_try_format(sd, cfg, pad);
1069} 1070}
1070 1071
1071static int fimc_lite_subdev_get_fmt(struct v4l2_subdev *sd, 1072static int fimc_lite_subdev_get_fmt(struct v4l2_subdev *sd,
1072 struct v4l2_subdev_fh *fh, 1073 struct v4l2_subdev_pad_config *cfg,
1073 struct v4l2_subdev_format *fmt) 1074 struct v4l2_subdev_format *fmt)
1074{ 1075{
1075 struct fimc_lite *fimc = v4l2_get_subdevdata(sd); 1076 struct fimc_lite *fimc = v4l2_get_subdevdata(sd);
@@ -1077,7 +1078,7 @@ static int fimc_lite_subdev_get_fmt(struct v4l2_subdev *sd,
1077 struct flite_frame *f = &fimc->inp_frame; 1078 struct flite_frame *f = &fimc->inp_frame;
1078 1079
1079 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1080 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1080 mf = __fimc_lite_subdev_get_try_fmt(fh, fmt->pad); 1081 mf = __fimc_lite_subdev_get_try_fmt(sd, cfg, fmt->pad);
1081 fmt->format = *mf; 1082 fmt->format = *mf;
1082 return 0; 1083 return 0;
1083 } 1084 }
@@ -1100,7 +1101,7 @@ static int fimc_lite_subdev_get_fmt(struct v4l2_subdev *sd,
1100} 1101}
1101 1102
1102static int fimc_lite_subdev_set_fmt(struct v4l2_subdev *sd, 1103static int fimc_lite_subdev_set_fmt(struct v4l2_subdev *sd,
1103 struct v4l2_subdev_fh *fh, 1104 struct v4l2_subdev_pad_config *cfg,
1104 struct v4l2_subdev_format *fmt) 1105 struct v4l2_subdev_format *fmt)
1105{ 1106{
1106 struct fimc_lite *fimc = v4l2_get_subdevdata(sd); 1107 struct fimc_lite *fimc = v4l2_get_subdevdata(sd);
@@ -1122,17 +1123,17 @@ static int fimc_lite_subdev_set_fmt(struct v4l2_subdev *sd,
1122 return -EBUSY; 1123 return -EBUSY;
1123 } 1124 }
1124 1125
1125 ffmt = fimc_lite_subdev_try_fmt(fimc, fh, fmt); 1126 ffmt = fimc_lite_subdev_try_fmt(fimc, cfg, fmt);
1126 1127
1127 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1128 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1128 struct v4l2_mbus_framefmt *src_fmt; 1129 struct v4l2_mbus_framefmt *src_fmt;
1129 1130
1130 mf = __fimc_lite_subdev_get_try_fmt(fh, fmt->pad); 1131 mf = __fimc_lite_subdev_get_try_fmt(sd, cfg, fmt->pad);
1131 *mf = fmt->format; 1132 *mf = fmt->format;
1132 1133
1133 if (fmt->pad == FLITE_SD_PAD_SINK) { 1134 if (fmt->pad == FLITE_SD_PAD_SINK) {
1134 unsigned int pad = FLITE_SD_PAD_SOURCE_DMA; 1135 unsigned int pad = FLITE_SD_PAD_SOURCE_DMA;
1135 src_fmt = __fimc_lite_subdev_get_try_fmt(fh, pad); 1136 src_fmt = __fimc_lite_subdev_get_try_fmt(sd, cfg, pad);
1136 *src_fmt = *mf; 1137 *src_fmt = *mf;
1137 } 1138 }
1138 1139
@@ -1160,7 +1161,7 @@ static int fimc_lite_subdev_set_fmt(struct v4l2_subdev *sd,
1160} 1161}
1161 1162
1162static int fimc_lite_subdev_get_selection(struct v4l2_subdev *sd, 1163static int fimc_lite_subdev_get_selection(struct v4l2_subdev *sd,
1163 struct v4l2_subdev_fh *fh, 1164 struct v4l2_subdev_pad_config *cfg,
1164 struct v4l2_subdev_selection *sel) 1165 struct v4l2_subdev_selection *sel)
1165{ 1166{
1166 struct fimc_lite *fimc = v4l2_get_subdevdata(sd); 1167 struct fimc_lite *fimc = v4l2_get_subdevdata(sd);
@@ -1172,7 +1173,7 @@ static int fimc_lite_subdev_get_selection(struct v4l2_subdev *sd,
1172 return -EINVAL; 1173 return -EINVAL;
1173 1174
1174 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { 1175 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
1175 sel->r = *v4l2_subdev_get_try_crop(fh, sel->pad); 1176 sel->r = *v4l2_subdev_get_try_crop(sd, cfg, sel->pad);
1176 return 0; 1177 return 0;
1177 } 1178 }
1178 1179
@@ -1195,7 +1196,7 @@ static int fimc_lite_subdev_get_selection(struct v4l2_subdev *sd,
1195} 1196}
1196 1197
1197static int fimc_lite_subdev_set_selection(struct v4l2_subdev *sd, 1198static int fimc_lite_subdev_set_selection(struct v4l2_subdev *sd,
1198 struct v4l2_subdev_fh *fh, 1199 struct v4l2_subdev_pad_config *cfg,
1199 struct v4l2_subdev_selection *sel) 1200 struct v4l2_subdev_selection *sel)
1200{ 1201{
1201 struct fimc_lite *fimc = v4l2_get_subdevdata(sd); 1202 struct fimc_lite *fimc = v4l2_get_subdevdata(sd);
@@ -1209,7 +1210,7 @@ static int fimc_lite_subdev_set_selection(struct v4l2_subdev *sd,
1209 fimc_lite_try_crop(fimc, &sel->r); 1210 fimc_lite_try_crop(fimc, &sel->r);
1210 1211
1211 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { 1212 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
1212 *v4l2_subdev_get_try_crop(fh, sel->pad) = sel->r; 1213 *v4l2_subdev_get_try_crop(sd, cfg, sel->pad) = sel->r;
1213 } else { 1214 } else {
1214 unsigned long flags; 1215 unsigned long flags;
1215 spin_lock_irqsave(&fimc->slock, flags); 1216 spin_lock_irqsave(&fimc->slock, flags);
diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c
index 2504aa89a6f4..d74e1bec3d86 100644
--- a/drivers/media/platform/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/exynos4-is/mipi-csis.c
@@ -540,7 +540,7 @@ unlock:
540} 540}
541 541
542static int s5pcsis_enum_mbus_code(struct v4l2_subdev *sd, 542static int s5pcsis_enum_mbus_code(struct v4l2_subdev *sd,
543 struct v4l2_subdev_fh *fh, 543 struct v4l2_subdev_pad_config *cfg,
544 struct v4l2_subdev_mbus_code_enum *code) 544 struct v4l2_subdev_mbus_code_enum *code)
545{ 545{
546 if (code->index >= ARRAY_SIZE(s5pcsis_formats)) 546 if (code->index >= ARRAY_SIZE(s5pcsis_formats))
@@ -568,23 +568,23 @@ static struct csis_pix_format const *s5pcsis_try_format(
568} 568}
569 569
570static struct v4l2_mbus_framefmt *__s5pcsis_get_format( 570static struct v4l2_mbus_framefmt *__s5pcsis_get_format(
571 struct csis_state *state, struct v4l2_subdev_fh *fh, 571 struct csis_state *state, struct v4l2_subdev_pad_config *cfg,
572 enum v4l2_subdev_format_whence which) 572 enum v4l2_subdev_format_whence which)
573{ 573{
574 if (which == V4L2_SUBDEV_FORMAT_TRY) 574 if (which == V4L2_SUBDEV_FORMAT_TRY)
575 return fh ? v4l2_subdev_get_try_format(fh, 0) : NULL; 575 return cfg ? v4l2_subdev_get_try_format(&state->sd, cfg, 0) : NULL;
576 576
577 return &state->format; 577 return &state->format;
578} 578}
579 579
580static int s5pcsis_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 580static int s5pcsis_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
581 struct v4l2_subdev_format *fmt) 581 struct v4l2_subdev_format *fmt)
582{ 582{
583 struct csis_state *state = sd_to_csis_state(sd); 583 struct csis_state *state = sd_to_csis_state(sd);
584 struct csis_pix_format const *csis_fmt; 584 struct csis_pix_format const *csis_fmt;
585 struct v4l2_mbus_framefmt *mf; 585 struct v4l2_mbus_framefmt *mf;
586 586
587 mf = __s5pcsis_get_format(state, fh, fmt->which); 587 mf = __s5pcsis_get_format(state, cfg, fmt->which);
588 588
589 if (fmt->pad == CSIS_PAD_SOURCE) { 589 if (fmt->pad == CSIS_PAD_SOURCE) {
590 if (mf) { 590 if (mf) {
@@ -605,13 +605,13 @@ static int s5pcsis_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
605 return 0; 605 return 0;
606} 606}
607 607
608static int s5pcsis_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 608static int s5pcsis_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
609 struct v4l2_subdev_format *fmt) 609 struct v4l2_subdev_format *fmt)
610{ 610{
611 struct csis_state *state = sd_to_csis_state(sd); 611 struct csis_state *state = sd_to_csis_state(sd);
612 struct v4l2_mbus_framefmt *mf; 612 struct v4l2_mbus_framefmt *mf;
613 613
614 mf = __s5pcsis_get_format(state, fh, fmt->which); 614 mf = __s5pcsis_get_format(state, cfg, fmt->which);
615 if (!mf) 615 if (!mf)
616 return -EINVAL; 616 return -EINVAL;
617 617
@@ -651,7 +651,7 @@ static int s5pcsis_log_status(struct v4l2_subdev *sd)
651 651
652static int s5pcsis_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) 652static int s5pcsis_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
653{ 653{
654 struct v4l2_mbus_framefmt *format = v4l2_subdev_get_try_format(fh, 0); 654 struct v4l2_mbus_framefmt *format = v4l2_subdev_get_try_format(sd, fh->pad, 0);
655 655
656 format->colorspace = V4L2_COLORSPACE_JPEG; 656 format->colorspace = V4L2_COLORSPACE_JPEG;
657 format->code = s5pcsis_formats[0].code; 657 format->code = s5pcsis_formats[0].code;
diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c
index 587489a072d5..b0431a988d47 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -32,7 +32,7 @@
32#define CCDC_MIN_HEIGHT 32 32#define CCDC_MIN_HEIGHT 32
33 33
34static struct v4l2_mbus_framefmt * 34static struct v4l2_mbus_framefmt *
35__ccdc_get_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh, 35__ccdc_get_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_pad_config *cfg,
36 unsigned int pad, enum v4l2_subdev_format_whence which); 36 unsigned int pad, enum v4l2_subdev_format_whence which);
37 37
38static const unsigned int ccdc_fmts[] = { 38static const unsigned int ccdc_fmts[] = {
@@ -1935,21 +1935,21 @@ static int ccdc_set_stream(struct v4l2_subdev *sd, int enable)
1935} 1935}
1936 1936
1937static struct v4l2_mbus_framefmt * 1937static struct v4l2_mbus_framefmt *
1938__ccdc_get_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh, 1938__ccdc_get_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_pad_config *cfg,
1939 unsigned int pad, enum v4l2_subdev_format_whence which) 1939 unsigned int pad, enum v4l2_subdev_format_whence which)
1940{ 1940{
1941 if (which == V4L2_SUBDEV_FORMAT_TRY) 1941 if (which == V4L2_SUBDEV_FORMAT_TRY)
1942 return v4l2_subdev_get_try_format(fh, pad); 1942 return v4l2_subdev_get_try_format(&ccdc->subdev, cfg, pad);
1943 else 1943 else
1944 return &ccdc->formats[pad]; 1944 return &ccdc->formats[pad];
1945} 1945}
1946 1946
1947static struct v4l2_rect * 1947static struct v4l2_rect *
1948__ccdc_get_crop(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh, 1948__ccdc_get_crop(struct isp_ccdc_device *ccdc, struct v4l2_subdev_pad_config *cfg,
1949 enum v4l2_subdev_format_whence which) 1949 enum v4l2_subdev_format_whence which)
1950{ 1950{
1951 if (which == V4L2_SUBDEV_FORMAT_TRY) 1951 if (which == V4L2_SUBDEV_FORMAT_TRY)
1952 return v4l2_subdev_get_try_crop(fh, CCDC_PAD_SOURCE_OF); 1952 return v4l2_subdev_get_try_crop(&ccdc->subdev, cfg, CCDC_PAD_SOURCE_OF);
1953 else 1953 else
1954 return &ccdc->crop; 1954 return &ccdc->crop;
1955} 1955}
@@ -1957,12 +1957,12 @@ __ccdc_get_crop(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh,
1957/* 1957/*
1958 * ccdc_try_format - Try video format on a pad 1958 * ccdc_try_format - Try video format on a pad
1959 * @ccdc: ISP CCDC device 1959 * @ccdc: ISP CCDC device
1960 * @fh : V4L2 subdev file handle 1960 * @cfg : V4L2 subdev pad configuration
1961 * @pad: Pad number 1961 * @pad: Pad number
1962 * @fmt: Format 1962 * @fmt: Format
1963 */ 1963 */
1964static void 1964static void
1965ccdc_try_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh, 1965ccdc_try_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_pad_config *cfg,
1966 unsigned int pad, struct v4l2_mbus_framefmt *fmt, 1966 unsigned int pad, struct v4l2_mbus_framefmt *fmt,
1967 enum v4l2_subdev_format_whence which) 1967 enum v4l2_subdev_format_whence which)
1968{ 1968{
@@ -1998,7 +1998,7 @@ ccdc_try_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh,
1998 case CCDC_PAD_SOURCE_OF: 1998 case CCDC_PAD_SOURCE_OF:
1999 pixelcode = fmt->code; 1999 pixelcode = fmt->code;
2000 field = fmt->field; 2000 field = fmt->field;
2001 *fmt = *__ccdc_get_format(ccdc, fh, CCDC_PAD_SINK, which); 2001 *fmt = *__ccdc_get_format(ccdc, cfg, CCDC_PAD_SINK, which);
2002 2002
2003 /* In SYNC mode the bridge converts YUV formats from 2X8 to 2003 /* In SYNC mode the bridge converts YUV formats from 2X8 to
2004 * 1X16. In BT.656 no such conversion occurs. As we don't know 2004 * 1X16. In BT.656 no such conversion occurs. As we don't know
@@ -2023,7 +2023,7 @@ ccdc_try_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh,
2023 } 2023 }
2024 2024
2025 /* Hardcode the output size to the crop rectangle size. */ 2025 /* Hardcode the output size to the crop rectangle size. */
2026 crop = __ccdc_get_crop(ccdc, fh, which); 2026 crop = __ccdc_get_crop(ccdc, cfg, which);
2027 fmt->width = crop->width; 2027 fmt->width = crop->width;
2028 fmt->height = crop->height; 2028 fmt->height = crop->height;
2029 2029
@@ -2040,7 +2040,7 @@ ccdc_try_format(struct isp_ccdc_device *ccdc, struct v4l2_subdev_fh *fh,
2040 break; 2040 break;
2041 2041
2042 case CCDC_PAD_SOURCE_VP: 2042 case CCDC_PAD_SOURCE_VP:
2043 *fmt = *__ccdc_get_format(ccdc, fh, CCDC_PAD_SINK, which); 2043 *fmt = *__ccdc_get_format(ccdc, cfg, CCDC_PAD_SINK, which);
2044 2044
2045 /* The video port interface truncates the data to 10 bits. */ 2045 /* The video port interface truncates the data to 10 bits. */
2046 info = omap3isp_video_format_info(fmt->code); 2046 info = omap3isp_video_format_info(fmt->code);
@@ -2112,12 +2112,12 @@ static void ccdc_try_crop(struct isp_ccdc_device *ccdc,
2112/* 2112/*
2113 * ccdc_enum_mbus_code - Handle pixel format enumeration 2113 * ccdc_enum_mbus_code - Handle pixel format enumeration
2114 * @sd : pointer to v4l2 subdev structure 2114 * @sd : pointer to v4l2 subdev structure
2115 * @fh : V4L2 subdev file handle 2115 * @cfg : V4L2 subdev pad configuration
2116 * @code : pointer to v4l2_subdev_mbus_code_enum structure 2116 * @code : pointer to v4l2_subdev_mbus_code_enum structure
2117 * return -EINVAL or zero on success 2117 * return -EINVAL or zero on success
2118 */ 2118 */
2119static int ccdc_enum_mbus_code(struct v4l2_subdev *sd, 2119static int ccdc_enum_mbus_code(struct v4l2_subdev *sd,
2120 struct v4l2_subdev_fh *fh, 2120 struct v4l2_subdev_pad_config *cfg,
2121 struct v4l2_subdev_mbus_code_enum *code) 2121 struct v4l2_subdev_mbus_code_enum *code)
2122{ 2122{
2123 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); 2123 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd);
@@ -2132,7 +2132,7 @@ static int ccdc_enum_mbus_code(struct v4l2_subdev *sd,
2132 break; 2132 break;
2133 2133
2134 case CCDC_PAD_SOURCE_OF: 2134 case CCDC_PAD_SOURCE_OF:
2135 format = __ccdc_get_format(ccdc, fh, code->pad, 2135 format = __ccdc_get_format(ccdc, cfg, code->pad,
2136 V4L2_SUBDEV_FORMAT_TRY); 2136 V4L2_SUBDEV_FORMAT_TRY);
2137 2137
2138 if (format->code == MEDIA_BUS_FMT_YUYV8_2X8 || 2138 if (format->code == MEDIA_BUS_FMT_YUYV8_2X8 ||
@@ -2163,7 +2163,7 @@ static int ccdc_enum_mbus_code(struct v4l2_subdev *sd,
2163 if (code->index != 0) 2163 if (code->index != 0)
2164 return -EINVAL; 2164 return -EINVAL;
2165 2165
2166 format = __ccdc_get_format(ccdc, fh, code->pad, 2166 format = __ccdc_get_format(ccdc, cfg, code->pad,
2167 V4L2_SUBDEV_FORMAT_TRY); 2167 V4L2_SUBDEV_FORMAT_TRY);
2168 2168
2169 /* A pixel code equal to 0 means that the video port doesn't 2169 /* A pixel code equal to 0 means that the video port doesn't
@@ -2183,7 +2183,7 @@ static int ccdc_enum_mbus_code(struct v4l2_subdev *sd,
2183} 2183}
2184 2184
2185static int ccdc_enum_frame_size(struct v4l2_subdev *sd, 2185static int ccdc_enum_frame_size(struct v4l2_subdev *sd,
2186 struct v4l2_subdev_fh *fh, 2186 struct v4l2_subdev_pad_config *cfg,
2187 struct v4l2_subdev_frame_size_enum *fse) 2187 struct v4l2_subdev_frame_size_enum *fse)
2188{ 2188{
2189 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); 2189 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd);
@@ -2195,7 +2195,7 @@ static int ccdc_enum_frame_size(struct v4l2_subdev *sd,
2195 format.code = fse->code; 2195 format.code = fse->code;
2196 format.width = 1; 2196 format.width = 1;
2197 format.height = 1; 2197 format.height = 1;
2198 ccdc_try_format(ccdc, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 2198 ccdc_try_format(ccdc, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
2199 fse->min_width = format.width; 2199 fse->min_width = format.width;
2200 fse->min_height = format.height; 2200 fse->min_height = format.height;
2201 2201
@@ -2205,7 +2205,7 @@ static int ccdc_enum_frame_size(struct v4l2_subdev *sd,
2205 format.code = fse->code; 2205 format.code = fse->code;
2206 format.width = -1; 2206 format.width = -1;
2207 format.height = -1; 2207 format.height = -1;
2208 ccdc_try_format(ccdc, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 2208 ccdc_try_format(ccdc, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
2209 fse->max_width = format.width; 2209 fse->max_width = format.width;
2210 fse->max_height = format.height; 2210 fse->max_height = format.height;
2211 2211
@@ -2215,7 +2215,7 @@ static int ccdc_enum_frame_size(struct v4l2_subdev *sd,
2215/* 2215/*
2216 * ccdc_get_selection - Retrieve a selection rectangle on a pad 2216 * ccdc_get_selection - Retrieve a selection rectangle on a pad
2217 * @sd: ISP CCDC V4L2 subdevice 2217 * @sd: ISP CCDC V4L2 subdevice
2218 * @fh: V4L2 subdev file handle 2218 * @cfg: V4L2 subdev pad configuration
2219 * @sel: Selection rectangle 2219 * @sel: Selection rectangle
2220 * 2220 *
2221 * The only supported rectangles are the crop rectangles on the output formatter 2221 * The only supported rectangles are the crop rectangles on the output formatter
@@ -2223,7 +2223,7 @@ static int ccdc_enum_frame_size(struct v4l2_subdev *sd,
2223 * 2223 *
2224 * Return 0 on success or a negative error code otherwise. 2224 * Return 0 on success or a negative error code otherwise.
2225 */ 2225 */
2226static int ccdc_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 2226static int ccdc_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
2227 struct v4l2_subdev_selection *sel) 2227 struct v4l2_subdev_selection *sel)
2228{ 2228{
2229 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); 2229 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd);
@@ -2239,12 +2239,12 @@ static int ccdc_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
2239 sel->r.width = INT_MAX; 2239 sel->r.width = INT_MAX;
2240 sel->r.height = INT_MAX; 2240 sel->r.height = INT_MAX;
2241 2241
2242 format = __ccdc_get_format(ccdc, fh, CCDC_PAD_SINK, sel->which); 2242 format = __ccdc_get_format(ccdc, cfg, CCDC_PAD_SINK, sel->which);
2243 ccdc_try_crop(ccdc, format, &sel->r); 2243 ccdc_try_crop(ccdc, format, &sel->r);
2244 break; 2244 break;
2245 2245
2246 case V4L2_SEL_TGT_CROP: 2246 case V4L2_SEL_TGT_CROP:
2247 sel->r = *__ccdc_get_crop(ccdc, fh, sel->which); 2247 sel->r = *__ccdc_get_crop(ccdc, cfg, sel->which);
2248 break; 2248 break;
2249 2249
2250 default: 2250 default:
@@ -2257,7 +2257,7 @@ static int ccdc_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
2257/* 2257/*
2258 * ccdc_set_selection - Set a selection rectangle on a pad 2258 * ccdc_set_selection - Set a selection rectangle on a pad
2259 * @sd: ISP CCDC V4L2 subdevice 2259 * @sd: ISP CCDC V4L2 subdevice
2260 * @fh: V4L2 subdev file handle 2260 * @cfg: V4L2 subdev pad configuration
2261 * @sel: Selection rectangle 2261 * @sel: Selection rectangle
2262 * 2262 *
2263 * The only supported rectangle is the actual crop rectangle on the output 2263 * The only supported rectangle is the actual crop rectangle on the output
@@ -2265,7 +2265,7 @@ static int ccdc_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
2265 * 2265 *
2266 * Return 0 on success or a negative error code otherwise. 2266 * Return 0 on success or a negative error code otherwise.
2267 */ 2267 */
2268static int ccdc_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 2268static int ccdc_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
2269 struct v4l2_subdev_selection *sel) 2269 struct v4l2_subdev_selection *sel)
2270{ 2270{
2271 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); 2271 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd);
@@ -2284,17 +2284,17 @@ static int ccdc_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
2284 * rectangle. 2284 * rectangle.
2285 */ 2285 */
2286 if (sel->flags & V4L2_SEL_FLAG_KEEP_CONFIG) { 2286 if (sel->flags & V4L2_SEL_FLAG_KEEP_CONFIG) {
2287 sel->r = *__ccdc_get_crop(ccdc, fh, sel->which); 2287 sel->r = *__ccdc_get_crop(ccdc, cfg, sel->which);
2288 return 0; 2288 return 0;
2289 } 2289 }
2290 2290
2291 format = __ccdc_get_format(ccdc, fh, CCDC_PAD_SINK, sel->which); 2291 format = __ccdc_get_format(ccdc, cfg, CCDC_PAD_SINK, sel->which);
2292 ccdc_try_crop(ccdc, format, &sel->r); 2292 ccdc_try_crop(ccdc, format, &sel->r);
2293 *__ccdc_get_crop(ccdc, fh, sel->which) = sel->r; 2293 *__ccdc_get_crop(ccdc, cfg, sel->which) = sel->r;
2294 2294
2295 /* Update the source format. */ 2295 /* Update the source format. */
2296 format = __ccdc_get_format(ccdc, fh, CCDC_PAD_SOURCE_OF, sel->which); 2296 format = __ccdc_get_format(ccdc, cfg, CCDC_PAD_SOURCE_OF, sel->which);
2297 ccdc_try_format(ccdc, fh, CCDC_PAD_SOURCE_OF, format, sel->which); 2297 ccdc_try_format(ccdc, cfg, CCDC_PAD_SOURCE_OF, format, sel->which);
2298 2298
2299 return 0; 2299 return 0;
2300} 2300}
@@ -2302,19 +2302,19 @@ static int ccdc_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
2302/* 2302/*
2303 * ccdc_get_format - Retrieve the video format on a pad 2303 * ccdc_get_format - Retrieve the video format on a pad
2304 * @sd : ISP CCDC V4L2 subdevice 2304 * @sd : ISP CCDC V4L2 subdevice
2305 * @fh : V4L2 subdev file handle 2305 * @cfg: V4L2 subdev pad configuration
2306 * @fmt: Format 2306 * @fmt: Format
2307 * 2307 *
2308 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond 2308 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
2309 * to the format type. 2309 * to the format type.
2310 */ 2310 */
2311static int ccdc_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 2311static int ccdc_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
2312 struct v4l2_subdev_format *fmt) 2312 struct v4l2_subdev_format *fmt)
2313{ 2313{
2314 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); 2314 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd);
2315 struct v4l2_mbus_framefmt *format; 2315 struct v4l2_mbus_framefmt *format;
2316 2316
2317 format = __ccdc_get_format(ccdc, fh, fmt->pad, fmt->which); 2317 format = __ccdc_get_format(ccdc, cfg, fmt->pad, fmt->which);
2318 if (format == NULL) 2318 if (format == NULL)
2319 return -EINVAL; 2319 return -EINVAL;
2320 2320
@@ -2325,30 +2325,30 @@ static int ccdc_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
2325/* 2325/*
2326 * ccdc_set_format - Set the video format on a pad 2326 * ccdc_set_format - Set the video format on a pad
2327 * @sd : ISP CCDC V4L2 subdevice 2327 * @sd : ISP CCDC V4L2 subdevice
2328 * @fh : V4L2 subdev file handle 2328 * @cfg: V4L2 subdev pad configuration
2329 * @fmt: Format 2329 * @fmt: Format
2330 * 2330 *
2331 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond 2331 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
2332 * to the format type. 2332 * to the format type.
2333 */ 2333 */
2334static int ccdc_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 2334static int ccdc_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
2335 struct v4l2_subdev_format *fmt) 2335 struct v4l2_subdev_format *fmt)
2336{ 2336{
2337 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); 2337 struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd);
2338 struct v4l2_mbus_framefmt *format; 2338 struct v4l2_mbus_framefmt *format;
2339 struct v4l2_rect *crop; 2339 struct v4l2_rect *crop;
2340 2340
2341 format = __ccdc_get_format(ccdc, fh, fmt->pad, fmt->which); 2341 format = __ccdc_get_format(ccdc, cfg, fmt->pad, fmt->which);
2342 if (format == NULL) 2342 if (format == NULL)
2343 return -EINVAL; 2343 return -EINVAL;
2344 2344
2345 ccdc_try_format(ccdc, fh, fmt->pad, &fmt->format, fmt->which); 2345 ccdc_try_format(ccdc, cfg, fmt->pad, &fmt->format, fmt->which);
2346 *format = fmt->format; 2346 *format = fmt->format;
2347 2347
2348 /* Propagate the format from sink to source */ 2348 /* Propagate the format from sink to source */
2349 if (fmt->pad == CCDC_PAD_SINK) { 2349 if (fmt->pad == CCDC_PAD_SINK) {
2350 /* Reset the crop rectangle. */ 2350 /* Reset the crop rectangle. */
2351 crop = __ccdc_get_crop(ccdc, fh, fmt->which); 2351 crop = __ccdc_get_crop(ccdc, cfg, fmt->which);
2352 crop->left = 0; 2352 crop->left = 0;
2353 crop->top = 0; 2353 crop->top = 0;
2354 crop->width = fmt->format.width; 2354 crop->width = fmt->format.width;
@@ -2357,16 +2357,16 @@ static int ccdc_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
2357 ccdc_try_crop(ccdc, &fmt->format, crop); 2357 ccdc_try_crop(ccdc, &fmt->format, crop);
2358 2358
2359 /* Update the source formats. */ 2359 /* Update the source formats. */
2360 format = __ccdc_get_format(ccdc, fh, CCDC_PAD_SOURCE_OF, 2360 format = __ccdc_get_format(ccdc, cfg, CCDC_PAD_SOURCE_OF,
2361 fmt->which); 2361 fmt->which);
2362 *format = fmt->format; 2362 *format = fmt->format;
2363 ccdc_try_format(ccdc, fh, CCDC_PAD_SOURCE_OF, format, 2363 ccdc_try_format(ccdc, cfg, CCDC_PAD_SOURCE_OF, format,
2364 fmt->which); 2364 fmt->which);
2365 2365
2366 format = __ccdc_get_format(ccdc, fh, CCDC_PAD_SOURCE_VP, 2366 format = __ccdc_get_format(ccdc, cfg, CCDC_PAD_SOURCE_VP,
2367 fmt->which); 2367 fmt->which);
2368 *format = fmt->format; 2368 *format = fmt->format;
2369 ccdc_try_format(ccdc, fh, CCDC_PAD_SOURCE_VP, format, 2369 ccdc_try_format(ccdc, cfg, CCDC_PAD_SOURCE_VP, format,
2370 fmt->which); 2370 fmt->which);
2371 } 2371 }
2372 2372
@@ -2453,7 +2453,7 @@ static int ccdc_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
2453 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; 2453 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
2454 format.format.width = 4096; 2454 format.format.width = 4096;
2455 format.format.height = 4096; 2455 format.format.height = 4096;
2456 ccdc_set_format(sd, fh, &format); 2456 ccdc_set_format(sd, fh ? fh->pad : NULL, &format);
2457 2457
2458 return 0; 2458 return 0;
2459} 2459}
diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c
index f4aedb37e41e..3f10c3af3a0a 100644
--- a/drivers/media/platform/omap3isp/ispccp2.c
+++ b/drivers/media/platform/omap3isp/ispccp2.c
@@ -611,17 +611,17 @@ static const unsigned int ccp2_fmts[] = {
611/* 611/*
612 * __ccp2_get_format - helper function for getting ccp2 format 612 * __ccp2_get_format - helper function for getting ccp2 format
613 * @ccp2 : Pointer to ISP CCP2 device 613 * @ccp2 : Pointer to ISP CCP2 device
614 * @fh : V4L2 subdev file handle 614 * @cfg: V4L2 subdev pad configuration
615 * @pad : pad number 615 * @pad : pad number
616 * @which : wanted subdev format 616 * @which : wanted subdev format
617 * return format structure or NULL on error 617 * return format structure or NULL on error
618 */ 618 */
619static struct v4l2_mbus_framefmt * 619static struct v4l2_mbus_framefmt *
620__ccp2_get_format(struct isp_ccp2_device *ccp2, struct v4l2_subdev_fh *fh, 620__ccp2_get_format(struct isp_ccp2_device *ccp2, struct v4l2_subdev_pad_config *cfg,
621 unsigned int pad, enum v4l2_subdev_format_whence which) 621 unsigned int pad, enum v4l2_subdev_format_whence which)
622{ 622{
623 if (which == V4L2_SUBDEV_FORMAT_TRY) 623 if (which == V4L2_SUBDEV_FORMAT_TRY)
624 return v4l2_subdev_get_try_format(fh, pad); 624 return v4l2_subdev_get_try_format(&ccp2->subdev, cfg, pad);
625 else 625 else
626 return &ccp2->formats[pad]; 626 return &ccp2->formats[pad];
627} 627}
@@ -629,13 +629,13 @@ __ccp2_get_format(struct isp_ccp2_device *ccp2, struct v4l2_subdev_fh *fh,
629/* 629/*
630 * ccp2_try_format - Handle try format by pad subdev method 630 * ccp2_try_format - Handle try format by pad subdev method
631 * @ccp2 : Pointer to ISP CCP2 device 631 * @ccp2 : Pointer to ISP CCP2 device
632 * @fh : V4L2 subdev file handle 632 * @cfg: V4L2 subdev pad configuration
633 * @pad : pad num 633 * @pad : pad num
634 * @fmt : pointer to v4l2 mbus format structure 634 * @fmt : pointer to v4l2 mbus format structure
635 * @which : wanted subdev format 635 * @which : wanted subdev format
636 */ 636 */
637static void ccp2_try_format(struct isp_ccp2_device *ccp2, 637static void ccp2_try_format(struct isp_ccp2_device *ccp2,
638 struct v4l2_subdev_fh *fh, unsigned int pad, 638 struct v4l2_subdev_pad_config *cfg, unsigned int pad,
639 struct v4l2_mbus_framefmt *fmt, 639 struct v4l2_mbus_framefmt *fmt,
640 enum v4l2_subdev_format_whence which) 640 enum v4l2_subdev_format_whence which)
641{ 641{
@@ -669,7 +669,7 @@ static void ccp2_try_format(struct isp_ccp2_device *ccp2,
669 * When CCP2 write to memory feature will be added this 669 * When CCP2 write to memory feature will be added this
670 * should be changed properly. 670 * should be changed properly.
671 */ 671 */
672 format = __ccp2_get_format(ccp2, fh, CCP2_PAD_SINK, which); 672 format = __ccp2_get_format(ccp2, cfg, CCP2_PAD_SINK, which);
673 memcpy(fmt, format, sizeof(*fmt)); 673 memcpy(fmt, format, sizeof(*fmt));
674 fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10; 674 fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
675 break; 675 break;
@@ -682,12 +682,12 @@ static void ccp2_try_format(struct isp_ccp2_device *ccp2,
682/* 682/*
683 * ccp2_enum_mbus_code - Handle pixel format enumeration 683 * ccp2_enum_mbus_code - Handle pixel format enumeration
684 * @sd : pointer to v4l2 subdev structure 684 * @sd : pointer to v4l2 subdev structure
685 * @fh : V4L2 subdev file handle 685 * @cfg: V4L2 subdev pad configuration
686 * @code : pointer to v4l2_subdev_mbus_code_enum structure 686 * @code : pointer to v4l2_subdev_mbus_code_enum structure
687 * return -EINVAL or zero on success 687 * return -EINVAL or zero on success
688 */ 688 */
689static int ccp2_enum_mbus_code(struct v4l2_subdev *sd, 689static int ccp2_enum_mbus_code(struct v4l2_subdev *sd,
690 struct v4l2_subdev_fh *fh, 690 struct v4l2_subdev_pad_config *cfg,
691 struct v4l2_subdev_mbus_code_enum *code) 691 struct v4l2_subdev_mbus_code_enum *code)
692{ 692{
693 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd); 693 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd);
@@ -702,7 +702,7 @@ static int ccp2_enum_mbus_code(struct v4l2_subdev *sd,
702 if (code->index != 0) 702 if (code->index != 0)
703 return -EINVAL; 703 return -EINVAL;
704 704
705 format = __ccp2_get_format(ccp2, fh, CCP2_PAD_SINK, 705 format = __ccp2_get_format(ccp2, cfg, CCP2_PAD_SINK,
706 V4L2_SUBDEV_FORMAT_TRY); 706 V4L2_SUBDEV_FORMAT_TRY);
707 code->code = format->code; 707 code->code = format->code;
708 } 708 }
@@ -711,7 +711,7 @@ static int ccp2_enum_mbus_code(struct v4l2_subdev *sd,
711} 711}
712 712
713static int ccp2_enum_frame_size(struct v4l2_subdev *sd, 713static int ccp2_enum_frame_size(struct v4l2_subdev *sd,
714 struct v4l2_subdev_fh *fh, 714 struct v4l2_subdev_pad_config *cfg,
715 struct v4l2_subdev_frame_size_enum *fse) 715 struct v4l2_subdev_frame_size_enum *fse)
716{ 716{
717 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd); 717 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd);
@@ -723,7 +723,7 @@ static int ccp2_enum_frame_size(struct v4l2_subdev *sd,
723 format.code = fse->code; 723 format.code = fse->code;
724 format.width = 1; 724 format.width = 1;
725 format.height = 1; 725 format.height = 1;
726 ccp2_try_format(ccp2, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 726 ccp2_try_format(ccp2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
727 fse->min_width = format.width; 727 fse->min_width = format.width;
728 fse->min_height = format.height; 728 fse->min_height = format.height;
729 729
@@ -733,7 +733,7 @@ static int ccp2_enum_frame_size(struct v4l2_subdev *sd,
733 format.code = fse->code; 733 format.code = fse->code;
734 format.width = -1; 734 format.width = -1;
735 format.height = -1; 735 format.height = -1;
736 ccp2_try_format(ccp2, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 736 ccp2_try_format(ccp2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
737 fse->max_width = format.width; 737 fse->max_width = format.width;
738 fse->max_height = format.height; 738 fse->max_height = format.height;
739 739
@@ -743,17 +743,17 @@ static int ccp2_enum_frame_size(struct v4l2_subdev *sd,
743/* 743/*
744 * ccp2_get_format - Handle get format by pads subdev method 744 * ccp2_get_format - Handle get format by pads subdev method
745 * @sd : pointer to v4l2 subdev structure 745 * @sd : pointer to v4l2 subdev structure
746 * @fh : V4L2 subdev file handle 746 * @cfg: V4L2 subdev pad configuration
747 * @fmt : pointer to v4l2 subdev format structure 747 * @fmt : pointer to v4l2 subdev format structure
748 * return -EINVAL or zero on success 748 * return -EINVAL or zero on success
749 */ 749 */
750static int ccp2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 750static int ccp2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
751 struct v4l2_subdev_format *fmt) 751 struct v4l2_subdev_format *fmt)
752{ 752{
753 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd); 753 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd);
754 struct v4l2_mbus_framefmt *format; 754 struct v4l2_mbus_framefmt *format;
755 755
756 format = __ccp2_get_format(ccp2, fh, fmt->pad, fmt->which); 756 format = __ccp2_get_format(ccp2, cfg, fmt->pad, fmt->which);
757 if (format == NULL) 757 if (format == NULL)
758 return -EINVAL; 758 return -EINVAL;
759 759
@@ -764,29 +764,29 @@ static int ccp2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
764/* 764/*
765 * ccp2_set_format - Handle set format by pads subdev method 765 * ccp2_set_format - Handle set format by pads subdev method
766 * @sd : pointer to v4l2 subdev structure 766 * @sd : pointer to v4l2 subdev structure
767 * @fh : V4L2 subdev file handle 767 * @cfg: V4L2 subdev pad configuration
768 * @fmt : pointer to v4l2 subdev format structure 768 * @fmt : pointer to v4l2 subdev format structure
769 * returns zero 769 * returns zero
770 */ 770 */
771static int ccp2_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 771static int ccp2_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
772 struct v4l2_subdev_format *fmt) 772 struct v4l2_subdev_format *fmt)
773{ 773{
774 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd); 774 struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd);
775 struct v4l2_mbus_framefmt *format; 775 struct v4l2_mbus_framefmt *format;
776 776
777 format = __ccp2_get_format(ccp2, fh, fmt->pad, fmt->which); 777 format = __ccp2_get_format(ccp2, cfg, fmt->pad, fmt->which);
778 if (format == NULL) 778 if (format == NULL)
779 return -EINVAL; 779 return -EINVAL;
780 780
781 ccp2_try_format(ccp2, fh, fmt->pad, &fmt->format, fmt->which); 781 ccp2_try_format(ccp2, cfg, fmt->pad, &fmt->format, fmt->which);
782 *format = fmt->format; 782 *format = fmt->format;
783 783
784 /* Propagate the format from sink to source */ 784 /* Propagate the format from sink to source */
785 if (fmt->pad == CCP2_PAD_SINK) { 785 if (fmt->pad == CCP2_PAD_SINK) {
786 format = __ccp2_get_format(ccp2, fh, CCP2_PAD_SOURCE, 786 format = __ccp2_get_format(ccp2, cfg, CCP2_PAD_SOURCE,
787 fmt->which); 787 fmt->which);
788 *format = fmt->format; 788 *format = fmt->format;
789 ccp2_try_format(ccp2, fh, CCP2_PAD_SOURCE, format, fmt->which); 789 ccp2_try_format(ccp2, cfg, CCP2_PAD_SOURCE, format, fmt->which);
790 } 790 }
791 791
792 return 0; 792 return 0;
@@ -811,7 +811,7 @@ static int ccp2_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
811 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; 811 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
812 format.format.width = 4096; 812 format.format.width = 4096;
813 format.format.height = 4096; 813 format.format.height = 4096;
814 ccp2_set_format(sd, fh, &format); 814 ccp2_set_format(sd, fh ? fh->pad : NULL, &format);
815 815
816 return 0; 816 return 0;
817} 817}
diff --git a/drivers/media/platform/omap3isp/ispcsi2.c b/drivers/media/platform/omap3isp/ispcsi2.c
index 09c686d96ae8..12ca63f2bf53 100644
--- a/drivers/media/platform/omap3isp/ispcsi2.c
+++ b/drivers/media/platform/omap3isp/ispcsi2.c
@@ -829,17 +829,17 @@ static const struct isp_video_operations csi2_ispvideo_ops = {
829 */ 829 */
830 830
831static struct v4l2_mbus_framefmt * 831static struct v4l2_mbus_framefmt *
832__csi2_get_format(struct isp_csi2_device *csi2, struct v4l2_subdev_fh *fh, 832__csi2_get_format(struct isp_csi2_device *csi2, struct v4l2_subdev_pad_config *cfg,
833 unsigned int pad, enum v4l2_subdev_format_whence which) 833 unsigned int pad, enum v4l2_subdev_format_whence which)
834{ 834{
835 if (which == V4L2_SUBDEV_FORMAT_TRY) 835 if (which == V4L2_SUBDEV_FORMAT_TRY)
836 return v4l2_subdev_get_try_format(fh, pad); 836 return v4l2_subdev_get_try_format(&csi2->subdev, cfg, pad);
837 else 837 else
838 return &csi2->formats[pad]; 838 return &csi2->formats[pad];
839} 839}
840 840
841static void 841static void
842csi2_try_format(struct isp_csi2_device *csi2, struct v4l2_subdev_fh *fh, 842csi2_try_format(struct isp_csi2_device *csi2, struct v4l2_subdev_pad_config *cfg,
843 unsigned int pad, struct v4l2_mbus_framefmt *fmt, 843 unsigned int pad, struct v4l2_mbus_framefmt *fmt,
844 enum v4l2_subdev_format_whence which) 844 enum v4l2_subdev_format_whence which)
845{ 845{
@@ -869,7 +869,7 @@ csi2_try_format(struct isp_csi2_device *csi2, struct v4l2_subdev_fh *fh,
869 * compression. 869 * compression.
870 */ 870 */
871 pixelcode = fmt->code; 871 pixelcode = fmt->code;
872 format = __csi2_get_format(csi2, fh, CSI2_PAD_SINK, which); 872 format = __csi2_get_format(csi2, cfg, CSI2_PAD_SINK, which);
873 memcpy(fmt, format, sizeof(*fmt)); 873 memcpy(fmt, format, sizeof(*fmt));
874 874
875 /* 875 /*
@@ -890,12 +890,12 @@ csi2_try_format(struct isp_csi2_device *csi2, struct v4l2_subdev_fh *fh,
890/* 890/*
891 * csi2_enum_mbus_code - Handle pixel format enumeration 891 * csi2_enum_mbus_code - Handle pixel format enumeration
892 * @sd : pointer to v4l2 subdev structure 892 * @sd : pointer to v4l2 subdev structure
893 * @fh : V4L2 subdev file handle 893 * @cfg: V4L2 subdev pad configuration
894 * @code : pointer to v4l2_subdev_mbus_code_enum structure 894 * @code : pointer to v4l2_subdev_mbus_code_enum structure
895 * return -EINVAL or zero on success 895 * return -EINVAL or zero on success
896 */ 896 */
897static int csi2_enum_mbus_code(struct v4l2_subdev *sd, 897static int csi2_enum_mbus_code(struct v4l2_subdev *sd,
898 struct v4l2_subdev_fh *fh, 898 struct v4l2_subdev_pad_config *cfg,
899 struct v4l2_subdev_mbus_code_enum *code) 899 struct v4l2_subdev_mbus_code_enum *code)
900{ 900{
901 struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd); 901 struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
@@ -908,7 +908,7 @@ static int csi2_enum_mbus_code(struct v4l2_subdev *sd,
908 908
909 code->code = csi2_input_fmts[code->index]; 909 code->code = csi2_input_fmts[code->index];
910 } else { 910 } else {
911 format = __csi2_get_format(csi2, fh, CSI2_PAD_SINK, 911 format = __csi2_get_format(csi2, cfg, CSI2_PAD_SINK,
912 V4L2_SUBDEV_FORMAT_TRY); 912 V4L2_SUBDEV_FORMAT_TRY);
913 switch (code->index) { 913 switch (code->index) {
914 case 0: 914 case 0:
@@ -932,7 +932,7 @@ static int csi2_enum_mbus_code(struct v4l2_subdev *sd,
932} 932}
933 933
934static int csi2_enum_frame_size(struct v4l2_subdev *sd, 934static int csi2_enum_frame_size(struct v4l2_subdev *sd,
935 struct v4l2_subdev_fh *fh, 935 struct v4l2_subdev_pad_config *cfg,
936 struct v4l2_subdev_frame_size_enum *fse) 936 struct v4l2_subdev_frame_size_enum *fse)
937{ 937{
938 struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd); 938 struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
@@ -944,7 +944,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd,
944 format.code = fse->code; 944 format.code = fse->code;
945 format.width = 1; 945 format.width = 1;
946 format.height = 1; 946 format.height = 1;
947 csi2_try_format(csi2, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 947 csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
948 fse->min_width = format.width; 948 fse->min_width = format.width;
949 fse->min_height = format.height; 949 fse->min_height = format.height;
950 950
@@ -954,7 +954,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd,
954 format.code = fse->code; 954 format.code = fse->code;
955 format.width = -1; 955 format.width = -1;
956 format.height = -1; 956 format.height = -1;
957 csi2_try_format(csi2, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 957 csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
958 fse->max_width = format.width; 958 fse->max_width = format.width;
959 fse->max_height = format.height; 959 fse->max_height = format.height;
960 960
@@ -964,17 +964,17 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd,
964/* 964/*
965 * csi2_get_format - Handle get format by pads subdev method 965 * csi2_get_format - Handle get format by pads subdev method
966 * @sd : pointer to v4l2 subdev structure 966 * @sd : pointer to v4l2 subdev structure
967 * @fh : V4L2 subdev file handle 967 * @cfg: V4L2 subdev pad configuration
968 * @fmt: pointer to v4l2 subdev format structure 968 * @fmt: pointer to v4l2 subdev format structure
969 * return -EINVAL or zero on success 969 * return -EINVAL or zero on success
970 */ 970 */
971static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 971static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
972 struct v4l2_subdev_format *fmt) 972 struct v4l2_subdev_format *fmt)
973{ 973{
974 struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd); 974 struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
975 struct v4l2_mbus_framefmt *format; 975 struct v4l2_mbus_framefmt *format;
976 976
977 format = __csi2_get_format(csi2, fh, fmt->pad, fmt->which); 977 format = __csi2_get_format(csi2, cfg, fmt->pad, fmt->which);
978 if (format == NULL) 978 if (format == NULL)
979 return -EINVAL; 979 return -EINVAL;
980 980
@@ -985,29 +985,29 @@ static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
985/* 985/*
986 * csi2_set_format - Handle set format by pads subdev method 986 * csi2_set_format - Handle set format by pads subdev method
987 * @sd : pointer to v4l2 subdev structure 987 * @sd : pointer to v4l2 subdev structure
988 * @fh : V4L2 subdev file handle 988 * @cfg: V4L2 subdev pad configuration
989 * @fmt: pointer to v4l2 subdev format structure 989 * @fmt: pointer to v4l2 subdev format structure
990 * return -EINVAL or zero on success 990 * return -EINVAL or zero on success
991 */ 991 */
992static int csi2_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 992static int csi2_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
993 struct v4l2_subdev_format *fmt) 993 struct v4l2_subdev_format *fmt)
994{ 994{
995 struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd); 995 struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
996 struct v4l2_mbus_framefmt *format; 996 struct v4l2_mbus_framefmt *format;
997 997
998 format = __csi2_get_format(csi2, fh, fmt->pad, fmt->which); 998 format = __csi2_get_format(csi2, cfg, fmt->pad, fmt->which);
999 if (format == NULL) 999 if (format == NULL)
1000 return -EINVAL; 1000 return -EINVAL;
1001 1001
1002 csi2_try_format(csi2, fh, fmt->pad, &fmt->format, fmt->which); 1002 csi2_try_format(csi2, cfg, fmt->pad, &fmt->format, fmt->which);
1003 *format = fmt->format; 1003 *format = fmt->format;
1004 1004
1005 /* Propagate the format from sink to source */ 1005 /* Propagate the format from sink to source */
1006 if (fmt->pad == CSI2_PAD_SINK) { 1006 if (fmt->pad == CSI2_PAD_SINK) {
1007 format = __csi2_get_format(csi2, fh, CSI2_PAD_SOURCE, 1007 format = __csi2_get_format(csi2, cfg, CSI2_PAD_SOURCE,
1008 fmt->which); 1008 fmt->which);
1009 *format = fmt->format; 1009 *format = fmt->format;
1010 csi2_try_format(csi2, fh, CSI2_PAD_SOURCE, format, fmt->which); 1010 csi2_try_format(csi2, cfg, CSI2_PAD_SOURCE, format, fmt->which);
1011 } 1011 }
1012 1012
1013 return 0; 1013 return 0;
@@ -1032,7 +1032,7 @@ static int csi2_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1032 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; 1032 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
1033 format.format.width = 4096; 1033 format.format.width = 4096;
1034 format.format.height = 4096; 1034 format.format.height = 4096;
1035 csi2_set_format(sd, fh, &format); 1035 csi2_set_format(sd, fh ? fh->pad : NULL, &format);
1036 1036
1037 return 0; 1037 return 0;
1038} 1038}
diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c
index dd9eed45d853..0571c57dbae0 100644
--- a/drivers/media/platform/omap3isp/isppreview.c
+++ b/drivers/media/platform/omap3isp/isppreview.c
@@ -1686,21 +1686,21 @@ static int preview_set_stream(struct v4l2_subdev *sd, int enable)
1686} 1686}
1687 1687
1688static struct v4l2_mbus_framefmt * 1688static struct v4l2_mbus_framefmt *
1689__preview_get_format(struct isp_prev_device *prev, struct v4l2_subdev_fh *fh, 1689__preview_get_format(struct isp_prev_device *prev, struct v4l2_subdev_pad_config *cfg,
1690 unsigned int pad, enum v4l2_subdev_format_whence which) 1690 unsigned int pad, enum v4l2_subdev_format_whence which)
1691{ 1691{
1692 if (which == V4L2_SUBDEV_FORMAT_TRY) 1692 if (which == V4L2_SUBDEV_FORMAT_TRY)
1693 return v4l2_subdev_get_try_format(fh, pad); 1693 return v4l2_subdev_get_try_format(&prev->subdev, cfg, pad);
1694 else 1694 else
1695 return &prev->formats[pad]; 1695 return &prev->formats[pad];
1696} 1696}
1697 1697
1698static struct v4l2_rect * 1698static struct v4l2_rect *
1699__preview_get_crop(struct isp_prev_device *prev, struct v4l2_subdev_fh *fh, 1699__preview_get_crop(struct isp_prev_device *prev, struct v4l2_subdev_pad_config *cfg,
1700 enum v4l2_subdev_format_whence which) 1700 enum v4l2_subdev_format_whence which)
1701{ 1701{
1702 if (which == V4L2_SUBDEV_FORMAT_TRY) 1702 if (which == V4L2_SUBDEV_FORMAT_TRY)
1703 return v4l2_subdev_get_try_crop(fh, PREV_PAD_SINK); 1703 return v4l2_subdev_get_try_crop(&prev->subdev, cfg, PREV_PAD_SINK);
1704 else 1704 else
1705 return &prev->crop; 1705 return &prev->crop;
1706} 1706}
@@ -1727,7 +1727,7 @@ static const unsigned int preview_output_fmts[] = {
1727/* 1727/*
1728 * preview_try_format - Validate a format 1728 * preview_try_format - Validate a format
1729 * @prev: ISP preview engine 1729 * @prev: ISP preview engine
1730 * @fh: V4L2 subdev file handle 1730 * @cfg: V4L2 subdev pad configuration
1731 * @pad: pad number 1731 * @pad: pad number
1732 * @fmt: format to be validated 1732 * @fmt: format to be validated
1733 * @which: try/active format selector 1733 * @which: try/active format selector
@@ -1736,7 +1736,7 @@ static const unsigned int preview_output_fmts[] = {
1736 * engine limits and the format and crop rectangles on other pads. 1736 * engine limits and the format and crop rectangles on other pads.
1737 */ 1737 */
1738static void preview_try_format(struct isp_prev_device *prev, 1738static void preview_try_format(struct isp_prev_device *prev,
1739 struct v4l2_subdev_fh *fh, unsigned int pad, 1739 struct v4l2_subdev_pad_config *cfg, unsigned int pad,
1740 struct v4l2_mbus_framefmt *fmt, 1740 struct v4l2_mbus_framefmt *fmt,
1741 enum v4l2_subdev_format_whence which) 1741 enum v4l2_subdev_format_whence which)
1742{ 1742{
@@ -1777,7 +1777,7 @@ static void preview_try_format(struct isp_prev_device *prev,
1777 1777
1778 case PREV_PAD_SOURCE: 1778 case PREV_PAD_SOURCE:
1779 pixelcode = fmt->code; 1779 pixelcode = fmt->code;
1780 *fmt = *__preview_get_format(prev, fh, PREV_PAD_SINK, which); 1780 *fmt = *__preview_get_format(prev, cfg, PREV_PAD_SINK, which);
1781 1781
1782 switch (pixelcode) { 1782 switch (pixelcode) {
1783 case MEDIA_BUS_FMT_YUYV8_1X16: 1783 case MEDIA_BUS_FMT_YUYV8_1X16:
@@ -1795,7 +1795,7 @@ static void preview_try_format(struct isp_prev_device *prev,
1795 * is not supported yet, hardcode the output size to the crop 1795 * is not supported yet, hardcode the output size to the crop
1796 * rectangle size. 1796 * rectangle size.
1797 */ 1797 */
1798 crop = __preview_get_crop(prev, fh, which); 1798 crop = __preview_get_crop(prev, cfg, which);
1799 fmt->width = crop->width; 1799 fmt->width = crop->width;
1800 fmt->height = crop->height; 1800 fmt->height = crop->height;
1801 1801
@@ -1864,12 +1864,12 @@ static void preview_try_crop(struct isp_prev_device *prev,
1864/* 1864/*
1865 * preview_enum_mbus_code - Handle pixel format enumeration 1865 * preview_enum_mbus_code - Handle pixel format enumeration
1866 * @sd : pointer to v4l2 subdev structure 1866 * @sd : pointer to v4l2 subdev structure
1867 * @fh : V4L2 subdev file handle 1867 * @cfg: V4L2 subdev pad configuration
1868 * @code : pointer to v4l2_subdev_mbus_code_enum structure 1868 * @code : pointer to v4l2_subdev_mbus_code_enum structure
1869 * return -EINVAL or zero on success 1869 * return -EINVAL or zero on success
1870 */ 1870 */
1871static int preview_enum_mbus_code(struct v4l2_subdev *sd, 1871static int preview_enum_mbus_code(struct v4l2_subdev *sd,
1872 struct v4l2_subdev_fh *fh, 1872 struct v4l2_subdev_pad_config *cfg,
1873 struct v4l2_subdev_mbus_code_enum *code) 1873 struct v4l2_subdev_mbus_code_enum *code)
1874{ 1874{
1875 switch (code->pad) { 1875 switch (code->pad) {
@@ -1893,7 +1893,7 @@ static int preview_enum_mbus_code(struct v4l2_subdev *sd,
1893} 1893}
1894 1894
1895static int preview_enum_frame_size(struct v4l2_subdev *sd, 1895static int preview_enum_frame_size(struct v4l2_subdev *sd,
1896 struct v4l2_subdev_fh *fh, 1896 struct v4l2_subdev_pad_config *cfg,
1897 struct v4l2_subdev_frame_size_enum *fse) 1897 struct v4l2_subdev_frame_size_enum *fse)
1898{ 1898{
1899 struct isp_prev_device *prev = v4l2_get_subdevdata(sd); 1899 struct isp_prev_device *prev = v4l2_get_subdevdata(sd);
@@ -1905,7 +1905,7 @@ static int preview_enum_frame_size(struct v4l2_subdev *sd,
1905 format.code = fse->code; 1905 format.code = fse->code;
1906 format.width = 1; 1906 format.width = 1;
1907 format.height = 1; 1907 format.height = 1;
1908 preview_try_format(prev, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 1908 preview_try_format(prev, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
1909 fse->min_width = format.width; 1909 fse->min_width = format.width;
1910 fse->min_height = format.height; 1910 fse->min_height = format.height;
1911 1911
@@ -1915,7 +1915,7 @@ static int preview_enum_frame_size(struct v4l2_subdev *sd,
1915 format.code = fse->code; 1915 format.code = fse->code;
1916 format.width = -1; 1916 format.width = -1;
1917 format.height = -1; 1917 format.height = -1;
1918 preview_try_format(prev, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 1918 preview_try_format(prev, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
1919 fse->max_width = format.width; 1919 fse->max_width = format.width;
1920 fse->max_height = format.height; 1920 fse->max_height = format.height;
1921 1921
@@ -1925,7 +1925,7 @@ static int preview_enum_frame_size(struct v4l2_subdev *sd,
1925/* 1925/*
1926 * preview_get_selection - Retrieve a selection rectangle on a pad 1926 * preview_get_selection - Retrieve a selection rectangle on a pad
1927 * @sd: ISP preview V4L2 subdevice 1927 * @sd: ISP preview V4L2 subdevice
1928 * @fh: V4L2 subdev file handle 1928 * @cfg: V4L2 subdev pad configuration
1929 * @sel: Selection rectangle 1929 * @sel: Selection rectangle
1930 * 1930 *
1931 * The only supported rectangles are the crop rectangles on the sink pad. 1931 * The only supported rectangles are the crop rectangles on the sink pad.
@@ -1933,7 +1933,7 @@ static int preview_enum_frame_size(struct v4l2_subdev *sd,
1933 * Return 0 on success or a negative error code otherwise. 1933 * Return 0 on success or a negative error code otherwise.
1934 */ 1934 */
1935static int preview_get_selection(struct v4l2_subdev *sd, 1935static int preview_get_selection(struct v4l2_subdev *sd,
1936 struct v4l2_subdev_fh *fh, 1936 struct v4l2_subdev_pad_config *cfg,
1937 struct v4l2_subdev_selection *sel) 1937 struct v4l2_subdev_selection *sel)
1938{ 1938{
1939 struct isp_prev_device *prev = v4l2_get_subdevdata(sd); 1939 struct isp_prev_device *prev = v4l2_get_subdevdata(sd);
@@ -1949,13 +1949,13 @@ static int preview_get_selection(struct v4l2_subdev *sd,
1949 sel->r.width = INT_MAX; 1949 sel->r.width = INT_MAX;
1950 sel->r.height = INT_MAX; 1950 sel->r.height = INT_MAX;
1951 1951
1952 format = __preview_get_format(prev, fh, PREV_PAD_SINK, 1952 format = __preview_get_format(prev, cfg, PREV_PAD_SINK,
1953 sel->which); 1953 sel->which);
1954 preview_try_crop(prev, format, &sel->r); 1954 preview_try_crop(prev, format, &sel->r);
1955 break; 1955 break;
1956 1956
1957 case V4L2_SEL_TGT_CROP: 1957 case V4L2_SEL_TGT_CROP:
1958 sel->r = *__preview_get_crop(prev, fh, sel->which); 1958 sel->r = *__preview_get_crop(prev, cfg, sel->which);
1959 break; 1959 break;
1960 1960
1961 default: 1961 default:
@@ -1968,7 +1968,7 @@ static int preview_get_selection(struct v4l2_subdev *sd,
1968/* 1968/*
1969 * preview_set_selection - Set a selection rectangle on a pad 1969 * preview_set_selection - Set a selection rectangle on a pad
1970 * @sd: ISP preview V4L2 subdevice 1970 * @sd: ISP preview V4L2 subdevice
1971 * @fh: V4L2 subdev file handle 1971 * @cfg: V4L2 subdev pad configuration
1972 * @sel: Selection rectangle 1972 * @sel: Selection rectangle
1973 * 1973 *
1974 * The only supported rectangle is the actual crop rectangle on the sink pad. 1974 * The only supported rectangle is the actual crop rectangle on the sink pad.
@@ -1976,7 +1976,7 @@ static int preview_get_selection(struct v4l2_subdev *sd,
1976 * Return 0 on success or a negative error code otherwise. 1976 * Return 0 on success or a negative error code otherwise.
1977 */ 1977 */
1978static int preview_set_selection(struct v4l2_subdev *sd, 1978static int preview_set_selection(struct v4l2_subdev *sd,
1979 struct v4l2_subdev_fh *fh, 1979 struct v4l2_subdev_pad_config *cfg,
1980 struct v4l2_subdev_selection *sel) 1980 struct v4l2_subdev_selection *sel)
1981{ 1981{
1982 struct isp_prev_device *prev = v4l2_get_subdevdata(sd); 1982 struct isp_prev_device *prev = v4l2_get_subdevdata(sd);
@@ -1995,17 +1995,17 @@ static int preview_set_selection(struct v4l2_subdev *sd,
1995 * rectangle. 1995 * rectangle.
1996 */ 1996 */
1997 if (sel->flags & V4L2_SEL_FLAG_KEEP_CONFIG) { 1997 if (sel->flags & V4L2_SEL_FLAG_KEEP_CONFIG) {
1998 sel->r = *__preview_get_crop(prev, fh, sel->which); 1998 sel->r = *__preview_get_crop(prev, cfg, sel->which);
1999 return 0; 1999 return 0;
2000 } 2000 }
2001 2001
2002 format = __preview_get_format(prev, fh, PREV_PAD_SINK, sel->which); 2002 format = __preview_get_format(prev, cfg, PREV_PAD_SINK, sel->which);
2003 preview_try_crop(prev, format, &sel->r); 2003 preview_try_crop(prev, format, &sel->r);
2004 *__preview_get_crop(prev, fh, sel->which) = sel->r; 2004 *__preview_get_crop(prev, cfg, sel->which) = sel->r;
2005 2005
2006 /* Update the source format. */ 2006 /* Update the source format. */
2007 format = __preview_get_format(prev, fh, PREV_PAD_SOURCE, sel->which); 2007 format = __preview_get_format(prev, cfg, PREV_PAD_SOURCE, sel->which);
2008 preview_try_format(prev, fh, PREV_PAD_SOURCE, format, sel->which); 2008 preview_try_format(prev, cfg, PREV_PAD_SOURCE, format, sel->which);
2009 2009
2010 return 0; 2010 return 0;
2011} 2011}
@@ -2013,17 +2013,17 @@ static int preview_set_selection(struct v4l2_subdev *sd,
2013/* 2013/*
2014 * preview_get_format - Handle get format by pads subdev method 2014 * preview_get_format - Handle get format by pads subdev method
2015 * @sd : pointer to v4l2 subdev structure 2015 * @sd : pointer to v4l2 subdev structure
2016 * @fh : V4L2 subdev file handle 2016 * @cfg: V4L2 subdev pad configuration
2017 * @fmt: pointer to v4l2 subdev format structure 2017 * @fmt: pointer to v4l2 subdev format structure
2018 * return -EINVAL or zero on success 2018 * return -EINVAL or zero on success
2019 */ 2019 */
2020static int preview_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 2020static int preview_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
2021 struct v4l2_subdev_format *fmt) 2021 struct v4l2_subdev_format *fmt)
2022{ 2022{
2023 struct isp_prev_device *prev = v4l2_get_subdevdata(sd); 2023 struct isp_prev_device *prev = v4l2_get_subdevdata(sd);
2024 struct v4l2_mbus_framefmt *format; 2024 struct v4l2_mbus_framefmt *format;
2025 2025
2026 format = __preview_get_format(prev, fh, fmt->pad, fmt->which); 2026 format = __preview_get_format(prev, cfg, fmt->pad, fmt->which);
2027 if (format == NULL) 2027 if (format == NULL)
2028 return -EINVAL; 2028 return -EINVAL;
2029 2029
@@ -2034,28 +2034,28 @@ static int preview_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
2034/* 2034/*
2035 * preview_set_format - Handle set format by pads subdev method 2035 * preview_set_format - Handle set format by pads subdev method
2036 * @sd : pointer to v4l2 subdev structure 2036 * @sd : pointer to v4l2 subdev structure
2037 * @fh : V4L2 subdev file handle 2037 * @cfg: V4L2 subdev pad configuration
2038 * @fmt: pointer to v4l2 subdev format structure 2038 * @fmt: pointer to v4l2 subdev format structure
2039 * return -EINVAL or zero on success 2039 * return -EINVAL or zero on success
2040 */ 2040 */
2041static int preview_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 2041static int preview_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
2042 struct v4l2_subdev_format *fmt) 2042 struct v4l2_subdev_format *fmt)
2043{ 2043{
2044 struct isp_prev_device *prev = v4l2_get_subdevdata(sd); 2044 struct isp_prev_device *prev = v4l2_get_subdevdata(sd);
2045 struct v4l2_mbus_framefmt *format; 2045 struct v4l2_mbus_framefmt *format;
2046 struct v4l2_rect *crop; 2046 struct v4l2_rect *crop;
2047 2047
2048 format = __preview_get_format(prev, fh, fmt->pad, fmt->which); 2048 format = __preview_get_format(prev, cfg, fmt->pad, fmt->which);
2049 if (format == NULL) 2049 if (format == NULL)
2050 return -EINVAL; 2050 return -EINVAL;
2051 2051
2052 preview_try_format(prev, fh, fmt->pad, &fmt->format, fmt->which); 2052 preview_try_format(prev, cfg, fmt->pad, &fmt->format, fmt->which);
2053 *format = fmt->format; 2053 *format = fmt->format;
2054 2054
2055 /* Propagate the format from sink to source */ 2055 /* Propagate the format from sink to source */
2056 if (fmt->pad == PREV_PAD_SINK) { 2056 if (fmt->pad == PREV_PAD_SINK) {
2057 /* Reset the crop rectangle. */ 2057 /* Reset the crop rectangle. */
2058 crop = __preview_get_crop(prev, fh, fmt->which); 2058 crop = __preview_get_crop(prev, cfg, fmt->which);
2059 crop->left = 0; 2059 crop->left = 0;
2060 crop->top = 0; 2060 crop->top = 0;
2061 crop->width = fmt->format.width; 2061 crop->width = fmt->format.width;
@@ -2064,9 +2064,9 @@ static int preview_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
2064 preview_try_crop(prev, &fmt->format, crop); 2064 preview_try_crop(prev, &fmt->format, crop);
2065 2065
2066 /* Update the source format. */ 2066 /* Update the source format. */
2067 format = __preview_get_format(prev, fh, PREV_PAD_SOURCE, 2067 format = __preview_get_format(prev, cfg, PREV_PAD_SOURCE,
2068 fmt->which); 2068 fmt->which);
2069 preview_try_format(prev, fh, PREV_PAD_SOURCE, format, 2069 preview_try_format(prev, cfg, PREV_PAD_SOURCE, format,
2070 fmt->which); 2070 fmt->which);
2071 } 2071 }
2072 2072
@@ -2093,7 +2093,7 @@ static int preview_init_formats(struct v4l2_subdev *sd,
2093 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; 2093 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
2094 format.format.width = 4096; 2094 format.format.width = 4096;
2095 format.format.height = 4096; 2095 format.format.height = 4096;
2096 preview_set_format(sd, fh, &format); 2096 preview_set_format(sd, fh ? fh->pad : NULL, &format);
2097 2097
2098 return 0; 2098 return 0;
2099} 2099}
diff --git a/drivers/media/platform/omap3isp/ispresizer.c b/drivers/media/platform/omap3isp/ispresizer.c
index 2b9bc4839876..3ede27bc0a45 100644
--- a/drivers/media/platform/omap3isp/ispresizer.c
+++ b/drivers/media/platform/omap3isp/ispresizer.c
@@ -112,16 +112,16 @@ static const struct isprsz_coef filter_coefs = {
112 * __resizer_get_format - helper function for getting resizer format 112 * __resizer_get_format - helper function for getting resizer format
113 * @res : pointer to resizer private structure 113 * @res : pointer to resizer private structure
114 * @pad : pad number 114 * @pad : pad number
115 * @fh : V4L2 subdev file handle 115 * @cfg: V4L2 subdev pad configuration
116 * @which : wanted subdev format 116 * @which : wanted subdev format
117 * return zero 117 * return zero
118 */ 118 */
119static struct v4l2_mbus_framefmt * 119static struct v4l2_mbus_framefmt *
120__resizer_get_format(struct isp_res_device *res, struct v4l2_subdev_fh *fh, 120__resizer_get_format(struct isp_res_device *res, struct v4l2_subdev_pad_config *cfg,
121 unsigned int pad, enum v4l2_subdev_format_whence which) 121 unsigned int pad, enum v4l2_subdev_format_whence which)
122{ 122{
123 if (which == V4L2_SUBDEV_FORMAT_TRY) 123 if (which == V4L2_SUBDEV_FORMAT_TRY)
124 return v4l2_subdev_get_try_format(fh, pad); 124 return v4l2_subdev_get_try_format(&res->subdev, cfg, pad);
125 else 125 else
126 return &res->formats[pad]; 126 return &res->formats[pad];
127} 127}
@@ -129,15 +129,15 @@ __resizer_get_format(struct isp_res_device *res, struct v4l2_subdev_fh *fh,
129/* 129/*
130 * __resizer_get_crop - helper function for getting resizer crop rectangle 130 * __resizer_get_crop - helper function for getting resizer crop rectangle
131 * @res : pointer to resizer private structure 131 * @res : pointer to resizer private structure
132 * @fh : V4L2 subdev file handle 132 * @cfg: V4L2 subdev pad configuration
133 * @which : wanted subdev crop rectangle 133 * @which : wanted subdev crop rectangle
134 */ 134 */
135static struct v4l2_rect * 135static struct v4l2_rect *
136__resizer_get_crop(struct isp_res_device *res, struct v4l2_subdev_fh *fh, 136__resizer_get_crop(struct isp_res_device *res, struct v4l2_subdev_pad_config *cfg,
137 enum v4l2_subdev_format_whence which) 137 enum v4l2_subdev_format_whence which)
138{ 138{
139 if (which == V4L2_SUBDEV_FORMAT_TRY) 139 if (which == V4L2_SUBDEV_FORMAT_TRY)
140 return v4l2_subdev_get_try_crop(fh, RESZ_PAD_SINK); 140 return v4l2_subdev_get_try_crop(&res->subdev, cfg, RESZ_PAD_SINK);
141 else 141 else
142 return &res->crop.request; 142 return &res->crop.request;
143} 143}
@@ -1215,7 +1215,7 @@ static void resizer_try_crop(const struct v4l2_mbus_framefmt *sink,
1215/* 1215/*
1216 * resizer_get_selection - Retrieve a selection rectangle on a pad 1216 * resizer_get_selection - Retrieve a selection rectangle on a pad
1217 * @sd: ISP resizer V4L2 subdevice 1217 * @sd: ISP resizer V4L2 subdevice
1218 * @fh: V4L2 subdev file handle 1218 * @cfg: V4L2 subdev pad configuration
1219 * @sel: Selection rectangle 1219 * @sel: Selection rectangle
1220 * 1220 *
1221 * The only supported rectangles are the crop rectangles on the sink pad. 1221 * The only supported rectangles are the crop rectangles on the sink pad.
@@ -1223,7 +1223,7 @@ static void resizer_try_crop(const struct v4l2_mbus_framefmt *sink,
1223 * Return 0 on success or a negative error code otherwise. 1223 * Return 0 on success or a negative error code otherwise.
1224 */ 1224 */
1225static int resizer_get_selection(struct v4l2_subdev *sd, 1225static int resizer_get_selection(struct v4l2_subdev *sd,
1226 struct v4l2_subdev_fh *fh, 1226 struct v4l2_subdev_pad_config *cfg,
1227 struct v4l2_subdev_selection *sel) 1227 struct v4l2_subdev_selection *sel)
1228{ 1228{
1229 struct isp_res_device *res = v4l2_get_subdevdata(sd); 1229 struct isp_res_device *res = v4l2_get_subdevdata(sd);
@@ -1234,9 +1234,9 @@ static int resizer_get_selection(struct v4l2_subdev *sd,
1234 if (sel->pad != RESZ_PAD_SINK) 1234 if (sel->pad != RESZ_PAD_SINK)
1235 return -EINVAL; 1235 return -EINVAL;
1236 1236
1237 format_sink = __resizer_get_format(res, fh, RESZ_PAD_SINK, 1237 format_sink = __resizer_get_format(res, cfg, RESZ_PAD_SINK,
1238 sel->which); 1238 sel->which);
1239 format_source = __resizer_get_format(res, fh, RESZ_PAD_SOURCE, 1239 format_source = __resizer_get_format(res, cfg, RESZ_PAD_SOURCE,
1240 sel->which); 1240 sel->which);
1241 1241
1242 switch (sel->target) { 1242 switch (sel->target) {
@@ -1251,7 +1251,7 @@ static int resizer_get_selection(struct v4l2_subdev *sd,
1251 break; 1251 break;
1252 1252
1253 case V4L2_SEL_TGT_CROP: 1253 case V4L2_SEL_TGT_CROP:
1254 sel->r = *__resizer_get_crop(res, fh, sel->which); 1254 sel->r = *__resizer_get_crop(res, cfg, sel->which);
1255 resizer_calc_ratios(res, &sel->r, format_source, &ratio); 1255 resizer_calc_ratios(res, &sel->r, format_source, &ratio);
1256 break; 1256 break;
1257 1257
@@ -1265,7 +1265,7 @@ static int resizer_get_selection(struct v4l2_subdev *sd,
1265/* 1265/*
1266 * resizer_set_selection - Set a selection rectangle on a pad 1266 * resizer_set_selection - Set a selection rectangle on a pad
1267 * @sd: ISP resizer V4L2 subdevice 1267 * @sd: ISP resizer V4L2 subdevice
1268 * @fh: V4L2 subdev file handle 1268 * @cfg: V4L2 subdev pad configuration
1269 * @sel: Selection rectangle 1269 * @sel: Selection rectangle
1270 * 1270 *
1271 * The only supported rectangle is the actual crop rectangle on the sink pad. 1271 * The only supported rectangle is the actual crop rectangle on the sink pad.
@@ -1276,7 +1276,7 @@ static int resizer_get_selection(struct v4l2_subdev *sd,
1276 * Return 0 on success or a negative error code otherwise. 1276 * Return 0 on success or a negative error code otherwise.
1277 */ 1277 */
1278static int resizer_set_selection(struct v4l2_subdev *sd, 1278static int resizer_set_selection(struct v4l2_subdev *sd,
1279 struct v4l2_subdev_fh *fh, 1279 struct v4l2_subdev_pad_config *cfg,
1280 struct v4l2_subdev_selection *sel) 1280 struct v4l2_subdev_selection *sel)
1281{ 1281{
1282 struct isp_res_device *res = v4l2_get_subdevdata(sd); 1282 struct isp_res_device *res = v4l2_get_subdevdata(sd);
@@ -1290,9 +1290,9 @@ static int resizer_set_selection(struct v4l2_subdev *sd,
1290 sel->pad != RESZ_PAD_SINK) 1290 sel->pad != RESZ_PAD_SINK)
1291 return -EINVAL; 1291 return -EINVAL;
1292 1292
1293 format_sink = __resizer_get_format(res, fh, RESZ_PAD_SINK, 1293 format_sink = __resizer_get_format(res, cfg, RESZ_PAD_SINK,
1294 sel->which); 1294 sel->which);
1295 format_source = *__resizer_get_format(res, fh, RESZ_PAD_SOURCE, 1295 format_source = *__resizer_get_format(res, cfg, RESZ_PAD_SOURCE,
1296 sel->which); 1296 sel->which);
1297 1297
1298 dev_dbg(isp->dev, "%s(%s): req %ux%u -> (%d,%d)/%ux%u -> %ux%u\n", 1298 dev_dbg(isp->dev, "%s(%s): req %ux%u -> (%d,%d)/%ux%u -> %ux%u\n",
@@ -1310,7 +1310,7 @@ static int resizer_set_selection(struct v4l2_subdev *sd,
1310 * stored the mangled rectangle. 1310 * stored the mangled rectangle.
1311 */ 1311 */
1312 resizer_try_crop(format_sink, &format_source, &sel->r); 1312 resizer_try_crop(format_sink, &format_source, &sel->r);
1313 *__resizer_get_crop(res, fh, sel->which) = sel->r; 1313 *__resizer_get_crop(res, cfg, sel->which) = sel->r;
1314 resizer_calc_ratios(res, &sel->r, &format_source, &ratio); 1314 resizer_calc_ratios(res, &sel->r, &format_source, &ratio);
1315 1315
1316 dev_dbg(isp->dev, "%s(%s): got %ux%u -> (%d,%d)/%ux%u -> %ux%u\n", 1316 dev_dbg(isp->dev, "%s(%s): got %ux%u -> (%d,%d)/%ux%u -> %ux%u\n",
@@ -1320,7 +1320,7 @@ static int resizer_set_selection(struct v4l2_subdev *sd,
1320 format_source.width, format_source.height); 1320 format_source.width, format_source.height);
1321 1321
1322 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { 1322 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
1323 *__resizer_get_format(res, fh, RESZ_PAD_SOURCE, sel->which) = 1323 *__resizer_get_format(res, cfg, RESZ_PAD_SOURCE, sel->which) =
1324 format_source; 1324 format_source;
1325 return 0; 1325 return 0;
1326 } 1326 }
@@ -1331,7 +1331,7 @@ static int resizer_set_selection(struct v4l2_subdev *sd,
1331 */ 1331 */
1332 spin_lock_irqsave(&res->lock, flags); 1332 spin_lock_irqsave(&res->lock, flags);
1333 1333
1334 *__resizer_get_format(res, fh, RESZ_PAD_SOURCE, sel->which) = 1334 *__resizer_get_format(res, cfg, RESZ_PAD_SOURCE, sel->which) =
1335 format_source; 1335 format_source;
1336 1336
1337 res->ratio = ratio; 1337 res->ratio = ratio;
@@ -1368,13 +1368,13 @@ static unsigned int resizer_max_in_width(struct isp_res_device *res)
1368/* 1368/*
1369 * resizer_try_format - Handle try format by pad subdev method 1369 * resizer_try_format - Handle try format by pad subdev method
1370 * @res : ISP resizer device 1370 * @res : ISP resizer device
1371 * @fh : V4L2 subdev file handle 1371 * @cfg: V4L2 subdev pad configuration
1372 * @pad : pad num 1372 * @pad : pad num
1373 * @fmt : pointer to v4l2 format structure 1373 * @fmt : pointer to v4l2 format structure
1374 * @which : wanted subdev format 1374 * @which : wanted subdev format
1375 */ 1375 */
1376static void resizer_try_format(struct isp_res_device *res, 1376static void resizer_try_format(struct isp_res_device *res,
1377 struct v4l2_subdev_fh *fh, unsigned int pad, 1377 struct v4l2_subdev_pad_config *cfg, unsigned int pad,
1378 struct v4l2_mbus_framefmt *fmt, 1378 struct v4l2_mbus_framefmt *fmt,
1379 enum v4l2_subdev_format_whence which) 1379 enum v4l2_subdev_format_whence which)
1380{ 1380{
@@ -1395,10 +1395,10 @@ static void resizer_try_format(struct isp_res_device *res,
1395 break; 1395 break;
1396 1396
1397 case RESZ_PAD_SOURCE: 1397 case RESZ_PAD_SOURCE:
1398 format = __resizer_get_format(res, fh, RESZ_PAD_SINK, which); 1398 format = __resizer_get_format(res, cfg, RESZ_PAD_SINK, which);
1399 fmt->code = format->code; 1399 fmt->code = format->code;
1400 1400
1401 crop = *__resizer_get_crop(res, fh, which); 1401 crop = *__resizer_get_crop(res, cfg, which);
1402 resizer_calc_ratios(res, &crop, fmt, &ratio); 1402 resizer_calc_ratios(res, &crop, fmt, &ratio);
1403 break; 1403 break;
1404 } 1404 }
@@ -1410,12 +1410,12 @@ static void resizer_try_format(struct isp_res_device *res,
1410/* 1410/*
1411 * resizer_enum_mbus_code - Handle pixel format enumeration 1411 * resizer_enum_mbus_code - Handle pixel format enumeration
1412 * @sd : pointer to v4l2 subdev structure 1412 * @sd : pointer to v4l2 subdev structure
1413 * @fh : V4L2 subdev file handle 1413 * @cfg: V4L2 subdev pad configuration
1414 * @code : pointer to v4l2_subdev_mbus_code_enum structure 1414 * @code : pointer to v4l2_subdev_mbus_code_enum structure
1415 * return -EINVAL or zero on success 1415 * return -EINVAL or zero on success
1416 */ 1416 */
1417static int resizer_enum_mbus_code(struct v4l2_subdev *sd, 1417static int resizer_enum_mbus_code(struct v4l2_subdev *sd,
1418 struct v4l2_subdev_fh *fh, 1418 struct v4l2_subdev_pad_config *cfg,
1419 struct v4l2_subdev_mbus_code_enum *code) 1419 struct v4l2_subdev_mbus_code_enum *code)
1420{ 1420{
1421 struct isp_res_device *res = v4l2_get_subdevdata(sd); 1421 struct isp_res_device *res = v4l2_get_subdevdata(sd);
@@ -1430,7 +1430,7 @@ static int resizer_enum_mbus_code(struct v4l2_subdev *sd,
1430 if (code->index != 0) 1430 if (code->index != 0)
1431 return -EINVAL; 1431 return -EINVAL;
1432 1432
1433 format = __resizer_get_format(res, fh, RESZ_PAD_SINK, 1433 format = __resizer_get_format(res, cfg, RESZ_PAD_SINK,
1434 V4L2_SUBDEV_FORMAT_TRY); 1434 V4L2_SUBDEV_FORMAT_TRY);
1435 code->code = format->code; 1435 code->code = format->code;
1436 } 1436 }
@@ -1439,7 +1439,7 @@ static int resizer_enum_mbus_code(struct v4l2_subdev *sd,
1439} 1439}
1440 1440
1441static int resizer_enum_frame_size(struct v4l2_subdev *sd, 1441static int resizer_enum_frame_size(struct v4l2_subdev *sd,
1442 struct v4l2_subdev_fh *fh, 1442 struct v4l2_subdev_pad_config *cfg,
1443 struct v4l2_subdev_frame_size_enum *fse) 1443 struct v4l2_subdev_frame_size_enum *fse)
1444{ 1444{
1445 struct isp_res_device *res = v4l2_get_subdevdata(sd); 1445 struct isp_res_device *res = v4l2_get_subdevdata(sd);
@@ -1451,7 +1451,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
1451 format.code = fse->code; 1451 format.code = fse->code;
1452 format.width = 1; 1452 format.width = 1;
1453 format.height = 1; 1453 format.height = 1;
1454 resizer_try_format(res, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 1454 resizer_try_format(res, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
1455 fse->min_width = format.width; 1455 fse->min_width = format.width;
1456 fse->min_height = format.height; 1456 fse->min_height = format.height;
1457 1457
@@ -1461,7 +1461,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
1461 format.code = fse->code; 1461 format.code = fse->code;
1462 format.width = -1; 1462 format.width = -1;
1463 format.height = -1; 1463 format.height = -1;
1464 resizer_try_format(res, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 1464 resizer_try_format(res, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
1465 fse->max_width = format.width; 1465 fse->max_width = format.width;
1466 fse->max_height = format.height; 1466 fse->max_height = format.height;
1467 1467
@@ -1471,17 +1471,17 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
1471/* 1471/*
1472 * resizer_get_format - Handle get format by pads subdev method 1472 * resizer_get_format - Handle get format by pads subdev method
1473 * @sd : pointer to v4l2 subdev structure 1473 * @sd : pointer to v4l2 subdev structure
1474 * @fh : V4L2 subdev file handle 1474 * @cfg: V4L2 subdev pad configuration
1475 * @fmt : pointer to v4l2 subdev format structure 1475 * @fmt : pointer to v4l2 subdev format structure
1476 * return -EINVAL or zero on success 1476 * return -EINVAL or zero on success
1477 */ 1477 */
1478static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1478static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1479 struct v4l2_subdev_format *fmt) 1479 struct v4l2_subdev_format *fmt)
1480{ 1480{
1481 struct isp_res_device *res = v4l2_get_subdevdata(sd); 1481 struct isp_res_device *res = v4l2_get_subdevdata(sd);
1482 struct v4l2_mbus_framefmt *format; 1482 struct v4l2_mbus_framefmt *format;
1483 1483
1484 format = __resizer_get_format(res, fh, fmt->pad, fmt->which); 1484 format = __resizer_get_format(res, cfg, fmt->pad, fmt->which);
1485 if (format == NULL) 1485 if (format == NULL)
1486 return -EINVAL; 1486 return -EINVAL;
1487 1487
@@ -1492,37 +1492,37 @@ static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1492/* 1492/*
1493 * resizer_set_format - Handle set format by pads subdev method 1493 * resizer_set_format - Handle set format by pads subdev method
1494 * @sd : pointer to v4l2 subdev structure 1494 * @sd : pointer to v4l2 subdev structure
1495 * @fh : V4L2 subdev file handle 1495 * @cfg: V4L2 subdev pad configuration
1496 * @fmt : pointer to v4l2 subdev format structure 1496 * @fmt : pointer to v4l2 subdev format structure
1497 * return -EINVAL or zero on success 1497 * return -EINVAL or zero on success
1498 */ 1498 */
1499static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1499static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1500 struct v4l2_subdev_format *fmt) 1500 struct v4l2_subdev_format *fmt)
1501{ 1501{
1502 struct isp_res_device *res = v4l2_get_subdevdata(sd); 1502 struct isp_res_device *res = v4l2_get_subdevdata(sd);
1503 struct v4l2_mbus_framefmt *format; 1503 struct v4l2_mbus_framefmt *format;
1504 struct v4l2_rect *crop; 1504 struct v4l2_rect *crop;
1505 1505
1506 format = __resizer_get_format(res, fh, fmt->pad, fmt->which); 1506 format = __resizer_get_format(res, cfg, fmt->pad, fmt->which);
1507 if (format == NULL) 1507 if (format == NULL)
1508 return -EINVAL; 1508 return -EINVAL;
1509 1509
1510 resizer_try_format(res, fh, fmt->pad, &fmt->format, fmt->which); 1510 resizer_try_format(res, cfg, fmt->pad, &fmt->format, fmt->which);
1511 *format = fmt->format; 1511 *format = fmt->format;
1512 1512
1513 if (fmt->pad == RESZ_PAD_SINK) { 1513 if (fmt->pad == RESZ_PAD_SINK) {
1514 /* reset crop rectangle */ 1514 /* reset crop rectangle */
1515 crop = __resizer_get_crop(res, fh, fmt->which); 1515 crop = __resizer_get_crop(res, cfg, fmt->which);
1516 crop->left = 0; 1516 crop->left = 0;
1517 crop->top = 0; 1517 crop->top = 0;
1518 crop->width = fmt->format.width; 1518 crop->width = fmt->format.width;
1519 crop->height = fmt->format.height; 1519 crop->height = fmt->format.height;
1520 1520
1521 /* Propagate the format from sink to source */ 1521 /* Propagate the format from sink to source */
1522 format = __resizer_get_format(res, fh, RESZ_PAD_SOURCE, 1522 format = __resizer_get_format(res, cfg, RESZ_PAD_SOURCE,
1523 fmt->which); 1523 fmt->which);
1524 *format = fmt->format; 1524 *format = fmt->format;
1525 resizer_try_format(res, fh, RESZ_PAD_SOURCE, format, 1525 resizer_try_format(res, cfg, RESZ_PAD_SOURCE, format,
1526 fmt->which); 1526 fmt->which);
1527 } 1527 }
1528 1528
@@ -1573,7 +1573,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
1573 format.format.code = MEDIA_BUS_FMT_YUYV8_1X16; 1573 format.format.code = MEDIA_BUS_FMT_YUYV8_1X16;
1574 format.format.width = 4096; 1574 format.format.width = 4096;
1575 format.format.height = 4096; 1575 format.format.height = 4096;
1576 resizer_set_format(sd, fh, &format); 1576 resizer_set_format(sd, fh ? fh->pad : NULL, &format);
1577 1577
1578 return 0; 1578 return 0;
1579} 1579}
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
index 54479d60cc0d..f6a61b9ceff4 100644
--- a/drivers/media/platform/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -1219,7 +1219,7 @@ static const u32 camif_mbus_formats[] = {
1219 */ 1219 */
1220 1220
1221static int s3c_camif_subdev_enum_mbus_code(struct v4l2_subdev *sd, 1221static int s3c_camif_subdev_enum_mbus_code(struct v4l2_subdev *sd,
1222 struct v4l2_subdev_fh *fh, 1222 struct v4l2_subdev_pad_config *cfg,
1223 struct v4l2_subdev_mbus_code_enum *code) 1223 struct v4l2_subdev_mbus_code_enum *code)
1224{ 1224{
1225 if (code->index >= ARRAY_SIZE(camif_mbus_formats)) 1225 if (code->index >= ARRAY_SIZE(camif_mbus_formats))
@@ -1230,14 +1230,14 @@ static int s3c_camif_subdev_enum_mbus_code(struct v4l2_subdev *sd,
1230} 1230}
1231 1231
1232static int s3c_camif_subdev_get_fmt(struct v4l2_subdev *sd, 1232static int s3c_camif_subdev_get_fmt(struct v4l2_subdev *sd,
1233 struct v4l2_subdev_fh *fh, 1233 struct v4l2_subdev_pad_config *cfg,
1234 struct v4l2_subdev_format *fmt) 1234 struct v4l2_subdev_format *fmt)
1235{ 1235{
1236 struct camif_dev *camif = v4l2_get_subdevdata(sd); 1236 struct camif_dev *camif = v4l2_get_subdevdata(sd);
1237 struct v4l2_mbus_framefmt *mf = &fmt->format; 1237 struct v4l2_mbus_framefmt *mf = &fmt->format;
1238 1238
1239 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1239 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1240 mf = v4l2_subdev_get_try_format(fh, fmt->pad); 1240 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
1241 fmt->format = *mf; 1241 fmt->format = *mf;
1242 return 0; 1242 return 0;
1243 } 1243 }
@@ -1297,7 +1297,7 @@ static void __camif_subdev_try_format(struct camif_dev *camif,
1297} 1297}
1298 1298
1299static int s3c_camif_subdev_set_fmt(struct v4l2_subdev *sd, 1299static int s3c_camif_subdev_set_fmt(struct v4l2_subdev *sd,
1300 struct v4l2_subdev_fh *fh, 1300 struct v4l2_subdev_pad_config *cfg,
1301 struct v4l2_subdev_format *fmt) 1301 struct v4l2_subdev_format *fmt)
1302{ 1302{
1303 struct camif_dev *camif = v4l2_get_subdevdata(sd); 1303 struct camif_dev *camif = v4l2_get_subdevdata(sd);
@@ -1325,7 +1325,7 @@ static int s3c_camif_subdev_set_fmt(struct v4l2_subdev *sd,
1325 __camif_subdev_try_format(camif, mf, fmt->pad); 1325 __camif_subdev_try_format(camif, mf, fmt->pad);
1326 1326
1327 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1327 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1328 mf = v4l2_subdev_get_try_format(fh, fmt->pad); 1328 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
1329 *mf = fmt->format; 1329 *mf = fmt->format;
1330 mutex_unlock(&camif->lock); 1330 mutex_unlock(&camif->lock);
1331 return 0; 1331 return 0;
@@ -1364,7 +1364,7 @@ static int s3c_camif_subdev_set_fmt(struct v4l2_subdev *sd,
1364} 1364}
1365 1365
1366static int s3c_camif_subdev_get_selection(struct v4l2_subdev *sd, 1366static int s3c_camif_subdev_get_selection(struct v4l2_subdev *sd,
1367 struct v4l2_subdev_fh *fh, 1367 struct v4l2_subdev_pad_config *cfg,
1368 struct v4l2_subdev_selection *sel) 1368 struct v4l2_subdev_selection *sel)
1369{ 1369{
1370 struct camif_dev *camif = v4l2_get_subdevdata(sd); 1370 struct camif_dev *camif = v4l2_get_subdevdata(sd);
@@ -1377,7 +1377,7 @@ static int s3c_camif_subdev_get_selection(struct v4l2_subdev *sd,
1377 return -EINVAL; 1377 return -EINVAL;
1378 1378
1379 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { 1379 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
1380 sel->r = *v4l2_subdev_get_try_crop(fh, sel->pad); 1380 sel->r = *v4l2_subdev_get_try_crop(sd, cfg, sel->pad);
1381 return 0; 1381 return 0;
1382 } 1382 }
1383 1383
@@ -1451,7 +1451,7 @@ static void __camif_try_crop(struct camif_dev *camif, struct v4l2_rect *r)
1451} 1451}
1452 1452
1453static int s3c_camif_subdev_set_selection(struct v4l2_subdev *sd, 1453static int s3c_camif_subdev_set_selection(struct v4l2_subdev *sd,
1454 struct v4l2_subdev_fh *fh, 1454 struct v4l2_subdev_pad_config *cfg,
1455 struct v4l2_subdev_selection *sel) 1455 struct v4l2_subdev_selection *sel)
1456{ 1456{
1457 struct camif_dev *camif = v4l2_get_subdevdata(sd); 1457 struct camif_dev *camif = v4l2_get_subdevdata(sd);
@@ -1465,7 +1465,7 @@ static int s3c_camif_subdev_set_selection(struct v4l2_subdev *sd,
1465 __camif_try_crop(camif, &sel->r); 1465 __camif_try_crop(camif, &sel->r);
1466 1466
1467 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { 1467 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
1468 *v4l2_subdev_get_try_crop(fh, sel->pad) = sel->r; 1468 *v4l2_subdev_get_try_crop(sd, cfg, sel->pad) = sel->r;
1469 } else { 1469 } else {
1470 unsigned long flags; 1470 unsigned long flags;
1471 unsigned int i; 1471 unsigned int i;
diff --git a/drivers/media/platform/vsp1/vsp1_bru.c b/drivers/media/platform/vsp1/vsp1_bru.c
index 401e2b77a0b6..31ad0b634e0c 100644
--- a/drivers/media/platform/vsp1/vsp1_bru.c
+++ b/drivers/media/platform/vsp1/vsp1_bru.c
@@ -183,7 +183,7 @@ static int bru_s_stream(struct v4l2_subdev *subdev, int enable)
183 */ 183 */
184 184
185static int bru_enum_mbus_code(struct v4l2_subdev *subdev, 185static int bru_enum_mbus_code(struct v4l2_subdev *subdev,
186 struct v4l2_subdev_fh *fh, 186 struct v4l2_subdev_pad_config *cfg,
187 struct v4l2_subdev_mbus_code_enum *code) 187 struct v4l2_subdev_mbus_code_enum *code)
188{ 188{
189 static const unsigned int codes[] = { 189 static const unsigned int codes[] = {
@@ -201,7 +201,7 @@ static int bru_enum_mbus_code(struct v4l2_subdev *subdev,
201 if (code->index) 201 if (code->index)
202 return -EINVAL; 202 return -EINVAL;
203 203
204 format = v4l2_subdev_get_try_format(fh, BRU_PAD_SINK(0)); 204 format = v4l2_subdev_get_try_format(subdev, cfg, BRU_PAD_SINK(0));
205 code->code = format->code; 205 code->code = format->code;
206 } 206 }
207 207
@@ -209,7 +209,7 @@ static int bru_enum_mbus_code(struct v4l2_subdev *subdev,
209} 209}
210 210
211static int bru_enum_frame_size(struct v4l2_subdev *subdev, 211static int bru_enum_frame_size(struct v4l2_subdev *subdev,
212 struct v4l2_subdev_fh *fh, 212 struct v4l2_subdev_pad_config *cfg,
213 struct v4l2_subdev_frame_size_enum *fse) 213 struct v4l2_subdev_frame_size_enum *fse)
214{ 214{
215 if (fse->index) 215 if (fse->index)
@@ -228,12 +228,12 @@ static int bru_enum_frame_size(struct v4l2_subdev *subdev,
228} 228}
229 229
230static struct v4l2_rect *bru_get_compose(struct vsp1_bru *bru, 230static struct v4l2_rect *bru_get_compose(struct vsp1_bru *bru,
231 struct v4l2_subdev_fh *fh, 231 struct v4l2_subdev_pad_config *cfg,
232 unsigned int pad, u32 which) 232 unsigned int pad, u32 which)
233{ 233{
234 switch (which) { 234 switch (which) {
235 case V4L2_SUBDEV_FORMAT_TRY: 235 case V4L2_SUBDEV_FORMAT_TRY:
236 return v4l2_subdev_get_try_crop(fh, pad); 236 return v4l2_subdev_get_try_crop(&bru->entity.subdev, cfg, pad);
237 case V4L2_SUBDEV_FORMAT_ACTIVE: 237 case V4L2_SUBDEV_FORMAT_ACTIVE:
238 return &bru->inputs[pad].compose; 238 return &bru->inputs[pad].compose;
239 default: 239 default:
@@ -241,18 +241,18 @@ static struct v4l2_rect *bru_get_compose(struct vsp1_bru *bru,
241 } 241 }
242} 242}
243 243
244static int bru_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 244static int bru_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
245 struct v4l2_subdev_format *fmt) 245 struct v4l2_subdev_format *fmt)
246{ 246{
247 struct vsp1_bru *bru = to_bru(subdev); 247 struct vsp1_bru *bru = to_bru(subdev);
248 248
249 fmt->format = *vsp1_entity_get_pad_format(&bru->entity, fh, fmt->pad, 249 fmt->format = *vsp1_entity_get_pad_format(&bru->entity, cfg, fmt->pad,
250 fmt->which); 250 fmt->which);
251 251
252 return 0; 252 return 0;
253} 253}
254 254
255static void bru_try_format(struct vsp1_bru *bru, struct v4l2_subdev_fh *fh, 255static void bru_try_format(struct vsp1_bru *bru, struct v4l2_subdev_pad_config *cfg,
256 unsigned int pad, struct v4l2_mbus_framefmt *fmt, 256 unsigned int pad, struct v4l2_mbus_framefmt *fmt,
257 enum v4l2_subdev_format_whence which) 257 enum v4l2_subdev_format_whence which)
258{ 258{
@@ -268,7 +268,7 @@ static void bru_try_format(struct vsp1_bru *bru, struct v4l2_subdev_fh *fh,
268 268
269 default: 269 default:
270 /* The BRU can't perform format conversion. */ 270 /* The BRU can't perform format conversion. */
271 format = vsp1_entity_get_pad_format(&bru->entity, fh, 271 format = vsp1_entity_get_pad_format(&bru->entity, cfg,
272 BRU_PAD_SINK(0), which); 272 BRU_PAD_SINK(0), which);
273 fmt->code = format->code; 273 fmt->code = format->code;
274 break; 274 break;
@@ -280,15 +280,15 @@ static void bru_try_format(struct vsp1_bru *bru, struct v4l2_subdev_fh *fh,
280 fmt->colorspace = V4L2_COLORSPACE_SRGB; 280 fmt->colorspace = V4L2_COLORSPACE_SRGB;
281} 281}
282 282
283static int bru_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 283static int bru_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
284 struct v4l2_subdev_format *fmt) 284 struct v4l2_subdev_format *fmt)
285{ 285{
286 struct vsp1_bru *bru = to_bru(subdev); 286 struct vsp1_bru *bru = to_bru(subdev);
287 struct v4l2_mbus_framefmt *format; 287 struct v4l2_mbus_framefmt *format;
288 288
289 bru_try_format(bru, fh, fmt->pad, &fmt->format, fmt->which); 289 bru_try_format(bru, cfg, fmt->pad, &fmt->format, fmt->which);
290 290
291 format = vsp1_entity_get_pad_format(&bru->entity, fh, fmt->pad, 291 format = vsp1_entity_get_pad_format(&bru->entity, cfg, fmt->pad,
292 fmt->which); 292 fmt->which);
293 *format = fmt->format; 293 *format = fmt->format;
294 294
@@ -296,7 +296,7 @@ static int bru_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh,
296 if (fmt->pad != BRU_PAD_SOURCE) { 296 if (fmt->pad != BRU_PAD_SOURCE) {
297 struct v4l2_rect *compose; 297 struct v4l2_rect *compose;
298 298
299 compose = bru_get_compose(bru, fh, fmt->pad, fmt->which); 299 compose = bru_get_compose(bru, cfg, fmt->pad, fmt->which);
300 compose->left = 0; 300 compose->left = 0;
301 compose->top = 0; 301 compose->top = 0;
302 compose->width = format->width; 302 compose->width = format->width;
@@ -308,7 +308,7 @@ static int bru_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh,
308 unsigned int i; 308 unsigned int i;
309 309
310 for (i = 0; i <= BRU_PAD_SOURCE; ++i) { 310 for (i = 0; i <= BRU_PAD_SOURCE; ++i) {
311 format = vsp1_entity_get_pad_format(&bru->entity, fh, 311 format = vsp1_entity_get_pad_format(&bru->entity, cfg,
312 i, fmt->which); 312 i, fmt->which);
313 format->code = fmt->format.code; 313 format->code = fmt->format.code;
314 } 314 }
@@ -318,7 +318,7 @@ static int bru_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh,
318} 318}
319 319
320static int bru_get_selection(struct v4l2_subdev *subdev, 320static int bru_get_selection(struct v4l2_subdev *subdev,
321 struct v4l2_subdev_fh *fh, 321 struct v4l2_subdev_pad_config *cfg,
322 struct v4l2_subdev_selection *sel) 322 struct v4l2_subdev_selection *sel)
323{ 323{
324 struct vsp1_bru *bru = to_bru(subdev); 324 struct vsp1_bru *bru = to_bru(subdev);
@@ -335,7 +335,7 @@ static int bru_get_selection(struct v4l2_subdev *subdev,
335 return 0; 335 return 0;
336 336
337 case V4L2_SEL_TGT_COMPOSE: 337 case V4L2_SEL_TGT_COMPOSE:
338 sel->r = *bru_get_compose(bru, fh, sel->pad, sel->which); 338 sel->r = *bru_get_compose(bru, cfg, sel->pad, sel->which);
339 return 0; 339 return 0;
340 340
341 default: 341 default:
@@ -344,7 +344,7 @@ static int bru_get_selection(struct v4l2_subdev *subdev,
344} 344}
345 345
346static int bru_set_selection(struct v4l2_subdev *subdev, 346static int bru_set_selection(struct v4l2_subdev *subdev,
347 struct v4l2_subdev_fh *fh, 347 struct v4l2_subdev_pad_config *cfg,
348 struct v4l2_subdev_selection *sel) 348 struct v4l2_subdev_selection *sel)
349{ 349{
350 struct vsp1_bru *bru = to_bru(subdev); 350 struct vsp1_bru *bru = to_bru(subdev);
@@ -360,7 +360,7 @@ static int bru_set_selection(struct v4l2_subdev *subdev,
360 /* The compose rectangle top left corner must be inside the output 360 /* The compose rectangle top left corner must be inside the output
361 * frame. 361 * frame.
362 */ 362 */
363 format = vsp1_entity_get_pad_format(&bru->entity, fh, BRU_PAD_SOURCE, 363 format = vsp1_entity_get_pad_format(&bru->entity, cfg, BRU_PAD_SOURCE,
364 sel->which); 364 sel->which);
365 sel->r.left = clamp_t(unsigned int, sel->r.left, 0, format->width - 1); 365 sel->r.left = clamp_t(unsigned int, sel->r.left, 0, format->width - 1);
366 sel->r.top = clamp_t(unsigned int, sel->r.top, 0, format->height - 1); 366 sel->r.top = clamp_t(unsigned int, sel->r.top, 0, format->height - 1);
@@ -368,12 +368,12 @@ static int bru_set_selection(struct v4l2_subdev *subdev,
368 /* Scaling isn't supported, the compose rectangle size must be identical 368 /* Scaling isn't supported, the compose rectangle size must be identical
369 * to the sink format size. 369 * to the sink format size.
370 */ 370 */
371 format = vsp1_entity_get_pad_format(&bru->entity, fh, sel->pad, 371 format = vsp1_entity_get_pad_format(&bru->entity, cfg, sel->pad,
372 sel->which); 372 sel->which);
373 sel->r.width = format->width; 373 sel->r.width = format->width;
374 sel->r.height = format->height; 374 sel->r.height = format->height;
375 375
376 compose = bru_get_compose(bru, fh, sel->pad, sel->which); 376 compose = bru_get_compose(bru, cfg, sel->pad, sel->which);
377 *compose = sel->r; 377 *compose = sel->r;
378 378
379 return 0; 379 return 0;
diff --git a/drivers/media/platform/vsp1/vsp1_entity.c b/drivers/media/platform/vsp1/vsp1_entity.c
index 79af71d5e270..a453bb4ddd37 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.c
+++ b/drivers/media/platform/vsp1/vsp1_entity.c
@@ -63,12 +63,12 @@ int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming)
63 63
64struct v4l2_mbus_framefmt * 64struct v4l2_mbus_framefmt *
65vsp1_entity_get_pad_format(struct vsp1_entity *entity, 65vsp1_entity_get_pad_format(struct vsp1_entity *entity,
66 struct v4l2_subdev_fh *fh, 66 struct v4l2_subdev_pad_config *cfg,
67 unsigned int pad, u32 which) 67 unsigned int pad, u32 which)
68{ 68{
69 switch (which) { 69 switch (which) {
70 case V4L2_SUBDEV_FORMAT_TRY: 70 case V4L2_SUBDEV_FORMAT_TRY:
71 return v4l2_subdev_get_try_format(fh, pad); 71 return v4l2_subdev_get_try_format(&entity->subdev, cfg, pad);
72 case V4L2_SUBDEV_FORMAT_ACTIVE: 72 case V4L2_SUBDEV_FORMAT_ACTIVE:
73 return &entity->formats[pad]; 73 return &entity->formats[pad];
74 default: 74 default:
@@ -79,14 +79,14 @@ vsp1_entity_get_pad_format(struct vsp1_entity *entity,
79/* 79/*
80 * vsp1_entity_init_formats - Initialize formats on all pads 80 * vsp1_entity_init_formats - Initialize formats on all pads
81 * @subdev: V4L2 subdevice 81 * @subdev: V4L2 subdevice
82 * @fh: V4L2 subdev file handle 82 * @cfg: V4L2 subdev pad configuration
83 * 83 *
84 * Initialize all pad formats with default values. If fh is not NULL, try 84 * Initialize all pad formats with default values. If cfg is not NULL, try
85 * formats are initialized on the file handle. Otherwise active formats are 85 * formats are initialized on the file handle. Otherwise active formats are
86 * initialized on the device. 86 * initialized on the device.
87 */ 87 */
88void vsp1_entity_init_formats(struct v4l2_subdev *subdev, 88void vsp1_entity_init_formats(struct v4l2_subdev *subdev,
89 struct v4l2_subdev_fh *fh) 89 struct v4l2_subdev_pad_config *cfg)
90{ 90{
91 struct v4l2_subdev_format format; 91 struct v4l2_subdev_format format;
92 unsigned int pad; 92 unsigned int pad;
@@ -95,17 +95,17 @@ void vsp1_entity_init_formats(struct v4l2_subdev *subdev,
95 memset(&format, 0, sizeof(format)); 95 memset(&format, 0, sizeof(format));
96 96
97 format.pad = pad; 97 format.pad = pad;
98 format.which = fh ? V4L2_SUBDEV_FORMAT_TRY 98 format.which = cfg ? V4L2_SUBDEV_FORMAT_TRY
99 : V4L2_SUBDEV_FORMAT_ACTIVE; 99 : V4L2_SUBDEV_FORMAT_ACTIVE;
100 100
101 v4l2_subdev_call(subdev, pad, set_fmt, fh, &format); 101 v4l2_subdev_call(subdev, pad, set_fmt, cfg, &format);
102 } 102 }
103} 103}
104 104
105static int vsp1_entity_open(struct v4l2_subdev *subdev, 105static int vsp1_entity_open(struct v4l2_subdev *subdev,
106 struct v4l2_subdev_fh *fh) 106 struct v4l2_subdev_fh *fh)
107{ 107{
108 vsp1_entity_init_formats(subdev, fh); 108 vsp1_entity_init_formats(subdev, fh->pad);
109 109
110 return 0; 110 return 0;
111} 111}
diff --git a/drivers/media/platform/vsp1/vsp1_entity.h b/drivers/media/platform/vsp1/vsp1_entity.h
index aa20aaa58208..62c768d1c6aa 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.h
+++ b/drivers/media/platform/vsp1/vsp1_entity.h
@@ -91,10 +91,10 @@ extern const struct media_entity_operations vsp1_media_ops;
91 91
92struct v4l2_mbus_framefmt * 92struct v4l2_mbus_framefmt *
93vsp1_entity_get_pad_format(struct vsp1_entity *entity, 93vsp1_entity_get_pad_format(struct vsp1_entity *entity,
94 struct v4l2_subdev_fh *fh, 94 struct v4l2_subdev_pad_config *cfg,
95 unsigned int pad, u32 which); 95 unsigned int pad, u32 which);
96void vsp1_entity_init_formats(struct v4l2_subdev *subdev, 96void vsp1_entity_init_formats(struct v4l2_subdev *subdev,
97 struct v4l2_subdev_fh *fh); 97 struct v4l2_subdev_pad_config *cfg);
98 98
99bool vsp1_entity_is_streaming(struct vsp1_entity *entity); 99bool vsp1_entity_is_streaming(struct vsp1_entity *entity);
100int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming); 100int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming);
diff --git a/drivers/media/platform/vsp1/vsp1_hsit.c b/drivers/media/platform/vsp1/vsp1_hsit.c
index 0bc0471746c9..d226b3ff5e30 100644
--- a/drivers/media/platform/vsp1/vsp1_hsit.c
+++ b/drivers/media/platform/vsp1/vsp1_hsit.c
@@ -55,7 +55,7 @@ static int hsit_s_stream(struct v4l2_subdev *subdev, int enable)
55 */ 55 */
56 56
57static int hsit_enum_mbus_code(struct v4l2_subdev *subdev, 57static int hsit_enum_mbus_code(struct v4l2_subdev *subdev,
58 struct v4l2_subdev_fh *fh, 58 struct v4l2_subdev_pad_config *cfg,
59 struct v4l2_subdev_mbus_code_enum *code) 59 struct v4l2_subdev_mbus_code_enum *code)
60{ 60{
61 struct vsp1_hsit *hsit = to_hsit(subdev); 61 struct vsp1_hsit *hsit = to_hsit(subdev);
@@ -73,12 +73,12 @@ static int hsit_enum_mbus_code(struct v4l2_subdev *subdev,
73} 73}
74 74
75static int hsit_enum_frame_size(struct v4l2_subdev *subdev, 75static int hsit_enum_frame_size(struct v4l2_subdev *subdev,
76 struct v4l2_subdev_fh *fh, 76 struct v4l2_subdev_pad_config *cfg,
77 struct v4l2_subdev_frame_size_enum *fse) 77 struct v4l2_subdev_frame_size_enum *fse)
78{ 78{
79 struct v4l2_mbus_framefmt *format; 79 struct v4l2_mbus_framefmt *format;
80 80
81 format = v4l2_subdev_get_try_format(fh, fse->pad); 81 format = v4l2_subdev_get_try_format(subdev, cfg, fse->pad);
82 82
83 if (fse->index || fse->code != format->code) 83 if (fse->index || fse->code != format->code)
84 return -EINVAL; 84 return -EINVAL;
@@ -102,25 +102,25 @@ static int hsit_enum_frame_size(struct v4l2_subdev *subdev,
102} 102}
103 103
104static int hsit_get_format(struct v4l2_subdev *subdev, 104static int hsit_get_format(struct v4l2_subdev *subdev,
105 struct v4l2_subdev_fh *fh, 105 struct v4l2_subdev_pad_config *cfg,
106 struct v4l2_subdev_format *fmt) 106 struct v4l2_subdev_format *fmt)
107{ 107{
108 struct vsp1_hsit *hsit = to_hsit(subdev); 108 struct vsp1_hsit *hsit = to_hsit(subdev);
109 109
110 fmt->format = *vsp1_entity_get_pad_format(&hsit->entity, fh, fmt->pad, 110 fmt->format = *vsp1_entity_get_pad_format(&hsit->entity, cfg, fmt->pad,
111 fmt->which); 111 fmt->which);
112 112
113 return 0; 113 return 0;
114} 114}
115 115
116static int hsit_set_format(struct v4l2_subdev *subdev, 116static int hsit_set_format(struct v4l2_subdev *subdev,
117 struct v4l2_subdev_fh *fh, 117 struct v4l2_subdev_pad_config *cfg,
118 struct v4l2_subdev_format *fmt) 118 struct v4l2_subdev_format *fmt)
119{ 119{
120 struct vsp1_hsit *hsit = to_hsit(subdev); 120 struct vsp1_hsit *hsit = to_hsit(subdev);
121 struct v4l2_mbus_framefmt *format; 121 struct v4l2_mbus_framefmt *format;
122 122
123 format = vsp1_entity_get_pad_format(&hsit->entity, fh, fmt->pad, 123 format = vsp1_entity_get_pad_format(&hsit->entity, cfg, fmt->pad,
124 fmt->which); 124 fmt->which);
125 125
126 if (fmt->pad == HSIT_PAD_SOURCE) { 126 if (fmt->pad == HSIT_PAD_SOURCE) {
@@ -143,7 +143,7 @@ static int hsit_set_format(struct v4l2_subdev *subdev,
143 fmt->format = *format; 143 fmt->format = *format;
144 144
145 /* Propagate the format to the source pad. */ 145 /* Propagate the format to the source pad. */
146 format = vsp1_entity_get_pad_format(&hsit->entity, fh, HSIT_PAD_SOURCE, 146 format = vsp1_entity_get_pad_format(&hsit->entity, cfg, HSIT_PAD_SOURCE,
147 fmt->which); 147 fmt->which);
148 *format = fmt->format; 148 *format = fmt->format;
149 format->code = hsit->inverse ? MEDIA_BUS_FMT_ARGB8888_1X32 149 format->code = hsit->inverse ? MEDIA_BUS_FMT_ARGB8888_1X32
diff --git a/drivers/media/platform/vsp1/vsp1_lif.c b/drivers/media/platform/vsp1/vsp1_lif.c
index 17a6ca7dafe6..b91c925a9887 100644
--- a/drivers/media/platform/vsp1/vsp1_lif.c
+++ b/drivers/media/platform/vsp1/vsp1_lif.c
@@ -74,7 +74,7 @@ static int lif_s_stream(struct v4l2_subdev *subdev, int enable)
74 */ 74 */
75 75
76static int lif_enum_mbus_code(struct v4l2_subdev *subdev, 76static int lif_enum_mbus_code(struct v4l2_subdev *subdev,
77 struct v4l2_subdev_fh *fh, 77 struct v4l2_subdev_pad_config *cfg,
78 struct v4l2_subdev_mbus_code_enum *code) 78 struct v4l2_subdev_mbus_code_enum *code)
79{ 79{
80 static const unsigned int codes[] = { 80 static const unsigned int codes[] = {
@@ -96,7 +96,7 @@ static int lif_enum_mbus_code(struct v4l2_subdev *subdev,
96 if (code->index) 96 if (code->index)
97 return -EINVAL; 97 return -EINVAL;
98 98
99 format = v4l2_subdev_get_try_format(fh, LIF_PAD_SINK); 99 format = v4l2_subdev_get_try_format(subdev, cfg, LIF_PAD_SINK);
100 code->code = format->code; 100 code->code = format->code;
101 } 101 }
102 102
@@ -104,12 +104,12 @@ static int lif_enum_mbus_code(struct v4l2_subdev *subdev,
104} 104}
105 105
106static int lif_enum_frame_size(struct v4l2_subdev *subdev, 106static int lif_enum_frame_size(struct v4l2_subdev *subdev,
107 struct v4l2_subdev_fh *fh, 107 struct v4l2_subdev_pad_config *cfg,
108 struct v4l2_subdev_frame_size_enum *fse) 108 struct v4l2_subdev_frame_size_enum *fse)
109{ 109{
110 struct v4l2_mbus_framefmt *format; 110 struct v4l2_mbus_framefmt *format;
111 111
112 format = v4l2_subdev_get_try_format(fh, LIF_PAD_SINK); 112 format = v4l2_subdev_get_try_format(subdev, cfg, LIF_PAD_SINK);
113 113
114 if (fse->index || fse->code != format->code) 114 if (fse->index || fse->code != format->code)
115 return -EINVAL; 115 return -EINVAL;
@@ -129,18 +129,18 @@ static int lif_enum_frame_size(struct v4l2_subdev *subdev,
129 return 0; 129 return 0;
130} 130}
131 131
132static int lif_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 132static int lif_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
133 struct v4l2_subdev_format *fmt) 133 struct v4l2_subdev_format *fmt)
134{ 134{
135 struct vsp1_lif *lif = to_lif(subdev); 135 struct vsp1_lif *lif = to_lif(subdev);
136 136
137 fmt->format = *vsp1_entity_get_pad_format(&lif->entity, fh, fmt->pad, 137 fmt->format = *vsp1_entity_get_pad_format(&lif->entity, cfg, fmt->pad,
138 fmt->which); 138 fmt->which);
139 139
140 return 0; 140 return 0;
141} 141}
142 142
143static int lif_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 143static int lif_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
144 struct v4l2_subdev_format *fmt) 144 struct v4l2_subdev_format *fmt)
145{ 145{
146 struct vsp1_lif *lif = to_lif(subdev); 146 struct vsp1_lif *lif = to_lif(subdev);
@@ -151,7 +151,7 @@ static int lif_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh,
151 fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32) 151 fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32)
152 fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32; 152 fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32;
153 153
154 format = vsp1_entity_get_pad_format(&lif->entity, fh, fmt->pad, 154 format = vsp1_entity_get_pad_format(&lif->entity, cfg, fmt->pad,
155 fmt->which); 155 fmt->which);
156 156
157 if (fmt->pad == LIF_PAD_SOURCE) { 157 if (fmt->pad == LIF_PAD_SOURCE) {
@@ -173,7 +173,7 @@ static int lif_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh,
173 fmt->format = *format; 173 fmt->format = *format;
174 174
175 /* Propagate the format to the source pad. */ 175 /* Propagate the format to the source pad. */
176 format = vsp1_entity_get_pad_format(&lif->entity, fh, LIF_PAD_SOURCE, 176 format = vsp1_entity_get_pad_format(&lif->entity, cfg, LIF_PAD_SOURCE,
177 fmt->which); 177 fmt->which);
178 *format = fmt->format; 178 *format = fmt->format;
179 179
diff --git a/drivers/media/platform/vsp1/vsp1_lut.c b/drivers/media/platform/vsp1/vsp1_lut.c
index 6f185c3621fe..003363d9a5d8 100644
--- a/drivers/media/platform/vsp1/vsp1_lut.c
+++ b/drivers/media/platform/vsp1/vsp1_lut.c
@@ -82,7 +82,7 @@ static int lut_s_stream(struct v4l2_subdev *subdev, int enable)
82 */ 82 */
83 83
84static int lut_enum_mbus_code(struct v4l2_subdev *subdev, 84static int lut_enum_mbus_code(struct v4l2_subdev *subdev,
85 struct v4l2_subdev_fh *fh, 85 struct v4l2_subdev_pad_config *cfg,
86 struct v4l2_subdev_mbus_code_enum *code) 86 struct v4l2_subdev_mbus_code_enum *code)
87{ 87{
88 static const unsigned int codes[] = { 88 static const unsigned int codes[] = {
@@ -104,7 +104,7 @@ static int lut_enum_mbus_code(struct v4l2_subdev *subdev,
104 if (code->index) 104 if (code->index)
105 return -EINVAL; 105 return -EINVAL;
106 106
107 format = v4l2_subdev_get_try_format(fh, LUT_PAD_SINK); 107 format = v4l2_subdev_get_try_format(subdev, cfg, LUT_PAD_SINK);
108 code->code = format->code; 108 code->code = format->code;
109 } 109 }
110 110
@@ -112,12 +112,12 @@ static int lut_enum_mbus_code(struct v4l2_subdev *subdev,
112} 112}
113 113
114static int lut_enum_frame_size(struct v4l2_subdev *subdev, 114static int lut_enum_frame_size(struct v4l2_subdev *subdev,
115 struct v4l2_subdev_fh *fh, 115 struct v4l2_subdev_pad_config *cfg,
116 struct v4l2_subdev_frame_size_enum *fse) 116 struct v4l2_subdev_frame_size_enum *fse)
117{ 117{
118 struct v4l2_mbus_framefmt *format; 118 struct v4l2_mbus_framefmt *format;
119 119
120 format = v4l2_subdev_get_try_format(fh, fse->pad); 120 format = v4l2_subdev_get_try_format(subdev, cfg, fse->pad);
121 121
122 if (fse->index || fse->code != format->code) 122 if (fse->index || fse->code != format->code)
123 return -EINVAL; 123 return -EINVAL;
@@ -140,18 +140,18 @@ static int lut_enum_frame_size(struct v4l2_subdev *subdev,
140 return 0; 140 return 0;
141} 141}
142 142
143static int lut_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 143static int lut_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
144 struct v4l2_subdev_format *fmt) 144 struct v4l2_subdev_format *fmt)
145{ 145{
146 struct vsp1_lut *lut = to_lut(subdev); 146 struct vsp1_lut *lut = to_lut(subdev);
147 147
148 fmt->format = *vsp1_entity_get_pad_format(&lut->entity, fh, fmt->pad, 148 fmt->format = *vsp1_entity_get_pad_format(&lut->entity, cfg, fmt->pad,
149 fmt->which); 149 fmt->which);
150 150
151 return 0; 151 return 0;
152} 152}
153 153
154static int lut_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 154static int lut_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
155 struct v4l2_subdev_format *fmt) 155 struct v4l2_subdev_format *fmt)
156{ 156{
157 struct vsp1_lut *lut = to_lut(subdev); 157 struct vsp1_lut *lut = to_lut(subdev);
@@ -163,7 +163,7 @@ static int lut_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh,
163 fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32) 163 fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32)
164 fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32; 164 fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32;
165 165
166 format = vsp1_entity_get_pad_format(&lut->entity, fh, fmt->pad, 166 format = vsp1_entity_get_pad_format(&lut->entity, cfg, fmt->pad,
167 fmt->which); 167 fmt->which);
168 168
169 if (fmt->pad == LUT_PAD_SOURCE) { 169 if (fmt->pad == LUT_PAD_SOURCE) {
@@ -182,7 +182,7 @@ static int lut_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh,
182 fmt->format = *format; 182 fmt->format = *format;
183 183
184 /* Propagate the format to the source pad. */ 184 /* Propagate the format to the source pad. */
185 format = vsp1_entity_get_pad_format(&lut->entity, fh, LUT_PAD_SOURCE, 185 format = vsp1_entity_get_pad_format(&lut->entity, cfg, LUT_PAD_SOURCE,
186 fmt->which); 186 fmt->which);
187 *format = fmt->format; 187 *format = fmt->format;
188 188
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.c b/drivers/media/platform/vsp1/vsp1_rwpf.c
index 1f1ba26a834a..a083d85e84b4 100644
--- a/drivers/media/platform/vsp1/vsp1_rwpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rwpf.c
@@ -25,7 +25,7 @@
25 */ 25 */
26 26
27int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev, 27int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev,
28 struct v4l2_subdev_fh *fh, 28 struct v4l2_subdev_pad_config *cfg,
29 struct v4l2_subdev_mbus_code_enum *code) 29 struct v4l2_subdev_mbus_code_enum *code)
30{ 30{
31 static const unsigned int codes[] = { 31 static const unsigned int codes[] = {
@@ -42,13 +42,13 @@ int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev,
42} 42}
43 43
44int vsp1_rwpf_enum_frame_size(struct v4l2_subdev *subdev, 44int vsp1_rwpf_enum_frame_size(struct v4l2_subdev *subdev,
45 struct v4l2_subdev_fh *fh, 45 struct v4l2_subdev_pad_config *cfg,
46 struct v4l2_subdev_frame_size_enum *fse) 46 struct v4l2_subdev_frame_size_enum *fse)
47{ 47{
48 struct vsp1_rwpf *rwpf = to_rwpf(subdev); 48 struct vsp1_rwpf *rwpf = to_rwpf(subdev);
49 struct v4l2_mbus_framefmt *format; 49 struct v4l2_mbus_framefmt *format;
50 50
51 format = v4l2_subdev_get_try_format(fh, fse->pad); 51 format = v4l2_subdev_get_try_format(subdev, cfg, fse->pad);
52 52
53 if (fse->index || fse->code != format->code) 53 if (fse->index || fse->code != format->code)
54 return -EINVAL; 54 return -EINVAL;
@@ -72,11 +72,11 @@ int vsp1_rwpf_enum_frame_size(struct v4l2_subdev *subdev,
72} 72}
73 73
74static struct v4l2_rect * 74static struct v4l2_rect *
75vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf, struct v4l2_subdev_fh *fh, u32 which) 75vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf, struct v4l2_subdev_pad_config *cfg, u32 which)
76{ 76{
77 switch (which) { 77 switch (which) {
78 case V4L2_SUBDEV_FORMAT_TRY: 78 case V4L2_SUBDEV_FORMAT_TRY:
79 return v4l2_subdev_get_try_crop(fh, RWPF_PAD_SINK); 79 return v4l2_subdev_get_try_crop(&rwpf->entity.subdev, cfg, RWPF_PAD_SINK);
80 case V4L2_SUBDEV_FORMAT_ACTIVE: 80 case V4L2_SUBDEV_FORMAT_ACTIVE:
81 return &rwpf->crop; 81 return &rwpf->crop;
82 default: 82 default:
@@ -84,18 +84,18 @@ vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf, struct v4l2_subdev_fh *fh, u32 which)
84 } 84 }
85} 85}
86 86
87int vsp1_rwpf_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 87int vsp1_rwpf_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
88 struct v4l2_subdev_format *fmt) 88 struct v4l2_subdev_format *fmt)
89{ 89{
90 struct vsp1_rwpf *rwpf = to_rwpf(subdev); 90 struct vsp1_rwpf *rwpf = to_rwpf(subdev);
91 91
92 fmt->format = *vsp1_entity_get_pad_format(&rwpf->entity, fh, fmt->pad, 92 fmt->format = *vsp1_entity_get_pad_format(&rwpf->entity, cfg, fmt->pad,
93 fmt->which); 93 fmt->which);
94 94
95 return 0; 95 return 0;
96} 96}
97 97
98int vsp1_rwpf_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 98int vsp1_rwpf_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
99 struct v4l2_subdev_format *fmt) 99 struct v4l2_subdev_format *fmt)
100{ 100{
101 struct vsp1_rwpf *rwpf = to_rwpf(subdev); 101 struct vsp1_rwpf *rwpf = to_rwpf(subdev);
@@ -107,7 +107,7 @@ int vsp1_rwpf_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh,
107 fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32) 107 fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32)
108 fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32; 108 fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32;
109 109
110 format = vsp1_entity_get_pad_format(&rwpf->entity, fh, fmt->pad, 110 format = vsp1_entity_get_pad_format(&rwpf->entity, cfg, fmt->pad,
111 fmt->which); 111 fmt->which);
112 112
113 if (fmt->pad == RWPF_PAD_SOURCE) { 113 if (fmt->pad == RWPF_PAD_SOURCE) {
@@ -130,14 +130,14 @@ int vsp1_rwpf_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh,
130 fmt->format = *format; 130 fmt->format = *format;
131 131
132 /* Update the sink crop rectangle. */ 132 /* Update the sink crop rectangle. */
133 crop = vsp1_rwpf_get_crop(rwpf, fh, fmt->which); 133 crop = vsp1_rwpf_get_crop(rwpf, cfg, fmt->which);
134 crop->left = 0; 134 crop->left = 0;
135 crop->top = 0; 135 crop->top = 0;
136 crop->width = fmt->format.width; 136 crop->width = fmt->format.width;
137 crop->height = fmt->format.height; 137 crop->height = fmt->format.height;
138 138
139 /* Propagate the format to the source pad. */ 139 /* Propagate the format to the source pad. */
140 format = vsp1_entity_get_pad_format(&rwpf->entity, fh, RWPF_PAD_SOURCE, 140 format = vsp1_entity_get_pad_format(&rwpf->entity, cfg, RWPF_PAD_SOURCE,
141 fmt->which); 141 fmt->which);
142 *format = fmt->format; 142 *format = fmt->format;
143 143
@@ -145,7 +145,7 @@ int vsp1_rwpf_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh,
145} 145}
146 146
147int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev, 147int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
148 struct v4l2_subdev_fh *fh, 148 struct v4l2_subdev_pad_config *cfg,
149 struct v4l2_subdev_selection *sel) 149 struct v4l2_subdev_selection *sel)
150{ 150{
151 struct vsp1_rwpf *rwpf = to_rwpf(subdev); 151 struct vsp1_rwpf *rwpf = to_rwpf(subdev);
@@ -157,11 +157,11 @@ int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
157 157
158 switch (sel->target) { 158 switch (sel->target) {
159 case V4L2_SEL_TGT_CROP: 159 case V4L2_SEL_TGT_CROP:
160 sel->r = *vsp1_rwpf_get_crop(rwpf, fh, sel->which); 160 sel->r = *vsp1_rwpf_get_crop(rwpf, cfg, sel->which);
161 break; 161 break;
162 162
163 case V4L2_SEL_TGT_CROP_BOUNDS: 163 case V4L2_SEL_TGT_CROP_BOUNDS:
164 format = vsp1_entity_get_pad_format(&rwpf->entity, fh, 164 format = vsp1_entity_get_pad_format(&rwpf->entity, cfg,
165 RWPF_PAD_SINK, sel->which); 165 RWPF_PAD_SINK, sel->which);
166 sel->r.left = 0; 166 sel->r.left = 0;
167 sel->r.top = 0; 167 sel->r.top = 0;
@@ -177,7 +177,7 @@ int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
177} 177}
178 178
179int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev, 179int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
180 struct v4l2_subdev_fh *fh, 180 struct v4l2_subdev_pad_config *cfg,
181 struct v4l2_subdev_selection *sel) 181 struct v4l2_subdev_selection *sel)
182{ 182{
183 struct vsp1_rwpf *rwpf = to_rwpf(subdev); 183 struct vsp1_rwpf *rwpf = to_rwpf(subdev);
@@ -194,7 +194,7 @@ int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
194 /* Make sure the crop rectangle is entirely contained in the image. The 194 /* Make sure the crop rectangle is entirely contained in the image. The
195 * WPF top and left offsets are limited to 255. 195 * WPF top and left offsets are limited to 255.
196 */ 196 */
197 format = vsp1_entity_get_pad_format(&rwpf->entity, fh, RWPF_PAD_SINK, 197 format = vsp1_entity_get_pad_format(&rwpf->entity, cfg, RWPF_PAD_SINK,
198 sel->which); 198 sel->which);
199 sel->r.left = min_t(unsigned int, sel->r.left, format->width - 2); 199 sel->r.left = min_t(unsigned int, sel->r.left, format->width - 2);
200 sel->r.top = min_t(unsigned int, sel->r.top, format->height - 2); 200 sel->r.top = min_t(unsigned int, sel->r.top, format->height - 2);
@@ -207,11 +207,11 @@ int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
207 sel->r.height = min_t(unsigned int, sel->r.height, 207 sel->r.height = min_t(unsigned int, sel->r.height,
208 format->height - sel->r.top); 208 format->height - sel->r.top);
209 209
210 crop = vsp1_rwpf_get_crop(rwpf, fh, sel->which); 210 crop = vsp1_rwpf_get_crop(rwpf, cfg, sel->which);
211 *crop = sel->r; 211 *crop = sel->r;
212 212
213 /* Propagate the format to the source pad. */ 213 /* Propagate the format to the source pad. */
214 format = vsp1_entity_get_pad_format(&rwpf->entity, fh, RWPF_PAD_SOURCE, 214 format = vsp1_entity_get_pad_format(&rwpf->entity, cfg, RWPF_PAD_SOURCE,
215 sel->which); 215 sel->which);
216 format->width = crop->width; 216 format->width = crop->width;
217 format->height = crop->height; 217 format->height = crop->height;
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.h b/drivers/media/platform/vsp1/vsp1_rwpf.h
index 2cf1f13d3bf9..f452dce1a931 100644
--- a/drivers/media/platform/vsp1/vsp1_rwpf.h
+++ b/drivers/media/platform/vsp1/vsp1_rwpf.h
@@ -51,20 +51,20 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index);
51struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index); 51struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index);
52 52
53int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev, 53int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev,
54 struct v4l2_subdev_fh *fh, 54 struct v4l2_subdev_pad_config *cfg,
55 struct v4l2_subdev_mbus_code_enum *code); 55 struct v4l2_subdev_mbus_code_enum *code);
56int vsp1_rwpf_enum_frame_size(struct v4l2_subdev *subdev, 56int vsp1_rwpf_enum_frame_size(struct v4l2_subdev *subdev,
57 struct v4l2_subdev_fh *fh, 57 struct v4l2_subdev_pad_config *cfg,
58 struct v4l2_subdev_frame_size_enum *fse); 58 struct v4l2_subdev_frame_size_enum *fse);
59int vsp1_rwpf_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 59int vsp1_rwpf_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
60 struct v4l2_subdev_format *fmt); 60 struct v4l2_subdev_format *fmt);
61int vsp1_rwpf_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 61int vsp1_rwpf_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
62 struct v4l2_subdev_format *fmt); 62 struct v4l2_subdev_format *fmt);
63int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev, 63int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
64 struct v4l2_subdev_fh *fh, 64 struct v4l2_subdev_pad_config *cfg,
65 struct v4l2_subdev_selection *sel); 65 struct v4l2_subdev_selection *sel);
66int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev, 66int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
67 struct v4l2_subdev_fh *fh, 67 struct v4l2_subdev_pad_config *cfg,
68 struct v4l2_subdev_selection *sel); 68 struct v4l2_subdev_selection *sel);
69 69
70#endif /* __VSP1_RWPF_H__ */ 70#endif /* __VSP1_RWPF_H__ */
diff --git a/drivers/media/platform/vsp1/vsp1_sru.c b/drivers/media/platform/vsp1/vsp1_sru.c
index 1129494c7cfc..c51dcee228bc 100644
--- a/drivers/media/platform/vsp1/vsp1_sru.c
+++ b/drivers/media/platform/vsp1/vsp1_sru.c
@@ -166,7 +166,7 @@ static int sru_s_stream(struct v4l2_subdev *subdev, int enable)
166 */ 166 */
167 167
168static int sru_enum_mbus_code(struct v4l2_subdev *subdev, 168static int sru_enum_mbus_code(struct v4l2_subdev *subdev,
169 struct v4l2_subdev_fh *fh, 169 struct v4l2_subdev_pad_config *cfg,
170 struct v4l2_subdev_mbus_code_enum *code) 170 struct v4l2_subdev_mbus_code_enum *code)
171{ 171{
172 static const unsigned int codes[] = { 172 static const unsigned int codes[] = {
@@ -187,7 +187,7 @@ static int sru_enum_mbus_code(struct v4l2_subdev *subdev,
187 if (code->index) 187 if (code->index)
188 return -EINVAL; 188 return -EINVAL;
189 189
190 format = v4l2_subdev_get_try_format(fh, SRU_PAD_SINK); 190 format = v4l2_subdev_get_try_format(subdev, cfg, SRU_PAD_SINK);
191 code->code = format->code; 191 code->code = format->code;
192 } 192 }
193 193
@@ -195,12 +195,12 @@ static int sru_enum_mbus_code(struct v4l2_subdev *subdev,
195} 195}
196 196
197static int sru_enum_frame_size(struct v4l2_subdev *subdev, 197static int sru_enum_frame_size(struct v4l2_subdev *subdev,
198 struct v4l2_subdev_fh *fh, 198 struct v4l2_subdev_pad_config *cfg,
199 struct v4l2_subdev_frame_size_enum *fse) 199 struct v4l2_subdev_frame_size_enum *fse)
200{ 200{
201 struct v4l2_mbus_framefmt *format; 201 struct v4l2_mbus_framefmt *format;
202 202
203 format = v4l2_subdev_get_try_format(fh, SRU_PAD_SINK); 203 format = v4l2_subdev_get_try_format(subdev, cfg, SRU_PAD_SINK);
204 204
205 if (fse->index || fse->code != format->code) 205 if (fse->index || fse->code != format->code)
206 return -EINVAL; 206 return -EINVAL;
@@ -226,18 +226,18 @@ static int sru_enum_frame_size(struct v4l2_subdev *subdev,
226 return 0; 226 return 0;
227} 227}
228 228
229static int sru_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 229static int sru_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
230 struct v4l2_subdev_format *fmt) 230 struct v4l2_subdev_format *fmt)
231{ 231{
232 struct vsp1_sru *sru = to_sru(subdev); 232 struct vsp1_sru *sru = to_sru(subdev);
233 233
234 fmt->format = *vsp1_entity_get_pad_format(&sru->entity, fh, fmt->pad, 234 fmt->format = *vsp1_entity_get_pad_format(&sru->entity, cfg, fmt->pad,
235 fmt->which); 235 fmt->which);
236 236
237 return 0; 237 return 0;
238} 238}
239 239
240static void sru_try_format(struct vsp1_sru *sru, struct v4l2_subdev_fh *fh, 240static void sru_try_format(struct vsp1_sru *sru, struct v4l2_subdev_pad_config *cfg,
241 unsigned int pad, struct v4l2_mbus_framefmt *fmt, 241 unsigned int pad, struct v4l2_mbus_framefmt *fmt,
242 enum v4l2_subdev_format_whence which) 242 enum v4l2_subdev_format_whence which)
243{ 243{
@@ -258,7 +258,7 @@ static void sru_try_format(struct vsp1_sru *sru, struct v4l2_subdev_fh *fh,
258 258
259 case SRU_PAD_SOURCE: 259 case SRU_PAD_SOURCE:
260 /* The SRU can't perform format conversion. */ 260 /* The SRU can't perform format conversion. */
261 format = vsp1_entity_get_pad_format(&sru->entity, fh, 261 format = vsp1_entity_get_pad_format(&sru->entity, cfg,
262 SRU_PAD_SINK, which); 262 SRU_PAD_SINK, which);
263 fmt->code = format->code; 263 fmt->code = format->code;
264 264
@@ -288,25 +288,25 @@ static void sru_try_format(struct vsp1_sru *sru, struct v4l2_subdev_fh *fh,
288 fmt->colorspace = V4L2_COLORSPACE_SRGB; 288 fmt->colorspace = V4L2_COLORSPACE_SRGB;
289} 289}
290 290
291static int sru_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 291static int sru_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
292 struct v4l2_subdev_format *fmt) 292 struct v4l2_subdev_format *fmt)
293{ 293{
294 struct vsp1_sru *sru = to_sru(subdev); 294 struct vsp1_sru *sru = to_sru(subdev);
295 struct v4l2_mbus_framefmt *format; 295 struct v4l2_mbus_framefmt *format;
296 296
297 sru_try_format(sru, fh, fmt->pad, &fmt->format, fmt->which); 297 sru_try_format(sru, cfg, fmt->pad, &fmt->format, fmt->which);
298 298
299 format = vsp1_entity_get_pad_format(&sru->entity, fh, fmt->pad, 299 format = vsp1_entity_get_pad_format(&sru->entity, cfg, fmt->pad,
300 fmt->which); 300 fmt->which);
301 *format = fmt->format; 301 *format = fmt->format;
302 302
303 if (fmt->pad == SRU_PAD_SINK) { 303 if (fmt->pad == SRU_PAD_SINK) {
304 /* Propagate the format to the source pad. */ 304 /* Propagate the format to the source pad. */
305 format = vsp1_entity_get_pad_format(&sru->entity, fh, 305 format = vsp1_entity_get_pad_format(&sru->entity, cfg,
306 SRU_PAD_SOURCE, fmt->which); 306 SRU_PAD_SOURCE, fmt->which);
307 *format = fmt->format; 307 *format = fmt->format;
308 308
309 sru_try_format(sru, fh, SRU_PAD_SOURCE, format, fmt->which); 309 sru_try_format(sru, cfg, SRU_PAD_SOURCE, format, fmt->which);
310 } 310 }
311 311
312 return 0; 312 return 0;
diff --git a/drivers/media/platform/vsp1/vsp1_uds.c b/drivers/media/platform/vsp1/vsp1_uds.c
index a4afec133800..08d916d5d1ac 100644
--- a/drivers/media/platform/vsp1/vsp1_uds.c
+++ b/drivers/media/platform/vsp1/vsp1_uds.c
@@ -169,7 +169,7 @@ static int uds_s_stream(struct v4l2_subdev *subdev, int enable)
169 */ 169 */
170 170
171static int uds_enum_mbus_code(struct v4l2_subdev *subdev, 171static int uds_enum_mbus_code(struct v4l2_subdev *subdev,
172 struct v4l2_subdev_fh *fh, 172 struct v4l2_subdev_pad_config *cfg,
173 struct v4l2_subdev_mbus_code_enum *code) 173 struct v4l2_subdev_mbus_code_enum *code)
174{ 174{
175 static const unsigned int codes[] = { 175 static const unsigned int codes[] = {
@@ -191,7 +191,7 @@ static int uds_enum_mbus_code(struct v4l2_subdev *subdev,
191 if (code->index) 191 if (code->index)
192 return -EINVAL; 192 return -EINVAL;
193 193
194 format = v4l2_subdev_get_try_format(fh, UDS_PAD_SINK); 194 format = v4l2_subdev_get_try_format(subdev, cfg, UDS_PAD_SINK);
195 code->code = format->code; 195 code->code = format->code;
196 } 196 }
197 197
@@ -199,12 +199,12 @@ static int uds_enum_mbus_code(struct v4l2_subdev *subdev,
199} 199}
200 200
201static int uds_enum_frame_size(struct v4l2_subdev *subdev, 201static int uds_enum_frame_size(struct v4l2_subdev *subdev,
202 struct v4l2_subdev_fh *fh, 202 struct v4l2_subdev_pad_config *cfg,
203 struct v4l2_subdev_frame_size_enum *fse) 203 struct v4l2_subdev_frame_size_enum *fse)
204{ 204{
205 struct v4l2_mbus_framefmt *format; 205 struct v4l2_mbus_framefmt *format;
206 206
207 format = v4l2_subdev_get_try_format(fh, UDS_PAD_SINK); 207 format = v4l2_subdev_get_try_format(subdev, cfg, UDS_PAD_SINK);
208 208
209 if (fse->index || fse->code != format->code) 209 if (fse->index || fse->code != format->code)
210 return -EINVAL; 210 return -EINVAL;
@@ -224,18 +224,18 @@ static int uds_enum_frame_size(struct v4l2_subdev *subdev,
224 return 0; 224 return 0;
225} 225}
226 226
227static int uds_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 227static int uds_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
228 struct v4l2_subdev_format *fmt) 228 struct v4l2_subdev_format *fmt)
229{ 229{
230 struct vsp1_uds *uds = to_uds(subdev); 230 struct vsp1_uds *uds = to_uds(subdev);
231 231
232 fmt->format = *vsp1_entity_get_pad_format(&uds->entity, fh, fmt->pad, 232 fmt->format = *vsp1_entity_get_pad_format(&uds->entity, cfg, fmt->pad,
233 fmt->which); 233 fmt->which);
234 234
235 return 0; 235 return 0;
236} 236}
237 237
238static void uds_try_format(struct vsp1_uds *uds, struct v4l2_subdev_fh *fh, 238static void uds_try_format(struct vsp1_uds *uds, struct v4l2_subdev_pad_config *cfg,
239 unsigned int pad, struct v4l2_mbus_framefmt *fmt, 239 unsigned int pad, struct v4l2_mbus_framefmt *fmt,
240 enum v4l2_subdev_format_whence which) 240 enum v4l2_subdev_format_whence which)
241{ 241{
@@ -256,7 +256,7 @@ static void uds_try_format(struct vsp1_uds *uds, struct v4l2_subdev_fh *fh,
256 256
257 case UDS_PAD_SOURCE: 257 case UDS_PAD_SOURCE:
258 /* The UDS scales but can't perform format conversion. */ 258 /* The UDS scales but can't perform format conversion. */
259 format = vsp1_entity_get_pad_format(&uds->entity, fh, 259 format = vsp1_entity_get_pad_format(&uds->entity, cfg,
260 UDS_PAD_SINK, which); 260 UDS_PAD_SINK, which);
261 fmt->code = format->code; 261 fmt->code = format->code;
262 262
@@ -271,25 +271,25 @@ static void uds_try_format(struct vsp1_uds *uds, struct v4l2_subdev_fh *fh,
271 fmt->colorspace = V4L2_COLORSPACE_SRGB; 271 fmt->colorspace = V4L2_COLORSPACE_SRGB;
272} 272}
273 273
274static int uds_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh, 274static int uds_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
275 struct v4l2_subdev_format *fmt) 275 struct v4l2_subdev_format *fmt)
276{ 276{
277 struct vsp1_uds *uds = to_uds(subdev); 277 struct vsp1_uds *uds = to_uds(subdev);
278 struct v4l2_mbus_framefmt *format; 278 struct v4l2_mbus_framefmt *format;
279 279
280 uds_try_format(uds, fh, fmt->pad, &fmt->format, fmt->which); 280 uds_try_format(uds, cfg, fmt->pad, &fmt->format, fmt->which);
281 281
282 format = vsp1_entity_get_pad_format(&uds->entity, fh, fmt->pad, 282 format = vsp1_entity_get_pad_format(&uds->entity, cfg, fmt->pad,
283 fmt->which); 283 fmt->which);
284 *format = fmt->format; 284 *format = fmt->format;
285 285
286 if (fmt->pad == UDS_PAD_SINK) { 286 if (fmt->pad == UDS_PAD_SINK) {
287 /* Propagate the format to the source pad. */ 287 /* Propagate the format to the source pad. */
288 format = vsp1_entity_get_pad_format(&uds->entity, fh, 288 format = vsp1_entity_get_pad_format(&uds->entity, cfg,
289 UDS_PAD_SOURCE, fmt->which); 289 UDS_PAD_SOURCE, fmt->which);
290 *format = fmt->format; 290 *format = fmt->format;
291 291
292 uds_try_format(uds, fh, UDS_PAD_SOURCE, format, fmt->which); 292 uds_try_format(uds, cfg, UDS_PAD_SOURCE, format, fmt->which);
293 } 293 }
294 294
295 return 0; 295 return 0;
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 19a034e79be4..3c8b198a0622 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -262,7 +262,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
262 if (rval) 262 if (rval)
263 return rval; 263 return rval;
264 264
265 return v4l2_subdev_call(sd, pad, get_fmt, subdev_fh, format); 265 return v4l2_subdev_call(sd, pad, get_fmt, subdev_fh->pad, format);
266 } 266 }
267 267
268 case VIDIOC_SUBDEV_S_FMT: { 268 case VIDIOC_SUBDEV_S_FMT: {
@@ -272,7 +272,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
272 if (rval) 272 if (rval)
273 return rval; 273 return rval;
274 274
275 return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh, format); 275 return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh->pad, format);
276 } 276 }
277 277
278 case VIDIOC_SUBDEV_G_CROP: { 278 case VIDIOC_SUBDEV_G_CROP: {
@@ -289,7 +289,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
289 sel.target = V4L2_SEL_TGT_CROP; 289 sel.target = V4L2_SEL_TGT_CROP;
290 290
291 rval = v4l2_subdev_call( 291 rval = v4l2_subdev_call(
292 sd, pad, get_selection, subdev_fh, &sel); 292 sd, pad, get_selection, subdev_fh->pad, &sel);
293 293
294 crop->rect = sel.r; 294 crop->rect = sel.r;
295 295
@@ -311,7 +311,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
311 sel.r = crop->rect; 311 sel.r = crop->rect;
312 312
313 rval = v4l2_subdev_call( 313 rval = v4l2_subdev_call(
314 sd, pad, set_selection, subdev_fh, &sel); 314 sd, pad, set_selection, subdev_fh->pad, &sel);
315 315
316 crop->rect = sel.r; 316 crop->rect = sel.r;
317 317
@@ -324,7 +324,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
324 if (code->pad >= sd->entity.num_pads) 324 if (code->pad >= sd->entity.num_pads)
325 return -EINVAL; 325 return -EINVAL;
326 326
327 return v4l2_subdev_call(sd, pad, enum_mbus_code, subdev_fh, 327 return v4l2_subdev_call(sd, pad, enum_mbus_code, subdev_fh->pad,
328 code); 328 code);
329 } 329 }
330 330
@@ -334,7 +334,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
334 if (fse->pad >= sd->entity.num_pads) 334 if (fse->pad >= sd->entity.num_pads)
335 return -EINVAL; 335 return -EINVAL;
336 336
337 return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh, 337 return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh->pad,
338 fse); 338 fse);
339 } 339 }
340 340
@@ -362,7 +362,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
362 if (fie->pad >= sd->entity.num_pads) 362 if (fie->pad >= sd->entity.num_pads)
363 return -EINVAL; 363 return -EINVAL;
364 364
365 return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh, 365 return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh->pad,
366 fie); 366 fie);
367 } 367 }
368 368
@@ -374,7 +374,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
374 return rval; 374 return rval;
375 375
376 return v4l2_subdev_call( 376 return v4l2_subdev_call(
377 sd, pad, get_selection, subdev_fh, sel); 377 sd, pad, get_selection, subdev_fh->pad, sel);
378 } 378 }
379 379
380 case VIDIOC_SUBDEV_S_SELECTION: { 380 case VIDIOC_SUBDEV_S_SELECTION: {
@@ -385,7 +385,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
385 return rval; 385 return rval;
386 386
387 return v4l2_subdev_call( 387 return v4l2_subdev_call(
388 sd, pad, set_selection, subdev_fh, sel); 388 sd, pad, set_selection, subdev_fh->pad, sel);
389 } 389 }
390 390
391 case VIDIOC_G_EDID: { 391 case VIDIOC_G_EDID: {
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index a425f71dfb97..715f1e6b8fe2 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -1414,17 +1414,17 @@ static int ipipe_set_stream(struct v4l2_subdev *sd, int enable)
1414 * __ipipe_get_format() - helper function for getting ipipe format 1414 * __ipipe_get_format() - helper function for getting ipipe format
1415 * @ipipe: pointer to ipipe private structure. 1415 * @ipipe: pointer to ipipe private structure.
1416 * @pad: pad number. 1416 * @pad: pad number.
1417 * @fh: V4L2 subdev file handle. 1417 * @cfg: V4L2 subdev pad config
1418 * @which: wanted subdev format. 1418 * @which: wanted subdev format.
1419 * 1419 *
1420 */ 1420 */
1421static struct v4l2_mbus_framefmt * 1421static struct v4l2_mbus_framefmt *
1422__ipipe_get_format(struct vpfe_ipipe_device *ipipe, 1422__ipipe_get_format(struct vpfe_ipipe_device *ipipe,
1423 struct v4l2_subdev_fh *fh, unsigned int pad, 1423 struct v4l2_subdev_pad_config *cfg, unsigned int pad,
1424 enum v4l2_subdev_format_whence which) 1424 enum v4l2_subdev_format_whence which)
1425{ 1425{
1426 if (which == V4L2_SUBDEV_FORMAT_TRY) 1426 if (which == V4L2_SUBDEV_FORMAT_TRY)
1427 return v4l2_subdev_get_try_format(fh, pad); 1427 return v4l2_subdev_get_try_format(&ipipe->subdev, cfg, pad);
1428 1428
1429 return &ipipe->formats[pad]; 1429 return &ipipe->formats[pad];
1430} 1430}
@@ -1432,14 +1432,14 @@ __ipipe_get_format(struct vpfe_ipipe_device *ipipe,
1432/* 1432/*
1433 * ipipe_try_format() - Handle try format by pad subdev method 1433 * ipipe_try_format() - Handle try format by pad subdev method
1434 * @ipipe: VPFE ipipe device. 1434 * @ipipe: VPFE ipipe device.
1435 * @fh: V4L2 subdev file handle. 1435 * @cfg: V4L2 subdev pad config
1436 * @pad: pad num. 1436 * @pad: pad num.
1437 * @fmt: pointer to v4l2 format structure. 1437 * @fmt: pointer to v4l2 format structure.
1438 * @which : wanted subdev format 1438 * @which : wanted subdev format
1439 */ 1439 */
1440static void 1440static void
1441ipipe_try_format(struct vpfe_ipipe_device *ipipe, 1441ipipe_try_format(struct vpfe_ipipe_device *ipipe,
1442 struct v4l2_subdev_fh *fh, unsigned int pad, 1442 struct v4l2_subdev_pad_config *cfg, unsigned int pad,
1443 struct v4l2_mbus_framefmt *fmt, 1443 struct v4l2_mbus_framefmt *fmt,
1444 enum v4l2_subdev_format_whence which) 1444 enum v4l2_subdev_format_whence which)
1445{ 1445{
@@ -1475,22 +1475,22 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe,
1475/* 1475/*
1476 * ipipe_set_format() - Handle set format by pads subdev method 1476 * ipipe_set_format() - Handle set format by pads subdev method
1477 * @sd: pointer to v4l2 subdev structure 1477 * @sd: pointer to v4l2 subdev structure
1478 * @fh: V4L2 subdev file handle 1478 * @cfg: V4L2 subdev pad config
1479 * @fmt: pointer to v4l2 subdev format structure 1479 * @fmt: pointer to v4l2 subdev format structure
1480 * return -EINVAL or zero on success 1480 * return -EINVAL or zero on success
1481 */ 1481 */
1482static int 1482static int
1483ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1483ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1484 struct v4l2_subdev_format *fmt) 1484 struct v4l2_subdev_format *fmt)
1485{ 1485{
1486 struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd); 1486 struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
1487 struct v4l2_mbus_framefmt *format; 1487 struct v4l2_mbus_framefmt *format;
1488 1488
1489 format = __ipipe_get_format(ipipe, fh, fmt->pad, fmt->which); 1489 format = __ipipe_get_format(ipipe, cfg, fmt->pad, fmt->which);
1490 if (format == NULL) 1490 if (format == NULL)
1491 return -EINVAL; 1491 return -EINVAL;
1492 1492
1493 ipipe_try_format(ipipe, fh, fmt->pad, &fmt->format, fmt->which); 1493 ipipe_try_format(ipipe, cfg, fmt->pad, &fmt->format, fmt->which);
1494 *format = fmt->format; 1494 *format = fmt->format;
1495 1495
1496 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) 1496 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
@@ -1512,11 +1512,11 @@ ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1512/* 1512/*
1513 * ipipe_get_format() - Handle get format by pads subdev method. 1513 * ipipe_get_format() - Handle get format by pads subdev method.
1514 * @sd: pointer to v4l2 subdev structure. 1514 * @sd: pointer to v4l2 subdev structure.
1515 * @fh: V4L2 subdev file handle. 1515 * @cfg: V4L2 subdev pad config
1516 * @fmt: pointer to v4l2 subdev format structure. 1516 * @fmt: pointer to v4l2 subdev format structure.
1517 */ 1517 */
1518static int 1518static int
1519ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1519ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1520 struct v4l2_subdev_format *fmt) 1520 struct v4l2_subdev_format *fmt)
1521{ 1521{
1522 struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd); 1522 struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
@@ -1524,7 +1524,7 @@ ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1524 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) 1524 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE)
1525 fmt->format = ipipe->formats[fmt->pad]; 1525 fmt->format = ipipe->formats[fmt->pad];
1526 else 1526 else
1527 fmt->format = *(v4l2_subdev_get_try_format(fh, fmt->pad)); 1527 fmt->format = *(v4l2_subdev_get_try_format(sd, cfg, fmt->pad));
1528 1528
1529 return 0; 1529 return 0;
1530} 1530}
@@ -1532,11 +1532,11 @@ ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1532/* 1532/*
1533 * ipipe_enum_frame_size() - enum frame sizes on pads 1533 * ipipe_enum_frame_size() - enum frame sizes on pads
1534 * @sd: pointer to v4l2 subdev structure. 1534 * @sd: pointer to v4l2 subdev structure.
1535 * @fh: V4L2 subdev file handle. 1535 * @cfg: V4L2 subdev pad config
1536 * @fse: pointer to v4l2_subdev_frame_size_enum structure. 1536 * @fse: pointer to v4l2_subdev_frame_size_enum structure.
1537 */ 1537 */
1538static int 1538static int
1539ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1539ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1540 struct v4l2_subdev_frame_size_enum *fse) 1540 struct v4l2_subdev_frame_size_enum *fse)
1541{ 1541{
1542 struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd); 1542 struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
@@ -1548,7 +1548,7 @@ ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1548 format.code = fse->code; 1548 format.code = fse->code;
1549 format.width = 1; 1549 format.width = 1;
1550 format.height = 1; 1550 format.height = 1;
1551 ipipe_try_format(ipipe, fh, fse->pad, &format, 1551 ipipe_try_format(ipipe, cfg, fse->pad, &format,
1552 V4L2_SUBDEV_FORMAT_TRY); 1552 V4L2_SUBDEV_FORMAT_TRY);
1553 fse->min_width = format.width; 1553 fse->min_width = format.width;
1554 fse->min_height = format.height; 1554 fse->min_height = format.height;
@@ -1559,7 +1559,7 @@ ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1559 format.code = fse->code; 1559 format.code = fse->code;
1560 format.width = -1; 1560 format.width = -1;
1561 format.height = -1; 1561 format.height = -1;
1562 ipipe_try_format(ipipe, fh, fse->pad, &format, 1562 ipipe_try_format(ipipe, cfg, fse->pad, &format,
1563 V4L2_SUBDEV_FORMAT_TRY); 1563 V4L2_SUBDEV_FORMAT_TRY);
1564 fse->max_width = format.width; 1564 fse->max_width = format.width;
1565 fse->max_height = format.height; 1565 fse->max_height = format.height;
@@ -1570,11 +1570,11 @@ ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1570/* 1570/*
1571 * ipipe_enum_mbus_code() - enum mbus codes for pads 1571 * ipipe_enum_mbus_code() - enum mbus codes for pads
1572 * @sd: pointer to v4l2 subdev structure. 1572 * @sd: pointer to v4l2 subdev structure.
1573 * @fh: V4L2 subdev file handle 1573 * @cfg: V4L2 subdev pad config
1574 * @code: pointer to v4l2_subdev_mbus_code_enum structure 1574 * @code: pointer to v4l2_subdev_mbus_code_enum structure
1575 */ 1575 */
1576static int 1576static int
1577ipipe_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1577ipipe_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1578 struct v4l2_subdev_mbus_code_enum *code) 1578 struct v4l2_subdev_mbus_code_enum *code)
1579{ 1579{
1580 switch (code->pad) { 1580 switch (code->pad) {
@@ -1630,9 +1630,8 @@ static int ipipe_s_ctrl(struct v4l2_ctrl *ctrl)
1630 * @sd: pointer to v4l2 subdev structure. 1630 * @sd: pointer to v4l2 subdev structure.
1631 * @fh: V4L2 subdev file handle 1631 * @fh: V4L2 subdev file handle
1632 * 1632 *
1633 * Initialize all pad formats with default values. If fh is not NULL, try 1633 * Initialize all pad formats with default values. Try formats are initialized
1634 * formats are initialized on the file handle. Otherwise active formats are 1634 * on the file handle.
1635 * initialized on the device.
1636 */ 1635 */
1637static int 1636static int
1638ipipe_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) 1637ipipe_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
@@ -1641,19 +1640,19 @@ ipipe_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1641 1640
1642 memset(&format, 0, sizeof(format)); 1641 memset(&format, 0, sizeof(format));
1643 format.pad = IPIPE_PAD_SINK; 1642 format.pad = IPIPE_PAD_SINK;
1644 format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; 1643 format.which = V4L2_SUBDEV_FORMAT_TRY;
1645 format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12; 1644 format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
1646 format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A; 1645 format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
1647 format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A; 1646 format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
1648 ipipe_set_format(sd, fh, &format); 1647 ipipe_set_format(sd, fh->pad, &format);
1649 1648
1650 memset(&format, 0, sizeof(format)); 1649 memset(&format, 0, sizeof(format));
1651 format.pad = IPIPE_PAD_SOURCE; 1650 format.pad = IPIPE_PAD_SOURCE;
1652 format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; 1651 format.which = V4L2_SUBDEV_FORMAT_TRY;
1653 format.format.code = MEDIA_BUS_FMT_UYVY8_2X8; 1652 format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
1654 format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A; 1653 format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
1655 format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A; 1654 format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
1656 ipipe_set_format(sd, fh, &format); 1655 ipipe_set_format(sd, fh->pad, &format);
1657 1656
1658 return 0; 1657 return 0;
1659} 1658}
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
index 87d42e18377d..68a9bb04922a 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
@@ -544,12 +544,12 @@ static int ipipeif_set_stream(struct v4l2_subdev *sd, int enable)
544/* 544/*
545 * ipipeif_enum_mbus_code() - Handle pixel format enumeration 545 * ipipeif_enum_mbus_code() - Handle pixel format enumeration
546 * @sd: pointer to v4l2 subdev structure 546 * @sd: pointer to v4l2 subdev structure
547 * @fh: V4L2 subdev file handle 547 * @cfg: V4L2 subdev pad config
548 * @code: pointer to v4l2_subdev_mbus_code_enum structure 548 * @code: pointer to v4l2_subdev_mbus_code_enum structure
549 * return -EINVAL or zero on success 549 * return -EINVAL or zero on success
550 */ 550 */
551static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd, 551static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd,
552 struct v4l2_subdev_fh *fh, 552 struct v4l2_subdev_pad_config *cfg,
553 struct v4l2_subdev_mbus_code_enum *code) 553 struct v4l2_subdev_mbus_code_enum *code)
554{ 554{
555 switch (code->pad) { 555 switch (code->pad) {
@@ -577,11 +577,11 @@ static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd,
577/* 577/*
578 * ipipeif_get_format() - Handle get format by pads subdev method 578 * ipipeif_get_format() - Handle get format by pads subdev method
579 * @sd: pointer to v4l2 subdev structure 579 * @sd: pointer to v4l2 subdev structure
580 * @fh: V4L2 subdev file handle 580 * @cfg: V4L2 subdev pad config
581 * @fmt: pointer to v4l2 subdev format structure 581 * @fmt: pointer to v4l2 subdev format structure
582 */ 582 */
583static int 583static int
584ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 584ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
585 struct v4l2_subdev_format *fmt) 585 struct v4l2_subdev_format *fmt)
586{ 586{
587 struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); 587 struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
@@ -589,7 +589,7 @@ ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
589 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) 589 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE)
590 fmt->format = ipipeif->formats[fmt->pad]; 590 fmt->format = ipipeif->formats[fmt->pad];
591 else 591 else
592 fmt->format = *(v4l2_subdev_get_try_format(fh, fmt->pad)); 592 fmt->format = *(v4l2_subdev_get_try_format(sd, cfg, fmt->pad));
593 593
594 return 0; 594 return 0;
595} 595}
@@ -600,14 +600,14 @@ ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
600/* 600/*
601 * ipipeif_try_format() - Handle try format by pad subdev method 601 * ipipeif_try_format() - Handle try format by pad subdev method
602 * @ipipeif: VPFE ipipeif device. 602 * @ipipeif: VPFE ipipeif device.
603 * @fh: V4L2 subdev file handle. 603 * @cfg: V4L2 subdev pad config
604 * @pad: pad num. 604 * @pad: pad num.
605 * @fmt: pointer to v4l2 format structure. 605 * @fmt: pointer to v4l2 format structure.
606 * @which : wanted subdev format 606 * @which : wanted subdev format
607 */ 607 */
608static void 608static void
609ipipeif_try_format(struct vpfe_ipipeif_device *ipipeif, 609ipipeif_try_format(struct vpfe_ipipeif_device *ipipeif,
610 struct v4l2_subdev_fh *fh, unsigned int pad, 610 struct v4l2_subdev_pad_config *cfg, unsigned int pad,
611 struct v4l2_mbus_framefmt *fmt, 611 struct v4l2_mbus_framefmt *fmt,
612 enum v4l2_subdev_format_whence which) 612 enum v4l2_subdev_format_whence which)
613{ 613{
@@ -641,7 +641,7 @@ ipipeif_try_format(struct vpfe_ipipeif_device *ipipeif,
641} 641}
642 642
643static int 643static int
644ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 644ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
645 struct v4l2_subdev_frame_size_enum *fse) 645 struct v4l2_subdev_frame_size_enum *fse)
646{ 646{
647 struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); 647 struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
@@ -653,7 +653,7 @@ ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
653 format.code = fse->code; 653 format.code = fse->code;
654 format.width = 1; 654 format.width = 1;
655 format.height = 1; 655 format.height = 1;
656 ipipeif_try_format(ipipeif, fh, fse->pad, &format, 656 ipipeif_try_format(ipipeif, cfg, fse->pad, &format,
657 V4L2_SUBDEV_FORMAT_TRY); 657 V4L2_SUBDEV_FORMAT_TRY);
658 fse->min_width = format.width; 658 fse->min_width = format.width;
659 fse->min_height = format.height; 659 fse->min_height = format.height;
@@ -664,7 +664,7 @@ ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
664 format.code = fse->code; 664 format.code = fse->code;
665 format.width = -1; 665 format.width = -1;
666 format.height = -1; 666 format.height = -1;
667 ipipeif_try_format(ipipeif, fh, fse->pad, &format, 667 ipipeif_try_format(ipipeif, cfg, fse->pad, &format,
668 V4L2_SUBDEV_FORMAT_TRY); 668 V4L2_SUBDEV_FORMAT_TRY);
669 fse->max_width = format.width; 669 fse->max_width = format.width;
670 fse->max_height = format.height; 670 fse->max_height = format.height;
@@ -675,18 +675,18 @@ ipipeif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
675/* 675/*
676 * __ipipeif_get_format() - helper function for getting ipipeif format 676 * __ipipeif_get_format() - helper function for getting ipipeif format
677 * @ipipeif: pointer to ipipeif private structure. 677 * @ipipeif: pointer to ipipeif private structure.
678 * @cfg: V4L2 subdev pad config
678 * @pad: pad number. 679 * @pad: pad number.
679 * @fh: V4L2 subdev file handle.
680 * @which: wanted subdev format. 680 * @which: wanted subdev format.
681 * 681 *
682 */ 682 */
683static struct v4l2_mbus_framefmt * 683static struct v4l2_mbus_framefmt *
684__ipipeif_get_format(struct vpfe_ipipeif_device *ipipeif, 684__ipipeif_get_format(struct vpfe_ipipeif_device *ipipeif,
685 struct v4l2_subdev_fh *fh, unsigned int pad, 685 struct v4l2_subdev_pad_config *cfg, unsigned int pad,
686 enum v4l2_subdev_format_whence which) 686 enum v4l2_subdev_format_whence which)
687{ 687{
688 if (which == V4L2_SUBDEV_FORMAT_TRY) 688 if (which == V4L2_SUBDEV_FORMAT_TRY)
689 return v4l2_subdev_get_try_format(fh, pad); 689 return v4l2_subdev_get_try_format(&ipipeif->subdev, cfg, pad);
690 690
691 return &ipipeif->formats[pad]; 691 return &ipipeif->formats[pad];
692} 692}
@@ -694,22 +694,22 @@ __ipipeif_get_format(struct vpfe_ipipeif_device *ipipeif,
694/* 694/*
695 * ipipeif_set_format() - Handle set format by pads subdev method 695 * ipipeif_set_format() - Handle set format by pads subdev method
696 * @sd: pointer to v4l2 subdev structure 696 * @sd: pointer to v4l2 subdev structure
697 * @fh: V4L2 subdev file handle 697 * @cfg: V4L2 subdev pad config
698 * @fmt: pointer to v4l2 subdev format structure 698 * @fmt: pointer to v4l2 subdev format structure
699 * return -EINVAL or zero on success 699 * return -EINVAL or zero on success
700 */ 700 */
701static int 701static int
702ipipeif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 702ipipeif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
703 struct v4l2_subdev_format *fmt) 703 struct v4l2_subdev_format *fmt)
704{ 704{
705 struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); 705 struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
706 struct v4l2_mbus_framefmt *format; 706 struct v4l2_mbus_framefmt *format;
707 707
708 format = __ipipeif_get_format(ipipeif, fh, fmt->pad, fmt->which); 708 format = __ipipeif_get_format(ipipeif, cfg, fmt->pad, fmt->which);
709 if (format == NULL) 709 if (format == NULL)
710 return -EINVAL; 710 return -EINVAL;
711 711
712 ipipeif_try_format(ipipeif, fh, fmt->pad, &fmt->format, fmt->which); 712 ipipeif_try_format(ipipeif, cfg, fmt->pad, &fmt->format, fmt->which);
713 *format = fmt->format; 713 *format = fmt->format;
714 714
715 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) 715 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
@@ -757,9 +757,8 @@ static void ipipeif_set_default_config(struct vpfe_ipipeif_device *ipipeif)
757 * @sd: VPFE ipipeif V4L2 subdevice 757 * @sd: VPFE ipipeif V4L2 subdevice
758 * @fh: V4L2 subdev file handle 758 * @fh: V4L2 subdev file handle
759 * 759 *
760 * Initialize all pad formats with default values. If fh is not NULL, try 760 * Initialize all pad formats with default values. Try formats are initialized
761 * formats are initialized on the file handle. Otherwise active formats are 761 * on the file handle.
762 * initialized on the device.
763 */ 762 */
764static int 763static int
765ipipeif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) 764ipipeif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
@@ -769,19 +768,19 @@ ipipeif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
769 768
770 memset(&format, 0, sizeof(format)); 769 memset(&format, 0, sizeof(format));
771 format.pad = IPIPEIF_PAD_SINK; 770 format.pad = IPIPEIF_PAD_SINK;
772 format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; 771 format.which = V4L2_SUBDEV_FORMAT_TRY;
773 format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12; 772 format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
774 format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A; 773 format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
775 format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A; 774 format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
776 ipipeif_set_format(sd, fh, &format); 775 ipipeif_set_format(sd, fh->pad, &format);
777 776
778 memset(&format, 0, sizeof(format)); 777 memset(&format, 0, sizeof(format));
779 format.pad = IPIPEIF_PAD_SOURCE; 778 format.pad = IPIPEIF_PAD_SOURCE;
780 format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; 779 format.which = V4L2_SUBDEV_FORMAT_TRY;
781 format.format.code = MEDIA_BUS_FMT_UYVY8_2X8; 780 format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
782 format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A; 781 format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
783 format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A; 782 format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
784 ipipeif_set_format(sd, fh, &format); 783 ipipeif_set_format(sd, fh->pad, &format);
785 784
786 ipipeif_set_default_config(ipipeif); 785 ipipeif_set_default_config(ipipeif);
787 786
diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c
index bcf762bc233d..02b6bdc0d771 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_isif.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c
@@ -278,11 +278,11 @@ isif_config_format(struct vpfe_device *vpfe_dev, unsigned int pad)
278/* 278/*
279 * isif_try_format() - Try video format on a pad 279 * isif_try_format() - Try video format on a pad
280 * @isif: VPFE isif device 280 * @isif: VPFE isif device
281 * @fh: V4L2 subdev file handle 281 * @cfg: V4L2 subdev pad config
282 * @fmt: pointer to v4l2 subdev format structure 282 * @fmt: pointer to v4l2 subdev format structure
283 */ 283 */
284static void 284static void
285isif_try_format(struct vpfe_isif_device *isif, struct v4l2_subdev_fh *fh, 285isif_try_format(struct vpfe_isif_device *isif, struct v4l2_subdev_pad_config *cfg,
286 struct v4l2_subdev_format *fmt) 286 struct v4l2_subdev_format *fmt)
287{ 287{
288 unsigned int width = fmt->format.width; 288 unsigned int width = fmt->format.width;
@@ -1394,11 +1394,11 @@ static int isif_set_stream(struct v4l2_subdev *sd, int enable)
1394 * __isif_get_format() - helper function for getting isif format 1394 * __isif_get_format() - helper function for getting isif format
1395 * @isif: pointer to isif private structure. 1395 * @isif: pointer to isif private structure.
1396 * @pad: pad number. 1396 * @pad: pad number.
1397 * @fh: V4L2 subdev file handle. 1397 * @cfg: V4L2 subdev pad config
1398 * @which: wanted subdev format. 1398 * @which: wanted subdev format.
1399 */ 1399 */
1400static struct v4l2_mbus_framefmt * 1400static struct v4l2_mbus_framefmt *
1401__isif_get_format(struct vpfe_isif_device *isif, struct v4l2_subdev_fh *fh, 1401__isif_get_format(struct vpfe_isif_device *isif, struct v4l2_subdev_pad_config *cfg,
1402 unsigned int pad, enum v4l2_subdev_format_whence which) 1402 unsigned int pad, enum v4l2_subdev_format_whence which)
1403{ 1403{
1404 if (which == V4L2_SUBDEV_FORMAT_TRY) { 1404 if (which == V4L2_SUBDEV_FORMAT_TRY) {
@@ -1407,32 +1407,32 @@ __isif_get_format(struct vpfe_isif_device *isif, struct v4l2_subdev_fh *fh,
1407 fmt.pad = pad; 1407 fmt.pad = pad;
1408 fmt.which = which; 1408 fmt.which = which;
1409 1409
1410 return v4l2_subdev_get_try_format(fh, pad); 1410 return v4l2_subdev_get_try_format(&isif->subdev, cfg, pad);
1411 } 1411 }
1412 return &isif->formats[pad]; 1412 return &isif->formats[pad];
1413} 1413}
1414 1414
1415/* 1415/*
1416* isif_set_format() - set format on pad 1416 * isif_set_format() - set format on pad
1417* @sd : VPFE ISIF device 1417 * @sd : VPFE ISIF device
1418* @fh : V4L2 subdev file handle 1418 * @cfg : V4L2 subdev pad config
1419* @fmt : pointer to v4l2 subdev format structure 1419 * @fmt : pointer to v4l2 subdev format structure
1420* 1420 *
1421* Return 0 on success or -EINVAL if format or pad is invalid 1421 * Return 0 on success or -EINVAL if format or pad is invalid
1422*/ 1422 */
1423static int 1423static int
1424isif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1424isif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1425 struct v4l2_subdev_format *fmt) 1425 struct v4l2_subdev_format *fmt)
1426{ 1426{
1427 struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd); 1427 struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd);
1428 struct vpfe_device *vpfe_dev = to_vpfe_device(isif); 1428 struct vpfe_device *vpfe_dev = to_vpfe_device(isif);
1429 struct v4l2_mbus_framefmt *format; 1429 struct v4l2_mbus_framefmt *format;
1430 1430
1431 format = __isif_get_format(isif, fh, fmt->pad, fmt->which); 1431 format = __isif_get_format(isif, cfg, fmt->pad, fmt->which);
1432 if (format == NULL) 1432 if (format == NULL)
1433 return -EINVAL; 1433 return -EINVAL;
1434 1434
1435 isif_try_format(isif, fh, fmt); 1435 isif_try_format(isif, cfg, fmt);
1436 memcpy(format, &fmt->format, sizeof(*format)); 1436 memcpy(format, &fmt->format, sizeof(*format));
1437 1437
1438 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) 1438 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
@@ -1447,20 +1447,20 @@ isif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1447/* 1447/*
1448 * isif_get_format() - Retrieve the video format on a pad 1448 * isif_get_format() - Retrieve the video format on a pad
1449 * @sd: VPFE ISIF V4L2 subdevice 1449 * @sd: VPFE ISIF V4L2 subdevice
1450 * @fh: V4L2 subdev file handle 1450 * @cfg: V4L2 subdev pad config
1451 * @fmt: pointer to v4l2 subdev format structure 1451 * @fmt: pointer to v4l2 subdev format structure
1452 * 1452 *
1453 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond 1453 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
1454 * to the format type. 1454 * to the format type.
1455 */ 1455 */
1456static int 1456static int
1457isif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1457isif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1458 struct v4l2_subdev_format *fmt) 1458 struct v4l2_subdev_format *fmt)
1459{ 1459{
1460 struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd); 1460 struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd);
1461 struct v4l2_mbus_framefmt *format; 1461 struct v4l2_mbus_framefmt *format;
1462 1462
1463 format = __isif_get_format(vpfe_isif, fh, fmt->pad, fmt->which); 1463 format = __isif_get_format(vpfe_isif, cfg, fmt->pad, fmt->which);
1464 if (format == NULL) 1464 if (format == NULL)
1465 return -EINVAL; 1465 return -EINVAL;
1466 1466
@@ -1472,11 +1472,11 @@ isif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1472/* 1472/*
1473 * isif_enum_frame_size() - enum frame sizes on pads 1473 * isif_enum_frame_size() - enum frame sizes on pads
1474 * @sd: VPFE isif V4L2 subdevice 1474 * @sd: VPFE isif V4L2 subdevice
1475 * @fh: V4L2 subdev file handle 1475 * @cfg: V4L2 subdev pad config
1476 * @code: pointer to v4l2_subdev_frame_size_enum structure 1476 * @code: pointer to v4l2_subdev_frame_size_enum structure
1477 */ 1477 */
1478static int 1478static int
1479isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1479isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1480 struct v4l2_subdev_frame_size_enum *fse) 1480 struct v4l2_subdev_frame_size_enum *fse)
1481{ 1481{
1482 struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd); 1482 struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd);
@@ -1490,7 +1490,7 @@ isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1490 format.format.width = 1; 1490 format.format.width = 1;
1491 format.format.height = 1; 1491 format.format.height = 1;
1492 format.which = V4L2_SUBDEV_FORMAT_TRY; 1492 format.which = V4L2_SUBDEV_FORMAT_TRY;
1493 isif_try_format(isif, fh, &format); 1493 isif_try_format(isif, cfg, &format);
1494 fse->min_width = format.format.width; 1494 fse->min_width = format.format.width;
1495 fse->min_height = format.format.height; 1495 fse->min_height = format.format.height;
1496 1496
@@ -1502,7 +1502,7 @@ isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1502 format.format.width = -1; 1502 format.format.width = -1;
1503 format.format.height = -1; 1503 format.format.height = -1;
1504 format.which = V4L2_SUBDEV_FORMAT_TRY; 1504 format.which = V4L2_SUBDEV_FORMAT_TRY;
1505 isif_try_format(isif, fh, &format); 1505 isif_try_format(isif, cfg, &format);
1506 fse->max_width = format.format.width; 1506 fse->max_width = format.format.width;
1507 fse->max_height = format.format.height; 1507 fse->max_height = format.format.height;
1508 1508
@@ -1512,11 +1512,11 @@ isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1512/* 1512/*
1513 * isif_enum_mbus_code() - enum mbus codes for pads 1513 * isif_enum_mbus_code() - enum mbus codes for pads
1514 * @sd: VPFE isif V4L2 subdevice 1514 * @sd: VPFE isif V4L2 subdevice
1515 * @fh: V4L2 subdev file handle 1515 * @cfg: V4L2 subdev pad config
1516 * @code: pointer to v4l2_subdev_mbus_code_enum structure 1516 * @code: pointer to v4l2_subdev_mbus_code_enum structure
1517 */ 1517 */
1518static int 1518static int
1519isif_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1519isif_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1520 struct v4l2_subdev_mbus_code_enum *code) 1520 struct v4l2_subdev_mbus_code_enum *code)
1521{ 1521{
1522 switch (code->pad) { 1522 switch (code->pad) {
@@ -1537,14 +1537,14 @@ isif_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1537/* 1537/*
1538 * isif_pad_set_selection() - set crop rectangle on pad 1538 * isif_pad_set_selection() - set crop rectangle on pad
1539 * @sd: VPFE isif V4L2 subdevice 1539 * @sd: VPFE isif V4L2 subdevice
1540 * @fh: V4L2 subdev file handle 1540 * @cfg: V4L2 subdev pad config
1541 * @code: pointer to v4l2_subdev_mbus_code_enum structure 1541 * @code: pointer to v4l2_subdev_mbus_code_enum structure
1542 * 1542 *
1543 * Return 0 on success, -EINVAL if pad is invalid 1543 * Return 0 on success, -EINVAL if pad is invalid
1544 */ 1544 */
1545static int 1545static int
1546isif_pad_set_selection(struct v4l2_subdev *sd, 1546isif_pad_set_selection(struct v4l2_subdev *sd,
1547 struct v4l2_subdev_fh *fh, 1547 struct v4l2_subdev_pad_config *cfg,
1548 struct v4l2_subdev_selection *sel) 1548 struct v4l2_subdev_selection *sel)
1549{ 1549{
1550 struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd); 1550 struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd);
@@ -1554,7 +1554,7 @@ isif_pad_set_selection(struct v4l2_subdev *sd,
1554 if (sel->pad != ISIF_PAD_SINK || sel->target != V4L2_SEL_TGT_CROP) 1554 if (sel->pad != ISIF_PAD_SINK || sel->target != V4L2_SEL_TGT_CROP)
1555 return -EINVAL; 1555 return -EINVAL;
1556 1556
1557 format = __isif_get_format(vpfe_isif, fh, sel->pad, sel->which); 1557 format = __isif_get_format(vpfe_isif, cfg, sel->pad, sel->which);
1558 if (format == NULL) 1558 if (format == NULL)
1559 return -EINVAL; 1559 return -EINVAL;
1560 1560
@@ -1577,7 +1577,7 @@ isif_pad_set_selection(struct v4l2_subdev *sd,
1577 } else { 1577 } else {
1578 struct v4l2_rect *rect; 1578 struct v4l2_rect *rect;
1579 1579
1580 rect = v4l2_subdev_get_try_crop(fh, ISIF_PAD_SINK); 1580 rect = v4l2_subdev_get_try_crop(sd, cfg, ISIF_PAD_SINK);
1581 memcpy(rect, &vpfe_isif->crop, sizeof(*rect)); 1581 memcpy(rect, &vpfe_isif->crop, sizeof(*rect));
1582 } 1582 }
1583 return 0; 1583 return 0;
@@ -1586,14 +1586,14 @@ isif_pad_set_selection(struct v4l2_subdev *sd,
1586/* 1586/*
1587 * isif_pad_get_selection() - get crop rectangle on pad 1587 * isif_pad_get_selection() - get crop rectangle on pad
1588 * @sd: VPFE isif V4L2 subdevice 1588 * @sd: VPFE isif V4L2 subdevice
1589 * @fh: V4L2 subdev file handle 1589 * @cfg: V4L2 subdev pad config
1590 * @code: pointer to v4l2_subdev_mbus_code_enum structure 1590 * @code: pointer to v4l2_subdev_mbus_code_enum structure
1591 * 1591 *
1592 * Return 0 on success, -EINVAL if pad is invalid 1592 * Return 0 on success, -EINVAL if pad is invalid
1593 */ 1593 */
1594static int 1594static int
1595isif_pad_get_selection(struct v4l2_subdev *sd, 1595isif_pad_get_selection(struct v4l2_subdev *sd,
1596 struct v4l2_subdev_fh *fh, 1596 struct v4l2_subdev_pad_config *cfg,
1597 struct v4l2_subdev_selection *sel) 1597 struct v4l2_subdev_selection *sel)
1598{ 1598{
1599 struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd); 1599 struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd);
@@ -1605,7 +1605,7 @@ isif_pad_get_selection(struct v4l2_subdev *sd,
1605 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { 1605 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
1606 struct v4l2_rect *rect; 1606 struct v4l2_rect *rect;
1607 1607
1608 rect = v4l2_subdev_get_try_crop(fh, ISIF_PAD_SINK); 1608 rect = v4l2_subdev_get_try_crop(sd, cfg, ISIF_PAD_SINK);
1609 memcpy(&sel->r, rect, sizeof(*rect)); 1609 memcpy(&sel->r, rect, sizeof(*rect));
1610 } else { 1610 } else {
1611 sel->r = vpfe_isif->crop; 1611 sel->r = vpfe_isif->crop;
@@ -1619,9 +1619,8 @@ isif_pad_get_selection(struct v4l2_subdev *sd,
1619 * @sd: VPFE isif V4L2 subdevice 1619 * @sd: VPFE isif V4L2 subdevice
1620 * @fh: V4L2 subdev file handle 1620 * @fh: V4L2 subdev file handle
1621 * 1621 *
1622 * Initialize all pad formats with default values. If fh is not NULL, try 1622 * Initialize all pad formats with default values. Try formats are initialized
1623 * formats are initialized on the file handle. Otherwise active formats are 1623 * on the file handle.
1624 * initialized on the device.
1625 */ 1624 */
1626static int 1625static int
1627isif_init_formats(struct v4l2_subdev *sd, 1626isif_init_formats(struct v4l2_subdev *sd,
@@ -1632,27 +1631,27 @@ isif_init_formats(struct v4l2_subdev *sd,
1632 1631
1633 memset(&format, 0, sizeof(format)); 1632 memset(&format, 0, sizeof(format));
1634 format.pad = ISIF_PAD_SINK; 1633 format.pad = ISIF_PAD_SINK;
1635 format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; 1634 format.which = V4L2_SUBDEV_FORMAT_TRY;
1636 format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12; 1635 format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
1637 format.format.width = MAX_WIDTH; 1636 format.format.width = MAX_WIDTH;
1638 format.format.height = MAX_HEIGHT; 1637 format.format.height = MAX_HEIGHT;
1639 isif_set_format(sd, fh, &format); 1638 isif_set_format(sd, fh->pad, &format);
1640 1639
1641 memset(&format, 0, sizeof(format)); 1640 memset(&format, 0, sizeof(format));
1642 format.pad = ISIF_PAD_SOURCE; 1641 format.pad = ISIF_PAD_SOURCE;
1643 format.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; 1642 format.which = V4L2_SUBDEV_FORMAT_TRY;
1644 format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12; 1643 format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
1645 format.format.width = MAX_WIDTH; 1644 format.format.width = MAX_WIDTH;
1646 format.format.height = MAX_HEIGHT; 1645 format.format.height = MAX_HEIGHT;
1647 isif_set_format(sd, fh, &format); 1646 isif_set_format(sd, fh->pad, &format);
1648 1647
1649 memset(&sel, 0, sizeof(sel)); 1648 memset(&sel, 0, sizeof(sel));
1650 sel.pad = ISIF_PAD_SINK; 1649 sel.pad = ISIF_PAD_SINK;
1651 sel.which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; 1650 sel.which = V4L2_SUBDEV_FORMAT_TRY;
1652 sel.target = V4L2_SEL_TGT_CROP; 1651 sel.target = V4L2_SEL_TGT_CROP;
1653 sel.r.width = MAX_WIDTH; 1652 sel.r.width = MAX_WIDTH;
1654 sel.r.height = MAX_HEIGHT; 1653 sel.r.height = MAX_HEIGHT;
1655 isif_pad_set_selection(sd, fh, &sel); 1654 isif_pad_set_selection(sd, fh->pad, &sel);
1656 1655
1657 return 0; 1656 return 0;
1658} 1657}
diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
index 75e70e14b724..acd9cb56f0f3 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
@@ -1289,19 +1289,19 @@ static int resizer_set_stream(struct v4l2_subdev *sd, int enable)
1289/* 1289/*
1290 * __resizer_get_format() - helper function for getting resizer format 1290 * __resizer_get_format() - helper function for getting resizer format
1291 * @sd: pointer to subdev. 1291 * @sd: pointer to subdev.
1292 * @fh: V4L2 subdev file handle. 1292 * @cfg: V4L2 subdev pad config
1293 * @pad: pad number. 1293 * @pad: pad number.
1294 * @which: wanted subdev format. 1294 * @which: wanted subdev format.
1295 * Retun wanted mbus frame format. 1295 * Retun wanted mbus frame format.
1296 */ 1296 */
1297static struct v4l2_mbus_framefmt * 1297static struct v4l2_mbus_framefmt *
1298__resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1298__resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1299 unsigned int pad, enum v4l2_subdev_format_whence which) 1299 unsigned int pad, enum v4l2_subdev_format_whence which)
1300{ 1300{
1301 struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd); 1301 struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd);
1302 1302
1303 if (which == V4L2_SUBDEV_FORMAT_TRY) 1303 if (which == V4L2_SUBDEV_FORMAT_TRY)
1304 return v4l2_subdev_get_try_format(fh, pad); 1304 return v4l2_subdev_get_try_format(sd, cfg, pad);
1305 if (&resizer->crop_resizer.subdev == sd) 1305 if (&resizer->crop_resizer.subdev == sd)
1306 return &resizer->crop_resizer.formats[pad]; 1306 return &resizer->crop_resizer.formats[pad];
1307 if (&resizer->resizer_a.subdev == sd) 1307 if (&resizer->resizer_a.subdev == sd)
@@ -1314,13 +1314,13 @@ __resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1314/* 1314/*
1315 * resizer_try_format() - Handle try format by pad subdev method 1315 * resizer_try_format() - Handle try format by pad subdev method
1316 * @sd: pointer to subdev. 1316 * @sd: pointer to subdev.
1317 * @fh: V4L2 subdev file handle. 1317 * @cfg: V4L2 subdev pad config
1318 * @pad: pad num. 1318 * @pad: pad num.
1319 * @fmt: pointer to v4l2 format structure. 1319 * @fmt: pointer to v4l2 format structure.
1320 * @which: wanted subdev format. 1320 * @which: wanted subdev format.
1321 */ 1321 */
1322static void 1322static void
1323resizer_try_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1323resizer_try_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1324 unsigned int pad, struct v4l2_mbus_framefmt *fmt, 1324 unsigned int pad, struct v4l2_mbus_framefmt *fmt,
1325 enum v4l2_subdev_format_whence which) 1325 enum v4l2_subdev_format_whence which)
1326{ 1326{
@@ -1388,21 +1388,21 @@ resizer_try_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1388/* 1388/*
1389 * resizer_set_format() - Handle set format by pads subdev method 1389 * resizer_set_format() - Handle set format by pads subdev method
1390 * @sd: pointer to v4l2 subdev structure 1390 * @sd: pointer to v4l2 subdev structure
1391 * @fh: V4L2 subdev file handle 1391 * @cfg: V4L2 subdev pad config
1392 * @fmt: pointer to v4l2 subdev format structure 1392 * @fmt: pointer to v4l2 subdev format structure
1393 * return -EINVAL or zero on success 1393 * return -EINVAL or zero on success
1394 */ 1394 */
1395static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1395static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1396 struct v4l2_subdev_format *fmt) 1396 struct v4l2_subdev_format *fmt)
1397{ 1397{
1398 struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd); 1398 struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd);
1399 struct v4l2_mbus_framefmt *format; 1399 struct v4l2_mbus_framefmt *format;
1400 1400
1401 format = __resizer_get_format(sd, fh, fmt->pad, fmt->which); 1401 format = __resizer_get_format(sd, cfg, fmt->pad, fmt->which);
1402 if (format == NULL) 1402 if (format == NULL)
1403 return -EINVAL; 1403 return -EINVAL;
1404 1404
1405 resizer_try_format(sd, fh, fmt->pad, &fmt->format, fmt->which); 1405 resizer_try_format(sd, cfg, fmt->pad, &fmt->format, fmt->which);
1406 *format = fmt->format; 1406 *format = fmt->format;
1407 1407
1408 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) 1408 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
@@ -1448,16 +1448,16 @@ static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1448/* 1448/*
1449 * resizer_get_format() - Retrieve the video format on a pad 1449 * resizer_get_format() - Retrieve the video format on a pad
1450 * @sd: pointer to v4l2 subdev structure. 1450 * @sd: pointer to v4l2 subdev structure.
1451 * @fh: V4L2 subdev file handle. 1451 * @cfg: V4L2 subdev pad config
1452 * @fmt: pointer to v4l2 subdev format structure 1452 * @fmt: pointer to v4l2 subdev format structure
1453 * return -EINVAL or zero on success 1453 * return -EINVAL or zero on success
1454 */ 1454 */
1455static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1455static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
1456 struct v4l2_subdev_format *fmt) 1456 struct v4l2_subdev_format *fmt)
1457{ 1457{
1458 struct v4l2_mbus_framefmt *format; 1458 struct v4l2_mbus_framefmt *format;
1459 1459
1460 format = __resizer_get_format(sd, fh, fmt->pad, fmt->which); 1460 format = __resizer_get_format(sd, cfg, fmt->pad, fmt->which);
1461 if (format == NULL) 1461 if (format == NULL)
1462 return -EINVAL; 1462 return -EINVAL;
1463 1463
@@ -1469,11 +1469,11 @@ static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
1469/* 1469/*
1470 * resizer_enum_frame_size() - enum frame sizes on pads 1470 * resizer_enum_frame_size() - enum frame sizes on pads
1471 * @sd: Pointer to subdevice. 1471 * @sd: Pointer to subdevice.
1472 * @fh: V4L2 subdev file handle. 1472 * @cfg: V4L2 subdev pad config
1473 * @code: pointer to v4l2_subdev_frame_size_enum structure. 1473 * @code: pointer to v4l2_subdev_frame_size_enum structure.
1474 */ 1474 */
1475static int resizer_enum_frame_size(struct v4l2_subdev *sd, 1475static int resizer_enum_frame_size(struct v4l2_subdev *sd,
1476 struct v4l2_subdev_fh *fh, 1476 struct v4l2_subdev_pad_config *cfg,
1477 struct v4l2_subdev_frame_size_enum *fse) 1477 struct v4l2_subdev_frame_size_enum *fse)
1478{ 1478{
1479 struct v4l2_mbus_framefmt format; 1479 struct v4l2_mbus_framefmt format;
@@ -1484,7 +1484,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
1484 format.code = fse->code; 1484 format.code = fse->code;
1485 format.width = 1; 1485 format.width = 1;
1486 format.height = 1; 1486 format.height = 1;
1487 resizer_try_format(sd, fh, fse->pad, &format, 1487 resizer_try_format(sd, cfg, fse->pad, &format,
1488 V4L2_SUBDEV_FORMAT_TRY); 1488 V4L2_SUBDEV_FORMAT_TRY);
1489 fse->min_width = format.width; 1489 fse->min_width = format.width;
1490 fse->min_height = format.height; 1490 fse->min_height = format.height;
@@ -1495,7 +1495,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
1495 format.code = fse->code; 1495 format.code = fse->code;
1496 format.width = -1; 1496 format.width = -1;
1497 format.height = -1; 1497 format.height = -1;
1498 resizer_try_format(sd, fh, fse->pad, &format, 1498 resizer_try_format(sd, cfg, fse->pad, &format,
1499 V4L2_SUBDEV_FORMAT_TRY); 1499 V4L2_SUBDEV_FORMAT_TRY);
1500 fse->max_width = format.width; 1500 fse->max_width = format.width;
1501 fse->max_height = format.height; 1501 fse->max_height = format.height;
@@ -1506,11 +1506,11 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
1506/* 1506/*
1507 * resizer_enum_mbus_code() - enum mbus codes for pads 1507 * resizer_enum_mbus_code() - enum mbus codes for pads
1508 * @sd: Pointer to subdevice. 1508 * @sd: Pointer to subdevice.
1509 * @fh: V4L2 subdev file handle 1509 * @cfg: V4L2 subdev pad config
1510 * @code: pointer to v4l2_subdev_mbus_code_enum structure 1510 * @code: pointer to v4l2_subdev_mbus_code_enum structure
1511 */ 1511 */
1512static int resizer_enum_mbus_code(struct v4l2_subdev *sd, 1512static int resizer_enum_mbus_code(struct v4l2_subdev *sd,
1513 struct v4l2_subdev_fh *fh, 1513 struct v4l2_subdev_pad_config *cfg,
1514 struct v4l2_subdev_mbus_code_enum *code) 1514 struct v4l2_subdev_mbus_code_enum *code)
1515{ 1515{
1516 if (code->pad == RESIZER_PAD_SINK) { 1516 if (code->pad == RESIZER_PAD_SINK) {
@@ -1533,14 +1533,13 @@ static int resizer_enum_mbus_code(struct v4l2_subdev *sd,
1533 * @sd: Pointer to subdevice. 1533 * @sd: Pointer to subdevice.
1534 * @fh: V4L2 subdev file handle. 1534 * @fh: V4L2 subdev file handle.
1535 * 1535 *
1536 * Initialize all pad formats with default values. If fh is not NULL, try 1536 * Initialize all pad formats with default values. Try formats are
1537 * formats are initialized on the file handle. Otherwise active formats are 1537 * initialized on the file handle.
1538 * initialized on the device.
1539 */ 1538 */
1540static int resizer_init_formats(struct v4l2_subdev *sd, 1539static int resizer_init_formats(struct v4l2_subdev *sd,
1541 struct v4l2_subdev_fh *fh) 1540 struct v4l2_subdev_fh *fh)
1542{ 1541{
1543 __u32 which = fh ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; 1542 __u32 which = V4L2_SUBDEV_FORMAT_TRY;
1544 struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd); 1543 struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd);
1545 struct v4l2_subdev_format format; 1544 struct v4l2_subdev_format format;
1546 1545
@@ -1551,7 +1550,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
1551 format.format.code = MEDIA_BUS_FMT_YUYV8_2X8; 1550 format.format.code = MEDIA_BUS_FMT_YUYV8_2X8;
1552 format.format.width = MAX_IN_WIDTH; 1551 format.format.width = MAX_IN_WIDTH;
1553 format.format.height = MAX_IN_HEIGHT; 1552 format.format.height = MAX_IN_HEIGHT;
1554 resizer_set_format(sd, fh, &format); 1553 resizer_set_format(sd, fh->pad, &format);
1555 1554
1556 memset(&format, 0, sizeof(format)); 1555 memset(&format, 0, sizeof(format));
1557 format.pad = RESIZER_CROP_PAD_SOURCE; 1556 format.pad = RESIZER_CROP_PAD_SOURCE;
@@ -1559,7 +1558,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
1559 format.format.code = MEDIA_BUS_FMT_UYVY8_2X8; 1558 format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
1560 format.format.width = MAX_IN_WIDTH; 1559 format.format.width = MAX_IN_WIDTH;
1561 format.format.height = MAX_IN_WIDTH; 1560 format.format.height = MAX_IN_WIDTH;
1562 resizer_set_format(sd, fh, &format); 1561 resizer_set_format(sd, fh->pad, &format);
1563 1562
1564 memset(&format, 0, sizeof(format)); 1563 memset(&format, 0, sizeof(format));
1565 format.pad = RESIZER_CROP_PAD_SOURCE2; 1564 format.pad = RESIZER_CROP_PAD_SOURCE2;
@@ -1567,7 +1566,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
1567 format.format.code = MEDIA_BUS_FMT_UYVY8_2X8; 1566 format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
1568 format.format.width = MAX_IN_WIDTH; 1567 format.format.width = MAX_IN_WIDTH;
1569 format.format.height = MAX_IN_WIDTH; 1568 format.format.height = MAX_IN_WIDTH;
1570 resizer_set_format(sd, fh, &format); 1569 resizer_set_format(sd, fh->pad, &format);
1571 } else if (&resizer->resizer_a.subdev == sd) { 1570 } else if (&resizer->resizer_a.subdev == sd) {
1572 memset(&format, 0, sizeof(format)); 1571 memset(&format, 0, sizeof(format));
1573 format.pad = RESIZER_PAD_SINK; 1572 format.pad = RESIZER_PAD_SINK;
@@ -1575,7 +1574,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
1575 format.format.code = MEDIA_BUS_FMT_YUYV8_2X8; 1574 format.format.code = MEDIA_BUS_FMT_YUYV8_2X8;
1576 format.format.width = MAX_IN_WIDTH; 1575 format.format.width = MAX_IN_WIDTH;
1577 format.format.height = MAX_IN_HEIGHT; 1576 format.format.height = MAX_IN_HEIGHT;
1578 resizer_set_format(sd, fh, &format); 1577 resizer_set_format(sd, fh->pad, &format);
1579 1578
1580 memset(&format, 0, sizeof(format)); 1579 memset(&format, 0, sizeof(format));
1581 format.pad = RESIZER_PAD_SOURCE; 1580 format.pad = RESIZER_PAD_SOURCE;
@@ -1583,7 +1582,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
1583 format.format.code = MEDIA_BUS_FMT_UYVY8_2X8; 1582 format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
1584 format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A; 1583 format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
1585 format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A; 1584 format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
1586 resizer_set_format(sd, fh, &format); 1585 resizer_set_format(sd, fh->pad, &format);
1587 } else if (&resizer->resizer_b.subdev == sd) { 1586 } else if (&resizer->resizer_b.subdev == sd) {
1588 memset(&format, 0, sizeof(format)); 1587 memset(&format, 0, sizeof(format));
1589 format.pad = RESIZER_PAD_SINK; 1588 format.pad = RESIZER_PAD_SINK;
@@ -1591,7 +1590,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
1591 format.format.code = MEDIA_BUS_FMT_YUYV8_2X8; 1590 format.format.code = MEDIA_BUS_FMT_YUYV8_2X8;
1592 format.format.width = MAX_IN_WIDTH; 1591 format.format.width = MAX_IN_WIDTH;
1593 format.format.height = MAX_IN_HEIGHT; 1592 format.format.height = MAX_IN_HEIGHT;
1594 resizer_set_format(sd, fh, &format); 1593 resizer_set_format(sd, fh->pad, &format);
1595 1594
1596 memset(&format, 0, sizeof(format)); 1595 memset(&format, 0, sizeof(format));
1597 format.pad = RESIZER_PAD_SOURCE; 1596 format.pad = RESIZER_PAD_SOURCE;
@@ -1599,7 +1598,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
1599 format.format.code = MEDIA_BUS_FMT_UYVY8_2X8; 1598 format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
1600 format.format.width = IPIPE_MAX_OUTPUT_WIDTH_B; 1599 format.format.width = IPIPE_MAX_OUTPUT_WIDTH_B;
1601 format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_B; 1600 format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_B;
1602 resizer_set_format(sd, fh, &format); 1601 resizer_set_format(sd, fh->pad, &format);
1603 } 1602 }
1604 1603
1605 return 0; 1604 return 0;
diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c
index 2d96fb3eca53..e404ad4fd987 100644
--- a/drivers/staging/media/omap4iss/iss_csi2.c
+++ b/drivers/staging/media/omap4iss/iss_csi2.c
@@ -828,17 +828,17 @@ static const struct iss_video_operations csi2_issvideo_ops = {
828 */ 828 */
829 829
830static struct v4l2_mbus_framefmt * 830static struct v4l2_mbus_framefmt *
831__csi2_get_format(struct iss_csi2_device *csi2, struct v4l2_subdev_fh *fh, 831__csi2_get_format(struct iss_csi2_device *csi2, struct v4l2_subdev_pad_config *cfg,
832 unsigned int pad, enum v4l2_subdev_format_whence which) 832 unsigned int pad, enum v4l2_subdev_format_whence which)
833{ 833{
834 if (which == V4L2_SUBDEV_FORMAT_TRY) 834 if (which == V4L2_SUBDEV_FORMAT_TRY)
835 return v4l2_subdev_get_try_format(fh, pad); 835 return v4l2_subdev_get_try_format(&csi2->subdev, cfg, pad);
836 836
837 return &csi2->formats[pad]; 837 return &csi2->formats[pad];
838} 838}
839 839
840static void 840static void
841csi2_try_format(struct iss_csi2_device *csi2, struct v4l2_subdev_fh *fh, 841csi2_try_format(struct iss_csi2_device *csi2, struct v4l2_subdev_pad_config *cfg,
842 unsigned int pad, struct v4l2_mbus_framefmt *fmt, 842 unsigned int pad, struct v4l2_mbus_framefmt *fmt,
843 enum v4l2_subdev_format_whence which) 843 enum v4l2_subdev_format_whence which)
844{ 844{
@@ -868,7 +868,7 @@ csi2_try_format(struct iss_csi2_device *csi2, struct v4l2_subdev_fh *fh,
868 * compression. 868 * compression.
869 */ 869 */
870 pixelcode = fmt->code; 870 pixelcode = fmt->code;
871 format = __csi2_get_format(csi2, fh, CSI2_PAD_SINK, which); 871 format = __csi2_get_format(csi2, cfg, CSI2_PAD_SINK, which);
872 memcpy(fmt, format, sizeof(*fmt)); 872 memcpy(fmt, format, sizeof(*fmt));
873 873
874 /* 874 /*
@@ -889,12 +889,12 @@ csi2_try_format(struct iss_csi2_device *csi2, struct v4l2_subdev_fh *fh,
889/* 889/*
890 * csi2_enum_mbus_code - Handle pixel format enumeration 890 * csi2_enum_mbus_code - Handle pixel format enumeration
891 * @sd : pointer to v4l2 subdev structure 891 * @sd : pointer to v4l2 subdev structure
892 * @fh : V4L2 subdev file handle 892 * @cfg : V4L2 subdev pad config
893 * @code : pointer to v4l2_subdev_mbus_code_enum structure 893 * @code : pointer to v4l2_subdev_mbus_code_enum structure
894 * return -EINVAL or zero on success 894 * return -EINVAL or zero on success
895 */ 895 */
896static int csi2_enum_mbus_code(struct v4l2_subdev *sd, 896static int csi2_enum_mbus_code(struct v4l2_subdev *sd,
897 struct v4l2_subdev_fh *fh, 897 struct v4l2_subdev_pad_config *cfg,
898 struct v4l2_subdev_mbus_code_enum *code) 898 struct v4l2_subdev_mbus_code_enum *code)
899{ 899{
900 struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd); 900 struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd);
@@ -907,7 +907,7 @@ static int csi2_enum_mbus_code(struct v4l2_subdev *sd,
907 907
908 code->code = csi2_input_fmts[code->index]; 908 code->code = csi2_input_fmts[code->index];
909 } else { 909 } else {
910 format = __csi2_get_format(csi2, fh, CSI2_PAD_SINK, 910 format = __csi2_get_format(csi2, cfg, CSI2_PAD_SINK,
911 V4L2_SUBDEV_FORMAT_TRY); 911 V4L2_SUBDEV_FORMAT_TRY);
912 switch (code->index) { 912 switch (code->index) {
913 case 0: 913 case 0:
@@ -931,7 +931,7 @@ static int csi2_enum_mbus_code(struct v4l2_subdev *sd,
931} 931}
932 932
933static int csi2_enum_frame_size(struct v4l2_subdev *sd, 933static int csi2_enum_frame_size(struct v4l2_subdev *sd,
934 struct v4l2_subdev_fh *fh, 934 struct v4l2_subdev_pad_config *cfg,
935 struct v4l2_subdev_frame_size_enum *fse) 935 struct v4l2_subdev_frame_size_enum *fse)
936{ 936{
937 struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd); 937 struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd);
@@ -943,7 +943,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd,
943 format.code = fse->code; 943 format.code = fse->code;
944 format.width = 1; 944 format.width = 1;
945 format.height = 1; 945 format.height = 1;
946 csi2_try_format(csi2, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 946 csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
947 fse->min_width = format.width; 947 fse->min_width = format.width;
948 fse->min_height = format.height; 948 fse->min_height = format.height;
949 949
@@ -953,7 +953,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd,
953 format.code = fse->code; 953 format.code = fse->code;
954 format.width = -1; 954 format.width = -1;
955 format.height = -1; 955 format.height = -1;
956 csi2_try_format(csi2, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 956 csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
957 fse->max_width = format.width; 957 fse->max_width = format.width;
958 fse->max_height = format.height; 958 fse->max_height = format.height;
959 959
@@ -963,17 +963,17 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd,
963/* 963/*
964 * csi2_get_format - Handle get format by pads subdev method 964 * csi2_get_format - Handle get format by pads subdev method
965 * @sd : pointer to v4l2 subdev structure 965 * @sd : pointer to v4l2 subdev structure
966 * @fh : V4L2 subdev file handle 966 * @cfg: V4L2 subdev pad config
967 * @fmt: pointer to v4l2 subdev format structure 967 * @fmt: pointer to v4l2 subdev format structure
968 * return -EINVAL or zero on success 968 * return -EINVAL or zero on success
969 */ 969 */
970static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 970static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
971 struct v4l2_subdev_format *fmt) 971 struct v4l2_subdev_format *fmt)
972{ 972{
973 struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd); 973 struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd);
974 struct v4l2_mbus_framefmt *format; 974 struct v4l2_mbus_framefmt *format;
975 975
976 format = __csi2_get_format(csi2, fh, fmt->pad, fmt->which); 976 format = __csi2_get_format(csi2, cfg, fmt->pad, fmt->which);
977 if (format == NULL) 977 if (format == NULL)
978 return -EINVAL; 978 return -EINVAL;
979 979
@@ -984,29 +984,29 @@ static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
984/* 984/*
985 * csi2_set_format - Handle set format by pads subdev method 985 * csi2_set_format - Handle set format by pads subdev method
986 * @sd : pointer to v4l2 subdev structure 986 * @sd : pointer to v4l2 subdev structure
987 * @fh : V4L2 subdev file handle 987 * @cfg: V4L2 subdev pad config
988 * @fmt: pointer to v4l2 subdev format structure 988 * @fmt: pointer to v4l2 subdev format structure
989 * return -EINVAL or zero on success 989 * return -EINVAL or zero on success
990 */ 990 */
991static int csi2_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 991static int csi2_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
992 struct v4l2_subdev_format *fmt) 992 struct v4l2_subdev_format *fmt)
993{ 993{
994 struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd); 994 struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd);
995 struct v4l2_mbus_framefmt *format; 995 struct v4l2_mbus_framefmt *format;
996 996
997 format = __csi2_get_format(csi2, fh, fmt->pad, fmt->which); 997 format = __csi2_get_format(csi2, cfg, fmt->pad, fmt->which);
998 if (format == NULL) 998 if (format == NULL)
999 return -EINVAL; 999 return -EINVAL;
1000 1000
1001 csi2_try_format(csi2, fh, fmt->pad, &fmt->format, fmt->which); 1001 csi2_try_format(csi2, cfg, fmt->pad, &fmt->format, fmt->which);
1002 *format = fmt->format; 1002 *format = fmt->format;
1003 1003
1004 /* Propagate the format from sink to source */ 1004 /* Propagate the format from sink to source */
1005 if (fmt->pad == CSI2_PAD_SINK) { 1005 if (fmt->pad == CSI2_PAD_SINK) {
1006 format = __csi2_get_format(csi2, fh, CSI2_PAD_SOURCE, 1006 format = __csi2_get_format(csi2, cfg, CSI2_PAD_SOURCE,
1007 fmt->which); 1007 fmt->which);
1008 *format = fmt->format; 1008 *format = fmt->format;
1009 csi2_try_format(csi2, fh, CSI2_PAD_SOURCE, format, fmt->which); 1009 csi2_try_format(csi2, cfg, CSI2_PAD_SOURCE, format, fmt->which);
1010 } 1010 }
1011 1011
1012 return 0; 1012 return 0;
@@ -1048,7 +1048,7 @@ static int csi2_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1048 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; 1048 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
1049 format.format.width = 4096; 1049 format.format.width = 4096;
1050 format.format.height = 4096; 1050 format.format.height = 4096;
1051 csi2_set_format(sd, fh, &format); 1051 csi2_set_format(sd, fh ? fh->pad : NULL, &format);
1052 1052
1053 return 0; 1053 return 0;
1054} 1054}
diff --git a/drivers/staging/media/omap4iss/iss_ipipe.c b/drivers/staging/media/omap4iss/iss_ipipe.c
index a1a46ef8319b..fc319822a33e 100644
--- a/drivers/staging/media/omap4iss/iss_ipipe.c
+++ b/drivers/staging/media/omap4iss/iss_ipipe.c
@@ -24,7 +24,7 @@
24#include "iss_ipipe.h" 24#include "iss_ipipe.h"
25 25
26static struct v4l2_mbus_framefmt * 26static struct v4l2_mbus_framefmt *
27__ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh, 27__ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_pad_config *cfg,
28 unsigned int pad, enum v4l2_subdev_format_whence which); 28 unsigned int pad, enum v4l2_subdev_format_whence which);
29 29
30static const unsigned int ipipe_fmts[] = { 30static const unsigned int ipipe_fmts[] = {
@@ -176,11 +176,11 @@ static int ipipe_set_stream(struct v4l2_subdev *sd, int enable)
176} 176}
177 177
178static struct v4l2_mbus_framefmt * 178static struct v4l2_mbus_framefmt *
179__ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh, 179__ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_pad_config *cfg,
180 unsigned int pad, enum v4l2_subdev_format_whence which) 180 unsigned int pad, enum v4l2_subdev_format_whence which)
181{ 181{
182 if (which == V4L2_SUBDEV_FORMAT_TRY) 182 if (which == V4L2_SUBDEV_FORMAT_TRY)
183 return v4l2_subdev_get_try_format(fh, pad); 183 return v4l2_subdev_get_try_format(&ipipe->subdev, cfg, pad);
184 184
185 return &ipipe->formats[pad]; 185 return &ipipe->formats[pad];
186} 186}
@@ -188,12 +188,12 @@ __ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh,
188/* 188/*
189 * ipipe_try_format - Try video format on a pad 189 * ipipe_try_format - Try video format on a pad
190 * @ipipe: ISS IPIPE device 190 * @ipipe: ISS IPIPE device
191 * @fh : V4L2 subdev file handle 191 * @cfg: V4L2 subdev pad config
192 * @pad: Pad number 192 * @pad: Pad number
193 * @fmt: Format 193 * @fmt: Format
194 */ 194 */
195static void 195static void
196ipipe_try_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh, 196ipipe_try_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_pad_config *cfg,
197 unsigned int pad, struct v4l2_mbus_framefmt *fmt, 197 unsigned int pad, struct v4l2_mbus_framefmt *fmt,
198 enum v4l2_subdev_format_whence which) 198 enum v4l2_subdev_format_whence which)
199{ 199{
@@ -220,7 +220,7 @@ ipipe_try_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh,
220 break; 220 break;
221 221
222 case IPIPE_PAD_SOURCE_VP: 222 case IPIPE_PAD_SOURCE_VP:
223 format = __ipipe_get_format(ipipe, fh, IPIPE_PAD_SINK, which); 223 format = __ipipe_get_format(ipipe, cfg, IPIPE_PAD_SINK, which);
224 memcpy(fmt, format, sizeof(*fmt)); 224 memcpy(fmt, format, sizeof(*fmt));
225 225
226 fmt->code = MEDIA_BUS_FMT_UYVY8_1X16; 226 fmt->code = MEDIA_BUS_FMT_UYVY8_1X16;
@@ -236,12 +236,12 @@ ipipe_try_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_fh *fh,
236/* 236/*
237 * ipipe_enum_mbus_code - Handle pixel format enumeration 237 * ipipe_enum_mbus_code - Handle pixel format enumeration
238 * @sd : pointer to v4l2 subdev structure 238 * @sd : pointer to v4l2 subdev structure
239 * @fh : V4L2 subdev file handle 239 * @cfg : V4L2 subdev pad config
240 * @code : pointer to v4l2_subdev_mbus_code_enum structure 240 * @code : pointer to v4l2_subdev_mbus_code_enum structure
241 * return -EINVAL or zero on success 241 * return -EINVAL or zero on success
242 */ 242 */
243static int ipipe_enum_mbus_code(struct v4l2_subdev *sd, 243static int ipipe_enum_mbus_code(struct v4l2_subdev *sd,
244 struct v4l2_subdev_fh *fh, 244 struct v4l2_subdev_pad_config *cfg,
245 struct v4l2_subdev_mbus_code_enum *code) 245 struct v4l2_subdev_mbus_code_enum *code)
246{ 246{
247 switch (code->pad) { 247 switch (code->pad) {
@@ -268,7 +268,7 @@ static int ipipe_enum_mbus_code(struct v4l2_subdev *sd,
268} 268}
269 269
270static int ipipe_enum_frame_size(struct v4l2_subdev *sd, 270static int ipipe_enum_frame_size(struct v4l2_subdev *sd,
271 struct v4l2_subdev_fh *fh, 271 struct v4l2_subdev_pad_config *cfg,
272 struct v4l2_subdev_frame_size_enum *fse) 272 struct v4l2_subdev_frame_size_enum *fse)
273{ 273{
274 struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd); 274 struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
@@ -280,7 +280,7 @@ static int ipipe_enum_frame_size(struct v4l2_subdev *sd,
280 format.code = fse->code; 280 format.code = fse->code;
281 format.width = 1; 281 format.width = 1;
282 format.height = 1; 282 format.height = 1;
283 ipipe_try_format(ipipe, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 283 ipipe_try_format(ipipe, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
284 fse->min_width = format.width; 284 fse->min_width = format.width;
285 fse->min_height = format.height; 285 fse->min_height = format.height;
286 286
@@ -290,7 +290,7 @@ static int ipipe_enum_frame_size(struct v4l2_subdev *sd,
290 format.code = fse->code; 290 format.code = fse->code;
291 format.width = -1; 291 format.width = -1;
292 format.height = -1; 292 format.height = -1;
293 ipipe_try_format(ipipe, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY); 293 ipipe_try_format(ipipe, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
294 fse->max_width = format.width; 294 fse->max_width = format.width;
295 fse->max_height = format.height; 295 fse->max_height = format.height;
296 296
@@ -300,19 +300,19 @@ static int ipipe_enum_frame_size(struct v4l2_subdev *sd,
300/* 300/*
301 * ipipe_get_format - Retrieve the video format on a pad 301 * ipipe_get_format - Retrieve the video format on a pad
302 * @sd : ISP IPIPE V4L2 subdevice 302 * @sd : ISP IPIPE V4L2 subdevice
303 * @fh : V4L2 subdev file handle 303 * @cfg: V4L2 subdev pad config
304 * @fmt: Format 304 * @fmt: Format
305 * 305 *
306 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond 306 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
307 * to the format type. 307 * to the format type.
308 */ 308 */
309static int ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 309static int ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
310 struct v4l2_subdev_format *fmt) 310 struct v4l2_subdev_format *fmt)
311{ 311{
312 struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd); 312 struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
313 struct v4l2_mbus_framefmt *format; 313 struct v4l2_mbus_framefmt *format;
314 314
315 format = __ipipe_get_format(ipipe, fh, fmt->pad, fmt->which); 315 format = __ipipe_get_format(ipipe, cfg, fmt->pad, fmt->which);
316 if (format == NULL) 316 if (format == NULL)
317 return -EINVAL; 317 return -EINVAL;
318 318
@@ -323,31 +323,31 @@ static int ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
323/* 323/*
324 * ipipe_set_format - Set the video format on a pad 324 * ipipe_set_format - Set the video format on a pad
325 * @sd : ISP IPIPE V4L2 subdevice 325 * @sd : ISP IPIPE V4L2 subdevice
326 * @fh : V4L2 subdev file handle 326 * @cfg: V4L2 subdev pad config
327 * @fmt: Format 327 * @fmt: Format
328 * 328 *
329 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond 329 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
330 * to the format type. 330 * to the format type.
331 */ 331 */
332static int ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 332static int ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
333 struct v4l2_subdev_format *fmt) 333 struct v4l2_subdev_format *fmt)
334{ 334{
335 struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd); 335 struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
336 struct v4l2_mbus_framefmt *format; 336 struct v4l2_mbus_framefmt *format;
337 337
338 format = __ipipe_get_format(ipipe, fh, fmt->pad, fmt->which); 338 format = __ipipe_get_format(ipipe, cfg, fmt->pad, fmt->which);
339 if (format == NULL) 339 if (format == NULL)
340 return -EINVAL; 340 return -EINVAL;
341 341
342 ipipe_try_format(ipipe, fh, fmt->pad, &fmt->format, fmt->which); 342 ipipe_try_format(ipipe, cfg, fmt->pad, &fmt->format, fmt->which);
343 *format = fmt->format; 343 *format = fmt->format;
344 344
345 /* Propagate the format from sink to source */ 345 /* Propagate the format from sink to source */
346 if (fmt->pad == IPIPE_PAD_SINK) { 346 if (fmt->pad == IPIPE_PAD_SINK) {
347 format = __ipipe_get_format(ipipe, fh, IPIPE_PAD_SOURCE_VP, 347 format = __ipipe_get_format(ipipe, cfg, IPIPE_PAD_SOURCE_VP,
348 fmt->which); 348 fmt->which);
349 *format = fmt->format; 349 *format = fmt->format;
350 ipipe_try_format(ipipe, fh, IPIPE_PAD_SOURCE_VP, format, 350 ipipe_try_format(ipipe, cfg, IPIPE_PAD_SOURCE_VP, format,
351 fmt->which); 351 fmt->which);
352 } 352 }
353 353
@@ -388,7 +388,7 @@ static int ipipe_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
388 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; 388 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
389 format.format.width = 4096; 389 format.format.width = 4096;
390 format.format.height = 4096; 390 format.format.height = 4096;
391 ipipe_set_format(sd, fh, &format); 391 ipipe_set_format(sd, fh ? fh->pad : NULL, &format);
392 392
393 return 0; 393 return 0;
394} 394}
diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c
index 3943fae699ee..948edcca8704 100644
--- a/drivers/staging/media/omap4iss/iss_ipipeif.c
+++ b/drivers/staging/media/omap4iss/iss_ipipeif.c
@@ -361,24 +361,24 @@ static int ipipeif_set_stream(struct v4l2_subdev *sd, int enable)
361 361
362static struct v4l2_mbus_framefmt * 362static struct v4l2_mbus_framefmt *
363__ipipeif_get_format(struct iss_ipipeif_device *ipipeif, 363__ipipeif_get_format(struct iss_ipipeif_device *ipipeif,
364 struct v4l2_subdev_fh *fh, unsigned int pad, 364 struct v4l2_subdev_pad_config *cfg, unsigned int pad,
365 enum v4l2_subdev_format_whence which) 365 enum v4l2_subdev_format_whence which)
366{ 366{
367 if (which == V4L2_SUBDEV_FORMAT_TRY) 367 if (which == V4L2_SUBDEV_FORMAT_TRY)
368 return v4l2_subdev_get_try_format(fh, pad); 368 return v4l2_subdev_get_try_format(&ipipeif->subdev, cfg, pad);
369 return &ipipeif->formats[pad]; 369 return &ipipeif->formats[pad];
370} 370}
371 371
372/* 372/*
373 * ipipeif_try_format - Try video format on a pad 373 * ipipeif_try_format - Try video format on a pad
374 * @ipipeif: ISS IPIPEIF device 374 * @ipipeif: ISS IPIPEIF device
375 * @fh : V4L2 subdev file handle 375 * @cfg: V4L2 subdev pad config
376 * @pad: Pad number 376 * @pad: Pad number
377 * @fmt: Format 377 * @fmt: Format
378 */ 378 */
379static void 379static void
380ipipeif_try_format(struct iss_ipipeif_device *ipipeif, 380ipipeif_try_format(struct iss_ipipeif_device *ipipeif,
381 struct v4l2_subdev_fh *fh, unsigned int pad, 381 struct v4l2_subdev_pad_config *cfg, unsigned int pad,
382 struct v4l2_mbus_framefmt *fmt, 382 struct v4l2_mbus_framefmt *fmt,
383 enum v4l2_subdev_format_whence which) 383 enum v4l2_subdev_format_whence which)
384{ 384{
@@ -407,7 +407,7 @@ ipipeif_try_format(struct iss_ipipeif_device *ipipeif,
407 break; 407 break;
408 408
409 case IPIPEIF_PAD_SOURCE_ISIF_SF: 409 case IPIPEIF_PAD_SOURCE_ISIF_SF:
410 format = __ipipeif_get_format(ipipeif, fh, IPIPEIF_PAD_SINK, 410 format = __ipipeif_get_format(ipipeif, cfg, IPIPEIF_PAD_SINK,
411 which); 411 which);
412 memcpy(fmt, format, sizeof(*fmt)); 412 memcpy(fmt, format, sizeof(*fmt));
413 413
@@ -422,7 +422,7 @@ ipipeif_try_format(struct iss_ipipeif_device *ipipeif,
422 break; 422 break;
423 423
424 case IPIPEIF_PAD_SOURCE_VP: 424 case IPIPEIF_PAD_SOURCE_VP:
425 format = __ipipeif_get_format(ipipeif, fh, IPIPEIF_PAD_SINK, 425 format = __ipipeif_get_format(ipipeif, cfg, IPIPEIF_PAD_SINK,
426 which); 426 which);
427 memcpy(fmt, format, sizeof(*fmt)); 427 memcpy(fmt, format, sizeof(*fmt));
428 428
@@ -441,12 +441,12 @@ ipipeif_try_format(struct iss_ipipeif_device *ipipeif,
441/* 441/*
442 * ipipeif_enum_mbus_code - Handle pixel format enumeration 442 * ipipeif_enum_mbus_code - Handle pixel format enumeration
443 * @sd : pointer to v4l2 subdev structure 443 * @sd : pointer to v4l2 subdev structure
444 * @fh : V4L2 subdev file handle 444 * @cfg : V4L2 subdev pad config
445 * @code : pointer to v4l2_subdev_mbus_code_enum structure 445 * @code : pointer to v4l2_subdev_mbus_code_enum structure
446 * return -EINVAL or zero on success 446 * return -EINVAL or zero on success
447 */ 447 */
448static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd, 448static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd,
449 struct v4l2_subdev_fh *fh, 449 struct v4l2_subdev_pad_config *cfg,
450 struct v4l2_subdev_mbus_code_enum *code) 450 struct v4l2_subdev_mbus_code_enum *code)
451{ 451{
452 struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); 452 struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
@@ -466,7 +466,7 @@ static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd,
466 if (code->index != 0) 466 if (code->index != 0)
467 return -EINVAL; 467 return -EINVAL;
468 468
469 format = __ipipeif_get_format(ipipeif, fh, IPIPEIF_PAD_SINK, 469 format = __ipipeif_get_format(ipipeif, cfg, IPIPEIF_PAD_SINK,
470 V4L2_SUBDEV_FORMAT_TRY); 470 V4L2_SUBDEV_FORMAT_TRY);
471 471
472 code->code = format->code; 472 code->code = format->code;
@@ -480,7 +480,7 @@ static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd,
480} 480}
481 481
482static int ipipeif_enum_frame_size(struct v4l2_subdev *sd, 482static int ipipeif_enum_frame_size(struct v4l2_subdev *sd,
483 struct v4l2_subdev_fh *fh, 483 struct v4l2_subdev_pad_config *cfg,
484 struct v4l2_subdev_frame_size_enum *fse) 484 struct v4l2_subdev_frame_size_enum *fse)
485{ 485{
486 struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); 486 struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
@@ -492,7 +492,7 @@ static int ipipeif_enum_frame_size(struct v4l2_subdev *sd,
492 format.code = fse->code; 492 format.code = fse->code;
493 format.width = 1; 493 format.width = 1;
494 format.height = 1; 494 format.height = 1;
495 ipipeif_try_format(ipipeif, fh, fse->pad, &format, 495 ipipeif_try_format(ipipeif, cfg, fse->pad, &format,
496 V4L2_SUBDEV_FORMAT_TRY); 496 V4L2_SUBDEV_FORMAT_TRY);
497 fse->min_width = format.width; 497 fse->min_width = format.width;
498 fse->min_height = format.height; 498 fse->min_height = format.height;
@@ -503,7 +503,7 @@ static int ipipeif_enum_frame_size(struct v4l2_subdev *sd,
503 format.code = fse->code; 503 format.code = fse->code;
504 format.width = -1; 504 format.width = -1;
505 format.height = -1; 505 format.height = -1;
506 ipipeif_try_format(ipipeif, fh, fse->pad, &format, 506 ipipeif_try_format(ipipeif, cfg, fse->pad, &format,
507 V4L2_SUBDEV_FORMAT_TRY); 507 V4L2_SUBDEV_FORMAT_TRY);
508 fse->max_width = format.width; 508 fse->max_width = format.width;
509 fse->max_height = format.height; 509 fse->max_height = format.height;
@@ -514,19 +514,19 @@ static int ipipeif_enum_frame_size(struct v4l2_subdev *sd,
514/* 514/*
515 * ipipeif_get_format - Retrieve the video format on a pad 515 * ipipeif_get_format - Retrieve the video format on a pad
516 * @sd : ISP IPIPEIF V4L2 subdevice 516 * @sd : ISP IPIPEIF V4L2 subdevice
517 * @fh : V4L2 subdev file handle 517 * @cfg: V4L2 subdev pad config
518 * @fmt: Format 518 * @fmt: Format
519 * 519 *
520 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond 520 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
521 * to the format type. 521 * to the format type.
522 */ 522 */
523static int ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 523static int ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
524 struct v4l2_subdev_format *fmt) 524 struct v4l2_subdev_format *fmt)
525{ 525{
526 struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); 526 struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
527 struct v4l2_mbus_framefmt *format; 527 struct v4l2_mbus_framefmt *format;
528 528
529 format = __ipipeif_get_format(ipipeif, fh, fmt->pad, fmt->which); 529 format = __ipipeif_get_format(ipipeif, cfg, fmt->pad, fmt->which);
530 if (format == NULL) 530 if (format == NULL)
531 return -EINVAL; 531 return -EINVAL;
532 532
@@ -537,39 +537,39 @@ static int ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
537/* 537/*
538 * ipipeif_set_format - Set the video format on a pad 538 * ipipeif_set_format - Set the video format on a pad
539 * @sd : ISP IPIPEIF V4L2 subdevice 539 * @sd : ISP IPIPEIF V4L2 subdevice
540 * @fh : V4L2 subdev file handle 540 * @cfg: V4L2 subdev pad config
541 * @fmt: Format 541 * @fmt: Format
542 * 542 *
543 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond 543 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
544 * to the format type. 544 * to the format type.
545 */ 545 */
546static int ipipeif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 546static int ipipeif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
547 struct v4l2_subdev_format *fmt) 547 struct v4l2_subdev_format *fmt)
548{ 548{
549 struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); 549 struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
550 struct v4l2_mbus_framefmt *format; 550 struct v4l2_mbus_framefmt *format;
551 551
552 format = __ipipeif_get_format(ipipeif, fh, fmt->pad, fmt->which); 552 format = __ipipeif_get_format(ipipeif, cfg, fmt->pad, fmt->which);
553 if (format == NULL) 553 if (format == NULL)
554 return -EINVAL; 554 return -EINVAL;
555 555
556 ipipeif_try_format(ipipeif, fh, fmt->pad, &fmt->format, fmt->which); 556 ipipeif_try_format(ipipeif, cfg, fmt->pad, &fmt->format, fmt->which);
557 *format = fmt->format; 557 *format = fmt->format;
558 558
559 /* Propagate the format from sink to source */ 559 /* Propagate the format from sink to source */
560 if (fmt->pad == IPIPEIF_PAD_SINK) { 560 if (fmt->pad == IPIPEIF_PAD_SINK) {
561 format = __ipipeif_get_format(ipipeif, fh, 561 format = __ipipeif_get_format(ipipeif, cfg,
562 IPIPEIF_PAD_SOURCE_ISIF_SF, 562 IPIPEIF_PAD_SOURCE_ISIF_SF,
563 fmt->which); 563 fmt->which);
564 *format = fmt->format; 564 *format = fmt->format;
565 ipipeif_try_format(ipipeif, fh, IPIPEIF_PAD_SOURCE_ISIF_SF, 565 ipipeif_try_format(ipipeif, cfg, IPIPEIF_PAD_SOURCE_ISIF_SF,
566 format, fmt->which); 566 format, fmt->which);
567 567
568 format = __ipipeif_get_format(ipipeif, fh, 568 format = __ipipeif_get_format(ipipeif, cfg,
569 IPIPEIF_PAD_SOURCE_VP, 569 IPIPEIF_PAD_SOURCE_VP,
570 fmt->which); 570 fmt->which);
571 *format = fmt->format; 571 *format = fmt->format;
572 ipipeif_try_format(ipipeif, fh, IPIPEIF_PAD_SOURCE_VP, format, 572 ipipeif_try_format(ipipeif, cfg, IPIPEIF_PAD_SOURCE_VP, format,
573 fmt->which); 573 fmt->which);
574 } 574 }
575 575
@@ -612,7 +612,7 @@ static int ipipeif_init_formats(struct v4l2_subdev *sd,
612 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10; 612 format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
613 format.format.width = 4096; 613 format.format.width = 4096;
614 format.format.height = 4096; 614 format.format.height = 4096;
615 ipipeif_set_format(sd, fh, &format); 615 ipipeif_set_format(sd, fh ? fh->pad : NULL, &format);
616 616
617 return 0; 617 return 0;
618} 618}
diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c
index 3ab972818f1b..f9b0aac91e9d 100644
--- a/drivers/staging/media/omap4iss/iss_resizer.c
+++ b/drivers/staging/media/omap4iss/iss_resizer.c
@@ -420,24 +420,24 @@ static int resizer_set_stream(struct v4l2_subdev *sd, int enable)
420 420
421static struct v4l2_mbus_framefmt * 421static struct v4l2_mbus_framefmt *
422__resizer_get_format(struct iss_resizer_device *resizer, 422__resizer_get_format(struct iss_resizer_device *resizer,
423 struct v4l2_subdev_fh *fh, unsigned int pad, 423 struct v4l2_subdev_pad_config *cfg, unsigned int pad,
424 enum v4l2_subdev_format_whence which) 424 enum v4l2_subdev_format_whence which)
425{ 425{
426 if (which == V4L2_SUBDEV_FORMAT_TRY) 426 if (which == V4L2_SUBDEV_FORMAT_TRY)
427 return v4l2_subdev_get_try_format(fh, pad); 427 return v4l2_subdev_get_try_format(&resizer->subdev, cfg, pad);
428 return &resizer->formats[pad]; 428 return &resizer->formats[pad];
429} 429}
430 430
431/* 431/*
432 * resizer_try_format - Try video format on a pad 432 * resizer_try_format - Try video format on a pad
433 * @resizer: ISS RESIZER device 433 * @resizer: ISS RESIZER device
434 * @fh : V4L2 subdev file handle 434 * @cfg: V4L2 subdev pad config
435 * @pad: Pad number 435 * @pad: Pad number
436 * @fmt: Format 436 * @fmt: Format
437 */ 437 */
438static void 438static void
439resizer_try_format(struct iss_resizer_device *resizer, 439resizer_try_format(struct iss_resizer_device *resizer,
440 struct v4l2_subdev_fh *fh, unsigned int pad, 440 struct v4l2_subdev_pad_config *cfg, unsigned int pad,
441 struct v4l2_mbus_framefmt *fmt, 441 struct v4l2_mbus_framefmt *fmt,
442 enum v4l2_subdev_format_whence which) 442 enum v4l2_subdev_format_whence which)
443{ 443{
@@ -465,7 +465,7 @@ resizer_try_format(struct iss_resizer_device *resizer,
465 465
466 case RESIZER_PAD_SOURCE_MEM: 466 case RESIZER_PAD_SOURCE_MEM:
467 pixelcode = fmt->code; 467 pixelcode = fmt->code;
468 format = __resizer_get_format(resizer, fh, RESIZER_PAD_SINK, 468 format = __resizer_get_format(resizer, cfg, RESIZER_PAD_SINK,
469 which); 469 which);
470 memcpy(fmt, format, sizeof(*fmt)); 470 memcpy(fmt, format, sizeof(*fmt));
471 471
@@ -492,12 +492,12 @@ resizer_try_format(struct iss_resizer_device *resizer,
492/* 492/*
493 * resizer_enum_mbus_code - Handle pixel format enumeration 493 * resizer_enum_mbus_code - Handle pixel format enumeration
494 * @sd : pointer to v4l2 subdev structure 494 * @sd : pointer to v4l2 subdev structure
495 * @fh : V4L2 subdev file handle 495 * @cfg: V4L2 subdev pad config
496 * @code : pointer to v4l2_subdev_mbus_code_enum structure 496 * @code : pointer to v4l2_subdev_mbus_code_enum structure
497 * return -EINVAL or zero on success 497 * return -EINVAL or zero on success
498 */ 498 */
499static int resizer_enum_mbus_code(struct v4l2_subdev *sd, 499static int resizer_enum_mbus_code(struct v4l2_subdev *sd,
500 struct v4l2_subdev_fh *fh, 500 struct v4l2_subdev_pad_config *cfg,
501 struct v4l2_subdev_mbus_code_enum *code) 501 struct v4l2_subdev_mbus_code_enum *code)
502{ 502{
503 struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); 503 struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd);
@@ -512,7 +512,7 @@ static int resizer_enum_mbus_code(struct v4l2_subdev *sd,
512 break; 512 break;
513 513
514 case RESIZER_PAD_SOURCE_MEM: 514 case RESIZER_PAD_SOURCE_MEM:
515 format = __resizer_get_format(resizer, fh, RESIZER_PAD_SINK, 515 format = __resizer_get_format(resizer, cfg, RESIZER_PAD_SINK,
516 V4L2_SUBDEV_FORMAT_TRY); 516 V4L2_SUBDEV_FORMAT_TRY);
517 517
518 if (code->index == 0) { 518 if (code->index == 0) {
@@ -542,7 +542,7 @@ static int resizer_enum_mbus_code(struct v4l2_subdev *sd,
542} 542}
543 543
544static int resizer_enum_frame_size(struct v4l2_subdev *sd, 544static int resizer_enum_frame_size(struct v4l2_subdev *sd,
545 struct v4l2_subdev_fh *fh, 545 struct v4l2_subdev_pad_config *cfg,
546 struct v4l2_subdev_frame_size_enum *fse) 546 struct v4l2_subdev_frame_size_enum *fse)
547{ 547{
548 struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); 548 struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd);
@@ -554,7 +554,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
554 format.code = fse->code; 554 format.code = fse->code;
555 format.width = 1; 555 format.width = 1;
556 format.height = 1; 556 format.height = 1;
557 resizer_try_format(resizer, fh, fse->pad, &format, 557 resizer_try_format(resizer, cfg, fse->pad, &format,
558 V4L2_SUBDEV_FORMAT_TRY); 558 V4L2_SUBDEV_FORMAT_TRY);
559 fse->min_width = format.width; 559 fse->min_width = format.width;
560 fse->min_height = format.height; 560 fse->min_height = format.height;
@@ -565,7 +565,7 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
565 format.code = fse->code; 565 format.code = fse->code;
566 format.width = -1; 566 format.width = -1;
567 format.height = -1; 567 format.height = -1;
568 resizer_try_format(resizer, fh, fse->pad, &format, 568 resizer_try_format(resizer, cfg, fse->pad, &format,
569 V4L2_SUBDEV_FORMAT_TRY); 569 V4L2_SUBDEV_FORMAT_TRY);
570 fse->max_width = format.width; 570 fse->max_width = format.width;
571 fse->max_height = format.height; 571 fse->max_height = format.height;
@@ -576,19 +576,19 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd,
576/* 576/*
577 * resizer_get_format - Retrieve the video format on a pad 577 * resizer_get_format - Retrieve the video format on a pad
578 * @sd : ISP RESIZER V4L2 subdevice 578 * @sd : ISP RESIZER V4L2 subdevice
579 * @fh : V4L2 subdev file handle 579 * @cfg: V4L2 subdev pad config
580 * @fmt: Format 580 * @fmt: Format
581 * 581 *
582 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond 582 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
583 * to the format type. 583 * to the format type.
584 */ 584 */
585static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 585static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
586 struct v4l2_subdev_format *fmt) 586 struct v4l2_subdev_format *fmt)
587{ 587{
588 struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); 588 struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd);
589 struct v4l2_mbus_framefmt *format; 589 struct v4l2_mbus_framefmt *format;
590 590
591 format = __resizer_get_format(resizer, fh, fmt->pad, fmt->which); 591 format = __resizer_get_format(resizer, cfg, fmt->pad, fmt->which);
592 if (format == NULL) 592 if (format == NULL)
593 return -EINVAL; 593 return -EINVAL;
594 594
@@ -599,32 +599,32 @@ static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
599/* 599/*
600 * resizer_set_format - Set the video format on a pad 600 * resizer_set_format - Set the video format on a pad
601 * @sd : ISP RESIZER V4L2 subdevice 601 * @sd : ISP RESIZER V4L2 subdevice
602 * @fh : V4L2 subdev file handle 602 * @cfg: V4L2 subdev pad config
603 * @fmt: Format 603 * @fmt: Format
604 * 604 *
605 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond 605 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
606 * to the format type. 606 * to the format type.
607 */ 607 */
608static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 608static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
609 struct v4l2_subdev_format *fmt) 609 struct v4l2_subdev_format *fmt)
610{ 610{
611 struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); 611 struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd);
612 struct v4l2_mbus_framefmt *format; 612 struct v4l2_mbus_framefmt *format;
613 613
614 format = __resizer_get_format(resizer, fh, fmt->pad, fmt->which); 614 format = __resizer_get_format(resizer, cfg, fmt->pad, fmt->which);
615 if (format == NULL) 615 if (format == NULL)
616 return -EINVAL; 616 return -EINVAL;
617 617
618 resizer_try_format(resizer, fh, fmt->pad, &fmt->format, fmt->which); 618 resizer_try_format(resizer, cfg, fmt->pad, &fmt->format, fmt->which);
619 *format = fmt->format; 619 *format = fmt->format;
620 620
621 /* Propagate the format from sink to source */ 621 /* Propagate the format from sink to source */
622 if (fmt->pad == RESIZER_PAD_SINK) { 622 if (fmt->pad == RESIZER_PAD_SINK) {
623 format = __resizer_get_format(resizer, fh, 623 format = __resizer_get_format(resizer, cfg,
624 RESIZER_PAD_SOURCE_MEM, 624 RESIZER_PAD_SOURCE_MEM,
625 fmt->which); 625 fmt->which);
626 *format = fmt->format; 626 *format = fmt->format;
627 resizer_try_format(resizer, fh, RESIZER_PAD_SOURCE_MEM, format, 627 resizer_try_format(resizer, cfg, RESIZER_PAD_SOURCE_MEM, format,
628 fmt->which); 628 fmt->which);
629 } 629 }
630 630
@@ -667,7 +667,7 @@ static int resizer_init_formats(struct v4l2_subdev *sd,
667 format.format.code = MEDIA_BUS_FMT_UYVY8_1X16; 667 format.format.code = MEDIA_BUS_FMT_UYVY8_1X16;
668 format.format.width = 4096; 668 format.format.width = 4096;
669 format.format.height = 4096; 669 format.format.height = 4096;
670 resizer_set_format(sd, fh, &format); 670 resizer_set_format(sd, fh ? fh->pad : NULL, &format);
671 671
672 return 0; 672 return 0;
673} 673}
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 5beeb8744fd1..d9404df80482 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -482,6 +482,18 @@ struct v4l2_subdev_ir_ops {
482 struct v4l2_subdev_ir_parameters *params); 482 struct v4l2_subdev_ir_parameters *params);
483}; 483};
484 484
485/*
486 * Used for storing subdev pad information. This structure only needs
487 * to be passed to the pad op if the 'which' field of the main argument
488 * is set to V4L2_SUBDEV_FORMAT_TRY. For V4L2_SUBDEV_FORMAT_ACTIVE it is
489 * safe to pass NULL.
490 */
491struct v4l2_subdev_pad_config {
492 struct v4l2_mbus_framefmt try_fmt;
493 struct v4l2_rect try_crop;
494 struct v4l2_rect try_compose;
495};
496
485/** 497/**
486 * struct v4l2_subdev_pad_ops - v4l2-subdev pad level operations 498 * struct v4l2_subdev_pad_ops - v4l2-subdev pad level operations
487 * @get_frame_desc: get the current low level media bus frame parameters. 499 * @get_frame_desc: get the current low level media bus frame parameters.
@@ -489,21 +501,26 @@ struct v4l2_subdev_ir_ops {
489 * may be adjusted by the subdev driver to device capabilities. 501 * may be adjusted by the subdev driver to device capabilities.
490 */ 502 */
491struct v4l2_subdev_pad_ops { 503struct v4l2_subdev_pad_ops {
492 int (*enum_mbus_code)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 504 int (*enum_mbus_code)(struct v4l2_subdev *sd,
505 struct v4l2_subdev_pad_config *cfg,
493 struct v4l2_subdev_mbus_code_enum *code); 506 struct v4l2_subdev_mbus_code_enum *code);
494 int (*enum_frame_size)(struct v4l2_subdev *sd, 507 int (*enum_frame_size)(struct v4l2_subdev *sd,
495 struct v4l2_subdev_fh *fh, 508 struct v4l2_subdev_pad_config *cfg,
496 struct v4l2_subdev_frame_size_enum *fse); 509 struct v4l2_subdev_frame_size_enum *fse);
497 int (*enum_frame_interval)(struct v4l2_subdev *sd, 510 int (*enum_frame_interval)(struct v4l2_subdev *sd,
498 struct v4l2_subdev_fh *fh, 511 struct v4l2_subdev_pad_config *cfg,
499 struct v4l2_subdev_frame_interval_enum *fie); 512 struct v4l2_subdev_frame_interval_enum *fie);
500 int (*get_fmt)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 513 int (*get_fmt)(struct v4l2_subdev *sd,
514 struct v4l2_subdev_pad_config *cfg,
501 struct v4l2_subdev_format *format); 515 struct v4l2_subdev_format *format);
502 int (*set_fmt)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 516 int (*set_fmt)(struct v4l2_subdev *sd,
517 struct v4l2_subdev_pad_config *cfg,
503 struct v4l2_subdev_format *format); 518 struct v4l2_subdev_format *format);
504 int (*get_selection)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 519 int (*get_selection)(struct v4l2_subdev *sd,
520 struct v4l2_subdev_pad_config *cfg,
505 struct v4l2_subdev_selection *sel); 521 struct v4l2_subdev_selection *sel);
506 int (*set_selection)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 522 int (*set_selection)(struct v4l2_subdev *sd,
523 struct v4l2_subdev_pad_config *cfg,
507 struct v4l2_subdev_selection *sel); 524 struct v4l2_subdev_selection *sel);
508 int (*get_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid); 525 int (*get_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
509 int (*set_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid); 526 int (*set_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
@@ -625,11 +642,7 @@ struct v4l2_subdev {
625struct v4l2_subdev_fh { 642struct v4l2_subdev_fh {
626 struct v4l2_fh vfh; 643 struct v4l2_fh vfh;
627#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) 644#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
628 struct { 645 struct v4l2_subdev_pad_config *pad;
629 struct v4l2_mbus_framefmt try_fmt;
630 struct v4l2_rect try_crop;
631 struct v4l2_rect try_compose;
632 } *pad;
633#endif 646#endif
634}; 647};
635 648
@@ -639,17 +652,17 @@ struct v4l2_subdev_fh {
639#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) 652#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
640#define __V4L2_SUBDEV_MK_GET_TRY(rtype, fun_name, field_name) \ 653#define __V4L2_SUBDEV_MK_GET_TRY(rtype, fun_name, field_name) \
641 static inline struct rtype * \ 654 static inline struct rtype * \
642 v4l2_subdev_get_try_##fun_name(struct v4l2_subdev_fh *fh, \ 655 fun_name(struct v4l2_subdev *sd, \
643 unsigned int pad) \ 656 struct v4l2_subdev_pad_config *cfg, \
657 unsigned int pad) \
644 { \ 658 { \
645 BUG_ON(pad >= vdev_to_v4l2_subdev( \ 659 BUG_ON(pad >= sd->entity.num_pads); \
646 fh->vfh.vdev)->entity.num_pads); \ 660 return &cfg[pad].field_name; \
647 return &fh->pad[pad].field_name; \
648 } 661 }
649 662
650__V4L2_SUBDEV_MK_GET_TRY(v4l2_mbus_framefmt, format, try_fmt) 663__V4L2_SUBDEV_MK_GET_TRY(v4l2_mbus_framefmt, v4l2_subdev_get_try_format, try_fmt)
651__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, crop, try_crop) 664__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_crop, try_crop)
652__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, compose, try_compose) 665__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_compose, try_compose)
653#endif 666#endif
654 667
655extern const struct v4l2_file_operations v4l2_subdev_fops; 668extern const struct v4l2_file_operations v4l2_subdev_fops;