Commit Graph

562 Commits

Author SHA1 Message Date
Clemens Ladisch e7373b702f sound: pcm: record a substream's owner process
Record the pid of the task that opened a PCM substream. For sound
cards with hardware mixing, this allows determining which process
is associated with a specific substream's volume control.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-11-10 16:32:20 +01:00
Clemens Ladisch 91d12c485b sound: rawmidi: fix opened substreams count
The substream_opened field is to count the number of opened substreams,
not the number of times that any substreams have been opened.

Furthermore, all substreams being opened does not imply that the next
open would fail, due to the possibility of O_APPEND.  With this wrong
check, opening a substream multiple times would succeed only if the
device had more unopened substreams.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-11-10 16:32:10 +01:00
Takashi Iwai 3f225c07c7 Merge branch 'topic/ctl-pid-lock' into topic/core-change 2009-11-10 16:30:03 +01:00
Clemens Ladisch b7fe750fcc sound: rawmidi: fix MIDI device O_APPEND error handling
Commit 9a1b64caac in 2.6.30 broke the
error handling code in rawmidi_open_priv().

If only the output substream of a RawMIDI device has been opened and
if this device is then opened with O_RDWR | O_APPEND and if the
initialization of the input substream fails (either because of low
memory or because the device driver's open callback fails), then the
runtime structure of the already open output substream will be freed
and all following writes through the first handle will cause
snd_rawmidi_write() to use the NULL runtime pointer.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-11-10 16:22:59 +01:00
Clemens Ladisch 16fb109644 sound: rawmidi: fix checking of O_APPEND when opening MIDI device
Commit 9a1b64caac in 2.6.30 dropped the
check that a substream must already have been opened with O_APPEND to be
able to open it a second time.

This would make it possible for a substream to be switched to append
mode, which would mean that non-atomic writes would fail unexpectedly.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-11-10 16:21:30 +01:00
Clemens Ladisch 8579d2d777 sound: rawmidi: fix double init when opening MIDI device with O_APPEND
Commit 9a1b64caac in 2.6.30 moved the
substream initialization code to where it would be executed every time
the substream is opened.

This had the consequence that any further opening would drop and leak
the data in the existing buffer, and that the device driver's open
callback would be called multiple times, unexpectedly.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-11-10 16:20:43 +01:00
Clemens Ladisch 25d27eded1 control: use reference-counted pid
Instead of storing the PID number, take a reference to the task's pid
structure.  This protects against duplicates due to PID overflows, and
using pid_vnr() ensures that the PID returned by snd_ctl_elem_info() is
correct as seen from the current namespace.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-11-06 14:32:06 +01:00
Clemens Ladisch 31cef7076e control: remove snd_konctrol_volatile::owner_pid field
We do not need to save the ID of the process that locked a control
because that information is already available in the owner's file data.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-11-06 14:32:03 +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 e87a3dd33e Merge branch 'fix/misc' into topic/misc 2009-11-01 11:11:07 +01:00
Julia Lawall 4b3be6afa4 ALSA: sound: Move dereference after NULL test and drop unnecessary NULL tests
In pcm.c, if the NULL test on pcm is needed, then the dereference should be
after the NULL test.

In dummy.c and ali5451.c, the context of the calls to
snd_card_dummy_new_mixer and snd_ali_free_voice show that dummy and pvoice,
respectively cannot be NULL.

A simplified version of the semantic match that detects this problem is as
follows (http://coccinelle.lip6.fr/):

// <smpl>
@match exists@
expression x, E;
identifier fld;
@@

* x->fld
  ... when != \(x = E\|&x\)
* x == NULL
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-10-30 12:01:27 +01:00
Krzysztof Helt 8066e51ae7 ALSA: snd_dma_pointer workaround for chipsets with buggy DMA
The chipsets with the isa_dma_bridge_buggy set do not stop DMA during
DMA counter reads. The DMA counter is read in two 8-bit read steps
on x86 platform. Sometimes, such reads happen during higher byte
change so the lower byte is already decremented (rolled over) but
the higher byte is not. It introduces an error that position is
moved 256 bytes ahead of the true position. Thus, the next DMA
position read can return a lower value then the previous read.
If the DMA position is decreased (reversed) the ALSA subsystem is
tricked into the playback underrun error and resets the playback.
It results in a "pop" during a playback.

Work around the issue by reading the counter twice and choosing a higher
value.

Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-10-11 18:03:13 +02:00
Alexey Dobriyan f0f37e2f77 const: mark struct vm_struct_operations
* mark struct vm_area_struct::vm_ops as const
* mark vm_ops in AGP code

But leave TTM code alone, something is fishy there with global vm_ops
being used.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-09-27 11:39:25 -07:00
Takashi Iwai d3a7dcfeeb ALSA: pcm - Simplify snd_pcm_drain() implementation
Simplify snd_pcm_drain() implementation and avoid unneeded array-
allocation for waitqueues.  Instead, one waitqueue is used for the
first draining stream, and wait until all streams finished.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-09-21 15:13:09 +02:00
Takashi Iwai b34c866394 Merge branch 'topic/tlv-minmax' into for-linus
* topic/tlv-minmax:
  ALSA: usb-audio - Correct bogus volume dB information
  ALSA: usb-audio - Use the new TLV_DB_MINMAX type
  ALSA: Add new TLV types for dBwith min/max
2009-09-10 15:33:06 +02:00
Takashi Iwai 9d416811f8 Merge branch 'topic/snd-printk' into for-linus
* topic/snd-printk:
  ALSA: Fixed a typo of printk()
  ALSA: Add debug module option
  ALSA: core - strip too long file names in snd_print*()
2009-09-10 15:33:03 +02:00
Takashi Iwai df9200dd04 Merge branch 'topic/pcm-estrpipe-in-pm' into for-linus
* topic/pcm-estrpipe-in-pm:
  ALSA: pcm - Tell user that stream to be rewound is suspended
2009-09-10 15:33:02 +02:00
Takashi Iwai 2c0d19a78d Merge branch 'topic/pcm-drain-nonblock' into for-linus
* topic/pcm-drain-nonblock:
  ALSA: pcm - Increase protocol version
  ALSA: pcm - Fix drain behavior in non-blocking mode
2009-09-10 15:33:00 +02: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 9cd9f42767 Merge branch 'topic/misc' into for-linus
* topic/misc:
  ALSA: Remove unneeded ifdef from sound/core.h
  ALSA: Remove struct snd_monitor_file from public sound/core.h
  ALSA: Release v1.0.21
2009-09-10 15:32:57 +02:00
Takashi Iwai 0f23c5cc50 Merge branch 'topic/midi' into for-linus
* topic/midi:
  sound: rawmidi: disable active-sensing-on-close by default
  sound: seq_oss_midi: remove magic numbers
  sound: seq_midi: do not send MIDI reset when closing
  seq-midi: always log message on output overrun
2009-09-10 15:32:56 +02:00
Takashi Iwai 6a0f402146 Merge branch 'topic/dummy' into for-linus
* topic/dummy:
  ALSA: dummy - Increase MAX_PCM_SUBSTREAMS to 128
  ALSA: dummy - Add debug proc file
  ALSA: Add const prefix to proc helper functions
  ALSA: Re-export snd_pcm_format_name() function
  ALSA: dummy - Fake buffer allocations
  ALSA: dummy - Fix the timer calculation in systimer mode
  ALSA: dummy - Add more description
  ALSA: dummy - Better jiffies handling
  ALSA: dummy - Support high-res timer mode
2009-09-10 15:32:51 +02:00
Takashi Iwai f9892a52e2 Merge branch 'topic/dma-sgbuf' into for-linus
* topic/dma-sgbuf:
  ALSA: Fix SG-buffer DMA with non-coherent architectures
2009-09-10 15:32:50 +02:00
Takashi Iwai f604529d0c Merge branch 'topic/ctl-add-remove-fixes' into for-linus
* topic/ctl-add-remove-fixes:
  sound: snd_ctl_remove_user_ctl: prevent removal of kernel controls
  sound: snd_ctl_remove_unlocked_id: simplify user control counting
  sound: snd_ctl_remove_unlocked_id: simplify error paths
  sound: snd_ctl_elem_add: fix value count check
2009-09-10 15:32:47 +02:00
Takashi Iwai d0064a1b22 Merge branch 'topic/cleanup' into for-linus
* topic/cleanup:
  ALSA: info - Use krealloc()
2009-09-10 15:32:43 +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
Takashi Iwai 6e5265ec34 ALSA: Re-export snd_pcm_format_name() function
Re-export snd_pcm_format_name() function to be used outside the PCM core.
As a first example, usbaudio is changed to use it now again.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-09-08 14:26:51 +02:00
Takashi Iwai 82a783f4bc ALSA: Remove struct snd_monitor_file from public sound/core.h
The struct snd_monitor_file is used locally only in sound/core/init.c,
thus it should be moved there from the public sound/core.h.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-09-07 15:50:18 +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 36ce99c1dc ALSA: Add debug module option
Add debug module option to snd core.
This controls the debug print level.  When CONFIG_SND_DEBUG_VERBOSE
is set, you can suppress the debug messages by giving or changing this
parameter to a lower value.  debug=0 means no debug messsages.
As default, it's set to the verbose level 2.

Since this option can be changed dynamically via sysfs file, you can
suppress the verbose debug messages on the fly, which wasn't possible
before.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-08-27 17:42:08 +02:00
Takashi Iwai 1b0053a0f0 ALSA: core - strip too long file names in snd_print*()
When modules are built with M= option, they pass long file paths to
__FILE__.  This results in ugly outputs of snd_print*() when
CONFIG_SND_VERBOSE_PRINTK is set.

This patch adds a check of the path and strips the leading path dirs
if the file name is an absolute path to improve the readability of logs.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-08-27 12:39:35 +02:00
Linus Torvalds a206e9417f Merge branch 'fix/misc' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
* '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-25 09:47:06 -07:00
Clemens Ladisch b1ddaf681e sound: pcm_lib: fix unsorted list constraint handling
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-25 08:52:34 +02:00
Takashi Iwai 4cdc115fd3 ALSA: pcm - Fix drain behavior in non-blocking mode
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-08-20 16:40:16 +02:00
Clemens Ladisch 18dd0aa5af sound: snd_ctl_remove_user_ctl: prevent removal of kernel controls
Ensure that userspace can remove only user controls.  Controls created
by kernel drivers must not be removed because they might be referenced
in calls to snd_ctl_notify().

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-08-17 12:48:21 +02:00
Clemens Ladisch f217ac59b6 sound: snd_ctl_remove_unlocked_id: simplify user control counting
Move the decrementing of the user controls counter from
snd_ctl_elem_remove to snd_ctl_remove_unlocked_id; this saves the
separate locking of the controls semaphore, and therefore removes
a harmless race.

Since the purpose of the function is to operate on user controls (the
control being unlocked is just a prerequisite), rename it to
snd_ctl_remove_user_ctl.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-08-17 12:48:15 +02:00
Clemens Ladisch 317b80817f sound: snd_ctl_remove_unlocked_id: simplify error paths
Use a common exit path to release the mutex and to return a possible
error.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-08-17 12:48:06 +02:00
Clemens Ladisch 2a031aedf7 sound: snd_ctl_elem_add: fix value count check
Make sure that no user element that has no values can be added.

The check for count>1024 is not needed because the count is checked
later for the individual control types.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-08-17 12:48:00 +02:00
Lubomir Rintel 51840409b6 ALSA: pcm - Tell user that stream to be rewound is suspended
Return STRPIPE instead of EBADF when userspace attempts to rewind
of forward a stream that was suspended in meanwhile, so that it
can be recovered by snd_pcm_recover().

This was causing Pulseaudio to unload the ALSA sink module under a race
condition when it attempted to rewind the stream right after resume from
suspend, before writing to the stream which would cause it to revive the
stream otherwise. Tested to work with Pulseaudio patched to attempt to
snd_pcm_recover() upon receiving an error from snd_pcm_rewind().

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-08-03 08:57:00 +02:00
Takashi Iwai b88158846f Merge branch 'fix/pcm-hwptr' into for-linus
* fix/pcm-hwptr:
  ALSA: pcm - Fix hwptr buffer-size overlap bug
  ALSA: pcm - Fix warnings in debug loggings
  ALSA: pcm - Add logging of hwptr updates and interrupt updates
  ALSA: pcm - Fix regressions with VMware
2009-07-26 11:07:07 +02:00
Takashi Iwai 947ca210f1 ALSA: pcm - Fix hwptr buffer-size overlap bug
The fix 79452f0a28 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-23 16:21:08 +02:00
Takashi Iwai 8935064043 ALSA: pcm - Fix warnings in debug loggings
Add proper cast.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-07-23 14:28:37 +02:00
Takashi Iwai cedb8118e8 ALSA: pcm - Add logging of hwptr updates and interrupt updates
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-23 11:09:03 +02:00
Takashi Iwai 79452f0a28 ALSA: pcm - Fix regressions with VMware
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-07-22 12:55:56 +02:00
Jaswinder Singh Rajput f96e080821 ALSA: OSS sequencer should be initialized after snd_seq_system_client_init
When build SND_SEQUENCER in kernel then OSS sequencer(alsa_seq_oss_init)
is initialized before System (snd_seq_system_client_init) which leads to
memory leak :

unreferenced object 0xf6b0e680 (size 256):
  comm "swapper", pid 1, jiffies 4294670753
  backtrace:
    [<c108ac5c>] create_object+0x135/0x204
    [<c108adfe>] kmemleak_alloc+0x26/0x4c
    [<c1087de2>] kmem_cache_alloc+0x72/0xff
    [<c126d2ac>] seq_create_client1+0x22/0x160
    [<c126e3b6>] snd_seq_create_kernel_client+0x72/0xef
    [<c1485a05>] snd_seq_oss_create_client+0x86/0x142
    [<c1485920>] alsa_seq_oss_init+0xf6/0x155
    [<c1001059>] do_one_initcall+0x4f/0x111
    [<c14655be>] kernel_init+0x115/0x166
    [<c10032af>] kernel_thread_helper+0x7/0x10
    [<ffffffff>] 0xffffffff
unreferenced object 0xf688a580 (size 64):
  comm "swapper", pid 1, jiffies 4294670753
  backtrace:
    [<c108ac5c>] create_object+0x135/0x204
    [<c108adfe>] kmemleak_alloc+0x26/0x4c
    [<c1087de2>] kmem_cache_alloc+0x72/0xff
    [<c126f964>] snd_seq_pool_new+0x1c/0xb8
    [<c126d311>] seq_create_client1+0x87/0x160
    [<c126e3b6>] snd_seq_create_kernel_client+0x72/0xef
    [<c1485a05>] snd_seq_oss_create_client+0x86/0x142
    [<c1485920>] alsa_seq_oss_init+0xf6/0x155
    [<c1001059>] do_one_initcall+0x4f/0x111
    [<c14655be>] kernel_init+0x115/0x166
    [<c10032af>] kernel_thread_helper+0x7/0x10
    [<ffffffff>] 0xffffffff
unreferenced object 0xf6b0e480 (size 256):
  comm "swapper", pid 1, jiffies 4294670754
  backtrace:
    [<c108ac5c>] create_object+0x135/0x204
    [<c108adfe>] kmemleak_alloc+0x26/0x4c
    [<c1087de2>] kmem_cache_alloc+0x72/0xff
    [<c12725a0>] snd_seq_create_port+0x51/0x21c
    [<c126de50>] snd_seq_ioctl_create_port+0x57/0x13c
    [<c126d07a>] snd_seq_do_ioctl+0x4a/0x69
    [<c126d0de>] snd_seq_kernel_client_ctl+0x33/0x49
    [<c1485a74>] snd_seq_oss_create_client+0xf5/0x142
    [<c1485920>] alsa_seq_oss_init+0xf6/0x155
    [<c1001059>] do_one_initcall+0x4f/0x111
    [<c14655be>] kernel_init+0x115/0x166
    [<c10032af>] kernel_thread_helper+0x7/0x10
    [<ffffffff>] 0xffffffff

The correct order should be :

System (snd_seq_system_client_init) should be initialized before
OSS sequencer(alsa_seq_oss_init) which is equivalent to :

1. insmod sound/core/seq/snd-seq-device.ko
2. insmod sound/core/seq/snd-seq.ko
3. insmod sound/core/seq/snd-seq-midi-event.ko
4. insmod sound/core/seq/oss/snd-seq-oss.ko

Including sound/core/seq/oss/Makefile after other seq modules
fixes the ordering and memory leak.

Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-07-19 19:10:01 +02:00
Clemens Ladisch 2d4b842014 sound: rawmidi: disable active-sensing-on-close by default
Sending an Active Sensing message when closing a port can interfere with
the following data if the port is reopened and a note-on is sent before
the device's timeout has elapsed.  Therefore, it is better to disable
this setting by default.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-07-15 11:57:20 +02:00
Clemens Ladisch 08d033405a sound: seq_oss_midi: remove magic numbers
Instead of using magic numbers for the controlles sent when resetting
a port, use the symbols from asoundef.h.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-07-15 11:57:08 +02:00
Clemens Ladisch b86c87288c sound: seq_midi: do not send MIDI reset when closing
Sending a MIDI reset message when closing a port is wrong because we
only want to shut the device up, not to reset all settings.
Furthermore, many devices ignore this message.

Fortunately, the RawMIDI layer already shuts the device up, so we can
ignore this matter here.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-07-15 11:56:58 +02:00
Clemens Ladisch f907ed94f9 seq-midi: always log message on output overrun
It turns out that the main cause of output buffer overruns is not slow
drivers but applications that generate too many messages.  Therefore, it
makes more sense to make that error message always visible, and to
rate-limit it.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-07-15 11:56:06 +02:00
Takashi Iwai cc6a8acdee ALSA: Fix SG-buffer DMA with non-coherent architectures
Using SG-buffers with dma_alloc_coherent() is often very inefficient
on non-coherent architectures because a tracking record could be
allocated in addition for each dma_alloc_coherent() call.
Instead, simply disable SG-buffers but just allocate normal continuous
buffers on non-supported (currently all but x86) architectures.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-07-08 14:20:20 +02:00
Takashi Iwai 9983aa62c3 ALSA: info - Use krealloc()
Use krealloc() to resize the buffer in sound/core/info.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-07-06 14:31:59 +02:00
Takashi Iwai 3f67f6693c Merge branch 'topic/seq-midi-fix' into for-linus
* topic/seq-midi-fix:
  sound: seq_midi_event: fix decoding of (N)RPN events
2009-06-22 17:03:56 +02:00
Takashi Iwai 12bc738596 Merge branch 'topic/pcm-jiffies-check' into for-linus
* topic/pcm-jiffies-check:
  sound: fix check for return value in snd_pcm_hw_refine
2009-06-22 17:03:54 +02:00
Clemens Ladisch 6423f9ea80 sound: seq_midi_event: fix decoding of (N)RPN events
When decoding (N)RPN sequencer events into raw MIDI commands, the
extra_decode_xrpn() function had accidentally swapped the MSB and LSB
controller values of both the parameter number and the data value.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-06-22 11:11:49 +02:00
Mariusz Kozlowski 8bd9bca3c1 sound: fix check for return value in snd_pcm_hw_refine
'params' is a pointer and looking at the code this probably should be a check
for ioctl return value.

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-06-22 07:54:21 +02:00
Takashi Iwai 085f306541 ALSA: Add new TLV types for dBwith min/max
Add new types for TLV dB scale specified with min/max values instead
of min/step since the resolution can't match always with the one
a device provides.  For example, usb audio devices give 1/256 dB
resolution while ALSA TLV is based on 1/100 dB resolution.
The new min/max types have less problems because the possible
rounding error happens only at min/max.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-06-17 10:56:53 +02:00
Takashi Iwai be914cf910 Merge branch 'topic/misc' into for-linus
* topic/misc:
  ALSA: use card device as parent for jack input-devices
2009-06-12 20:03:13 +02:00
Kay Sievers 1f3fff7bda ALSA: use card device as parent for jack input-devices
This moves the jack devices from the PCI device into the ALSA card device, which
makes it easier for userspace to find all devices belonging to a specific card
while granting access to logged-in users.

Jack input devices from sound cards can now simply be matched with udev by doing:
  SUBSYSTEM="input", SUBSYSTEMS="sound", ...

 ls -l /sys/devices/pci0000:00/0000:00:1b.0/sound/card0
 controlC0
 device -> ../../../0000:00:1b.0
 id
 input10
 input11
 input8
 input9
 number
 pcmC0D0c
 pcmC0D0p
 pcmC0D1p
 power
 subsystem -> ../../../../../class/sound
 uevent

Cc: Lennart Poettering <lennart@0pointer.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-06-10 19:50:33 +02:00
Takashi Iwai 4ef279205a Merge branch 'topic/seq-kconfig-cleanup' into for-linus
* topic/seq-kconfig-cleanup:
  ALSA: clean up the logic for building sequencer modules
2009-06-10 07:26:48 +02:00
Takashi Iwai 3b88bc5229 Merge branch 'topic/pcm-jiffies-check' into for-linus
* 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-10 07:26:41 +02:00
Takashi Iwai eabaf0634a Merge branch 'topic/pcm-delay' into for-linus
* topic/pcm-delay:
  ALSA: usbaudio - Add delay account
  ALSA: Add extra delay count in PCM
2009-06-10 07:26:40 +02:00
Takashi Iwai 19b1a15a3d Merge branch 'topic/div64-cleanup' into for-linus
* topic/div64-cleanup:
  ALSA: Clean up 64bit division functions
2009-06-10 07:26:28 +02:00
Takashi Iwai c00701101b ALSA: pcm - A helper function to compose PCM stream name for debug prints
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-08 16:01:47 +02:00
Takashi Iwai ab1863fc9b ALSA: pcm - Fix update of runtime->hw_ptr_interrupt
The commit 13f040f9e5 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-07 12:19:33 +02:00
Jaroslav Kysela d86bf92313 ALSA: pcm - Fix a typo in hw_ptr update check
Fix a typo in the commit 13f040f9e5
  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-06 18:32:06 +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
Jaroslav Kysela 5fdc18d938 ALSA: Core - clean up snd_card_set_id* calls and remove possible id collision
Move locking outside snd_card_set_id_internal() function and rename it
to snd_card_set_id_no_lock() for better function description.

User defined id is just copied to card structure at allocation time.
The real unique id procedure is called in snd_card_register() to
ensure real atomicity.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-06-04 01:22:07 +02:00
Mark Brown 872c78202c ALSA: Fix double locking of card list in snd_card_register()
The introduction of snd_card_set_id() added a lock on the card list
to the old choose_default_id() function when using it to implement
the new API call. This lock is needed to allow us to walk the list
and check to see if our new name is a duplicate. Unfortunately this
causes a lockup when called from snd_card_register() (in cases
where no ID is supplied for the card) since the card list is already
locked there.

Fix this fairly hideously by factoring out the implementation and
using a flag to indicate if the lock should be held. A better fix
would probably be to refactor snd_card_register() to move the
_set_id() outside the locking region but I can't immediately see
anything I can convince myself is safe.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-06-03 23:33:28 +02:00
Jaroslav Kysela 10a8ebbb08 ALSA: Core - add snd_card_set_id() function
Introduce snd_card_set_id() function to allow lowlevel drivers to set
default identification name for card slot. The function checks also
for identification name collisions and tries to create unique name.

Also, the snd_card_create() function is simplified, because this new
function is used. As bonus, proper name collision checks are evaluated
at the card create time.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-06-02 12:47:46 +02:00
Michal Marek 0528c7494e ALSA: clean up the logic for building sequencer modules
Instead of mangling the CONFIG_* variables in the makefiles over and
over, set a few helper variables in Kconfig.

Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-05-29 11:49:42 +02:00
Jaroslav Kysela a4444da31e ALSA: PCM midlevel: lower jiffies check margin using runtime->delay value
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-29 11:47:40 +02:00
Jaroslav Kysela 13f040f9e5 ALSA: PCM midlevel: Do not update hw_ptr_jiffies when hw_ptr is not changed
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-29 11:47:38 +02:00
Jaroslav Kysela c62a01ad6e ALSA: PCM midlevel: introduce mask for xrun_debug() macro
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-29 11:47:36 +02:00
Jaroslav Kysela 8bea869c5e ALSA: PCM midlevel: improve fifo_size handling
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-29 11:47:33 +02:00
Takashi Iwai e93721a702 Merge branch 'fix/pcm-jiffies-check' into topic/pcm-jiffies-check 2009-05-29 11:46:10 +02:00
Takashi Iwai c87d973200 ALSA: Enable PCM hw_ptr_jiffies check only in xrun_debug mode
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-27 11:04:30 +02:00
Takashi Iwai 6af3fb72d2 ALSA: Fix invalid jiffies check after pause
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-05-27 11:04:18 +02:00
Takashi Iwai 4bbe1ddf89 ALSA: Add extra delay count in PCM
Added runtime->delay field to adjust the delayed samples for snd_pcm_delay().
Typically a hardware FIFO length is stored in this field, so that the
extra delay between hwptr and applptr can be computed.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-05-05 14:47:21 +02:00
Takashi Iwai 3e5b50165f ALSA: pcm core - Avoid jiffies check for devices with BATCH flag
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-28 15:10:16 +02:00
Takashi Iwai f4723b224d Merge branch 'topic/memdup_user' into for-linus
* topic/memdup_user:
  ALSA: sound/pci: use memdup_user()
  ALSA: sound/usb: use memdup_user()
  ALSA: sound/isa: use memdup_user()
  ALSA: sound/core: use memdup_user()
2009-04-15 11:24:27 +02:00
Takashi Iwai 2e8e59f437 Merge branch 'topic/hda' into for-linus
* topic/hda:
  ALSA: hda - Add quirk mask for Fujitsu Amilo laptops with ALC883
  ALSA: hda - Avoid call of snd_jack_report at release
  ALSA: add private_data to struct snd_jack
2009-04-15 11:24:09 +02:00
Takashi Iwai 9d59065cd6 ALSA: add private_data to struct snd_jack
Added private_data and private_free fields to struct snd_jack so that
the caller can assign the data.  It'll be helpful for avoiding the
double-free of the jack instance.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-04-14 16:15:09 +02:00
Li Zefan ef44a1ec6e ALSA: sound/core: use memdup_user()
Remove open-coded memdup_user().

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2009-04-14 12:39:12 +02:00
Jaroslav Kysela bbf6ad1399 [ALSA] pcm-midlevel: Add more strict buffer position checks based on jiffies
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-04-10 12:28:58 +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
Alexey Dobriyan 99b7623380 proc 2/2: remove struct proc_dir_entry::owner
Setting ->owner as done currently (pde->owner = THIS_MODULE) is racy
as correctly noted at bug #12454. Someone can lookup entry with NULL
->owner, thus not pinning enything, and release it later resulting
in module refcount underflow.

We can keep ->owner and supply it at registration time like ->proc_fops
and ->data.

But this leaves ->owner as easy-manipulative field (just one C assignment)
and somebody will forget to unpin previous/pin current module when
switching ->owner. ->proc_fops is declared as "const" which should give
some thoughts.

->read_proc/->write_proc were just fixed to not require ->owner for
protection.

rmmod'ed directories will be empty and return "." and ".." -- no harm.
And directories with tricky enough readdir and lookup shouldn't be modular.
We definitely don't want such modular code.

Removing ->owner will also make PDE smaller.

So, let's nuke it.

Kudos to Jeff Layton for reminding about this, let's say, oversight.

http://bugzilla.kernel.org/show_bug.cgi?id=12454

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
2009-03-31 01:14:44 +04: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
Takashi Iwai d807500a24 Merge branch 'topic/pcm-cleanup' into for-linus 2009-03-24 00:35:49 +01:00
Takashi Iwai ec6659c389 Merge branch 'topic/vmaster-update' into for-linus 2009-03-24 00:35:47 +01:00
Takashi Iwai c944a93df0 Merge branch 'topic/rawmidi-fix' into for-linus 2009-03-24 00:35:46 +01:00
Takashi Iwai 65b3864b85 Merge branch 'topic/ctl-list-cleanup' into for-linus 2009-03-24 00:35:45 +01:00
Takashi Iwai bafdb7278c Merge branch 'topic/quirk-cleanup' into for-linus 2009-03-24 00:35:44 +01:00
Takashi Iwai 5b56eec774 Merge branch 'topic/jack' into for-linus 2009-03-24 00:35:43 +01:00
Takashi Iwai c2f43981e5 Merge branch 'topic/hwdep-cleanup' into for-linus 2009-03-24 00:35:41 +01:00
Takashi Iwai dec14f8c0e Merge branch 'topic/snd_card_new-err' into for-linus 2009-03-24 00:35:35 +01:00
Takashi Iwai 8b22d943c3 ALSA: pcm - Safer boundary checks
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-20 16:26:15 +01:00
Takashi Iwai ded652f702 ALSA: pcm - Fix delta calculation at boundary overlap
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-19 10:08:49 +01:00
Takashi Iwai 5f513e1197 ALSA: pcm - Reset invalid position even without debug option
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-19 10:01:47 +01:00