From patchwork Wed May 11 14:02:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 67538 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp242390qge; Wed, 11 May 2016 07:03:27 -0700 (PDT) X-Received: by 10.66.79.197 with SMTP id l5mr5183430pax.61.1462975407244; Wed, 11 May 2016 07:03:27 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4si10087592pay.151.2016.05.11.07.03.27; Wed, 11 May 2016 07:03:27 -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 S932926AbcEKODX (ORCPT + 4 others); Wed, 11 May 2016 10:03:23 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33034 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932749AbcEKODU (ORCPT ); Wed, 11 May 2016 10:03:20 -0400 Received: by mail-wm0-f68.google.com with SMTP id r12so9662069wme.0; Wed, 11 May 2016 07:03:18 -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=rN3quH91H+N2oWkew0oz7sqFL2jkQelAkMmUBv6eZmjrcCCNQv69nIAdRvWs4olCQ7 ObxvPBeLJyE+KaGNX551NLLNvZVn1c5XYBeuDocJAxzsZ5wp6IGoHYZ6GNtPBwK59Lku 14zDOl/Y3mNYq7hJ8kGtgc0dxMIqxt0Kk0kWaG7+xDz2j87K3gUMIVWgkJ1olsAiGHWs N8roNGNWZWKRgmzEmGmQII4NaTUqRMmTajeyTdcbJWSTLBJjHz0IicCg+/zY3HiFOIzF VzSbhzpXokQKt3AEDJbzFfmUCVdHSye1GZO1aqFFtKEJQvXVwk1yxCrJeIn33TOEoCi6 sWtw== 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=ffbsTuOYO70IHGRiQh0nnfcLtb8CG/u+xypHgC3mXn5FgGzTCuAi+kqi3Ofexjn2+v ecVlLGP4HCWVqBBadh0WC0+5tFj8kWf7m5FpXWZZXW7/mWGLxTtahuxW23f1FhDzFHVv cNqWjYNjqTL1POr1J+/ZfjNTTwSHa2OZFymDKZlIoWYYb5/DQF/NXWuKfG3F8Fxm0bgs +AW1BsP1Oj5Yp94NtYRjXf9nzj+BBaIH2veEFFZiQnD3PCuKBTIpbsjF0bOMRH7KI1Vf FtzmfGXJumuY2XcWZHET/08XhnmcC1R6gpiLsW0ci4u45KFBay4R1mSXvQx/EZAnBAE5 sZjQ== X-Gm-Message-State: AOPr4FWk7oocjIFqb8ja41IDv01DdgmRTJLB6uXvvc8ni2KCNy/S8b0B285jk7SCvWTo4A== X-Received: by 10.194.192.106 with SMTP id hf10mr4057578wjc.52.1462975398164; Wed, 11 May 2016 07:03:18 -0700 (PDT) Received: from groucho.site (ip9234e209.dynamic.kabel-deutschland.de. [146.52.226.9]) by smtp.gmail.com with ESMTPSA id iv1sm8276401wjb.34.2016.05.11.07.03.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 May 2016 07:03:15 -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 v4 1/8] v4l: subdev: Add pad config allocator and init Date: Wed, 11 May 2016 16:02:49 +0200 Message-Id: <1462975376-491-2-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462975376-491-1-git-send-email-ulrich.hecht+renesas@gmail.com> References: <1462975376-491-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);