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,
	linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-staging@lists.linux.dev,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Chen-Yu Tsai <wens@kernel.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Nicolas Dufresne <nicolas.dufresne@collabora.com>
Subject: Re: [PATCH 10/16] media: sun6i-csi: Add support for MC-centric format enumeration
Date: Wed, 27 May 2026 09:59:18 +0200	[thread overview]
Message-ID: <ahakVq7Fv78ODicG@shepard> (raw)
In-Reply-To: <CAMxPZkiKBFsPA5x6KpBajGqO5xqxD5AOd26j3uwqnQko1VzknQ@mail.gmail.com>

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

Hi Arash,

On Wed 27 May 26, 09:20, arash golgol wrote:
> On Mon, May 18, 2026 at 2:00 PM Paul Kocialkowski <paulk@sys-base.io> wrote:
> >
> > Use the dedicated helper to check possible pixelformats against the
> > provided mbus code in order to support MC-centric format enumeration.
> >
> > Note that multiple pixelformats may be returned for a given mbus code.
> >
> > Signed-off-by: Paul Kocialkowski <paulk@sys-base.io>
> > ---
> >  .../sunxi/sun6i-csi/sun6i_csi_capture.c       | 38 +++++++++++++++++--
> >  1 file changed, 34 insertions(+), 4 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 a836fa7f081a..409c28621093 100644
> > --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> > +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> > @@ -773,14 +773,43 @@ static int sun6i_csi_capture_querycap(struct file *file, void *priv,
> >  static int sun6i_csi_capture_enum_fmt(struct file *file, void *priv,
> >                                       struct v4l2_fmtdesc *fmtdesc)
> >  {
> > +       const struct sun6i_csi_capture_format *capture_format;
> > +       const struct sun6i_csi_bridge_format *bridge_format;
> > +       u32 mbus_code = fmtdesc->mbus_code;
> >         u32 index = fmtdesc->index;
> > +       unsigned int index_valid = 0;
> > +       unsigned int i;
> > +
> > +       /* Video-node-centric enumeration. */
> > +       if (!mbus_code) {
> > +               if (index >= ARRAY_SIZE(sun6i_csi_capture_formats))
> > +                       return -EINVAL;
> > +
> > +               fmtdesc->pixelformat =
> > +                       sun6i_csi_capture_formats[index].pixelformat;
> > +               return 0;
> > +       }
> >
> > -       if (index >= ARRAY_SIZE(sun6i_csi_capture_formats))
> > +       bridge_format = sun6i_csi_bridge_format_find(mbus_code);
> > +       if (!bridge_format)
> >                 return -EINVAL;
> >
> > -       fmtdesc->pixelformat = sun6i_csi_capture_formats[index].pixelformat;
> > +       for (i = 0; i < ARRAY_SIZE(sun6i_csi_capture_formats); i++) {
> > +               capture_format = &sun6i_csi_capture_formats[i];
> >
> > -       return 0;
> > +               if (!sun6i_csi_capture_format_check(capture_format,
> > +                                                   bridge_format))
> > +                       continue;
> > +
> > +               if (index_valid == index) {
> > +                       fmtdesc->pixelformat = capture_format->pixelformat;
> > +                       return 0;
> > +               }
> > +
> > +               index_valid++;
> > +       }
> > +
> > +       return -EINVAL;
> >  }
> >
> >  static int sun6i_csi_capture_enum_framesize(struct file *file, void *fh,
> > @@ -1076,7 +1105,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.54.0
> >
> 
> Tested on a LicheePi Zero Dock (V3s) with the following pipeline:
> 
> ov7670 -> sun6i-csi-bridge -> sun6i-csi-capture
> 
> I verified that mbus-code-based format enumeration works correctly
> from userspace and that the reported capture formats change according
> to the selected media bus format.
> 
> I could also successfully start streaming with several of the
> enumerated capture formats (e.g. YUYV and BA81)

Excellent, thank-you very much for testing this!

> However, I could not fully validate actual format conversion behavior
> (e.g. MEDIA_BUS_FMT_YUYV8_2X8 to NV12) because my OV7670 setup
> currently has non-functional test patterns except for 'shifting-1'
> mode.

That's fine. I don't think I have tested it recently either.

> Tested-by: Arash Golgol <arash.golgol@gmail.com>
> 
> PS:
> 
> While testing this patch I also noticed that
> VIDIOC_SUBDEV_ENUM_MBUS_CODE reports duplicate entries for:
>  - MEDIA_BUS_FMT_UYVY8_2X8
>  - MEDIA_BUS_FMT_UYVY8_1X16
> on sun6i-csi-bridge.

I just had a look and you are definitely right, the entries are clearly
duplicates and at the same time all the relevant formats are included, so they
are not taking the place of another format that was forgotten.

You're welcome to submit a patch to remove these entries if you'd like,
or I could do it otherwise.

By the way would you be interested in testing the H.264 encoder support for
V3/V3s once I send a first version for it? I had written initial support for
it a while ago (did not send it to the list) and now that my work on the V4L2
stateless uAPI has reached a point of usability I will probably try to update
my rework of the cedrus driver to use it.

All the best,

Paul

> This appears to come from duplicate format entries being exposed by
> the bridge driver.
> 
> -- 
> Regards,
> Arash Golgol

-- 
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-27  9:28 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18 10:24 [PATCH 00/16] media: sun6i-csi/isp MC-centric support and cleanups Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 01/16] media: sun6i-csi: bridge: Use V4L2 subdev active state Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 02/16] media: sun6i-csi: capture: Implement vidioc_enum_framesizes Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 03/16] media: sun6i-mipi-csi2: Use V4L2 subdev active state Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 04/16] media: sun8i-a83t-mipi-csi2: " Paul Kocialkowski
2026-05-18 14:09   ` Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 05/16] media: v4l2-common: Fix NV15_4L4 format info block height Paul Kocialkowski
2026-05-19 15:16   ` Nicolas Dufresne
2026-05-19 20:33     ` Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 06/16] media: v4l2-common: Add missing tiled format info block sizes Paul Kocialkowski
2026-05-19 15:18   ` Nicolas Dufresne
2026-05-19 20:37     ` Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 07/16] media: v4l2-common: Add NV12_16L16 pixel format to v4l2 format info Paul Kocialkowski
2026-05-19 15:22   ` Nicolas Dufresne
2026-05-18 10:24 ` [PATCH 08/16] media: v4l2-common: Add NV12_32L32 " Paul Kocialkowski
2026-05-19 15:23   ` Nicolas Dufresne
2026-05-18 10:24 ` [PATCH 09/16] media: sun6i-csi: Split format validation to a dedicated helper Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 10/16] media: sun6i-csi: Add support for MC-centric format enumeration Paul Kocialkowski
2026-05-27  5:50   ` arash golgol
2026-05-27  7:59     ` Paul Kocialkowski [this message]
2026-05-27 11:53       ` arash golgol
2026-05-18 10:24 ` [PATCH 11/16] media: sun6i-csi: Tidy up and unify coding style Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 12/16] media: sun6i-mipi-csi2: Fix parenthesis alignment Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 13/16] media: sun6i-isp: Add dummy params link_validate implementation Paul Kocialkowski
2026-05-25  3:25   ` arash golgol
2026-05-18 10:24 ` [PATCH 14/16] media: sun6i-isp: Use V4L2 subdev active state Paul Kocialkowski
2026-05-21  9:23   ` arash golgol
2026-05-22 11:15     ` Paul Kocialkowski
2026-05-23  3:15       ` arash golgol
2026-05-18 10:24 ` [PATCH 15/16] media: sun6i-isp: Add support for MC-centric format enumeration Paul Kocialkowski
2026-05-18 10:24 ` [PATCH 16/16] media: sun6i-isp: Add support for frame size enumeration Paul Kocialkowski
2026-05-23  4:34   ` arash golgol
2026-05-18 12:15 ` [PATCH 00/16] media: sun6i-csi/isp MC-centric support and cleanups Laurent Pinchart
2026-05-18 14:08   ` Paul Kocialkowski

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=ahakVq7Fv78ODicG@shepard \
    --to=paulk@sys-base.io \
    --cc=arash.golgol@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=nicolas.dufresne@collabora.com \
    --cc=samuel@sholland.org \
    --cc=wens@kernel.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