media: i2c: Use accessors for pad config 'try_*' fields
The 'try_*' fields of the v4l2_subdev_pad_config structure are meant to be accessed through helper functions. Replace direct access with usage of the v4l2_subdev_get_pad_format(), v4l2_subdev_get_pad_crop() and v4l2_subdev_get_pad_compose() helpers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
parent
0623979d83
commit
fd17e3a9a7
@ -443,7 +443,7 @@ static int adv7183_set_fmt(struct v4l2_subdev *sd,
|
||||
if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
|
||||
decoder->fmt = *fmt;
|
||||
else
|
||||
sd_state->pads->try_fmt = *fmt;
|
||||
*v4l2_subdev_get_pad_format(sd, sd_state, 0) = *fmt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1018,8 +1018,8 @@ static int __imx274_change_compose(struct stimx274 *imx274,
|
||||
int best_goodness = INT_MIN;
|
||||
|
||||
if (which == V4L2_SUBDEV_FORMAT_TRY) {
|
||||
cur_crop = &sd_state->pads->try_crop;
|
||||
tgt_fmt = &sd_state->pads->try_fmt;
|
||||
cur_crop = v4l2_subdev_get_pad_crop(&imx274->sd, sd_state, 0);
|
||||
tgt_fmt = v4l2_subdev_get_pad_format(&imx274->sd, sd_state, 0);
|
||||
} else {
|
||||
cur_crop = &imx274->crop;
|
||||
tgt_fmt = &imx274->format;
|
||||
@ -1112,7 +1112,7 @@ static int imx274_set_fmt(struct v4l2_subdev *sd,
|
||||
*/
|
||||
fmt->field = V4L2_FIELD_NONE;
|
||||
if (format->which == V4L2_SUBDEV_FORMAT_TRY)
|
||||
sd_state->pads->try_fmt = *fmt;
|
||||
*v4l2_subdev_get_pad_format(sd, sd_state, 0) = *fmt;
|
||||
else
|
||||
imx274->format = *fmt;
|
||||
|
||||
@ -1143,8 +1143,8 @@ static int imx274_get_selection(struct v4l2_subdev *sd,
|
||||
}
|
||||
|
||||
if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
|
||||
src_crop = &sd_state->pads->try_crop;
|
||||
src_fmt = &sd_state->pads->try_fmt;
|
||||
src_crop = v4l2_subdev_get_pad_crop(sd, sd_state, 0);
|
||||
src_fmt = v4l2_subdev_get_pad_format(sd, sd_state, 0);
|
||||
} else {
|
||||
src_crop = &imx274->crop;
|
||||
src_fmt = &imx274->format;
|
||||
@ -1215,7 +1215,7 @@ static int imx274_set_selection_crop(struct stimx274 *imx274,
|
||||
sel->r = new_crop;
|
||||
|
||||
if (sel->which == V4L2_SUBDEV_FORMAT_TRY)
|
||||
tgt_crop = &sd_state->pads->try_crop;
|
||||
tgt_crop = v4l2_subdev_get_pad_crop(&imx274->sd, sd_state, 0);
|
||||
else
|
||||
tgt_crop = &imx274->crop;
|
||||
|
||||
|
@ -405,7 +405,7 @@ static int mt9m001_set_fmt(struct v4l2_subdev *sd,
|
||||
|
||||
if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
|
||||
return mt9m001_s_fmt(sd, fmt, mf);
|
||||
sd_state->pads->try_fmt = *mf;
|
||||
*v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -671,7 +671,7 @@ static int mt9m111_set_fmt(struct v4l2_subdev *sd,
|
||||
mf->xfer_func = V4L2_XFER_FUNC_DEFAULT;
|
||||
|
||||
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
|
||||
sd_state->pads->try_fmt = *mf;
|
||||
*v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -982,7 +982,7 @@ static int mt9t112_set_fmt(struct v4l2_subdev *sd,
|
||||
|
||||
if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
|
||||
return mt9t112_s_fmt(sd, mf);
|
||||
sd_state->pads->try_fmt = *mf;
|
||||
*v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ static int mt9v011_set_fmt(struct v4l2_subdev *sd,
|
||||
|
||||
set_res(sd);
|
||||
} else {
|
||||
sd_state->pads->try_fmt = *fmt;
|
||||
*v4l2_subdev_get_pad_format(sd, sd_state, 0) = *fmt;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -951,7 +951,7 @@ done:
|
||||
static int mt9v111_init_cfg(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_state *sd_state)
|
||||
{
|
||||
sd_state->pads->try_fmt = mt9v111_def_fmt;
|
||||
*v4l2_subdev_get_pad_format(subdev, sd_state, 0) = mt9v111_def_fmt;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -988,7 +988,7 @@ static int ov2640_set_fmt(struct v4l2_subdev *sd,
|
||||
/* select format */
|
||||
priv->cfmt_code = mf->code;
|
||||
} else {
|
||||
sd_state->pads->try_fmt = *mf;
|
||||
*v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
|
||||
}
|
||||
out:
|
||||
mutex_unlock(&priv->lock);
|
||||
|
@ -760,9 +760,9 @@ static int ov2680_init_cfg(struct v4l2_subdev *sd,
|
||||
{
|
||||
struct ov2680_dev *sensor = to_ov2680_dev(sd);
|
||||
|
||||
sd_state->pads[0].try_crop = ov2680_default_crop;
|
||||
*v4l2_subdev_get_pad_crop(sd, sd_state, 0) = ov2680_default_crop;
|
||||
|
||||
ov2680_fill_format(sensor, &sd_state->pads[0].try_fmt,
|
||||
ov2680_fill_format(sensor, v4l2_subdev_get_pad_format(sd, sd_state, 0),
|
||||
OV2680_DEFAULT_WIDTH, OV2680_DEFAULT_HEIGHT);
|
||||
return 0;
|
||||
}
|
||||
|
@ -476,7 +476,7 @@ static int ov6650_get_selection(struct v4l2_subdev *sd,
|
||||
|
||||
if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
|
||||
/* pre-select try crop rectangle */
|
||||
rect = &sd_state->pads->try_crop;
|
||||
rect = v4l2_subdev_get_pad_crop(sd, sd_state, 0);
|
||||
|
||||
} else {
|
||||
/* pre-select active crop rectangle */
|
||||
@ -531,8 +531,10 @@ static int ov6650_set_selection(struct v4l2_subdev *sd,
|
||||
ov6650_bind_align_crop_rectangle(&sel->r);
|
||||
|
||||
if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
|
||||
struct v4l2_rect *crop = &sd_state->pads->try_crop;
|
||||
struct v4l2_mbus_framefmt *mf = &sd_state->pads->try_fmt;
|
||||
struct v4l2_rect *crop =
|
||||
v4l2_subdev_get_pad_crop(sd, sd_state, 0);
|
||||
struct v4l2_mbus_framefmt *mf =
|
||||
v4l2_subdev_get_pad_format(sd, sd_state, 0);
|
||||
/* detect current pad config scaling factor */
|
||||
bool half_scale = !is_unscaled_ok(mf->width, mf->height, crop);
|
||||
|
||||
@ -588,9 +590,12 @@ static int ov6650_get_fmt(struct v4l2_subdev *sd,
|
||||
|
||||
/* update media bus format code and frame size */
|
||||
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
|
||||
mf->width = sd_state->pads->try_fmt.width;
|
||||
mf->height = sd_state->pads->try_fmt.height;
|
||||
mf->code = sd_state->pads->try_fmt.code;
|
||||
struct v4l2_mbus_framefmt *try_fmt =
|
||||
v4l2_subdev_get_pad_format(sd, sd_state, 0);
|
||||
|
||||
mf->width = try_fmt->width;
|
||||
mf->height = try_fmt->height;
|
||||
mf->code = try_fmt->code;
|
||||
|
||||
} else {
|
||||
mf->width = priv->rect.width >> priv->half_scale;
|
||||
@ -717,23 +722,26 @@ static int ov6650_set_fmt(struct v4l2_subdev *sd,
|
||||
}
|
||||
|
||||
if (format->which == V4L2_SUBDEV_FORMAT_TRY)
|
||||
crop = &sd_state->pads->try_crop;
|
||||
crop = v4l2_subdev_get_pad_crop(sd, sd_state, 0);
|
||||
else
|
||||
crop = &priv->rect;
|
||||
|
||||
half_scale = !is_unscaled_ok(mf->width, mf->height, crop);
|
||||
|
||||
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
|
||||
struct v4l2_mbus_framefmt *try_fmt =
|
||||
v4l2_subdev_get_pad_format(sd, sd_state, 0);
|
||||
|
||||
/* store new mbus frame format code and size in pad config */
|
||||
sd_state->pads->try_fmt.width = crop->width >> half_scale;
|
||||
sd_state->pads->try_fmt.height = crop->height >> half_scale;
|
||||
sd_state->pads->try_fmt.code = mf->code;
|
||||
try_fmt->width = crop->width >> half_scale;
|
||||
try_fmt->height = crop->height >> half_scale;
|
||||
try_fmt->code = mf->code;
|
||||
|
||||
/* return default mbus frame format updated with pad config */
|
||||
*mf = ov6650_def_fmt;
|
||||
mf->width = sd_state->pads->try_fmt.width;
|
||||
mf->height = sd_state->pads->try_fmt.height;
|
||||
mf->code = sd_state->pads->try_fmt.code;
|
||||
mf->width = try_fmt->width;
|
||||
mf->height = try_fmt->height;
|
||||
mf->code = try_fmt->code;
|
||||
|
||||
} else {
|
||||
int ret = 0;
|
||||
|
@ -1220,7 +1220,7 @@ static int ov772x_set_fmt(struct v4l2_subdev *sd,
|
||||
mf->xfer_func = V4L2_XFER_FUNC_DEFAULT;
|
||||
|
||||
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
|
||||
sd_state->pads->try_fmt = *mf;
|
||||
*v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -547,7 +547,7 @@ static int ov9640_set_fmt(struct v4l2_subdev *sd,
|
||||
if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
|
||||
return ov9640_s_fmt(sd, mf);
|
||||
|
||||
sd_state->pads->try_fmt = *mf;
|
||||
*v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1009,7 +1009,7 @@ static int rj54n1_set_fmt(struct v4l2_subdev *sd,
|
||||
&mf->height, 84, RJ54N1_MAX_HEIGHT, align, 0);
|
||||
|
||||
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
|
||||
sd_state->pads->try_fmt = *mf;
|
||||
*v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -595,7 +595,7 @@ static int saa6752hs_set_fmt(struct v4l2_subdev *sd,
|
||||
f->colorspace = V4L2_COLORSPACE_SMPTE170M;
|
||||
|
||||
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
|
||||
sd_state->pads->try_fmt = *f;
|
||||
*v4l2_subdev_get_pad_format(sd, sd_state, 0) = *f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -829,7 +829,7 @@ static int tw9910_set_fmt(struct v4l2_subdev *sd,
|
||||
if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
|
||||
return tw9910_s_fmt(sd, mf);
|
||||
|
||||
sd_state->pads->try_fmt = *mf;
|
||||
*v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user