From patchwork Mon Jan 18 16:17:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 8056011 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DCEB9BEEE5 for ; Mon, 18 Jan 2016 16:18:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 13B57204AF for ; Mon, 18 Jan 2016 16:18:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 26019204AD for ; Mon, 18 Jan 2016 16:18:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932135AbcARQSr (ORCPT ); Mon, 18 Jan 2016 11:18:47 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:47035 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932123AbcARQSr (ORCPT ); Mon, 18 Jan 2016 11:18:47 -0500 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O1500V0SPB5UN20@mailout3.samsung.com> for linux-media@vger.kernel.org; Tue, 19 Jan 2016 01:18:46 +0900 (KST) X-AuditID: cbfee61a-f79266d000003652-13-569d10651c5b Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 09.31.13906.5601D965; Tue, 19 Jan 2016 01:18:45 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O15003TLP9I9Y00@mmp2.samsung.com>; Tue, 19 Jan 2016 01:18:45 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, gjasny@googlemail.com, hdegoede@redhat.com, hverkuil@xs4all.nl, Jacek Anaszewski Subject: [PATCH 09/15] mediactl: libv4l2subdev: Add colorspace logging Date: Mon, 18 Jan 2016 17:17:34 +0100 Message-id: <1453133860-21571-10-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1453133860-21571-1-git-send-email-j.anaszewski@samsung.com> References: <1453133860-21571-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrALMWRmVeSWpSXmKPExsVy+t9jQd1UgblhBtNn2FhMnzKL0eLN8elM FqcmP2Oy6L36nNGic+ISdoueDVtZLT5t+cbkwO7xdMJkdo/ZHTNZPeadDPR4v+8qm0ffllWM Hp83yXmc+vqZPYA9issmJTUnsyy1SN8ugSuj6cNG1oIVohVbt+5mbWCcK9jFyMkhIWAisait mx3CFpO4cG89WxcjF4eQwCxGiVWTpzJDOD8ZJW5P/wFWxSZgKPHzxWsmEFtEQF7iSe8NsA5m gS2MEnfvLAIrEhZwk3h8/QkLiM0ioCrxfPY7MJtXwFPib/NWoKkcQOsUJOZMsgEJcwKF39zc zwZiCwl4SBy4u5V5AiPvAkaGVYwSqQXJBcVJ6bmGeanlesWJucWleel6yfm5mxjB4fZMagfj wV3uhxgFOBiVeHgdzs4OE2JNLCuuzD3EKMHBrCTCe4hjbpgQb0piZVVqUX58UWlOavEhRmkO FiVx3tpLkWFCAumJJanZqakFqUUwWSYOTqkGxjlPftlMuHxwJb/z/e28cwWaj1/8d+vthTm/ Y06r+P6p77WY837Kh7xWiZj/rLocKbqL682WLXv9RC1h2728T4/+3nm1vL7v9pWJljcWSMoG ph2Xt1r958rtA3O+XVz47kcox7l9vPN5zHTYhfKFeNrvTSjeMefijR2BwR3GVxvyg21eTU7b nxuoxFKckWioxVxUnAgACg0NczMCAAA= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.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 --- 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 5175188..b3d11ef 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -32,6 +32,7 @@ #include #include +#include #include "mediactl.h" #include "mediactl-priv.h" @@ -819,6 +820,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 length) { diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h index f395065..7d9e53a 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -289,6 +289,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 - input string * @param length - length of the string