aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/pcm_lib.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2010-01-07ALSA: pcm_lib.c - convert second xrun_debug() parameter to use definesJaroslav Kysela1-10/+17
To increase code readability, convert send xrun_debug() argument to use defines. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2009-12-22ALSA: refine rate selection in snd_interval_ratnum()Krzysztof Helt1-3/+17
Refine the rate selection by choosing the rate closer to the requested one in case of selecting single frequency. Previously, the higher rate was always selected. Also, fix problem with the best_diff unsigned int value wrapping (turning negative). Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-12-21ALSA: fix incorrect rounding direction in snd_interval_ratnum()Krzysztof Helt1-2/+2
The direction of rounding is incorrect in the snd_interval_ratnum() It was detected with following parameters (sb8 driver playing 8kHz stereo file): - num is always 1000000 - requested frequency rate is from 7999 to 7999 (single frequency) The first loop calculates div_down(num, freq->min) which is 125. Thus, a frequency range's minimum value is 1000000 / 125 = 8000 Hz. The second loop calculates div_up(num, freq->max) which is 126 The frequency range's maximum value is 1000000 / 126 = 7936 Hz. The range maximum is lower than the range minimum so the function fails due to empty result range. Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-09-10Merge branch 'topic/pcm-drain-nonblock' into for-linusTakashi Iwai1-4/+8
* topic/pcm-drain-nonblock: ALSA: pcm - Increase protocol version ALSA: pcm - Fix drain behavior in non-blocking mode
2009-08-25Merge branch 'fix/misc' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6Linus Torvalds1-31/+8
* 'fix/misc' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6: sound: pcm_lib: fix unsorted list constraint handling sound: vx222: fix input level control range check ALSA: ali5451: fix timeout handling in snd_ali_{codecs,timer}_ready()
2009-08-25sound: pcm_lib: fix unsorted list constraint handlingClemens Ladisch1-31/+8
snd_interval_list() expected a sorted list but did not document this, so there are drivers that give it an unsorted list. To fix this, change the algorithm to work with any list. This fixes the "Slave PCM not usable" error with USB devices that have multiple alternate settings with sample rates in decreasing order, such as the Philips Askey VC010 WebCam. http://bugzilla.kernel.org/show_bug.cgi?id=14028 Reported-and-tested-by: Andrzej <adkadk@gmail.com> Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Cc: <stable@kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-08-20ALSA: pcm - Fix drain behavior in non-blocking modeTakashi Iwai1-4/+8
The current PCM core has the following problems regarding PCM draining in non-blocking mode: - the current f_flags isn't checked in snd_pcm_drain(), thus changing the mode dynamically via snd_pcm_nonblock() after open doesn't work. - calling drain in non-blocking mode just return -EAGAIN error, but doesn't provide any way to sync with draining. This patch fixes these issues. - check file->f_flags in snd_pcm_drain() properly - when O_NONBLOCK is set, PCM core sets the stream(s) to DRAIN state but quits ioctl immediately without waiting the whole drain; the caller can sync the drain manually via poll() Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-07-23ALSA: pcm - Fix hwptr buffer-size overlap bugTakashi Iwai1-1/+1
The fix 79452f0a28aa5a40522c487b42a5fc423647ad98 introduced another bug due to the missing offset for the overlapped hwptr. When the hwptr goes back to zero, the delta value has to be corrected with the buffer size. Otherwise this causes looping sounds. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-07-23ALSA: pcm - Fix warnings in debug loggingsTakashi Iwai1-12/+12
Add proper cast. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-07-23ALSA: pcm - Add logging of hwptr updates and interrupt updatesTakashi Iwai1-0/+25
Added the logging functionality to xrun_debug to record the hwptr updates via snd_pcm_update_hw_ptr() and snd_pcm_update_hwptr_interrupt(), corresponding to 16 and 8, respectively. For example, # echo 9 > /proc/asound/card0/pcm0p/xrun_debug will record the position and other parameters at each period interrupt together with the normal XRUN debugging. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-07-22ALSA: pcm - Fix regressions with VMwareTakashi Iwai1-1/+10
VMware tends to report PCM positions and period updates at utterly wrong timing. This screws up the recent PCM core code that tries to correct the position based on the irq timing. Now, when a backward irq position is detected, skip the update instead of rebasing. (This is almost the old behavior before 2.6.30.) Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-06-10Merge branch 'topic/pcm-jiffies-check' into for-linusTakashi Iwai1-19/+70
* topic/pcm-jiffies-check: ALSA: pcm - A helper function to compose PCM stream name for debug prints ALSA: pcm - Fix update of runtime->hw_ptr_interrupt ALSA: pcm - Fix a typo in hw_ptr update check ALSA: PCM midlevel: lower jiffies check margin using runtime->delay value ALSA: PCM midlevel: Do not update hw_ptr_jiffies when hw_ptr is not changed ALSA: PCM midlevel: introduce mask for xrun_debug() macro ALSA: PCM midlevel: improve fifo_size handling
2009-06-08ALSA: pcm - A helper function to compose PCM stream name for debug printsTakashi Iwai1-6/+17
Use a common helper function for the PCM stream name displayed in XRUN and buffer-pointer debug prints. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-06-07ALSA: pcm - Fix update of runtime->hw_ptr_interruptTakashi Iwai1-1/+2
The commit 13f040f9e55d41e92e485389123654971e03b819 made another regression, the missing update of runtime->hw_ptr_interrupt. Since this field is only checked in snd_pcmupdate__hw_ptr_interrupt(), not in snd_pcm_update_hw_ptr(), it must be updated before the hw_ptr change check. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-06-06ALSA: pcm - Fix a typo in hw_ptr update checkJaroslav Kysela1-1/+1
Fix a typo in the commit 13f040f9e55d41e92e485389123654971e03b819 ALSA: PCM midlevel: Do not update hw_ptr_jiffies when hw_ptr is not changed which causes obvious problems with PA. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-06-05ALSA: Clean up 64bit division functionsTakashi Iwai1-1/+2
Replace the house-made div64_32() with the standard div_u64*() functions. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-05-29ALSA: PCM midlevel: lower jiffies check margin using runtime->delay valueJaroslav Kysela1-2/+10
When hardware has large FIFO, it is necessary to lower jiffies margin by count of queued samples. Signed-off-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-05-29ALSA: PCM midlevel: Do not update hw_ptr_jiffies when hw_ptr is not changedJaroslav Kysela1-2/+14
Some hardware might have bigger FIFOs and DMA pointer value will be updated in large chunks. Do not update hw_ptr_jiffies and position timestamp when hw_ptr value was not changed. Signed-off-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-05-29ALSA: PCM midlevel: introduce mask for xrun_debug() macroJaroslav Kysela1-9/+9
For debugging purposes, it is better to separate actions. Bit-values: 1: show bad PCM ring buffer pointer 2: show also stack (to debug kernel latency issues) 4: check pointer against system jiffies Example: 5: show bad PCM ring buffer pointer and do jiffies check Signed-off-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-05-29ALSA: PCM midlevel: improve fifo_size handlingJaroslav Kysela1-0/+19
Move the fifo_size assignment to hw->ioctl callback to allow lowlevel drivers overwrite the default behaviour. fifo_size is in frames not bytes as specified in asound.h and alsa-lib's documentation, but most hardware have fixed byte based FIFOs. Introduce internal SNDRV_PCM_INFO_FIFO_IN_FRAMES. Signed-off-by: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-05-27ALSA: Enable PCM hw_ptr_jiffies check only in xrun_debug modeTakashi Iwai1-1/+8
The PCM hw_ptr jiffies check results sometimes in problems when a hardware doesn't give smooth hw_ptr updates. So far, au88x0 and some other drivers appear not working due to this strict check. However, this check is a nice debug tool, and the capability should be still kept. Hence, we disable this check now as default unless the user enables it by setting the xrun_debug mode to the specific stream via a proc file. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-05-27ALSA: Fix invalid jiffies check after pauseTakashi Iwai1-1/+0
The hw_ptr_jiffies has to be reset properly to avoid the invalid check of jiffies delta in snd_pcm_update_hw_ptr*() functions. Especailly this patch fixes the bogus jiffies check after the puase and resume. This patch is a modified version of the original patch by Jaroslav. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-04-28ALSA: pcm core - Avoid jiffies check for devices with BATCH flagTakashi Iwai1-0/+7
The hardware devices with SNDRV_PCM_INFO_BATCH flag can't give the precise current position. And such hardwares have often big FIFO in addition to the ring buffer, and it screws up the jiffies check in pcm_lib.c. This patch adds a simple check of info flag so that the driver skips the jiffies check in snd_pcm_period_elapsed() when BATCH flag is set. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-04-10[ALSA] pcm-midlevel: Add more strict buffer position checks based on jiffiesJaroslav Kysela1-8/+39
Some drivers like Intel8x0 or Intel HDA are broken for some hardware variants. This patch adds more strict buffer position checks based on jiffies when internal hw_ptr is updated. Enable xrun_debug to see mangling of wrong positions. As a side effect, the hw_ptr interrupt update routine might do slightly better job when many interrupts are lost. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2009-03-20ALSA: pcm - Safer boundary checksTakashi Iwai1-4/+5
Make the boundary checks a bit safer. These caese are rare or theoretically won't happen, but nothing bad to keep the checks safer... Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-03-19ALSA: pcm - Fix delta calculation at boundary overlapTakashi Iwai1-2/+7
When the hw_ptr_interrupt reaches the boundary, it must check whether the hw_base was already lapped and corret the delta value appropriately. Also, rebasing the hw_ptr needs a correction because buffer_size isn't always aligned to period_size. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-03-19ALSA: pcm - Reset invalid position even without debug optionTakashi Iwai1-3/+7
Always reset the invalind hw_ptr position returned by the pointer callback. The behavior should be consitent independently from the debug option. Also, add the printk_ratelimit() check to avoid flooding debug prints. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-03-19ALSA: pcm - avoid unnecessary inlineTakashi Iwai1-5/+6
Remove unnecessary explicit inlininig of internal functions. Let compiler optimize. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-03-19ALSA: pcm - Fix a typo in error messagesTakashi Iwai1-1/+1
Fix a typo in error messages; forgotten after a copy&paste error. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-03-09ALSA: Rewrite hw_ptr updatersTakashi Iwai1-45/+83
Clean up and improve snd_pcm_update_hw_ptr*() functions. snd_pcm_update_hw_ptr() tries to detect the unexpected hwptr jumps more strictly to avoid the position mess-up, which often results in the bad quality I/O with pulseaudio. The hw-ptr skip error messages are printed when xrun proc is set to non-zero. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2008-10-16ALSA: kernel docs: fix sound/core/ kernel-docRandy Dunlap1-24/+24
Add kernel-doc function short descriptions to sound/core functions that are missing this short description. Mostly this involves moving some of the function description onto the @funcname line. Also correct a few variable names and fix other kernel-doc notation. Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2008-08-13ALSA: Kill snd_assert() in sound/core/*Takashi Iwai1-41/+61
Kill snd_assert() in sound/core/*, either removed or replaced with if () with snd_BUG_ON(). Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-01-31[ALSA] PCM interface - rename SNDRV_PCM_TSTAMP_MMAP to SNDRV_PCM_TSTAMP_ENABLEJaroslav Kysela1-2/+2
Change semantics for SNDRV_PCM_TSTAMP_MMAP. Doing timestamping only in the interrupt handler might cause that hw_ptr is not related to actual timestamp. With this change, grab timestamp at every hw_ptr update to have always valid timestamp + ring buffer position pair. With this change, SNDRV_PCM_TSTAMP_MMAP was renamed to SNDRV_PCM_TSTAMP_ENABLE. It's no regression (I think). Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-01-31[ALSA] Remove sound/driver.hTakashi Iwai1-1/+0
This header file exists only for some hacks to adapt alsa-driver tree. It's useless for building in the kernel. Let's move a few lines in it to sound/core.h and remove it. With this patch, sound/driver.h isn't removed but has just a single compile warning to include it. This should be really killed in future. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-01-31[ALSA] Remove PCM sleep_min and tickTakashi Iwai1-110/+3
The 'tick' in PCM is set (again) via sw_params. And, nobody uses this feature at all except for a command line option of aplay. (This is literally 'nobody', as I checked alsa-lib API calls in all programs in major distros.) Above all, if we need finer wake-ups for the position update, it's basically an issue that the driver should solve, not tuned by each application. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-01-31[ALSA] PCM - clean up snd_pcm_lib_read/writeTakashi Iwai1-140/+76
Introduce a common helper function for snd_pcm_lib_read and snd_pcm_lib_write for cleaning up the code. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-01-31[ALSA] Remove PCM xfer_align sw paramsTakashi Iwai1-14/+4
The xfer_align sw_params parameter has never been used in a sane manner, and no one understands what this does exactly. The current implementation looks also buggy because it allows write of shorter size than xfer_align. So, if you do partial writes, the write isn't actually aligned at all. Removing this parameter will make some pcm_lib_* code more readable (and less buggy). Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-01-31[ALSA] Fix PCM write blockingTakashi Iwai1-2/+5
The snd_pcm_lib_write1() may block in some weird condition: - the stream isn't started - avail_min is big (e.g. period size) - partial write up to buffer_size - avail_min The patch fixes this invalid blocking problem. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-01-31[ALSA] pcm_lib: fix sparse warning about different signednessMarcin Ślusarz1-1/+1
pcm_lib: fix sparse warning about different signedness Signed-off-by: Marcin Ślusarz <marcin.slusarz@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-01-31[ALSA] pcm_lib: fix sparse warning about shadowing 'n' symbolMarcin Ślusarz1-6/+10
pcm_lib: fix sparse warning about shadowing 'n' symbol Signed-off-by: Marcin Ślusarz <marcin.slusarz@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-01-31[ALSA] Use posix clock monotonic for PCM and timer timestampsJaroslav Kysela1-1/+1
We need an accurate and continuous (monotonic) time sources to do accurate synchronization among more timing sources. This patch allows to enable monotonic timestamps for ALSA PCM devices and enables monotonic timestamps for ALSA timer devices. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-01-31[ALSA] Fix PCM MMAP time-stamp modeTakashi Iwai1-2/+2
When MMAP time-stamp mode is given, it's supposed to update the time-stamp only at period boundary. However, it currently updates at each status call so this is just useless. The patch fixes this misbehavior. Also it fixes the wrong check of tstamp_mode (don't use bit-and for enum). Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2007-10-16[ALSA] Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.czJaroslav Kysela1-1/+1
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2007-02-09[ALSA] Fix possible invalid memory access in PCM coreTakashi Iwai1-0/+5
snd_internval_list() may access invalid memory in the case count = 0 is given. It shouldn't be passed, but it'd better to make the code a bit more robust. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2006-12-20[ALSA] pcm core: fix silence_start calculationsClemens Ladisch1-5/+3
The case where silence_size < boundary was broken because different parts of the snd_pcm_playback_silence() function disagreed about whether silence_start should point to the start or to the end of the buffer part to be silenced. This patch changes the code to always use to the start, which also simplifies several calculations. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2006-06-22[ALSA] Add O_APPEND flag support to PCMTakashi Iwai1-4/+4
Added O_APPEND flag support to PCM to enable shared substreams among multiple processes. This mechanism is used by dmix and dsnoop plugins. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-06-22[ALSA] Clean up ugly hacks in pcm_lib.cTakashi Iwai1-44/+26
Clean up ugly hacks for sync with alsa-lib code in pcm_lib.c. Also, optimize snd_pcm_hw_params_choose() with a loop. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-06-22[ALSA] Move OSS-specific hw_params helper to snd-pcm-oss moduleTakashi Iwai1-595/+54
Move EXPORT_SYMBOL()s to places adjacent to functions/variables. Also move OSS-specific hw_params helper functions to pcm_oss.c. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-04-27[ALSA] PCM core - introduce CONFIG_SND_PCM_XRUN_DEBUGJaroslav Kysela1-3/+3
This patch makes the XRUN (overrun/underrun) notification code optional. Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2006-03-31[ALSA] Clean up PCM codes (take 2)Takashi Iwai1-49/+0
- Clean up initialization and destruction of substream instance Now snd_pcm_open_substream() alone does most initialization jobs. Add pcm_release callback for cleaning up at snd_pcm_release_substream() - Tidy up PCM oss code Signed-off-by: Takashi Iwai <tiwai@suse.de>