From patchwork Thu Nov 6 10:11:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 5240701 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D63539F387 for ; Thu, 6 Nov 2014 10:12:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CFBDC20114 for ; Thu, 6 Nov 2014 10:12:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C08F32010C for ; Thu, 6 Nov 2014 10:12:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751960AbaKFKMS (ORCPT ); Thu, 6 Nov 2014 05:12:18 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:51249 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751330AbaKFKMN (ORCPT ); Thu, 6 Nov 2014 05:12:13 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NEM00KF74CC5250@mailout1.samsung.com> for linux-media@vger.kernel.org; Thu, 06 Nov 2014 19:12:12 +0900 (KST) X-AuditID: cbfee61a-f79c06d000004e71-d5-545b497b6bdf Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id C7.ED.20081.B794B545; Thu, 06 Nov 2014 19:12:12 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NEM00DZ94BK47N0@mmp2.samsung.com>; Thu, 06 Nov 2014 19:12:11 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: m.chehab@samsung.com, gjasny@googlemail.com, hdegoede@redhat.com, hans.verkuil@cisco.com, b.zolnierkie@samsung.com, sakari.ailus@linux.intel.com, kyungmin.park@samsung.com, Jacek Anaszewski Subject: [v4l-utils RFC v3 06/11] mediactl: Add subdev_fmt property to the media_entity Date: Thu, 06 Nov 2014 11:11:37 +0100 Message-id: <1415268702-23685-7-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1415268702-23685-1-git-send-email-j.anaszewski@samsung.com> References: <1415268702-23685-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrILMWRmVeSWpSXmKPExsVy+t9jQd0az+gQg9Y2VouNM9azWkyfMovR YsnPXUwWb45PZ7Lovfqc0eJs0xt2i54NW1ktLq6Tt/i05RuTA6fHlN8bWT2eTpjM7jHvZKDH +31X2Tz6tqxi9Pi8SS6ALYrLJiU1J7MstUjfLoEr4+3Xu4wF2+QrZm+aytzA+FWyi5GTQ0LA ROLeyqWsELaYxIV769m6GLk4hASmM0o8mdLPCOG0M0m83fiADaSKTcBQ4ueL10wgtoiAvMST 3htgHcwCjxglni77zgiSEBaIlLi9eBU7iM0ioCox7dIbsBW8Ah4SGza9AWrmAFqnIDFnkg1I mFPAU2L20RNg5UJAJTM+nGCbwMi7gJFhFaNoakFyQXFSeq6hXnFibnFpXrpecn7uJkZwwD2T 2sG4ssHiEKMAB6MSD++Oo1EhQqyJZcWVuYcYJTiYlUR4FRyjQ4R4UxIrq1KL8uOLSnNSiw8x SnOwKInzHmi1DhQSSE8sSc1OTS1ILYLJMnFwSjUwGqbymLXP7Ve0+VInXC159qmUJofC3skL mG+wa6vs9FrVuD/pg7bg+7CNBV+T9qqviIrrv3bllLaJ2yTfs++na0w6Yrg9/d/rqfkH181Z f09y80HR/IKDj1+GHfj3+LOTfatL1GnWl4tCzr7jNdabd+r2wYlNqR1rVQqSgk7vvCNkJFh4 +8P2n0osxRmJhlrMRcWJANkjvkE0AgAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 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 subdev_fmt field to the structure media_entity. Added is also API for setting the media_entity format and comparing two subdev formats. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libmediactl.c | 6 ++++++ utils/media-ctl/libv4l2subdev.c | 34 ++++++++++++++++++++++++++++++++++ utils/media-ctl/mediactl-priv.h | 3 +++ utils/media-ctl/mediactl.h | 12 ++++++++++++ utils/media-ctl/v4l2subdev.h | 12 ++++++++++++ 5 files changed, 67 insertions(+) diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c index 10f0491..27e7329 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -1260,3 +1260,9 @@ int media_entity_get_fd(struct media_entity *entity) { return entity->fd; } + +void media_entity_set_subdev_fmt(struct media_entity *entity, + struct v4l2_subdev_format *fmt) +{ + entity->subdev_fmt = *fmt; +} diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index 99ac6b2..449565c 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -786,3 +786,37 @@ int v4l2_subdev_validate_v4l2_ctrl(struct media_device *media, entity->info.name); return 0; } + +int 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\n"); + return 0; + } + + if (fmt1->height != fmt2->height) { + printf("height mismatch\n"); + return 0; + } + + if (fmt1->code != fmt2->code) { + printf("mbus code mismatch\n"); + return 0; + } + + if (fmt1->field != fmt2->field) { + printf("field mismatch\n"); + return 0; + } + + if (fmt1->colorspace != fmt2->colorspace) { + printf("colorspace mismatch\n"); + return 0; + } + + return 1; +} diff --git a/utils/media-ctl/mediactl-priv.h b/utils/media-ctl/mediactl-priv.h index b9e9b20..b2c466b 100644 --- a/utils/media-ctl/mediactl-priv.h +++ b/utils/media-ctl/mediactl-priv.h @@ -23,6 +23,7 @@ #define __MEDIA_PRIV_H__ #include +#include #include "mediactl.h" @@ -34,6 +35,8 @@ struct media_entity { unsigned int max_links; unsigned int num_links; + struct v4l2_subdev_format subdev_fmt; + char devname[32]; int fd; }; diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h index 0dc7f95..d28b0a8 100644 --- a/utils/media-ctl/mediactl.h +++ b/utils/media-ctl/mediactl.h @@ -42,6 +42,7 @@ struct media_pad { struct media_device; struct media_entity; +struct v4l2_subdev_format; /** * @brief Create a new media device. @@ -611,4 +612,15 @@ int media_entity_get_sink_pad_index(struct media_entity *entity); */ int media_entity_get_fd(struct media_entity *entity); +/** + * @brief Set sub-device format + * @param entity - media entity + * @param fmt - pointer to the sub-device format structure + * + * This function sets the format of the sub-device related + * to this entity. + */ +void media_entity_set_subdev_fmt(struct media_entity *entity, + struct v4l2_subdev_format *fmt); + #endif diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h index 3bc0412..2c9d507 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -270,4 +270,16 @@ 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 + */ +int v4l2_subdev_format_compare(struct v4l2_mbus_framefmt *fmt1, + struct v4l2_mbus_framefmt *fmt2); + #endif