From patchwork Wed Feb 17 15:48:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 8340531 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 527E79F372 for ; Wed, 17 Feb 2016 15:49:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0C24203F3 for ; Wed, 17 Feb 2016 15:49:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D908D203B1 for ; Wed, 17 Feb 2016 15:49:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161546AbcBQPtC (ORCPT ); Wed, 17 Feb 2016 10:49:02 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:37148 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161129AbcBQPtA (ORCPT ); Wed, 17 Feb 2016 10:49:00 -0500 Received: by mail-wm0-f45.google.com with SMTP id g62so34207653wme.0; Wed, 17 Feb 2016 07:49:00 -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=csrlVSCm9Uqo/g89lRvPykdkBO7R8IsjxRKnNVhYtud/Zl5375jUbJ4kCPnDY44zQc 5X7x90ArkMRLbwz/kGcLTYC5u/Fn1vnxetaqbPlpCjq3wYDMMS9Dl7PabkZjhXR2RHGx 79eczPUJfpSruwbsGxdTA499QNbcUoklQLbuR+Tiu1rn7Fg3t4wyXr188MQaYGjs05Fz Ikx2F58+mwxiw1qfO3RwB1MGk5hN57Fd6tvySPrEj7cYJR2iojvi5Y12K0ngbkATVCGc sjBLcrwoym15u40pfgbbYB54Qo5JZaoYki1Ixbl+G3Ao1TlGhvjzVjrPu1TXoLSfaB/f kvgA== 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=gEky2lXiPYvz5PyusDLhHREWf25HPBEXVnvT0f1EwQ32eQyd+21RwRxIi3ISJhzyEv mAD6iLvLTTVN9PGpnrGyTeI4SzFHeqgevpDDc7vVaJSmtAV7ftnEDSoY+ul1TyFS+vLc +b1gYS3vRwf8gDe2NFnd1ajB1cfwiz3aFoSbHJsFMQMIQsGw5wlI5igyZA4UauK11/Bb v8TUeMIaGvE20w6haxtuWpKpJPk/iHTLVu0VoitvlBc5lrA1+7Fuhf5W1rRNX/F21og2 xrtqvNRyhRAq0jiHpg+20i13JqYqGxBrW1+1Ewpb/HE7wN84gaVsuxuUXL0PXxixJEmp ujmw== X-Gm-Message-State: AG10YORXtA8LngFxiFGCEherpMyHoM21qwbHe6GCdLTLAkVC3ziRzgct0kjmPw9JQt/Epg== X-Received: by 10.194.171.66 with SMTP id as2mr2678710wjc.110.1455724139621; Wed, 17 Feb 2016 07:48:59 -0800 (PST) Received: from groucho.site (ip9234e209.dynamic.kabel-deutschland.de. [146.52.226.9]) by smtp.gmail.com with ESMTPSA id u4sm2136725wjz.4.2016.02.17.07.48.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Feb 2016 07:48:58 -0800 (PST) From: Ulrich Hecht To: linux-renesas-soc@vger.kernel.org, niklas.soderlund@ragnatech.se Cc: linux-media@vger.kernel.org, magnus.damm@gmail.com, laurent.pinchart@ideasonboard.com, hans.verkuil@cisco.com, ian.molton@codethink.co.uk, lars@metafoo.de, william.towle@codethink.co.uk, Laurent Pinchart Subject: [PATCH/RFC 1/9] v4l: subdev: Add pad config allocator and init Date: Wed, 17 Feb 2016 16:48:37 +0100 Message-Id: <1455724125-13004-2-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1455724125-13004-1-git-send-email-ulrich.hecht+renesas@gmail.com> References: <1455724125-13004-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=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 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);