Commit 65ee2ba3105f6ca3b8814d993682d4f21a1f0d8d
Exists in
master
and in
20 other branches
Merge branch 'devel' of git://git.alsa-project.org/alsa-kernel into topic/misc
Showing 3 changed files Side-by-side Diff
include/sound/pcm.h
... | ... | @@ -317,7 +317,7 @@ |
317 | 317 | struct snd_pcm_mmap_control *control; |
318 | 318 | |
319 | 319 | /* -- locking / scheduling -- */ |
320 | - unsigned int twake: 1; /* do transfer (!poll) wakeup */ | |
320 | + snd_pcm_uframes_t twake; /* do transfer (!poll) wakeup if non-zero */ | |
321 | 321 | wait_queue_head_t sleep; /* poll sleep */ |
322 | 322 | wait_queue_head_t tsleep; /* transfer sleep */ |
323 | 323 | struct fasync_struct *fasync; |
sound/core/pcm_lib.c
... | ... | @@ -287,8 +287,11 @@ |
287 | 287 | return -EPIPE; |
288 | 288 | } |
289 | 289 | } |
290 | - if (avail >= runtime->control->avail_min) | |
291 | - wake_up(runtime->twake ? &runtime->tsleep : &runtime->sleep); | |
290 | + if (runtime->twake) { | |
291 | + if (avail >= runtime->twake) | |
292 | + wake_up(&runtime->tsleep); | |
293 | + } else if (avail >= runtime->control->avail_min) | |
294 | + wake_up(&runtime->sleep); | |
292 | 295 | return 0; |
293 | 296 | } |
294 | 297 | |
... | ... | @@ -1707,7 +1710,7 @@ |
1707 | 1710 | * The available space is stored on availp. When err = 0 and avail = 0 |
1708 | 1711 | * on the capture stream, it indicates the stream is in DRAINING state. |
1709 | 1712 | */ |
1710 | -static int wait_for_avail_min(struct snd_pcm_substream *substream, | |
1713 | +static int wait_for_avail(struct snd_pcm_substream *substream, | |
1711 | 1714 | snd_pcm_uframes_t *availp) |
1712 | 1715 | { |
1713 | 1716 | struct snd_pcm_runtime *runtime = substream->runtime; |
... | ... | @@ -1757,7 +1760,7 @@ |
1757 | 1760 | avail = snd_pcm_playback_avail(runtime); |
1758 | 1761 | else |
1759 | 1762 | avail = snd_pcm_capture_avail(runtime); |
1760 | - if (avail >= runtime->control->avail_min) | |
1763 | + if (avail >= runtime->twake) | |
1761 | 1764 | break; |
1762 | 1765 | } |
1763 | 1766 | _endloop: |
... | ... | @@ -1820,7 +1823,7 @@ |
1820 | 1823 | goto _end_unlock; |
1821 | 1824 | } |
1822 | 1825 | |
1823 | - runtime->twake = 1; | |
1826 | + runtime->twake = runtime->control->avail_min ? : 1; | |
1824 | 1827 | while (size > 0) { |
1825 | 1828 | snd_pcm_uframes_t frames, appl_ptr, appl_ofs; |
1826 | 1829 | snd_pcm_uframes_t avail; |
... | ... | @@ -1833,7 +1836,9 @@ |
1833 | 1836 | err = -EAGAIN; |
1834 | 1837 | goto _end_unlock; |
1835 | 1838 | } |
1836 | - err = wait_for_avail_min(substream, &avail); | |
1839 | + runtime->twake = min_t(snd_pcm_uframes_t, size, | |
1840 | + runtime->control->avail_min ? : 1); | |
1841 | + err = wait_for_avail(substream, &avail); | |
1837 | 1842 | if (err < 0) |
1838 | 1843 | goto _end_unlock; |
1839 | 1844 | } |
... | ... | @@ -2042,7 +2047,7 @@ |
2042 | 2047 | goto _end_unlock; |
2043 | 2048 | } |
2044 | 2049 | |
2045 | - runtime->twake = 1; | |
2050 | + runtime->twake = runtime->control->avail_min ? : 1; | |
2046 | 2051 | while (size > 0) { |
2047 | 2052 | snd_pcm_uframes_t frames, appl_ptr, appl_ofs; |
2048 | 2053 | snd_pcm_uframes_t avail; |
... | ... | @@ -2060,7 +2065,9 @@ |
2060 | 2065 | err = -EAGAIN; |
2061 | 2066 | goto _end_unlock; |
2062 | 2067 | } |
2063 | - err = wait_for_avail_min(substream, &avail); | |
2068 | + runtime->twake = min_t(snd_pcm_uframes_t, size, | |
2069 | + runtime->control->avail_min ? : 1); | |
2070 | + err = wait_for_avail(substream, &avail); | |
2064 | 2071 | if (err < 0) |
2065 | 2072 | goto _end_unlock; |
2066 | 2073 | if (!avail) |
sound/pci/sis7019.c
... | ... | @@ -264,11 +264,13 @@ |
264 | 264 | * if using small periods. |
265 | 265 | * |
266 | 266 | * If we're less than 9 samples behind, we're on target. |
267 | + * Otherwise, shorten the next vperiod by the amount we've | |
268 | + * been delayed. | |
267 | 269 | */ |
268 | 270 | if (sync > -9) |
269 | 271 | voice->vperiod = voice->sync_period_size + 1; |
270 | 272 | else |
271 | - voice->vperiod = voice->sync_period_size - 4; | |
273 | + voice->vperiod = voice->sync_period_size + sync + 10; | |
272 | 274 | |
273 | 275 | if (voice->vperiod < voice->buffer_size) { |
274 | 276 | sis_update_sso(voice, voice->vperiod); |
... | ... | @@ -736,7 +738,7 @@ |
736 | 738 | period_size = buffer_size; |
737 | 739 | |
738 | 740 | /* Initially, we want to interrupt just a bit behind the end of |
739 | - * the period we're clocking out. 10 samples seems to give a good | |
741 | + * the period we're clocking out. 12 samples seems to give a good | |
740 | 742 | * delay. |
741 | 743 | * |
742 | 744 | * We want to spread our interrupts throughout the virtual period, |
... | ... | @@ -747,7 +749,7 @@ |
747 | 749 | * |
748 | 750 | * This is all moot if we don't need to use virtual periods. |
749 | 751 | */ |
750 | - vperiod = runtime->period_size + 10; | |
752 | + vperiod = runtime->period_size + 12; | |
751 | 753 | if (vperiod > period_size) { |
752 | 754 | u16 tail = vperiod % period_size; |
753 | 755 | u16 quarter_period = period_size / 4; |
... | ... | @@ -776,7 +778,7 @@ |
776 | 778 | */ |
777 | 779 | timing->flags |= VOICE_SYNC_TIMING; |
778 | 780 | timing->sync_base = voice->ctrl_base; |
779 | - timing->sync_cso = runtime->period_size - 1; | |
781 | + timing->sync_cso = runtime->period_size; | |
780 | 782 | timing->sync_period_size = runtime->period_size; |
781 | 783 | timing->sync_buffer_size = runtime->buffer_size; |
782 | 784 | timing->period_size = period_size; |
... | ... | @@ -1047,7 +1049,7 @@ |
1047 | 1049 | /* Reset the chip, and disable all interrputs. |
1048 | 1050 | */ |
1049 | 1051 | outl(SIS_GCR_SOFTWARE_RESET, sis->ioport + SIS_GCR); |
1050 | - udelay(10); | |
1052 | + udelay(25); | |
1051 | 1053 | outl(0, sis->ioport + SIS_GCR); |
1052 | 1054 | outl(0, sis->ioport + SIS_GIER); |
1053 | 1055 | |
... | ... | @@ -1083,7 +1085,7 @@ |
1083 | 1085 | /* Reset the audio controller |
1084 | 1086 | */ |
1085 | 1087 | outl(SIS_GCR_SOFTWARE_RESET, io + SIS_GCR); |
1086 | - udelay(10); | |
1088 | + udelay(25); | |
1087 | 1089 | outl(0, io + SIS_GCR); |
1088 | 1090 | |
1089 | 1091 | /* Get the AC-link semaphore, and reset the codecs |
... | ... | @@ -1096,7 +1098,7 @@ |
1096 | 1098 | return -EIO; |
1097 | 1099 | |
1098 | 1100 | outl(SIS_AC97_CMD_CODEC_COLD_RESET, io + SIS_AC97_CMD); |
1099 | - udelay(10); | |
1101 | + udelay(250); | |
1100 | 1102 | |
1101 | 1103 | count = 0xffff; |
1102 | 1104 | while ((inw(io + SIS_AC97_STATUS) & SIS_AC97_STATUS_BUSY) && --count) |