[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>
此提交包含在:
@@ -1557,7 +1557,7 @@ static int smiapp_set_stream(struct v4l2_subdev *subdev, int enable)
|
||||
}
|
||||
|
||||
static int smiapp_enum_mbus_code(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_mbus_code_enum *code)
|
||||
{
|
||||
struct i2c_client *client = v4l2_get_subdevdata(subdev);
|
||||
@@ -1611,13 +1611,13 @@ static u32 __smiapp_get_mbus_code(struct v4l2_subdev *subdev,
|
||||
}
|
||||
|
||||
static int __smiapp_get_format(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_format *fmt)
|
||||
{
|
||||
struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
|
||||
|
||||
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
|
||||
fmt->format = *v4l2_subdev_get_try_format(fh, fmt->pad);
|
||||
fmt->format = *v4l2_subdev_get_try_format(subdev, cfg, fmt->pad);
|
||||
} else {
|
||||
struct v4l2_rect *r;
|
||||
|
||||
@@ -1636,21 +1636,21 @@ static int __smiapp_get_format(struct v4l2_subdev *subdev,
|
||||
}
|
||||
|
||||
static int smiapp_get_format(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_format *fmt)
|
||||
{
|
||||
struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
|
||||
int rval;
|
||||
|
||||
mutex_lock(&sensor->mutex);
|
||||
rval = __smiapp_get_format(subdev, fh, fmt);
|
||||
rval = __smiapp_get_format(subdev, cfg, fmt);
|
||||
mutex_unlock(&sensor->mutex);
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
static void smiapp_get_crop_compose(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_rect **crops,
|
||||
struct v4l2_rect **comps, int which)
|
||||
{
|
||||
@@ -1666,12 +1666,12 @@ static void smiapp_get_crop_compose(struct v4l2_subdev *subdev,
|
||||
} else {
|
||||
if (crops) {
|
||||
for (i = 0; i < subdev->entity.num_pads; i++) {
|
||||
crops[i] = v4l2_subdev_get_try_crop(fh, i);
|
||||
crops[i] = v4l2_subdev_get_try_crop(subdev, cfg, i);
|
||||
BUG_ON(!crops[i]);
|
||||
}
|
||||
}
|
||||
if (comps) {
|
||||
*comps = v4l2_subdev_get_try_compose(fh,
|
||||
*comps = v4l2_subdev_get_try_compose(subdev, cfg,
|
||||
SMIAPP_PAD_SINK);
|
||||
BUG_ON(!*comps);
|
||||
}
|
||||
@@ -1680,14 +1680,14 @@ static void smiapp_get_crop_compose(struct v4l2_subdev *subdev,
|
||||
|
||||
/* Changes require propagation only on sink pad. */
|
||||
static void smiapp_propagate(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh, int which,
|
||||
struct v4l2_subdev_pad_config *cfg, int which,
|
||||
int target)
|
||||
{
|
||||
struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
|
||||
struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
|
||||
struct v4l2_rect *comp, *crops[SMIAPP_PADS];
|
||||
|
||||
smiapp_get_crop_compose(subdev, fh, crops, &comp, which);
|
||||
smiapp_get_crop_compose(subdev, cfg, crops, &comp, which);
|
||||
|
||||
switch (target) {
|
||||
case V4L2_SEL_TGT_CROP:
|
||||
@@ -1730,7 +1730,7 @@ static const struct smiapp_csi_data_format
|
||||
}
|
||||
|
||||
static int smiapp_set_format_source(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_format *fmt)
|
||||
{
|
||||
struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
|
||||
@@ -1741,7 +1741,7 @@ static int smiapp_set_format_source(struct v4l2_subdev *subdev,
|
||||
unsigned int i;
|
||||
int rval;
|
||||
|
||||
rval = __smiapp_get_format(subdev, fh, fmt);
|
||||
rval = __smiapp_get_format(subdev, cfg, fmt);
|
||||
if (rval)
|
||||
return rval;
|
||||
|
||||
@@ -1783,7 +1783,7 @@ static int smiapp_set_format_source(struct v4l2_subdev *subdev,
|
||||
}
|
||||
|
||||
static int smiapp_set_format(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_format *fmt)
|
||||
{
|
||||
struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
|
||||
@@ -1795,7 +1795,7 @@ static int smiapp_set_format(struct v4l2_subdev *subdev,
|
||||
if (fmt->pad == ssd->source_pad) {
|
||||
int rval;
|
||||
|
||||
rval = smiapp_set_format_source(subdev, fh, fmt);
|
||||
rval = smiapp_set_format_source(subdev, cfg, fmt);
|
||||
|
||||
mutex_unlock(&sensor->mutex);
|
||||
|
||||
@@ -1817,7 +1817,7 @@ static int smiapp_set_format(struct v4l2_subdev *subdev,
|
||||
sensor->limits[SMIAPP_LIMIT_MIN_Y_OUTPUT_SIZE],
|
||||
sensor->limits[SMIAPP_LIMIT_MAX_Y_OUTPUT_SIZE]);
|
||||
|
||||
smiapp_get_crop_compose(subdev, fh, crops, NULL, fmt->which);
|
||||
smiapp_get_crop_compose(subdev, cfg, crops, NULL, fmt->which);
|
||||
|
||||
crops[ssd->sink_pad]->left = 0;
|
||||
crops[ssd->sink_pad]->top = 0;
|
||||
@@ -1825,7 +1825,7 @@ static int smiapp_set_format(struct v4l2_subdev *subdev,
|
||||
crops[ssd->sink_pad]->height = fmt->format.height;
|
||||
if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE)
|
||||
ssd->sink_fmt = *crops[ssd->sink_pad];
|
||||
smiapp_propagate(subdev, fh, fmt->which,
|
||||
smiapp_propagate(subdev, cfg, fmt->which,
|
||||
V4L2_SEL_TGT_CROP);
|
||||
|
||||
mutex_unlock(&sensor->mutex);
|
||||
@@ -1878,7 +1878,7 @@ static int scaling_goodness(struct v4l2_subdev *subdev, int w, int ask_w,
|
||||
}
|
||||
|
||||
static void smiapp_set_compose_binner(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_selection *sel,
|
||||
struct v4l2_rect **crops,
|
||||
struct v4l2_rect *comp)
|
||||
@@ -1926,7 +1926,7 @@ static void smiapp_set_compose_binner(struct v4l2_subdev *subdev,
|
||||
* result.
|
||||
*/
|
||||
static void smiapp_set_compose_scaler(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_selection *sel,
|
||||
struct v4l2_rect **crops,
|
||||
struct v4l2_rect *comp)
|
||||
@@ -2042,25 +2042,25 @@ static void smiapp_set_compose_scaler(struct v4l2_subdev *subdev,
|
||||
}
|
||||
/* We're only called on source pads. This function sets scaling. */
|
||||
static int smiapp_set_compose(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_selection *sel)
|
||||
{
|
||||
struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
|
||||
struct smiapp_subdev *ssd = to_smiapp_subdev(subdev);
|
||||
struct v4l2_rect *comp, *crops[SMIAPP_PADS];
|
||||
|
||||
smiapp_get_crop_compose(subdev, fh, crops, &comp, sel->which);
|
||||
smiapp_get_crop_compose(subdev, cfg, crops, &comp, sel->which);
|
||||
|
||||
sel->r.top = 0;
|
||||
sel->r.left = 0;
|
||||
|
||||
if (ssd == sensor->binner)
|
||||
smiapp_set_compose_binner(subdev, fh, sel, crops, comp);
|
||||
smiapp_set_compose_binner(subdev, cfg, sel, crops, comp);
|
||||
else
|
||||
smiapp_set_compose_scaler(subdev, fh, sel, crops, comp);
|
||||
smiapp_set_compose_scaler(subdev, cfg, sel, crops, comp);
|
||||
|
||||
*comp = sel->r;
|
||||
smiapp_propagate(subdev, fh, sel->which,
|
||||
smiapp_propagate(subdev, cfg, sel->which,
|
||||
V4L2_SEL_TGT_COMPOSE);
|
||||
|
||||
if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE)
|
||||
@@ -2113,7 +2113,7 @@ static int __smiapp_sel_supported(struct v4l2_subdev *subdev,
|
||||
}
|
||||
|
||||
static int smiapp_set_crop(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_selection *sel)
|
||||
{
|
||||
struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
|
||||
@@ -2121,7 +2121,7 @@ static int smiapp_set_crop(struct v4l2_subdev *subdev,
|
||||
struct v4l2_rect *src_size, *crops[SMIAPP_PADS];
|
||||
struct v4l2_rect _r;
|
||||
|
||||
smiapp_get_crop_compose(subdev, fh, crops, NULL, sel->which);
|
||||
smiapp_get_crop_compose(subdev, cfg, crops, NULL, sel->which);
|
||||
|
||||
if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
|
||||
if (sel->pad == ssd->sink_pad)
|
||||
@@ -2132,15 +2132,15 @@ static int smiapp_set_crop(struct v4l2_subdev *subdev,
|
||||
if (sel->pad == ssd->sink_pad) {
|
||||
_r.left = 0;
|
||||
_r.top = 0;
|
||||
_r.width = v4l2_subdev_get_try_format(fh, sel->pad)
|
||||
_r.width = v4l2_subdev_get_try_format(subdev, cfg, sel->pad)
|
||||
->width;
|
||||
_r.height = v4l2_subdev_get_try_format(fh, sel->pad)
|
||||
_r.height = v4l2_subdev_get_try_format(subdev, cfg, sel->pad)
|
||||
->height;
|
||||
src_size = &_r;
|
||||
} else {
|
||||
src_size =
|
||||
v4l2_subdev_get_try_compose(
|
||||
fh, ssd->sink_pad);
|
||||
subdev, cfg, ssd->sink_pad);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2158,14 +2158,14 @@ static int smiapp_set_crop(struct v4l2_subdev *subdev,
|
||||
*crops[sel->pad] = sel->r;
|
||||
|
||||
if (ssd != sensor->pixel_array && sel->pad == SMIAPP_PAD_SINK)
|
||||
smiapp_propagate(subdev, fh, sel->which,
|
||||
smiapp_propagate(subdev, cfg, sel->which,
|
||||
V4L2_SEL_TGT_CROP);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __smiapp_get_selection(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_selection *sel)
|
||||
{
|
||||
struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
|
||||
@@ -2178,13 +2178,13 @@ static int __smiapp_get_selection(struct v4l2_subdev *subdev,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
smiapp_get_crop_compose(subdev, fh, crops, &comp, sel->which);
|
||||
smiapp_get_crop_compose(subdev, cfg, crops, &comp, sel->which);
|
||||
|
||||
if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
|
||||
sink_fmt = ssd->sink_fmt;
|
||||
} else {
|
||||
struct v4l2_mbus_framefmt *fmt =
|
||||
v4l2_subdev_get_try_format(fh, ssd->sink_pad);
|
||||
v4l2_subdev_get_try_format(subdev, cfg, ssd->sink_pad);
|
||||
|
||||
sink_fmt.left = 0;
|
||||
sink_fmt.top = 0;
|
||||
@@ -2220,20 +2220,20 @@ static int __smiapp_get_selection(struct v4l2_subdev *subdev,
|
||||
}
|
||||
|
||||
static int smiapp_get_selection(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_selection *sel)
|
||||
{
|
||||
struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
|
||||
int rval;
|
||||
|
||||
mutex_lock(&sensor->mutex);
|
||||
rval = __smiapp_get_selection(subdev, fh, sel);
|
||||
rval = __smiapp_get_selection(subdev, cfg, sel);
|
||||
mutex_unlock(&sensor->mutex);
|
||||
|
||||
return rval;
|
||||
}
|
||||
static int smiapp_set_selection(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_fh *fh,
|
||||
struct v4l2_subdev_pad_config *cfg,
|
||||
struct v4l2_subdev_selection *sel)
|
||||
{
|
||||
struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
|
||||
@@ -2259,10 +2259,10 @@ static int smiapp_set_selection(struct v4l2_subdev *subdev,
|
||||
|
||||
switch (sel->target) {
|
||||
case V4L2_SEL_TGT_CROP:
|
||||
ret = smiapp_set_crop(subdev, fh, sel);
|
||||
ret = smiapp_set_crop(subdev, cfg, sel);
|
||||
break;
|
||||
case V4L2_SEL_TGT_COMPOSE:
|
||||
ret = smiapp_set_compose(subdev, fh, sel);
|
||||
ret = smiapp_set_compose(subdev, cfg, sel);
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
@@ -2841,8 +2841,8 @@ static int smiapp_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
|
||||
|
||||
for (i = 0; i < ssd->npads; i++) {
|
||||
struct v4l2_mbus_framefmt *try_fmt =
|
||||
v4l2_subdev_get_try_format(fh, i);
|
||||
struct v4l2_rect *try_crop = v4l2_subdev_get_try_crop(fh, i);
|
||||
v4l2_subdev_get_try_format(sd, fh->pad, i);
|
||||
struct v4l2_rect *try_crop = v4l2_subdev_get_try_crop(sd, fh->pad, i);
|
||||
struct v4l2_rect *try_comp;
|
||||
|
||||
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)
|
||||
if (ssd != sensor->pixel_array)
|
||||
continue;
|
||||
|
||||
try_comp = v4l2_subdev_get_try_compose(fh, i);
|
||||
try_comp = v4l2_subdev_get_try_compose(sd, fh->pad, i);
|
||||
*try_comp = *try_crop;
|
||||
}
|
||||
|
||||
|
新增問題並參考
封鎖使用者