Linux Media Controller development
 help / color / mirror / Atom feed
From: Paul Elder <paul.elder@ideasonboard.com>
To: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Sakari Ailus <sakari.ailus@iki.fi>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Stefan Klug <stefan.klug@ideasonboard.com>,
	Daniel Scally <dan.scally@ideasonboard.com>,
	Kieran Bingham <kieran.bingham@ideasonboard.com>,
	Umang Jain <umang.jain@ideasonboard.com>,
	Dafna Hirschfeld <dafna@fastmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>
Subject: Re: [PATCH v5 7/7] media: rkisp1: Implement s_fmt/try_fmt
Date: Fri, 5 Jul 2024 20:23:22 +0900	[thread overview]
Message-ID: <ZofXqtRwQRWOj1AE@pyrite.rasen.tech> (raw)
In-Reply-To: <20240703161048.247124-8-jacopo.mondi@ideasonboard.com>

On Wed, Jul 03, 2024 at 06:10:46PM +0200, Jacopo Mondi wrote:
> Implement in the rkisp1 driver support for the s_fmt and try_fmt
> operation to allow userspace to select between the extensible
> and the fixed parameters formats.
> 
> Implement enum_mbus_code to enumerate the fixed and the extensible
> formats and disallow changing the data format while the queue is busy.
> 
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  .../platform/rockchip/rkisp1/rkisp1-params.c  | 58 ++++++++++++++++---
>  1 file changed, 50 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
> index 3ef410337aa2..ea1ad92d2b21 100644
> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c
> @@ -75,6 +75,17 @@ static const struct v4l2_meta_format rkisp1_params_formats[] = {
>  	},
>  };
>  
> +static const struct v4l2_meta_format *
> +rkisp1_params_get_format_info(u32 dataformat)
> +{
> +	for (unsigned int i = 0; i < ARRAY_SIZE(rkisp1_params_formats); i++) {
> +		if (rkisp1_params_formats[i].dataformat == dataformat)
> +			return &rkisp1_params_formats[i];
> +	}
> +
> +	return &rkisp1_params_formats[RKISP1_PARAMS_FIXED];
> +}
> +
>  static inline void
>  rkisp1_param_set_bits(struct rkisp1_params *params, u32 reg, u32 bit_mask)
>  {
> @@ -2233,12 +2244,12 @@ static int rkisp1_params_enum_fmt_meta_out(struct file *file, void *priv,
>  					   struct v4l2_fmtdesc *f)
>  {
>  	struct video_device *video = video_devdata(file);
> -	struct rkisp1_params *params = video_get_drvdata(video);
>  
> -	if (f->index > 0 || f->type != video->queue->type)
> +	if (f->index >= ARRAY_SIZE(rkisp1_params_formats) ||
> +	    f->type != video->queue->type)
>  		return -EINVAL;
>  
> -	f->pixelformat = params->metafmt->dataformat;
> +	f->pixelformat = rkisp1_params_formats[f->index].dataformat;
>  
>  	return 0;
>  }
> @@ -2253,9 +2264,40 @@ static int rkisp1_params_g_fmt_meta_out(struct file *file, void *fh,
>  	if (f->type != video->queue->type)
>  		return -EINVAL;
>  
> -	memset(meta, 0, sizeof(*meta));
> -	meta->dataformat = params->metafmt->dataformat;
> -	meta->buffersize = params->metafmt->buffersize;
> +	*meta = *params->metafmt;
> +
> +	return 0;
> +}
> +
> +static int rkisp1_params_try_fmt_meta_out(struct file *file, void *fh,
> +					  struct v4l2_format *f)
> +{
> +	struct video_device *video = video_devdata(file);
> +	struct v4l2_meta_format *meta = &f->fmt.meta;
> +
> +	if (f->type != video->queue->type)
> +		return -EINVAL;
> +
> +	*meta = *rkisp1_params_get_format_info(meta->dataformat);
> +
> +	return 0;
> +}
> +
> +static int rkisp1_params_s_fmt_meta_out(struct file *file, void *fh,
> +					struct v4l2_format *f)
> +{
> +	struct video_device *video = video_devdata(file);
> +	struct rkisp1_params *params = video_get_drvdata(video);
> +	struct v4l2_meta_format *meta = &f->fmt.meta;
> +
> +	if (f->type != video->queue->type)
> +		return -EINVAL;
> +
> +	if (vb2_is_busy(video->queue))
> +		return -EBUSY;
> +
> +	params->metafmt = rkisp1_params_get_format_info(meta->dataformat);
> +	*meta = *params->metafmt;
>  
>  	return 0;
>  }
> @@ -2285,8 +2327,8 @@ static const struct v4l2_ioctl_ops rkisp1_params_ioctl = {
>  	.vidioc_streamoff = vb2_ioctl_streamoff,
>  	.vidioc_enum_fmt_meta_out = rkisp1_params_enum_fmt_meta_out,
>  	.vidioc_g_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
> -	.vidioc_s_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
> -	.vidioc_try_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
> +	.vidioc_s_fmt_meta_out = rkisp1_params_s_fmt_meta_out,
> +	.vidioc_try_fmt_meta_out = rkisp1_params_try_fmt_meta_out,
>  	.vidioc_querycap = rkisp1_params_querycap,
>  	.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
>  	.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
> -- 
> 2.45.2
> 

      reply	other threads:[~2024-07-05 11:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-03 16:10 [PATCH v5 0/7] media: rkisp1: Implement support for extensible parameters Jacopo Mondi
2024-07-03 16:10 ` [PATCH v5 1/7] uapi: rkisp1-config: Add extensible parameters format Jacopo Mondi
2024-07-03 16:10 ` [PATCH v5 2/7] uapi: videodev2: Add V4L2_META_FMT_RK_ISP1_EXT_PARAMS Jacopo Mondi
2024-07-03 16:10 ` [PATCH v5 3/7] media: rkisp1: Add struct rkisp1_params_buffer Jacopo Mondi
2024-07-03 16:10 ` [PATCH v5 4/7] media: rkisp1: Copy the parameters buffer Jacopo Mondi
2024-07-05 10:52   ` Paul Elder
2024-07-03 16:10 ` [PATCH v5 5/7] media: rkisp1: Cache the currently active format Jacopo Mondi
2024-07-05 10:56   ` Paul Elder
2024-07-03 16:10 ` [PATCH v5 6/7] media: rkisp1: Implement extensible params support Jacopo Mondi
2024-07-03 20:56   ` Laurent Pinchart
2024-07-03 21:17   ` [PATCH v5.1 " Laurent Pinchart
2024-07-04  7:36     ` Jacopo Mondi
2024-07-04  9:40       ` Laurent Pinchart
2024-07-04  9:56   ` [PATCH v5.2 " Laurent Pinchart
2024-07-05 11:21     ` Paul Elder
2024-07-08  8:39       ` Jacopo Mondi
2024-07-06 12:18   ` [PATCH v5 " Sakari Ailus
2024-07-08  8:25     ` Jacopo Mondi
2024-07-08  9:41       ` Sakari Ailus
2024-07-03 16:10 ` [PATCH v5 7/7] media: rkisp1: Implement s_fmt/try_fmt Jacopo Mondi
2024-07-05 11:23   ` Paul Elder [this message]

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=ZofXqtRwQRWOj1AE@pyrite.rasen.tech \
    --to=paul.elder@ideasonboard.com \
    --cc=dafna@fastmail.com \
    --cc=dan.scally@ideasonboard.com \
    --cc=heiko@sntech.de \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@iki.fi \
    --cc=stefan.klug@ideasonboard.com \
    --cc=umang.jain@ideasonboard.com \
    /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