mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Randy Li <ayaka@soulik.info>
To: Tomasz Figa <tfiga@chromium.org>
Cc: linux-media@vger.kernel.org, randy.li@synaptics.com,
	Brian.Starkey@arm.com, boris.brezillon@collabora.com,
	frkoenig@chromium.org, hans.verkuil@cisco.com,
	hiroh@chromium.org, hverkuil@xs4all.nl, kernel@collabora.com,
	laurent.pinchart@ideasonboard.com, linux-kernel@vger.kernel.org,
	mchehab@kernel.org, narmstrong@baylibre.com,
	nicolas@ndufresne.ca, sakari.ailus@iki.fi,
	stanimir.varbanov@linaro.org,
	Helen Koike <helen.koike@collabora.com>
Subject: Re: [PATCH v7 2/9] media: vivid: Convert to v4l2_ext_pix_format
Date: Tue, 18 Jul 2023 00:00:23 +0800	[thread overview]
Message-ID: <46d15120-6e19-e224-47f3-e0dcbf0aeda5@soulik.info> (raw)
In-Reply-To: <20230713103912.favcnhqwjkzvsa6b@chromium.org>


On 2023/7/13 18:39, Tomasz Figa wrote:
> On Mon, Feb 06, 2023 at 12:33:01PM +0800, ayaka wrote:
>> From: Helen Koike <helen.koike@collabora.com>
>>
>> Simplify Multi/Single planer API handling by converting to v4l2_ext_pix_format.
>>
>> Duplicate v4l2_ioctl_ops for touch devices. This is done to force the
>> framework to use the ext hooks when the classic Api is used from
>> userspace in Vid devices, and to keep touch devices with classic hook.
>>
>> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
>> Signed-off-by: Helen Koike <helen.koike@collabora.com>
>> ---
>> Changes in v7:
>> - Force the userspace using the new APIs to operate non-touch drivers.
> The primary objective of Linux development is not to break the
> userspace. We can't just remove the old API, especially not from
> existing drivers.
Maybe I should create a new virtual driver here? It is impossible to 
support the new fourcc modifier with the old APIs.
>
> [snip]
>>   int vivid_try_fmt_vid_cap(struct file *file, void *priv,
>> -			struct v4l2_format *f)
>> +			  struct v4l2_ext_pix_format *f)
>>   {
>> -	struct v4l2_pix_format_mplane *mp = &f->fmt.pix_mp;
>> -	struct v4l2_plane_pix_format *pfmt = mp->plane_fmt;
>>   	struct vivid_dev *dev = video_drvdata(file);
>> +	struct v4l2_plane_pix_format *pfmt = f->plane_fmt;
>>   	const struct vivid_fmt *fmt;
>>   	unsigned bytesperline, max_bpl;
>>   	unsigned factor = 1;
>>   	unsigned w, h;
>>   	unsigned p;
>> -	bool user_set_csc = !!(mp->flags & V4L2_PIX_FMT_FLAG_SET_CSC);
> Why is this condition being removed?

Because the v4l2_ext_pix has a struct for the colorspace?

Would you like the idea that driver exports a buffer contains all the 
info for an enumeration ?

>
> Best regards,
> Tomasz
>
>>   
>> -	fmt = vivid_get_format(dev, mp->pixelformat);
>> +	fmt = vivid_get_format(dev, f->pixelformat);
>>   	if (!fmt) {
>>   		dprintk(dev, 1, "Fourcc format (0x%08x) unknown.\n",
>> -			mp->pixelformat);
>> -		mp->pixelformat = V4L2_PIX_FMT_YUYV;
>> -		fmt = vivid_get_format(dev, mp->pixelformat);
>> +			f->pixelformat);
>> +		f->pixelformat = V4L2_PIX_FMT_YUYV;
>> +		fmt = vivid_get_format(dev, f->pixelformat);
>>   	}
>>   
>> -	mp->field = vivid_field_cap(dev, mp->field);
>> +	f->field = vivid_field_cap(dev, f->field);
>>   	if (vivid_is_webcam(dev)) {
>>   		const struct v4l2_frmsize_discrete *sz =
>>   			v4l2_find_nearest_size(webcam_sizes,
>>   					       VIVID_WEBCAM_SIZES, width,
>> -					       height, mp->width, mp->height);
>> +					       height, f->width, f->height);
>>   
>>   		w = sz->width;
>>   		h = sz->height;
>> @@ -604,14 +603,14 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv,
>>   		w = dev->src_rect.width;
>>   		h = dev->src_rect.height;
>>   	}
>> -	if (V4L2_FIELD_HAS_T_OR_B(mp->field))
>> +	if (V4L2_FIELD_HAS_T_OR_B(f->field))
>>   		factor = 2;
>>   	if (vivid_is_webcam(dev) ||
>>   	    (!dev->has_scaler_cap && !dev->has_crop_cap && !dev->has_compose_cap)) {
>> -		mp->width = w;
>> -		mp->height = h / factor;
>> +		f->width = w;
>> +		f->height = h / factor;
>>   	} else {
>> -		struct v4l2_rect r = { 0, 0, mp->width, mp->height * factor };
>> +		struct v4l2_rect r = { 0, 0, f->width, f->height * factor };
>>   
>>   		v4l2_rect_set_min_size(&r, &vivid_min_rect);
>>   		v4l2_rect_set_max_size(&r, &vivid_max_rect);
>> @@ -624,16 +623,15 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv,
>>   		} else if (!dev->has_scaler_cap && !dev->has_crop_cap) {
>>   			v4l2_rect_set_min_size(&r, &dev->src_rect);
>>   		}
>> -		mp->width = r.width;
>> -		mp->height = r.height / factor;
>> +		f->width = r.width;
>> +		f->height = r.height / factor;
>>   	}
>>   
>>   	/* This driver supports custom bytesperline values */
>>   
>> -	mp->num_planes = fmt->buffers;
>>   	for (p = 0; p < fmt->buffers; p++) {
>>   		/* Calculate the minimum supported bytesperline value */
>> -		bytesperline = (mp->width * fmt->bit_depth[p]) >> 3;
>> +		bytesperline = (f->width * fmt->bit_depth[p]) >> 3;
>>   		/* Calculate the maximum supported bytesperline value */
>>   		max_bpl = (MAX_ZOOM * MAX_WIDTH * fmt->bit_depth[p]) >> 3;
>>   
>> @@ -642,48 +640,49 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv,
>>   		if (pfmt[p].bytesperline < bytesperline)
>>   			pfmt[p].bytesperline = bytesperline;
>>   
>> -		pfmt[p].sizeimage = (pfmt[p].bytesperline * mp->height) /
>> +		pfmt[p].sizeimage = (pfmt[p].bytesperline * f->height) /
>>   				fmt->vdownsampling[p] + fmt->data_offset[p];
>> -
>> -		memset(pfmt[p].reserved, 0, sizeof(pfmt[p].reserved));
>>   	}
>> +
>> +	if (p < VIDEO_MAX_PLANES)
>> +		pfmt[p].sizeimage = 0;
>> +
>>   	for (p = fmt->buffers; p < fmt->planes; p++)
>> -		pfmt[0].sizeimage += (pfmt[0].bytesperline * mp->height *
>> +		pfmt[0].sizeimage += (pfmt[0].bytesperline * f->height *
>>   			(fmt->bit_depth[p] / fmt->vdownsampling[p])) /
>>   			(fmt->bit_depth[0] / fmt->vdownsampling[0]);
>>   
>> -	if (!user_set_csc || !v4l2_is_colorspace_valid(mp->colorspace))
>> -		mp->colorspace = vivid_colorspace_cap(dev);
>> +	if (!v4l2_is_colorspace_valid(f->colorspace))
>> +		f->colorspace = vivid_colorspace_cap(dev);
>>   
>> -	if (!user_set_csc || !v4l2_is_xfer_func_valid(mp->xfer_func))
>> -		mp->xfer_func = vivid_xfer_func_cap(dev);
>> +	if (!v4l2_is_xfer_func_valid(f->xfer_func))
>> +		f->xfer_func = vivid_xfer_func_cap(dev);
>>   
>>   	if (fmt->color_enc == TGP_COLOR_ENC_HSV) {
>> -		if (!user_set_csc || !v4l2_is_hsv_enc_valid(mp->hsv_enc))
>> -			mp->hsv_enc = vivid_hsv_enc_cap(dev);
>> +		if (!v4l2_is_hsv_enc_valid(f->hsv_enc))
>> +			f->hsv_enc = vivid_hsv_enc_cap(dev);
>>   	} else if (fmt->color_enc == TGP_COLOR_ENC_YCBCR) {
>> -		if (!user_set_csc || !v4l2_is_ycbcr_enc_valid(mp->ycbcr_enc))
>> -			mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev);
>> +		if (!v4l2_is_ycbcr_enc_valid(f->ycbcr_enc))
>> +			f->ycbcr_enc = vivid_ycbcr_enc_cap(dev);
>>   	} else {
>> -		mp->ycbcr_enc = vivid_ycbcr_enc_cap(dev);
>> +		f->ycbcr_enc = vivid_ycbcr_enc_cap(dev);
>>   	}
>>   
>>   	if (fmt->color_enc == TGP_COLOR_ENC_YCBCR ||
>>   	    fmt->color_enc == TGP_COLOR_ENC_RGB) {
>> -		if (!user_set_csc || !v4l2_is_quant_valid(mp->quantization))
>> -			mp->quantization = vivid_quantization_cap(dev);
>> +		if (!v4l2_is_quant_valid(f->quantization))
>> +			f->quantization = vivid_quantization_cap(dev);
>>   	} else {
>> -		mp->quantization = vivid_quantization_cap(dev);
>> +		f->quantization = vivid_quantization_cap(dev);
>>   	}
>>   
>> -	memset(mp->reserved, 0, sizeof(mp->reserved));
>> +	memset(f->reserved, 0, sizeof(f->reserved));
>>   	return 0;
>>   }
> [snip]

  reply	other threads:[~2023-07-17 16:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-06  4:32 [RFC PATCH v7 0/9] media: v4l2: Add extended fmt and buffer ayaka
2023-02-06  4:33 ` [PATCH v7 1/9] media: v4l2: Extend pixel formats to unify single/multi-planar handling (and more) ayaka
     [not found]   ` <1e3a583f-f9ef-d2d3-6571-ac3b79d800ce@synaptics.com>
2023-06-28 16:27     ` Nicolas Dufresne
2023-06-29  3:43       ` Hsia-Jun Li
2023-07-13 10:26   ` Tomasz Figa
2023-07-21  6:03     ` Hsia-Jun Li
2023-02-06  4:33 ` [PATCH v7 2/9] media: vivid: Convert to v4l2_ext_pix_format ayaka
2023-07-13 10:39   ` Tomasz Figa
2023-07-17 16:00     ` Randy Li [this message]
2023-07-20 20:09       ` Nicolas Dufresne
2023-07-28  7:22         ` Tomasz Figa
2023-07-28 18:40           ` Randy Li
2023-08-04 20:19           ` Nicolas Dufresne
2023-07-28  7:18       ` Tomasz Figa
2023-02-06  4:33 ` [PATCH v7 3/9] media: v4l2: Add extended buffer (de)queue operations for video types ayaka
2023-02-06  4:33 ` [PATCH v7 4/9] media: videobuf2-v4l2: reorganize flags handling ayaka
2023-02-06  4:33 ` [PATCH v7 5/9] media: videobuf2: Expose helpers for Ext qbuf/dqbuf ayaka
2023-02-06  4:33 ` [PATCH v7 6/9] media: vivid: use vb2_ioctls_ext_{d}qbuf hooks ayaka
2023-02-06  4:33 ` [PATCH v7 7/9] media: vimc: " ayaka
2023-02-06  4:33 ` [PATCH v7 8/9] media: mediabus: Add helpers to convert a ext_pix format to/from a mbus_fmt ayaka
2023-02-06  4:33 ` [PATCH v7 9/9] media: vimc: Convert to v4l2_ext_pix_format ayaka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46d15120-6e19-e224-47f3-e0dcbf0aeda5@soulik.info \
    --to=ayaka@soulik.info \
    --cc=Brian.Starkey@arm.com \
    --cc=boris.brezillon@collabora.com \
    --cc=frkoenig@chromium.org \
    --cc=hans.verkuil@cisco.com \
    --cc=helen.koike@collabora.com \
    --cc=hiroh@chromium.org \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=narmstrong@baylibre.com \
    --cc=nicolas@ndufresne.ca \
    --cc=randy.li@synaptics.com \
    --cc=sakari.ailus@iki.fi \
    --cc=stanimir.varbanov@linaro.org \
    --cc=tfiga@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®