From patchwork Fri Jul 3 17:10:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11642399 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C261912 for ; Fri, 3 Jul 2020 17:10:49 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3596420708 for ; Fri, 3 Jul 2020 17:10:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="siZVVMCu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3596420708 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=o6S7DWW6ewZF7fRzmDrUOtTWUPlKKbfQavoN/1EXl6I=; b=siZVVMCuIb5tTxG6Eelkgau2Nd A7amIq4ht4mSlMdbQLARt8qKBuUdptTMHkSdQM3H2DD3GxKA2AnNeDTFZrrUm2tdF8drnxAeXVLyp QUvpvzBd9ofgKhCZBCj11ep98QqkpJ1chhyYExdpjcr/SC3f5/4Zq7QOUe/dgL6F8kgd8xA2nepKv kVMeZN1UiF9B6n4AUQ4yyfoWQ7r5ylGn3P855to/RsAtANty2ZYjCljiFIrhHkSgDc0d6ipy92Nkz L7l7isvtMp43UQkrJLy+QEctes2vywe7S8olIiNt+oyYRrHfd3iW/a+4Gk9lGkHSxGvJQed8f9SBq J+b3sU3A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrPD3-0004vo-8j; Fri, 03 Jul 2020 17:10:45 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrPCq-0004mt-RM for linux-rockchip@lists.infradead.org; Fri, 03 Jul 2020 17:10:40 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id F0AE52A65C9 From: Dafna Hirschfeld To: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com Subject: [PATCH v5 5/7] media: v4l2: add support for the subdev CSC API for hsv_enc on mediabus Date: Fri, 3 Jul 2020 19:10:17 +0200 Message-Id: <20200703171019.19270-6-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703171019.19270-1-dafna.hirschfeld@collabora.com> References: <20200703171019.19270-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200703_131033_202370_D3BC6C6B X-CRM114-Status: GOOD ( 15.37 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [46.235.227.227 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org Add the flag V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC that drivers can set when enumerating the supported mediabus formats on subdevices to indicate that the userspace can ask to set the 'hsv_enc'. The patch also replaces the 'ycbcr_enc' field in 'struct v4l2_mbus_framefmt' with a union that includes 'hsv_enc' Signed-off-by: Dafna Hirschfeld --- .../media/v4l/subdev-formats.rst | 33 +++++++++++++++---- include/uapi/linux/v4l2-mediabus.h | 8 ++++- include/uapi/linux/v4l2-subdev.h | 1 + 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/subdev-formats.rst b/Documentation/userspace-api/media/v4l/subdev-formats.rst index 7362ee0b1e96..dddc38191547 100644 --- a/Documentation/userspace-api/media/v4l/subdev-formats.rst +++ b/Documentation/userspace-api/media/v4l/subdev-formats.rst @@ -51,7 +51,9 @@ Media Bus Formats The driver indicates that colorspace conversion is supported by setting the flag V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE in the corresponding struct :c:type:`v4l2_subdev_mbus_code_enum` during enumeration. - See :ref:`colorspaces`. + See :ref:`v4l2-subdev-mbus-code-flags`. + * - union { + - (anonymous) * - __u16 - ``ycbcr_enc`` - Y'CbCr encoding, from enum :c:type:`v4l2_ycbcr_encoding`. @@ -67,7 +69,23 @@ Media Bus Formats V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC in the corresponding struct :c:type:`v4l2_subdev_mbus_code_enum` during enumeration. See :ref:`v4l2-subdev-mbus-code-flags`. - + * - __u16 + - ``hsv_enc`` + - HSV encoding, from enum :c:type:`v4l2_hsv_encoding`. + This information supplements the ``colorspace`` and must be set by + the driver for capture streams and by the application for output + streams, see :ref:`colorspaces`. If the application sets the + flag ``V4L2_MBUS_FRAMEFMT_SET_CSC`` then the application can set + this field for a capture stream to request a specific HSV encoding + for the media bus data. If the driver cannot handle requested + conversion, it will return another supported encoding. + This field is ignored for Y'CbCr media bus formats. The driver indicates + that hsv_enc conversion is supported by setting the flag + V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC in the corresponding struct + :c:type:`v4l2_subdev_mbus_code_enum` during enumeration. + See :ref:`v4l2-subdev-mbus-code-flags` + * - } + - * - __u16 - ``quantization`` - Quantization range, from enum :c:type:`v4l2_quantization`. @@ -123,11 +141,12 @@ Media Bus Formats ignored for output streams. If set, then request the subdevice to do colorspace conversion from the received colorspace to the requested colorspace values. If colorimetry field (``colorspace``, ``ycbcr_enc``, - ``quantization`` or ``xfer_func``) is set to 0, then that colorimetry - setting will remain unchanged from what was received. So to change the - quantization, only the ``quantization`` field shall be set to non-zero values - (``V4L2_QUANTIZATION_FULL_RANGE`` or ``V4L2_QUANTIZATION_LIM_RANGE``) - and all other colorimetry fields shall be set to 0. + ''hsv_enc``, ``quantization`` or ``xfer_func``) is set to 0, then that + colorimetry setting will remain unchanged from what was received. So to + change the quantization, only the ``quantization`` field shall be set to + non-zero values (``V4L2_QUANTIZATION_FULL_RANGE`` or + ``V4L2_QUANTIZATION_LIM_RANGE``) and all other colorimetry fields shall + be set to 0. To check which conversions are supported by the hardware for the current media bus frame format, see :ref:`v4l2-subdev-mbus-code-flags`. diff --git a/include/uapi/linux/v4l2-mediabus.h b/include/uapi/linux/v4l2-mediabus.h index 3b7d692b4015..d0bc8df18ad5 100644 --- a/include/uapi/linux/v4l2-mediabus.h +++ b/include/uapi/linux/v4l2-mediabus.h @@ -26,6 +26,7 @@ * @field: used interlacing type (from enum v4l2_field) * @colorspace: colorspace of the data (from enum v4l2_colorspace) * @ycbcr_enc: YCbCr encoding of the data (from enum v4l2_ycbcr_encoding) + * @hsv_enc: HSV encoding of the data (from enum v4l2_hsv_encoding) * @quantization: quantization of the data (from enum v4l2_quantization) * @xfer_func: transfer function of the data (from enum v4l2_xfer_func) * @reserved2: two reserved bytes that can be later used @@ -38,7 +39,12 @@ struct v4l2_mbus_framefmt { __u32 code; __u32 field; __u32 colorspace; - __u16 ycbcr_enc; + union { + /* enum v4l2_ycbcr_encoding */ + __u16 ycbcr_enc; + /* enum v4l2_hsv_encoding */ + __u16 hsv_enc; + }; __u16 quantization; __u16 xfer_func; __u16 reserved2; diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h index c20aa9a89864..08e25a961d15 100644 --- a/include/uapi/linux/v4l2-subdev.h +++ b/include/uapi/linux/v4l2-subdev.h @@ -67,6 +67,7 @@ struct v4l2_subdev_crop { #define V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE 0x00000001 #define V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC 0x00000002 +#define V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC #define V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION 0x00000004 #define V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC 0x00000008 /**