diff options
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 10 | ||||
-rw-r--r-- | sound/pci/hda/hda_codec.h | 1 | ||||
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 4 | ||||
-rw-r--r-- | sound/soc/omap/mcbsp.c | 2 | ||||
-rw-r--r-- | sound/soc/omap/omap-abe-twl6040.c | 4 | ||||
-rw-r--r-- | sound/soc/omap/omap-mcbsp.c | 1 | ||||
-rw-r--r-- | sound/soc/omap/omap-mcpdm.c | 2 | ||||
-rw-r--r-- | sound/soc/omap/omap-pcm.c | 1 | ||||
-rw-r--r-- | sound/soc/omap/sdp3430.c | 1 | ||||
-rw-r--r-- | sound/usb/card.c | 4 | ||||
-rw-r--r-- | sound/usb/endpoint.c | 24 | ||||
-rw-r--r-- | sound/usb/endpoint.h | 3 | ||||
-rw-r--r-- | sound/usb/pcm.c | 64 |
13 files changed, 86 insertions, 35 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index f560051a949e..f25c24c743f9 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -1209,6 +1209,9 @@ static void snd_hda_codec_free(struct hda_codec *codec) | |||
1209 | kfree(codec); | 1209 | kfree(codec); |
1210 | } | 1210 | } |
1211 | 1211 | ||
1212 | static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, | ||
1213 | hda_nid_t fg, unsigned int power_state); | ||
1214 | |||
1212 | static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, | 1215 | static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, |
1213 | unsigned int power_state); | 1216 | unsigned int power_state); |
1214 | 1217 | ||
@@ -1317,6 +1320,10 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, | |||
1317 | AC_VERB_GET_SUBSYSTEM_ID, 0); | 1320 | AC_VERB_GET_SUBSYSTEM_ID, 0); |
1318 | } | 1321 | } |
1319 | 1322 | ||
1323 | codec->epss = snd_hda_codec_get_supported_ps(codec, | ||
1324 | codec->afg ? codec->afg : codec->mfg, | ||
1325 | AC_PWRST_EPSS); | ||
1326 | |||
1320 | /* power-up all before initialization */ | 1327 | /* power-up all before initialization */ |
1321 | hda_set_power_state(codec, | 1328 | hda_set_power_state(codec, |
1322 | codec->afg ? codec->afg : codec->mfg, | 1329 | codec->afg ? codec->afg : codec->mfg, |
@@ -3543,8 +3550,7 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, | |||
3543 | /* this delay seems necessary to avoid click noise at power-down */ | 3550 | /* this delay seems necessary to avoid click noise at power-down */ |
3544 | if (power_state == AC_PWRST_D3) { | 3551 | if (power_state == AC_PWRST_D3) { |
3545 | /* transition time less than 10ms for power down */ | 3552 | /* transition time less than 10ms for power down */ |
3546 | bool epss = snd_hda_codec_get_supported_ps(codec, fg, AC_PWRST_EPSS); | 3553 | msleep(codec->epss ? 10 : 100); |
3547 | msleep(epss ? 10 : 100); | ||
3548 | } | 3554 | } |
3549 | 3555 | ||
3550 | /* repeat power states setting at most 10 times*/ | 3556 | /* repeat power states setting at most 10 times*/ |
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 7fbc1bcaf1a9..e5a7e19a8071 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -862,6 +862,7 @@ struct hda_codec { | |||
862 | unsigned int ignore_misc_bit:1; /* ignore MISC_NO_PRESENCE bit */ | 862 | unsigned int ignore_misc_bit:1; /* ignore MISC_NO_PRESENCE bit */ |
863 | unsigned int no_jack_detect:1; /* Machine has no jack-detection */ | 863 | unsigned int no_jack_detect:1; /* Machine has no jack-detection */ |
864 | unsigned int pcm_format_first:1; /* PCM format must be set first */ | 864 | unsigned int pcm_format_first:1; /* PCM format must be set first */ |
865 | unsigned int epss:1; /* supporting EPSS? */ | ||
865 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 866 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
866 | unsigned int power_on :1; /* current (global) power-state */ | 867 | unsigned int power_on :1; /* current (global) power-state */ |
867 | int power_transition; /* power-state in transition */ | 868 | int power_transition; /* power-state in transition */ |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index ea5775a1a7db..6f806d3e56bb 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -4543,6 +4543,9 @@ static void stac92xx_line_out_detect(struct hda_codec *codec, | |||
4543 | struct auto_pin_cfg *cfg = &spec->autocfg; | 4543 | struct auto_pin_cfg *cfg = &spec->autocfg; |
4544 | int i; | 4544 | int i; |
4545 | 4545 | ||
4546 | if (cfg->speaker_outs == 0) | ||
4547 | return; | ||
4548 | |||
4546 | for (i = 0; i < cfg->line_outs; i++) { | 4549 | for (i = 0; i < cfg->line_outs; i++) { |
4547 | if (presence) | 4550 | if (presence) |
4548 | break; | 4551 | break; |
@@ -5531,6 +5534,7 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) | |||
5531 | snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e); | 5534 | snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e); |
5532 | } | 5535 | } |
5533 | 5536 | ||
5537 | codec->epss = 0; /* longer delay needed for D3 */ | ||
5534 | codec->no_trigger_sense = 1; | 5538 | codec->no_trigger_sense = 1; |
5535 | codec->spec = spec; | 5539 | codec->spec = spec; |
5536 | 5540 | ||
diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c index d33c48baaf71..f18e48847323 100644 --- a/sound/soc/omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c | |||
@@ -27,6 +27,8 @@ | |||
27 | 27 | ||
28 | #include <plat/mcbsp.h> | 28 | #include <plat/mcbsp.h> |
29 | 29 | ||
30 | #include <plat/cpu.h> | ||
31 | |||
30 | #include "mcbsp.h" | 32 | #include "mcbsp.h" |
31 | 33 | ||
32 | static void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) | 34 | static void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) |
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index 9d93793d3077..45909ca889fa 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c | |||
@@ -31,10 +31,6 @@ | |||
31 | #include <sound/soc.h> | 31 | #include <sound/soc.h> |
32 | #include <sound/jack.h> | 32 | #include <sound/jack.h> |
33 | 33 | ||
34 | #include <asm/mach-types.h> | ||
35 | #include <plat/hardware.h> | ||
36 | #include <plat/mux.h> | ||
37 | |||
38 | #include "omap-dmic.h" | 34 | #include "omap-dmic.h" |
39 | #include "omap-mcpdm.h" | 35 | #include "omap-mcpdm.h" |
40 | #include "omap-pcm.h" | 36 | #include "omap-pcm.h" |
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index acdd3ef14e08..d0ee71d6cc23 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <sound/initval.h> | 32 | #include <sound/initval.h> |
33 | #include <sound/soc.h> | 33 | #include <sound/soc.h> |
34 | 34 | ||
35 | #include <plat/cpu.h> | ||
35 | #include <plat/dma.h> | 36 | #include <plat/dma.h> |
36 | #include <plat/mcbsp.h> | 37 | #include <plat/mcbsp.h> |
37 | #include "mcbsp.h" | 38 | #include "mcbsp.h" |
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index 2c66e2498a45..ea053c3d2ab1 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c | |||
@@ -45,6 +45,8 @@ | |||
45 | #include "omap-mcpdm.h" | 45 | #include "omap-mcpdm.h" |
46 | #include "omap-pcm.h" | 46 | #include "omap-pcm.h" |
47 | 47 | ||
48 | #define OMAP44XX_MCPDM_L3_BASE 0x49032000 | ||
49 | |||
48 | struct omap_mcpdm { | 50 | struct omap_mcpdm { |
49 | struct device *dev; | 51 | struct device *dev; |
50 | unsigned long phys_base; | 52 | unsigned long phys_base; |
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index f0feb06615f8..b30994179885 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <sound/pcm_params.h> | 30 | #include <sound/pcm_params.h> |
31 | #include <sound/soc.h> | 31 | #include <sound/soc.h> |
32 | 32 | ||
33 | #include <plat/cpu.h> | ||
33 | #include <plat/dma.h> | 34 | #include <plat/dma.h> |
34 | #include "omap-pcm.h" | 35 | #include "omap-pcm.h" |
35 | 36 | ||
diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c index 0e283226e2bf..78e14198aa11 100644 --- a/sound/soc/omap/sdp3430.c +++ b/sound/soc/omap/sdp3430.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <mach/hardware.h> | 34 | #include <mach/hardware.h> |
35 | #include <mach/gpio.h> | 35 | #include <mach/gpio.h> |
36 | #include <plat/mcbsp.h> | 36 | #include <plat/mcbsp.h> |
37 | #include <linux/platform_data/gpio-omap.h> | ||
37 | 38 | ||
38 | /* Register descriptions for twl4030 codec part */ | 39 | /* Register descriptions for twl4030 codec part */ |
39 | #include <linux/mfd/twl4030-audio.h> | 40 | #include <linux/mfd/twl4030-audio.h> |
diff --git a/sound/usb/card.c b/sound/usb/card.c index d5b5c3388e28..4a469f0cb6d4 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c | |||
@@ -553,7 +553,7 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, | |||
553 | struct snd_usb_audio *chip) | 553 | struct snd_usb_audio *chip) |
554 | { | 554 | { |
555 | struct snd_card *card; | 555 | struct snd_card *card; |
556 | struct list_head *p; | 556 | struct list_head *p, *n; |
557 | 557 | ||
558 | if (chip == (void *)-1L) | 558 | if (chip == (void *)-1L) |
559 | return; | 559 | return; |
@@ -570,7 +570,7 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, | |||
570 | snd_usb_stream_disconnect(p); | 570 | snd_usb_stream_disconnect(p); |
571 | } | 571 | } |
572 | /* release the endpoint resources */ | 572 | /* release the endpoint resources */ |
573 | list_for_each(p, &chip->ep_list) { | 573 | list_for_each_safe(p, n, &chip->ep_list) { |
574 | snd_usb_endpoint_free(p); | 574 | snd_usb_endpoint_free(p); |
575 | } | 575 | } |
576 | /* release the midi resources */ | 576 | /* release the midi resources */ |
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index c41181202688..d6e2bb49c59c 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c | |||
@@ -141,7 +141,7 @@ int snd_usb_endpoint_implict_feedback_sink(struct snd_usb_endpoint *ep) | |||
141 | * | 141 | * |
142 | * For implicit feedback, next_packet_size() is unused. | 142 | * For implicit feedback, next_packet_size() is unused. |
143 | */ | 143 | */ |
144 | static int next_packet_size(struct snd_usb_endpoint *ep) | 144 | int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep) |
145 | { | 145 | { |
146 | unsigned long flags; | 146 | unsigned long flags; |
147 | int ret; | 147 | int ret; |
@@ -177,15 +177,6 @@ static void retire_inbound_urb(struct snd_usb_endpoint *ep, | |||
177 | ep->retire_data_urb(ep->data_subs, urb); | 177 | ep->retire_data_urb(ep->data_subs, urb); |
178 | } | 178 | } |
179 | 179 | ||
180 | static void prepare_outbound_urb_sizes(struct snd_usb_endpoint *ep, | ||
181 | struct snd_urb_ctx *ctx) | ||
182 | { | ||
183 | int i; | ||
184 | |||
185 | for (i = 0; i < ctx->packets; ++i) | ||
186 | ctx->packet_size[i] = next_packet_size(ep); | ||
187 | } | ||
188 | |||
189 | /* | 180 | /* |
190 | * Prepare a PLAYBACK urb for submission to the bus. | 181 | * Prepare a PLAYBACK urb for submission to the bus. |
191 | */ | 182 | */ |
@@ -370,7 +361,6 @@ static void snd_complete_urb(struct urb *urb) | |||
370 | goto exit_clear; | 361 | goto exit_clear; |
371 | } | 362 | } |
372 | 363 | ||
373 | prepare_outbound_urb_sizes(ep, ctx); | ||
374 | prepare_outbound_urb(ep, ctx); | 364 | prepare_outbound_urb(ep, ctx); |
375 | } else { | 365 | } else { |
376 | retire_inbound_urb(ep, ctx); | 366 | retire_inbound_urb(ep, ctx); |
@@ -799,7 +789,9 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, | |||
799 | /** | 789 | /** |
800 | * snd_usb_endpoint_start: start an snd_usb_endpoint | 790 | * snd_usb_endpoint_start: start an snd_usb_endpoint |
801 | * | 791 | * |
802 | * @ep: the endpoint to start | 792 | * @ep: the endpoint to start |
793 | * @can_sleep: flag indicating whether the operation is executed in | ||
794 | * non-atomic context | ||
803 | * | 795 | * |
804 | * A call to this function will increment the use count of the endpoint. | 796 | * A call to this function will increment the use count of the endpoint. |
805 | * In case it is not already running, the URBs for this endpoint will be | 797 | * In case it is not already running, the URBs for this endpoint will be |
@@ -809,7 +801,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, | |||
809 | * | 801 | * |
810 | * Returns an error if the URB submission failed, 0 in all other cases. | 802 | * Returns an error if the URB submission failed, 0 in all other cases. |
811 | */ | 803 | */ |
812 | int snd_usb_endpoint_start(struct snd_usb_endpoint *ep) | 804 | int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep) |
813 | { | 805 | { |
814 | int err; | 806 | int err; |
815 | unsigned int i; | 807 | unsigned int i; |
@@ -821,6 +813,11 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep) | |||
821 | if (++ep->use_count != 1) | 813 | if (++ep->use_count != 1) |
822 | return 0; | 814 | return 0; |
823 | 815 | ||
816 | /* just to be sure */ | ||
817 | deactivate_urbs(ep, 0, can_sleep); | ||
818 | if (can_sleep) | ||
819 | wait_clear_urbs(ep); | ||
820 | |||
824 | ep->active_mask = 0; | 821 | ep->active_mask = 0; |
825 | ep->unlink_mask = 0; | 822 | ep->unlink_mask = 0; |
826 | ep->phase = 0; | 823 | ep->phase = 0; |
@@ -850,7 +847,6 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *ep) | |||
850 | goto __error; | 847 | goto __error; |
851 | 848 | ||
852 | if (usb_pipeout(ep->pipe)) { | 849 | if (usb_pipeout(ep->pipe)) { |
853 | prepare_outbound_urb_sizes(ep, urb->context); | ||
854 | prepare_outbound_urb(ep, urb->context); | 850 | prepare_outbound_urb(ep, urb->context); |
855 | } else { | 851 | } else { |
856 | prepare_inbound_urb(ep, urb->context); | 852 | prepare_inbound_urb(ep, urb->context); |
diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h index ee2723fb174f..cbbbdf226d66 100644 --- a/sound/usb/endpoint.h +++ b/sound/usb/endpoint.h | |||
@@ -13,7 +13,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep, | |||
13 | struct audioformat *fmt, | 13 | struct audioformat *fmt, |
14 | struct snd_usb_endpoint *sync_ep); | 14 | struct snd_usb_endpoint *sync_ep); |
15 | 15 | ||
16 | int snd_usb_endpoint_start(struct snd_usb_endpoint *ep); | 16 | int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep); |
17 | void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, | 17 | void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, |
18 | int force, int can_sleep, int wait); | 18 | int force, int can_sleep, int wait); |
19 | int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); | 19 | int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); |
@@ -21,6 +21,7 @@ int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep); | |||
21 | void snd_usb_endpoint_free(struct list_head *head); | 21 | void snd_usb_endpoint_free(struct list_head *head); |
22 | 22 | ||
23 | int snd_usb_endpoint_implict_feedback_sink(struct snd_usb_endpoint *ep); | 23 | int snd_usb_endpoint_implict_feedback_sink(struct snd_usb_endpoint *ep); |
24 | int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep); | ||
24 | 25 | ||
25 | void snd_usb_handle_sync_urb(struct snd_usb_endpoint *ep, | 26 | void snd_usb_handle_sync_urb(struct snd_usb_endpoint *ep, |
26 | struct snd_usb_endpoint *sender, | 27 | struct snd_usb_endpoint *sender, |
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 62ec808ed792..fd5e982fc98c 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c | |||
@@ -212,7 +212,7 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface, | |||
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | static int start_endpoints(struct snd_usb_substream *subs) | 215 | static int start_endpoints(struct snd_usb_substream *subs, int can_sleep) |
216 | { | 216 | { |
217 | int err; | 217 | int err; |
218 | 218 | ||
@@ -225,7 +225,7 @@ static int start_endpoints(struct snd_usb_substream *subs) | |||
225 | snd_printdd(KERN_DEBUG "Starting data EP @%p\n", ep); | 225 | snd_printdd(KERN_DEBUG "Starting data EP @%p\n", ep); |
226 | 226 | ||
227 | ep->data_subs = subs; | 227 | ep->data_subs = subs; |
228 | err = snd_usb_endpoint_start(ep); | 228 | err = snd_usb_endpoint_start(ep, can_sleep); |
229 | if (err < 0) { | 229 | if (err < 0) { |
230 | clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags); | 230 | clear_bit(SUBSTREAM_FLAG_DATA_EP_STARTED, &subs->flags); |
231 | return err; | 231 | return err; |
@@ -236,10 +236,25 @@ static int start_endpoints(struct snd_usb_substream *subs) | |||
236 | !test_and_set_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags)) { | 236 | !test_and_set_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags)) { |
237 | struct snd_usb_endpoint *ep = subs->sync_endpoint; | 237 | struct snd_usb_endpoint *ep = subs->sync_endpoint; |
238 | 238 | ||
239 | if (subs->data_endpoint->iface != subs->sync_endpoint->iface || | ||
240 | subs->data_endpoint->alt_idx != subs->sync_endpoint->alt_idx) { | ||
241 | err = usb_set_interface(subs->dev, | ||
242 | subs->sync_endpoint->iface, | ||
243 | subs->sync_endpoint->alt_idx); | ||
244 | if (err < 0) { | ||
245 | snd_printk(KERN_ERR | ||
246 | "%d:%d:%d: cannot set interface (%d)\n", | ||
247 | subs->dev->devnum, | ||
248 | subs->sync_endpoint->iface, | ||
249 | subs->sync_endpoint->alt_idx, err); | ||
250 | return -EIO; | ||
251 | } | ||
252 | } | ||
253 | |||
239 | snd_printdd(KERN_DEBUG "Starting sync EP @%p\n", ep); | 254 | snd_printdd(KERN_DEBUG "Starting sync EP @%p\n", ep); |
240 | 255 | ||
241 | ep->sync_slave = subs->data_endpoint; | 256 | ep->sync_slave = subs->data_endpoint; |
242 | err = snd_usb_endpoint_start(ep); | 257 | err = snd_usb_endpoint_start(ep, can_sleep); |
243 | if (err < 0) { | 258 | if (err < 0) { |
244 | clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags); | 259 | clear_bit(SUBSTREAM_FLAG_SYNC_EP_STARTED, &subs->flags); |
245 | return err; | 260 | return err; |
@@ -544,13 +559,10 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) | |||
544 | subs->last_frame_number = 0; | 559 | subs->last_frame_number = 0; |
545 | runtime->delay = 0; | 560 | runtime->delay = 0; |
546 | 561 | ||
547 | /* clear the pending deactivation on the target EPs */ | ||
548 | deactivate_endpoints(subs); | ||
549 | |||
550 | /* for playback, submit the URBs now; otherwise, the first hwptr_done | 562 | /* for playback, submit the URBs now; otherwise, the first hwptr_done |
551 | * updates for all URBs would happen at the same time when starting */ | 563 | * updates for all URBs would happen at the same time when starting */ |
552 | if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) | 564 | if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) |
553 | return start_endpoints(subs); | 565 | return start_endpoints(subs, 1); |
554 | 566 | ||
555 | return 0; | 567 | return 0; |
556 | } | 568 | } |
@@ -1032,6 +1044,7 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, | |||
1032 | struct urb *urb) | 1044 | struct urb *urb) |
1033 | { | 1045 | { |
1034 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; | 1046 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; |
1047 | struct snd_usb_endpoint *ep = subs->data_endpoint; | ||
1035 | struct snd_urb_ctx *ctx = urb->context; | 1048 | struct snd_urb_ctx *ctx = urb->context; |
1036 | unsigned int counts, frames, bytes; | 1049 | unsigned int counts, frames, bytes; |
1037 | int i, stride, period_elapsed = 0; | 1050 | int i, stride, period_elapsed = 0; |
@@ -1043,7 +1056,11 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, | |||
1043 | urb->number_of_packets = 0; | 1056 | urb->number_of_packets = 0; |
1044 | spin_lock_irqsave(&subs->lock, flags); | 1057 | spin_lock_irqsave(&subs->lock, flags); |
1045 | for (i = 0; i < ctx->packets; i++) { | 1058 | for (i = 0; i < ctx->packets; i++) { |
1046 | counts = ctx->packet_size[i]; | 1059 | if (ctx->packet_size[i]) |
1060 | counts = ctx->packet_size[i]; | ||
1061 | else | ||
1062 | counts = snd_usb_endpoint_next_packet_size(ep); | ||
1063 | |||
1047 | /* set up descriptor */ | 1064 | /* set up descriptor */ |
1048 | urb->iso_frame_desc[i].offset = frames * stride; | 1065 | urb->iso_frame_desc[i].offset = frames * stride; |
1049 | urb->iso_frame_desc[i].length = counts * stride; | 1066 | urb->iso_frame_desc[i].length = counts * stride; |
@@ -1094,7 +1111,16 @@ static void prepare_playback_urb(struct snd_usb_substream *subs, | |||
1094 | subs->hwptr_done += bytes; | 1111 | subs->hwptr_done += bytes; |
1095 | if (subs->hwptr_done >= runtime->buffer_size * stride) | 1112 | if (subs->hwptr_done >= runtime->buffer_size * stride) |
1096 | subs->hwptr_done -= runtime->buffer_size * stride; | 1113 | subs->hwptr_done -= runtime->buffer_size * stride; |
1114 | |||
1115 | /* update delay with exact number of samples queued */ | ||
1116 | runtime->delay = subs->last_delay; | ||
1097 | runtime->delay += frames; | 1117 | runtime->delay += frames; |
1118 | subs->last_delay = runtime->delay; | ||
1119 | |||
1120 | /* realign last_frame_number */ | ||
1121 | subs->last_frame_number = usb_get_current_frame_number(subs->dev); | ||
1122 | subs->last_frame_number &= 0xFF; /* keep 8 LSBs */ | ||
1123 | |||
1098 | spin_unlock_irqrestore(&subs->lock, flags); | 1124 | spin_unlock_irqrestore(&subs->lock, flags); |
1099 | urb->transfer_buffer_length = bytes; | 1125 | urb->transfer_buffer_length = bytes; |
1100 | if (period_elapsed) | 1126 | if (period_elapsed) |
@@ -1112,12 +1138,26 @@ static void retire_playback_urb(struct snd_usb_substream *subs, | |||
1112 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; | 1138 | struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; |
1113 | int stride = runtime->frame_bits >> 3; | 1139 | int stride = runtime->frame_bits >> 3; |
1114 | int processed = urb->transfer_buffer_length / stride; | 1140 | int processed = urb->transfer_buffer_length / stride; |
1141 | int est_delay; | ||
1115 | 1142 | ||
1116 | spin_lock_irqsave(&subs->lock, flags); | 1143 | spin_lock_irqsave(&subs->lock, flags); |
1117 | if (processed > runtime->delay) | 1144 | est_delay = snd_usb_pcm_delay(subs, runtime->rate); |
1118 | runtime->delay = 0; | 1145 | /* update delay with exact number of samples played */ |
1146 | if (processed > subs->last_delay) | ||
1147 | subs->last_delay = 0; | ||
1119 | else | 1148 | else |
1120 | runtime->delay -= processed; | 1149 | subs->last_delay -= processed; |
1150 | runtime->delay = subs->last_delay; | ||
1151 | |||
1152 | /* | ||
1153 | * Report when delay estimate is off by more than 2ms. | ||
1154 | * The error should be lower than 2ms since the estimate relies | ||
1155 | * on two reads of a counter updated every ms. | ||
1156 | */ | ||
1157 | if (abs(est_delay - subs->last_delay) * 1000 > runtime->rate * 2) | ||
1158 | snd_printk(KERN_DEBUG "delay: estimated %d, actual %d\n", | ||
1159 | est_delay, subs->last_delay); | ||
1160 | |||
1121 | spin_unlock_irqrestore(&subs->lock, flags); | 1161 | spin_unlock_irqrestore(&subs->lock, flags); |
1122 | } | 1162 | } |
1123 | 1163 | ||
@@ -1175,7 +1215,7 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream | |||
1175 | 1215 | ||
1176 | switch (cmd) { | 1216 | switch (cmd) { |
1177 | case SNDRV_PCM_TRIGGER_START: | 1217 | case SNDRV_PCM_TRIGGER_START: |
1178 | err = start_endpoints(subs); | 1218 | err = start_endpoints(subs, 0); |
1179 | if (err < 0) | 1219 | if (err < 0) |
1180 | return err; | 1220 | return err; |
1181 | 1221 | ||