From patchwork Wed Oct 12 14:35:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 9373293 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1929A60865 for ; Wed, 12 Oct 2016 14:38:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C860295D4 for ; Wed, 12 Oct 2016 14:38:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 017F629638; Wed, 12 Oct 2016 14:38:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DC11295DA for ; Wed, 12 Oct 2016 14:38:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933553AbcJLOib (ORCPT ); Wed, 12 Oct 2016 10:38:31 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:49979 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933254AbcJLOiT (ORCPT ); Wed, 12 Oct 2016 10:38:19 -0400 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OEX01FZBV7FY8A0@mailout1.samsung.com> for linux-media@vger.kernel.org; Wed, 12 Oct 2016 23:35:45 +0900 (KST) X-AuditID: cbfee61a-f79786d000004c78-34-57fe4a41045e Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 51.E8.19576.14A4EF75; Wed, 12 Oct 2016 23:35:45 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OEX00HXUV70WM50@mmp1.samsung.com>; Wed, 12 Oct 2016 23:35:45 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: sakari.ailus@linux.intel.com, hverkuil@xs4all.nl, mchehab@kernel.org, m.szyprowski@samsung.com, s.nawrocki@samsung.com, Jacek Anaszewski Subject: [PATCH v4l-utils v7 5/7] mediactl: libv4l2subdev: Add colorspace logging Date: Wed, 12 Oct 2016 16:35:20 +0200 Message-id: <1476282922-11544-6-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1476282922-11544-1-git-send-email-j.anaszewski@samsung.com> References: <1476282922-11544-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRmVeSWpSXmKPExsVy+t9jAV1Hr3/hBtP3CFmcmvyMyaL36nNG i54NW1kt1h65y26xbNMfJovDb9pZLT5t+cbkwO6xaVUnm8e8k4EefVtWMXp83iTncerrZ/YA 1ig3m4zUxJTUIoXUvOT8lMy8dFul0BA3XQslhbzE3FRbpQhd35AgJYWyxJxSIM/IAA04OAe4 Byvp2yW4Zey/s5SlYKZoxfKv85gbGGcJdjFyckgImEg8WPiEEcIWk7hwbz1bFyMXh5DAUkaJ a1PWsEM4PxklTu87yA5SxSZgKPHzxWsmEFtEQF7iSe8NNhCbWWA1o8TFZSkgtrBAsMTzs43M IDaLgKrEo5MHwep5BTwknjdOg9omJ3Hy2GRWEJtTwFPi0+eXYHOEgGrO7DvEOoGRdwEjwypG idSC5ILipPRcw7zUcr3ixNzi0rx0veT83E2M4JB+JrWD8eAu90OMAhyMSjy8Al//hAuxJpYV V+YeYpTgYFYS4Q12+xcuxJuSWFmVWpQfX1Sak1p8iNEU6LCJzFKiyfnAeMsriTc0MTcxNzaw MLe0NDFSEudtnP0sXEggPbEkNTs1tSC1CKaPiYNTqoExyWa+//0ndpvOi7DZ3N5ltHL9dMfq lW8uK9nWqza2Xf/i1eIwxUOrrftatLnCRIHX8t/3TP5yd1LxgwLL6RL2onFTckIvdK7Onmgn 5nP/iFbZwYgg9tfzVx2wOXPFZ+mxpb83bVqhr6z88VvV36PHInUbK+JLLkka7PUQO/Td9XqY KqfUjQmSSizFGYmGWsxFxYkA9k8Dwn8CAAA= X-MTR: 20000000000000000@CPGS Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a function for obtaining colorspace name by id. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park Acked-by: Sakari Ailus --- utils/media-ctl/libv4l2subdev.c | 32 ++++++++++++++++++++++++++++++++ utils/media-ctl/v4l2subdev.h | 10 ++++++++++ 2 files changed, 42 insertions(+) diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index 4f8ee7f..31393bb 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -33,6 +33,7 @@ #include #include +#include #include "mediactl.h" #include "mediactl-priv.h" @@ -831,6 +832,37 @@ const char *v4l2_subdev_pixelcode_to_string(enum v4l2_mbus_pixelcode code) return "unknown"; } +static struct { + const char *name; + enum v4l2_colorspace cs; +} colorspaces[] = { + { "DEFAULT", V4L2_COLORSPACE_DEFAULT }, + { "SMPTE170M", V4L2_COLORSPACE_SMPTE170M }, + { "SMPTE240M", V4L2_COLORSPACE_SMPTE240M }, + { "REC709", V4L2_COLORSPACE_REC709 }, + { "BT878", V4L2_COLORSPACE_BT878 }, + { "470_SYSTEM_M", V4L2_COLORSPACE_470_SYSTEM_M }, + { "470_SYSTEM_BG", V4L2_COLORSPACE_470_SYSTEM_BG }, + { "JPEG", V4L2_COLORSPACE_JPEG }, + { "SRGB", V4L2_COLORSPACE_SRGB }, + { "ADOBERGB", V4L2_COLORSPACE_ADOBERGB }, + { "BT2020", V4L2_COLORSPACE_BT2020 }, + { "RAW", V4L2_COLORSPACE_RAW }, + { "DCI_P3", V4L2_COLORSPACE_DCI_P3 }, +}; + +const char *v4l2_subdev_colorspace_to_string(enum v4l2_colorspace cs) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(colorspaces); ++i) { + if (colorspaces[i].cs == cs) + return colorspaces[i].name; + } + + return "unknown"; +} + enum v4l2_mbus_pixelcode v4l2_subdev_string_to_pixelcode(const char *string) { unsigned int i; diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h index 4dee6b1..cf1250d 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -278,6 +278,16 @@ int v4l2_subdev_parse_setup_formats(struct media_device *media, const char *p); const char *v4l2_subdev_pixelcode_to_string(enum v4l2_mbus_pixelcode code); /** + * @brief Convert colorspace to string. + * @param code - input string + * + * Convert colorspace @a to a human-readable string. + * + * @return A pointer to a string on success, NULL on failure. + */ +const char *v4l2_subdev_colorspace_to_string(enum v4l2_colorspace cs); + +/** * @brief Parse string to media bus pixel code. * @param string - nul terminalted string, textual media bus pixel code *