summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-03-31 08:57:29 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-03-31 14:02:33 -0400
commitc89178f57a19300b2056f58167e183e966a4836d (patch)
tree5ba4770b2377124e1d905a9e4f91d75dc9bb7365
parente8e3039f5b941f7825d335f8ca11c12a8104db11 (diff)
[media] Revert "[media] sound/usb: Use Media Controller API to share media resources"
Unfortunately, this patch caused several regressions at au0828 and snd-usb-audio, like this one: https://bugzilla.kernel.org/show_bug.cgi?id=115561 It also showed several troubles at the MC core that handles pretty poorly the memory protections and data lifetime management. So, better to revert it and fix the core before reapplying this change. This reverts commit aebb2b89bff0 ("[media] sound/usb: Use Media Controller API to share media resources")' Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--sound/usb/Kconfig4
-rw-r--r--sound/usb/Makefile2
-rw-r--r--sound/usb/card.c14
-rw-r--r--sound/usb/card.h3
-rw-r--r--sound/usb/media.c318
-rw-r--r--sound/usb/media.h72
-rw-r--r--sound/usb/mixer.h3
-rw-r--r--sound/usb/pcm.c28
-rw-r--r--sound/usb/quirks-table.h1
-rw-r--r--sound/usb/stream.c2
-rw-r--r--sound/usb/usbaudio.h6
11 files changed, 5 insertions, 448 deletions
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig
index d14bf411515b..a452ad7cec40 100644
--- a/sound/usb/Kconfig
+++ b/sound/usb/Kconfig
@@ -15,7 +15,6 @@ config SND_USB_AUDIO
15 select SND_RAWMIDI 15 select SND_RAWMIDI
16 select SND_PCM 16 select SND_PCM
17 select BITREVERSE 17 select BITREVERSE
18 select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND_USB_AUDIO)
19 help 18 help
20 Say Y here to include support for USB audio and USB MIDI 19 Say Y here to include support for USB audio and USB MIDI
21 devices. 20 devices.
@@ -23,9 +22,6 @@ config SND_USB_AUDIO
23 To compile this driver as a module, choose M here: the module 22 To compile this driver as a module, choose M here: the module
24 will be called snd-usb-audio. 23 will be called snd-usb-audio.
25 24
26config SND_USB_AUDIO_USE_MEDIA_CONTROLLER
27 bool
28
29config SND_USB_UA101 25config SND_USB_UA101
30 tristate "Edirol UA-101/UA-1000 driver" 26 tristate "Edirol UA-101/UA-1000 driver"
31 select SND_PCM 27 select SND_PCM
diff --git a/sound/usb/Makefile b/sound/usb/Makefile
index 8dca3c407f5a..2d2d122b069f 100644
--- a/sound/usb/Makefile
+++ b/sound/usb/Makefile
@@ -15,8 +15,6 @@ snd-usb-audio-objs := card.o \
15 quirks.o \ 15 quirks.o \
16 stream.o 16 stream.o
17 17
18snd-usb-audio-$(CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER) += media.o
19
20snd-usbmidi-lib-objs := midi.o 18snd-usbmidi-lib-objs := midi.o
21 19
22# Toplevel Module Dependency 20# Toplevel Module Dependency
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 63244bbba8c7..3fc63583a537 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -66,7 +66,6 @@
66#include "format.h" 66#include "format.h"
67#include "power.h" 67#include "power.h"
68#include "stream.h" 68#include "stream.h"
69#include "media.h"
70 69
71MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>"); 70MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
72MODULE_DESCRIPTION("USB Audio"); 71MODULE_DESCRIPTION("USB Audio");
@@ -612,11 +611,6 @@ static int usb_audio_probe(struct usb_interface *intf,
612 if (err < 0) 611 if (err < 0)
613 goto __error; 612 goto __error;
614 613
615 if (quirk->media_device) {
616 /* don't want to fail when media_snd_device_create() fails */
617 media_snd_device_create(chip, intf);
618 }
619
620 usb_chip[chip->index] = chip; 614 usb_chip[chip->index] = chip;
621 chip->num_interfaces++; 615 chip->num_interfaces++;
622 usb_set_intfdata(intf, chip); 616 usb_set_intfdata(intf, chip);
@@ -673,14 +667,6 @@ static void usb_audio_disconnect(struct usb_interface *intf)
673 list_for_each(p, &chip->midi_list) { 667 list_for_each(p, &chip->midi_list) {
674 snd_usbmidi_disconnect(p); 668 snd_usbmidi_disconnect(p);
675 } 669 }
676 /*
677 * Nice to check quirk && quirk->media_device
678 * need some special handlings. Doesn't look like
679 * we have access to quirk here
680 * Acceses mixer_list
681 */
682 media_snd_device_delete(chip);
683
684 /* release mixer resources */ 670 /* release mixer resources */
685 list_for_each_entry(mixer, &chip->mixer_list, list) { 671 list_for_each_entry(mixer, &chip->mixer_list, list) {
686 snd_usb_mixer_disconnect(mixer); 672 snd_usb_mixer_disconnect(mixer);
diff --git a/sound/usb/card.h b/sound/usb/card.h
index 34a0898e2238..71778ca4b26a 100644
--- a/sound/usb/card.h
+++ b/sound/usb/card.h
@@ -105,8 +105,6 @@ struct snd_usb_endpoint {
105 struct list_head list; 105 struct list_head list;
106}; 106};
107 107
108struct media_ctl;
109
110struct snd_usb_substream { 108struct snd_usb_substream {
111 struct snd_usb_stream *stream; 109 struct snd_usb_stream *stream;
112 struct usb_device *dev; 110 struct usb_device *dev;
@@ -158,7 +156,6 @@ struct snd_usb_substream {
158 } dsd_dop; 156 } dsd_dop;
159 157
160 bool trigger_tstamp_pending_update; /* trigger timestamp being updated from initial estimate */ 158 bool trigger_tstamp_pending_update; /* trigger timestamp being updated from initial estimate */
161 struct media_ctl *media_ctl;
162}; 159};
163 160
164struct snd_usb_stream { 161struct snd_usb_stream {
diff --git a/sound/usb/media.c b/sound/usb/media.c
deleted file mode 100644
index 93a50d01490c..000000000000
--- a/sound/usb/media.c
+++ /dev/null
@@ -1,318 +0,0 @@
1/*
2 * media.c - Media Controller specific ALSA driver code
3 *
4 * Copyright (c) 2016 Shuah Khan <shuahkh@osg.samsung.com>
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6 *
7 * This file is released under the GPLv2.
8 */
9
10/*
11 * This file adds Media Controller support to ALSA driver
12 * to use the Media Controller API to share tuner with DVB
13 * and V4L2 drivers that control media device. Media device
14 * is created based on existing quirks framework. Using this
15 * approach, the media controller API usage can be added for
16 * a specific device.
17*/
18
19#include <linux/init.h>
20#include <linux/list.h>
21#include <linux/mutex.h>
22#include <linux/slab.h>
23#include <linux/usb.h>
24
25#include <sound/pcm.h>
26#include <sound/core.h>
27
28#include "usbaudio.h"
29#include "card.h"
30#include "mixer.h"
31#include "media.h"
32
33static int media_snd_enable_source(struct media_ctl *mctl)
34{
35 if (mctl && mctl->media_dev->enable_source)
36 return mctl->media_dev->enable_source(&mctl->media_entity,
37 &mctl->media_pipe);
38 return 0;
39}
40
41static void media_snd_disable_source(struct media_ctl *mctl)
42{
43 if (mctl && mctl->media_dev->disable_source)
44 mctl->media_dev->disable_source(&mctl->media_entity);
45}
46
47int media_snd_stream_init(struct snd_usb_substream *subs, struct snd_pcm *pcm,
48 int stream)
49{
50 struct media_device *mdev;
51 struct media_ctl *mctl;
52 struct device *pcm_dev = &pcm->streams[stream].dev;
53 u32 intf_type;
54 int ret = 0;
55 u16 mixer_pad;
56 struct media_entity *entity;
57
58 mdev = subs->stream->chip->media_dev;
59 if (!mdev)
60 return -ENODEV;
61
62 if (subs->media_ctl)
63 return 0;
64
65 /* allocate media_ctl */
66 mctl = kzalloc(sizeof(*mctl), GFP_KERNEL);
67 if (!mctl)
68 return -ENOMEM;
69
70 mctl->media_dev = mdev;
71 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
72 intf_type = MEDIA_INTF_T_ALSA_PCM_PLAYBACK;
73 mctl->media_entity.function = MEDIA_ENT_F_AUDIO_PLAYBACK;
74 mctl->media_pad.flags = MEDIA_PAD_FL_SOURCE;
75 mixer_pad = 1;
76 } else {
77 intf_type = MEDIA_INTF_T_ALSA_PCM_CAPTURE;
78 mctl->media_entity.function = MEDIA_ENT_F_AUDIO_CAPTURE;
79 mctl->media_pad.flags = MEDIA_PAD_FL_SINK;
80 mixer_pad = 2;
81 }
82 mctl->media_entity.name = pcm->name;
83 media_entity_pads_init(&mctl->media_entity, 1, &mctl->media_pad);
84 ret = media_device_register_entity(mctl->media_dev,
85 &mctl->media_entity);
86 if (ret)
87 goto free_mctl;
88
89 mctl->intf_devnode = media_devnode_create(mdev, intf_type, 0,
90 MAJOR(pcm_dev->devt),
91 MINOR(pcm_dev->devt));
92 if (!mctl->intf_devnode) {
93 ret = -ENOMEM;
94 goto unregister_entity;
95 }
96 mctl->intf_link = media_create_intf_link(&mctl->media_entity,
97 &mctl->intf_devnode->intf,
98 MEDIA_LNK_FL_ENABLED);
99 if (!mctl->intf_link) {
100 ret = -ENOMEM;
101 goto devnode_remove;
102 }
103
104 /* create link between mixer and audio */
105 media_device_for_each_entity(entity, mdev) {
106 switch (entity->function) {
107 case MEDIA_ENT_F_AUDIO_MIXER:
108 ret = media_create_pad_link(entity, mixer_pad,
109 &mctl->media_entity, 0,
110 MEDIA_LNK_FL_ENABLED);
111 if (ret)
112 goto remove_intf_link;
113 break;
114 }
115 }
116
117 subs->media_ctl = mctl;
118 return 0;
119
120remove_intf_link:
121 media_remove_intf_link(mctl->intf_link);
122devnode_remove:
123 media_devnode_remove(mctl->intf_devnode);
124unregister_entity:
125 media_device_unregister_entity(&mctl->media_entity);
126free_mctl:
127 kfree(mctl);
128 return ret;
129}
130
131void media_snd_stream_delete(struct snd_usb_substream *subs)
132{
133 struct media_ctl *mctl = subs->media_ctl;
134
135 if (mctl && mctl->media_dev) {
136 struct media_device *mdev;
137
138 mdev = subs->stream->chip->media_dev;
139 if (mdev && media_devnode_is_registered(&mdev->devnode)) {
140 media_devnode_remove(mctl->intf_devnode);
141 media_device_unregister_entity(&mctl->media_entity);
142 media_entity_cleanup(&mctl->media_entity);
143 }
144 kfree(mctl);
145 subs->media_ctl = NULL;
146 }
147}
148
149int media_snd_start_pipeline(struct snd_usb_substream *subs)
150{
151 struct media_ctl *mctl = subs->media_ctl;
152
153 if (mctl)
154 return media_snd_enable_source(mctl);
155 return 0;
156}
157
158void media_snd_stop_pipeline(struct snd_usb_substream *subs)
159{
160 struct media_ctl *mctl = subs->media_ctl;
161
162 if (mctl)
163 media_snd_disable_source(mctl);
164}
165
166int media_snd_mixer_init(struct snd_usb_audio *chip)
167{
168 struct device *ctl_dev = &chip->card->ctl_dev;
169 struct media_intf_devnode *ctl_intf;
170 struct usb_mixer_interface *mixer;
171 struct media_device *mdev = chip->media_dev;
172 struct media_mixer_ctl *mctl;
173 u32 intf_type = MEDIA_INTF_T_ALSA_CONTROL;
174 int ret;
175
176 if (!mdev)
177 return -ENODEV;
178
179 ctl_intf = chip->ctl_intf_media_devnode;
180 if (!ctl_intf) {
181 ctl_intf = media_devnode_create(mdev, intf_type, 0,
182 MAJOR(ctl_dev->devt),
183 MINOR(ctl_dev->devt));
184 if (!ctl_intf)
185 return -ENOMEM;
186 chip->ctl_intf_media_devnode = ctl_intf;
187 }
188
189 list_for_each_entry(mixer, &chip->mixer_list, list) {
190
191 if (mixer->media_mixer_ctl)
192 continue;
193
194 /* allocate media_mixer_ctl */
195 mctl = kzalloc(sizeof(*mctl), GFP_KERNEL);
196 if (!mctl)
197 return -ENOMEM;
198
199 mctl->media_dev = mdev;
200 mctl->media_entity.function = MEDIA_ENT_F_AUDIO_MIXER;
201 mctl->media_entity.name = chip->card->mixername;
202 mctl->media_pad[0].flags = MEDIA_PAD_FL_SINK;
203 mctl->media_pad[1].flags = MEDIA_PAD_FL_SOURCE;
204 mctl->media_pad[2].flags = MEDIA_PAD_FL_SOURCE;
205 media_entity_pads_init(&mctl->media_entity, MEDIA_MIXER_PAD_MAX,
206 mctl->media_pad);
207 ret = media_device_register_entity(mctl->media_dev,
208 &mctl->media_entity);
209 if (ret) {
210 kfree(mctl);
211 return ret;
212 }
213
214 mctl->intf_link = media_create_intf_link(&mctl->media_entity,
215 &ctl_intf->intf,
216 MEDIA_LNK_FL_ENABLED);
217 if (!mctl->intf_link) {
218 media_device_unregister_entity(&mctl->media_entity);
219 media_entity_cleanup(&mctl->media_entity);
220 kfree(mctl);
221 return -ENOMEM;
222 }
223 mctl->intf_devnode = ctl_intf;
224 mixer->media_mixer_ctl = mctl;
225 }
226 return 0;
227}
228
229static void media_snd_mixer_delete(struct snd_usb_audio *chip)
230{
231 struct usb_mixer_interface *mixer;
232 struct media_device *mdev = chip->media_dev;
233
234 if (!mdev)
235 return;
236
237 list_for_each_entry(mixer, &chip->mixer_list, list) {
238 struct media_mixer_ctl *mctl;
239
240 mctl = mixer->media_mixer_ctl;
241 if (!mixer->media_mixer_ctl)
242 continue;
243
244 if (media_devnode_is_registered(&mdev->devnode)) {
245 media_device_unregister_entity(&mctl->media_entity);
246 media_entity_cleanup(&mctl->media_entity);
247 }
248 kfree(mctl);
249 mixer->media_mixer_ctl = NULL;
250 }
251 if (media_devnode_is_registered(&mdev->devnode))
252 media_devnode_remove(chip->ctl_intf_media_devnode);
253 chip->ctl_intf_media_devnode = NULL;
254}
255
256int media_snd_device_create(struct snd_usb_audio *chip,
257 struct usb_interface *iface)
258{
259 struct media_device *mdev;
260 struct usb_device *usbdev = interface_to_usbdev(iface);
261 int ret;
262
263 mdev = media_device_get_devres(&usbdev->dev);
264 if (!mdev)
265 return -ENOMEM;
266 if (!mdev->dev) {
267 /* register media device */
268 mdev->dev = &usbdev->dev;
269 if (usbdev->product)
270 strlcpy(mdev->model, usbdev->product,
271 sizeof(mdev->model));
272 if (usbdev->serial)
273 strlcpy(mdev->serial, usbdev->serial,
274 sizeof(mdev->serial));
275 strcpy(mdev->bus_info, usbdev->devpath);
276 mdev->hw_revision = le16_to_cpu(usbdev->descriptor.bcdDevice);
277 media_device_init(mdev);
278 }
279 if (!media_devnode_is_registered(&mdev->devnode)) {
280 ret = media_device_register(mdev);
281 if (ret) {
282 dev_err(&usbdev->dev,
283 "Couldn't register media device. Error: %d\n",
284 ret);
285 return ret;
286 }
287 }
288
289 /* save media device - avoid lookups */
290 chip->media_dev = mdev;
291
292 /* Create media entities for mixer and control dev */
293 ret = media_snd_mixer_init(chip);
294 if (ret) {
295 dev_err(&usbdev->dev,
296 "Couldn't create media mixer entities. Error: %d\n",
297 ret);
298
299 /* clear saved media_dev */
300 chip->media_dev = NULL;
301
302 return ret;
303 }
304 return 0;
305}
306
307void media_snd_device_delete(struct snd_usb_audio *chip)
308{
309 struct media_device *mdev = chip->media_dev;
310
311 media_snd_mixer_delete(chip);
312
313 if (mdev) {
314 if (media_devnode_is_registered(&mdev->devnode))
315 media_device_unregister(mdev);
316 chip->media_dev = NULL;
317 }
318}
diff --git a/sound/usb/media.h b/sound/usb/media.h
deleted file mode 100644
index 1dcdcdc5f7aa..000000000000
--- a/sound/usb/media.h
+++ /dev/null
@@ -1,72 +0,0 @@
1/*
2 * media.h - Media Controller specific ALSA driver code
3 *
4 * Copyright (c) 2016 Shuah Khan <shuahkh@osg.samsung.com>
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6 *
7 * This file is released under the GPLv2.
8 */
9
10/*
11 * This file adds Media Controller support to ALSA driver
12 * to use the Media Controller API to share tuner with DVB
13 * and V4L2 drivers that control media device. Media device
14 * is created based on existing quirks framework. Using this
15 * approach, the media controller API usage can be added for
16 * a specific device.
17*/
18#ifndef __MEDIA_H
19
20#ifdef CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER
21
22#include <media/media-device.h>
23#include <media/media-entity.h>
24#include <sound/asound.h>
25
26struct media_ctl {
27 struct media_device *media_dev;
28 struct media_entity media_entity;
29 struct media_intf_devnode *intf_devnode;
30 struct media_link *intf_link;
31 struct media_pad media_pad;
32 struct media_pipeline media_pipe;
33};
34
35/*
36 * One source pad each for SNDRV_PCM_STREAM_CAPTURE and
37 * SNDRV_PCM_STREAM_PLAYBACK. One for sink pad to link
38 * to AUDIO Source
39*/
40#define MEDIA_MIXER_PAD_MAX (SNDRV_PCM_STREAM_LAST + 2)
41
42struct media_mixer_ctl {
43 struct media_device *media_dev;
44 struct media_entity media_entity;
45 struct media_intf_devnode *intf_devnode;
46 struct media_link *intf_link;
47 struct media_pad media_pad[MEDIA_MIXER_PAD_MAX];
48 struct media_pipeline media_pipe;
49};
50
51int media_snd_device_create(struct snd_usb_audio *chip,
52 struct usb_interface *iface);
53void media_snd_device_delete(struct snd_usb_audio *chip);
54int media_snd_stream_init(struct snd_usb_substream *subs, struct snd_pcm *pcm,
55 int stream);
56void media_snd_stream_delete(struct snd_usb_substream *subs);
57int media_snd_start_pipeline(struct snd_usb_substream *subs);
58void media_snd_stop_pipeline(struct snd_usb_substream *subs);
59#else
60static inline int media_snd_device_create(struct snd_usb_audio *chip,
61 struct usb_interface *iface)
62 { return 0; }
63static inline void media_snd_device_delete(struct snd_usb_audio *chip) { }
64static inline int media_snd_stream_init(struct snd_usb_substream *subs,
65 struct snd_pcm *pcm, int stream)
66 { return 0; }
67static inline void media_snd_stream_delete(struct snd_usb_substream *subs) { }
68static inline int media_snd_start_pipeline(struct snd_usb_substream *subs)
69 { return 0; }
70static inline void media_snd_stop_pipeline(struct snd_usb_substream *subs) { }
71#endif
72#endif /* __MEDIA_H */
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index f3789446ab9c..3417ef347e40 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -3,8 +3,6 @@
3 3
4#include <sound/info.h> 4#include <sound/info.h>
5 5
6struct media_mixer_ctl;
7
8struct usb_mixer_interface { 6struct usb_mixer_interface {
9 struct snd_usb_audio *chip; 7 struct snd_usb_audio *chip;
10 struct usb_host_interface *hostif; 8 struct usb_host_interface *hostif;
@@ -24,7 +22,6 @@ struct usb_mixer_interface {
24 struct urb *rc_urb; 22 struct urb *rc_urb;
25 struct usb_ctrlrequest *rc_setup_packet; 23 struct usb_ctrlrequest *rc_setup_packet;
26 u8 rc_buffer[6]; 24 u8 rc_buffer[6];
27 struct media_mixer_ctl *media_mixer_ctl;
28}; 25};
29 26
30#define MAX_CHANNELS 16 /* max logical channels */ 27#define MAX_CHANNELS 16 /* max logical channels */
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 0e4e0640c504..44d178ee9177 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -35,7 +35,6 @@
35#include "pcm.h" 35#include "pcm.h"
36#include "clock.h" 36#include "clock.h"
37#include "power.h" 37#include "power.h"
38#include "media.h"
39 38
40#define SUBSTREAM_FLAG_DATA_EP_STARTED 0 39#define SUBSTREAM_FLAG_DATA_EP_STARTED 0
41#define SUBSTREAM_FLAG_SYNC_EP_STARTED 1 40#define SUBSTREAM_FLAG_SYNC_EP_STARTED 1
@@ -718,14 +717,10 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
718 struct audioformat *fmt; 717 struct audioformat *fmt;
719 int ret; 718 int ret;
720 719
721 ret = media_snd_start_pipeline(subs);
722 if (ret)
723 return ret;
724
725 ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, 720 ret = snd_pcm_lib_alloc_vmalloc_buffer(substream,
726 params_buffer_bytes(hw_params)); 721 params_buffer_bytes(hw_params));
727 if (ret < 0) 722 if (ret < 0)
728 goto err_ret; 723 return ret;
729 724
730 subs->pcm_format = params_format(hw_params); 725 subs->pcm_format = params_format(hw_params);
731 subs->period_bytes = params_period_bytes(hw_params); 726 subs->period_bytes = params_period_bytes(hw_params);
@@ -739,27 +734,22 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
739 dev_dbg(&subs->dev->dev, 734 dev_dbg(&subs->dev->dev,
740 "cannot set format: format = %#x, rate = %d, channels = %d\n", 735 "cannot set format: format = %#x, rate = %d, channels = %d\n",
741 subs->pcm_format, subs->cur_rate, subs->channels); 736 subs->pcm_format, subs->cur_rate, subs->channels);
742 ret = -EINVAL; 737 return -EINVAL;
743 goto err_ret;
744 } 738 }
745 739
746 ret = snd_usb_lock_shutdown(subs->stream->chip); 740 ret = snd_usb_lock_shutdown(subs->stream->chip);
747 if (ret < 0) 741 if (ret < 0)
748 goto err_ret; 742 return ret;
749 ret = set_format(subs, fmt); 743 ret = set_format(subs, fmt);
750 snd_usb_unlock_shutdown(subs->stream->chip); 744 snd_usb_unlock_shutdown(subs->stream->chip);
751 if (ret < 0) 745 if (ret < 0)
752 goto err_ret; 746 return ret;
753 747
754 subs->interface = fmt->iface; 748 subs->interface = fmt->iface;
755 subs->altset_idx = fmt->altset_idx; 749 subs->altset_idx = fmt->altset_idx;
756 subs->need_setup_ep = true; 750 subs->need_setup_ep = true;
757 751
758 return 0; 752 return 0;
759
760err_ret:
761 media_snd_stop_pipeline(subs);
762 return ret;
763} 753}
764 754
765/* 755/*
@@ -771,7 +761,6 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
771{ 761{
772 struct snd_usb_substream *subs = substream->runtime->private_data; 762 struct snd_usb_substream *subs = substream->runtime->private_data;
773 763
774 media_snd_stop_pipeline(subs);
775 subs->cur_audiofmt = NULL; 764 subs->cur_audiofmt = NULL;
776 subs->cur_rate = 0; 765 subs->cur_rate = 0;
777 subs->period_bytes = 0; 766 subs->period_bytes = 0;
@@ -1232,7 +1221,6 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction)
1232 struct snd_usb_stream *as = snd_pcm_substream_chip(substream); 1221 struct snd_usb_stream *as = snd_pcm_substream_chip(substream);
1233 struct snd_pcm_runtime *runtime = substream->runtime; 1222 struct snd_pcm_runtime *runtime = substream->runtime;
1234 struct snd_usb_substream *subs = &as->substream[direction]; 1223 struct snd_usb_substream *subs = &as->substream[direction];
1235 int ret;
1236 1224
1237 subs->interface = -1; 1225 subs->interface = -1;
1238 subs->altset_idx = 0; 1226 subs->altset_idx = 0;
@@ -1246,12 +1234,7 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction)
1246 subs->dsd_dop.channel = 0; 1234 subs->dsd_dop.channel = 0;
1247 subs->dsd_dop.marker = 1; 1235 subs->dsd_dop.marker = 1;
1248 1236
1249 ret = setup_hw_info(runtime, subs); 1237 return setup_hw_info(runtime, subs);
1250 if (ret == 0)
1251 ret = media_snd_stream_init(subs, as->pcm, direction);
1252 if (ret)
1253 snd_usb_autosuspend(subs->stream->chip);
1254 return ret;
1255} 1238}
1256 1239
1257static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction) 1240static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction)
@@ -1260,7 +1243,6 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction)
1260 struct snd_usb_substream *subs = &as->substream[direction]; 1243 struct snd_usb_substream *subs = &as->substream[direction];
1261 1244
1262 stop_endpoints(subs, true); 1245 stop_endpoints(subs, true);
1263 media_snd_stop_pipeline(subs);
1264 1246
1265 if (subs->interface >= 0 && 1247 if (subs->interface >= 0 &&
1266 !snd_usb_lock_shutdown(subs->stream->chip)) { 1248 !snd_usb_lock_shutdown(subs->stream->chip)) {
diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index 9d087b19c70c..c60a776e815d 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -2886,7 +2886,6 @@ YAMAHA_DEVICE(0x7010, "UB99"),
2886 .product_name = pname, \ 2886 .product_name = pname, \
2887 .ifnum = QUIRK_ANY_INTERFACE, \ 2887 .ifnum = QUIRK_ANY_INTERFACE, \
2888 .type = QUIRK_AUDIO_ALIGN_TRANSFER, \ 2888 .type = QUIRK_AUDIO_ALIGN_TRANSFER, \
2889 .media_device = 1, \
2890 } \ 2889 } \
2891} 2890}
2892 2891
diff --git a/sound/usb/stream.c b/sound/usb/stream.c
index 51258a15f653..c4dc577ab1bd 100644
--- a/sound/usb/stream.c
+++ b/sound/usb/stream.c
@@ -36,7 +36,6 @@
36#include "format.h" 36#include "format.h"
37#include "clock.h" 37#include "clock.h"
38#include "stream.h" 38#include "stream.h"
39#include "media.h"
40 39
41/* 40/*
42 * free a substream 41 * free a substream
@@ -53,7 +52,6 @@ static void free_substream(struct snd_usb_substream *subs)
53 kfree(fp); 52 kfree(fp);
54 } 53 }
55 kfree(subs->rate_list.list); 54 kfree(subs->rate_list.list);
56 media_snd_stream_delete(subs);
57} 55}
58 56
59 57
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
index a161c7c1b126..b665d85555cb 100644
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -30,9 +30,6 @@
30 * 30 *
31 */ 31 */
32 32
33struct media_device;
34struct media_intf_devnode;
35
36struct snd_usb_audio { 33struct snd_usb_audio {
37 int index; 34 int index;
38 struct usb_device *dev; 35 struct usb_device *dev;
@@ -63,8 +60,6 @@ struct snd_usb_audio {
63 bool autoclock; /* from the 'autoclock' module param */ 60 bool autoclock; /* from the 'autoclock' module param */
64 61
65 struct usb_host_interface *ctrl_intf; /* the audio control interface */ 62 struct usb_host_interface *ctrl_intf; /* the audio control interface */
66 struct media_device *media_dev;
67 struct media_intf_devnode *ctl_intf_media_devnode;
68}; 63};
69 64
70#define usb_audio_err(chip, fmt, args...) \ 65#define usb_audio_err(chip, fmt, args...) \
@@ -115,7 +110,6 @@ struct snd_usb_audio_quirk {
115 const char *product_name; 110 const char *product_name;
116 int16_t ifnum; 111 int16_t ifnum;
117 uint16_t type; 112 uint16_t type;
118 bool media_device;
119 const void *data; 113 const void *data;
120}; 114};
121 115