Re: [PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt

2015-07-12 Thread Guennadi Liakhovetski
On Thu, 25 Jun 2015, William Towle wrote:

 Fix rcar_vin_try_fmt's use of an inappropriate pad number when calling
 the subdev set_fmt function - for the ADV7612, IDs should be non-zero.
 
 Signed-off-by: William Towle william.to...@codethink.co.uk
 Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
 ---
  drivers/media/platform/soc_camera/rcar_vin.c |   20 ++--
  1 file changed, 14 insertions(+), 6 deletions(-)
 
 diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
 b/drivers/media/platform/soc_camera/rcar_vin.c
 index 00c1034..1023c5b 100644
 --- a/drivers/media/platform/soc_camera/rcar_vin.c
 +++ b/drivers/media/platform/soc_camera/rcar_vin.c
 @@ -1697,14 +1697,18 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   const struct soc_camera_format_xlate *xlate;
   struct v4l2_pix_format *pix = f-fmt.pix;
   struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
 - struct v4l2_subdev_pad_config pad_cfg;
 + struct v4l2_subdev_pad_config *pad_cfg;
   struct v4l2_subdev_format format = {
   .which = V4L2_SUBDEV_FORMAT_TRY,
   };
   struct v4l2_mbus_framefmt *mf = format.format;
   __u32 pixfmt = pix-pixelformat;
   int width, height;
 - int ret;
 + int ret= -ENOMEM;

Uhm, I find this very superfluous...

 +
 + pad_cfg = v4l2_subdev_alloc_pad_config(sd);
 + if (pad_cfg == NULL)
 + goto out;

I like the addition of the cleanup label instead of freeing the 
allocated pad on each error, but here please just do

+   return -ENOMEN;

and remove the out label.

Thanks
Guennadi

  
   xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
   if (!xlate) {
 @@ -1734,10 +1738,11 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   mf-code = xlate-code;
   mf-colorspace = pix-colorspace;
  
 + format.pad = icd-src_pad_idx;
   ret = v4l2_device_call_until_err(sd-v4l2_dev, soc_camera_grp_id(icd),
 -  pad, set_fmt, pad_cfg, format);
 +  pad, set_fmt, pad_cfg, format);
   if (ret  0)
 - return ret;
 + goto cleanup;
  
   /* Adjust only if VIN cannot scale */
   if (pix-width  mf-width * 2)
 @@ -1761,12 +1766,12 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   mf-height = VIN_MAX_HEIGHT;
   ret = v4l2_device_call_until_err(sd-v4l2_dev,
soc_camera_grp_id(icd),
 -  pad, set_fmt, pad_cfg,
 +  pad, set_fmt, pad_cfg,
format);
   if (ret  0) {
   dev_err(icd-parent,
   client try_fmt() = %d\n, ret);
 - return ret;
 + goto cleanup;
   }
   }
   /* We will scale exactly */
 @@ -1776,6 +1781,9 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   pix-height = height;
   }
  
 +cleanup:
 + v4l2_subdev_free_pad_config(pad_cfg);
 +out:
   return ret;
  }
  
 -- 
 1.7.10.4
 
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt

2015-06-25 Thread William Towle
Fix rcar_vin_try_fmt's use of an inappropriate pad number when calling
the subdev set_fmt function - for the ADV7612, IDs should be non-zero.

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |   20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 00c1034..1023c5b 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1697,14 +1697,18 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
const struct soc_camera_format_xlate *xlate;
struct v4l2_pix_format *pix = f-fmt.pix;
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-   struct v4l2_subdev_pad_config pad_cfg;
+   struct v4l2_subdev_pad_config *pad_cfg;
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_TRY,
};
struct v4l2_mbus_framefmt *mf = format.format;
__u32 pixfmt = pix-pixelformat;
int width, height;
-   int ret;
+   int ret= -ENOMEM;
+
+   pad_cfg = v4l2_subdev_alloc_pad_config(sd);
+   if (pad_cfg == NULL)
+   goto out;
 
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
@@ -1734,10 +1738,11 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
mf-code = xlate-code;
mf-colorspace = pix-colorspace;
 
+   format.pad = icd-src_pad_idx;
ret = v4l2_device_call_until_err(sd-v4l2_dev, soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg, format);
+pad, set_fmt, pad_cfg, format);
if (ret  0)
-   return ret;
+   goto cleanup;
 
/* Adjust only if VIN cannot scale */
if (pix-width  mf-width * 2)
@@ -1761,12 +1766,12 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
mf-height = VIN_MAX_HEIGHT;
ret = v4l2_device_call_until_err(sd-v4l2_dev,
 soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg,
+pad, set_fmt, pad_cfg,
 format);
if (ret  0) {
dev_err(icd-parent,
client try_fmt() = %d\n, ret);
-   return ret;
+   goto cleanup;
}
}
/* We will scale exactly */
@@ -1776,6 +1781,9 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
pix-height = height;
}
 
+cleanup:
+   v4l2_subdev_free_pad_config(pad_cfg);
+out:
return ret;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt

2015-06-20 Thread Guennadi Liakhovetski
Hi William,

On Wed, 3 Jun 2015, William Towle wrote:

 Fix rcar_vin_try_fmt to use the correct pad number when calling the
 subdev set_fmt. Previously pad number 0 was always used, resulting in
 EINVAL if the subdev cares about the pad number (e.g. ADV7612).
 
 Signed-off-by: William Towle william.to...@codethink.co.uk
 Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
 ---
  drivers/media/platform/soc_camera/rcar_vin.c |   20 +++-
  1 file changed, 15 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
 b/drivers/media/platform/soc_camera/rcar_vin.c
 index 00c1034..cc993bc 100644
 --- a/drivers/media/platform/soc_camera/rcar_vin.c
 +++ b/drivers/media/platform/soc_camera/rcar_vin.c
 @@ -1697,7 +1697,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   const struct soc_camera_format_xlate *xlate;
   struct v4l2_pix_format *pix = f-fmt.pix;
   struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
 - struct v4l2_subdev_pad_config pad_cfg;
 + struct v4l2_subdev_pad_config *pad_cfg;
   struct v4l2_subdev_format format = {
   .which = V4L2_SUBDEV_FORMAT_TRY,
   };
 @@ -1706,6 +1706,8 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   int width, height;
   int ret;
  
 + pad_cfg = v4l2_subdev_alloc_pad_config(sd);

Don't you have to check for NULL here? Are all subdevice drivers supposed 
to be able to handle pad_cfg = NULL in their .set_fmt() methods? Doesn't 
look like that to me, looking at the v4l2_subdev_get_try_format() 
implementation.

Thanks
Guennadi

 +
   xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
   if (!xlate) {
   xlate = icd-current_fmt;
 @@ -1734,10 +1736,15 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   mf-code = xlate-code;
   mf-colorspace = pix-colorspace;
  
 - ret = v4l2_device_call_until_err(sd-v4l2_dev, soc_camera_grp_id(icd),
 -  pad, set_fmt, pad_cfg, format);
 - if (ret  0)
 + format.pad = icd-src_pad_idx;
 + ret = v4l2_device_call_until_err(sd-v4l2_dev,
 + soc_camera_grp_id(icd), pad,
 + set_fmt, pad_cfg,
 + format);
 + if (ret  0) {
 + v4l2_subdev_free_pad_config(pad_cfg);
   return ret;
 + }
  
   /* Adjust only if VIN cannot scale */
   if (pix-width  mf-width * 2)
 @@ -1759,13 +1766,15 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
*/
   mf-width = VIN_MAX_WIDTH;
   mf-height = VIN_MAX_HEIGHT;
 + format.pad = icd-src_pad_idx;
   ret = v4l2_device_call_until_err(sd-v4l2_dev,
soc_camera_grp_id(icd),
 -  pad, set_fmt, pad_cfg,
 +  pad, set_fmt, pad_cfg,
format);
   if (ret  0) {
   dev_err(icd-parent,
   client try_fmt() = %d\n, ret);
 + v4l2_subdev_free_pad_config(pad_cfg);
   return ret;
   }
   }
 @@ -1776,6 +1785,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   pix-height = height;
   }
  
 + v4l2_subdev_free_pad_config(pad_cfg);
   return ret;
  }
  
 -- 
 1.7.10.4
 
--
To unsubscribe from this list: send the line unsubscribe linux-media in


Re: [PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt

2015-06-12 Thread Hans Verkuil
On 06/03/2015 03:59 PM, William Towle wrote:
 Fix rcar_vin_try_fmt to use the correct pad number when calling the
 subdev set_fmt. Previously pad number 0 was always used, resulting in
 EINVAL if the subdev cares about the pad number (e.g. ADV7612).
 
 Signed-off-by: William Towle william.to...@codethink.co.uk
 Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
 ---
  drivers/media/platform/soc_camera/rcar_vin.c |   20 +++-
  1 file changed, 15 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
 b/drivers/media/platform/soc_camera/rcar_vin.c
 index 00c1034..cc993bc 100644
 --- a/drivers/media/platform/soc_camera/rcar_vin.c
 +++ b/drivers/media/platform/soc_camera/rcar_vin.c
 @@ -1697,7 +1697,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   const struct soc_camera_format_xlate *xlate;
   struct v4l2_pix_format *pix = f-fmt.pix;
   struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
 - struct v4l2_subdev_pad_config pad_cfg;
 + struct v4l2_subdev_pad_config *pad_cfg;
   struct v4l2_subdev_format format = {
   .which = V4L2_SUBDEV_FORMAT_TRY,
   };
 @@ -1706,6 +1706,8 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   int width, height;
   int ret;
  
 + pad_cfg = v4l2_subdev_alloc_pad_config(sd);
 +
   xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
   if (!xlate) {
   xlate = icd-current_fmt;
 @@ -1734,10 +1736,15 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   mf-code = xlate-code;
   mf-colorspace = pix-colorspace;
  
 - ret = v4l2_device_call_until_err(sd-v4l2_dev, soc_camera_grp_id(icd),
 -  pad, set_fmt, pad_cfg, format);
 - if (ret  0)
 + format.pad = icd-src_pad_idx;
 + ret = v4l2_device_call_until_err(sd-v4l2_dev,
 + soc_camera_grp_id(icd), pad,
 + set_fmt, pad_cfg,
 + format);
 + if (ret  0) {
 + v4l2_subdev_free_pad_config(pad_cfg);
   return ret;

I would use a goto to the end of the function here.

 + }
  
   /* Adjust only if VIN cannot scale */
   if (pix-width  mf-width * 2)
 @@ -1759,13 +1766,15 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
*/
   mf-width = VIN_MAX_WIDTH;
   mf-height = VIN_MAX_HEIGHT;
 + format.pad = icd-src_pad_idx;
   ret = v4l2_device_call_until_err(sd-v4l2_dev,
soc_camera_grp_id(icd),
 -  pad, set_fmt, pad_cfg,
 +  pad, set_fmt, pad_cfg,
format);
   if (ret  0) {
   dev_err(icd-parent,
   client try_fmt() = %d\n, ret);
 + v4l2_subdev_free_pad_config(pad_cfg);
   return ret;

Ditto.

   }
   }
 @@ -1776,6 +1785,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   pix-height = height;
   }
  

With the error label here.

 + v4l2_subdev_free_pad_config(pad_cfg);
   return ret;
  }
  
 

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt

2015-06-03 Thread William Towle
Fix rcar_vin_try_fmt to use the correct pad number when calling the
subdev set_fmt. Previously pad number 0 was always used, resulting in
EINVAL if the subdev cares about the pad number (e.g. ADV7612).

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |   20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 00c1034..cc993bc 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1697,7 +1697,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
const struct soc_camera_format_xlate *xlate;
struct v4l2_pix_format *pix = f-fmt.pix;
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-   struct v4l2_subdev_pad_config pad_cfg;
+   struct v4l2_subdev_pad_config *pad_cfg;
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_TRY,
};
@@ -1706,6 +1706,8 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
int width, height;
int ret;
 
+   pad_cfg = v4l2_subdev_alloc_pad_config(sd);
+
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
xlate = icd-current_fmt;
@@ -1734,10 +1736,15 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
mf-code = xlate-code;
mf-colorspace = pix-colorspace;
 
-   ret = v4l2_device_call_until_err(sd-v4l2_dev, soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg, format);
-   if (ret  0)
+   format.pad = icd-src_pad_idx;
+   ret = v4l2_device_call_until_err(sd-v4l2_dev,
+   soc_camera_grp_id(icd), pad,
+   set_fmt, pad_cfg,
+   format);
+   if (ret  0) {
+   v4l2_subdev_free_pad_config(pad_cfg);
return ret;
+   }
 
/* Adjust only if VIN cannot scale */
if (pix-width  mf-width * 2)
@@ -1759,13 +1766,15 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
 */
mf-width = VIN_MAX_WIDTH;
mf-height = VIN_MAX_HEIGHT;
+   format.pad = icd-src_pad_idx;
ret = v4l2_device_call_until_err(sd-v4l2_dev,
 soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg,
+pad, set_fmt, pad_cfg,
 format);
if (ret  0) {
dev_err(icd-parent,
client try_fmt() = %d\n, ret);
+   v4l2_subdev_free_pad_config(pad_cfg);
return ret;
}
}
@@ -1776,6 +1785,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
pix-height = height;
}
 
+   v4l2_subdev_free_pad_config(pad_cfg);
return ret;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt

2015-05-29 Thread Hans Verkuil
On 05/27/2015 06:10 PM, William Towle wrote:
 Fix rcar_vin_try_fmt to use the correct pad number when calling the
 subdev set_fmt. Previously pad number 0 was always used, resulting in
 EINVAL if the subdev cares about the pad number (e.g. ADV7612).
 
 Signed-off-by: William Towle william.to...@codethink.co.uk
 Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
 ---
  drivers/media/platform/soc_camera/rcar_vin.c |   36 
 ++
  1 file changed, 31 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
 b/drivers/media/platform/soc_camera/rcar_vin.c
 index 0df3212..5523d04 100644
 --- a/drivers/media/platform/soc_camera/rcar_vin.c
 +++ b/drivers/media/platform/soc_camera/rcar_vin.c
 @@ -1702,7 +1702,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   const struct soc_camera_format_xlate *xlate;
   struct v4l2_pix_format *pix = f-fmt.pix;
   struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
 - struct v4l2_subdev_pad_config pad_cfg;
 + struct v4l2_subdev_pad_config *pad_cfg = NULL;
   struct v4l2_subdev_format format = {
   .which = V4L2_SUBDEV_FORMAT_TRY,
   };
 @@ -1710,6 +1710,11 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   __u32 pixfmt = pix-pixelformat;
   int width, height;
   int ret;
 +#if defined(CONFIG_MEDIA_CONTROLLER)
 + struct media_pad *remote_pad;
 +
 + pad_cfg = v4l2_subdev_alloc_pad_config(sd);
 +#endif
  
   xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
   if (!xlate) {
 @@ -1739,10 +1744,22 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   mf-code = xlate-code;
   mf-colorspace = pix-colorspace;
  
 - ret = v4l2_device_call_until_err(sd-v4l2_dev, soc_camera_grp_id(icd),
 -  pad, set_fmt, pad_cfg, format);
 - if (ret  0)
 +#if defined(CONFIG_MEDIA_CONTROLLER)
 + remote_pad = media_entity_remote_pad(
 + icd-vdev-entity.pads[0]);

Can't you store this when you setup the link in soc_camera_probe_finish? Rather 
then
looking it up every time?

Also, I think r-car should just depend on MEDIA_CONTROLLER, rather than adding 
these
#ifdef's everywhere. But that's up to you.

Regards,

Hans

 + format.pad = remote_pad-index;
 +#endif
 +
 + ret = v4l2_device_call_until_err(sd-v4l2_dev,
 + soc_camera_grp_id(icd), pad,
 + set_fmt, pad_cfg,
 + format);
 + if (ret  0) {
 +#if defined(CONFIG_MEDIA_CONTROLLER)
 + v4l2_subdev_free_pad_config(pad_cfg);
 +#endif
   return ret;
 + }
  
   /* Adjust only if VIN cannot scale */
   if (pix-width  mf-width * 2)
 @@ -1764,13 +1781,19 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
*/
   mf-width = VIN_MAX_WIDTH;
   mf-height = VIN_MAX_HEIGHT;
 +#if defined(CONFIG_MEDIA_CONTROLLER)
 + format.pad = remote_pad-index;
 +#endif
   ret = v4l2_device_call_until_err(sd-v4l2_dev,
soc_camera_grp_id(icd),
 -  pad, set_fmt, pad_cfg,
 +  pad, set_fmt, pad_cfg,
format);
   if (ret  0) {
   dev_err(icd-parent,
   client try_fmt() = %d\n, ret);
 +#if defined(CONFIG_MEDIA_CONTROLLER)
 + v4l2_subdev_free_pad_config(pad_cfg);
 +#endif
   return ret;
   }
   }
 @@ -1781,6 +1804,9 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
 *icd,
   pix-height = height;
   }
  
 +#if defined(CONFIG_MEDIA_CONTROLLER)
 + v4l2_subdev_free_pad_config(pad_cfg);
 +#endif
   return ret;
  }
  
 

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/15] media: rcar_vin: Use correct pad number in try_fmt

2015-05-27 Thread William Towle
Fix rcar_vin_try_fmt to use the correct pad number when calling the
subdev set_fmt. Previously pad number 0 was always used, resulting in
EINVAL if the subdev cares about the pad number (e.g. ADV7612).

Signed-off-by: William Towle william.to...@codethink.co.uk
Reviewed-by: Rob Taylor rob.tay...@codethink.co.uk
---
 drivers/media/platform/soc_camera/rcar_vin.c |   36 ++
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index 0df3212..5523d04 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -1702,7 +1702,7 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
const struct soc_camera_format_xlate *xlate;
struct v4l2_pix_format *pix = f-fmt.pix;
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-   struct v4l2_subdev_pad_config pad_cfg;
+   struct v4l2_subdev_pad_config *pad_cfg = NULL;
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_TRY,
};
@@ -1710,6 +1710,11 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
__u32 pixfmt = pix-pixelformat;
int width, height;
int ret;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   struct media_pad *remote_pad;
+
+   pad_cfg = v4l2_subdev_alloc_pad_config(sd);
+#endif
 
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
@@ -1739,10 +1744,22 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
mf-code = xlate-code;
mf-colorspace = pix-colorspace;
 
-   ret = v4l2_device_call_until_err(sd-v4l2_dev, soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg, format);
-   if (ret  0)
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   remote_pad = media_entity_remote_pad(
+   icd-vdev-entity.pads[0]);
+   format.pad = remote_pad-index;
+#endif
+
+   ret = v4l2_device_call_until_err(sd-v4l2_dev,
+   soc_camera_grp_id(icd), pad,
+   set_fmt, pad_cfg,
+   format);
+   if (ret  0) {
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   v4l2_subdev_free_pad_config(pad_cfg);
+#endif
return ret;
+   }
 
/* Adjust only if VIN cannot scale */
if (pix-width  mf-width * 2)
@@ -1764,13 +1781,19 @@ static int rcar_vin_try_fmt(struct soc_camera_device 
*icd,
 */
mf-width = VIN_MAX_WIDTH;
mf-height = VIN_MAX_HEIGHT;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   format.pad = remote_pad-index;
+#endif
ret = v4l2_device_call_until_err(sd-v4l2_dev,
 soc_camera_grp_id(icd),
-pad, set_fmt, pad_cfg,
+pad, set_fmt, pad_cfg,
 format);
if (ret  0) {
dev_err(icd-parent,
client try_fmt() = %d\n, ret);
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   v4l2_subdev_free_pad_config(pad_cfg);
+#endif
return ret;
}
}
@@ -1781,6 +1804,9 @@ static int rcar_vin_try_fmt(struct soc_camera_device *icd,
pix-height = height;
}
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+   v4l2_subdev_free_pad_config(pad_cfg);
+#endif
return ret;
 }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html