From patchwork Thu Jun 16 18:23:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16249 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 94087C3273 for ; Thu, 16 Jun 2022 18:24:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CB91065640; Thu, 16 Jun 2022 20:24:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655403850; bh=ztBi00rSKDcSgkfJv3UH/XLkdSemXx4Zgh7eNV0uouA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=nLdz1LVQ1C5Cxx2+qLnqzimNq8QaAIwRcNLgX71Xyw9N2Czlmvf7zg8inJBMZJJho JgKh5gd4DiOuRirVFz+NFVY3uPpCZ6MS3NIptBG1v7q3+dYSMyxYHdnTCfH1+H5O0c U34Joa1Tjo9LGJJOi+pWGYgv9B1VTLyt+4sKgnRAfiaxJsZKON93ijWIE/kI+wEe5r 0evc2LTzHlQc50QuxKa2W1kKnNOOZVpipF0GYsC8iQt42WSwF9UWHL44qPECfBuCys bYBW1TVWj2fd6Iep9FdixG6kt6XPtQ1a2kYjpR30JdQwA4MvaIFoj+U90KNhpfK2Ey sI1A+TjfSWhxA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE3B4600F0 for ; Thu, 16 Jun 2022 20:24:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="L449YwWd"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3500D415; Thu, 16 Jun 2022 20:24:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655403846; bh=ztBi00rSKDcSgkfJv3UH/XLkdSemXx4Zgh7eNV0uouA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L449YwWd7OrfX4ExuDlAKCM5KA+Ogu6cb2IO6xUte3VulhvsB8oEOxyQa89KQLl6V qwQ2G++C8Cpd/16DElQjbhMwPus/frF0MIQTzMxM8Mectp17Lq/vPOUf9uWCHLVk+s v7QwxLjGFe6GRkRz26/Hvm7kTFI5id3Sgu3LztlY= To: libcamera-devel@lists.libcamera.org Date: Thu, 16 Jun 2022 21:23:44 +0300 Message-Id: <20220616182350.17352-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220616182350.17352-1-laurent.pinchart@ideasonboard.com> References: <20220616182350.17352-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/7] media: v4l: Add packed YUV 4:4:4 YUVA and YUVX pixel formats X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Sakari Ailus , linux-imx@nxp.com, kernel@pengutronix.de, Hans Verkuil Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The new YUVA and YUVX are permutations of the existing AYUV and XYUV formats. They are use by the NXP i.MX8 ISI hardware. Signed-off-by: Laurent Pinchart Reviewed-by: Nicolas Dufresne Reviewed-by: Jacopo Mondi --- .../media/v4l/pixfmt-packed-yuv.rst | 20 +++++++++++++++++++ drivers/media/v4l2-core/v4l2-ioctl.c | 2 ++ include/uapi/linux/videodev2.h | 2 ++ 3 files changed, 24 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/pixfmt-packed-yuv.rst b/Documentation/userspace-api/media/v4l/pixfmt-packed-yuv.rst index 65520c3af7cf..bf283a1b5581 100644 --- a/Documentation/userspace-api/media/v4l/pixfmt-packed-yuv.rst +++ b/Documentation/userspace-api/media/v4l/pixfmt-packed-yuv.rst @@ -220,6 +220,26 @@ the second byte and Y'\ :sub:`7-0` in the third byte. - Y'\ :sub:`7-0` - X\ :sub:`7-0` + * .. _V4L2-PIX-FMT-YUVA32: + + - ``V4L2_PIX_FMT_YUVA32`` + - 'YUVA' + + - Y'\ :sub:`7-0` + - Cb\ :sub:`7-0` + - Cr\ :sub:`7-0` + - A\ :sub:`7-0` + + * .. _V4L2-PIX-FMT-YUVX32: + + - ``V4L2_PIX_FMT_YUVX32`` + - 'YUVX' + + - Y'\ :sub:`7-0` + - Cb\ :sub:`7-0` + - Cr\ :sub:`7-0` + - X\ :sub:`7-0` + * .. _V4L2-PIX-FMT-YUV24: - ``V4L2_PIX_FMT_YUV24`` diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index f42f7ffcc247..18ed2227255a 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1297,6 +1297,8 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) case V4L2_PIX_FMT_XYUV32: descr = "32-bit XYUV 8-8-8-8"; break; case V4L2_PIX_FMT_VUYA32: descr = "32-bit VUYA 8-8-8-8"; break; case V4L2_PIX_FMT_VUYX32: descr = "32-bit VUYX 8-8-8-8"; break; + case V4L2_PIX_FMT_YUVA32: descr = "32-bit YUVA 8-8-8-8"; break; + case V4L2_PIX_FMT_YUVX32: descr = "32-bit YUVX 8-8-8-8"; break; case V4L2_PIX_FMT_YUV410: descr = "Planar YUV 4:1:0"; break; case V4L2_PIX_FMT_YUV420: descr = "Planar YUV 4:2:0"; break; case V4L2_PIX_FMT_HI240: descr = "8-bit Dithered RGB (BTTV)"; break; diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 343b95107fce..f6f9a690971e 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -593,6 +593,8 @@ struct v4l2_pix_format { #define V4L2_PIX_FMT_XYUV32 v4l2_fourcc('X', 'Y', 'U', 'V') /* 32 XYUV-8-8-8-8 */ #define V4L2_PIX_FMT_VUYA32 v4l2_fourcc('V', 'U', 'Y', 'A') /* 32 VUYA-8-8-8-8 */ #define V4L2_PIX_FMT_VUYX32 v4l2_fourcc('V', 'U', 'Y', 'X') /* 32 VUYX-8-8-8-8 */ +#define V4L2_PIX_FMT_YUVA32 v4l2_fourcc('Y', 'U', 'V', 'A') /* 32 YUVA-8-8-8-8 */ +#define V4L2_PIX_FMT_YUVX32 v4l2_fourcc('Y', 'U', 'V', 'X') /* 32 YUVX-8-8-8-8 */ #define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */ /* two planes -- one Y, one Cr + Cb interleaved */ From patchwork Thu Jun 16 18:23:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16250 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id F3083C3274 for ; Thu, 16 Jun 2022 18:24:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DE31865636; Thu, 16 Jun 2022 20:24:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655403851; bh=b8WkaueeIzLEqbQ8sB35rfXwjGfTvjGApyJfYg7OAtg=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=eE9+jMGyg29VsC6ygaxVmc71U54Wh2DSPZ3YjHfKOgIyiVofori/TnBePh9qps85Q IQ0esTbywHAVcIApPQb9VcTUbiQJn6maXjDj9aOnevV07/fQU6bZ0axyErJtANM3P/ 5yED5ek/YPurTSkoGSrxzDVhw6s0m07ppOqPfbUMcfYCHttPT2XmLfnQ74+MnpPpVW GN602cuCHXgoko4Es0IXN/SiTbjrc8gNZ6bLIqm7Njtu+LhjMSNL6G0uiHQSgagc+l VZ9ObEqWZnwDnuDeCWgL797b1y3BYwA2j1CfsjhFZXA9YaGjs6OZENEaxAzgVgkY99 DVrF5HNMGKB8w== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BE36E6563A for ; Thu, 16 Jun 2022 20:24:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="M18GfE/C"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E48B359D; Thu, 16 Jun 2022 20:24:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655403847; bh=b8WkaueeIzLEqbQ8sB35rfXwjGfTvjGApyJfYg7OAtg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M18GfE/CXl6Ur/3WnGEI3nGYCaRfE3A12zxPeNGiwNv7p8ZacAosbLs9dIYHOpcIF pGKKWnfeU0xyzSEL4/GxZUCXJK3owAQKwELZlQv6BW1XHz1sCG31wsq36oltIOsS4W FABHzCKLzeCH/SJ+8pSyfRamM8nKdZd1rovQRq94= To: libcamera-devel@lists.libcamera.org Date: Thu, 16 Jun 2022 21:23:45 +0300 Message-Id: <20220616182350.17352-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220616182350.17352-1-laurent.pinchart@ideasonboard.com> References: <20220616182350.17352-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/7] media: v4l2-tpg: Add support for the new YUVA and YUVX formats X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Sakari Ailus , linux-imx@nxp.com, kernel@pengutronix.de, Hans Verkuil Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Extend the TPG to support generating the newly added YUVA and YUVX pixel formats. Signed-off-by: Laurent Pinchart --- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c index 7607b516a7c4..29d24f8d7c28 100644 --- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c @@ -266,6 +266,8 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) case V4L2_PIX_FMT_XYUV32: case V4L2_PIX_FMT_VUYA32: case V4L2_PIX_FMT_VUYX32: + case V4L2_PIX_FMT_YUVA32: + case V4L2_PIX_FMT_YUVX32: tpg->color_enc = TGP_COLOR_ENC_YCBCR; break; case V4L2_PIX_FMT_YUV420M: @@ -412,6 +414,8 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) case V4L2_PIX_FMT_XYUV32: case V4L2_PIX_FMT_VUYA32: case V4L2_PIX_FMT_VUYX32: + case V4L2_PIX_FMT_YUVA32: + case V4L2_PIX_FMT_YUVX32: case V4L2_PIX_FMT_HSV32: tpg->twopixelsize[0] = 2 * 4; break; @@ -1376,9 +1380,11 @@ static void gen_twopix(struct tpg_data *tpg, buf[0][offset + 3] = b_v; break; case V4L2_PIX_FMT_RGBX32: + case V4L2_PIX_FMT_YUVX32: alpha = 0; fallthrough; case V4L2_PIX_FMT_RGBA32: + case V4L2_PIX_FMT_YUVA32: buf[0][offset] = r_y_h; buf[0][offset + 1] = g_u_s; buf[0][offset + 2] = b_v; From patchwork Thu Jun 16 18:23:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16251 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0CEA5BD161 for ; Thu, 16 Jun 2022 18:24:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7FA7A65641; Thu, 16 Jun 2022 20:24:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655403853; bh=RN1KaYPR86OAmsv+ndwaXA/1GmqnIThqQYd+ZcJZLBI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=fcao0d3ctwGXQAXxv+UtJ0IZi26M4n2EM4B7KTDzcwmXMcs2bIqLwSwsz8q5i1Phj Ll9sMBenvl+RXD3uG/dM7bxL1jmlkJpr3skbEXdqT7DFMVZmESBw170wry17UnORj8 79s47mPtJc/k/4Qmmqxt2XA3lKmx2uwJric2vK8nF2TLYw8CkprXZtZDyyo5R2hK1O /k8kNBBFTjkC75IA8FtbRIJENSQoCWUwkG65jjH0K2CSmcksoq3THeHu/blXLvL69v e8AC5AL88eqfZ/x/aQV1iVcowPR9RrTeGV6cjDdX7sh0q3T44s11anchkwbqiXHmQv yeqo8XYkeK1Qg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6288E6563D for ; Thu, 16 Jun 2022 20:24:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="YhTCugoS"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A0E12898; Thu, 16 Jun 2022 20:24:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655403848; bh=RN1KaYPR86OAmsv+ndwaXA/1GmqnIThqQYd+ZcJZLBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YhTCugoSHioUxDgIbJMmmLSDvQKGV70X3a/faGxccV8m/Pt87rjopkg/Gwbl/tiU4 RXG6DXKyx6jbE3B8nJhHrAWBo8SM45Zm+4tP3HLahf7DjvU6jIIulpRfBGCL0c7aoU sRqBOoMRtKl6OOUlRRJFepXdrvCeM9YljIVkClRE= To: libcamera-devel@lists.libcamera.org Date: Thu, 16 Jun 2022 21:23:46 +0300 Message-Id: <20220616182350.17352-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220616182350.17352-1-laurent.pinchart@ideasonboard.com> References: <20220616182350.17352-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/7] media: vivid: Add support for the new YUVA and YUVX formats X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Sakari Ailus , linux-imx@nxp.com, kernel@pengutronix.de, Hans Verkuil Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Extend vivid to support the newly added YUVA and YUVX pixel formats through the TPG. Signed-off-by: Laurent Pinchart --- .../media/test-drivers/vivid/vivid-vid-common.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/media/test-drivers/vivid/vivid-vid-common.c b/drivers/media/test-drivers/vivid/vivid-vid-common.c index 19701fe72030..38d788b5cf19 100644 --- a/drivers/media/test-drivers/vivid/vivid-vid-common.c +++ b/drivers/media/test-drivers/vivid/vivid-vid-common.c @@ -198,6 +198,21 @@ struct vivid_fmt vivid_formats[] = { .planes = 1, .buffers = 1, }, + { + .fourcc = V4L2_PIX_FMT_YUVA32, + .vdownsampling = { 1 }, + .bit_depth = { 32 }, + .planes = 1, + .buffers = 1, + .alpha_mask = 0xff000000, + }, + { + .fourcc = V4L2_PIX_FMT_YUVX32, + .vdownsampling = { 1 }, + .bit_depth = { 32 }, + .planes = 1, + .buffers = 1, + }, { .fourcc = V4L2_PIX_FMT_GREY, .vdownsampling = { 1 }, From patchwork Thu Jun 16 18:23:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16252 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0010AC3275 for ; Thu, 16 Jun 2022 18:24:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 77F936563F; Thu, 16 Jun 2022 20:24:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655403854; bh=4oraDFQGac7iP6sqkblu/Ky4ylMjLz5Y9aGH+ReEdXc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=fJjmpLRcLoLwissGvhP62SEaFNYRiJguTGEPwemruEfq6Dr8yvctbdR1Qs7uRZ6h2 H0M45VW2/OeKJh6xKoiWinGDOuIr2rlHjiFl9gkYbU012Pf2ocIxmykkkoh1pjAG5N GEoXHw0wGe+ytNlKoRMk90qerQGNUP/YbKs42t2JNXtwd++HteubD1U23bMf2FgIkQ cFkptBc7MyNaBaV2rE5PoMnRPIUjSV9CCbUcku9KV6VlSn4CDTLBM8w/UwnjzR+T6x djg2NQicEJ/oHY9MpDLoO5WrAXc7LFM/KQHnx4O+NIl7GHZO6p7nGsORnf1Jko8+tN 0x5b5N6fleV8Q== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2FAF065634 for ; Thu, 16 Jun 2022 20:24:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Tv8WrHly"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7683E8AF; Thu, 16 Jun 2022 20:24:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655403849; bh=4oraDFQGac7iP6sqkblu/Ky4ylMjLz5Y9aGH+ReEdXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tv8WrHlySezVN6fDhTI1NYNOTwfDe8bmAg8OzSLwB/5wd6owwcUG6rL4uAo5+ukmz L1Aq07ueaGPPScgZN50j9X3BMiLj8m+6sccGbq5URgoUL4qNHYZ3X2Glyk44BWmm90 Wu88U4ZbfluP5fALCbNBBkV9wgM8ZArTIGZTbgXI= To: libcamera-devel@lists.libcamera.org Date: Thu, 16 Jun 2022 21:23:47 +0300 Message-Id: <20220616182350.17352-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220616182350.17352-1-laurent.pinchart@ideasonboard.com> References: <20220616182350.17352-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/7] media: v4l2: Make colorspace validity checks more future-proof X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Sakari Ailus , linux-imx@nxp.com, kernel@pengutronix.de, Hans Verkuil Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The helper functions that test validity of colorspace-related fields use the last value of the corresponding enums. This isn't very future-proof, as there's a high chance someone adding a new value may forget to update the helpers. Add new "LAST" entries to the enumerations to improve this, and keep them private to the kernel. Signed-off-by: Laurent Pinchart Acked-by: Sakari Ailus --- Changes since v1: - Let the compiler assign a value to the *_LAST enum entries --- include/media/v4l2-common.h | 10 +++++----- include/uapi/linux/videodev2.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index 3eb202259e8c..ccc138a9104d 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -563,19 +563,19 @@ static inline void v4l2_buffer_set_timestamp(struct v4l2_buffer *buf, static inline bool v4l2_is_colorspace_valid(__u32 colorspace) { return colorspace > V4L2_COLORSPACE_DEFAULT && - colorspace <= V4L2_COLORSPACE_DCI_P3; + colorspace < V4L2_COLORSPACE_LAST; } static inline bool v4l2_is_xfer_func_valid(__u32 xfer_func) { return xfer_func > V4L2_XFER_FUNC_DEFAULT && - xfer_func <= V4L2_XFER_FUNC_SMPTE2084; + xfer_func < V4L2_XFER_FUNC_LAST; } static inline bool v4l2_is_ycbcr_enc_valid(__u8 ycbcr_enc) { return ycbcr_enc > V4L2_YCBCR_ENC_DEFAULT && - ycbcr_enc <= V4L2_YCBCR_ENC_SMPTE240M; + ycbcr_enc < V4L2_YCBCR_ENC_LAST; } static inline bool v4l2_is_hsv_enc_valid(__u8 hsv_enc) @@ -585,8 +585,8 @@ static inline bool v4l2_is_hsv_enc_valid(__u8 hsv_enc) static inline bool v4l2_is_quant_valid(__u8 quantization) { - return quantization == V4L2_QUANTIZATION_FULL_RANGE || - quantization == V4L2_QUANTIZATION_LIM_RANGE; + return quantization > V4L2_QUANTIZATION_DEFAULT && + quantization < V4L2_QUANTIZATION_LAST; } #endif /* V4L2_COMMON_H_ */ diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index f6f9a690971e..7b7d852dc74b 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -245,6 +245,14 @@ enum v4l2_colorspace { /* DCI-P3 colorspace, used by cinema projectors */ V4L2_COLORSPACE_DCI_P3 = 12, + +#ifdef __KERNEL__ + /* + * Largest supported colorspace value, assigned by the compiler, used + * by the framework to check for invalid values. + */ + V4L2_COLORSPACE_LAST, +#endif }; /* @@ -283,6 +291,13 @@ enum v4l2_xfer_func { V4L2_XFER_FUNC_NONE = 5, V4L2_XFER_FUNC_DCI_P3 = 6, V4L2_XFER_FUNC_SMPTE2084 = 7, +#ifdef __KERNEL__ + /* + * Largest supported transfer function value, assigned by the compiler, + * used by the framework to check for invalid values. + */ + V4L2_XFER_FUNC_LAST, +#endif }; /* @@ -343,6 +358,13 @@ enum v4l2_ycbcr_encoding { /* SMPTE 240M -- Obsolete HDTV */ V4L2_YCBCR_ENC_SMPTE240M = 8, +#ifdef __KERNEL__ + /* + * Largest supported encoding value, assigned by the compiler, used by + * the framework to check for invalid values. + */ + V4L2_YCBCR_ENC_LAST, +#endif }; /* @@ -378,6 +400,13 @@ enum v4l2_quantization { V4L2_QUANTIZATION_DEFAULT = 0, V4L2_QUANTIZATION_FULL_RANGE = 1, V4L2_QUANTIZATION_LIM_RANGE = 2, +#ifdef __KERNEL__ + /* + * Largest supported quantization value, assigned by the compiler, used + * by the framework to check for invalid values. + */ + V4L2_QUANTIZATION_LAST, +#endif }; /* From patchwork Thu Jun 16 18:23:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16253 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C2A0FC3276 for ; Thu, 16 Jun 2022 18:24:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F2F0A65645; Thu, 16 Jun 2022 20:24:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655403855; bh=bWNlCtgrMVPV7UjDm0QpNxf3zyYr7EaxNscRNaxH4jw=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=bW6SuRFyBplRjYKZW5ayFc/i1ZVF18wZcYN0w1EYxlTpJ6ppHkohr3RkB8FY+qNUd gXcc08+6otWr0iuIGP49K14toeFVZQxWv9dQaFpKwqOH6ZUQ+LUnFz24fewKYuq4CA LoAZIfiz5puB3AxDnFRN44y0VNw8Ge7gXE9AzkAhiW1jhw/VVizyvsJlJ3sYoqIpBc UFHVLi4izBYdyBADviHEZQ5VMYcY1sknLAI5ge/HepvNbGBaA2133dQm42RvDg4X8Y Fpt0BJmONygQn45eGehrurdgZQLRXIV+olHtF77+qR9jASAb1YDjqkdeAFmtxW6BCH yJFrn4bL1RDsA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F28DC600F0 for ; Thu, 16 Jun 2022 20:24:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vJMHmKCD"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3AF3ABC0; Thu, 16 Jun 2022 20:24:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655403849; bh=bWNlCtgrMVPV7UjDm0QpNxf3zyYr7EaxNscRNaxH4jw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vJMHmKCDQNT99G/rz6gEGI4ajhlaDWhmCPRup+swIpKaHw5kvaFdhWt+66/zo2Hjt AkY3Pg4kN/4x0FxL4Sy03tgbJBGn4cw6TTFO2j/3MxbHtMJmffsr2FA9xwhNu/UFfk lOdjCMPlLW0ok+M4sunCVqmJa2yjTai7fvBZPxCQ= To: libcamera-devel@lists.libcamera.org Date: Thu, 16 Jun 2022 21:23:48 +0300 Message-Id: <20220616182350.17352-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220616182350.17352-1-laurent.pinchart@ideasonboard.com> References: <20220616182350.17352-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/7] media: v4l2: Sanitize colorspace values in the framework X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Sakari Ailus , linux-imx@nxp.com, kernel@pengutronix.de, Hans Verkuil Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Extend the format sanitization code in the framework to handle invalid values for the colorspace-related fields. Signed-off-by: Laurent Pinchart Acked-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-ioctl.c | 65 +++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 10 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 18ed2227255a..24b5968e8f32 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1008,6 +1008,31 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type) return -EINVAL; } +static void v4l_sanitize_colorspace(u32 pixelformat, u32 *colorspace, + u32 *encoding, u32 *quantization, + u32 *xfer_func) +{ + bool is_hsv = pixelformat == V4L2_PIX_FMT_HSV24 || + pixelformat == V4L2_PIX_FMT_HSV32; + + if (!v4l2_is_colorspace_valid(*colorspace)) { + *colorspace = V4L2_COLORSPACE_DEFAULT; + *encoding = V4L2_YCBCR_ENC_DEFAULT; + *quantization = V4L2_QUANTIZATION_DEFAULT; + *xfer_func = V4L2_XFER_FUNC_DEFAULT; + } + + if ((!is_hsv && !v4l2_is_ycbcr_enc_valid(*encoding)) || + (is_hsv && !v4l2_is_hsv_enc_valid(*encoding))) + *encoding = V4L2_YCBCR_ENC_DEFAULT; + + if (!v4l2_is_quant_valid(*quantization)) + *quantization = V4L2_QUANTIZATION_DEFAULT; + + if (!v4l2_is_xfer_func_valid(*xfer_func)) + *xfer_func = V4L2_XFER_FUNC_DEFAULT; +} + static void v4l_sanitize_format(struct v4l2_format *fmt) { unsigned int offset; @@ -1027,20 +1052,40 @@ static void v4l_sanitize_format(struct v4l2_format *fmt) * field to the magic value when the extended pixel format structure * isn't used by applications. */ + if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE || + fmt->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { + if (fmt->fmt.pix.priv != V4L2_PIX_FMT_PRIV_MAGIC) { + fmt->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC; - if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && - fmt->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) - return; + offset = offsetof(struct v4l2_pix_format, priv) + + sizeof(fmt->fmt.pix.priv); + memset(((void *)&fmt->fmt.pix) + offset, 0, + sizeof(fmt->fmt.pix) - offset); + } + } - if (fmt->fmt.pix.priv == V4L2_PIX_FMT_PRIV_MAGIC) - return; + /* Replace invalid colorspace values with defaults. */ + if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE || + fmt->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { + v4l_sanitize_colorspace(fmt->fmt.pix.pixelformat, + &fmt->fmt.pix.colorspace, + &fmt->fmt.pix.ycbcr_enc, + &fmt->fmt.pix.quantization, + &fmt->fmt.pix.xfer_func); + } else if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE || + fmt->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + u32 ycbcr_enc = fmt->fmt.pix_mp.ycbcr_enc; + u32 quantization = fmt->fmt.pix_mp.quantization; + u32 xfer_func = fmt->fmt.pix_mp.xfer_func; - fmt->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC; + v4l_sanitize_colorspace(fmt->fmt.pix_mp.pixelformat, + &fmt->fmt.pix_mp.colorspace, &ycbcr_enc, + &quantization, &xfer_func); - offset = offsetof(struct v4l2_pix_format, priv) - + sizeof(fmt->fmt.pix.priv); - memset(((void *)&fmt->fmt.pix) + offset, 0, - sizeof(fmt->fmt.pix) - offset); + fmt->fmt.pix_mp.ycbcr_enc = ycbcr_enc; + fmt->fmt.pix_mp.quantization = quantization; + fmt->fmt.pix_mp.xfer_func = xfer_func; + } } static int v4l_querycap(const struct v4l2_ioctl_ops *ops, From patchwork Thu Jun 16 18:23:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16254 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id E1851C3277 for ; Thu, 16 Jun 2022 18:24:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6FFC06564F; Thu, 16 Jun 2022 20:24:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655403856; bh=6zhorOMHMcApn1JCVBnoz1jaHDN+7f/JdyrBu4DYqwk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=C6Kxrww+JAvtmLa3lbo7yfYzTVDgbBIOInl585ygyiSpV21KhZzv7fd/3EnUcenA7 6B/XYGwYMGJWR3F2tLh2ZhlfjTEy/Zwr3+13400Gg1JEdkTntILCILR3qsHE3P05Du fE5vzI43VYiPRVUJMivvByU2PAYXfJmLdfLrZXfk20e5c3gu8UW6/r2uP9/JUXycAS c251o21k5mCZuBfxhOooon1g5ZQARH74VO0Jnv8O0g/Fp5PogYUIsQgHhcuRrR8tiT c4Si7urhzMkuZYonaxJqvUrvaFmRAGg/n8CYl3MCy/E6mEjUussgEh5Oe6+s5Zmu+1 2DqZFkkodF/YQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D8E2665641 for ; Thu, 16 Jun 2022 20:24:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IzrHQr2L"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F35B5DBF; Thu, 16 Jun 2022 20:24:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655403850; bh=6zhorOMHMcApn1JCVBnoz1jaHDN+7f/JdyrBu4DYqwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IzrHQr2Lo8z1eo+AiH6zpLqtkmmhD6axP+JKJBG4rZSBao/9VY+BGhtCm7I9gxQMq XSsRv0HAhybzNJWxpVcGwgyhIqGvxffwn5nAlxsDXyBo7jbZdA8iuabWntN5KcyrYZ He+8T9QGwsWrEAFD8a3q+VE4HwuuXYPA4nzORhq8= To: libcamera-devel@lists.libcamera.org Date: Thu, 16 Jun 2022 21:23:49 +0300 Message-Id: <20220616182350.17352-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220616182350.17352-1-laurent.pinchart@ideasonboard.com> References: <20220616182350.17352-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 6/7] dt-bindings: media: Add i.MX8 ISI DT bindings X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: devicetree@vger.kernel.org, Krzysztof Kozlowski , Rob Herring , Sakari Ailus , linux-imx@nxp.com, kernel@pengutronix.de, Hans Verkuil Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The Image Sensing Interface (ISI) combines image processing pipelines with DMA engines to process and capture frames originating from a variety of sources. The inputs to the ISI go through Pixel Link interfaces, and their number and nature is SoC-dependent. They cover both capture interfaces (MIPI CSI-2 RX, HDMI RX) and memory inputs. Signed-off-by: Laurent Pinchart --- .../bindings/media/nxp,imx8-isi.yaml | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/nxp,imx8-isi.yaml diff --git a/Documentation/devicetree/bindings/media/nxp,imx8-isi.yaml b/Documentation/devicetree/bindings/media/nxp,imx8-isi.yaml new file mode 100644 index 000000000000..6812c66fa49d --- /dev/null +++ b/Documentation/devicetree/bindings/media/nxp,imx8-isi.yaml @@ -0,0 +1,146 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/nxp,imx8-isi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: i.MX8 Image Sensing Interface + +maintainers: + - Laurent Pinchart + +description: | + The Image Sensing Interface (ISI) combines image processing pipelines with + DMA engines to process and capture frames originating from a variety of + sources. The inputs to the ISI go through Pixel Link interfaces, and their + number and nature is SoC-dependent. They cover both capture interfaces (MIPI + CSI-2 RX, HDMI RX, ...) and display engine outputs for writeback support. + +properties: + compatible: + enum: + - fsl,imx8mn-isi + - fsl,imx8mp-isi + + reg: + maxItems: 1 + + clocks: + items: + - description: The AXI clock + - description: The APB clock + # TODO: Check if the per-channel ipg_proc_clk clocks need to be specified + # as well, in case some SoCs have the ability to control them separately. + # This may be the case of the i.MX8[DQ]X(P) + + clock-names: + items: + - const: axi + - const: apb + + fsl,blk-ctrl: + $ref: /schemas/types.yaml#/definitions/phandle + description: + A phandle referencing the block control that contains the CSIS to ISI + gasket. + + power-domains: true + + ports: + $ref: /schemas/graph.yaml#/properties/ports + description: | + Ports represent the Pixel Link inputs to the ISI. Their number and + assignment are model-dependent. Each port shall have a single endpoint. + + patternProperties: + "^port@[0-9]$": + $ref: /schemas/graph.yaml#/properties/port + unevaluatedProperties: false + + unevaluatedProperties: false + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - fsl,blk-ctrl + - ports + +allOf: + - if: + properties: + compatible: + contains: + const: nxp,imx8mn-isi + then: + properties: + interrupts: + maxItems: 1 + ports: + properties: + port@0: + description: MIPI CSI-2 RX + required: + - port@0 + + - if: + properties: + compatible: + contains: + const: nxp,imx8mp-isi + then: + properties: + interrupts: + maxItems: 2 + ports: + properties: + port@0: + description: MIPI CSI-2 RX 0 + port@1: + description: MIPI CSI-2 RX 1 + required: + - port@0 + - port@1 + +additionalProperties: false + +examples: + - | + #include + #include + #include + + isi@32e00000 { + compatible = "fsl,imx8mp-isi"; + reg = <0x32e00000 0x4000>; + interrupts = , + ; + clocks = <&clk IMX8MP_CLK_MEDIA_AXI_ROOT>, + <&clk IMX8MP_CLK_MEDIA_APB_ROOT>; + clock-names = "axi", "apb"; + fsl,blk-ctrl = <&media_blk_ctrl>; + power-domains = <&mediamix_pd>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + isi_in_0: endpoint { + remote-endpoint = <&mipi_csi_0_out>; + }; + }; + + port@1 { + reg = <1>; + isi_in_1: endpoint { + remote-endpoint = <&mipi_csi_1_out>; + }; + }; + }; + }; + +...