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) &&