aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/oss/pcm_oss.c
Commit message (Collapse)AuthorAgeFilesLines
* ALSA: Fix card refcount unbalanceTakashi Iwai2012-11-171-0/+1
| | | | | | | | | | | | | | | | | commit 8bb4d9ce08b0a92ca174e41d92c180328f86173f upstream. There are uncovered cases whether the card refcount introduced by the commit a0830dbd isn't properly increased or decreased: - OSS PCM and mixer success paths - When lookup function gets NULL This patch fixes these places. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=50251 Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* ALSA: Avoid endless sleep after disconnectTakashi Iwai2012-11-171-0/+4
| | | | | | | | | | | commit 0914f7961babbf28aaa2f19b453951fb4841c03f upstream. When disconnect callback is called, each component should wake up sleepers and check card->shutdown flag for avoiding the endless sleep blocking the proper resource release. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* ALSA: Add a reference counter to card instanceTakashi Iwai2012-11-171-0/+2
| | | | | | | | | | | | | | | commit a0830dbd4e42b38aefdf3fb61ba5019a1a99ea85 upstream. For more strict protection for wild disconnections, a refcount is introduced to the card instance, and let it up/down when an object is referred via snd_lookup_*() in the open ops. The free-after-last-close check is also changed to check this refcount instead of the empty list, too. Reported-by: Matthieu CASTET <matthieu.castet@parrot.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* ALSA: core: sparse cleanupsClemens Ladisch2011-02-141-23/+28
| | | | | | | | | Change the core code where sparse complains. In most cases, this means just adding annotations to confirm that we indeed want to do the dirty things we're doing. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: Don't leak in sound/core/oss/pcm_oss.c::snd_pcm_hw_param_near()Jesper Juhl2011-01-101-1/+3
| | | | | | | | | snd_pcm_hw_param_near() will leak the memory allocated to 'save' if the call to snd_pcm_hw_param_max() returns less than zero. This patch makes sure we never leak. Signed-off-by: Jesper Juhl <jj@chaosbits.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: Fix SNDCTL_DSP_RESET ioctl for OSS emulationTakashi Iwai2010-11-301-8/+11
| | | | | | | | | | In OSS emulation, SNDCTL_DSP_RESET ioctl needs the reset of the internal buffer state in addition to drop of the running streams. Otherwise the succeeding access becomes inconsistent. Tested-by: Amit Nagal <helloin.amit@gmail.com> Cc: <stable@kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: core - Define llseek fopsTakashi Iwai2010-04-131-0/+5
| | | | | | | | | | | Set no_llseek to llseek file ops of each sound component (but for hwdep). This avoids the implicit BKL invocation via generic_file_llseek() used as default when fops.llseek is NULL. Also call nonseekable_open() at each open ops to ensure the file flags have no seek bit. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: pcm_lib - return back hw_ptr_interruptJaroslav Kysela2010-01-261-2/+1
| | | | | | | | | | | | | | | | | | | | Clemens Ladisch noted for hw_ptr_removal in "cleanup & merge hw_ptr update functions" commit: "It is possible for the status/delay ioctls to be called when the sound card's pointer register alreay shows a position at the beginning of the new period, but immediately before the interrupt is actually executed. (This happens regularly on a SMP machine with mplayer.) When that happens, the code thinks that the position must be at least one period ahead of the current position and drops an entire buffer of data." Return back the hw_ptr_interrupt variable. The last interrupt pointer is always computed from the latest hw_ptr instead of tracking it separately (in this case all hw_ptr checks and modifications might influence also hw_ptr_interrupt and it is difficult to keep it consistent). Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ALSA: pcm_lib - cleanup & merge hw_ptr update functionsJaroslav Kysela2010-01-071-9/+23
| | | | | | | | | | | | Do general cleanup in snd_pcm_update_hw_ptr*() routines and merge them. The main change is hw_ptr_interrupt variable removal to simplify code logic. This variable can be computed directly from hw_ptr. Ensure that updated hw_ptr is not lower than previous one (it was possible with old code in some obscure situations when interrupt was delayed or the lowlevel driver returns wrong ring buffer position value). Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* Merge branch 'topic/oss' into for-linusTakashi Iwai2009-09-101-2/+7
|\ | | | | | | | | | | | | * topic/oss: ALSA: allocation may fail in snd_pcm_oss_change_params() sound: vwsnd: Fix setting of cfgval and ctlval in li_setup_dma() sound: fix OSS MIDI output data loss
| * ALSA: allocation may fail in snd_pcm_oss_change_params()Roel Kluin2009-08-311-2/+7
| | | | | | | | | | | | | | | | Allocation may fail, show if it did. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> [Additional fix for invalid runtime->oss.prepare flag set by tiwai] Signed-off-by: Takashi Iwai <tiwai@suse.de>
* | ALSA: Add const prefix to proc helper functionsTakashi Iwai2009-09-081-1/+2
|/ | | | | | | Add appropriate const prefix to char * arguments in proc helper functions. Also fixed the caller side to be proper const pointers. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: Clean up 64bit division functionsTakashi Iwai2009-06-051-3/+2
| | | | | | Replace the house-made div64_32() with the standard div_u64*() functions. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* Merge branch 'bkl-removal' of git://git.lwn.net/linux-2.6Linus Torvalds2009-03-261-0/+2
|\ | | | | | | | | | | | | | | * 'bkl-removal' of git://git.lwn.net/linux-2.6: Rationalize fasync return values Move FASYNC bit handling to f_op->fasync() Use f_lock to protect f_flags Rename struct file->f_ep_lock
| * Use f_lock to protect f_flagsJonathan Corbet2009-03-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Traditionally, changes to struct file->f_flags have been done under BKL protection, or with no protection at all. This patch causes all f_flags changes after file open/creation time to be done under protection of f_lock. This allows the removal of some BKL usage and fixes a number of longstanding (if microscopic) races. Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
* | Merge branch 'topic/misc' into for-linusTakashi Iwai2009-03-241-18/+31
|\ \
| * | ALSA: Add missing KERN_* prefix to printk in sound/coreTakashi Iwai2009-02-051-18/+31
| | | | | | | | | | | | Signed-off-by: Takashi Iwai <tiwai@suse.de>
* | | ALSA: pcm_oss, fix locking typoJiri Slaby2009-03-181-2/+2
| |/ |/| | | | | | | | | | | | | | | s/mutex_lock/mutex_unlock/ on 2 fail paths in snd_pcm_oss_proc_write. Probably a typo, lock should be unlocked when leaving the function. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Cc: <stable@kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* | ALSA: pcm_oss: AFMT_S24_LE is set twice in return valueRoel Kluin2009-02-041-1/+1
|/ | | | | | | | | | | AFMT_S24_LE is set twice in return value vi sound/core/oss/pcm_oss.c +640 #define AFMT_S24_LE 0x00008000 #define AFMT_S24_BE 0x00010000 Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* [PATCH] introduce fmode_t, do annotationsAl Viro2008-10-211-1/+1
| | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* ALSA: Kill snd_assert() in sound/core/*Takashi Iwai2008-08-131-17/+35
| | | | | | | | 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>
* sound: Revert "ALSA: Fix limit of 8 PCM devices in ↵Jaroslav Kysela2008-08-011-5/+5
| | | | | | | | | | SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE" This reverts commit fb3d6f2b77bdec75d45aa9d4464287ed87927866. New, updated patch with same subject replaces this commit. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ALSA: Fix limit of 8 PCM devices in SNDRV_CTL_IOCTL_PCM_NEXT_DEVICEPawel MOLL2008-07-291-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | When compiled with CONFIG_SND_DYNAMIC_MINORS the ALSA core is fine to have more than 8 PCM devices per card, except one place - the SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE ioctl, which will not enumerate devices > 7. This patch fixes the issue, changing the devices list organisation. Instead of adding new device to the tail, the list is now kept always ordered (by card number, then device number). Thus, during enumeration, it is easy to discover the fact that there is no more given card's devices. The same limit was present in OSS emulation code. It has been fixed as well. Additionally the device field of struct snd_pcm is now int, instead of unsigned int, as there is no obvious reason for keeping it unsigned. This caused a lot of problems with comparing this value with other (almost always signed) variables. There is just one more place where device number is unsigned - in struct snd_pcm_info, which should be also sorted out in future. Signed-off-by: Pawel MOLL <pawel.moll@st.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* [ALSA] Fix Oops with PCM OSS syncTakashi Iwai2008-01-311-0/+1
| | | | | | | | | The PCM OSS emulation can cause Oops at sync operation due to the wrong data size calculation. Typically happening on Sparc64: http://lkml.org/lkml/2008/1/24/426 Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* [ALSA] Remove sound/driver.hTakashi Iwai2008-01-311-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>
* [ALSA] Remove PCM sleep_min and tickTakashi Iwai2008-01-311-1/+0
| | | | | | | | | | | | | 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>
* [ALSA] Remove PCM xfer_align sw paramsTakashi Iwai2008-01-311-1/+0
| | | | | | | | | | | | | 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>
* [ALSA] Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.czJaroslav Kysela2007-10-161-2/+2
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* [ALSA] Add new AFMT_* formats for OSS emulationTakashi Iwai2007-10-161-1/+34
| | | | | | | | The recent OSS includes the support for 32bit and other formats, which we already have, too. Let's define and map them. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
* header cleaning: don't include smp_lock.h when not usedRandy Dunlap2007-05-081-1/+0
| | | | | | | | | | | | Remove includes of <linux/smp_lock.h> where it is not used/needed. Suggested by Al Viro. Builds cleanly on x86_64, i386, alpha, ia64, powerpc, sparc, sparc64, and arm (all 59 defconfigs). Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* [PATCH] mark struct file_operations const 9Arjan van de Ven2007-02-121-1/+1
| | | | | | | | | | | Many struct file_operations in the kernel can be "const". Marking them const moves these to the .rodata section, which avoids false sharing with potential dirty data. In addition it'll catch accidental writes at compile time to these shared resources. Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* [ALSA] Fix races in PCM OSS emulationTakashi Iwai2006-12-201-12/+40
| | | | | | | | | Fixed the race among multiple threads accessing the OSS PCM instance concurrently by simply introducing a mutex for protecting a setup of the PCM. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
* [ALSA] Fix hang-up at disconnection of usb-audioTakashi Iwai2006-11-281-1/+2
| | | | | | | | Fix hang-up at disconnection of usb-audio devices while accessing PCM. Don't handle PCM operations any more after shutdown flag is set. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
* [ALSA] Unregister device files at disconnectionTakashi Iwai2006-09-231-9/+7
| | | | | | | | | | | | Orignally proposed by Sam Revitch <sam.revitch@gmail.com>. Unregister device files at disconnection to avoid the futher accesses. Also, the dev_unregister callback is removed and replaced with the combination of disconnect + free. A new function snd_card_free_when_closed() is introduced, which is used in USB disconnect callback. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
* [ALSA] Fix disconnection of proc interfaceTakashi Iwai2006-09-231-5/+3
| | | | | | | | | | - Add the linked list to each proc entry to enable a single-shot disconnection (unregister) - Deprecate snd_info_unregister(), use snd_info_free_entry() - Removed NULL checks of snd_info_free_entry() Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
* [ALSA] Don't reject O_RDWR at opening PCM OSS with read/write-only deviceTakashi Iwai2006-08-031-0/+2
| | | | | | | | Accept O_RDWR at opening a PCM OSS device that is read- or write-only, just for the compatibility with the behavior of older versions. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
* [ALSA] Remove zero-initialization of static variablesTakashi Iwai2006-06-221-1/+1
| | | | | | | Removed zero-initializations of static variables. A tiny optimization. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* [ALSA] Fix mmap_count with O_APPEND opened streamsTakashi Iwai2006-06-221-13/+14
| | | | | | | | Move mmap_count to snd_pcm_substream instead of runtime struct so that multiplly opened substreams via O_APPEND can be handled correctly. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* [ALSA] Add O_APPEND flag support to PCMTakashi Iwai2006-06-221-7/+10
| | | | | | | | 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>
* [ALSA] Remove unneeded read/write_size fields in proc text opsTakashi Iwai2006-06-221-2/+0
| | | | | | | Remove unneeded read/write_size fields in proc text ops. snd_info_set_text_ops() is fixed, too. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* [ALSA] Move OSS-specific hw_params helper to snd-pcm-oss moduleTakashi Iwai2006-06-221-0/+481
| | | | | | | 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>
* [ALSA] Fix Oops at rmmod with CONFIG_SND_VERBOSE_PROCFS=nTakashi Iwai2006-04-271-3/+3
| | | | | | | | Fixed Oops at rmmod with CONFIG_SND_VERBOSE_PROCFS=n. Add ifdef to struct fields for optimization and better compile checks. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* [ALSA] Handle the error correctly in SNDCTL_DSP_SETFMT ioctlSteven Finney2006-04-271-0/+2
| | | | | | | | Handle the error returned from snd_pcm_oss_get_formats() correctly in SNDCTL_DSP_SETFMT ioctl handler of PCM OSS emulation. Signed-off-by: Steven Finney <sfinney@healthhero.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* [ALSA] Fix Oops of PCM OSS emulationTakashi Iwai2006-04-121-2/+3
| | | | | | | | Modules: PCM Midlevel,ALSA<-OSS emulation Fix Oops of PCM OSS emulation occuring when multiple playback is used. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* [ALSA] pcm_oss: fix snd_pcm_oss_release() oopsOGAWA Hirofumi2006-04-121-1/+1
| | | | | | | | | Modules: ALSA<-OSS emulation Fix Oops due to a typo in snd_pcm_oss.c. Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* [ALSA] Fix / clean up PCM-OSS setup hooksTakashi Iwai2006-03-311-70/+63
| | | | | | | | - Fix possible race of referring the setup hook from the running PCM - Fix memory leak in an error path of proc write - Clean up the setup hook parser Signed-off-by: Takashi Iwai <tiwai@suse.de>
* [ALSA] Clean up PCM codes (take 2)Takashi Iwai2006-03-311-107/+44
| | | | | | | | | - 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>
* [ALSA] Tiny clean up of PCM codesTakashi Iwai2006-03-311-8/+8
| | | | | | | - Make snd_pcm_prepare() static - Clean up snd_pcm_kernel_*_ioctl() functions, reduce exports Signed-off-by: Takashi Iwai <tiwai@suse.de>
* [ALSA] semaphore -> mutex (core part)Ingo Molnar2006-03-221-15/+15
| | | | | | | | | | | Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* [ALSA] PCM midlevel & PCM OSS - make procfs & OSS plugin code optionalJaroslav Kysela2006-03-221-2/+18
| | | | | | | | | | | | Modules: ALSA Core,PCM Midlevel,ALSA<-OSS emulation,USB generic driver 1) The verbose procfs code for the PCM midlevel and usb audio can be removed now (more patches will follow). CONFIG_SND_VERBOSE_PROCFS 2) The PCM OSS plugin system can be also compiled optionaly. CONFIG_SND_PCM_OSS_PLUGINS Signed-off-by: Jaroslav Kysela <perex@suse.cz>