From patchwork Sun May 24 21:10:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 48921 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 593F42121F for ; Sun, 24 May 2015 21:09:51 +0000 (UTC) Received: by wgez8 with SMTP id z8sf4636619wge.2 for ; Sun, 24 May 2015 14:09:50 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=AUdPSoRmuBFpJyQA1y2GSaNBmZRXtDNnSneGT5yFx8E=; b=FcCjMScy06mU5ass4efbpxficeCOVusJcDdnGZuYjFK3AQVTIHxcuZq77WOnuBq7Cl 7hu3yW0//Dc5SM/gf7sjpu6guY9cetxT1P2tTDr+3yLrr/MS1zJAKULvdhMDwGU9YEHo 7ovUm3q5L08EWqAk/9/yJPVEYd1+YDjahB+6eyXkDJrVdh3BJKUGaTt6r8iSaLmlnYEx CKTNrxb/rHh+Tx9LjiSHsDqmjOyceClQWxa5cjNc2EbvhcswX0ypL/B4GYsIrn57Titu 3N5ORnJr7f1z5vSGP2WBdfZFC5xdRd/ejZmCIusJtx/CaaFbKBkNoJvWXbCd9OUoQgny W8LQ== X-Gm-Message-State: ALoCoQkNzkOmD9bZ3i6hYZXQgr+qpHHNM4dvAz1SDGmEEk8L2VFFe/rexqOvFP+OUB/5iT5GFvrH X-Received: by 10.112.171.41 with SMTP id ar9mr19217309lbc.24.1432501790642; Sun, 24 May 2015 14:09:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.227 with SMTP id lf3ls558210lab.93.gmail; Sun, 24 May 2015 14:09:50 -0700 (PDT) X-Received: by 10.112.202.36 with SMTP id kf4mr8792808lbc.0.1432501790461; Sun, 24 May 2015 14:09:50 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id cj1si6742340lad.28.2015.05.24.14.09.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 May 2015 14:09:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by laat2 with SMTP id t2so39311557laa.1 for ; Sun, 24 May 2015 14:09:49 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr15778635lbc.32.1432501789799; Sun, 24 May 2015 14:09:49 -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 hn6csp1404546lbb; Sun, 24 May 2015 14:09:48 -0700 (PDT) X-Received: by 10.66.138.15 with SMTP id qm15mr34099211pab.52.1432501787972; Sun, 24 May 2015 14:09:47 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fl4si4989460pab.108.2015.05.24.14.09.47; Sun, 24 May 2015 14:09:47 -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 S1751556AbbEXVJq (ORCPT + 4 others); Sun, 24 May 2015 17:09:46 -0400 Received: from galahad.ideasonboard.com ([185.26.127.97]:38656 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751411AbbEXVJp (ORCPT ); Sun, 24 May 2015 17:09:45 -0400 Received: from avalon.ideasonboard.com (dsl-hkibrasgw3-50ddcc-40.dhcp.inet.fi [80.221.204.40]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 24C4920010; Sun, 24 May 2015 23:09:25 +0200 (CEST) From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Hans Verkuil , Vaibhav Hiremath Subject: [PATCH v2] v4l: subdev: Add pad config allocator and init Date: Mon, 25 May 2015 00:10:00 +0300 Message-Id: <1432501800-3411-1-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.3.6 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: laurent.pinchart@ideasonboard.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 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 diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 63596063b213..d594fe566be2 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 8f5da73dacff..cf2ee07b0745 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -483,6 +483,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); @@ -675,7 +677,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);