Re: [PATCH 7/7] sound/usb: Update ALSA driver to use Managed Media Controller API

2015-07-20 Thread Shuah Khan
On 07/20/2015 03:00 AM, Takashi Iwai wrote:
> On Mon, 20 Jul 2015 10:47:46 +0200,
> Dan Carpenter wrote:
>>
>> On Tue, Jul 14, 2015 at 06:34:06PM -0600, Shuah Khan wrote:
>>> +   ret = media_entity_setup_link(link, flags);
>>> +   if (ret) {
>>> +   dev_err(mctl->media_dev->dev,
>>> +   "Couldn't change tuner link",
>>> +   "%s->%s to %s. Error %d\n",
>>
>> Add a space after "link".
>>
>>  "Couldn't change tuner link ",
>>  "%s->%s to %s. Error %d\n",
> 
> Such a message string would be better to be in a single line even if
> it's over 80 chars.  Otherwise it becomes hard to grep.
> 

Right. The above generates a warning and I found it after I sent
the patch. I will have to re-do this patch to fix this. I prefer
not splitting the message, but checkpatch compains if I don't.

thanks,
-- Shuah

-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shua...@osg.samsung.com | (970) 217-8978
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 7/7] sound/usb: Update ALSA driver to use Managed Media Controller API

2015-07-20 Thread Takashi Iwai
On Mon, 20 Jul 2015 10:47:46 +0200,
Dan Carpenter wrote:
> 
> On Tue, Jul 14, 2015 at 06:34:06PM -0600, Shuah Khan wrote:
> > +   ret = media_entity_setup_link(link, flags);
> > +   if (ret) {
> > +   dev_err(mctl->media_dev->dev,
> > +   "Couldn't change tuner link",
> > +   "%s->%s to %s. Error %d\n",
> 
> Add a space after "link".
> 
>   "Couldn't change tuner link ",
>   "%s->%s to %s. Error %d\n",

Such a message string would be better to be in a single line even if
it's over 80 chars.  Otherwise it becomes hard to grep.


thanks,

Takashi
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 7/7] sound/usb: Update ALSA driver to use Managed Media Controller API

2015-07-20 Thread Dan Carpenter
On Tue, Jul 14, 2015 at 06:34:06PM -0600, Shuah Khan wrote:
> + ret = media_entity_setup_link(link, flags);
> + if (ret) {
> + dev_err(mctl->media_dev->dev,
> + "Couldn't change tuner link",
> + "%s->%s to %s. Error %d\n",

Add a space after "link".

"Couldn't change tuner link ",
"%s->%s to %s. Error %d\n",

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/7] sound/usb: Update ALSA driver to use Managed Media Controller API

2015-07-14 Thread Shuah Khan
Change ALSA driver to use Managed ~media Managed Controller
API to share tuner with DVB and V4L2 drivers that control
AU0828 media device.  Media device is created based on a
newly added field value in the struct snd_usb_audio_quirk.
Using this approach, the media controller API usage can be
added for a specific device. In this patch, Media Controller
API is enabled for AU0828 hw. snd_usb_create_quirk() will
check this new field, if set will create a media device using
media_device_get_devres() interface.

media_device_get_devres() will allocate a new media device
devres or return an existing one, if it finds one.

During probe, media usb driver could have created the media
device devres. It will then register the media device if it
isn't already registered. Media device unregister is done from
usb_audio_disconnect().

During probe, media usb driver could have created the
media device devres. It will then register the media
device if it isn't already registered. Media device
unregister is done from usb_audio_disconnect().

New structure media_ctl is added to group the new
fields to support media entity and links. This new
structure is added to struct snd_usb_substream.

A new entity_notify hook and a new ALSA capture media
entity are registered from snd_usb_pcm_open() after
setting up hardware information for the PCM device.

When a new entity is registered, Media Controller API
interface media_device_register_entity() invokes all
registered entity_notify hooks for the media device.
ALSA entity_notify hook parses all the entity list to
find a link from decoder it ALSA entity. This indicates
that the bridge driver created a link from decoder to
ALSA capture entity. At this time, ALSA will attempt to
enable the tuner to link the tuner to the decoder calling
media_entity_setup_link(). media_entity_setup_link() will
either return success activating tuner to decoder link or
error if it tuner is busy.

Media pipeline gets started to mark the tuner busy from
snd_usb_substream_capture_trigger() in response to
SNDRV_PCM_TRIGGER_START and pipeline is stopped in
response to SNDRV_PCM_TRIGGER_STOP. snd_usb_pcm_close()
stops pipeline to cover the case when SNDRV_PCM_TRIGGER_STOP
isn't issued. Pipeline start and stop are done only when
decoder_linked is set. Tuner enable step could be done
from snd_usb_substream_capture_trigger(). The reason it
is done from snd_usb_pcm_open() is that it reduces the
work that is needed from snd_usb_substream_capture_trigger().

There is an open issue with graph_mutex hold in Media Controller
media_entity_pipeline_start() and media_entity_pipeline_stop()
API. snd-us-audio calls these from snd_usb_substream_capture_trigger()
which could be called in irq path. This issue needs to be resolved
before this patch can go in.

Signed-off-by: Shuah Khan 
---
 sound/usb/Makefile   |  15 ++-
 sound/usb/card.c |   5 +
 sound/usb/card.h |   1 +
 sound/usb/media.c| 260 +++
 sound/usb/media.h|  52 ++
 sound/usb/pcm.c  |  15 ++-
 sound/usb/quirks-table.h |   1 +
 sound/usb/quirks.c   |   9 +-
 sound/usb/stream.c   |   2 +
 sound/usb/usbaudio.h |   1 +
 10 files changed, 357 insertions(+), 4 deletions(-)
 create mode 100644 sound/usb/media.c
 create mode 100644 sound/usb/media.h

diff --git a/sound/usb/Makefile b/sound/usb/Makefile
index 2d2d122..665fdd9 100644
--- a/sound/usb/Makefile
+++ b/sound/usb/Makefile
@@ -2,6 +2,18 @@
 # Makefile for ALSA
 #
 
+# Media Controller
+ifeq ($(CONFIG_MEDIA_CONTROLLER),y)
+  ifeq ($(CONFIG_MEDIA_SUPPORT),y)
+KBUILD_CFLAGS += -DUSE_MEDIA_CONTROLLER
+  endif
+  ifeq ($(CONFIG_MEDIA_SUPPORT_MODULE),y)
+ifeq ($(MODULE),y)
+  KBUILD_CFLAGS += -DUSE_MEDIA_CONTROLLER
+endif
+  endif
+endif
+
 snd-usb-audio-objs :=  card.o \
clock.o \
endpoint.o \
@@ -13,7 +25,8 @@ snd-usb-audio-objs := card.o \
pcm.o \
proc.o \
quirks.o \
-   stream.o
+   stream.o \
+   media.o
 
 snd-usbmidi-lib-objs := midi.o
 
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 1fab977..469d2bf 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -66,6 +66,7 @@
 #include "format.h"
 #include "power.h"
 #include "stream.h"
+#include "media.h"
 
 MODULE_AUTHOR("Takashi Iwai ");
 MODULE_DESCRIPTION("USB Audio");
@@ -619,6 +620,10 @@ static void usb_audio_disconnect(struct usb_interface 
*intf)
list_for_each_entry(mixer, &chip->mixer_list, list) {
snd_usb_mixer_disconnect(mixer);
}
+   /* Nice to check quirk && quirk->media_device
+* need some special handlings. Doesn't look like
+* we have access to quirk here */
+   media_device_delete(intf);
}
 
chip->num_interf