Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e80c473 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

[media] v4l2: replace s_mbus_fmt by set_fmt



The s_mbus_fmt video op is a duplicate of the pad op. Replace all uses
in sub-devices by the set_fmt() pad op.

Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 717fd5b4
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -296,11 +296,16 @@ static int adv7170_get_fmt(struct v4l2_subdev *sd,
	return 0;
}

static int adv7170_s_fmt(struct v4l2_subdev *sd,
				struct v4l2_mbus_framefmt *mf)
static int adv7170_set_fmt(struct v4l2_subdev *sd,
		struct v4l2_subdev_pad_config *cfg,
		struct v4l2_subdev_format *format)
{
	struct v4l2_mbus_framefmt *mf = &format->format;
	u8 val = adv7170_read(sd, 0x7);
	int ret;
	int ret = 0;

	if (format->pad)
		return -EINVAL;

	switch (mf->code) {
	case MEDIA_BUS_FMT_UYVY8_2X8:
@@ -317,6 +322,7 @@ static int adv7170_s_fmt(struct v4l2_subdev *sd,
		return -EINVAL;
	}

	if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
		ret = adv7170_write(sd, 0x7, val);

	return ret;
@@ -327,12 +333,12 @@ static int adv7170_s_fmt(struct v4l2_subdev *sd,
static const struct v4l2_subdev_video_ops adv7170_video_ops = {
	.s_std_output = adv7170_s_std_output,
	.s_routing = adv7170_s_routing,
	.s_mbus_fmt = adv7170_s_fmt,
};

static const struct v4l2_subdev_pad_ops adv7170_pad_ops = {
	.enum_mbus_code = adv7170_enum_mbus_code,
	.get_fmt = adv7170_get_fmt,
	.set_fmt = adv7170_set_fmt,
};

static const struct v4l2_subdev_ops adv7170_ops = {
+11 −5
Original line number Diff line number Diff line
@@ -334,11 +334,16 @@ static int adv7175_get_fmt(struct v4l2_subdev *sd,
	return 0;
}

static int adv7175_s_fmt(struct v4l2_subdev *sd,
				struct v4l2_mbus_framefmt *mf)
static int adv7175_set_fmt(struct v4l2_subdev *sd,
		struct v4l2_subdev_pad_config *cfg,
		struct v4l2_subdev_format *format)
{
	struct v4l2_mbus_framefmt *mf = &format->format;
	u8 val = adv7175_read(sd, 0x7);
	int ret;
	int ret = 0;

	if (format->pad)
		return -EINVAL;

	switch (mf->code) {
	case MEDIA_BUS_FMT_UYVY8_2X8:
@@ -355,6 +360,7 @@ static int adv7175_s_fmt(struct v4l2_subdev *sd,
		return -EINVAL;
	}

	if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
		ret = adv7175_write(sd, 0x7, val);

	return ret;
@@ -380,12 +386,12 @@ static const struct v4l2_subdev_core_ops adv7175_core_ops = {
static const struct v4l2_subdev_video_ops adv7175_video_ops = {
	.s_std_output = adv7175_s_std_output,
	.s_routing = adv7175_s_routing,
	.s_mbus_fmt = adv7175_s_fmt,
};

static const struct v4l2_subdev_pad_ops adv7175_pad_ops = {
	.enum_mbus_code = adv7175_enum_mbus_code,
	.get_fmt = adv7175_get_fmt,
	.set_fmt = adv7175_set_fmt,
};

static const struct v4l2_subdev_ops adv7175_ops = {
+12 −3
Original line number Diff line number Diff line
@@ -1366,14 +1366,17 @@ static int cx25840_s_ctrl(struct v4l2_ctrl *ctrl)

/* ----------------------------------------------------------------------- */

static int cx25840_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt)
static int cx25840_set_fmt(struct v4l2_subdev *sd,
		struct v4l2_subdev_pad_config *cfg,
		struct v4l2_subdev_format *format)
{
	struct v4l2_mbus_framefmt *fmt = &format->format;
	struct cx25840_state *state = to_state(sd);
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	int HSC, VSC, Vsrc, Hsrc, filter, Vlines;
	int is_50Hz = !(state->std & V4L2_STD_525_60);

	if (fmt->code != MEDIA_BUS_FMT_FIXED)
	if (format->pad || fmt->code != MEDIA_BUS_FMT_FIXED)
		return -EINVAL;

	fmt->field = V4L2_FIELD_INTERLACED;
@@ -1403,6 +1406,8 @@ static int cx25840_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt
				fmt->width, fmt->height);
		return -ERANGE;
	}
	if (format->which == V4L2_SUBDEV_FORMAT_TRY)
		return 0;

	HSC = (Hsrc * (1 << 20)) / fmt->width - (1 << 20);
	VSC = (1 << 16) - (Vsrc * (1 << 9) / Vlines - (1 << 9));
@@ -5068,7 +5073,6 @@ static const struct v4l2_subdev_video_ops cx25840_video_ops = {
	.s_std = cx25840_s_std,
	.g_std = cx25840_g_std,
	.s_routing = cx25840_s_video_routing,
	.s_mbus_fmt = cx25840_s_mbus_fmt,
	.s_stream = cx25840_s_stream,
	.g_input_status = cx25840_g_input_status,
};
@@ -5080,12 +5084,17 @@ static const struct v4l2_subdev_vbi_ops cx25840_vbi_ops = {
	.g_sliced_fmt = cx25840_g_sliced_fmt,
};

static const struct v4l2_subdev_pad_ops cx25840_pad_ops = {
	.set_fmt = cx25840_set_fmt,
};

static const struct v4l2_subdev_ops cx25840_ops = {
	.core = &cx25840_core_ops,
	.tuner = &cx25840_tuner_ops,
	.audio = &cx25840_audio_ops,
	.video = &cx25840_video_ops,
	.vbi = &cx25840_vbi_ops,
	.pad = &cx25840_pad_ops,
	.ir = &cx25840_ir_ops,
};

+13 −3
Original line number Diff line number Diff line
@@ -1170,12 +1170,18 @@ static int saa711x_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_f
	return 0;
}

static int saa711x_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt)
static int saa711x_set_fmt(struct v4l2_subdev *sd,
		struct v4l2_subdev_pad_config *cfg,
		struct v4l2_subdev_format *format)
{
	if (fmt->code != MEDIA_BUS_FMT_FIXED)
	struct v4l2_mbus_framefmt *fmt = &format->format;

	if (format->pad || fmt->code != MEDIA_BUS_FMT_FIXED)
		return -EINVAL;
	fmt->field = V4L2_FIELD_INTERLACED;
	fmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
	if (format->which == V4L2_SUBDEV_FORMAT_TRY)
		return 0;
	return saa711x_set_size(sd, fmt->width, fmt->height);
}

@@ -1603,7 +1609,6 @@ static const struct v4l2_subdev_video_ops saa711x_video_ops = {
	.s_std = saa711x_s_std,
	.s_routing = saa711x_s_routing,
	.s_crystal_freq = saa711x_s_crystal_freq,
	.s_mbus_fmt = saa711x_s_mbus_fmt,
	.s_stream = saa711x_s_stream,
	.querystd = saa711x_querystd,
	.g_input_status = saa711x_g_input_status,
@@ -1617,12 +1622,17 @@ static const struct v4l2_subdev_vbi_ops saa711x_vbi_ops = {
	.s_raw_fmt = saa711x_s_raw_fmt,
};

static const struct v4l2_subdev_pad_ops saa711x_pad_ops = {
	.set_fmt = saa711x_set_fmt,
};

static const struct v4l2_subdev_ops saa711x_ops = {
	.core = &saa711x_core_ops,
	.tuner = &saa711x_tuner_ops,
	.audio = &saa711x_audio_ops,
	.video = &saa711x_video_ops,
	.vbi = &saa711x_vbi_ops,
	.pad = &saa711x_pad_ops,
};

#define CHIP_VER_SIZE	16
+13 −3
Original line number Diff line number Diff line
@@ -992,13 +992,16 @@ static int saa717x_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_regi
}
#endif

static int saa717x_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt)
static int saa717x_set_fmt(struct v4l2_subdev *sd,
		struct v4l2_subdev_pad_config *cfg,
		struct v4l2_subdev_format *format)
{
	struct v4l2_mbus_framefmt *fmt = &format->format;
	int prescale, h_scale, v_scale;

	v4l2_dbg(1, debug, sd, "decoder set size\n");

	if (fmt->code != MEDIA_BUS_FMT_FIXED)
	if (format->pad || fmt->code != MEDIA_BUS_FMT_FIXED)
		return -EINVAL;

	/* FIXME need better bounds checking here */
@@ -1010,6 +1013,9 @@ static int saa717x_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt
	fmt->field = V4L2_FIELD_INTERLACED;
	fmt->colorspace = V4L2_COLORSPACE_SMPTE170M;

	if (format->which == V4L2_SUBDEV_FORMAT_TRY)
		return 0;

	/* scaling setting */
	/* NTSC and interlace only */
	prescale = SAA717X_NTSC_WIDTH / fmt->width;
@@ -1217,7 +1223,6 @@ static const struct v4l2_subdev_tuner_ops saa717x_tuner_ops = {
static const struct v4l2_subdev_video_ops saa717x_video_ops = {
	.s_std = saa717x_s_std,
	.s_routing = saa717x_s_video_routing,
	.s_mbus_fmt = saa717x_s_mbus_fmt,
	.s_stream = saa717x_s_stream,
};

@@ -1225,11 +1230,16 @@ static const struct v4l2_subdev_audio_ops saa717x_audio_ops = {
	.s_routing = saa717x_s_audio_routing,
};

static const struct v4l2_subdev_pad_ops saa717x_pad_ops = {
	.set_fmt = saa717x_set_fmt,
};

static const struct v4l2_subdev_ops saa717x_ops = {
	.core = &saa717x_core_ops,
	.tuner = &saa717x_tuner_ops,
	.audio = &saa717x_audio_ops,
	.video = &saa717x_video_ops,
	.pad = &saa717x_pad_ops,
};

/* ----------------------------------------------------------------------- */
Loading