From patchwork Wed Jun 10 14:21:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 6580931 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A87EEC0020 for ; Wed, 10 Jun 2015 14:22:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD60D205FC for ; Wed, 10 Jun 2015 14:22:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E719205F5 for ; Wed, 10 Jun 2015 14:22:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964959AbbFJOWG (ORCPT ); Wed, 10 Jun 2015 10:22:06 -0400 Received: from resqmta-po-12v.sys.comcast.net ([96.114.154.171]:41589 "EHLO resqmta-po-12v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932711AbbFJOWD (ORCPT ); Wed, 10 Jun 2015 10:22:03 -0400 Received: from resomta-po-11v.sys.comcast.net ([96.114.154.235]) by resqmta-po-12v.sys.comcast.net with comcast id eeMf1q00554zqzk01eN2ze; Wed, 10 Jun 2015 14:22:02 +0000 Received: from mail.gonehiking.org ([73.181.52.62]) by resomta-po-11v.sys.comcast.net with comcast id eeMz1q00D1LXgTt01eMzvX; Wed, 10 Jun 2015 14:22:02 +0000 Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id D148440094; Wed, 10 Jun 2015 08:21:58 -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 Cc: Shuah Khan , linux-media@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH v3 1/2] media: media controller entity framework enhancements for ALSA Date: Wed, 10 Jun 2015 08:21:56 -0600 Message-Id: <3f740931e63a551c75aeed1c36955c468d448ef2.1433904553.git.shuahkh@osg.samsung.com> 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=1433946122; bh=tMJcIvEvavRfVk4+ZYPDvDjw4GZeVDUEB8L2hUYaVaw=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=lqOTe6HO1KYwlutt2u9iUowglANvmz+KbuomR8xfxpFwYkjda22AbK1gAwzbPvFgo R/wcLkbtrmhNeuAE060kyQOsizxjn1ITllR84Aj28JiX27fxkozO4kfffYwFrTm9oj cwBCWNtPZJRZFO7muKmVc0nTlgXrdotsHhkpMgXVRS7X6XSzHckQEGKxWDCa/m8OBd 1XNXXOU+XTvB1APeHmtkkUh3t+1myHfvNCE2xS6UNruXY+FafhX0OqmVcDMQY7fr8Y j6ae4FTen12BlN7Kx5ByhOCige/VJhuwydn3sVMGZuzRrTsCOBhGwd3RCWAgQ8NhOU nqL5PhKnL7vMA== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a new media entity operation register_notify is added to media_entity_operations structure. This hook is called from media_device_register_entity() whenever a new entity is registered to notify other entities attached to that media device of the newly created entity. Entity owners can register the hook to create links and take any other action when a new entity is registered. A new field is added to the struct media_entity for entity owners to save their private data that is used in the register_notify hook. Signed-off-by: Shuah Khan --- drivers/media/media-device.c | 7 +++++++ include/media/media-entity.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index c55ab50..76590ba 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -428,6 +428,8 @@ EXPORT_SYMBOL_GPL(media_device_unregister); int __must_check media_device_register_entity(struct media_device *mdev, struct media_entity *entity) { + struct media_entity *eptr; + /* Warn if we apparently re-register an entity */ WARN_ON(entity->parent != NULL); entity->parent = mdev; @@ -440,6 +442,11 @@ int __must_check media_device_register_entity(struct media_device *mdev, list_add_tail(&entity->list, &mdev->entities); spin_unlock(&mdev->lock); + media_device_for_each_entity(eptr, mdev) { + if (eptr != entity) + media_entity_call(eptr, register_notify); + } + return 0; } EXPORT_SYMBOL_GPL(media_device_register_entity); diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 0c003d8..0bc4c2f 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -46,6 +46,7 @@ struct media_pad { /** * struct media_entity_operations - Media entity operations + * @register_notify Notify entity of newly registered entity * @link_setup: Notify the entity of link changes. The operation can * return an error, in which case link setup will be * cancelled. Optional. @@ -54,6 +55,7 @@ struct media_pad { * validates all links by calling this operation. Optional. */ struct media_entity_operations { + int (*register_notify)(struct media_entity *entity); int (*link_setup)(struct media_entity *entity, const struct media_pad *local, const struct media_pad *remote, u32 flags); @@ -101,6 +103,8 @@ struct media_entity { /* Sub-device specifications */ /* Nothing needed yet */ } info; + + void *private; /* private data for the entity */ }; static inline u32 media_entity_type(struct media_entity *entity)