From patchwork Thu Jun 25 09:31:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Towle X-Patchwork-Id: 50308 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A2ED3228FC for ; Thu, 25 Jun 2015 09:31:47 +0000 (UTC) Received: by wiws10 with SMTP id s10sf20146264wiw.2 for ; Thu, 25 Jun 2015 02:31:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=cDq0O+4Kh5Jt7bju7y0KNAgNqfvo56hD+2+WgP8zR28=; b=YHZZz3XEX/P2FswmqRKq1IJ1dngRz1+AQ3vly8kcOD90y9MwZbcKBAqG33+vCX+j5Y 14URx32V8oQ3BZiFPZrbpMfLKSBTRcgYX5HSMULqY6DYIlinubmF0QAzgXkQrspo+kFN IZmucTiN2GX5oget1y7CsIaio80kW8cH0Ru/PGLLW3slpKxdpZ280RQjAzAYCgA+jjhy v5B/4mh4Ti4EfDD21K7u6aVJA0PfXgAHjuBXXwSDLQJm28Bs94PKMdoDsTBnF5/RyjCm 4krAwqpB/3msTYK/qPROR9VNb1RWh20z2AQsTHSUUE4DaEBIbdynTjf1zSVbtF94wmaE exOQ== X-Gm-Message-State: ALoCoQng5O6y5eGEJ3dSXabeJx9LUKbYLp3zSTywwz7DBVOeDAkW5xKioK39zqH6p/juQGtsqpd8 X-Received: by 10.152.88.70 with SMTP id be6mr19856354lab.9.1435224706955; Thu, 25 Jun 2015 02:31:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.163 with SMTP id t3ls325760lat.6.gmail; Thu, 25 Jun 2015 02:31:46 -0700 (PDT) X-Received: by 10.152.87.231 with SMTP id bb7mr40589085lab.16.1435224706797; Thu, 25 Jun 2015 02:31:46 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id ay7si24235185lbc.60.2015.06.25.02.31.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jun 2015 02:31:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbbvz5 with SMTP id vz5so41825853lbb.0 for ; Thu, 25 Jun 2015 02:31:46 -0700 (PDT) X-Received: by 10.112.42.50 with SMTP id k18mr15872302lbl.76.1435224706702; Thu, 25 Jun 2015 02:31:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp468968lbb; Thu, 25 Jun 2015 02:31:45 -0700 (PDT) X-Received: by 10.66.66.65 with SMTP id d1mr88967987pat.22.1435224697927; Thu, 25 Jun 2015 02:31:37 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tg9si38047897pab.202.2015.06.25.02.31.37; Thu, 25 Jun 2015 02:31:37 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751930AbbFYJbe (ORCPT + 4 others); Thu, 25 Jun 2015 05:31:34 -0400 Received: from 82-70-136-246.dsl.in-addr.zen.co.uk ([82.70.136.246]:49639 "EHLO xk120.dyn.ducie.codethink.co.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751807AbbFYJbO (ORCPT ); Thu, 25 Jun 2015 05:31:14 -0400 Received: from william by xk120.dyn.ducie.codethink.co.uk with local (Exim 4.80) (envelope-from ) id 1Z83V2-0006eV-Au; Thu, 25 Jun 2015 10:31:12 +0100 From: William Towle To: linux-media@vger.kernel.org, linux-kernel@lists.codethink.co.uk Cc: Guennadi Liakhovetski , Sergei Shtylyov , Hans Verkuil Subject: [PATCH 08/15] v4l: subdev: Add pad config allocator and init Date: Thu, 25 Jun 2015 10:31:02 +0100 Message-Id: <1435224669-23672-9-git-send-email-william.towle@codethink.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1435224669-23672-1-git-send-email-william.towle@codethink.co.uk> References: <1435224669-23672-1-git-send-email-william.towle@codethink.co.uk> Sender: linux-media-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: william.towle@codethink.co.uk X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- drivers/media/v4l2-core/v4l2-subdev.c | 19 ++++++++++++++++++- include/media/v4l2-subdev.h | 10 ++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) Changes since v1: - Added v4l2_subdev_free_pad_config --- 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 6359606..d594fe5 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 dc20102..4a609f6 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -485,6 +485,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); @@ -677,7 +679,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);