From patchwork Thu Apr 14 16:17:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 65839 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp694045qge; Thu, 14 Apr 2016 09:18:06 -0700 (PDT) X-Received: by 10.66.193.131 with SMTP id ho3mr22144755pac.154.1460650686346; Thu, 14 Apr 2016 09:18:06 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si11184739pas.21.2016.04.14.09.18.06; Thu, 14 Apr 2016 09:18:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932651AbcDNQSE (ORCPT + 4 others); Thu, 14 Apr 2016 12:18:04 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35772 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932281AbcDNQSC (ORCPT ); Thu, 14 Apr 2016 12:18:02 -0400 Received: by mail-wm0-f67.google.com with SMTP id a140so24287113wma.2; Thu, 14 Apr 2016 09:18:01 -0700 (PDT) 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=ah3IV70ZFUyaJnVDgGPv/uswkPR3h3eoBIS8cENvXGc=; b=UeNr82u1P+kDezw0h8/g8LQtExfmFxjqV471gBev2afeHsmFt0NAeKHrAbYCWfsvUG jGvbdwA9RpsKi+sYGBYelx9+500hvZUgcuZ5ty169yKWJlOTyUtlJH4ga+iLcOLb89o9 36W7t9NxuSLgHmmASY+HVcUt31Bl6T4VCghm/507TjwuPWIJXlJvaOIImbTbp/94kdqL B5mHYlh+iTHibQvE6h6G/ymk5a0C8R2zIGdG4A5eixTzwlPs+vtOVw+koHWZUvEntUSM 9HbD2813AcmQveNCJs2+ZCRF6pJr3xdNtkuK76dKkxuDheDoWvJ4+4yDzoBRdnYCAhID C6gw== 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=ah3IV70ZFUyaJnVDgGPv/uswkPR3h3eoBIS8cENvXGc=; b=RRMEqGsJNZpHhLIzd+7/Vay1chIInO6062WvYC8ONOLn6KsI06R1TROG3Ub5g34CLi Mvgn0eGgUi2QLDYUMU4gEmNO3zqh8hO2gCa3u0q7MMrEh/sSeEAet9c5jodq0hrkRHhO ITRodDzQJDQjVUHaH00I8cGwmom5qSkBoOV4+zaqmAu3zm1O3rSvRaNmhoPECoNMgWAy sf7iakgWLxMLy6qgZcMvj4j5Hz7WLUP3YuJCUjmus8cRmdz8diGm8vxF27ynzu59JUON kUTe0BNVacCowE+W0bal3HZ/SuknGlI79Q1nrhctHz5jYn2XwD3oaNXj/zT0aBafXnHQ PWCg== X-Gm-Message-State: AOPr4FXfxiNel9RFqRKng0NabeU3IGv2w8yYERxCMoImGxNwtkJcgraEpfMkgBvTqz++oA== X-Received: by 10.194.118.5 with SMTP id ki5mr15970742wjb.138.1460650680553; Thu, 14 Apr 2016 09:18:00 -0700 (PDT) Received: from groucho.site (ip9234e209.dynamic.kabel-deutschland.de. [146.52.226.9]) by smtp.gmail.com with ESMTPSA id j10sm44720459wjb.46.2016.04.14.09.17.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Apr 2016 09:17:59 -0700 (PDT) From: Ulrich Hecht To: hans.verkuil@cisco.com, niklas.soderlund@ragnatech.se Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, magnus.damm@gmail.com, laurent.pinchart@ideasonboard.com, ian.molton@codethink.co.uk, lars@metafoo.de, william.towle@codethink.co.uk, Laurent Pinchart Subject: [PATCH v3 1/7] v4l: subdev: Add pad config allocator and init Date: Thu, 14 Apr 2016 18:17:44 +0200 Message-Id: <1460650670-20849-2-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1460650670-20849-1-git-send-email-ulrich.hecht+renesas@gmail.com> References: <1460650670-20849-1-git-send-email-ulrich.hecht+renesas@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 11e2dfe..6c47cdd 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -607,6 +607,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); @@ -801,7 +803,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);