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

Commit a5f04589 authored by Steve Longerbeam's avatar Steve Longerbeam Committed by Mauro Carvalho Chehab
Browse files

media: imx: mipi csi-2: Fix set_fmt try



csi2_set_fmt() was setting the try_fmt only on the first pad, and pad
index was ignored. Fix by introducing __csi2_get_fmt().

Signed-off-by: default avatarSteve Longerbeam <steve_longerbeam@mentor.com>
Reviewed-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 46c121e0
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -447,6 +447,16 @@ static int csi2_link_setup(struct media_entity *entity,
	return ret;
}

static struct v4l2_mbus_framefmt *
__csi2_get_fmt(struct csi2_dev *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(&csi2->sd, cfg, pad);
	else
		return &csi2->format_mbus;
}

static int csi2_get_fmt(struct v4l2_subdev *sd,
			struct v4l2_subdev_pad_config *cfg,
			struct v4l2_subdev_format *sdformat)
@@ -456,11 +466,7 @@ static int csi2_get_fmt(struct v4l2_subdev *sd,

	mutex_lock(&csi2->lock);

	if (sdformat->which == V4L2_SUBDEV_FORMAT_TRY)
		fmt = v4l2_subdev_get_try_format(&csi2->sd, cfg,
						 sdformat->pad);
	else
		fmt = &csi2->format_mbus;
	fmt = __csi2_get_fmt(csi2, cfg, sdformat->pad, sdformat->which);

	sdformat->format = *fmt;

@@ -474,6 +480,7 @@ static int csi2_set_fmt(struct v4l2_subdev *sd,
			struct v4l2_subdev_format *sdformat)
{
	struct csi2_dev *csi2 = sd_to_dev(sd);
	struct v4l2_mbus_framefmt *fmt;
	int ret = 0;

	if (sdformat->pad >= CSI2_NUM_PADS)
@@ -490,10 +497,9 @@ static int csi2_set_fmt(struct v4l2_subdev *sd,
	if (sdformat->pad != CSI2_SINK_PAD)
		sdformat->format = csi2->format_mbus;

	if (sdformat->which == V4L2_SUBDEV_FORMAT_TRY)
		cfg->try_fmt = sdformat->format;
	else
		csi2->format_mbus = sdformat->format;
	fmt = __csi2_get_fmt(csi2, cfg, sdformat->pad, sdformat->which);

	*fmt = sdformat->format;
out:
	mutex_unlock(&csi2->lock);
	return ret;