From patchwork Fri May 8 19:31:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 6367201 Return-Path: X-Original-To: patchwork-alsa-devel@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 249AF9F1C2 for ; Fri, 8 May 2015 19:32:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4EC3D20220 for ; Fri, 8 May 2015 19:32:02 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id DC98C200ED for ; Fri, 8 May 2015 19:32:00 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 024B2265DF5; Fri, 8 May 2015 21:31:59 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id A0D9826058E; Fri, 8 May 2015 21:31:50 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 13D99260595; Fri, 8 May 2015 21:31:49 +0200 (CEST) Received: from resqmta-po-06v.sys.comcast.net (resqmta-po-06v.sys.comcast.net [96.114.154.165]) by alsa0.perex.cz (Postfix) with ESMTP id 9ED6926058E for ; Fri, 8 May 2015 21:31:38 +0200 (CEST) Received: from resomta-po-18v.sys.comcast.net ([96.114.154.242]) by resqmta-po-06v.sys.comcast.net with comcast id RXXd1q0075E3ZMc01XXdgV; Fri, 08 May 2015 19:31:37 +0000 Received: from mail.gonehiking.org ([73.181.52.62]) by resomta-po-18v.sys.comcast.net with comcast id RXXa1q00S1LXgTt01XXaTu; Fri, 08 May 2015 19:31:37 +0000 Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 75EAE40E84; Fri, 8 May 2015 13:31:34 -0600 (MDT) From: Shuah Khan To: mchehab@osg.samsung.com, hans.verkuil@cisco.com, laurent.pinchart@ideasonboard.com, tiwai@suse.de, perex@perex.cz, agoode@google.com, pierre-louis.bossart@linux.intel.com, gtmkramer@xs4all.nl, clemens@ladisch.de, vladcatoi@gmail.com, damien@zamaudio.com, chris.j.arges@canonical.com, takamichiho@gmail.com, misterpib@gmail.com, daniel@zonque.org, pmatilai@laiskiainen.org, jussi@sonarnerd.net, normalperson@yhbt.net, fisch602@gmail.com, joe@oampo.co.uk Date: Fri, 8 May 2015 13:31:30 -0600 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1431113497; bh=701jDgQz4D/BVQwNTm7ltR37dR2qrzM2B9jIIk+ILBo=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=ZGxCffJP8QULFcfVuvs8VJ/sDP/71pPS97qdA11t0pauRSmIYeDqq/Y48vHVM+atM JW+UMT7CqObT7azzEBLEpDQiLyLtos4vOjPp5DeQBuvCvwaOX2PNKyzHoNtObf2ju4 0TOmQUXnRvEPC6Mgc8/qsWMX6V9CjwwzYJmW3VKqDESUIpHS2onNV111TTAThLKvGv JYu9Bl2un1c3O67d9egSj0W8UTVUOMxJxo2df9q0ngbewmuKKoBDnxQKqYVRHzlTNJ m+jU+fGYWyLeOqVXL6o6avgtiOAigjjhOmPQED9U24eYcXEfCk+EE4IEstESUkiwuz 0E9ixuk5WAJuA== Cc: alsa-devel@alsa-project.org, Shuah Khan , linux-media@vger.kernel.org Subject: [alsa-devel] [PATCH 1/2] media: new media controller API for device resource support X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Add new media controller API to allocate media device as a device resource. When a media device is created on the main struct device which is the parent device for the interface device, it will be available to all drivers associated with that interface. For example, if a usb media device driver creates the media device on the main struct device which is common for all the drivers that control the media device, including the non-media ALSA driver, media controller API can be used to share access to the resources on the media device. This new interface provides the above described feature. A second interface that finds and returns the media device is added to allow drivers to find the media device created by any of the drivers associated with the device. Signed-off-by: Shuah Khan --- drivers/media/media-device.c | 33 +++++++++++++++++++++++++++++++++ include/media/media-device.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 7b39440..1c32752 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -462,3 +462,36 @@ void media_device_unregister_entity(struct media_entity *entity) entity->parent = NULL; } EXPORT_SYMBOL_GPL(media_device_unregister_entity); + +static void media_device_release_dr(struct device *dev, void *res) +{ +} + +/* + * media_device_get_dr() - get media device as device resource + * creates if one doesn't exist +*/ +struct media_device *media_device_get_dr(struct device *dev) +{ + struct media_device *mdev; + + mdev = devres_find(dev, media_device_release_dr, NULL, NULL); + if (mdev) + return mdev; + + mdev = devres_alloc(media_device_release_dr, + sizeof(struct media_device), GFP_KERNEL); + if (!mdev) + return NULL; + return devres_get(dev, mdev, NULL, NULL); +} +EXPORT_SYMBOL_GPL(media_device_get_dr); + +/* + * media_device_find_dr() - find media device as device resource +*/ +struct media_device *media_device_find_dr(struct device *dev) +{ + return devres_find(dev, media_device_release_dr, NULL, NULL); +} +EXPORT_SYMBOL_GPL(media_device_find_dr); diff --git a/include/media/media-device.h b/include/media/media-device.h index 6e6db78..53d0fc3 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -95,6 +95,8 @@ void media_device_unregister(struct media_device *mdev); int __must_check media_device_register_entity(struct media_device *mdev, struct media_entity *entity); void media_device_unregister_entity(struct media_entity *entity); +struct media_device *media_device_get_dr(struct device *dev); +struct media_device *media_device_find_dr(struct device *dev); /* Iterate over all entities. */ #define media_device_for_each_entity(entity, mdev) \