[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>
This commit is contained in:

committed by
Mauro Carvalho Chehab

parent
3d945be05a
commit
f7234138f1
@@ -829,17 +829,17 @@ static const struct isp_video_operations csi2_ispvideo_ops = {
|
||||
*/
|
||||
|
||||
static struct v4l2_mbus_framefmt *
|
||||
__csi2_get_format(struct isp_csi2_device *csi2, struct v4l2_subdev_fh *fh,
|
||||
__csi2_get_format(struct isp_csi2_device *csi2, struct v4l2_subdev_pad_config *cfg,
|
||||
unsigned int pad, enum v4l2_subdev_format_whence which)
|
||||
{
|
||||
if (which == V4L2_SUBDEV_FORMAT_TRY)
|
||||
return v4l2_subdev_get_try_format(fh, pad);
|
||||
return v4l2_subdev_get_try_format(&csi2->subdev, cfg, pad);
|
||||
else
|
||||
return &csi2->formats[pad];
|
||||
}
|
||||
|
||||
static void
|
||||
csi2_try_format(struct isp_csi2_device *csi2, struct v4l2_subdev_fh *fh,
|
||||
csi2_try_format(struct isp_csi2_device *csi2, struct v4l2_subdev_pad_config *cfg,
|
||||
unsigned int pad, struct v4l2_mbus_framefmt *fmt,
|
||||
enum v4l2_subdev_format_whence which)
|
||||
{
|
||||
@@ -869,7 +869,7 @@ csi2_try_format(struct isp_csi2_device *csi2, struct v4l2_subdev_fh *fh,
|
||||
* compression.
|
||||
*/
|
||||
pixelcode = fmt->code;
|
||||
format = __csi2_get_format(csi2, fh, CSI2_PAD_SINK, which);
|
||||
format = __csi2_get_format(csi2, cfg, CSI2_PAD_SINK, which);
|
||||
memcpy(fmt, format, sizeof(*fmt));
|
||||
|
||||
/*
|
||||
@@ -890,12 +890,12 @@ csi2_try_format(struct isp_csi2_device *csi2, struct v4l2_subdev_fh *fh,
|
||||
/*
|
||||
* csi2_enum_mbus_code - Handle pixel format enumeration
|
||||
* @sd : pointer to v4l2 subdev structure
|
||||
* @fh : V4L2 subdev file handle
|
||||
* @cfg: V4L2 subdev pad configuration
|
||||
* @code : pointer to v4l2_subdev_mbus_code_enum structure
|
||||
* return -EINVAL or zero on success
|
||||
*/
|
||||
static int csi2_enum_mbus_code(struct v4l2_subdev *sd,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_mbus_code_enum *code)
|
||||
{
|
||||
struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
|
||||
@@ -908,7 +908,7 @@ static int csi2_enum_mbus_code(struct v4l2_subdev *sd,
|
||||
|
||||
code->code = csi2_input_fmts[code->index];
|
||||
} else {
|
||||
format = __csi2_get_format(csi2, fh, CSI2_PAD_SINK,
|
||||
format = __csi2_get_format(csi2, cfg, CSI2_PAD_SINK,
|
||||
V4L2_SUBDEV_FORMAT_TRY);
|
||||
switch (code->index) {
|
||||
case 0:
|
||||
@@ -932,7 +932,7 @@ static int csi2_enum_mbus_code(struct v4l2_subdev *sd,
|
||||
}
|
||||
|
||||
static int csi2_enum_frame_size(struct v4l2_subdev *sd,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_frame_size_enum *fse)
|
||||
{
|
||||
struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
|
||||
@@ -944,7 +944,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd,
|
||||
format.code = fse->code;
|
||||
format.width = 1;
|
||||
format.height = 1;
|
||||
csi2_try_format(csi2, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
|
||||
csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
|
||||
fse->min_width = format.width;
|
||||
fse->min_height = format.height;
|
||||
|
||||
@@ -954,7 +954,7 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd,
|
||||
format.code = fse->code;
|
||||
format.width = -1;
|
||||
format.height = -1;
|
||||
csi2_try_format(csi2, fh, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
|
||||
csi2_try_format(csi2, cfg, fse->pad, &format, V4L2_SUBDEV_FORMAT_TRY);
|
||||
fse->max_width = format.width;
|
||||
fse->max_height = format.height;
|
||||
|
||||
@@ -964,17 +964,17 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd,
|
||||
/*
|
||||
* csi2_get_format - Handle get format by pads subdev method
|
||||
* @sd : pointer to v4l2 subdev structure
|
||||
* @fh : V4L2 subdev file handle
|
||||
* @cfg: V4L2 subdev pad configuration
|
||||
* @fmt: pointer to v4l2 subdev format structure
|
||||
* return -EINVAL or zero on success
|
||||
*/
|
||||
static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
|
||||
static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_format *fmt)
|
||||
{
|
||||
struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
|
||||
struct v4l2_mbus_framefmt *format;
|
||||
|
||||
format = __csi2_get_format(csi2, fh, fmt->pad, fmt->which);
|
||||
format = __csi2_get_format(csi2, cfg, fmt->pad, fmt->which);
|
||||
if (format == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -985,29 +985,29 @@ static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
|
||||
/*
|
||||
* csi2_set_format - Handle set format by pads subdev method
|
||||
* @sd : pointer to v4l2 subdev structure
|
||||
* @fh : V4L2 subdev file handle
|
||||
* @cfg: V4L2 subdev pad configuration
|
||||
* @fmt: pointer to v4l2 subdev format structure
|
||||
* return -EINVAL or zero on success
|
||||
*/
|
||||
static int csi2_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
|
||||
static int csi2_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_format *fmt)
|
||||
{
|
||||
struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
|
||||
struct v4l2_mbus_framefmt *format;
|
||||
|
||||
format = __csi2_get_format(csi2, fh, fmt->pad, fmt->which);
|
||||
format = __csi2_get_format(csi2, cfg, fmt->pad, fmt->which);
|
||||
if (format == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
csi2_try_format(csi2, fh, fmt->pad, &fmt->format, fmt->which);
|
||||
csi2_try_format(csi2, cfg, fmt->pad, &fmt->format, fmt->which);
|
||||
*format = fmt->format;
|
||||
|
||||
/* Propagate the format from sink to source */
|
||||
if (fmt->pad == CSI2_PAD_SINK) {
|
||||
format = __csi2_get_format(csi2, fh, CSI2_PAD_SOURCE,
|
||||
format = __csi2_get_format(csi2, cfg, CSI2_PAD_SOURCE,
|
||||
fmt->which);
|
||||
*format = fmt->format;
|
||||
csi2_try_format(csi2, fh, CSI2_PAD_SOURCE, format, fmt->which);
|
||||
csi2_try_format(csi2, cfg, CSI2_PAD_SOURCE, format, fmt->which);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1032,7 +1032,7 @@ static int csi2_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
|
||||
format.format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
|
||||
format.format.width = 4096;
|
||||
format.format.height = 4096;
|
||||
csi2_set_format(sd, fh, &format);
|
||||
csi2_set_format(sd, fh ? fh->pad : NULL, &format);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user