From patchwork Wed Mar 2 17:16:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 8484011 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 24ECD9F2F0 for ; Wed, 2 Mar 2016 17:17:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6455620125 for ; Wed, 2 Mar 2016 17:16:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A509920122 for ; Wed, 2 Mar 2016 17:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752713AbcCBRQ6 (ORCPT ); Wed, 2 Mar 2016 12:16:58 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34057 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752013AbcCBRQ5 (ORCPT ); Wed, 2 Mar 2016 12:16:57 -0500 Received: by mail-wm0-f66.google.com with SMTP id p65so10757834wmp.1; Wed, 02 Mar 2016 09:16:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ByX77fINbpMX08ywgNUSwEy4edPwqbqc+N6PnXSHWoY=; b=aqzp3dwViXJ572iUvVbF27UbB/ZUDzZqvVMYtMBBHauGiXFfonKi9c+w8T3/P497qw Yzw7sbIoWE6FheKxWnPNGc3Xj2KaNXQ3ug5GG5i/pRKZ+1Sybxw3OJv12qiwCUIs/hAT cSr79ZrlsQRnv8fnnj3DHqvfu0F7n6zjVXWVsbkaAkxk2uXnwOy4LjhpwL30ISQlGab/ zdfoU18hjirXtEuqpWQ18vGLJouqfZwsuZREPSZIiZQMQoV7I6joNdOfLzzQuMjbORUg LbKYZSapFDpQvn+MxPe0m3M5vmOr7gTnzjDFPeCFBYqFlp7fgaZ3HVNkod+f/6NR6zro 3Apw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ByX77fINbpMX08ywgNUSwEy4edPwqbqc+N6PnXSHWoY=; b=ezfMgWPszByVN7o85giSqM/WxlEGMUz6KdTL3TPSsz0Pcc9BPNNyHfwKlWf0yFicVt nX+n3EUthprv+Q3QOgwdB6YIjCNKlVdthCY2H+Vjt8j5V8/+caTn0nokAv1rgj18E04h jjX1p85KcsCCLHTkTiSiacwFTjvaN4K8PfESpS0Uvh/tsOPSExvxxyPQ8YJvU5FAp/EF 1xScUdJEPOPChnEtzdXgXAdGczYm6PgG8mOwBAXygy4sYBi8tt5ZI7HdXMdyXto6eYol MQHtMS1DzvvmwQ1UlRTGFLREuKDgNvrb9PgzlQqJdzSwH/iBgFCsRQXs5gLVgD8iMMNU K7tA== X-Gm-Message-State: AD7BkJLNhQTAclWBvg+HCvSvzcHvURtgbiu7/9/nEY33xI+wFM1gp0QlCNCV9wOhX8Wu0A== X-Received: by 10.194.248.200 with SMTP id yo8mr27261859wjc.38.1456939015938; Wed, 02 Mar 2016 09:16:55 -0800 (PST) Received: from groucho.site (ip9234e209.dynamic.kabel-deutschland.de. [146.52.226.9]) by smtp.gmail.com with ESMTPSA id ka7sm36741410wjb.8.2016.03.02.09.16.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Mar 2016 09:16:54 -0800 (PST) From: Ulrich Hecht To: linux-renesas-soc@vger.kernel.org, laurent.pinchart@ideasonboard.com, niklas.soderlund@ragnatech.se Cc: linux-media@vger.kernel.org, magnus.damm@gmail.com, hans.verkuil@cisco.com, ian.molton@codethink.co.uk, lars@metafoo.de, william.towle@codethink.co.uk, Laurent Pinchart Subject: [PATCH v2 1/9] v4l: subdev: Add pad config allocator and init Date: Wed, 2 Mar 2016 18:16:29 +0100 Message-Id: <1456938997-29971-2-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1456938997-29971-1-git-send-email-ulrich.hecht+renesas@gmail.com> References: <1456938997-29971-1-git-send-email-ulrich.hecht+renesas@gmail.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 From: Laurent Pinchart Add a new subdev operation to initialize a subdev pad config array, and a helper function to allocate and initialize the array. This can be used by bridge drivers to implement try format based on subdev pad operations. Signed-off-by: Laurent Pinchart Acked-by: Vaibhav Hiremath Acked-by: Hans Verkuil --- drivers/media/v4l2-core/v4l2-subdev.c | 19 ++++++++++++++++++- include/media/v4l2-subdev.h | 10 ++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index d630838..f32ac0d 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -35,7 +35,7 @@ static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd) { #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) - fh->pad = kzalloc(sizeof(*fh->pad) * sd->entity.num_pads, GFP_KERNEL); + fh->pad = v4l2_subdev_alloc_pad_config(sd); if (fh->pad == NULL) return -ENOMEM; #endif @@ -569,6 +569,23 @@ int v4l2_subdev_link_validate(struct media_link *link) sink, link, &source_fmt, &sink_fmt); } EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate); + +struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd) +{ + struct v4l2_subdev_pad_config *cfg; + + if (!sd->entity.num_pads) + return NULL; + + cfg = kcalloc(sd->entity.num_pads, sizeof(*cfg), GFP_KERNEL); + if (!cfg) + return NULL; + + v4l2_subdev_call(sd, pad, init_cfg, cfg); + + return cfg; +} +EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config); #endif /* CONFIG_MEDIA_CONTROLLER */ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops) diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index b273cf9..e1e25fa 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -604,6 +604,8 @@ struct v4l2_subdev_pad_config { * may be adjusted by the subdev driver to device capabilities. */ struct v4l2_subdev_pad_ops { + void (*init_cfg)(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg); int (*enum_mbus_code)(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code); @@ -798,7 +800,15 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd, struct v4l2_subdev_format *source_fmt, struct v4l2_subdev_format *sink_fmt); int v4l2_subdev_link_validate(struct media_link *link); + +struct v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd); + +static inline void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg) +{ + kfree(cfg); +} #endif /* CONFIG_MEDIA_CONTROLLER */ + void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops);