From patchwork Wed Oct 12 14:35:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 9373295 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 47487608A0 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 3951C295D4 for ; Wed, 12 Oct 2016 14:38:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E264295DA; Wed, 12 Oct 2016 14:38:37 +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 6EC8A2963A for ; Wed, 12 Oct 2016 14:38:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933558AbcJLOid (ORCPT ); Wed, 12 Oct 2016 10:38:33 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:49568 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933302AbcJLOiT (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:48 +0900 (KST) X-AuditID: cbfee61a-f79786d000004c78-38-57fe4a43be7e Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 12.E8.19576.34A4EF75; Wed, 12 Oct 2016 23:35:47 +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:47 +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 6/7] mediactl: libv4l2subdev: add support for comparing mbus formats Date: Wed, 12 Oct 2016 16:35:21 +0200 Message-id: <1476282922-11544-7-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+t9jAV1nr3/hBn2/rS1OTX7GZNF79Tmj Rc+GrawWa4/cZbdYtukPk8XhN+2sFp+2fGNyYPfYtKqTzWPeyUCPvi2rGD0+b5LzOPX1M3sA a5SbTUZqYkpqkUJqXnJ+SmZeuq1SaIibroWSQl5ibqqtUoSub0iQkkJZYk4pkGdkgAYcnAPc g5X07RLcMibf7GIueC9e0X/oMFMD4x3hLkZODgkBE4m9jUdYIGwxiQv31rN1MXJxCAksZZRY 9ecyO4Tzk1Gib34vG0gVm4ChxM8Xr5lAbBEBeYknvTfA4swCqxklLi5LAbGFBZIljpz9AzaV RUBV4uuDI2D1vAIeEs9eHmKD2CYncfLYZFYQm1PAU+LT55dgcSGgmjP7DrFOYORdwMiwilEi tSC5oDgpPdcwL7Vcrzgxt7g0L10vOT93EyM4pJ9J7WA8uMv9EKMAB6MSD6/A1z/hQqyJZcWV uYcYJTiYlUR4g93+hQvxpiRWVqUW5ccXleakFh9iNAU6bCKzlGhyPjDe8kriDU3MTcyNDSzM LS1NjJTEeRtnPwsXEkhPLEnNTk0tSC2C6WPi4JRqYBRqf75CWVbrh8OZfyeZZL5suznP7OPt Y8pOv/IXZr0KjDTc/Sfq65aDZd3r3u39IDUvTLEi5bPNwXddc+ubVutOS8p+fETJgfPJzIob /SU9iR3fdW1XCy2Kn3Fj7t6ccG2DVx58KhMZbxydXn+af/ZPldBGlzCPI2KuFfPkssMbyqLl PvtmX1NiKc5INNRiLipOBACP7/5ifwIAAA== 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 This patch adds a function for checking whether two mbus formats are compatible. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libv4l2subdev.c | 42 +++++++++++++++++++++++++++++++++++++++++ utils/media-ctl/v4l2subdev.h | 21 +++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index 31393bb..2ec9b5e 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -948,3 +948,45 @@ int v4l2_subdev_supports_v4l2_ctrl(struct media_device *media, return 0; } + +enum v4l2_subdev_fmt_mismatch v4l2_subdev_format_compare( + struct v4l2_mbus_framefmt *fmt1, + struct v4l2_mbus_framefmt *fmt2) +{ + if (fmt1 == NULL || fmt2 == NULL) + return 0; + + if (fmt1->width != fmt2->width) { + printf("width mismatch (fmt1: %d, fmt2: %d)\n", + fmt1->width, fmt2->width); + return FMT_MISMATCH_WIDTH; + } + + if (fmt1->height != fmt2->height) { + printf("height mismatch (fmt1: %d, fmt2: %d)\n", + fmt1->height, fmt2->height); + return FMT_MISMATCH_HEIGHT; + } + + if (fmt1->code != fmt2->code) { + printf("mbus code mismatch (fmt1: %s, fmt2: %s)\n", + v4l2_subdev_pixelcode_to_string(fmt1->code), + v4l2_subdev_pixelcode_to_string(fmt2->code)); + return FMT_MISMATCH_CODE; + } + + if (fmt1->field != fmt2->field) { + printf("field mismatch (fmt1: %d, fmt2: %d)\n", + fmt1->field, fmt2->field); + return FMT_MISMATCH_FIELD; + } + + if (fmt1->colorspace != fmt2->colorspace) { + printf("colorspace mismatch (fmt1: %s, fmt2: %s)\n", + v4l2_subdev_colorspace_to_string(fmt1->colorspace), + v4l2_subdev_colorspace_to_string(fmt2->colorspace)); + return FMT_MISMATCH_COLORSPACE; + } + + return FMT_MISMATCH_NONE; +} diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h index cf1250d..c438f71 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -28,6 +28,15 @@ struct media_device; struct media_entity; struct media_device; +enum v4l2_subdev_fmt_mismatch { + FMT_MISMATCH_NONE = 0, + FMT_MISMATCH_WIDTH, + FMT_MISMATCH_HEIGHT, + FMT_MISMATCH_CODE, + FMT_MISMATCH_FIELD, + FMT_MISMATCH_COLORSPACE, +}; + struct v4l2_subdev { int fd; unsigned int fd_owner:1; @@ -342,5 +351,17 @@ const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list( int v4l2_subdev_supports_v4l2_ctrl(struct media_device *device, struct media_entity *entity, __u32 ctrl_id); +/** + * @brief Compare mbus formats + * @param fmt1 - 1st mbus format to compare. + * @param fmt2 - 2nd mbus format to compare. + * + * Check whether two mbus formats are compatible. + * + * @return 1 if formats are compatible, 0 otherwise. + */ +enum v4l2_subdev_fmt_mismatch v4l2_subdev_format_compare( + struct v4l2_mbus_framefmt *fmt1, + struct v4l2_mbus_framefmt *fmt2); #endif