Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Kocialkowski <paulk@sys-base.io>
To: Arash Golgol <arash.golgol@gmail.com>
Cc: linux-media@vger.kernel.org, yong.deng@magewell.com,
	mchehab@kernel.org, wens@kernel.org, jernej.skrabec@gmail.com,
	samuel@sholland.org, linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, laurent.pinchart@ideasonboard.com,
	sakari.ailus@linux.intel.com
Subject: Re: [PATCH v3 3/3] media: sun6i-csi: capture: Support MC-centric format enumeration
Date: Sun, 17 May 2026 23:58:13 +0200	[thread overview]
Message-ID: <ago59fn0CJaN5309@collins> (raw)
In-Reply-To: <ago3mOxf1adhogFW@collins>

[-- Attachment #1: Type: text/plain, Size: 5499 bytes --]

Hi again,

Le Sun 17 May 26, 23:48, Paul Kocialkowski a écrit :
> Hi Arash,
> 
> Le Sat 09 May 26, 08:39, Arash Golgol a écrit :
> > Extend vidioc_enum_fmt to support MC-centric enumeration by filtering
> > pixel formats based on the provided mbus code. Advertise MC I/O support
> > on the video device to reflect its intended usage within a media graph.
> 
> There is one (important) thing I overlooked last time: the list of
> direct matches between mbus code and pixelformat only covers some of the
> formats that the driver supports, but not all of them.
> 
> This is reflected in sun6i_csi_capture_link_validate, where we check
> that a given mbus format set on the bridge is compatible with the
> pixelformat set on the capture side.
> 
> I think we essentially have to extract that validation logic into a new
> helper and then use it against all supported pixel formats for a given
> mbus code to find out if that pixel format should be returned or not.
> So it also means that multiple pixel formats can be supported for a given
> mbus format.
> 
> A typical example of this would be MEDIA_BUS_FMT_YUYV8_2X8 than can be
> stored to either YUYV (raw mode), NV16/YUV422 (YUV mode, no resampling) or
> NV12/YUV420 (YUV mode, 422 -> 420 resampling).
> 
> You're welcome to give it a try if you'd like or I could take a look at
> this myself.

I just found this old series I never follow-up on which does pretty much
exactly that, along with additions to v4l2_format_info.

https://patchwork.kernel.org/project/linux-media/list/?series=733589&archive=both

If you don't mind I will just pick up this work based on my earlier
series directly.

All the best,

Paul

> Also the first comment after the sun6i_csi_capture_format_matches
> declaration should be "YUV422", not "YUV420" (would be good to fix it
> while touching these parts).
> 
> All the best,
> 
> Paul
> 
> > Signed-off-by: Arash Golgol <arash.golgol@gmail.com>
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > Changes in v3:
> >  - No change
> >  - Link to v2: https://patchwork.kernel.org/project/linux-media/patch/20260508161721.94285-4-arash.golgol@gmail.com/
> > 
> > Changes in v2:
> >  - Return pixelformat directly instead of a pointer
> >  - Link to v1: https://patchwork.kernel.org/project/linux-media/patch/20260217064050.18388-4-arash.golgol@gmail.com/
> > 
> >  .../sunxi/sun6i-csi/sun6i_csi_capture.c       | 39 +++++++++++++++++--
> >  1 file changed, 36 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> > index f788b4234673..5737ebaa7297 100644
> > --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> > +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> > @@ -327,6 +327,22 @@ static bool sun6i_csi_capture_format_match(u32 pixelformat, u32 mbus_code)
> >  	return false;
> >  }
> >  
> > +static u32 sun6i_csi_capture_pixelformat_find(u32 mbus_code)
> > +{
> > +	unsigned int i;
> > +
> > +	for (i = 0; i < ARRAY_SIZE(sun6i_csi_capture_format_matches); i++) {
> > +		const struct sun6i_csi_capture_format_match *match =
> > +			&sun6i_csi_capture_format_matches[i];
> > +
> > +		if (match->mbus_code == mbus_code)
> > +			return match->pixelformat;
> > +	}
> > +
> > +	/* Valid fourcc is non-zero. */
> > +	return 0;
> > +}
> > +
> >  /* Capture */
> >  
> >  static void
> > @@ -729,11 +745,27 @@ static int sun6i_csi_capture_enum_fmt(struct file *file, void *priv,
> >  				      struct v4l2_fmtdesc *fmtdesc)
> >  {
> >  	u32 index = fmtdesc->index;
> > +	u32 mbus_code = fmtdesc->mbus_code;
> > +	u32 pixelformat;
> > +
> > +	/* MC-centric or Video-node-centric */
> > +	if (mbus_code) {
> > +		/* There is only one pixelformat for a mbus_code. */
> > +		if (index)
> > +			return -EINVAL;
> > +
> > +		pixelformat = sun6i_csi_capture_pixelformat_find(mbus_code);
> > +	} else {
> > +		if (index >= ARRAY_SIZE(sun6i_csi_capture_formats))
> > +			return -EINVAL;
> > +
> > +		pixelformat = sun6i_csi_capture_formats[index].pixelformat;
> > +	}
> >  
> > -	if (index >= ARRAY_SIZE(sun6i_csi_capture_formats))
> > +	if (!pixelformat)
> >  		return -EINVAL;
> >  
> > -	fmtdesc->pixelformat = sun6i_csi_capture_formats[index].pixelformat;
> > +	fmtdesc->pixelformat = pixelformat;
> >  
> >  	return 0;
> >  }
> > @@ -1065,7 +1097,8 @@ int sun6i_csi_capture_setup(struct sun6i_csi_device *csi_dev)
> >  
> >  	strscpy(video_dev->name, SUN6I_CSI_CAPTURE_NAME,
> >  		sizeof(video_dev->name));
> > -	video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
> > +	video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
> > +				 V4L2_CAP_IO_MC;
> >  	video_dev->vfl_dir = VFL_DIR_RX;
> >  	video_dev->release = video_device_release_empty;
> >  	video_dev->fops = &sun6i_csi_capture_fops;
> > -- 
> > 2.34.1
> > 
> 
> -- 
> Paul Kocialkowski,
> 
> Independent contractor - sys-base - https://www.sys-base.io/
> Free software developer - https://www.paulk.fr/
> 
> Expert in multimedia, graphics and embedded hardware support with Linux.



-- 
Paul Kocialkowski,

Independent contractor - sys-base - https://www.sys-base.io/
Free software developer - https://www.paulk.fr/

Expert in multimedia, graphics and embedded hardware support with Linux.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2026-05-17 21:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-09  5:09 [PATCH v3 0/3] media: sun6i-csi: Convert to active state and improve MC support Arash Golgol
2026-05-09  5:09 ` [PATCH v3 1/3] media: sun6i-csi: bridge: Use V4L2 subdev active state Arash Golgol
2026-05-09  5:09 ` [PATCH v3 2/3] media: sun6i-csi: capture: Implement vidioc_enum_framesizes Arash Golgol
2026-05-09  5:09 ` [PATCH v3 3/3] media: sun6i-csi: capture: Support MC-centric format enumeration Arash Golgol
2026-05-17 21:48   ` Paul Kocialkowski
2026-05-17 21:58     ` Paul Kocialkowski [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=ago59fn0CJaN5309@collins \
    --to=paulk@sys-base.io \
    --cc=arash.golgol@gmail.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=samuel@sholland.org \
    --cc=wens@kernel.org \
    --cc=yong.deng@magewell.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