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

Commit 5eab4983 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

[media] v4l2: replace try_mbus_fmt by set_fmt in bridge drivers



Replace all calls to try_mbus_fmt in bridge drivers by calls to the
set_fmt pad op.

[mchehab@osg.samsung.com: fix a merge conflict at mcam-core.c]
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: default avatarScott Jiang <scott.jiang.linux@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 6e80c473
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -157,11 +157,14 @@ static int empress_try_fmt_vid_cap(struct file *file, void *priv,
				struct v4l2_format *f)
{
	struct saa7134_dev *dev = video_drvdata(file);
	struct v4l2_mbus_framefmt mbus_fmt;
	struct v4l2_subdev_pad_config pad_cfg;
	struct v4l2_subdev_format format = {
		.which = V4L2_SUBDEV_FORMAT_TRY,
	};

	v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, MEDIA_BUS_FMT_FIXED);
	saa_call_all(dev, video, try_mbus_fmt, &mbus_fmt);
	v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt);
	v4l2_fill_mbus_format(&format.format, &f->fmt.pix, MEDIA_BUS_FMT_FIXED);
	saa_call_all(dev, pad, set_fmt, &pad_cfg, &format);
	v4l2_fill_pix_format(&f->fmt.pix, &format.format);

	f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
	f->fmt.pix.sizeimage    = TS_PACKET_SIZE * dev->ts.nr_packets;
+9 −6
Original line number Diff line number Diff line
@@ -602,7 +602,10 @@ static int bcap_try_format(struct bcap_device *bcap,
{
	struct bcap_format *sf = bcap->sensor_formats;
	struct bcap_format *fmt = NULL;
	struct v4l2_mbus_framefmt mbus_fmt;
	struct v4l2_subdev_pad_config pad_cfg;
	struct v4l2_subdev_format format = {
		.which = V4L2_SUBDEV_FORMAT_TRY,
	};
	int ret, i;

	for (i = 0; i < bcap->num_sensor_formats; i++) {
@@ -613,16 +616,16 @@ static int bcap_try_format(struct bcap_device *bcap,
	if (i == bcap->num_sensor_formats)
		fmt = &sf[0];

	v4l2_fill_mbus_format(&mbus_fmt, pixfmt, fmt->mbus_code);
	ret = v4l2_subdev_call(bcap->sd, video,
				try_mbus_fmt, &mbus_fmt);
	v4l2_fill_mbus_format(&format.format, pixfmt, fmt->mbus_code);
	ret = v4l2_subdev_call(bcap->sd, pad, set_fmt, &pad_cfg,
				&format);
	if (ret < 0)
		return ret;
	v4l2_fill_pix_format(pixfmt, &mbus_fmt);
	v4l2_fill_pix_format(pixfmt, &format.format);
	if (bcap_fmt) {
		for (i = 0; i < bcap->num_sensor_formats; i++) {
			fmt = &sf[i];
			if (mbus_fmt.code == fmt->mbus_code)
			if (format.format.code == fmt->mbus_code)
				break;
		}
		*bcap_fmt = *fmt;
+7 −4
Original line number Diff line number Diff line
@@ -1351,14 +1351,17 @@ static int mcam_vidioc_try_fmt_vid_cap(struct file *filp, void *priv,
	struct mcam_camera *cam = video_drvdata(filp);
	struct mcam_format_struct *f;
	struct v4l2_pix_format *pix = &fmt->fmt.pix;
	struct v4l2_mbus_framefmt mbus_fmt;
	struct v4l2_subdev_pad_config pad_cfg;
	struct v4l2_subdev_format format = {
		.which = V4L2_SUBDEV_FORMAT_TRY,
	};
	int ret;

	f = mcam_find_format(pix->pixelformat);
	pix->pixelformat = f->pixelformat;
	v4l2_fill_mbus_format(&mbus_fmt, pix, f->mbus_code);
	ret = sensor_call(cam, video, try_mbus_fmt, &mbus_fmt);
	v4l2_fill_pix_format(pix, &mbus_fmt);
	v4l2_fill_mbus_format(&format.format, pix, f->mbus_code);
	ret = sensor_call(cam, pad, set_fmt, &pad_cfg, &format);
	v4l2_fill_pix_format(pix, &format.format);
	pix->bytesperline = pix->width * f->bpp;
	switch (f->pixelformat) {
	case V4L2_PIX_FMT_YUV420:
+16 −12
Original line number Diff line number Diff line
@@ -535,7 +535,11 @@ static int isi_camera_try_fmt(struct soc_camera_device *icd,
	struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
	const struct soc_camera_format_xlate *xlate;
	struct v4l2_pix_format *pix = &f->fmt.pix;
	struct v4l2_mbus_framefmt mf;
	struct v4l2_subdev_pad_config pad_cfg;
	struct v4l2_subdev_format format = {
		.which = V4L2_SUBDEV_FORMAT_TRY,
	};
	struct v4l2_mbus_framefmt *mf = &format.format;
	u32 pixfmt = pix->pixelformat;
	int ret;

@@ -552,21 +556,21 @@ static int isi_camera_try_fmt(struct soc_camera_device *icd,
		pix->width = MAX_SUPPORT_WIDTH;

	/* limit to sensor capabilities */
	mf.width	= pix->width;
	mf.height	= pix->height;
	mf.field	= pix->field;
	mf.colorspace	= pix->colorspace;
	mf.code		= xlate->code;
	mf->width	= pix->width;
	mf->height	= pix->height;
	mf->field	= pix->field;
	mf->colorspace	= pix->colorspace;
	mf->code	= xlate->code;

	ret = v4l2_subdev_call(sd, video, try_mbus_fmt, &mf);
	ret = v4l2_subdev_call(sd, pad, set_fmt, &pad_cfg, &format);
	if (ret < 0)
		return ret;

	pix->width	= mf.width;
	pix->height	= mf.height;
	pix->colorspace	= mf.colorspace;
	pix->width	= mf->width;
	pix->height	= mf->height;
	pix->colorspace	= mf->colorspace;

	switch (mf.field) {
	switch (mf->field) {
	case V4L2_FIELD_ANY:
		pix->field = V4L2_FIELD_NONE;
		break;
@@ -574,7 +578,7 @@ static int isi_camera_try_fmt(struct soc_camera_device *icd,
		break;
	default:
		dev_err(icd->parent, "Field type %d unsupported.\n",
			mf.field);
			mf->field);
		ret = -EINVAL;
	}

+21 −17
Original line number Diff line number Diff line
@@ -1187,7 +1187,11 @@ static int mx2_camera_try_fmt(struct soc_camera_device *icd,
	struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
	const struct soc_camera_format_xlate *xlate;
	struct v4l2_pix_format *pix = &f->fmt.pix;
	struct v4l2_mbus_framefmt mf;
	struct v4l2_subdev_pad_config pad_cfg;
	struct v4l2_subdev_format format = {
		.which = V4L2_SUBDEV_FORMAT_TRY,
	};
	struct v4l2_mbus_framefmt *mf = &format.format;
	__u32 pixfmt = pix->pixelformat;
	struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
	struct mx2_camera_dev *pcdev = ici->priv;
@@ -1210,13 +1214,13 @@ static int mx2_camera_try_fmt(struct soc_camera_device *icd,
	pix->width &= ~0x7;

	/* limit to sensor capabilities */
	mf.width	= pix->width;
	mf.height	= pix->height;
	mf.field	= pix->field;
	mf.colorspace	= pix->colorspace;
	mf.code		= xlate->code;
	mf->width	= pix->width;
	mf->height	= pix->height;
	mf->field	= pix->field;
	mf->colorspace	= pix->colorspace;
	mf->code	= xlate->code;

	ret = v4l2_subdev_call(sd, video, try_mbus_fmt, &mf);
	ret = v4l2_subdev_call(sd, pad, set_fmt, &pad_cfg, &format);
	if (ret < 0)
		return ret;

@@ -1227,29 +1231,29 @@ static int mx2_camera_try_fmt(struct soc_camera_device *icd,
	emma_prp = mx27_emma_prp_get_format(xlate->code,
					    xlate->host_fmt->fourcc);

	if ((mf.width != pix->width || mf.height != pix->height) &&
	if ((mf->width != pix->width || mf->height != pix->height) &&
		emma_prp->cfg.in_fmt == PRP_CNTL_DATA_IN_YUV422) {
		if (mx2_emmaprp_resize(pcdev, &mf, pix, false) < 0)
		if (mx2_emmaprp_resize(pcdev, mf, pix, false) < 0)
			dev_dbg(icd->parent, "%s: can't resize\n", __func__);
	}

	if (mf.field == V4L2_FIELD_ANY)
		mf.field = V4L2_FIELD_NONE;
	if (mf->field == V4L2_FIELD_ANY)
		mf->field = V4L2_FIELD_NONE;
	/*
	 * Driver supports interlaced images provided they have
	 * both fields so that they can be processed as if they
	 * were progressive.
	 */
	if (mf.field != V4L2_FIELD_NONE && !V4L2_FIELD_HAS_BOTH(mf.field)) {
	if (mf->field != V4L2_FIELD_NONE && !V4L2_FIELD_HAS_BOTH(mf->field)) {
		dev_err(icd->parent, "Field type %d unsupported.\n",
				mf.field);
				mf->field);
		return -EINVAL;
	}

	pix->width	= mf.width;
	pix->height	= mf.height;
	pix->field	= mf.field;
	pix->colorspace	= mf.colorspace;
	pix->width	= mf->width;
	pix->height	= mf->height;
	pix->field	= mf->field;
	pix->colorspace	= mf->colorspace;

	dev_dbg(icd->parent, "%s: returned params: width = %d, height = %d\n",
		__func__, pix->width, pix->height);
Loading