1
0
Fork 0
Commit Graph

156 Commits (a369e8378b48aa8fc93e574e5df7e198cfb88cd4)

Author SHA1 Message Date
Takashi Iwai ec0e9937aa ALSA: core: Drop superfluous error/debug messages after malloc failures
The kernel memory allocators already report the errors when the
requested allocation fails, thus we don't need to warn it again in
each caller side.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-10 15:42:14 +01:00
Lars-Peter Clausen f6dbe1bee5 ALSA: snd_pcm_oss_period_size: Use round{up,down}_pow_of_two()
Instead of opencoding them use the standard roundup_pow_of_two() and
rounddown_pow_of_two() helper functions. This gets rids one of the few users
of the custom ld2() function and also makes it a bit more obvious what the
code does.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-30 16:41:55 +01:00
Takashi Iwai 61efcee860 ALSA: oss: Use standard printk helpers
Use dev_err() & co as much as possible.  If not available (no device
assigned at the calling point), use pr_xxx() helpers instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-02-14 08:14:17 +01:00
Takashi Iwai 80d7d771ae ALSA: Drop unused name argument in snd_register_oss_device()
The last argument, name, of snd_oss_register_device() is nowhere
referred in the function in the current code.  Let's drop it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-02-12 10:58:19 +01:00
Xi Wang 701ef3205e ALSA: core: fix NULL checking in snd_pcm_plug_slave_size()
The dereference snd_pcm_plug_stream(plug) should come after the NULL
check snd_BUG_ON(!plug).

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-14 08:03:31 +01:00
Xi Wang 9af4e7feda ALSA: core: fix NULL checking in snd_pcm_plug_client_size()
The dereference snd_pcm_plug_stream(plug) should come after the NULL
check snd_BUG_ON(!plug).

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-14 08:03:27 +01:00
Takashi Iwai 8bb4d9ce08 ALSA: Fix card refcount unbalance
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

Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-08 14:36:18 +01:00
Takashi Iwai 0914f7961b ALSA: Avoid endless sleep after disconnect
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.

Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-10-30 11:07:15 +01:00
Takashi Iwai a0830dbd4e ALSA: Add a reference counter to card instance
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>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-10-30 11:07:10 +01:00
Wei Yongjun 1f3b14072b ALSA: fix possible memory leak in snd_mixer_oss_build_input()
uinfo has been allocated in this function and should be
freed before leaving from the error handling cases.

spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-03 10:08:28 +02:00
Rusty Russell a67ff6a540 ALSA: module_param: make bool parameters really bool
module_param(bool) used to counter-intuitively take an int.  In
fddd5201 (mid-2009) we allowed bool or int/unsigned int using a messy
trick.

It's time to remove the int/unsigned int option.  For this version
it'll simply give a warning, but it'll break next kernel version.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-12-19 10:34:41 +01:00
Paul Gortmaker da155d5b40 sound: Add module.h to the previously silent sound users
Lots of sound drivers were getting module.h via the implicit presence
of it in <linux/device.h> but we are going to clean that up.  So
fix up those users now.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2011-10-31 19:31:21 -04:00
Paul Gortmaker 65a772172b sound: fix drivers needing module.h not moduleparam.h
The implicit presence of module.h lured several users into
incorrectly thinking that they only needed/used modparam.h
but once we clean up the module.h presence, these will show
up as build failures, so fix 'em now.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2011-10-31 19:31:19 -04:00
Dan Carpenter f92766bc89 ALSA: oss-mixer - use strlcpy() instead strcpy()
This is mostly a static checker fix more than anything else.  We're
copying from a 64 char buffer into a 44 char buffer.

The 64 character buffer is str[] in snd_mixer_oss_build_test_all().
The call tree is:
	snd_mixer_oss_build_test_all()
	-> snd_mixer_oss_build_test()
	   -> snd_mixer_oss_build_test().

We never actually do fill str[] buffer all the way to 64 characters.
The longest string is:
	sprintf(str, "%s Playback Switch", ptr->name);
ptr->name is a 32 character buffer so 32 plus 16 characters for
" Playback Switch" still puts us over the 44 limit from "id.name".

Most likely ptr->name never gets filled to the limit, but we can't
really change the size of that buffer so lets just use strlcpy() here
and be safe.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-10-04 08:47:52 +02:00
Luca Tettamanti 78fa2c4d24 ALSA: core: remove unused variables.
Drop a few variables that are never read.

Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-05-26 08:19:04 +02:00
Clemens Ladisch fea952e5cc ALSA: core: sparse cleanups
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>
2011-02-14 17:10:11 +01:00
Jesper Juhl 3daa7ea650 ALSA: Don't leak in sound/core/oss/pcm_oss.c::snd_pcm_hw_param_near()
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>
2011-01-10 11:13:42 +01:00
Takashi Iwai 60686aa008 ALSA: Fix SNDCTL_DSP_RESET ioctl for OSS emulation
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>
2010-11-30 08:18:58 +01:00
Takashi Iwai e799d0bce6 Merge remote branch 'alsa/devel' into topic/misc 2010-10-11 13:56:12 +02:00
Jaroslav Kysela 838c364ff0 ALSA: OSS mixer emulation - fix locking
Fix mutex release and cleanup some locking code.

Cc: <stable@kernel.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-11 11:14:23 +02:00
Joe Perches 9fe856e47e sound: Remove unnecessary casts of private_data
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2010-09-07 08:05:59 +02:00
Takashi Iwai 02f4865fa4 ALSA: core - Define llseek fops
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>
2010-04-13 12:01:21 +02:00
Tejun Heo 5a0e3ad6af include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files.  percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed.  Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability.  As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

  http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
  only the necessary includes are there.  ie. if only gfp is used,
  gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
  blocks and try to put the new include such that its order conforms
  to its surrounding.  It's put in the include block which contains
  core kernel includes, in the same order that the rest are ordered -
  alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
  doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
  because the file doesn't have fitting include block), it prints out
  an error message indicating which .h file needs to be added to the
  file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
   over 4000 files, deleting around 700 includes and adding ~480 gfp.h
   and ~3000 slab.h inclusions.  The script emitted errors for ~400
   files.

2. Each error was manually checked.  Some didn't need the inclusion,
   some needed manual addition while adding it to implementation .h or
   embedding .c file was more appropriate for others.  This step added
   inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
   from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
   e.g. lib/decompress_*.c used malloc/free() wrappers around slab
   APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
   editing them as sprinkling gfp.h and slab.h inclusions around .h
   files could easily lead to inclusion dependency hell.  Most gfp.h
   inclusion directives were ignored as stuff from gfp.h was usually
   wildly available and often used in preprocessor macros.  Each
   slab.h inclusion directive was examined and added manually as
   necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
   were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
   distributed build env didn't work with gcov compiles) and a few
   more options had to be turned off depending on archs to make things
   build (like ipr on powerpc/64 which failed due to missing writeq).

   * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
   * powerpc and powerpc64 SMP allmodconfig
   * sparc and sparc64 SMP allmodconfig
   * ia64 SMP allmodconfig
   * s390 SMP allmodconfig
   * alpha SMP allmodconfig
   * um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
   a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-30 22:02:32 +09:00
Jaroslav Kysela e763692578 ALSA: pcm_lib - return back hw_ptr_interrupt
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>
2010-01-26 17:50:50 +01:00
Jaroslav Kysela f240406bab ALSA: pcm_lib - cleanup & merge hw_ptr update functions
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>
2010-01-07 15:47:38 +01:00
Jaroslav Kysela ad1cd74506 ALSA: rename "PC Speaker" controls to "Speaker"
To unify control names, rename "PC Speaker" to "Speaker" for PPC ALSA drivers.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-11-05 09:00:21 +01:00
Jaroslav Kysela d355c82a01 ALSA: rename "PC Speaker" and "PC Beep" controls to "Beep"
To avoid confusion in control names for the standard analog PC Beep generator
using a small Internal PC Speaker, rename all related "PC Speaker" and "PC
Beep" controls to "Beep" only. This name is more universal and can be also
used on more platforms without confusion.

Introduce also "Internal Speaker" in ControlNames.txt for systems with
full-featured build-in internal speaker.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-11-05 09:00:18 +01:00
Takashi Iwai fa28519002 Merge branch 'topic/oss' into for-linus
* 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
2009-09-10 15:32:58 +02:00
Takashi Iwai 4f7454a997 ALSA: Add const prefix to proc helper functions
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>
2009-09-08 14:45:06 +02:00
Roel Kluin cbbb05703d ALSA: allocation may fail in snd_pcm_oss_change_params()
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>
2009-08-31 16:33:23 +02:00
Takashi Iwai 3f7440a6b7 ALSA: Clean up 64bit division functions
Replace the house-made div64_32() with the standard div_u64*() functions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-06-05 17:45:17 +02:00
Deepika Makhija d2e8e52976 ALSA: oss - volume control for CSWITCH and CROUTE
Added an else part to check
SNDRV_MIXER_OSS_PRESENT_CVOLUME for MIC (slot 7)
in commit 36c7b833e5

Similarly, checks and volume control is required for
SNDRV_MIXER_OSS_PRESENT_CSWITCH and SNDRV_MIXER_OSS_PRESENT_CROUTE
as well.

Signed-off-by: Deepika Makhija <deepika.makhija@einfochips.com>
Signed-off-by: Viral Mehta <viral.mehta@einfochips.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-04-07 04:23:46 +02:00
Linus Torvalds 8e9d208972 Merge branch 'bkl-removal' of git://git.lwn.net/linux-2.6
* '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
2009-03-26 16:14:02 -07:00
Takashi Iwai e0d2054fd3 Merge branch 'topic/misc' into for-linus 2009-03-24 00:35:50 +01:00
Jiri Slaby 91054598f7 ALSA: pcm_oss, fix locking typo
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>
2009-03-18 08:03:33 +01:00
Viral Mehta 36c7b833e5 ALSA: oss-mixer - Fixes recording gain control
At the time of initialization, SNDRV_MIXER_OSS_PRESENT_PVOLUME bit is not
set for MIC (slot 7).
So, the same should not be checked when an application tries to do gain
control for audio recording devices.

Just check slot->present for SNDRV_MIXER_OSS_PRESENT_CVOLUME independently.
Verified with a simple application which opens /dev/dsp for recording and
/dev/mixer for volume control.

Have tested two usb audio mic devices.

Signed-off-by: Viral Mehta <viral.mehta@einfochips.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-03-18 07:52:28 +01:00
Jonathan Corbet db1dd4d376 Use f_lock to protect f_flags
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>
2009-03-16 08:32:27 -06:00
Steve Chen 5370d96f85 ALSA: fix excessive background noise introduced by OSS emulation rate shrink
Incorrect variable was used to get the next sample which caused S2
to be stuck with the same value resulting in loud background noise.

Signed-off-by: Steve Chen <schen at mvista.com>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-02-23 07:49:04 +01:00
Takashi Iwai 006de26735 ALSA: Add missing KERN_* prefix to printk in sound/core
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-02-05 16:00:49 +01:00
Roel Kluin 7924f0cadc ALSA: pcm_oss: AFMT_S24_LE is set twice in return value
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>
2009-02-04 18:18:03 +01:00
Al Viro aeb5d72706 [PATCH] introduce fmode_t, do annotations
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2008-10-21 07:47:06 -04:00
Takashi Iwai 7eaa943c8e ALSA: Kill snd_assert() in sound/core/*
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-08-13 11:46:35 +02:00
Jaroslav Kysela 896e6cc20e sound: Revert "ALSA: Fix limit of 8 PCM devices in 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>
2008-08-01 13:36:04 +02:00
Pawel MOLL 9423969005 ALSA: Fix limit of 8 PCM devices in SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE
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>
2008-07-29 21:32:48 +02:00
Takashi Iwai 6c4cc3a8ed [ALSA] Add more fallbacks to OSS PHONEOUT mixer map
Added more fallbacks to OSS PHONEOUT mixer mapping.  This corresponds
to the speaker output in general, so now "Mono" and "Speaker" are
assigned.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2008-04-24 12:00:07 +02:00
Takashi Iwai 4939c66034 [ALSA] Fix Oops with PCM OSS sync
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>
2008-01-31 17:30:20 +01:00
Takashi Iwai 9004acc70e [ALSA] Remove sound/driver.h
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 17:29:48 +01:00
Takashi Iwai 31e8960b35 [ALSA] Remove PCM sleep_min and tick
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 17:29:47 +01:00
Takashi Iwai d948035a92 [ALSA] Remove PCM xfer_align sw params
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 17:29:47 +01:00
Jean Delvare 22a860a9e2 snd_mixer_oss_build_input(): fix for __you_cannot_kmalloc_that_much failure with gcc-3.2
Rework this functions so that gcc-3.2 can successfully perform
constant-folding.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Jaroslav Kysela <perex@suse.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-01-08 16:10:36 -08:00
Jaroslav Kysela c1017a4cdb [ALSA] Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2007-10-16 16:51:18 +02:00
Takashi Iwai 24038a25e7 [ALSA] Add new AFMT_* formats for OSS emulation
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>
2007-10-16 15:58:33 +02:00
Takashi Iwai 64d27f96cb [ALSA] Support 3-bytes 24bit format in PCM OSS emulation
Add the support of 3-bytes 24bit formats in PCM OSS emulation.
Also removed snd_pcm_build_linear_format() function.  It's exported
just for OSS emulation, and now the code was changed without calling
this function.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2007-10-16 15:58:31 +02:00
Takashi Iwai 9390ec85c0 [ALSA] Simplify the format conversion in PCM OSS emulation
Simplify the format conversion code in PCM OSS emulation.
This patch also adds the support of 3bytes 24bit formats with linear
and mulaw, but they are not enabled in pcm_plugin.c yet.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2007-10-16 15:58:31 +02:00
Takashi Iwai 887f9f0253 [ALSA] Remove ifdefs from OSS PCM emulation codes
Fix Makefile to compile files conditionally to CONFIG_SND_PCM_OSS_PLUGINS,
and remove unneeded ifdefs in these files.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2007-10-16 15:58:30 +02:00
Randy Dunlap e63340ae6b header cleaning: don't include smp_lock.h when not used
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>
2007-05-08 11:15:07 -07:00
Arjan van de Ven 9c2e08c592 [PATCH] mark struct file_operations const 9
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>
2007-02-12 09:48:46 -08:00
Takashi Iwai e3a5d59a17 [ALSA] Fix races in PCM OSS emulation
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>
2006-12-20 08:55:54 +01:00
Robert P. J. Day 5cbded585d [PATCH] getting rid of all casts of k[cmz]alloc() calls
Run this:

	#!/bin/sh
	for f in $(grep -Erl "\([^\)]*\) *k[cmz]alloc" *) ; do
	  echo "De-casting $f..."
	  perl -pi -e "s/ ?= ?\([^\)]*\) *(k[cmz]alloc) *\(/ = \1\(/" $f
	done

And then go through and reinstate those cases where code is casting pointers
to non-pointers.

And then drop a few hunks which conflicted with outstanding work.

Cc: Russell King <rmk@arm.linux.org.uk>, Ian Molton <spyro@f2s.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Greg KH <greg@kroah.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Karsten Keil <kkeil@suse.de>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: Ian Kent <raven@themaw.net>
Cc: Steven French <sfrench@us.ibm.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Neil Brown <neilb@cse.unsw.edu.au>
Cc: Jaroslav Kysela <perex@suse.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-13 09:05:58 -08:00
Takashi Iwai de1b8b93a0 [ALSA] Fix hang-up at disconnection of usb-audio
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>
2006-11-28 13:46:38 +01:00
Takashi Iwai c461482c80 [ALSA] Unregister device files at disconnection
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>
2006-09-23 10:36:58 +02:00
Takashi Iwai 746d4a02e6 [ALSA] Fix disconnection of proc interface
- 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>
2006-09-23 10:36:48 +02:00
Takashi Iwai 6cb53e7ed7 [ALSA] Don't reject O_RDWR at opening PCM OSS with read/write-only device
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>
2006-08-03 15:21:31 +02:00
Panagiotis Issaris 59feddb25f [ALSA] Conversions from kmalloc+memset to k(z|c)alloc
sound: Conversions from kmalloc+memset to k(c|z)alloc.

Signed-off-by: Panagiotis Issaris <takis@issaris.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2006-08-03 15:21:18 +02:00
Takashi Iwai 6581f4e74d [ALSA] Remove zero-initialization of static variables
Removed zero-initializations of static variables.
A tiny optimization.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-06-22 21:33:45 +02:00
Takashi Iwai 9c323fcbc5 [ALSA] Fix mmap_count with O_APPEND opened streams
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>
2006-06-22 21:33:14 +02:00
Takashi Iwai 0df63e44c3 [ALSA] Add O_APPEND flag support to PCM
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 21:33:13 +02:00
Takashi Iwai bf850204a7 [ALSA] Remove unneeded read/write_size fields in proc text ops
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>
2006-06-22 21:33:09 +02:00
Takashi Iwai e88e8ae639 [ALSA] Move OSS-specific hw_params helper to snd-pcm-oss module
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-06-22 21:33:05 +02:00
Takashi Iwai b7d90a356a [ALSA] Fix Oops at rmmod with CONFIG_SND_VERBOSE_PROCFS=n
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>
2006-04-27 21:10:42 +02:00
Steven Finney 5c59e09d7e [ALSA] Handle the error correctly in SNDCTL_DSP_SETFMT ioctl
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>
2006-04-27 21:10:06 +02:00
Takashi Iwai 1576274d30 [ALSA] Fix Oops of PCM OSS emulation
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>
2006-04-12 11:34:04 +02:00
OGAWA Hirofumi bbdc1b7dbe [ALSA] pcm_oss: fix snd_pcm_oss_release() oops
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>
2006-04-12 11:34:01 +02:00
Takashi Iwai 060d77b9c0 [ALSA] Fix / clean up PCM-OSS setup hooks
- 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>
2006-03-31 17:58:59 +02:00
Takashi Iwai 3bf75f9b90 [ALSA] Clean up PCM codes (take 2)
- 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>
2006-03-31 17:58:59 +02:00
Takashi Iwai bf1bbb5a49 [ALSA] Tiny clean up of PCM codes
- Make snd_pcm_prepare() static
- Clean up snd_pcm_kernel_*_ioctl() functions, reduce exports

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-03-31 17:58:58 +02:00
Takashi Iwai c82590d2b2 [ALSA] Fix mulaw -> linear conversion in OSS PCM emulation
Modules: ALSA<-OSS emulation

Fixed the missing mulaw -> linear conversion in OSS PCM emulation code.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-03-22 10:28:02 +01:00
Ingo Molnar 1a60d4c5a0 [ALSA] semaphore -> mutex (core part)
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>
2006-03-22 10:24:50 +01:00
Takashi Iwai 0534ab4279 [ALSA] Clean up pcm-oss plugins
Modules: ALSA<-OSS emulation

Clean up pcm-oss plugin codes.
Removed dead codes, and simplified route/rate plugins.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-03-22 10:23:20 +01:00
Takashi Iwai 9d83911ac0 [ALSA] Fix a typo
Modules: ALSA<-OSS emulation

Fixed a typo.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-03-22 10:23:16 +01:00
Jaroslav Kysela 21a3479a0b [ALSA] PCM midlevel & PCM OSS - make procfs & OSS plugin code optional
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>
2006-03-22 10:23:12 +01:00
Jes Sorensen 1b1dcc1b57 [PATCH] mutex subsystem, semaphore to mutex: VFS, ->i_sem
This patch converts the inode semaphore to a mutex. I have tested it on
XFS and compiled as much as one can consider on an ia64. Anyway your
luck with it might be different.

Modified-by: Ingo Molnar <mingo@elte.hu>

(finished the conversion)

Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2006-01-09 15:59:24 -08:00
Takashi Iwai 04f141a880 [ALSA] Optimize for config without PROC_FS (seq and oss parts)
Modules: ALSA<-OSS emulation,ALSA sequencer,ALSA<-OSS sequencer

Optimize the code when compiled without CONFIG_PROC_FS (in seq and oss
emulation parts).

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-01-03 12:30:05 +01:00
Clemens Ladisch f87135f56c [ALSA] dynamic minors (3/6): store device-specific object pointers dynamically
Instead of storing the pointers to the device-specific structures in an
array, put them into the struct snd_minor, and look them up dynamically.

This makes the device type modules independent of the minor number
encoding.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2006-01-03 12:29:17 +01:00
Clemens Ladisch 2af677fc88 [ALSA] dynamic minors (1/6): store device type in struct snd_minor
Instead of a comment string, store the device type in the snd_minor
structure.  This makes snd_minor more flexible, and has the nice side
effect that we don't need anymore to create a separate snd_minor
template for registering a device but can pass the file_operations
directly to snd_register_device().

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2006-01-03 12:29:14 +01:00
Takashi Iwai 6ac77bc180 [ALSA] Remove xxx_t typedefs: PCM OSS-emulation
Modules: ALSA<-OSS emulation

Remove xxx_t typedefs from the core PCM OSS-emulation codes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-01-03 12:17:48 +01:00
Takashi Iwai f956b4a3ae [ALSA] Remove xxx_t typedefs: Mixer OSS-emulation
Modules: ALSA<-OSS emulation

Remove xxx_t typedefs from the core mixer OSS-emulation codes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-01-03 12:17:47 +01:00
Takashi Iwai 47eaebfd31 [ALSA] Use standard bitmap functions
Modules: ALSA<-OSS emulation

Use standard bitmap functions instead of in-house ones.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2006-01-03 12:16:33 +01:00
Takashi Iwai d3d579f84e [ALSA] Add missing KERN_* prefix
Modules: ALSA<-OSS emulation,USB generic driver,USB USX2Y

Added missing KERN_* prefix to printk.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-11-04 13:19:32 +01:00
Takashi Iwai 93f2e37840 [ALSA] Make snd_task_name() module local
Modules: ALSA Core,ALSA<-OSS emulation

Remove a global function snd_task_name(), and move it local
to snd-pcm-oss module.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-11-04 13:17:54 +01:00
Takashi Iwai 7c22f1aaa2 [ALSA] Remove snd_runtime_check() macro
Remove snd_runtime_check() macro.
This macro worsens the readability of codes.  They should be either
normal if() or removable asserts.

Also, the assert displays stack-dump, instead of only the last caller
pointer.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-11-04 13:17:42 +01:00
Takashi Iwai ca2c096656 [ALSA] Replace with kzalloc() - core stuff
Control Midlevel,ALSA Core,HWDEP Midlevel,PCM Midlevel,RawMidi Midlevel
Timer Midlevel,ALSA<-OSS emulation
Replace kcalloc(1,..) with kzalloc().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-09-12 10:47:59 +02:00
Takashi Iwai 10f69f9e42 [ALSA] pcm-oss - Add bugg-yptr option
Documentation,ALSA<-OSS emulation
Added 'buggy-ptr' proc option to switch the behavior of GETOPTR ioctl.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-09-12 10:47:37 +02:00
Clemens Ladisch 4d23359b7e [ALSA] sparse address space annotations
ALSA Core,RawMidi Midlevel,ALSA<-OSS emulation,ALSA sequencer
RME32 driver,RME96 driver,EMU10K1/EMU10K2 driver,NM256 driver
Add sparse annotations where we do strange this with __iomem/__user
pointers.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2005-09-12 10:41:16 +02:00
Karsten Wiese 443feb8826 [ALSA] ALSA's struct _snd_pcm_substream: Obsolete open_flag
PCM Midlevel,ALSA<-OSS emulation,USB USX2Y
This patch removes open_flag from struct _snd_pcm_substream.
All of its uses are substituted by querying struct _snd_pcm_substream's
member ffile instead.

Signed-off-by: Karsten Wiese <annabellesgarden@yahoo.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-08-30 08:44:48 +02:00
Paulo Marques 543537bd92 [PATCH] create a kstrdup library function
This patch creates a new kstrdup library function and changes the "local"
implementations in several places to use this function.

Most of the changes come from the sound and net subsystems.  The sound part
had already been acknowledged by Takashi Iwai and the net part by David S.
Miller.

I left UML alone for now because I would need more time to read the code
carefully before making changes there.

Signed-off-by: Paulo Marques <pmarques@grupopie.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-06-23 09:45:18 -07:00
Jaroslav Kysela 5ac0fab95c [ALSA] OSS PCM emulation - The 2nd final fix for SNDCTL_DSP_GETOPTR problem
ALSA<-OSS emulation
The problem was negative/wrong result (info.bytes) in a specific condition at
playback startup.

Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2005-06-22 12:28:03 +02:00
Jaroslav Kysela fb4bd0adc4 [ALSA] OSS PCM emulation - The final fix for SNDCTL_DSP_GETOPTR problem
ALSA<-OSS emulation
The problem was negative result (info.bytes) in a specific condition at
playback startup.

Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2005-06-22 12:27:57 +02:00
Takashi Iwai cdc5c53fde [ALSA] Fix compilation on 32bit arch
ALSA<-OSS emulation
Fix the division with int64 for 32bit architectures.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2005-05-29 10:15:30 +02:00
Jaroslav Kysela af0816139f [ALSA] alsa-oss - 2nd - improved readability
ALSA<-OSS emulation
Use 'long' for byte counters in snd_pcm_oss_bytes() snd_pcm_alsa_bytes().

Signed-off-by: Jaroslav Kysela <perex@suse.cz>
2005-05-29 10:15:17 +02:00