From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10058CD4F3D for ; Sun, 17 May 2026 21:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Mbvd05pFQtM/VXTbrNC0oyMCIt7wMVzwPROdVNsgxkk=; b=a9Djv6ZXGkrMbsBK7NGTn7CN6Q emXuGEKJkn2HV9PN8HshpQdcax8pl5tsFRrqFSDSJkxlqg04anfcPl3hCs86L0FgOi/I/NEMZ800O fc0fLdn6CXHqBl+vqvZcWymNgnJ6EuVT6ZV4MSELJlKd841qsMK3ntOdtMlU7sDpc7Ws3vHSf47Gj MaNiGfR7rpVO+Xcf3UX0hd1OKpehnhQGiARwr+HG37l3aBM+fprtK4c8459NIwfVEySpNaKmIaNB5 rnTbyXxNmLCxLst2EVJZC1bmTdqhU+yCxXKr10PWOb0Hecv/J78bLIZVaxkNdcqjRmT8XlnJIe+Sl uCf0Zt6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wOjV9-0000000DY5p-2Mxv; Sun, 17 May 2026 21:58:23 +0000 Received: from leonov.paulk.fr ([185.233.101.22]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wOjV7-0000000DY5P-0ZZB for linux-arm-kernel@lists.infradead.org; Sun, 17 May 2026 21:58:22 +0000 Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id 5D5771F8004D for ; Sun, 17 May 2026 21:58:18 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id 174E6B407AA; Sun, 17 May 2026 21:58:17 +0000 (UTC) Received: from collins (unknown [192.168.1.1]) by laika.paulk.fr (Postfix) with ESMTPSA id E06DAB4079E; Sun, 17 May 2026 21:58:15 +0000 (UTC) Date: Sun, 17 May 2026 23:58:13 +0200 From: Paul Kocialkowski To: Arash Golgol 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 Message-ID: References: <20260509050921.22158-1-arash.golgol@gmail.com> <20260509050921.22158-4-arash.golgol@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="+lPBCRAKF88mfx7A" Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260517_145821_504458_77C38152 X-CRM114-Status: GOOD ( 40.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --+lPBCRAKF88mfx7A Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi again, Le Sun 17 May 26, 23:48, Paul Kocialkowski a =C3=A9crit : > Hi Arash, >=20 > Le Sat 09 May 26, 08:39, Arash Golgol a =C3=A9crit : > > 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. >=20 > 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. >=20 > 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. >=20 > 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. >=20 > 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). >=20 > 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=3D733589&arch= ive=3Dboth 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). >=20 > All the best, >=20 > Paul >=20 > > Signed-off-by: Arash Golgol > > Reviewed-by: Laurent Pinchart > > --- > > Changes in v3: > > - No change > > - Link to v2: https://patchwork.kernel.org/project/linux-media/patch/2= 0260508161721.94285-4-arash.golgol@gmail.com/ > >=20 > > Changes in v2: > > - Return pixelformat directly instead of a pointer > > - Link to v1: https://patchwork.kernel.org/project/linux-media/patch/2= 0260217064050.18388-4-arash.golgol@gmail.com/ > >=20 > > .../sunxi/sun6i-csi/sun6i_csi_capture.c | 39 +++++++++++++++++-- > > 1 file changed, 36 insertions(+), 3 deletions(-) > >=20 > > 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 pix= elformat, u32 mbus_code) > > return false; > > } > > =20 > > +static u32 sun6i_csi_capture_pixelformat_find(u32 mbus_code) > > +{ > > + unsigned int i; > > + > > + for (i =3D 0; i < ARRAY_SIZE(sun6i_csi_capture_format_matches); i++) { > > + const struct sun6i_csi_capture_format_match *match =3D > > + &sun6i_csi_capture_format_matches[i]; > > + > > + if (match->mbus_code =3D=3D mbus_code) > > + return match->pixelformat; > > + } > > + > > + /* Valid fourcc is non-zero. */ > > + return 0; > > +} > > + > > /* Capture */ > > =20 > > static void > > @@ -729,11 +745,27 @@ static int sun6i_csi_capture_enum_fmt(struct file= *file, void *priv, > > struct v4l2_fmtdesc *fmtdesc) > > { > > u32 index =3D fmtdesc->index; > > + u32 mbus_code =3D 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 =3D sun6i_csi_capture_pixelformat_find(mbus_code); > > + } else { > > + if (index >=3D ARRAY_SIZE(sun6i_csi_capture_formats)) > > + return -EINVAL; > > + > > + pixelformat =3D sun6i_csi_capture_formats[index].pixelformat; > > + } > > =20 > > - if (index >=3D ARRAY_SIZE(sun6i_csi_capture_formats)) > > + if (!pixelformat) > > return -EINVAL; > > =20 > > - fmtdesc->pixelformat =3D sun6i_csi_capture_formats[index].pixelformat; > > + fmtdesc->pixelformat =3D pixelformat; > > =20 > > return 0; > > } > > @@ -1065,7 +1097,8 @@ int sun6i_csi_capture_setup(struct sun6i_csi_devi= ce *csi_dev) > > =20 > > strscpy(video_dev->name, SUN6I_CSI_CAPTURE_NAME, > > sizeof(video_dev->name)); > > - video_dev->device_caps =3D V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMIN= G; > > + video_dev->device_caps =3D V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMIN= G | > > + V4L2_CAP_IO_MC; > > video_dev->vfl_dir =3D VFL_DIR_RX; > > video_dev->release =3D video_device_release_empty; > > video_dev->fops =3D &sun6i_csi_capture_fops; > > --=20 > > 2.34.1 > >=20 >=20 > --=20 > Paul Kocialkowski, >=20 > Independent contractor - sys-base - https://www.sys-base.io/ > Free software developer - https://www.paulk.fr/ >=20 > Expert in multimedia, graphics and embedded hardware support with Linux. --=20 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. --+lPBCRAKF88mfx7A Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEAbcMXZQMtj1fphLChP3B6o/ulQwFAmoKOfUACgkQhP3B6o/u lQyLrw/9GtTO/jWPOJMHb1iOQL6mwfoU8M7I0xJ19ViEhji949UAC5DA8JTl8Gi/ 9YGBIRTWQ1nvjzNuc5XHfo4JdyGaRaCcv2xtWfap8cvHvduCHlAHpo4c7W2utr3Q UKij3LgJtLEKj+J769ILuNQRR/KeWYRj2/imjjf0nPX+yF5b89k8HXicLSI1rnks YZGoyZmLIw1dapVQfrVivHZkGYYJ0/kcvct2QiyxZHrS0l+nlSw3pjpHGZqo+pH9 S7kYX9GDl3PZ1SipGj2gsLJ+qCyJzs8khk7mEJbnczH7MMp3kk91PB79xz9y+ari tA79YJlonsHcPBYtbTlDarzJBV4UDHTVU3HpZhtPmN6clLv1oqKxrmGyFGvsTpcv RiwV5zBl2PICOHFQzFgzochujyhNyoHFgGDd1ONF4JNKK+bd1w+HzZB0aEfUu/nw f1T7EPcVrQwq6Tp6KgaMXPH4uLmyoHTIqWUWfylFbQVl9KF8j9bMhfBCfqRGvpq7 IKZE7fX895khZaFPTEtczh3Wup/496fG58Sb4A2qrb+ZiGEohwZeh1WMDp4QetHM sH33nCsZjfqvfffvSbAXofzD19shRHzQCw1Ia7CzG6GWDPss0GWaQ23yEDHoo4TE roQqlEiVzmkUhbJnb5cd/UlSswZlxJO9TV4GW/+V2RwaWYTtQYY= =P/ft -----END PGP SIGNATURE----- --+lPBCRAKF88mfx7A--