From nobody Sun Feb 8 01:21:16 2026 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F2DEA34 for ; Tue, 9 Jul 2024 16:17:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720541846; cv=none; b=A3W5woNr4hW2s2w5WrscTclcaQCSqTn5pWNj4VJ+HULE9+bxhyFu3yytkVc7JydzrCOTFs09qk0956Wpa+Nk/oqw6SgydsV2kQwjhlTBfbCK8wqxRWT0tUGUGeoFwqEM3+92TkR4hB9R1oodGiEDLBbhvxwHIw9vFVm7VwX+JoA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720541846; c=relaxed/simple; bh=pY9dyAuf+IgDN1fa8f1eKketAbqYvw22P2aR6+ef43M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GliaDHEpNc04Z/0m/W4mME799EV9Qw3nyKPVJHxPuHVi42aI73EteWTZJaqt7phozPHaa7CIepGlDYYghVN7KSiwyNzicep+J84YO1IyTKOK8zRWcid+n+m7kjFEL+8GdY27n+ezOQzvfw7+rAFYclYV/QLrtkRrUpJMkvk0P9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=EpmAn/Ot; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="EpmAn/Ot" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1720541837; bh=pY9dyAuf+IgDN1fa8f1eKketAbqYvw22P2aR6+ef43M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EpmAn/OtCJT2GGyZArBtv6j9t5PQtB7mHzXT/p9lXmV6OBIByK5uwxAX6b6job0pL D21Lodx2rqVhmECxSPclMSWbMXe0mcRU1Um3shunxGJfY+UTeQWobDVZE+qavNATKX TJaU3rW4LLPJRCE0vJ50pvsmAdKOvRxNqC7R4GkxaXehsErU9ADrWHXm+WAbPf6FtI tcozblnpOXC1BTqMrGT3rY6/vNlQWJ3X8NuIOM5BPeu4MKA8xULWAMwHJvsn+Gr09Y qkesIlMgcrIEmqqyRxt3sDiIc6yYMumjZaTD3p4shA1ud1/IqLppw4Ny9nD3DtwC/f ToxNFFkrAk8wA== Received: from benjamin-XPS-13-9310.. (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 060C137813C0; Tue, 9 Jul 2024 16:17:16 +0000 (UTC) From: Benjamin Gaignard To: mchehab@kernel.org, ezequiel@vanguardiasur.com.ar, hverkuil-cisco@xs4all.nl Cc: linux-media@vger.kernel.or, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v3 1/2] media: videodev2: Add flags to unconditionnaly enumerate pixels formats Date: Tue, 9 Jul 2024 18:17:09 +0200 Message-ID: <20240709161710.83109-2-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240709161710.83109-1-benjamin.gaignard@collabora.com> References: <20240709161710.83109-1-benjamin.gaignard@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add new flags to allow enumerate all pixels formats when calling VIDIOC_ENUM_FMT ioctl. When this V4L2_FMT_FLAG_ENUM_ALL_FORMATS flag is set drivers must ignore the configuration and return the hardware supported pixel formats for the specified queue. To distinguish this partical enumeration case V4L2_FMT_FLAG_ALL_FORMATS flag must be set be drivers so user space applications can know that drivers support this feature. This will permit to discover which pixels formats are supported without setting codec-specific information so userland can more easily knows if the driver suit well to what it needs. The main target are stateless decoders so update the documentation about how use this flag. Signed-off-by: Benjamin Gaignard --- changes in version 3: - Add a flag to inform userspace application that driver as take care of the flag. .../userspace-api/media/v4l/dev-stateless-decoder.rst | 6 ++++++ .../userspace-api/media/v4l/vidioc-enum-fmt.rst | 10 ++++++++++ .../userspace-api/media/videodev2.h.rst.exceptions | 2 ++ drivers/media/v4l2-core/v4l2-ioctl.c | 3 +++ include/uapi/linux/videodev2.h | 2 ++ 5 files changed, 23 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/dev-stateless-decoder.rs= t b/Documentation/userspace-api/media/v4l/dev-stateless-decoder.rst index 35ed05f2695e..de006a7fd02a 100644 --- a/Documentation/userspace-api/media/v4l/dev-stateless-decoder.rst +++ b/Documentation/userspace-api/media/v4l/dev-stateless-decoder.rst @@ -58,6 +58,12 @@ Querying capabilities default values for these controls being used, and a returned set of f= ormats that may not be usable for the media the client is trying to decode. =20 + * If ``V4L2_FMT_FLAG_ENUM_ALL_FORMATS`` flag is set the driver must enu= merate + all the supported formats without taking care of codec-dependent cont= rols + set on ``OUTPUT`` queue. To indicate that the driver has take care of= this + flag it must set ``V4L2_FMT_FLAG_ALL_FORMATS`` flag when it enumerate= s the + format. + 3. The client may use :c:func:`VIDIOC_ENUM_FRAMESIZES` to detect supported resolutions for a given format, passing desired pixel format in :c:type:`v4l2_frmsizeenum`'s ``pixel_format``. diff --git a/Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst b/Do= cumentation/userspace-api/media/v4l/vidioc-enum-fmt.rst index 3adb3d205531..510d2a6700aa 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-enum-fmt.rst @@ -234,6 +234,16 @@ the ``mbus_code`` field is handled differently: valid. The buffer consists of ``height`` lines, each having ``width`` Data Units of data and the offset (in bytes) between the beginning of each two consecutive lines is ``bytesperline``. + * - ``V4L2_FMT_FLAG_ENUM_ALL_FORMATS`` + - 0x0400 + - Set by userland application to enumerate all possible pixels forma= ts + without taking care of any configuration done on OUTPUT or CAPTURE + queues. + * - ``V4L2_FMT_FLAG_ALL_FORMATS`` + - 0x0800 + - Set by driver to indicated that format has been enumerated because + :ref:`V4L2_FMT_FLAG_ENUM_ALL_FORMATS ` = has + been set by userland application. =20 Return Value =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b= /Documentation/userspace-api/media/videodev2.h.rst.exceptions index bdc628e8c1d6..7a3a1e9dc055 100644 --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions @@ -216,6 +216,8 @@ replace define V4L2_FMT_FLAG_CSC_YCBCR_ENC fmtdesc-flags replace define V4L2_FMT_FLAG_CSC_HSV_ENC fmtdesc-flags replace define V4L2_FMT_FLAG_CSC_QUANTIZATION fmtdesc-flags replace define V4L2_FMT_FLAG_META_LINE_BASED fmtdesc-flags +replace define V4L2_FMT_FLAG_ENUM_ALL_FORMATS fmtdesc-flags +replace define V4L2_FMT_FLAG_ALL_FORMATS fmtdesc-flags =20 # V4L2 timecode types replace define V4L2_TC_TYPE_24FPS timecode-type diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core= /v4l2-ioctl.c index 4c76d17b4629..5785a98b6ba2 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1569,6 +1569,7 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *= ops, int ret =3D check_fmt(file, p->type); u32 mbus_code; u32 cap_mask; + u32 flags; =20 if (ret) return ret; @@ -1578,8 +1579,10 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops = *ops, p->mbus_code =3D 0; =20 mbus_code =3D p->mbus_code; + flags =3D p->flags & V4L2_FMT_FLAG_ENUM_ALL_FORMATS; memset_after(p, 0, type); p->mbus_code =3D mbus_code; + p->flags =3D flags; =20 switch (p->type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index fe6b67e83751..b6a5da79ba21 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -886,6 +886,8 @@ struct v4l2_fmtdesc { #define V4L2_FMT_FLAG_CSC_HSV_ENC V4L2_FMT_FLAG_CSC_YCBCR_ENC #define V4L2_FMT_FLAG_CSC_QUANTIZATION 0x0100 #define V4L2_FMT_FLAG_META_LINE_BASED 0x0200 +#define V4L2_FMT_FLAG_ENUM_ALL_FORMATS 0x0400 +#define V4L2_FMT_FLAG_ALL_FORMATS 0x0800 =20 /* Frame Size and frame rate enumeration */ /* --=20 2.43.0 From nobody Sun Feb 8 01:21:16 2026 Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8DDF12C498 for ; Tue, 9 Jul 2024 16:17:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720541847; cv=none; b=pWVsCh35hf4mxLyObGzaqqbD75HbJU6NL6mEbJLKEp5LEmrXqEOi0i4A98KY4thaPPnVEBEhFpTMINS6FTildpvAQ8uPX2vwPiRxTCvvCC+CYhu3C9u+MmdVVuW4iMQ7ta/3tZH5059VWa7Dh+jr31EarRWTphuiTfynHA4ogbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720541847; c=relaxed/simple; bh=kzYMEzDjxTpW5eugXBBcAXl8xSootQ7RO2p3jTHcEPo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aBRaWaN+1ThvrPWHQdYH8xhP3QMdlEF6DeSXgCUePVYap9wUdxMPBLEz9wJTI5raJQBjBJyJX94DyutAv3l5bUvS0ZA78TJrTFBZYXsEGgedogjuZgUo2saRExYQfSI21QAVvtBP/n8IDfG6/Y+zrL+N197xXdiXbzyQOM7As6E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=KErRxHF+; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="KErRxHF+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1720541838; bh=kzYMEzDjxTpW5eugXBBcAXl8xSootQ7RO2p3jTHcEPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KErRxHF+aBh0ns9MwcZyWn3AUq4HrqqVrf185PZ8SvL5ZBCD/duXPMIYO7Zx1lMiV p5l5WSoJYxfzI53aE8x676kcdelt3r6wcOf1RwFTqSHvocwekAd7UyNWvMEa/IZr/b ntU/3k3hkEMMPEG5MwctYLsDWJ2rROaY3z/L3zGUkNMDlomIro8GkoXzPAS+DoCPd7 pDLyGMfweM2zS8Q0e7O7l/Vm24aLcLyCNa+RJbGG65L/h84xGJj06EySRJHL4PlIXW 9jgXgpIhRuvCazLil0QZ2jHkGC/O3H7Xts2nQSuMa7pMdsIOaOYkgI782cHcwUOjAN WOjGKF0FBiWtQ== Received: from benjamin-XPS-13-9310.. (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: benjamin.gaignard) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 96582378219C; Tue, 9 Jul 2024 16:17:17 +0000 (UTC) From: Benjamin Gaignard To: mchehab@kernel.org, ezequiel@vanguardiasur.com.ar, hverkuil-cisco@xs4all.nl Cc: linux-media@vger.kernel.or, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, kernel@collabora.com, Benjamin Gaignard Subject: [PATCH v3 2/2] media: verisilicon: Use V4L2_FMT_FLAG_ENUM_ALL_FORMATS flag Date: Tue, 9 Jul 2024 18:17:10 +0200 Message-ID: <20240709161710.83109-3-benjamin.gaignard@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240709161710.83109-1-benjamin.gaignard@collabora.com> References: <20240709161710.83109-1-benjamin.gaignard@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If V4L2_FMT_FLAG_ENUM_ALL_FORMATS flag has been set when calling VIDIOC_ENUM_FMT ignore depth match and returns all the hardware supported pixels formats. In this case all set V4L2_FMT_FLAG_ALL_FORMATS when returning the pixels formats. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/verisilicon/hantro_v4l2.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/verisilicon/hantro_v4l2.c b/drivers/med= ia/platform/verisilicon/hantro_v4l2.c index df6f2536263b..b995ad31cddc 100644 --- a/drivers/media/platform/verisilicon/hantro_v4l2.c +++ b/drivers/media/platform/verisilicon/hantro_v4l2.c @@ -201,7 +201,13 @@ static int vidioc_enum_fmt(struct file *file, void *pr= iv, struct hantro_ctx *ctx =3D fh_to_ctx(priv); const struct hantro_fmt *fmt, *formats; unsigned int num_fmts, i, j =3D 0; - bool skip_mode_none; + bool skip_mode_none, ignore_depth_match; + + /* + * If V4L2_FMT_FLAG_ALL_FORMATS flag is set, we want to enumerate all + * hardware supported pixels formats + */ + ignore_depth_match =3D !!(f->flags & V4L2_FMT_FLAG_ENUM_ALL_FORMATS); =20 /* * When dealing with an encoder: @@ -222,10 +228,12 @@ static int vidioc_enum_fmt(struct file *file, void *p= riv, =20 if (skip_mode_none =3D=3D mode_none) continue; - if (!hantro_check_depth_match(fmt, ctx->bit_depth)) + if (!hantro_check_depth_match(fmt, ctx->bit_depth) && !ignore_depth_matc= h) continue; if (j =3D=3D f->index) { f->pixelformat =3D fmt->fourcc; + if (ignore_depth_match) + f->flags |=3D V4L2_FMT_FLAG_ALL_FORMATS; return 0; } ++j; @@ -242,10 +250,12 @@ static int vidioc_enum_fmt(struct file *file, void *p= riv, for (i =3D 0; i < num_fmts; i++) { fmt =3D &formats[i]; =20 - if (!hantro_check_depth_match(fmt, ctx->bit_depth)) + if (!hantro_check_depth_match(fmt, ctx->bit_depth) && !ignore_depth_matc= h) continue; if (j =3D=3D f->index) { f->pixelformat =3D fmt->fourcc; + if (ignore_depth_match) + f->flags |=3D V4L2_FMT_FLAG_ALL_FORMATS; return 0; } ++j; --=20 2.43.0