From patchwork Fri Jul 3 18:02:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11642599 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 ABCE614B7 for ; Fri, 3 Jul 2020 18:02:59 +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 84A1D21D7D for ; Fri, 3 Jul 2020 18:02:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gBlZg0bi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84A1D21D7D 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=SUam9+CXAy6zyJOyZ3NLUuGndKdqLvehvaOSMjltvBg=; b=gBlZg0bikNjOvtfL38j4dk81pY G0ZmIPJ3mbWRruflJiVuXuoowHp2TcXU6LCqUDMlz3mWdaO7lPBnj22I24/g0Yuu9WEsZLuw7fTgu jtNYA4KyCy7VA8aT9hj7XA+CI6Or98QP25/mRPWO0jA8cRhL+jNiTyiyh/QVnBymbeF3xRNCW6D+l pRE8RWXIxRLP1iJYBZtoJJGZsjyaph0pBkzKH2l76d6t4gLY9jgTnafN0UYpKxVdBdsqVvW8wPpM4 lIe4NBYJE7vN3h9W+2H7prt2HFJRaYwqj4qlhptnjgOIOzyNsSD79ATcvmGmb/RshLXtXfJTBuxoy vtmknkxQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrQ1X-0003II-J9; Fri, 03 Jul 2020 18:02:55 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrQ1T-0003ET-Tv for linux-rockchip@lists.infradead.org; Fri, 03 Jul 2020 18:02:53 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 04FC82A64FE From: Dafna Hirschfeld To: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com Subject: [PATCH v4l-utils v5 1/4] v4l2-ctl: vidcap: Add support for the CSC API Date: Fri, 3 Jul 2020 20:02:36 +0200 Message-Id: <20200703180239.25841-2-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703180239.25841-1-dafna.hirschfeld@collabora.com> References: <20200703180239.25841-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200703_140252_083892_50C21F3F X-CRM114-Status: GOOD ( 12.27 ) 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 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 With the CSC API, capture drivers can allow userspace to request to set the colorspace fields of the pixelformat. This patch adds supports for this feature. when calling 'v4l2-ctl --set-fmt-video' on capture devices userspace can ask to change the fields 'colorspace', 'ycbcr/hsv_enc', 'quantization' and 'xfer_func' of the format if the driver supports it. Signed-off-by: Dafna Hirschfeld --- utils/v4l2-compliance/v4l2-test-formats.cpp | 4 ++- utils/v4l2-ctl/v4l2-ctl-vidcap.cpp | 39 +++++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp index e1b00f3c..70e5f506 100644 --- a/utils/v4l2-compliance/v4l2-test-formats.cpp +++ b/utils/v4l2-compliance/v4l2-test-formats.cpp @@ -264,7 +264,9 @@ static int testEnumFormatsType(struct node *node, unsigned type) return fail("drivers must never set the emulated flag\n"); if (fmtdesc.flags & ~(V4L2_FMT_FLAG_COMPRESSED | V4L2_FMT_FLAG_EMULATED | V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM | - V4L2_FMT_FLAG_DYN_RESOLUTION)) + V4L2_FMT_FLAG_DYN_RESOLUTION | V4L2_FMT_FLAG_CSC_COLORSPACE | + V4L2_FMT_FLAG_CSC_YCBCR_ENC | V4L2_FMT_FLAG_CSC_HSV_ENC | + V4L2_FMT_FLAG_CSC_QUANTIZATION | V4L2_FMT_FLAG_CSC_XFER_FUNC)) return fail("unknown flag %08x returned\n", fmtdesc.flags); if (!(fmtdesc.flags & V4L2_FMT_FLAG_COMPRESSED)) fail_on_test(fmtdesc.flags & (V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM | diff --git a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp index 80312b51..26c8a578 100644 --- a/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-vidcap.cpp @@ -21,6 +21,7 @@ static struct v4l2_frmsizeenum frmsize; /* list frame sizes */ static struct v4l2_frmivalenum frmival; /* list frame intervals */ static unsigned set_fmts; static __u32 width, height, pixfmt, field, flags; +static __u32 ycbcr, quantization, xfer_func, colorspace; static __u32 bytesperline[VIDEO_MAX_PLANES]; static __u32 sizeimage[VIDEO_MAX_PLANES]; @@ -101,7 +102,6 @@ static void print_video_fields(int fd) void vidcap_cmd(int ch, char *optarg) { - __u32 colorspace, xfer_func, ycbcr, quantization; char *value, *subs; bool be_pixfmt; @@ -111,8 +111,7 @@ void vidcap_cmd(int ch, char *optarg) set_fmts = parse_fmt(optarg, width, height, pixfmt, field, colorspace, xfer_func, ycbcr, quantization, flags, bytesperline, sizeimage); - if (!set_fmts || - (set_fmts & (FmtColorspace | FmtYCbCr | FmtQuantization | FmtXferFunc))) { + if (!set_fmts) { vidcap_usage(); std::exit(EXIT_FAILURE); } @@ -220,6 +219,23 @@ int vidcap_get_and_update_fmt(cv4l_fd &_fd, struct v4l2_format &vfmt) vfmt.fmt.pix_mp.plane_fmt[i].sizeimage = sizeimage[i]; } + + if (set_fmts & FmtColorspace) { + vfmt.fmt.pix_mp.flags |= V4L2_PIX_FMT_FLAG_SET_CSC; + vfmt.fmt.pix_mp.colorspace = colorspace; + } + if (set_fmts & FmtYCbCr) { + vfmt.fmt.pix_mp.flags |= V4L2_PIX_FMT_FLAG_SET_CSC; + vfmt.fmt.pix_mp.ycbcr_enc = ycbcr; + } + if (set_fmts & FmtQuantization) { + vfmt.fmt.pix_mp.flags |= V4L2_PIX_FMT_FLAG_SET_CSC; + vfmt.fmt.pix_mp.quantization = quantization; + } + if (set_fmts & FmtXferFunc) { + vfmt.fmt.pix_mp.flags |= V4L2_PIX_FMT_FLAG_SET_CSC; + vfmt.fmt.pix_mp.xfer_func = xfer_func; + } } else { if (set_fmts & FmtWidth) vfmt.fmt.pix.width = width; @@ -249,6 +265,23 @@ int vidcap_get_and_update_fmt(cv4l_fd &_fd, struct v4l2_format &vfmt) } if (set_fmts & FmtSizeImage) vfmt.fmt.pix.sizeimage = sizeimage[0]; + if (set_fmts & FmtColorspace) { + vfmt.fmt.pix.flags |= V4L2_PIX_FMT_FLAG_SET_CSC; + vfmt.fmt.pix.colorspace = colorspace; + } + if (set_fmts & FmtYCbCr) { + vfmt.fmt.pix.flags |= V4L2_PIX_FMT_FLAG_SET_CSC; + vfmt.fmt.pix.ycbcr_enc = ycbcr; + } + if (set_fmts & FmtQuantization) { + vfmt.fmt.pix.flags |= V4L2_PIX_FMT_FLAG_SET_CSC; + vfmt.fmt.pix.quantization = quantization; + } + if (set_fmts & FmtXferFunc) { + vfmt.fmt.pix.flags |= V4L2_PIX_FMT_FLAG_SET_CSC; + vfmt.fmt.pix.xfer_func = xfer_func; + } + } if ((set_fmts & FmtPixelFormat) && From patchwork Fri Jul 3 18:02:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11642601 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 09A4E14B7 for ; Fri, 3 Jul 2020 18:03:01 +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 D6D5621D79 for ; Fri, 3 Jul 2020 18:03:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="wGXFba3n" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6D5621D79 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=YOLD8CpRas6IbWPwwi5WPm8Uh+FKwjCtChD9rTvqi7s=; b=wGXFba3nuCqZcnwJMTRl99QOEj 6h+eB4fvv2N5W7j491ALKDUqL6r69OR9Y6A5Jp5VkfgD/nAnhw6HykJ4lBvXWtyCclB5vY69RwsjW PEyCQNKYhnqLIp93kSAGWPoHSDc9AJj3pEoPl4I8kZIAdz+xjy4pqTvAbO/aUcDvSD5qVFwx7KQ0o w5g4NlOtWY4JM4eaPz/vJ+0T6lhwJWF7oDLuwbi0IRflbRMei02gpILhL3Pu53cYTjiQaMVtG7ogX /e8FJxeLYbBr0XhAKgFK4LEAxUgJG2hXejAuKpQcZF5uln76peZKviLbYI21TnZ2FRTX7ihAlgYPo /5RMPIOw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrQ1a-0003Jn-I4; Fri, 03 Jul 2020 18:02:58 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrQ1U-0003En-2c for linux-rockchip@lists.infradead.org; Fri, 03 Jul 2020 18:02:53 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id A4D262A6505 From: Dafna Hirschfeld To: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com Subject: [PATCH v4l-utils v5 2/4] v4l2: common: add the flags V4L2_FMT_FLAG_CSC* to the list that maps flags to str Date: Fri, 3 Jul 2020 20:02:37 +0200 Message-Id: <20200703180239.25841-3-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703180239.25841-1-dafna.hirschfeld@collabora.com> References: <20200703180239.25841-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200703_140252_242797_85E9DF1A X-CRM114-Status: GOOD ( 10.31 ) 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 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 Replace the array fmtdesc_def with a macro 'FMTDESC_DEF' The macro is used to to create two arrays 'fmtdesc_def_ycbcr', 'fmtdesc_def_hsv' that map the format flags to strings. The function 'fmtdesc2s' is changed to get a parameter 'is_hsv' that decides which array to use. The new CSC flags V4L2_FMT_FLAG_CSC* are added to the arries. Signed-off-by: Dafna Hirschfeld --- utils/common/v4l2-info.cpp | 28 +++++++++++++++++++--------- utils/common/v4l2-info.h | 2 +- utils/v4l2-ctl/v4l2-ctl.cpp | 16 ++++++++++++---- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/utils/common/v4l2-info.cpp b/utils/common/v4l2-info.cpp index 16be409a..a8fa6236 100644 --- a/utils/common/v4l2-info.cpp +++ b/utils/common/v4l2-info.cpp @@ -366,18 +366,28 @@ std::string service2s(unsigned service) return flags2s(service, service_def); } -static const flag_def fmtdesc_def[] = { - { V4L2_FMT_FLAG_COMPRESSED, "compressed" }, - { V4L2_FMT_FLAG_EMULATED, "emulated" }, - { V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM, "continuous-bytestream" }, - { V4L2_FMT_FLAG_DYN_RESOLUTION, "dyn-resolution" }, - { V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL, "enc-cap-frame-interval" }, - { 0, NULL } +#define FMTDESC_DEF(enc_type) \ +static const flag_def fmtdesc_ ## enc_type ## _def[] = { \ + { V4L2_FMT_FLAG_COMPRESSED, "compressed" }, \ + { V4L2_FMT_FLAG_EMULATED, "emulated" }, \ + { V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM, "continuous-bytestream" }, \ + { V4L2_FMT_FLAG_DYN_RESOLUTION, "dyn-resolution" }, \ + { V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL, "enc-cap-frame-interval" }, \ + { V4L2_FMT_FLAG_CSC_COLORSPACE, "csc-colorspace" }, \ + { V4L2_FMT_FLAG_CSC_YCBCR_ENC, "csc-"#enc_type }, \ + { V4L2_FMT_FLAG_CSC_QUANTIZATION, "csc-quantization" }, \ + { V4L2_FMT_FLAG_CSC_XFER_FUNC, "csc-xfer-func" }, \ + { 0, NULL } \ }; -std::string fmtdesc2s(unsigned flags) +FMTDESC_DEF(ycbcr) +FMTDESC_DEF(hsv) + +std::string fmtdesc2s(unsigned flags, bool is_hsv) { - return flags2s(flags, fmtdesc_def); + if (is_hsv) + return flags2s(flags, fmtdesc_hsv_def); + return flags2s(flags, fmtdesc_ycbcr_def); } static const flag_def selection_targets_def[] = { diff --git a/utils/common/v4l2-info.h b/utils/common/v4l2-info.h index ce2600f0..5b34409c 100644 --- a/utils/common/v4l2-info.h +++ b/utils/common/v4l2-info.h @@ -51,7 +51,7 @@ std::string pixflags2s(unsigned flags); std::string service2s(unsigned service); /* Return v4l2_fmtdesc flags description */ -std::string fmtdesc2s(unsigned flags); +std::string fmtdesc2s(unsigned flags, bool is_hsv); /* Return selection flags description */ std::string selflags2s(__u32 flags); diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index 4972591e..edac19f1 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -615,8 +615,12 @@ void print_video_formats(cv4l_fd &fd, __u32 type) do { printf("\t[%d]: '%s' (%s", fmt.index, fcc2s(fmt.pixelformat).c_str(), fmt.description); - if (fmt.flags) - printf(", %s", fmtdesc2s(fmt.flags).c_str()); + if (fmt.flags) { + bool is_hsv = fmt.pixelformat == V4L2_PIX_FMT_HSV24 || + fmt.pixelformat == V4L2_PIX_FMT_HSV32; + + printf(", %s", fmtdesc2s(fmt.flags, is_hsv).c_str()); + } printf(")\n"); } while (!fd.enum_fmt(fmt)); } @@ -634,8 +638,12 @@ void print_video_formats_ext(cv4l_fd &fd, __u32 type) do { printf("\t[%d]: '%s' (%s", fmt.index, fcc2s(fmt.pixelformat).c_str(), fmt.description); - if (fmt.flags) - printf(", %s", fmtdesc2s(fmt.flags).c_str()); + if (fmt.flags) { + bool is_hsv = fmt.pixelformat == V4L2_PIX_FMT_HSV24 || + fmt.pixelformat == V4L2_PIX_FMT_HSV32; + + printf(", %s", fmtdesc2s(fmt.flags, is_hsv).c_str()); + } printf(")\n"); if (fd.enum_framesizes(frmsize, fmt.pixelformat)) continue; From patchwork Fri Jul 3 18:02:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11642603 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 A581714B7 for ; Fri, 3 Jul 2020 18:03:02 +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 7EBEC21D79 for ; Fri, 3 Jul 2020 18:03:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="zswncCyp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EBEC21D79 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=BtEkKjB+NoZ2RTJFqJA+u35YHcExx8WhbPHrCyGOY18=; b=zswncCypfM0KivtZVn/gXTA/XT xmXUoqm0BDdnZ6/zuXvUSrf4feb5TGB/1zcLxfBZHFImg2onm6idy02ves+bxCUgohFqsfBYZXeTP jEW6i5zo8Vvi61ThnQJwm9ttxCj2HSOSpL4rkh9uz3FhEc7wvxVR2LIODwllAgGB+/FM9K5sHhzcl 93LNi81GhMZmoMYzVttIF5pkVK39Jnp2ecghJeOQKD5pLEFBsayw+cEudUNijGkLwbQRpxtV/+C8Q uWoxo9WamBpcsHqSF3Wy7Vj325B+gcX08T1fzpqrLmzfhU2/Omige1g7bt1vQk3Zf3QUlnjwAj0gT +KDWDsEA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrQ1c-0003Kd-GZ; Fri, 03 Jul 2020 18:03:00 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrQ1U-0003FE-MO for linux-rockchip@lists.infradead.org; Fri, 03 Jul 2020 18:02:56 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 543162A65A5 From: Dafna Hirschfeld To: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com Subject: [PATCH v4l-utils v5 3/4] v4l2-ctl: subdev: Add support for the CSC API in the subdevices Date: Fri, 3 Jul 2020 20:02:38 +0200 Message-Id: <20200703180239.25841-4-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703180239.25841-1-dafna.hirschfeld@collabora.com> References: <20200703180239.25841-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200703_140252_857395_B6393663 X-CRM114-Status: UNSURE ( 8.72 ) X-CRM114-Notice: Please train this message. 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 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 The CSC API allows userspace to configure the colorspace, quantization, (ycbcr/hsv)_enc and xfer_func fields when setting the formats, so those fields are not read only in userspace. This patch adds support for this API in subevices. Signed-off-by: Dafna Hirschfeld --- utils/v4l2-ctl/v4l2-ctl-subdev.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/utils/v4l2-ctl/v4l2-ctl-subdev.cpp b/utils/v4l2-ctl/v4l2-ctl-subdev.cpp index c0f36eab..c6ec21a9 100644 --- a/utils/v4l2-ctl/v4l2-ctl-subdev.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-subdev.cpp @@ -424,14 +424,22 @@ void subdev_set(cv4l_fd &_fd) fmt.format.code = ffmt.code; if (set_fmt & FmtField) fmt.format.field = ffmt.field; - if (set_fmt & FmtColorspace) + if (set_fmt & FmtColorspace) { fmt.format.colorspace = ffmt.colorspace; - if (set_fmt & FmtXferFunc) + fmt.format.flags |= V4L2_MBUS_FRAMEFMT_SET_CSC; + } + if (set_fmt & FmtXferFunc) { fmt.format.xfer_func = ffmt.xfer_func; - if (set_fmt & FmtYCbCr) + fmt.format.flags |= V4L2_MBUS_FRAMEFMT_SET_CSC; + } + if (set_fmt & FmtYCbCr) { fmt.format.ycbcr_enc = ffmt.ycbcr_enc; - if (set_fmt & FmtQuantization) + fmt.format.flags |= V4L2_MBUS_FRAMEFMT_SET_CSC; + } + if (set_fmt & FmtQuantization) { fmt.format.quantization = ffmt.quantization; + fmt.format.flags |= V4L2_MBUS_FRAMEFMT_SET_CSC; + } if (options[OptSetSubDevFormat]) printf("Note: --set-subdev-fmt is only for testing.\n" From patchwork Fri Jul 3 18:02:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11642605 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 7244B6C1 for ; Fri, 3 Jul 2020 18:03:05 +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 4C13421D79 for ; Fri, 3 Jul 2020 18:03:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rb9CZgcr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C13421D79 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=RBaGORb3E8g4jSyRjl70lMCA6oHkXsplhRYtDA/XwJ0=; b=rb9CZgcrWNwLLp5pb1Vcylr5Mi CkOH2eBbpCQrX8JexxvujZQdN+yM0tG55nCy2kUEMLI7nkaP+fEz2gL/dg1DhpkWjmsIJ313h6Q9G ZKtzc3iiBTPhHsBIInKhkgUPGZIb9BNcFBvN0nQcDmOqbMcP2SlBZtzHNtmXUwW6aEs4doxuwCAA8 ZWBLE4uak8t8N5x8woiPxBAuajMLgs/JCUtOi8MzrsJ385gKbHv6PqDpv8zzXT+DM2Tqe8aBl0tNF kSUvc9TnmUb2+WQ5ADOcNUAHdeA/w37yuVzX7JLQIrzX7cB4KA/VHV1RUYk8voPrOhKSzU0UuQYRL D/YFCTng==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrQ1d-0003LB-H2; Fri, 03 Jul 2020 18:03:01 +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 1jrQ1V-0003G8-8M for linux-rockchip@lists.infradead.org; Fri, 03 Jul 2020 18:02:56 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id F09342A6502 From: Dafna Hirschfeld To: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com Subject: [PATCH v4l-utils v5 4/4] v4l2-ctl: subdev: Add the flags to the list of supported mbus formats Date: Fri, 3 Jul 2020 20:02:39 +0200 Message-Id: <20200703180239.25841-5-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703180239.25841-1-dafna.hirschfeld@collabora.com> References: <20200703180239.25841-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200703_140253_440866_3B6807FA X-CRM114-Status: GOOD ( 13.30 ) 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 a new function mbus2s to that prints a descriptive string of the supported flags of the the v4l2_subdev_mbus_code_enum Use this function in the print_mbus_code function. Also add a macro MBUS_DEF(enc_type) to create the two arries 'mbus_hsv_def' and mbus_ycbcr_def' that maps flags to string according to the enc_type (ycbcr/hsv) Signed-off-by: Dafna Hirschfeld --- utils/common/v4l2-info.cpp | 19 +++++++++++++++++++ utils/common/v4l2-info.h | 4 ++++ utils/v4l2-ctl/v4l2-ctl-subdev.cpp | 10 ++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/utils/common/v4l2-info.cpp b/utils/common/v4l2-info.cpp index a8fa6236..67690f61 100644 --- a/utils/common/v4l2-info.cpp +++ b/utils/common/v4l2-info.cpp @@ -390,6 +390,25 @@ std::string fmtdesc2s(unsigned flags, bool is_hsv) return flags2s(flags, fmtdesc_ycbcr_def); } +#define MBUS_DEF(enc_type) \ +static const flag_def mbus_ ## enc_type ## _def[] = { \ + { V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE, "csc-colorspace" }, \ + { V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC, "csc-"#enc_type }, \ + { V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION, "csc-quantization" }, \ + { V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC, "csc-xfer-func" }, \ + { 0, NULL } \ +}; + +MBUS_DEF(ycbcr) +MBUS_DEF(hsv) + +std::string mbus2s(unsigned flags, bool is_hsv) +{ + if (is_hsv) + return flags2s(flags, mbus_hsv_def); + return flags2s(flags, mbus_ycbcr_def); +} + static const flag_def selection_targets_def[] = { { V4L2_SEL_TGT_CROP_ACTIVE, "crop" }, { V4L2_SEL_TGT_CROP_DEFAULT, "crop_default" }, diff --git a/utils/common/v4l2-info.h b/utils/common/v4l2-info.h index 5b34409c..97c1e64a 100644 --- a/utils/common/v4l2-info.h +++ b/utils/common/v4l2-info.h @@ -8,6 +8,7 @@ #include #include +#include /* Print capability information */ void v4l2_info_capability(const v4l2_capability &cap); @@ -50,6 +51,9 @@ std::string pixflags2s(unsigned flags); /* Return sliced vbi services description */ std::string service2s(unsigned service); +/* Return v4l2_subdev_mbus_code_enum flags description */ +std::string mbus2s(unsigned flags, bool is_hsv); + /* Return v4l2_fmtdesc flags description */ std::string fmtdesc2s(unsigned flags, bool is_hsv); diff --git a/utils/v4l2-ctl/v4l2-ctl-subdev.cpp b/utils/v4l2-ctl/v4l2-ctl-subdev.cpp index c6ec21a9..6f712af2 100644 --- a/utils/v4l2-ctl/v4l2-ctl-subdev.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-subdev.cpp @@ -577,10 +577,10 @@ static void print_mbus_code(__u32 code) if (mbus_names[i].code == code) break; if (mbus_names[i].name) - printf("\t0x%04x: MEDIA_BUS_FMT_%s\n", + printf("\t0x%04x: MEDIA_BUS_FMT_%s", mbus_names[i].code, mbus_names[i].name); else - printf("\t0x%04x\n", code); + printf("\t0x%04x", code); } static void print_mbus_codes(int fd, __u32 pad) @@ -597,6 +597,12 @@ static void print_mbus_codes(int fd, __u32 pad) if (ret) break; print_mbus_code(mbus_code.code); + if (mbus_code.flags) { + bool is_hsv = mbus_code.code == MEDIA_BUS_FMT_AHSV8888_1X32; + + printf(", %s", mbus2s(mbus_code.flags, is_hsv).c_str()); + } + printf("\n"); mbus_code.index++; } }