From patchwork Mon Jan 18 16:17:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 8056021 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 A9362BEEE5 for ; Mon, 18 Jan 2016 16:18:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C3904204AF for ; Mon, 18 Jan 2016 16:18:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CEC6A204A9 for ; Mon, 18 Jan 2016 16:18:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932148AbcARQSy (ORCPT ); Mon, 18 Jan 2016 11:18:54 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:41472 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932123AbcARQSx (ORCPT ); Mon, 18 Jan 2016 11:18:53 -0500 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O1501N1RPAIDD20@mailout4.samsung.com> for linux-media@vger.kernel.org; Tue, 19 Jan 2016 01:18:52 +0900 (KST) X-AuditID: cbfee61b-f793c6d00000236c-b9-569d106c221e Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id FB.59.09068.C601D965; Tue, 19 Jan 2016 01:18:52 +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:52 +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 10/15] mediactl: libv4l2subdev: add support for comparing mbus formats Date: Mon, 18 Jan 2016 17:17:35 +0100 Message-id: <1453133860-21571-11-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+NgFprPLMWRmVeSWpSXmKPExsVy+t9jQd0cgblhBrunaVtMnzKL0eLN8elM FqcmP2Oy6L36nNGic+ISdoueDVtZLT5t+cbkwO7xdMJkdo/ZHTNZPeadDPR4v+8qm0ffllWM Hp83yXmc+vqZPYA9issmJTUnsyy1SN8ugSvjxtkJzAW3JSqafpxhb2DcIdLFyMEhIWAisWKv XBcjJ5ApJnHh3nq2LkYuDiGBWYwSy9f9Y4JwfgI5S6YzglSxCRhK/HzxmgnEFhGQl3jSewOs g1lgC6PE3TuL2EESwgIREksmnABrYBFQlZjwazcLiM0r4Cmxb8pXVojNChJzJtmAhDmBwm9u 7mcDsYUEPCQO3N3KPIGRdwEjwypGidSC5ILipPRco7zUcr3ixNzi0rx0veT83E2M4GB7Jr2D 8fAu90OMAhyMSjy8DmdnhwmxJpYVV+YeYpTgYFYS4T3EMTdMiDclsbIqtSg/vqg0J7X4EKM0 B4uSOO++S5FhQgLpiSWp2ampBalFMFkmDk6pBsa9U3xbpB1aDu+NNgud9CDk++f0kjJn1+Va E2Kkjj9uTpJadLbk9vuwwLtdmrZpOTIz4oM7f0ms9cqOfVtRMUdrqp/DC/eqXw9LHwRefql9 +IC1JNd92Zf11yflWjF9/rHF5NdbV5nDdc+UJzXtszX/8m1Ra0LzIv1VX633z9loE77mY9gX k9VKLMUZiYZazEXFiQB/wcXNMgIAAA== 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 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 | 39 +++++++++++++++++++++++++++++++++++++++ utils/media-ctl/v4l2subdev.h | 22 ++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index b3d11ef..3282fe9 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -934,6 +934,45 @@ int v4l2_subdev_validate_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 (%d %d)\n", fmt1->width, fmt2->width); + return FMT_MISMATCH_WIDTH; + } + + if (fmt1->height != fmt2->height) { + printf("height mismatch (%d %d)\n", fmt1->height, fmt2->height); + return FMT_MISMATCH_HEIGHT; + } + + if (fmt1->code != fmt2->code) { + printf("mbus code mismatch (%s %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 (%d %d)\n", fmt1->field, fmt2->field); + return FMT_MISMATCH_FIELD; + } + + if (fmt1->colorspace != fmt2->colorspace) { + printf("colorspace mismatch (%s %s)\n", + v4l2_subdev_colorspace_to_string(fmt1->colorspace), + v4l2_subdev_colorspace_to_string(fmt2->colorspace)); + return FMT_MISMATCH_COLORSPACE; + } + + return FMT_MISMATCH_NONE; +} + bool v4l2_subdev_has_v4l2_control_redir(struct media_device *media, struct media_entity *entity, int ctrl_id) diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h index 7d9e53a..3732755 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -29,6 +29,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; @@ -345,6 +354,19 @@ int v4l2_subdev_validate_v4l2_ctrl(struct media_device *media, 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); + +/** * @brief Check if there was a v4l2_control redirection defined for the entity * @param media - media device. * @param entity - subdev-device media entity.