From d30e5d897c3da7c2d17c8112331b66ed953eec78 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 28 May 2010 04:42:59 +0200 Subject: [ARM] pxa/spitz: Correctly register WM8750 This patch registers the WM8750 codec on a proper place on the SPITZ machine after the WM8750 driver was converted to new API. Signed-off-by: Marek Vasut Signed-off-by: Eric Miao --- sound/soc/pxa/spitz.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'sound') diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c index 1941a35..d256f5f 100644 --- a/sound/soc/pxa/spitz.c +++ b/sound/soc/pxa/spitz.c @@ -328,38 +328,6 @@ static struct snd_soc_device spitz_snd_devdata = { .codec_dev = &soc_codec_dev_wm8750, }; -/* - * FIXME: This is a temporary bodge to avoid cross-tree merge issues. - * New drivers should register the wm8750 I2C device in the machine - * setup code (under arch/arm for ARM systems). - */ -static int wm8750_i2c_register(void) -{ - struct i2c_board_info info; - struct i2c_adapter *adapter; - struct i2c_client *client; - - memset(&info, 0, sizeof(struct i2c_board_info)); - info.addr = 0x1b; - strlcpy(info.type, "wm8750", I2C_NAME_SIZE); - - adapter = i2c_get_adapter(0); - if (!adapter) { - printk(KERN_ERR "can't get i2c adapter 0\n"); - return -ENODEV; - } - - client = i2c_new_device(adapter, &info); - i2c_put_adapter(adapter); - if (!client) { - printk(KERN_ERR "can't add i2c device at 0x%x\n", - (unsigned int)info.addr); - return -ENODEV; - } - - return 0; -} - static struct platform_device *spitz_snd_device; static int __init spitz_init(void) @@ -369,10 +337,6 @@ static int __init spitz_init(void) if (!(machine_is_spitz() || machine_is_borzoi() || machine_is_akita())) return -ENODEV; - ret = wm8750_i2c_setup(); - if (ret != 0) - return ret; - spitz_snd_device = platform_device_alloc("soc-audio", -1); if (!spitz_snd_device) return -ENOMEM; -- cgit v1.1 From 15c0cee6c809a137e0fc7f1d2b0867cc03473c0c Mon Sep 17 00:00:00 2001 From: Ben Collins Date: Fri, 28 May 2010 11:43:45 -0400 Subject: ALSA: pcm: Define G723 3-bit and 5-bit formats This defines the 24bps and 40bps (8khz sample rate) G.723 codec formats. They are going to be used once I submit the driver for an mpeg4/g723 compression card. I've updated the signed value to -1 as per Takashi's comments since these are non-linear formats. Signed-off-by: Ben Collins Signed-off-by: Takashi Iwai --- sound/core/pcm_misc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sound') diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index ea2bf82..434af3c 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c @@ -128,6 +128,14 @@ static struct pcm_format_data pcm_formats[SNDRV_PCM_FORMAT_LAST+1] = { .width = 4, .phys = 4, .le = -1, .signd = -1, .silence = {}, }, + [SNDRV_PCM_FORMAT_G723_24] = { + .width = 3, .phys = 3, .le = -1, .signd = -1, + .silence = {}, + }, + [SNDRV_PCM_FORMAT_G723_40] = { + .width = 5, .phys = 5, .le = -1, .signd = -1, + .silence = {}, + }, /* FIXME: the following three formats are not defined properly yet */ [SNDRV_PCM_FORMAT_MPEG] = { .le = -1, .signd = -1, @@ -186,6 +194,14 @@ static struct pcm_format_data pcm_formats[SNDRV_PCM_FORMAT_LAST+1] = { .width = 18, .phys = 24, .le = 0, .signd = 0, .silence = { 0x02, 0x00, 0x00 }, }, + [SNDRV_PCM_FORMAT_G723_24_1B] = { + .width = 3, .phys = 8, .le = -1, .signd = -1, + .silence = {}, + }, + [SNDRV_PCM_FORMAT_G723_40_1B] = { + .width = 5, .phys = 8, .le = -1, .signd = -1, + .silence = {}, + }, }; -- cgit v1.1 From dd37f8e8659bc617c3f2a84e007a4824ccdac458 Mon Sep 17 00:00:00 2001 From: Daniel T Chen Date: Sun, 30 May 2010 01:17:03 -0400 Subject: ALSA: hda: Use LPIB for an ASUS device BugLink: https://launchpad.net/bugs/465942 Symptom: On the reporter's ASUS device, using PulseAudio in Ubuntu 10.04 LTS results in the PA daemon crashing shortly after attempting to select capture or to configure the audio hardware profile. Test case: Using Ubuntu 10.04 LTS (Linux 2.6.32.12), Linux 2.6.33, or Linux 2.6.34, adjust the HDA device's capture volume with PulseAudio. Resolution: add SSID for this machine to the position_fix quirk table, explicitly specifying the LPIB method. Reported-and-Tested-By: Irihapeti Cc: Signed-off-by: Daniel T Chen Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index dc79564..7c54a40 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2288,6 +2288,7 @@ static struct snd_pci_quirk position_fix_list[] __devinitdata = { SND_PCI_QUIRK(0x1028, 0x01f6, "Dell Latitude 131L", POS_FIX_LPIB), SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB), SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), + SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB), SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB), SND_PCI_QUIRK(0x1106, 0x3288, "ASUS M2V-MX SE", POS_FIX_LPIB), SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba A100-259", POS_FIX_LPIB), -- cgit v1.1 From 26fd74fc01991a18f0e3bd54f8b1b75945ee3dbb Mon Sep 17 00:00:00 2001 From: Daniel T Chen Date: Sun, 30 May 2010 09:55:23 -0400 Subject: ALSA: hda: Use mb31 quirk for an iMac model BugLink: https://launchpad.net/bugs/542550 Symptom: On the reporter's iMac, in Ubuntu 10.04 LTS neither playback nor capture appear audible out-of-the-box. Test case: Boot from an Ubuntu 10.04 LTS live cd or from an installed configuration and attempt to play or capture audio. Resolution: Specify the mb31 quirk for this machine in the codec SSID table. Reported-and-Tested-By: f3a97 Cc: Signed-off-by: Daniel T Chen Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 17d4548..d792cdd 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -9476,6 +9476,7 @@ static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = { SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24), SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24), SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3), + SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31), SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31), SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3), SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24), -- cgit v1.1 From b90c076424da8166797bdc34187660fd0124f530 Mon Sep 17 00:00:00 2001 From: Daniel T Chen Date: Sun, 30 May 2010 19:31:41 -0400 Subject: ALSA: hda: Use LPIB for another mainboard BugLink: https://launchpad.net/bugs/580749 Symptom: on the original reporter's VIA VT1708-based board, the PulseAudio daemon dies shortly after the user attempts to play an audio file. Test case: boot from Ubuntu 10.04 LTS live cd; attempt to play an audio file. Resolution: add SSID for the original reporter's hardware to the position_fix quirk table, explicitly specifying the LPIB method. Reported-and-Tested-By: Harald Cc: Signed-off-by: Daniel T Chen Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 7c54a40..1640005 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2297,6 +2297,7 @@ static struct snd_pci_quirk position_fix_list[] __devinitdata = { SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB), SND_PCI_QUIRK(0x1565, 0x820f, "Biostar Microtech", POS_FIX_LPIB), SND_PCI_QUIRK(0x1565, 0x8218, "Biostar Microtech", POS_FIX_LPIB), + SND_PCI_QUIRK(0x1849, 0x0888, "775Dual-VSTA", POS_FIX_LPIB), SND_PCI_QUIRK(0x8086, 0x2503, "DG965OT AAD63733-203", POS_FIX_LPIB), SND_PCI_QUIRK(0x8086, 0xd601, "eMachines T5212", POS_FIX_LPIB), {} -- cgit v1.1 From dcbe7bcfa32c5bc4f9bb6c75d4d41bb4db8c36fc Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 31 May 2010 13:35:36 +0200 Subject: ALSA: usb-audio: UAC2: clean up parsing of bmaControls Introduce two new static inline functions for a more readable parsing of UAC2 bmaControls. Signed-off-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/mixer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 03ce971..43d6417 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1188,9 +1188,9 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void for (j = 0; j < channels; j++) { unsigned int mask = snd_usb_combine_bytes(bmaControls + csize * (j+1), csize); - if (mask & (1 << (i * 2))) { + if (uac2_control_is_readable(mask, i)) { ch_bits |= (1 << j); - if (~mask & (1 << ((i * 2) + 1))) + if (!uac2_control_is_writeable(mask, i)) ch_read_only |= (1 << j); } } @@ -1198,9 +1198,9 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void /* FIXME: the whole unit is read-only if any of the channels is marked read-only */ if (ch_bits & 1) /* the first channel must be set (for ease of programming) */ build_feature_ctl(state, _ftr, ch_bits, i, &iterm, unitid, !!ch_read_only); - if (master_bits & (1 << i * 2)) + if (uac2_control_is_readable(master_bits, i)) build_feature_ctl(state, _ftr, 0, i, &iterm, unitid, - ~master_bits & (1 << ((i * 2) + 1))); + !uac2_control_is_writeable(master_bits, i)); } } -- cgit v1.1 From a6a3325913efbe35a10e87fd3e9c3ce621fd32c7 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 31 May 2010 13:35:37 +0200 Subject: ALSA: usb-audio: support partially write-protected UAC2 controls So far, UAC2 controls are marked read-only if any of the channels are marked read-only in the descriptors. Change this behaviour and - mark them writeable unless all channels are read-only - store the read-only mask in usb_mixer_elem_info and - check the mask again in set_cur_mix_value(), and bail out for write-protected channels. Signed-off-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/mixer.c | 30 ++++++++++++++++++++++++------ sound/usb/mixer.h | 2 ++ 2 files changed, 26 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 43d6417..9149a84 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -462,6 +462,16 @@ static int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, int index, int value) { int err; + unsigned int read_only = (channel == 0) ? + cval->master_readonly : + cval->ch_readonly & (1 << (channel - 1)); + + if (read_only) { + snd_printdd(KERN_INFO "%s(): channel %d of control %d is read_only\n", + __func__, channel, cval->control); + return 0; + } + err = snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR, (cval->control << 8) | channel, value); if (err < 0) @@ -958,7 +968,7 @@ static size_t append_ctl_name(struct snd_kcontrol *kctl, const char *str) static void build_feature_ctl(struct mixer_build *state, void *raw_desc, unsigned int ctl_mask, int control, struct usb_audio_term *iterm, int unitid, - int read_only) + int readonly_mask) { struct uac_feature_unit_descriptor *desc = raw_desc; unsigned int len = 0; @@ -989,20 +999,25 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, cval->control = control; cval->cmask = ctl_mask; cval->val_type = audio_feature_info[control-1].type; - if (ctl_mask == 0) + if (ctl_mask == 0) { cval->channels = 1; /* master channel */ - else { + cval->master_readonly = readonly_mask; + } else { int i, c = 0; for (i = 0; i < 16; i++) if (ctl_mask & (1 << i)) c++; cval->channels = c; + cval->ch_readonly = readonly_mask; } /* get min/max values */ get_min_max(cval, 0); - if (read_only) + /* if all channels in the mask are marked read-only, make the control + * read-only. set_cur_mix_value() will check the mask again and won't + * issue write commands to read-only channels. */ + if (cval->channels == readonly_mask) kctl = snd_ctl_new1(&usb_feature_unit_ctl_ro, cval); else kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval); @@ -1195,9 +1210,12 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void } } - /* FIXME: the whole unit is read-only if any of the channels is marked read-only */ + /* NOTE: build_feature_ctl() will mark the control read-only if all channels + * are marked read-only in the descriptors. Otherwise, the control will be + * reported as writeable, but the driver will not actually issue a write + * command for read-only channels */ if (ch_bits & 1) /* the first channel must be set (for ease of programming) */ - build_feature_ctl(state, _ftr, ch_bits, i, &iterm, unitid, !!ch_read_only); + build_feature_ctl(state, _ftr, ch_bits, i, &iterm, unitid, ch_read_only); if (uac2_control_is_readable(master_bits, i)) build_feature_ctl(state, _ftr, 0, i, &iterm, unitid, !uac2_control_is_writeable(master_bits, i)); diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h index 1301238..a7cf100 100644 --- a/sound/usb/mixer.h +++ b/sound/usb/mixer.h @@ -34,6 +34,8 @@ struct usb_mixer_elem_info { unsigned int id; unsigned int control; /* CS or ICN (high byte) */ unsigned int cmask; /* channel mask bitmap: 0 = master */ + unsigned int ch_readonly; + unsigned int master_readonly; int channels; int val_type; int min, max, res; -- cgit v1.1 From 79f920fbff566ffc9de44111eb1456a3cef310f0 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 31 May 2010 14:51:31 +0200 Subject: ALSA: usb-audio: parse clock topology of UAC2 devices Audio devices which comply to the UAC2 standard can export complex clock topologies in its descriptors and set up links between them. The entities that are defined are - clock sources, which define the end-leafs. - clock selectors, which act as switch to select one out of many possible clocks sources. - clock multipliers, which have an input clock source, and act as clock source again. They can be used to derive one clock from another. All sample rate changes, clock validity queries and the like must go to clock source elements, while clock selectors and multipliers can be used as terminal clock source. The following patch adds a parser for these elements and functions to iterate over the tree and find the leaf nodes (clock sources). The samplerate set functions were moved to the new clock.c file. Signed-off-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/Makefile | 3 +- sound/usb/card.c | 18 +-- sound/usb/card.h | 1 + sound/usb/clock.c | 311 +++++++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/clock.h | 12 ++ sound/usb/endpoint.c | 57 +++++++++- sound/usb/format.c | 16 ++- sound/usb/pcm.c | 98 +--------------- sound/usb/usbaudio.h | 5 +- 9 files changed, 396 insertions(+), 125 deletions(-) create mode 100644 sound/usb/clock.c create mode 100644 sound/usb/clock.h (limited to 'sound') diff --git a/sound/usb/Makefile b/sound/usb/Makefile index e7ac7f4..1e362bf 100644 --- a/sound/usb/Makefile +++ b/sound/usb/Makefile @@ -11,7 +11,8 @@ snd-usb-audio-objs := card.o \ endpoint.o \ urb.o \ pcm.o \ - helper.o + helper.o \ + clock.o snd-usbmidi-lib-objs := midi.o diff --git a/sound/usb/card.c b/sound/usb/card.c index da1346b..7a8ac1d 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -236,7 +236,6 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif) } case UAC_VERSION_2: { - struct uac_clock_source_descriptor *cs; struct usb_interface_assoc_descriptor *assoc = usb_ifnum_to_if(dev, ctrlif)->intf_assoc; @@ -245,21 +244,6 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif) return -EINVAL; } - /* FIXME: for now, we expect there is at least one clock source - * descriptor and we always take the first one. - * We should properly support devices with multiple clock sources, - * clock selectors and sample rate conversion units. */ - - cs = snd_usb_find_csint_desc(host_iface->extra, host_iface->extralen, - NULL, UAC2_CLOCK_SOURCE); - - if (!cs) { - snd_printk(KERN_ERR "CLOCK_SOURCE descriptor not found\n"); - return -EINVAL; - } - - chip->clock_id = cs->bClockID; - for (i = 0; i < assoc->bInterfaceCount; i++) { int intf = assoc->bFirstInterface + i; @@ -481,6 +465,8 @@ static void *snd_usb_audio_probe(struct usb_device *dev, goto __error; } + chip->ctrl_intf = alts; + if (err > 0) { /* create normal USB audio interfaces */ if (snd_usb_create_streams(chip, ifnum) < 0 || diff --git a/sound/usb/card.h b/sound/usb/card.h index ed92420..1febf2f 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -25,6 +25,7 @@ struct audioformat { unsigned int rate_min, rate_max; /* min/max rates */ unsigned int nr_rates; /* number of rate table entries */ unsigned int *rate_table; /* rate table */ + unsigned char clock; /* associated clock */ }; struct snd_usb_substream; diff --git a/sound/usb/clock.c b/sound/usb/clock.c new file mode 100644 index 0000000..b7aadd6 --- /dev/null +++ b/sound/usb/clock.c @@ -0,0 +1,311 @@ +/* + * Clock domain and sample rate management functions + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "usbaudio.h" +#include "card.h" +#include "midi.h" +#include "mixer.h" +#include "proc.h" +#include "quirks.h" +#include "endpoint.h" +#include "helper.h" +#include "debug.h" +#include "pcm.h" +#include "urb.h" +#include "format.h" + +static struct uac_clock_source_descriptor * + snd_usb_find_clock_source(struct usb_host_interface *ctrl_iface, + int clock_id) +{ + struct uac_clock_source_descriptor *cs = NULL; + + while ((cs = snd_usb_find_csint_desc(ctrl_iface->extra, + ctrl_iface->extralen, + cs, UAC2_CLOCK_SOURCE))) { + if (cs->bClockID == clock_id) + return cs; + } + + return NULL; +} + +static struct uac_clock_selector_descriptor * + snd_usb_find_clock_selector(struct usb_host_interface *ctrl_iface, + int clock_id) +{ + struct uac_clock_selector_descriptor *cs = NULL; + + while ((cs = snd_usb_find_csint_desc(ctrl_iface->extra, + ctrl_iface->extralen, + cs, UAC2_CLOCK_SELECTOR))) { + if (cs->bClockID == clock_id) + return cs; + } + + return NULL; +} + +static struct uac_clock_multiplier_descriptor * + snd_usb_find_clock_multiplier(struct usb_host_interface *ctrl_iface, + int clock_id) +{ + struct uac_clock_multiplier_descriptor *cs = NULL; + + while ((cs = snd_usb_find_csint_desc(ctrl_iface->extra, + ctrl_iface->extralen, + cs, UAC2_CLOCK_MULTIPLIER))) { + if (cs->bClockID == clock_id) + return cs; + } + + return NULL; +} + +static int uac_clock_selector_get_val(struct snd_usb_audio *chip, int selector_id) +{ + unsigned char buf; + int ret; + + ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), + UAC2_CS_CUR, + USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, + UAC2_CX_CLOCK_SELECTOR << 8, selector_id << 8, + &buf, sizeof(buf), 1000); + + if (ret < 0) + return ret; + + return buf; +} + +static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id) +{ + int err; + unsigned char data; + struct usb_device *dev = chip->dev; + + err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, + USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, + UAC2_CS_CONTROL_CLOCK_VALID << 8, source_id << 8, + &data, sizeof(data), 1000); + + if (err < 0) { + snd_printk(KERN_WARNING "%s(): cannot get clock validity for id %d\n", + __func__, source_id); + return err; + } + + return !!data; +} + +/* Try to find the clock source ID of a given clock entity */ + +static int __uac_clock_find_source(struct snd_usb_audio *chip, + struct usb_host_interface *host_iface, + int entity_id, unsigned long *visited) +{ + struct uac_clock_source_descriptor *source; + struct uac_clock_selector_descriptor *selector; + struct uac_clock_multiplier_descriptor *multiplier; + + entity_id &= 0xff; + + if (test_and_set_bit(entity_id, visited)) { + snd_printk(KERN_WARNING + "%s(): recursive clock topology detected, id %d.\n", + __func__, entity_id); + return -EINVAL; + } + + /* first, see if the ID we're looking for is a clock source already */ + source = snd_usb_find_clock_source(host_iface, entity_id); + if (source) + return source->bClockID; + + selector = snd_usb_find_clock_selector(host_iface, entity_id); + if (selector) { + int ret; + + /* the entity ID we are looking for is a selector. + * find out what it currently selects */ + ret = uac_clock_selector_get_val(chip, selector->bClockID); + if (ret < 0) + return ret; + + if (ret > selector->bNrInPins || ret < 1) { + printk(KERN_ERR + "%s(): selector reported illegal value, id %d, ret %d\n", + __func__, selector->bClockID, ret); + + return -EINVAL; + } + + return __uac_clock_find_source(chip, host_iface, + selector->baCSourceID[ret-1], + visited); + } + + /* FIXME: multipliers only act as pass-thru element for now */ + multiplier = snd_usb_find_clock_multiplier(host_iface, entity_id); + if (multiplier) + return __uac_clock_find_source(chip, host_iface, + multiplier->bCSourceID, visited); + + return -EINVAL; +} + +int snd_usb_clock_find_source(struct snd_usb_audio *chip, + struct usb_host_interface *host_iface, + int entity_id) +{ + DECLARE_BITMAP(visited, 256); + memset(visited, 0, sizeof(visited)); + return __uac_clock_find_source(chip, host_iface, entity_id, visited); +} + +static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface, + struct usb_host_interface *alts, + struct audioformat *fmt, int rate) +{ + struct usb_device *dev = chip->dev; + unsigned int ep; + unsigned char data[3]; + int err, crate; + + ep = get_endpoint(alts, 0)->bEndpointAddress; + + /* if endpoint doesn't have sampling rate control, bail out */ + if (!(fmt->attributes & UAC_EP_CS_ATTR_SAMPLE_RATE)) { + snd_printk(KERN_WARNING "%d:%d:%d: endpoint lacks sample rate attribute bit, cannot set.\n", + dev->devnum, iface, fmt->altsetting); + return 0; + } + + data[0] = rate; + data[1] = rate >> 8; + data[2] = rate >> 16; + if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, + USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT, + UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, + data, sizeof(data), 1000)) < 0) { + snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n", + dev->devnum, iface, fmt->altsetting, rate, ep); + return err; + } + + if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR, + USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_IN, + UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, + data, sizeof(data), 1000)) < 0) { + snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n", + dev->devnum, iface, fmt->altsetting, ep); + return 0; /* some devices don't support reading */ + } + + crate = data[0] | (data[1] << 8) | (data[2] << 16); + if (crate != rate) { + snd_printd(KERN_WARNING "current rate %d is different from the runtime rate %d\n", crate, rate); + // runtime->rate = crate; + } + + return 0; +} + +static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, + struct usb_host_interface *alts, + struct audioformat *fmt, int rate) +{ + struct usb_device *dev = chip->dev; + unsigned char data[4]; + int err, crate; + int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fmt->clock); + + if (clock < 0) + return clock; + + if (!uac_clock_source_is_valid(chip, clock)) { + snd_printk(KERN_ERR "%d:%d:%d: clock source %d is not valid, cannot use\n", + dev->devnum, iface, fmt->altsetting, clock); + return -ENXIO; + } + + data[0] = rate; + data[1] = rate >> 8; + data[2] = rate >> 16; + data[3] = rate >> 24; + if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, + USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, + UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, + data, sizeof(data), 1000)) < 0) { + snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n", + dev->devnum, iface, fmt->altsetting, rate); + return err; + } + + if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, + USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, + UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, + data, sizeof(data), 1000)) < 0) { + snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n", + dev->devnum, iface, fmt->altsetting); + return err; + } + + crate = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); + if (crate != rate) + snd_printd(KERN_WARNING "current rate %d is different from the runtime rate %d\n", crate, rate); + + return 0; +} + +int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface, + struct usb_host_interface *alts, + struct audioformat *fmt, int rate) +{ + struct usb_interface_descriptor *altsd = get_iface_desc(alts); + + switch (altsd->bInterfaceProtocol) { + case UAC_VERSION_1: + return set_sample_rate_v1(chip, iface, alts, fmt, rate); + + case UAC_VERSION_2: + return set_sample_rate_v2(chip, iface, alts, fmt, rate); + } + + return -EINVAL; +} + diff --git a/sound/usb/clock.h b/sound/usb/clock.h new file mode 100644 index 0000000..beb2536 --- /dev/null +++ b/sound/usb/clock.h @@ -0,0 +1,12 @@ +#ifndef __USBAUDIO_CLOCK_H +#define __USBAUDIO_CLOCK_H + +int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface, + struct usb_host_interface *alts, + struct audioformat *fmt, int rate); + +int snd_usb_clock_find_source(struct snd_usb_audio *chip, + struct usb_host_interface *host_iface, + int entity_id); + +#endif /* __USBAUDIO_CLOCK_H */ diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 28ee1ce..9593b91 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -190,6 +190,38 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip, return attributes; } +static struct uac2_input_terminal_descriptor * + snd_usb_find_input_terminal_descriptor(struct usb_host_interface *ctrl_iface, + int terminal_id) +{ + struct uac2_input_terminal_descriptor *term = NULL; + + while ((term = snd_usb_find_csint_desc(ctrl_iface->extra, + ctrl_iface->extralen, + term, UAC_INPUT_TERMINAL))) { + if (term->bTerminalID == terminal_id) + return term; + } + + return NULL; +} + +static struct uac2_output_terminal_descriptor * + snd_usb_find_output_terminal_descriptor(struct usb_host_interface *ctrl_iface, + int terminal_id) +{ + struct uac2_output_terminal_descriptor *term = NULL; + + while ((term = snd_usb_find_csint_desc(ctrl_iface->extra, + ctrl_iface->extralen, + term, UAC_OUTPUT_TERMINAL))) { + if (term->bTerminalID == terminal_id) + return term; + } + + return NULL; +} + int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) { struct usb_device *dev; @@ -199,7 +231,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) int i, altno, err, stream; int format = 0, num_channels = 0; struct audioformat *fp = NULL; - int num, protocol; + int num, protocol, clock = 0; struct uac_format_type_i_continuous_descriptor *fmt; dev = chip->dev; @@ -263,6 +295,8 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) } case UAC_VERSION_2: { + struct uac2_input_terminal_descriptor *input_term; + struct uac2_output_terminal_descriptor *output_term; struct uac_as_header_descriptor_v2 *as = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL); @@ -281,7 +315,25 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) num_channels = as->bNrChannels; format = le32_to_cpu(as->bmFormats); - break; + /* lookup the terminal associated to this interface + * to extract the clock */ + input_term = snd_usb_find_input_terminal_descriptor(chip->ctrl_intf, + as->bTerminalLink); + if (input_term) { + clock = input_term->bCSourceID; + break; + } + + output_term = snd_usb_find_output_terminal_descriptor(chip->ctrl_intf, + as->bTerminalLink); + if (output_term) { + clock = output_term->bCSourceID; + break; + } + + snd_printk(KERN_ERR "%d:%u:%d : bogus bTerminalLink %d\n", + dev->devnum, iface_no, altno, as->bTerminalLink); + continue; } default: @@ -338,6 +390,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) * (fp->maxpacksize & 0x7ff); fp->attributes = parse_uac_endpoint_attributes(chip, alts, protocol, iface_no); + fp->clock = clock; /* some quirks for attributes here */ diff --git a/sound/usb/format.c b/sound/usb/format.c index fe29d61..5367cd1 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -29,6 +29,7 @@ #include "quirks.h" #include "helper.h" #include "debug.h" +#include "clock.h" /* * parse the audio format type I descriptor @@ -215,15 +216,17 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip, struct usb_device *dev = chip->dev; unsigned char tmp[2], *data; int i, nr_rates, data_size, ret = 0; + int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fp->clock); /* get the number of sample rates first by only fetching 2 bytes */ ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, - UAC2_CS_CONTROL_SAM_FREQ << 8, chip->clock_id << 8, + UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, tmp, sizeof(tmp), 1000); if (ret < 0) { - snd_printk(KERN_ERR "unable to retrieve number of sample rates\n"); + snd_printk(KERN_ERR "%s(): unable to retrieve number of sample rates (clock %d)\n", + __func__, clock); goto err; } @@ -237,12 +240,13 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip, /* now get the full information */ ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, - USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, - UAC2_CS_CONTROL_SAM_FREQ << 8, chip->clock_id << 8, - data, data_size, 1000); + USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, + UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, + data, data_size, 1000); if (ret < 0) { - snd_printk(KERN_ERR "unable to retrieve sample rate range\n"); + snd_printk(KERN_ERR "%s(): unable to retrieve sample rate range (clock %d)\n", + __func__, clock); ret = -EINVAL; goto err_free; } diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 056587d..4568298 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -31,6 +31,7 @@ #include "urb.h" #include "helper.h" #include "pcm.h" +#include "clock.h" /* * return the current pcm pointer. just based on the hwptr_done value. @@ -181,103 +182,6 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface, return -EINVAL; } -static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface, - struct usb_host_interface *alts, - struct audioformat *fmt, int rate) -{ - struct usb_device *dev = chip->dev; - unsigned int ep; - unsigned char data[3]; - int err, crate; - - ep = get_endpoint(alts, 0)->bEndpointAddress; - /* if endpoint doesn't have sampling rate control, bail out */ - if (!(fmt->attributes & UAC_EP_CS_ATTR_SAMPLE_RATE)) { - snd_printk(KERN_WARNING "%d:%d:%d: endpoint lacks sample rate attribute bit, cannot set.\n", - dev->devnum, iface, fmt->altsetting); - return 0; - } - - data[0] = rate; - data[1] = rate >> 8; - data[2] = rate >> 16; - if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR, - USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT, - UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, - data, sizeof(data), 1000)) < 0) { - snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n", - dev->devnum, iface, fmt->altsetting, rate, ep); - return err; - } - if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR, - USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN, - UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, - data, sizeof(data), 1000)) < 0) { - snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n", - dev->devnum, iface, fmt->altsetting, ep); - return 0; /* some devices don't support reading */ - } - crate = data[0] | (data[1] << 8) | (data[2] << 16); - if (crate != rate) { - snd_printd(KERN_WARNING "current rate %d is different from the runtime rate %d\n", crate, rate); - // runtime->rate = crate; - } - - return 0; -} - -static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, - struct usb_host_interface *alts, - struct audioformat *fmt, int rate) -{ - struct usb_device *dev = chip->dev; - unsigned char data[4]; - int err, crate; - - data[0] = rate; - data[1] = rate >> 8; - data[2] = rate >> 16; - data[3] = rate >> 24; - if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, - USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, - UAC2_CS_CONTROL_SAM_FREQ << 8, chip->clock_id << 8, - data, sizeof(data), 1000)) < 0) { - snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n", - dev->devnum, iface, fmt->altsetting, rate); - return err; - } - if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, - USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, - UAC2_CS_CONTROL_SAM_FREQ << 8, chip->clock_id << 8, - data, sizeof(data), 1000)) < 0) { - snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n", - dev->devnum, iface, fmt->altsetting); - return err; - } - crate = data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24); - if (crate != rate) - snd_printd(KERN_WARNING "current rate %d is different from the runtime rate %d\n", crate, rate); - - return 0; -} - -int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface, - struct usb_host_interface *alts, - struct audioformat *fmt, int rate) -{ - struct usb_interface_descriptor *altsd = get_iface_desc(alts); - - switch (altsd->bInterfaceProtocol) { - case UAC_VERSION_1: - return set_sample_rate_v1(chip, iface, alts, fmt, rate); - - case UAC_VERSION_2: - return set_sample_rate_v2(chip, iface, alts, fmt, rate); - } - - return -EINVAL; -} - /* * find a matching format and set up the interface */ diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index 06ebf24..24d3319 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -40,9 +40,6 @@ struct snd_usb_audio { int num_interfaces; int num_suspended_intf; - /* for audio class v2 */ - int clock_id; - struct list_head pcm_list; /* list of pcm streams */ int pcm_devs; @@ -53,6 +50,8 @@ struct snd_usb_audio { int setup; /* from the 'device_setup' module param */ int nrpacks; /* from the 'nrpacks' module param */ int async_unlink; /* from the 'async_unlink' module param */ + + struct usb_host_interface *ctrl_intf; /* the audio control interface */ }; /* -- cgit v1.1 From 65f25da44b51f55e3a74301c25f29263be2bf1ba Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 31 May 2010 13:35:41 +0200 Subject: ALSA: usb-audio: unify constants from specification Move more definitions from private enums to appropriate header files. Signed-off-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/mixer.c | 99 +++++++++++++++++--------------------------------- sound/usb/mixer_maps.c | 4 +- 2 files changed, 35 insertions(+), 68 deletions(-) (limited to 'sound') diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 9149a84..2442819 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -78,39 +78,6 @@ enum { USB_MIXER_U16, }; -enum { - USB_PROC_UPDOWN = 1, - USB_PROC_UPDOWN_SWITCH = 1, - USB_PROC_UPDOWN_MODE_SEL = 2, - - USB_PROC_PROLOGIC = 2, - USB_PROC_PROLOGIC_SWITCH = 1, - USB_PROC_PROLOGIC_MODE_SEL = 2, - - USB_PROC_3DENH = 3, - USB_PROC_3DENH_SWITCH = 1, - USB_PROC_3DENH_SPACE = 2, - - USB_PROC_REVERB = 4, - USB_PROC_REVERB_SWITCH = 1, - USB_PROC_REVERB_LEVEL = 2, - USB_PROC_REVERB_TIME = 3, - USB_PROC_REVERB_DELAY = 4, - - USB_PROC_CHORUS = 5, - USB_PROC_CHORUS_SWITCH = 1, - USB_PROC_CHORUS_LEVEL = 2, - USB_PROC_CHORUS_RATE = 3, - USB_PROC_CHORUS_DEPTH = 4, - - USB_PROC_DCR = 6, - USB_PROC_DCR_SWITCH = 1, - USB_PROC_DCR_RATIO = 2, - USB_PROC_DCR_MAX_AMP = 3, - USB_PROC_DCR_THRESHOLD = 4, - USB_PROC_DCR_ATTACK = 5, - USB_PROC_DCR_RELEASE = 6, -}; /*E-mu 0202(0404) eXtension Unit(XU) control*/ enum { @@ -980,7 +947,7 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, control++; /* change from zero-based to 1-based value */ - if (control == UAC_GRAPHIC_EQUALIZER_CONTROL) { + if (control == UAC_FU_GRAPHIC_EQUALIZER) { /* FIXME: not supported yet */ return; } @@ -1036,8 +1003,8 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, kctl->id.name, sizeof(kctl->id.name)); switch (control) { - case UAC_MUTE_CONTROL: - case UAC_VOLUME_CONTROL: + case UAC_FU_MUTE: + case UAC_FU_VOLUME: /* determine the control name. the rule is: * - if a name id is given in descriptor, use it. * - if the connected input can be determined, then use the name @@ -1064,9 +1031,9 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, len = append_ctl_name(kctl, " Playback"); } } - append_ctl_name(kctl, control == UAC_MUTE_CONTROL ? + append_ctl_name(kctl, control == UAC_FU_MUTE ? " Switch" : " Volume"); - if (control == UAC_VOLUME_CONTROL) { + if (control == UAC_FU_VOLUME) { kctl->tlv.c = mixer_vol_tlv; kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ | @@ -1165,7 +1132,7 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void snd_printk(KERN_INFO "usbmixer: master volume quirk for PCM2702 chip\n"); /* disable non-functional volume control */ - master_bits &= ~UAC_FU_VOLUME; + master_bits &= ~UAC_CONTROL_BIT(UAC_FU_VOLUME); break; } if (channels > 0) @@ -1410,51 +1377,51 @@ struct procunit_info { }; static struct procunit_value_info updown_proc_info[] = { - { USB_PROC_UPDOWN_SWITCH, "Switch", USB_MIXER_BOOLEAN }, - { USB_PROC_UPDOWN_MODE_SEL, "Mode Select", USB_MIXER_U8, 1 }, + { UAC_UD_ENABLE, "Switch", USB_MIXER_BOOLEAN }, + { UAC_UD_MODE_SELECT, "Mode Select", USB_MIXER_U8, 1 }, { 0 } }; static struct procunit_value_info prologic_proc_info[] = { - { USB_PROC_PROLOGIC_SWITCH, "Switch", USB_MIXER_BOOLEAN }, - { USB_PROC_PROLOGIC_MODE_SEL, "Mode Select", USB_MIXER_U8, 1 }, + { UAC_DP_ENABLE, "Switch", USB_MIXER_BOOLEAN }, + { UAC_DP_MODE_SELECT, "Mode Select", USB_MIXER_U8, 1 }, { 0 } }; static struct procunit_value_info threed_enh_proc_info[] = { - { USB_PROC_3DENH_SWITCH, "Switch", USB_MIXER_BOOLEAN }, - { USB_PROC_3DENH_SPACE, "Spaciousness", USB_MIXER_U8 }, + { UAC_3D_ENABLE, "Switch", USB_MIXER_BOOLEAN }, + { UAC_3D_SPACE, "Spaciousness", USB_MIXER_U8 }, { 0 } }; static struct procunit_value_info reverb_proc_info[] = { - { USB_PROC_REVERB_SWITCH, "Switch", USB_MIXER_BOOLEAN }, - { USB_PROC_REVERB_LEVEL, "Level", USB_MIXER_U8 }, - { USB_PROC_REVERB_TIME, "Time", USB_MIXER_U16 }, - { USB_PROC_REVERB_DELAY, "Delay", USB_MIXER_U8 }, + { UAC_REVERB_ENABLE, "Switch", USB_MIXER_BOOLEAN }, + { UAC_REVERB_LEVEL, "Level", USB_MIXER_U8 }, + { UAC_REVERB_TIME, "Time", USB_MIXER_U16 }, + { UAC_REVERB_FEEDBACK, "Feedback", USB_MIXER_U8 }, { 0 } }; static struct procunit_value_info chorus_proc_info[] = { - { USB_PROC_CHORUS_SWITCH, "Switch", USB_MIXER_BOOLEAN }, - { USB_PROC_CHORUS_LEVEL, "Level", USB_MIXER_U8 }, - { USB_PROC_CHORUS_RATE, "Rate", USB_MIXER_U16 }, - { USB_PROC_CHORUS_DEPTH, "Depth", USB_MIXER_U16 }, + { UAC_CHORUS_ENABLE, "Switch", USB_MIXER_BOOLEAN }, + { UAC_CHORUS_LEVEL, "Level", USB_MIXER_U8 }, + { UAC_CHORUS_RATE, "Rate", USB_MIXER_U16 }, + { UAC_CHORUS_DEPTH, "Depth", USB_MIXER_U16 }, { 0 } }; static struct procunit_value_info dcr_proc_info[] = { - { USB_PROC_DCR_SWITCH, "Switch", USB_MIXER_BOOLEAN }, - { USB_PROC_DCR_RATIO, "Ratio", USB_MIXER_U16 }, - { USB_PROC_DCR_MAX_AMP, "Max Amp", USB_MIXER_S16 }, - { USB_PROC_DCR_THRESHOLD, "Threshold", USB_MIXER_S16 }, - { USB_PROC_DCR_ATTACK, "Attack Time", USB_MIXER_U16 }, - { USB_PROC_DCR_RELEASE, "Release Time", USB_MIXER_U16 }, + { UAC_DCR_ENABLE, "Switch", USB_MIXER_BOOLEAN }, + { UAC_DCR_RATE, "Ratio", USB_MIXER_U16 }, + { UAC_DCR_MAXAMPL, "Max Amp", USB_MIXER_S16 }, + { UAC_DCR_THRESHOLD, "Threshold", USB_MIXER_S16 }, + { UAC_DCR_ATTACK_TIME, "Attack Time", USB_MIXER_U16 }, + { UAC_DCR_RELEASE_TIME, "Release Time", USB_MIXER_U16 }, { 0 } }; static struct procunit_info procunits[] = { - { USB_PROC_UPDOWN, "Up Down", updown_proc_info }, - { USB_PROC_PROLOGIC, "Dolby Prologic", prologic_proc_info }, - { USB_PROC_3DENH, "3D Stereo Extender", threed_enh_proc_info }, - { USB_PROC_REVERB, "Reverb", reverb_proc_info }, - { USB_PROC_CHORUS, "Chorus", chorus_proc_info }, - { USB_PROC_DCR, "DCR", dcr_proc_info }, + { UAC_PROCESS_UP_DOWNMIX, "Up Down", updown_proc_info }, + { UAC_PROCESS_DOLBY_PROLOGIC, "Dolby Prologic", prologic_proc_info }, + { UAC_PROCESS_STEREO_EXTENDER, "3D Stereo Extender", threed_enh_proc_info }, + { UAC_PROCESS_REVERB, "Reverb", reverb_proc_info }, + { UAC_PROCESS_CHORUS, "Chorus", chorus_proc_info }, + { UAC_PROCESS_DYN_RANGE_COMP, "DCR", dcr_proc_info }, { 0 }, }; /* @@ -1542,7 +1509,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid, void *raw cval->channels = 1; /* get min/max values */ - if (type == USB_PROC_UPDOWN && cval->control == USB_PROC_UPDOWN_MODE_SEL) { + if (type == UAC_PROCESS_UP_DOWNMIX && cval->control == UAC_UD_MODE_SELECT) { __u8 *control_spec = uac_processing_unit_specific(desc, state->mixer->protocol); /* FIXME: hard-coded */ cval->min = 1; diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c index d93fc89..f1324c4 100644 --- a/sound/usb/mixer_maps.c +++ b/sound/usb/mixer_maps.c @@ -85,8 +85,8 @@ static struct usbmix_name_map extigy_map[] = { /* 16: MU (w/o controls) */ { 17, NULL, 1 }, /* DISABLED: PU-switch (any effect?) */ { 17, "Channel Routing", 2 }, /* PU: mode select */ - { 18, "Tone Control - Bass", UAC_BASS_CONTROL }, /* FU */ - { 18, "Tone Control - Treble", UAC_TREBLE_CONTROL }, /* FU */ + { 18, "Tone Control - Bass", UAC_FU_BASS }, /* FU */ + { 18, "Tone Control - Treble", UAC_FU_TREBLE }, /* FU */ { 18, "Master Playback" }, /* FU; others */ /* 19: OT speaker */ /* 20: OT headphone */ -- cgit v1.1 From 2e0281d15c220d0a81c45c73872aa08d2f3ae3ef Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 31 May 2010 13:35:42 +0200 Subject: ALSA: usb-audio: add UAC2 sepecific Feature Unit controls The bits to enable them are always 0 for UAC1 devices, so no additional checks are required. Signed-off-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/mixer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 2442819..8be6bf2 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -686,16 +686,20 @@ struct usb_feature_control_info { }; static struct usb_feature_control_info audio_feature_info[] = { - { "Mute", USB_MIXER_INV_BOOLEAN }, - { "Volume", USB_MIXER_S16 }, + { "Mute", USB_MIXER_INV_BOOLEAN }, + { "Volume", USB_MIXER_S16 }, { "Tone Control - Bass", USB_MIXER_S8 }, { "Tone Control - Mid", USB_MIXER_S8 }, { "Tone Control - Treble", USB_MIXER_S8 }, { "Graphic Equalizer", USB_MIXER_S8 }, /* FIXME: not implemeted yet */ - { "Auto Gain Control", USB_MIXER_BOOLEAN }, - { "Delay Control", USB_MIXER_U16 }, - { "Bass Boost", USB_MIXER_BOOLEAN }, - { "Loudness", USB_MIXER_BOOLEAN }, + { "Auto Gain Control", USB_MIXER_BOOLEAN }, + { "Delay Control", USB_MIXER_U16 }, + { "Bass Boost", USB_MIXER_BOOLEAN }, + { "Loudness", USB_MIXER_BOOLEAN }, + /* UAC2 specific */ + { "Input Gain Control", USB_MIXER_U16 }, + { "Input Gain Pad Control", USB_MIXER_BOOLEAN }, + { "Phase Inverter Control", USB_MIXER_BOOLEAN }, }; -- cgit v1.1 From 67e1daa0bb30eda6ec5add27c3abf4536030f5a6 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 31 May 2010 13:35:43 +0200 Subject: ALSA: usb-audio: clean up find_audio_control_unit() Use a struct to parse the audio units, and return usable descriptors for all types. There's no need to limit the result set, except for some kind of sanity check. Signed-off-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/mixer.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 8be6bf2..cb345360 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -165,22 +165,24 @@ static int check_mapped_selector_name(struct mixer_build *state, int unitid, /* * find an audio control unit with the given unit id - * this doesn't return any clock related units, so they need to be handled elsewhere */ static void *find_audio_control_unit(struct mixer_build *state, unsigned char unit) { - unsigned char *p; + /* we just parse the header */ + struct uac_feature_unit_descriptor *hdr = NULL; - p = NULL; - while ((p = snd_usb_find_desc(state->buffer, state->buflen, p, - USB_DT_CS_INTERFACE)) != NULL) { - if (p[0] >= 4 && p[2] >= UAC_INPUT_TERMINAL && p[2] <= UAC2_EXTENSION_UNIT_V2 && p[3] == unit) - return p; + while ((hdr = snd_usb_find_desc(state->buffer, state->buflen, hdr, + USB_DT_CS_INTERFACE)) != NULL) { + if (hdr->bLength >= 4 && + hdr->bDescriptorSubtype >= UAC_INPUT_TERMINAL && + hdr->bDescriptorSubtype <= UAC2_SAMPLE_RATE_CONVERTER && + hdr->bUnitID == unit) + return hdr; } + return NULL; } - /* * copy a string with the given id */ -- cgit v1.1 From 09414207d4daab8c4990bface3a79fdba3474bec Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 31 May 2010 13:35:44 +0200 Subject: ALSA: usb-audio: export UAC2 clock selectors as mixer controls The UAC2 clock selectors are fortunately compatible with UAC1 audio selector units, so we can simply reuse the same approach to get all the linked units. Requests to this control need a different CS value though. Signed-off-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/mixer.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index cb345360..a060d00 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -313,8 +313,8 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v buf, sizeof(buf), 1000); if (ret < 0) { - snd_printdd(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", - request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type); + snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", + request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type); return ret; } @@ -610,6 +610,7 @@ static int get_term_name(struct mixer_build *state, struct usb_audio_term *iterm */ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_term *term) { + int err; void *p1; memset(term, 0, sizeof(*term)); @@ -630,6 +631,11 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_ term->channels = d->bNrChannels; term->chconfig = le32_to_cpu(d->bmChannelConfig); term->name = d->iTerminal; + + /* call recursively to get the clock selectors */ + err = check_input_term(state, d->bCSourceID, term); + if (err < 0) + return err; } return 0; case UAC_FEATURE_UNIT: { @@ -646,7 +652,8 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_ term->name = uac_mixer_unit_iMixer(d); return 0; } - case UAC_SELECTOR_UNIT: { + case UAC_SELECTOR_UNIT: + case UAC2_CLOCK_SELECTOR: { struct uac_selector_unit_descriptor *d = p1; /* call recursively to retrieve the channel info */ if (check_input_term(state, d->baSourceID[0], term) < 0) @@ -669,6 +676,13 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_ term->name = uac_processing_unit_iProcessing(d, state->mixer->protocol); return 0; } + case UAC2_CLOCK_SOURCE: { + struct uac_clock_source_descriptor *d = p1; + term->type = d->bDescriptorSubtype << 16; /* virtual type */ + term->id = id; + term->name = d->iClockSource; + return 0; + } default: return -ENODEV; } @@ -1610,7 +1624,7 @@ static int mixer_ctl_selector_get(struct snd_kcontrol *kcontrol, struct snd_ctl_ struct usb_mixer_elem_info *cval = kcontrol->private_data; int val, err; - err = get_cur_ctl_value(cval, 0, &val); + err = get_cur_ctl_value(cval, cval->control << 8, &val); if (err < 0) { if (cval->mixer->ignore_ctl_error) { ucontrol->value.enumerated.item[0] = 0; @@ -1629,7 +1643,7 @@ static int mixer_ctl_selector_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ struct usb_mixer_elem_info *cval = kcontrol->private_data; int val, oval, err; - err = get_cur_ctl_value(cval, 0, &oval); + err = get_cur_ctl_value(cval, cval->control << 8, &oval); if (err < 0) { if (cval->mixer->ignore_ctl_error) return 0; @@ -1638,7 +1652,7 @@ static int mixer_ctl_selector_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ val = ucontrol->value.enumerated.item[0]; val = get_abs_value(cval, val); if (val != oval) { - set_cur_ctl_value(cval, 0, val); + set_cur_ctl_value(cval, cval->control << 8, val); return 1; } return 0; @@ -1720,6 +1734,11 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void cval->res = 1; cval->initialized = 1; + if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) + cval->control = UAC2_CX_CLOCK_SELECTOR; + else + cval->control = 0; + namelist = kmalloc(sizeof(char *) * desc->bNrInPins, GFP_KERNEL); if (! namelist) { snd_printk(KERN_ERR "cannot malloc\n"); @@ -1769,7 +1788,9 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, void if (! len) strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name)); - if ((state->oterm.type & 0xff00) == 0x0100) + if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) + append_ctl_name(kctl, " Clock Source"); + else if ((state->oterm.type & 0xff00) == 0x0100) append_ctl_name(kctl, " Capture Source"); else append_ctl_name(kctl, " Playback Source"); @@ -1803,10 +1824,12 @@ static int parse_audio_unit(struct mixer_build *state, int unitid) switch (p1[2]) { case UAC_INPUT_TERMINAL: + case UAC2_CLOCK_SOURCE: return 0; /* NOP */ case UAC_MIXER_UNIT: return parse_audio_mixer_unit(state, unitid, p1); case UAC_SELECTOR_UNIT: + case UAC2_CLOCK_SELECTOR: return parse_audio_selector_unit(state, unitid, p1); case UAC_FEATURE_UNIT: return parse_audio_feature_unit(state, unitid, p1); @@ -1903,6 +1926,11 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) err = parse_audio_unit(&state, desc->bSourceID); if (err < 0) return err; + + /* for UAC2, use the same approach to also add the clock selectors */ + err = parse_audio_unit(&state, desc->bCSourceID); + if (err < 0) + return err; } } -- cgit v1.1 From 9f75c1b12c5ef392ddcea575b13560842c28b1b3 Mon Sep 17 00:00:00 2001 From: Daniel T Chen Date: Sun, 30 May 2010 13:08:41 -0400 Subject: ALSA: hda: Use LPIB for ASUS M2V BugLink: https://launchpad.net/bugs/587546 Symptom: On the reporter's ASUS M2V, using PulseAudio in Ubuntu 10.04 LTS results in the PA daemon crashing shortly after attempting playback of an audio file. Test case: Using Ubuntu 10.04 LTS (Linux 2.6.32.12), Linux 2.6.33, or Linux 2.6.34, attempt playback of an audio file while PulseAudio is active. Resolution: add SSID for this machine to the position_fix quirk table, explicitly specifying the LPIB method. Reported-and-Tested-By: D Tangman Cc: Signed-off-by: Daniel T Chen Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 1640005..e42ab99 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2289,6 +2289,7 @@ static struct snd_pci_quirk position_fix_list[] __devinitdata = { SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB), SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB), + SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS M2V", POS_FIX_LPIB), SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB), SND_PCI_QUIRK(0x1106, 0x3288, "ASUS M2V-MX SE", POS_FIX_LPIB), SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba A100-259", POS_FIX_LPIB), -- cgit v1.1 From c2cdf6aba0dfcfb54be646ab630c1bccd180e890 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 2 Jun 2010 17:09:18 +1000 Subject: powerpc/macio: Fix probing of macio devices by using the right of match table Grant patches added an of mach table to struct device_driver. However, while he changed the macio device code to use that, he left the match table pointer in struct macio_driver and didn't update drivers to use the "new" one, thus breaking the probing. This completes the change by moving all drivers to setup the "new" one, removing all traces of the old one, and while at it (since it changes the exact same locations), I also remove two other duplicates from struct driver which are the name and owner fields. Signed-off-by: Benjamin Herrenschmidt --- sound/aoa/soundbus/i2sbus/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/aoa/soundbus/i2sbus/core.c b/sound/aoa/soundbus/i2sbus/core.c index 6789337..3ff8cc5 100644 --- a/sound/aoa/soundbus/i2sbus/core.c +++ b/sound/aoa/soundbus/i2sbus/core.c @@ -437,9 +437,11 @@ static int i2sbus_shutdown(struct macio_dev* dev) } static struct macio_driver i2sbus_drv = { - .name = "soundbus-i2s", - .owner = THIS_MODULE, - .match_table = i2sbus_match, + .driver = { + .name = "soundbus-i2s", + .owner = THIS_MODULE, + .of_match_table = i2sbus_match, + }, .probe = i2sbus_probe, .remove = i2sbus_remove, #ifdef CONFIG_PM -- cgit v1.1 From 21896bc010c17e5ac58951e771496ec2fb1051ed Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 2 Jun 2010 12:08:37 +0200 Subject: ALSA: asihpi - Fix uninitialized variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Initialize prev_ctl properly before reference: sound/pci/asihpi/asihpi.c: In function ‘snd_card_asihpi_mixer_new’: sound/pci/asihpi/asihpi.c:2568:30: warning: ‘prev_ctl.dst_node_index’ may be used uninitialized in this function Signed-off-by: Takashi Iwai --- sound/pci/asihpi/asihpi.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound') diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index f74c737..1db586a 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c @@ -2578,6 +2578,9 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) if (err) return -err; + memset(&prev_ctl, 0, sizeof(prev_ctl)); + prev_ctl.control_type = -1; + for (idx = 0; idx < 2000; idx++) { err = hpi_mixer_get_control_by_index( ss, asihpi->h_mixer, -- cgit v1.1 From edb39935c8b19fcd9a8f619d0bc1e9d04594cd2b Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 2 Jun 2010 13:29:17 +0200 Subject: ALSA: hda-intel - fix wallclk variable update and condition This patch fixes thinko introduced in "last minutes" before commiting of the last wallclk patch. It also fixes the condition checking if the first period after last wallclk update is processed. There is a little rounding error in period_wallclk. Signed-off-by: Jaroslav Kysela --- sound/pci/hda/hda_intel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index dc79564..af701a8 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1913,11 +1913,11 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev) if (WARN_ONCE(!azx_dev->period_bytes, "hda-intel: zero azx_dev->period_bytes")) return -1; /* this shouldn't happen! */ - if (wallclk <= azx_dev->period_wallclk && + if (wallclk < (azx_dev->period_wallclk * 5) / 4 && pos % azx_dev->period_bytes > azx_dev->period_bytes / 2) /* NG - it's below the first next period boundary */ return bdl_pos_adj[chip->dev_index] ? 0 : -1; - azx_dev->start_wallclk = wallclk; + azx_dev->start_wallclk += wallclk; return 1; /* OK, it's fine */ } -- cgit v1.1 From 8fc6d4186e0a60b3755a6b88bf67a3ac3214dcc3 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 2 Jun 2010 13:29:17 +0200 Subject: ALSA: hda-intel - fix wallclk variable update and condition This patch fixes thinko introduced in "last minutes" before commiting of the last wallclk patch. It also fixes the condition checking if the first period after last wallclk update is processed. There is a little rounding error in period_wallclk. Signed-off-by: Jaroslav Kysela --- sound/pci/hda/hda_intel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index dc79564..af701a8 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1913,11 +1913,11 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev) if (WARN_ONCE(!azx_dev->period_bytes, "hda-intel: zero azx_dev->period_bytes")) return -1; /* this shouldn't happen! */ - if (wallclk <= azx_dev->period_wallclk && + if (wallclk < (azx_dev->period_wallclk * 5) / 4 && pos % azx_dev->period_bytes > azx_dev->period_bytes / 2) /* NG - it's below the first next period boundary */ return bdl_pos_adj[chip->dev_index] ? 0 : -1; - azx_dev->start_wallclk = wallclk; + azx_dev->start_wallclk += wallclk; return 1; /* OK, it's fine */ } -- cgit v1.1 From f534116308a0d553641725c4619814337758784f Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Tue, 8 Jun 2010 08:57:13 +0200 Subject: ALSA: atmel: set "channel A event" output to debug Signed-off-by: Yegor Yefremov Signed-off-by: Takashi Iwai --- sound/atmel/ac97c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 428121a..10c3a87 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -657,7 +657,7 @@ static irqreturn_t atmel_ac97c_interrupt(int irq, void *dev) if (sr & AC97C_SR_CAEVT) { struct snd_pcm_runtime *runtime; int offset, next_period, block_size; - dev_info(&chip->pdev->dev, "channel A event%s%s%s%s%s%s\n", + dev_dbg(&chip->pdev->dev, "channel A event%s%s%s%s%s%s\n", casr & AC97C_CSR_OVRUN ? " OVRUN" : "", casr & AC97C_CSR_RXRDY ? " RXRDY" : "", casr & AC97C_CSR_UNRUN ? " UNRUN" : "", -- cgit v1.1 From 6e12970bd4f453c9cfcac6564567efe515ce1f1d Mon Sep 17 00:00:00 2001 From: "Justin P. Mattock" Date: Sun, 6 Jun 2010 16:09:49 -0700 Subject: ALSA: hda - Add SSID table for MacBookAir2,1 This adds the SSID number to snd_pci_quirk for the MacBookAir2,1 taken from codec#0 at: http://launchpadlibrarian.net/49455483/Card0.Codecs.codec.0.txt keep in mind I do not have one of these machines on hand so please if you do have this machine please test for me.. Signed-off-by: Justin P. Mattock Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index d792cdd..f266c54 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -9477,6 +9477,7 @@ static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = { SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24), SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3), SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31), + SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21), SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31), SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3), SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24), -- cgit v1.1 From f53dae28cd17ec618a1295962d0f40e00b84665d Mon Sep 17 00:00:00 2001 From: "Justin P. Mattock" Date: Sun, 6 Jun 2010 16:09:51 -0700 Subject: ALSA: hda - Add SSID table for MacBookAir1,1 This patch add's the MacBookAir1,1 SSID entry to patch_realtek.c which adds sound support. bug entry: https://bugs.launchpad.net/mactel-support/+bug/268301 Note:I do not have this machine on hand only codec#0 file for the machine so please test if you have the appropriate equipment. Signed-off-by: Justin P. Mattock Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index f266c54..9df3c08 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -9477,6 +9477,7 @@ static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = { SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24), SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3), SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31), + SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3), SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21), SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31), SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3), -- cgit v1.1 From ab669967d0ecf784567843180e715ccb0e42db36 Mon Sep 17 00:00:00 2001 From: "Justin P. Mattock" Date: Sun, 6 Jun 2010 16:09:53 -0700 Subject: ALSA: hda - Add SSID table for iMac7,1. This patch add's the iMac7,1 SSID entry to patch_realtek.c which adds sound support. bug entry: https://bugs.launchpad.net/mactel-support/+bug/360866 Note:I do not have this machine on hand only codec#0 file for the machine so please test if you have the appropriate equipment. Signed-off-by: Justin P. Mattock Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 9df3c08..fc767b6 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -9477,6 +9477,7 @@ static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = { SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24), SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3), SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31), + SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M), SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3), SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21), SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31), -- cgit v1.1 From ff8bd64eaf2963752feaa0ac2f7ff1254e0091ce Mon Sep 17 00:00:00 2001 From: Wan ZongShun Date: Tue, 8 Jun 2010 16:51:27 +0200 Subject: ALSA: sound/spi: patch for the unuseful variable removal The '*bitclk' of structure 'snd_at73c213' seems no use, so I make a patch to remove the unnecessary variable. Signed-off-by: Wan ZongShun Acked-by: Liam Girdwood Signed-off-by: Takashi Iwai --- sound/spi/at73c213.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c index 4c7b051..1bc56b2 100644 --- a/sound/spi/at73c213.c +++ b/sound/spi/at73c213.c @@ -69,7 +69,6 @@ struct snd_at73c213 { int irq; int period; unsigned long bitrate; - struct clk *bitclk; struct ssc_device *ssc; struct spi_device *spi; u8 spi_wbuffer[2]; -- cgit v1.1 From fbe618f216830f47b183858c3380d4767b1ad02f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 11 Jun 2010 11:24:58 +0200 Subject: ALSA: hda - Don't check capture source mixer if no ADC is available With multiple codec configurations, some codec might have no ADC, thus it keeps spec->adc_nids = NULL. This causes an Oops in alc_build_controls(). Reference: kernel bug #16156 https://bugzilla.kernel.org/show_bug.cgi?id=16156 Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index fc767b6..f6cd8ed 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -2619,16 +2619,18 @@ static int alc_build_controls(struct hda_codec *codec) } /* assign Capture Source enums to NID */ - kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); - if (!kctl) - kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); - for (i = 0; kctl && i < kctl->count; i++) { - hda_nid_t *nids = spec->capsrc_nids; - if (!nids) - nids = spec->adc_nids; - err = snd_hda_add_nid(codec, kctl, i, nids[i]); - if (err < 0) - return err; + if (spec->capsrc_nids || spec->adc_nids) { + kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); + if (!kctl) + kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); + for (i = 0; kctl && i < kctl->count; i++) { + hda_nid_t *nids = spec->capsrc_nids; + if (!nids) + nids = spec->adc_nids; + err = snd_hda_add_nid(codec, kctl, i, nids[i]); + if (err < 0) + return err; + } } if (spec->cap_mixer) { const char *kname = kctl ? kctl->id.name : NULL; -- cgit v1.1 From d07140ba7fe1b41713627c6dc3f169a00019fb0e Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Fri, 11 Jun 2010 17:34:19 +0200 Subject: ALSA: usb-audio: add check for faulty clock in parse_audio_format_rates_v2() Signed-off-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/format.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sound') diff --git a/sound/usb/format.c b/sound/usb/format.c index 5367cd1..df5b29f 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -218,6 +218,12 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip, int i, nr_rates, data_size, ret = 0; int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fp->clock); + if (clock < 0) { + snd_printk(KERN_ERR "%s(): unable to find clock source (clock %d)\n", + __func__, clock); + goto err; + } + /* get the number of sample rates first by only fetching 2 bytes */ ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, -- cgit v1.1 From 11bcbc443a17653c65bc20029172fae76f4bcca4 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Fri, 11 Jun 2010 17:34:20 +0200 Subject: ALSA: usb-audio: fix control messages for USB_RECIP_INTERFACE Control messages directed to an interface must have the interface number set in the lower 8 bits of wIndex. This wasn't done correctly for some clock and mixer messages. Signed-off-by: Daniel Mack Reported-by: Alex Lee Signed-off-by: Takashi Iwai --- sound/usb/clock.c | 12 ++++++++---- sound/usb/format.c | 6 ++++-- sound/usb/helper.h | 4 ++++ 3 files changed, 16 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/usb/clock.c b/sound/usb/clock.c index b7aadd6..b585511 100644 --- a/sound/usb/clock.c +++ b/sound/usb/clock.c @@ -103,7 +103,8 @@ static int uac_clock_selector_get_val(struct snd_usb_audio *chip, int selector_i ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), UAC2_CS_CUR, USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, - UAC2_CX_CLOCK_SELECTOR << 8, selector_id << 8, + UAC2_CX_CLOCK_SELECTOR << 8, + snd_usb_ctrl_intf(chip) | (selector_id << 8), &buf, sizeof(buf), 1000); if (ret < 0) @@ -120,7 +121,8 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id) err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, - UAC2_CS_CONTROL_CLOCK_VALID << 8, source_id << 8, + UAC2_CS_CONTROL_CLOCK_VALID << 8, + snd_usb_ctrl_intf(chip) | (source_id << 8), &data, sizeof(data), 1000); if (err < 0) { @@ -269,7 +271,8 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, data[3] = rate >> 24; if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC2_CS_CUR, USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, - UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, + UAC2_CS_CONTROL_SAM_FREQ << 8, + snd_usb_ctrl_intf(chip) | (clock << 8), data, sizeof(data), 1000)) < 0) { snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2)\n", dev->devnum, iface, fmt->altsetting, rate); @@ -278,7 +281,8 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_CUR, USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, - UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, + UAC2_CS_CONTROL_SAM_FREQ << 8, + snd_usb_ctrl_intf(chip) | (clock << 8), data, sizeof(data), 1000)) < 0) { snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2)\n", dev->devnum, iface, fmt->altsetting); diff --git a/sound/usb/format.c b/sound/usb/format.c index df5b29f..8eccf17 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -227,7 +227,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip, /* get the number of sample rates first by only fetching 2 bytes */ ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, - UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, + UAC2_CS_CONTROL_SAM_FREQ << 8, + snd_usb_ctrl_intf(chip) | (clock << 8), tmp, sizeof(tmp), 1000); if (ret < 0) { @@ -247,7 +248,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip, /* now get the full information */ ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC2_CS_RANGE, USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, - UAC2_CS_CONTROL_SAM_FREQ << 8, clock << 8, + UAC2_CS_CONTROL_SAM_FREQ << 8, + snd_usb_ctrl_intf(chip) | (clock << 8), data, data_size, 1000); if (ret < 0) { diff --git a/sound/usb/helper.h b/sound/usb/helper.h index a6b0e51..09bd943 100644 --- a/sound/usb/helper.h +++ b/sound/usb/helper.h @@ -28,5 +28,9 @@ unsigned char snd_usb_parse_datainterval(struct snd_usb_audio *chip, #define snd_usb_get_speed(dev) ((dev)->speed) #endif +static inline int snd_usb_ctrl_intf(struct snd_usb_audio *chip) +{ + return get_iface_desc(chip->ctrl_intf)->bInterfaceNumber; +} #endif /* __USBAUDIO_HELPER_H */ -- cgit v1.1 From 67c103664a06fa590f2990c01773dfa1dffcefdc Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Fri, 11 Jun 2010 17:46:33 +0200 Subject: ALSA: usb-audio: parse UAC2 sample rate ranges correctly A device may report its supported sample rates in ranges rather than in discrete triplets. The code used to only parse the MIN field instead of properly paying attention to the MAX and RES values. Also, handle RES values of 1 correctly and announce a continous sample rate range in this case. Signed-off-by: Daniel Mack Reported-by: Alex Lee Signed-off-by: Takashi Iwai --- sound/usb/format.c | 92 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 74 insertions(+), 18 deletions(-) (limited to 'sound') diff --git a/sound/usb/format.c b/sound/usb/format.c index 8eccf17..30364ab 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -206,6 +206,60 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof } /* + * Helper function to walk the array of sample rate triplets reported by + * the device. The problem is that we need to parse whole array first to + * get to know how many sample rates we have to expect. + * Then fp->rate_table can be allocated and filled. + */ +static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets, + const unsigned char *data) +{ + int i, nr_rates = 0; + + fp->rates = fp->rate_min = fp->rate_max = 0; + + for (i = 0; i < nr_triplets; i++) { + int min = combine_quad(&data[2 + 12 * i]); + int max = combine_quad(&data[6 + 12 * i]); + int res = combine_quad(&data[10 + 12 * i]); + int rate; + + if ((max < 0) || (min < 0) || (res < 0) || (max < min)) + continue; + + /* + * for ranges with res == 1, we announce a continuous sample + * rate range, and this function should return 0 for no further + * parsing. + */ + if (res == 1) { + fp->rate_min = min; + fp->rate_max = max; + fp->rates = SNDRV_PCM_RATE_CONTINUOUS; + return 0; + } + + for (rate = min; rate <= max; rate += res) { + if (fp->rate_table) + fp->rate_table[nr_rates] = rate; + if (!fp->rate_min || rate < fp->rate_min) + fp->rate_min = rate; + if (!fp->rate_max || rate > fp->rate_max) + fp->rate_max = rate; + fp->rates |= snd_pcm_rate_to_rate_bit(rate); + + nr_rates++; + + /* avoid endless loop */ + if (res == 0) + break; + } + } + + return nr_rates; +} + +/* * parse the format descriptor and stores the possible sample rates * on the audioformat table (audio class v2). */ @@ -215,7 +269,7 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip, { struct usb_device *dev = chip->dev; unsigned char tmp[2], *data; - int i, nr_rates, data_size, ret = 0; + int nr_triplets, data_size, ret = 0; int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fp->clock); if (clock < 0) { @@ -237,8 +291,8 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip, goto err; } - nr_rates = (tmp[1] << 8) | tmp[0]; - data_size = 2 + 12 * nr_rates; + nr_triplets = (tmp[1] << 8) | tmp[0]; + data_size = 2 + 12 * nr_triplets; data = kzalloc(data_size, GFP_KERNEL); if (!data) { ret = -ENOMEM; @@ -259,26 +313,28 @@ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip, goto err_free; } - fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); + /* Call the triplet parser, and make sure fp->rate_table is NULL. + * We just use the return value to know how many sample rates we + * will have to deal with. */ + kfree(fp->rate_table); + fp->rate_table = NULL; + fp->nr_rates = parse_uac2_sample_rate_range(fp, nr_triplets, data); + + if (fp->nr_rates == 0) { + /* SNDRV_PCM_RATE_CONTINUOUS */ + ret = 0; + goto err_free; + } + + fp->rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL); if (!fp->rate_table) { ret = -ENOMEM; goto err_free; } - fp->nr_rates = 0; - fp->rate_min = fp->rate_max = 0; - - for (i = 0; i < nr_rates; i++) { - int rate = combine_quad(&data[2 + 12 * i]); - - fp->rate_table[fp->nr_rates] = rate; - if (!fp->rate_min || rate < fp->rate_min) - fp->rate_min = rate; - if (!fp->rate_max || rate > fp->rate_max) - fp->rate_max = rate; - fp->rates |= snd_pcm_rate_to_rate_bit(rate); - fp->nr_rates++; - } + /* Call the triplet parser again, but this time, fp->rate_table is + * allocated, so the rates will be stored */ + parse_uac2_sample_rate_range(fp, nr_triplets, data); err_free: kfree(data); -- cgit v1.1 From e8bdb6bbab60a8731f21823c86391f176d052348 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Fri, 11 Jun 2010 17:34:22 +0200 Subject: ALSA: usb-audio: fix UAC2 control value queries For RANGE requests, we should only query as much bytes as we're in fact interested in. For CUR requests, we shouldn't confuse the firmware with an overlong request but just ask for 2 bytes. This might need fixing in the future as it's not entirely clear when to dispatch 1-byte, 2-byte and 4-byte request blocks. For now, we assume everything is coded in 16bit - this works for all firmware implementations I've seen. Signed-off-by: Daniel Mack Reported-by: Alex Lee Signed-off-by: Takashi Iwai --- sound/usb/mixer.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index a060d00..6939d0f5 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -297,20 +297,27 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) { - unsigned char buf[14]; /* enough space for one range of 4 bytes */ + unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */ unsigned char *val; - int ret; + int ret, size; __u8 bRequest; - bRequest = (request == UAC_GET_CUR) ? - UAC2_CS_CUR : UAC2_CS_RANGE; + if (request == UAC_GET_CUR) { + bRequest = UAC2_CS_CUR; + size = sizeof(__u16); + } else { + bRequest = UAC2_CS_RANGE; + size = sizeof(buf); + } + + memset(buf, 0, sizeof(buf)); ret = snd_usb_ctl_msg(cval->mixer->chip->dev, usb_rcvctrlpipe(cval->mixer->chip->dev, 0), bRequest, USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, validx, cval->mixer->ctrlif | (cval->id << 8), - buf, sizeof(buf), 1000); + buf, size, 1000); if (ret < 0) { snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", @@ -318,6 +325,8 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v return ret; } + /* FIXME: how should we handle multiple triplets here? */ + switch (request) { case UAC_GET_CUR: val = buf; -- cgit v1.1 From b8f171e7e7ed5c9b77324bcc6bb580ddcc84da49 Mon Sep 17 00:00:00 2001 From: Alex Murray Date: Mon, 14 Jun 2010 12:08:43 +0930 Subject: ALSA: hda - Fix line-in for mb5 model MacBook (Pro) 5,1 / 5,2 The line-in input is 0x7 not 0x2 for MacBook (Pro) 5,1 / 5,2 models Signed-off-by: Alex Murray Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index f6cd8ed..f1ce7d7 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -6950,7 +6950,7 @@ static struct hda_input_mux mb5_capture_source = { .num_items = 3, .items = { { "Mic", 0x1 }, - { "Line", 0x2 }, + { "Line", 0x7 }, { "CD", 0x4 }, }, }; @@ -7471,8 +7471,8 @@ static struct snd_kcontrol_new alc885_mb5_mixer[] = { HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT), HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT), HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT), - HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), - HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT), + HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT), HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT), @@ -7855,10 +7855,9 @@ static struct hda_verb alc885_mb5_init_verbs[] = { {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, - {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, - {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, - {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)}, { } }; -- cgit v1.1 From f487537c2b6b23332bbea7ecb1fe793b6c74d5b2 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Mon, 14 Jun 2010 00:03:34 -0600 Subject: powerpc/5200: Fix build error in sound code. Compiling in the MPC5200 sound drivers results in the following build error: sound/soc/fsl/mpc5200_psc_ac97.o: In function `to_psc_dma_stream': mpc5200_psc_ac97.c:(.text+0x0): multiple definition of `to_psc_dma_stream' sound/soc/fsl/mpc5200_dma.o:mpc5200_dma.c:(.text+0x0): first defined here sound/soc/fsl/efika-audio-fabric.o: In function `to_psc_dma_stream': efika-audio-fabric.c:(.text+0x0): multiple definition of `to_psc_dma_stream' sound/soc/fsl/mpc5200_dma.o:mpc5200_dma.c:(.text+0x0): first defined here make[3]: *** [sound/soc/fsl/built-in.o] Error 1 make[2]: *** [sound/soc/fsl] Error 2 make[1]: *** [sound/soc] Error 2 make: *** [sound] Error 2 This patch fixes it by declaring the inline function in the header file to also be a static. Signed-off-by: Grant Likely Cc: Jon Smirl Tested-by: John Hilmar Linkhorst Acked-by: Mark Brown --- sound/soc/fsl/mpc5200_dma.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h index 22208b3..e1ec6d9 100644 --- a/sound/soc/fsl/mpc5200_dma.h +++ b/sound/soc/fsl/mpc5200_dma.h @@ -73,7 +73,7 @@ struct psc_dma { }; /* Utility for retrieving psc_dma_stream structure from a substream */ -inline struct psc_dma_stream * +static inline struct psc_dma_stream * to_psc_dma_stream(struct snd_pcm_substream *substream, struct psc_dma *psc_dma) { if (substream->pstr->stream == SNDRV_PCM_STREAM_CAPTURE) -- cgit v1.1 From 421f91d21ad6f799dc7b489bb33cc560ccc56f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Fri, 11 Jun 2010 12:17:00 +0200 Subject: fix typos concerning "initiali[zs]e" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-König Signed-off-by: Jiri Kosina --- sound/pci/trident/trident_main.c | 2 +- sound/soc/fsl/mpc8610_hpcd.c | 2 +- sound/soc/soc-core.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 6d943f6..2870a4f 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -1055,7 +1055,7 @@ static int snd_trident_capture_prepare(struct snd_pcm_substream *substream) spin_lock_irq(&trident->reg_lock); - // Initilize the channel and set channel Mode + // Initialize the channel and set channel Mode outb(0, TRID_REG(trident, LEGACY_DMAR15)); // Set DMA channel operation mode register diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c index 83de1c8..604a91f 100644 --- a/sound/soc/fsl/mpc8610_hpcd.c +++ b/sound/soc/fsl/mpc8610_hpcd.c @@ -46,7 +46,7 @@ struct mpc8610_hpcd_data { }; /** - * mpc8610_hpcd_machine_probe: initalize the board + * mpc8610_hpcd_machine_probe: initialize the board * * This function is called when platform_device_add() is called. It is used * to initialize the board-specific hardware. diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 998569d..e048e09 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1307,7 +1307,7 @@ cpu_dai_err: } /* - * Attempt to initialise any uninitalised cards. Must be called with + * Attempt to initialise any uninitialised cards. Must be called with * client_mutex. */ static void snd_soc_instantiate_cards(void) -- cgit v1.1 From 2a383cb3f1a571b281c2e1ace4c8491f0370e866 Mon Sep 17 00:00:00 2001 From: Eliot Blennerhassett Date: Thu, 17 Jun 2010 17:08:36 +1200 Subject: ALSA: asihpi - Get rid of incorrect "long" types and casts. These give incorrect results for index wrap on 64 bit. Signed-off-by: Eliot Blennerhassett Signed-off-by: Takashi Iwai --- sound/pci/asihpi/hpi6205.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c index e89991e..3b44134 100644 --- a/sound/pci/asihpi/hpi6205.c +++ b/sound/pci/asihpi/hpi6205.c @@ -941,11 +941,11 @@ static void outstream_host_buffer_free(struct hpi_adapter_obj *pao, } -static long outstream_get_space_available(struct hpi_hostbuffer_status +static u32 outstream_get_space_available(struct hpi_hostbuffer_status *status) { - return status->size_in_bytes - ((long)(status->host_index) - - (long)(status->dSP_index)); + return status->size_in_bytes - (status->host_index - + status->dSP_index); } static void outstream_write(struct hpi_adapter_obj *pao, @@ -954,7 +954,7 @@ static void outstream_write(struct hpi_adapter_obj *pao, struct hpi_hw_obj *phw = pao->priv; struct bus_master_interface *interface = phw->p_interface_buffer; struct hpi_hostbuffer_status *status; - long space_available; + u32 space_available; if (!phw->outstream_host_buffer_size[phm->obj_index]) { /* there is no BBM buffer, write via message */ @@ -1007,7 +1007,7 @@ static void outstream_write(struct hpi_adapter_obj *pao, } space_available = outstream_get_space_available(status); - if (space_available < (long)phm->u.d.u.data.data_size) { + if (space_available < phm->u.d.u.data.data_size) { phr->error = HPI_ERROR_INVALID_DATASIZE; return; } @@ -1018,7 +1018,7 @@ static void outstream_write(struct hpi_adapter_obj *pao, && hpios_locked_mem_valid(&phw->outstream_host_buffers[phm-> obj_index])) { u8 *p_bbm_data; - long l_first_write; + u32 l_first_write; u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; if (hpios_locked_mem_get_virt_addr(&phw-> @@ -1248,9 +1248,9 @@ static void instream_start(struct hpi_adapter_obj *pao, hw_message(pao, phm, phr); } -static long instream_get_bytes_available(struct hpi_hostbuffer_status *status) +static u32 instream_get_bytes_available(struct hpi_hostbuffer_status *status) { - return (long)(status->dSP_index) - (long)(status->host_index); + return status->dSP_index - status->host_index; } static void instream_read(struct hpi_adapter_obj *pao, @@ -1259,9 +1259,9 @@ static void instream_read(struct hpi_adapter_obj *pao, struct hpi_hw_obj *phw = pao->priv; struct bus_master_interface *interface = phw->p_interface_buffer; struct hpi_hostbuffer_status *status; - long data_available; + u32 data_available; u8 *p_bbm_data; - long l_first_read; + u32 l_first_read; u8 *p_app_data = (u8 *)phm->u.d.u.data.pb_data; if (!phw->instream_host_buffer_size[phm->obj_index]) { @@ -1272,7 +1272,7 @@ static void instream_read(struct hpi_adapter_obj *pao, status = &interface->instream_host_buffer_status[phm->obj_index]; data_available = instream_get_bytes_available(status); - if (data_available < (long)phm->u.d.u.data.data_size) { + if (data_available < phm->u.d.u.data.data_size) { phr->error = HPI_ERROR_INVALID_DATASIZE; return; } -- cgit v1.1 From c9ff921abecda352e987a6aae169118a3fc9aa5d Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 15 Jun 2010 17:26:28 +0300 Subject: ALSA: alsa: riptide: don't use own hex_to_bin() method Signed-off-by: Andy Shevchenko Signed-off-by: Takashi Iwai --- sound/pci/riptide/riptide.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index ad44626..59d7996 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -97,6 +97,7 @@ #include #include #include +#include #include #include #include @@ -667,13 +668,12 @@ static u32 atoh(const unsigned char *in, unsigned int len) unsigned char c; while (len) { + int value; + c = in[len - 1]; - if ((c >= '0') && (c <= '9')) - sum += mult * (c - '0'); - else if ((c >= 'A') && (c <= 'F')) - sum += mult * (c - ('A' - 10)); - else if ((c >= 'a') && (c <= 'f')) - sum += mult * (c - ('a' - 10)); + value = hex_to_bin(c); + if (value >= 0) + sum += mult * value; mult *= 16; --len; } -- cgit v1.1 From f7154de220f14073ef0d76638f85e254ad2e202f Mon Sep 17 00:00:00 2001 From: Herton Ronaldo Krzesinski Date: Thu, 17 Jun 2010 14:15:06 -0300 Subject: ALSA: hda - add ideapad model for Conexant 5051 codec Lenovo IdeaPad Y430 has an additional subwoofer connected at pin 0x1b, which isn't muted when headphone is plugged in. This adds additional support to the extra subwoofer via new ideapad model. Signed-off-by: Herton Ronaldo Krzesinski Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 2bf2cb5..54f7419 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -1632,6 +1632,11 @@ static void cxt5051_update_speaker(struct hda_codec *codec) pinctl = (!spec->hp_present && spec->cur_eapd) ? PIN_OUT : 0; snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl); + /* on ideapad there is an aditional speaker (subwoofer) to mute */ + if (spec->ideapad) + snd_hda_codec_write(codec, 0x1b, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, + pinctl); } /* turn on/off EAPD (+ mute HP) as a master switch */ @@ -1888,6 +1893,13 @@ static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, #endif } +static struct hda_verb cxt5051_ideapad_init_verbs[] = { + /* Subwoofer */ + {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, + { } /* end */ +}; + /* initialize jack-sensing, too */ static int cxt5051_init(struct hda_codec *codec) { @@ -1917,6 +1929,7 @@ enum { CXT5051_LENOVO_X200, /* Lenovo X200 laptop, also used for Advanced Mini Dock 250410 */ CXT5051_F700, /* HP Compaq Presario F700 */ CXT5051_TOSHIBA, /* Toshiba M300 & co */ + CXT5051_IDEAPAD, /* Lenovo IdeaPad Y430 */ CXT5051_MODELS }; @@ -1927,6 +1940,7 @@ static const char *cxt5051_models[CXT5051_MODELS] = { [CXT5051_LENOVO_X200] = "lenovo-x200", [CXT5051_F700] = "hp-700", [CXT5051_TOSHIBA] = "toshiba", + [CXT5051_IDEAPAD] = "ideapad", }; static struct snd_pci_quirk cxt5051_cfg_tbl[] = { @@ -1938,6 +1952,7 @@ static struct snd_pci_quirk cxt5051_cfg_tbl[] = { CXT5051_LAPTOP), SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200), + SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo IdeaPad", CXT5051_IDEAPAD), {} }; @@ -1999,6 +2014,11 @@ static int patch_cxt5051(struct hda_codec *codec) spec->mixers[0] = cxt5051_toshiba_mixers; spec->auto_mic = AUTO_MIC_PORTB; break; + case CXT5051_IDEAPAD: + spec->init_verbs[spec->num_init_verbs++] = + cxt5051_ideapad_init_verbs; + spec->ideapad = 1; + break; } return 0; -- cgit v1.1 From 272cbc98cfbdd30cff37a35f8ad8f1b737288e88 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 21 Jun 2010 17:03:21 +0200 Subject: ALSA: usb/endpoint, fix dangling pointer use Stanse found that in snd_usb_parse_audio_endpoints, there is a dangling pointer dereference. When snd_usb_parse_audio_format fails, fp is freed, and continue invoked. On the next loop, there is "fp && fp->altsetting == 1 && fp->channels == 1" test, but fp is set from the last iteration (but is bogus) and thus ilegally dereferenced. Set fp to NULL before "continue". Signed-off-by: Jiri Slaby Acked-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/endpoint.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 9593b91..6f6596c 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -427,6 +427,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) if (snd_usb_parse_audio_format(chip, fp, format, fmt, stream, alts) < 0) { kfree(fp->rate_table); kfree(fp); + fp = NULL; continue; } -- cgit v1.1 From 2f44f84725dec354228fddc129e83e251060361d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 22 Jun 2010 11:12:32 +0200 Subject: ALSA: hda - Fix uninitialized variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the following compile warning. kctl should be NULL-initialized. sound/pci/hda/patch_realtek.c: In function ‘alc_build_controls’: sound/pci/hda/patch_realtek.c:2550:23: warning: ‘kctl’ may be used uninitialized in this function Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index f1ce7d7..2bf6789 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -2547,7 +2547,7 @@ static struct snd_kcontrol_new alc_beep_mixer[] = { static int alc_build_controls(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; - struct snd_kcontrol *kctl; + struct snd_kcontrol *kctl = NULL; struct snd_kcontrol_new *knew; int i, j, err; unsigned int u; -- cgit v1.1 From 3bfea98ff73d377ffce0d4c7f938b7ef958cdb35 Mon Sep 17 00:00:00 2001 From: Luke Yelavich Date: Tue, 22 Jun 2010 11:04:19 +1000 Subject: ALSA: hda - Add Macbook 5,2 quirk BugLink: https://bugs.launchpad.net/bugs/463178 Set Macbook 5,2 (106b:4a00) hardware to use ALC885_MB5 Cc: Signed-off-by: Luke Yelavich Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 2bf6789..32299ee 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -9486,6 +9486,7 @@ static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = { SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24), SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91), SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5), + SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5), /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2, * so apparently no perfect solution yet */ -- cgit v1.1 From a5c7d797dcce3be5e77cd6ea62cc4920ededc32b Mon Sep 17 00:00:00 2001 From: Alexey Fisher Date: Wed, 23 Jun 2010 14:17:09 +0200 Subject: ALSA: usb-audio - Add volume resolution quirk for some Logitech webcams Some programs like Skype trying to set capture volume automatically. Normally it will tray, carefully step by step lover or higher, set the volume. In real word it work not really well, because devises and vendors lie about real audio settings. For example most Logitech webcams have 6400 or 3500 steps for capture volume. They do not tell that actual resolution is 384. So we have only 7 or 18 real steps. In this patch I set real resolution only for tested devices. Signed-off-by: Alexey Fisher Signed-off-by: Takashi Iwai --- sound/usb/mixer.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'sound') diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 6939d0f5..736d134 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1107,6 +1107,19 @@ static void build_feature_ctl(struct mixer_build *state, void *raw_desc, } break; + case USB_ID(0x046d, 0x0809): + case USB_ID(0x046d, 0x0991): + /* Most audio usb devices lie about volume resolution. + * Most Logitech webcams have res = 384. + * Proboly there is some logitech magic behind this number --fishor + */ + if (!strcmp(kctl->id.name, "Mic Capture Volume")) { + snd_printk(KERN_INFO + "set resolution quirk: cval->res = 384\n"); + cval->res = 384; + } + break; + } snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", -- cgit v1.1 From f22aa94908352f40fce65b9a9180370fb09ecbe9 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Wed, 16 Jun 2010 17:57:27 +0200 Subject: ALSA: usb-audio: clean up includes in clock.c Signed-off-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/clock.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'sound') diff --git a/sound/usb/clock.c b/sound/usb/clock.c index b585511..386b09c 100644 --- a/sound/usb/clock.c +++ b/sound/usb/clock.c @@ -19,33 +19,19 @@ #include #include -#include -#include #include #include -#include -#include #include #include #include #include #include -#include -#include #include "usbaudio.h" #include "card.h" -#include "midi.h" -#include "mixer.h" -#include "proc.h" -#include "quirks.h" -#include "endpoint.h" #include "helper.h" -#include "debug.h" -#include "pcm.h" -#include "urb.h" -#include "format.h" +#include "clock.h" static struct uac_clock_source_descriptor * snd_usb_find_clock_source(struct usb_host_interface *ctrl_iface, -- cgit v1.1 From 69da9bcb98ccbfb5d5f751bc13418f1307332925 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Wed, 16 Jun 2010 17:57:28 +0200 Subject: ALSA: usb-audio: unify UAC macros and struct names Get rid of the last occurances of _v1 suffixes, and move the version number right after the "uac" string. Now things are consitent again. Sorry for the forth and back, but it just looks much nicer this way. Signed-off-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/card.c | 2 +- sound/usb/endpoint.c | 4 ++-- sound/usb/mixer.c | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/usb/card.c b/sound/usb/card.c index 7a8ac1d..9feb00c 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -217,7 +217,7 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif) switch (protocol) { case UAC_VERSION_1: { - struct uac_ac_header_descriptor_v1 *h1 = control_header; + struct uac1_ac_header_descriptor *h1 = control_header; if (!h1->bInCollection) { snd_printk(KERN_INFO "skipping empty audio interface (v1)\n"); diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 6f6596c..2af0f9e 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -275,7 +275,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) /* get audio formats */ switch (protocol) { case UAC_VERSION_1: { - struct uac_as_header_descriptor_v1 *as = + struct uac1_as_header_descriptor *as = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL); if (!as) { @@ -297,7 +297,7 @@ int snd_usb_parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) case UAC_VERSION_2: { struct uac2_input_terminal_descriptor *input_term; struct uac2_output_terminal_descriptor *output_term; - struct uac_as_header_descriptor_v2 *as = + struct uac2_as_header_descriptor *as = snd_usb_find_csint_desc(alts->extra, alts->extralen, NULL, UAC_AS_GENERAL); if (!as) { diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 736d134..ba54eb6 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -582,9 +582,9 @@ static int get_term_name(struct mixer_build *state, struct usb_audio_term *iterm switch (iterm->type >> 16) { case UAC_SELECTOR_UNIT: strcpy(name, "Selector"); return 8; - case UAC_PROCESSING_UNIT_V1: + case UAC1_PROCESSING_UNIT: strcpy(name, "Process Unit"); return 12; - case UAC_EXTENSION_UNIT_V1: + case UAC1_EXTENSION_UNIT: strcpy(name, "Ext Unit"); return 8; case UAC_MIXER_UNIT: strcpy(name, "Mixer"); return 5; @@ -672,8 +672,8 @@ static int check_input_term(struct mixer_build *state, int id, struct usb_audio_ term->name = uac_selector_unit_iSelector(d); return 0; } - case UAC_PROCESSING_UNIT_V1: - case UAC_EXTENSION_UNIT_V1: { + case UAC1_PROCESSING_UNIT: + case UAC1_EXTENSION_UNIT: { struct uac_processing_unit_descriptor *d = p1; if (d->bNrInPins) { id = d->baSourceID[0]; @@ -1855,13 +1855,13 @@ static int parse_audio_unit(struct mixer_build *state, int unitid) return parse_audio_selector_unit(state, unitid, p1); case UAC_FEATURE_UNIT: return parse_audio_feature_unit(state, unitid, p1); - case UAC_PROCESSING_UNIT_V1: + case UAC1_PROCESSING_UNIT: /* UAC2_EFFECT_UNIT has the same value */ if (state->mixer->protocol == UAC_VERSION_1) return parse_audio_processing_unit(state, unitid, p1); else return 0; /* FIXME - effect units not implemented yet */ - case UAC_EXTENSION_UNIT_V1: + case UAC1_EXTENSION_UNIT: /* UAC2_PROCESSING_UNIT_V2 has the same value */ if (state->mixer->protocol == UAC_VERSION_1) return parse_audio_extension_unit(state, unitid, p1); @@ -1925,7 +1925,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) p = NULL; while ((p = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, p, UAC_OUTPUT_TERMINAL)) != NULL) { if (mixer->protocol == UAC_VERSION_1) { - struct uac_output_terminal_descriptor_v1 *desc = p; + struct uac1_output_terminal_descriptor *desc = p; if (desc->bLength < sizeof(*desc)) continue; /* invalid descriptor? */ -- cgit v1.1 From 21af7d8c0c0a88f6f9fc6993d73001b4caf23b08 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Wed, 16 Jun 2010 17:57:29 +0200 Subject: ALSA: usb-midi: whitespace fixes Signed-off-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/midi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/usb/midi.c b/sound/usb/midi.c index 4678564..b9c2bc6 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -434,7 +434,7 @@ static void snd_usbmidi_maudio_broken_running_status_input( u8 cin = buffer[i] & 0x0f; struct usbmidi_in_port *port = &ep->ports[cable]; int length; - + length = snd_usbmidi_cin_length[cin]; if (cin == 0xf && buffer[i + 1] >= 0xf8) ; /* realtime msg: no running status change */ @@ -628,13 +628,13 @@ static struct usb_protocol_ops snd_usbmidi_standard_ops = { static struct usb_protocol_ops snd_usbmidi_midiman_ops = { .input = snd_usbmidi_midiman_input, - .output = snd_usbmidi_standard_output, + .output = snd_usbmidi_standard_output, .output_packet = snd_usbmidi_output_midiman_packet, }; static struct usb_protocol_ops snd_usbmidi_maudio_broken_running_status_ops = { .input = snd_usbmidi_maudio_broken_running_status_input, - .output = snd_usbmidi_standard_output, + .output = snd_usbmidi_standard_output, .output_packet = snd_usbmidi_output_standard_packet, }; @@ -1248,7 +1248,7 @@ static void snd_usbmidi_out_endpoint_delete(struct snd_usb_midi_out_endpoint *ep */ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi, struct snd_usb_midi_endpoint_info* ep_info, - struct snd_usb_midi_endpoint* rep) + struct snd_usb_midi_endpoint* rep) { struct snd_usb_midi_out_endpoint* ep; unsigned int i; @@ -1398,7 +1398,7 @@ static void snd_usbmidi_rawmidi_free(struct snd_rawmidi *rmidi) } static struct snd_rawmidi_substream *snd_usbmidi_find_substream(struct snd_usb_midi* umidi, - int stream, int number) + int stream, int number) { struct list_head* list; @@ -1811,7 +1811,7 @@ static int snd_usbmidi_detect_endpoints(struct snd_usb_midi* umidi, snd_usbmidi_switch_roland_altsetting(umidi); if (endpoint[0].out_ep || endpoint[0].in_ep) - return 0; + return 0; intf = umidi->iface; if (!intf || intf->num_altsetting < 1) @@ -1849,7 +1849,7 @@ static int snd_usbmidi_detect_per_port_endpoints(struct snd_usb_midi* umidi, struct snd_usb_midi_endpoint_info* endpoints) { int err, i; - + err = snd_usbmidi_detect_endpoints(umidi, endpoints, MIDI_MAX_ENDPOINTS); for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { if (endpoints[i].out_ep) -- cgit v1.1 From 157a57b6fae7d3c6d24b7623dcc6679c6d244621 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Wed, 16 Jun 2010 17:57:30 +0200 Subject: ALSA: usb-audio: move and add some comments Also add a list of open topics. Signed-off-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/clock.c | 16 ++++++++++++++-- sound/usb/mixer.c | 24 ++++++++++++++++-------- 2 files changed, 30 insertions(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/usb/clock.c b/sound/usb/clock.c index 386b09c..7279d61 100644 --- a/sound/usb/clock.c +++ b/sound/usb/clock.c @@ -120,8 +120,6 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id) return !!data; } -/* Try to find the clock source ID of a given clock entity */ - static int __uac_clock_find_source(struct snd_usb_audio *chip, struct usb_host_interface *host_iface, int entity_id, unsigned long *visited) @@ -154,6 +152,8 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, if (ret < 0) return ret; + /* Selector values are one-based */ + if (ret > selector->bNrInPins || ret < 1) { printk(KERN_ERR "%s(): selector reported illegal value, id %d, ret %d\n", @@ -176,6 +176,17 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, return -EINVAL; } +/* + * For all kinds of sample rate settings and other device queries, + * the clock source (end-leaf) must be used. However, clock selectors, + * clock multipliers and sample rate converters may be specified as + * clock source input to terminal. This functions walks the clock path + * to its end and tries to find the source. + * + * The 'visited' bitfield is used internally to detect recursive loops. + * + * Returns the clock source UnitID (>=0) on success, or an error. + */ int snd_usb_clock_find_source(struct snd_usb_audio *chip, struct usb_host_interface *host_iface, int entity_id) @@ -246,6 +257,7 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, return clock; if (!uac_clock_source_is_valid(chip, clock)) { + /* TODO: should we try to find valid clock setups by ourself? */ snd_printk(KERN_ERR "%d:%d:%d: clock source %d is not valid, cannot use\n", dev->devnum, iface, fmt->altsetting, clock); return -ENXIO; diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index ba54eb6..1163ec3 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -26,6 +26,22 @@ * */ +/* + * TODOs, for both the mixer and the streaming interfaces: + * + * - support for UAC2 effect units + * - support for graphical equalizers + * - RANGE and MEM set commands (UAC2) + * - RANGE and MEM interrupt dispatchers (UAC2) + * - audio channel clustering (UAC2) + * - audio sample rate converter units (UAC2) + * - proper handling of clock multipliers (UAC2) + * - dispatch clock change notifications (UAC2) + * - stop PCM streams which use a clock that became invalid + * - stop PCM streams which use a clock selector that has changed + * - parse available sample rates again when clock sources changed + */ + #include #include #include @@ -1199,14 +1215,6 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void } } else { /* UAC_VERSION_2 */ for (i = 0; i < 30/2; i++) { - /* From the USB Audio spec v2.0: - bmaControls() is a (ch+1)-element array of 4-byte bitmaps, - each containing a set of bit pairs. If a Control is present, - it must be Host readable. If a certain Control is not - present then the bit pair must be set to 0b00. - If a Control is present but read-only, the bit pair must be - set to 0b01. If a Control is also Host programmable, the bit - pair must be set to 0b11. The value 0b10 is not allowed. */ unsigned int ch_bits = 0; unsigned int ch_read_only = 0; -- cgit v1.1 From 3d8d4dcfd423b01ef7ea7c3c97720764b7adb6df Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Wed, 16 Jun 2010 17:57:31 +0200 Subject: ALSA: usb-audio: simplify control interface access As the control interface is now carried in struct snd_usb_audio, we can simplify the API a little and also drop the private ctrlif field from struct usb_mixer_interface. Also remove a left-over function prototype in pcm.h. Signed-off-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/clock.c | 22 +++++++++------------- sound/usb/clock.h | 4 +--- sound/usb/endpoint.c | 1 + sound/usb/format.c | 9 ++++----- sound/usb/mixer.c | 37 ++++++++++++++++++------------------- sound/usb/mixer.h | 1 - sound/usb/pcm.h | 3 --- sound/usb/quirks.c | 1 + 8 files changed, 34 insertions(+), 44 deletions(-) (limited to 'sound') diff --git a/sound/usb/clock.c b/sound/usb/clock.c index 7279d61..66bd157 100644 --- a/sound/usb/clock.c +++ b/sound/usb/clock.c @@ -121,7 +121,6 @@ static bool uac_clock_source_is_valid(struct snd_usb_audio *chip, int source_id) } static int __uac_clock_find_source(struct snd_usb_audio *chip, - struct usb_host_interface *host_iface, int entity_id, unsigned long *visited) { struct uac_clock_source_descriptor *source; @@ -138,11 +137,11 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, } /* first, see if the ID we're looking for is a clock source already */ - source = snd_usb_find_clock_source(host_iface, entity_id); + source = snd_usb_find_clock_source(chip->ctrl_intf, entity_id); if (source) return source->bClockID; - selector = snd_usb_find_clock_selector(host_iface, entity_id); + selector = snd_usb_find_clock_selector(chip->ctrl_intf, entity_id); if (selector) { int ret; @@ -162,16 +161,15 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, return -EINVAL; } - return __uac_clock_find_source(chip, host_iface, - selector->baCSourceID[ret-1], + return __uac_clock_find_source(chip, selector->baCSourceID[ret-1], visited); } /* FIXME: multipliers only act as pass-thru element for now */ - multiplier = snd_usb_find_clock_multiplier(host_iface, entity_id); + multiplier = snd_usb_find_clock_multiplier(chip->ctrl_intf, entity_id); if (multiplier) - return __uac_clock_find_source(chip, host_iface, - multiplier->bCSourceID, visited); + return __uac_clock_find_source(chip, multiplier->bCSourceID, + visited); return -EINVAL; } @@ -187,13 +185,11 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, * * Returns the clock source UnitID (>=0) on success, or an error. */ -int snd_usb_clock_find_source(struct snd_usb_audio *chip, - struct usb_host_interface *host_iface, - int entity_id) +int snd_usb_clock_find_source(struct snd_usb_audio *chip, int entity_id) { DECLARE_BITMAP(visited, 256); memset(visited, 0, sizeof(visited)); - return __uac_clock_find_source(chip, host_iface, entity_id, visited); + return __uac_clock_find_source(chip, entity_id, visited); } static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface, @@ -251,7 +247,7 @@ static int set_sample_rate_v2(struct snd_usb_audio *chip, int iface, struct usb_device *dev = chip->dev; unsigned char data[4]; int err, crate; - int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fmt->clock); + int clock = snd_usb_clock_find_source(chip, fmt->clock); if (clock < 0) return clock; diff --git a/sound/usb/clock.h b/sound/usb/clock.h index beb2536..4663093 100644 --- a/sound/usb/clock.h +++ b/sound/usb/clock.h @@ -5,8 +5,6 @@ int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface, struct usb_host_interface *alts, struct audioformat *fmt, int rate); -int snd_usb_clock_find_source(struct snd_usb_audio *chip, - struct usb_host_interface *host_iface, - int entity_id); +int snd_usb_clock_find_source(struct snd_usb_audio *chip, int entity_id); #endif /* __USBAUDIO_CLOCK_H */ diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 2af0f9e..1a701f1 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -33,6 +33,7 @@ #include "pcm.h" #include "helper.h" #include "format.h" +#include "clock.h" /* * free a substream diff --git a/sound/usb/format.c b/sound/usb/format.c index 30364ab..4387f54 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -264,13 +264,12 @@ static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets, * on the audioformat table (audio class v2). */ static int parse_audio_format_rates_v2(struct snd_usb_audio *chip, - struct audioformat *fp, - struct usb_host_interface *iface) + struct audioformat *fp) { struct usb_device *dev = chip->dev; unsigned char tmp[2], *data; int nr_triplets, data_size, ret = 0; - int clock = snd_usb_clock_find_source(chip, chip->ctrl_intf, fp->clock); + int clock = snd_usb_clock_find_source(chip, fp->clock); if (clock < 0) { snd_printk(KERN_ERR "%s(): unable to find clock source (clock %d)\n", @@ -391,7 +390,7 @@ static int parse_audio_format_i(struct snd_usb_audio *chip, break; case UAC_VERSION_2: /* fp->channels is already set in this case */ - ret = parse_audio_format_rates_v2(chip, fp, iface); + ret = parse_audio_format_rates_v2(chip, fp); break; } @@ -450,7 +449,7 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip, framesize = le16_to_cpu(fmt->wSamplesPerFrame); snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize); fp->frame_size = framesize; - ret = parse_audio_format_rates_v2(chip, fp, iface); + ret = parse_audio_format_rates_v2(chip, fp); break; } } diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 1163ec3..035a77b 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -291,16 +291,15 @@ static int get_abs_value(struct usb_mixer_elem_info *cval, int val) static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) { + struct snd_usb_audio *chip = cval->mixer->chip; unsigned char buf[2]; int val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1; int timeout = 10; while (timeout-- > 0) { - if (snd_usb_ctl_msg(cval->mixer->chip->dev, - usb_rcvctrlpipe(cval->mixer->chip->dev, 0), - request, + if (snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), request, USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, - validx, cval->mixer->ctrlif | (cval->id << 8), + validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), buf, val_len, 100) >= val_len) { *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len)); return 0; @@ -313,6 +312,7 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) { + struct snd_usb_audio *chip = cval->mixer->chip; unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */ unsigned char *val; int ret, size; @@ -328,16 +328,14 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v memset(buf, 0, sizeof(buf)); - ret = snd_usb_ctl_msg(cval->mixer->chip->dev, - usb_rcvctrlpipe(cval->mixer->chip->dev, 0), - bRequest, + ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), bRequest, USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, - validx, cval->mixer->ctrlif | (cval->id << 8), + validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), buf, size, 1000); if (ret < 0) { snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", - request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type); + request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type); return ret; } @@ -413,6 +411,7 @@ static int get_cur_mix_value(struct usb_mixer_elem_info *cval, int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval, int request, int validx, int value_set) { + struct snd_usb_audio *chip = cval->mixer->chip; unsigned char buf[2]; int val_len, timeout = 10; @@ -435,15 +434,14 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval, buf[0] = value_set & 0xff; buf[1] = (value_set >> 8) & 0xff; while (timeout-- > 0) - if (snd_usb_ctl_msg(cval->mixer->chip->dev, - usb_sndctrlpipe(cval->mixer->chip->dev, 0), - request, + if (snd_usb_ctl_msg(chip->dev, + usb_sndctrlpipe(chip->dev, 0), request, USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, - validx, cval->mixer->ctrlif | (cval->id << 8), + validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), buf, val_len, 100) >= 0) return 0; snd_printdd(KERN_ERR "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n", - request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type, buf[0], buf[1]); + request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type, buf[0], buf[1]); return -EINVAL; } @@ -761,6 +759,8 @@ static void usb_mixer_elem_free(struct snd_kcontrol *kctl) */ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) { + struct snd_usb_audio *chip = cval->mixer->chip; + /* for failsafe */ cval->min = default_min; cval->max = cval->min + 1; @@ -783,7 +783,7 @@ static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) if (get_ctl_value(cval, UAC_GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 || get_ctl_value(cval, UAC_GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n", - cval->id, cval->mixer->ctrlif, cval->control, cval->id); + cval->id, snd_usb_ctrl_intf(chip), cval->control, cval->id); return -EINVAL; } if (get_ctl_value(cval, UAC_GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) { @@ -1913,7 +1913,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) struct usb_host_interface *hostif; void *p; - hostif = &usb_ifnum_to_if(mixer->chip->dev, mixer->ctrlif)->altsetting[0]; + hostif = mixer->chip->ctrl_intf; memset(&state, 0, sizeof(state)); state.chip = mixer->chip; state.mixer = mixer; @@ -2005,7 +2005,7 @@ static void snd_usb_mixer_proc_read(struct snd_info_entry *entry, list_for_each_entry(mixer, &chip->mixer_list, list) { snd_iprintf(buffer, "USB Mixer: usb_id=0x%08x, ctrlif=%i, ctlerr=%i\n", - chip->usb_id, mixer->ctrlif, + chip->usb_id, snd_usb_ctrl_intf(chip), mixer->ignore_ctl_error); snd_iprintf(buffer, "Card: %s\n", chip->card->longname); for (unitid = 0; unitid < MAX_ID_ELEMS; unitid++) { @@ -2123,7 +2123,7 @@ static int snd_usb_mixer_status_create(struct usb_mixer_interface *mixer) int buffer_length; unsigned int epnum; - hostif = &usb_ifnum_to_if(mixer->chip->dev, mixer->ctrlif)->altsetting[0]; + hostif = mixer->chip->ctrl_intf; /* we need one interrupt input endpoint */ if (get_iface_desc(hostif)->bNumEndpoints < 1) return 0; @@ -2166,7 +2166,6 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, if (!mixer) return -ENOMEM; mixer->chip = chip; - mixer->ctrlif = ctrlif; mixer->ignore_ctl_error = ignore_error; mixer->id_elems = kcalloc(MAX_ID_ELEMS, sizeof(*mixer->id_elems), GFP_KERNEL); diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h index a7cf100..26c636c 100644 --- a/sound/usb/mixer.h +++ b/sound/usb/mixer.h @@ -3,7 +3,6 @@ struct usb_mixer_interface { struct snd_usb_audio *chip; - unsigned int ctrlif; struct list_head list; unsigned int ignore_ctl_error; struct urb *urb; diff --git a/sound/usb/pcm.h b/sound/usb/pcm.h index 1c931b6..ed3e283 100644 --- a/sound/usb/pcm.h +++ b/sound/usb/pcm.h @@ -7,8 +7,5 @@ int snd_usb_init_pitch(struct snd_usb_audio *chip, int iface, struct usb_host_interface *alts, struct audioformat *fmt); -int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface, - struct usb_host_interface *alts, - struct audioformat *fmt, int rate); #endif /* __USBAUDIO_PCM_H */ diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index b45e54c..9a9da09 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -32,6 +32,7 @@ #include "helper.h" #include "endpoint.h" #include "pcm.h" +#include "clock.h" /* * handle the quirks for the contained interfaces -- cgit v1.1 From d1eb57f47b7f524c13112c891e87fb1f51029fd1 Mon Sep 17 00:00:00 2001 From: Kailang Yang Date: Wed, 23 Jun 2010 16:25:26 +0200 Subject: ALSA: hda - Support ALC680 codec Signed-off-by: Kailang Yang Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 331 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 330 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index f1ce7d7..630e667 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -18612,7 +18612,7 @@ static int alc662_parse_auto_config(struct hda_codec *codec) add_verb(spec, alc662_init_verbs); if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || - codec->vendor_id == 0x10ec0665) + codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) add_verb(spec, alc663_init_verbs); if (codec->vendor_id == 0x10ec0272) @@ -18756,6 +18756,334 @@ static int patch_alc888(struct hda_codec *codec) } /* + * ALC680 support + */ +#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID +#define alc680_modes alc260_modes + +static hda_nid_t alc680_dac_nids[3] = { + /* Lout1, Lout2, hp */ + 0x02, 0x03, 0x04 +}; + +static hda_nid_t alc680_adc_nids[3] = { + /* ADC0-2 */ + /* DMIC, MIC, Line-in*/ + 0x07, 0x08, 0x09 +}; + +static struct snd_kcontrol_new alc680_base_mixer[] = { + /* output mixer control */ + HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), + { } +}; + +static struct snd_kcontrol_new alc680_capture_mixer[] = { + HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), + HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), + HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), + { } /* end */ +}; + +/* + * generic initialization of ADC, input mixers and output mixers + */ +static struct hda_verb alc680_init_verbs[] = { + /* Unmute DAC0-1 and set vol = 0 */ + {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, + {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, + {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, + {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, + + {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + { } +}; + +/* create input playback/capture controls for the given pin */ +static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid, + const char *ctlname, int idx) +{ + hda_nid_t dac; + int err; + + switch (nid) { + case 0x14: + dac = 0x02; + break; + case 0x15: + dac = 0x03; + break; + case 0x16: + dac = 0x04; + break; + default: + return 0; + } + if (spec->multiout.dac_nids[0] != dac && + spec->multiout.dac_nids[1] != dac) { + err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, + HDA_COMPOSE_AMP_VAL(dac, 3, idx, + HDA_OUTPUT)); + if (err < 0) + return err; + + err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, + HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT)); + + if (err < 0) + return err; + spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac; + } + + return 0; +} + +/* add playback controls from the parsed DAC table */ +static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec, + const struct auto_pin_cfg *cfg) +{ + hda_nid_t nid; + int err; + + spec->multiout.dac_nids = spec->private_dac_nids; + + nid = cfg->line_out_pins[0]; + if (nid) { + const char *name; + if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) + name = "Speaker"; + else + name = "Front"; + err = alc680_new_analog_output(spec, nid, name, 0); + if (err < 0) + return err; + } + + nid = cfg->speaker_pins[0]; + if (nid) { + err = alc680_new_analog_output(spec, nid, "Speaker", 0); + if (err < 0) + return err; + } + nid = cfg->hp_pins[0]; + if (nid) { + err = alc680_new_analog_output(spec, nid, "Headphone", 0); + if (err < 0) + return err; + } + + return 0; +} + +static void alc680_auto_set_output_and_unmute(struct hda_codec *codec, + hda_nid_t nid, int pin_type) +{ + alc_set_pin_output(codec, nid, pin_type); +} + +static void alc680_auto_init_multi_out(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + hda_nid_t nid = spec->autocfg.line_out_pins[0]; + if (nid) { + int pin_type = get_pin_type(spec->autocfg.line_out_type); + alc680_auto_set_output_and_unmute(codec, nid, pin_type); + } +} + +static void alc680_auto_init_hp_out(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + hda_nid_t pin; + + pin = spec->autocfg.hp_pins[0]; + if (pin) + alc680_auto_set_output_and_unmute(codec, pin, PIN_HP); + pin = spec->autocfg.speaker_pins[0]; + if (pin) + alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT); +} + +/* pcm configuration: identical with ALC880 */ +#define alc680_pcm_analog_playback alc880_pcm_analog_playback +#define alc680_pcm_analog_capture alc880_pcm_analog_capture +#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture +#define alc680_pcm_digital_playback alc880_pcm_digital_playback + +static struct hda_input_mux alc680_capture_source = { + .num_items = 1, + .items = { + { "Mic", 0x0 }, + }, +}; + +/* + * BIOS auto configuration + */ +static int alc680_parse_auto_config(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + int err; + static hda_nid_t alc680_ignore[] = { 0 }; + + err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, + alc680_ignore); + if (err < 0) + return err; + if (!spec->autocfg.line_outs) { + if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) { + spec->multiout.max_channels = 2; + spec->no_analog = 1; + goto dig_only; + } + return 0; /* can't find valid BIOS pin config */ + } + err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg); + if (err < 0) + return err; + + spec->multiout.max_channels = 2; + + dig_only: + /* digital only support output */ + if (spec->autocfg.dig_outs) { + spec->multiout.dig_out_nid = ALC680_DIGOUT_NID; + spec->dig_out_type = spec->autocfg.dig_out_type[0]; + } + if (spec->kctls.list) + add_mixer(spec, spec->kctls.list); + + add_verb(spec, alc680_init_verbs); + spec->num_mux_defs = 1; + spec->input_mux = &alc680_capture_source; + + err = alc_auto_add_mic_boost(codec); + if (err < 0) + return err; + + return 1; +} + +#define alc680_auto_init_analog_input alc882_auto_init_analog_input + +/* init callback for auto-configuration model -- overriding the default init */ +static void alc680_auto_init(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + alc680_auto_init_multi_out(codec); + alc680_auto_init_hp_out(codec); + alc680_auto_init_analog_input(codec); + if (spec->unsol_event) + alc_inithook(codec); +} + +/* + * configuration and preset + */ +static const char *alc680_models[ALC680_MODEL_LAST] = { + [ALC680_BASE] = "alc680_base", +}; + +static struct snd_pci_quirk alc680_cfg_tbl[] = { + SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE), + {} +}; + +static struct alc_config_preset alc680_presets[] = { + [ALC680_BASE] = { + .mixers = { alc680_base_mixer }, + .cap_mixer = alc680_capture_mixer, + .init_verbs = { alc680_init_verbs }, + .num_dacs = ARRAY_SIZE(alc680_dac_nids), + .dac_nids = alc680_dac_nids, + .num_adc_nids = ARRAY_SIZE(alc680_adc_nids), + .adc_nids = alc680_adc_nids, + .hp_nid = 0x04, + .dig_out_nid = ALC680_DIGOUT_NID, + .num_channel_mode = ARRAY_SIZE(alc680_modes), + .channel_mode = alc680_modes, + .input_mux = &alc680_capture_source, + }, +}; + +static int patch_alc680(struct hda_codec *codec) +{ + struct alc_spec *spec; + int board_config; + int err; + + spec = kzalloc(sizeof(*spec), GFP_KERNEL); + if (spec == NULL) + return -ENOMEM; + + codec->spec = spec; + + board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST, + alc680_models, + alc680_cfg_tbl); + + if (board_config < 0 || board_config >= ALC680_MODEL_LAST) { + printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", + codec->chip_name); + board_config = ALC680_AUTO; + } + + if (board_config == ALC680_AUTO) { + /* automatic parse from the BIOS config */ + err = alc680_parse_auto_config(codec); + if (err < 0) { + alc_free(codec); + return err; + } else if (!err) { + printk(KERN_INFO + "hda_codec: Cannot set up configuration " + "from BIOS. Using base mode...\n"); + board_config = ALC680_BASE; + } + } + + if (board_config != ALC680_AUTO) + setup_preset(codec, &alc680_presets[board_config]); + + spec->stream_analog_playback = &alc680_pcm_analog_playback; + spec->stream_analog_capture = &alc680_pcm_analog_capture; + spec->stream_analog_alt_capture = &alc680_pcm_analog_alt_capture; + spec->stream_digital_playback = &alc680_pcm_digital_playback; + + if (!spec->adc_nids) { + spec->adc_nids = alc680_adc_nids; + spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids); + } + + if (!spec->cap_mixer) + set_capture_mixer(codec); + + spec->vmaster_nid = 0x02; + + codec->patch_ops = alc_patch_ops; + if (board_config == ALC680_AUTO) + spec->init_hook = alc680_auto_init; + + return 0; +} + +/* * patch entries */ static struct hda_codec_preset snd_hda_preset_realtek[] = { @@ -18779,6 +19107,7 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = { { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, + { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, -- cgit v1.1 From d4a86d81944d3cccb3f4a309230e835823a61252 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 23 Jun 2010 17:51:26 +0200 Subject: ALSA: hda - Add missing ALC680_* definitions Also update the documentation. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 630e667..9b15a46 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -256,6 +256,13 @@ enum { ALC882_MODEL_LAST, }; +/* ALC680 models */ +enum { + ALC680_BASE, + ALC680_AUTO, + ALC680_MODEL_LAST, +}; + /* for GPIO Poll */ #define GPIO_MASK 0x03 @@ -18997,7 +19004,8 @@ static void alc680_auto_init(struct hda_codec *codec) * configuration and preset */ static const char *alc680_models[ALC680_MODEL_LAST] = { - [ALC680_BASE] = "alc680_base", + [ALC680_BASE] = "base", + [ALC680_AUTO] = "auto", }; static struct snd_pci_quirk alc680_cfg_tbl[] = { -- cgit v1.1 From b415ec7041429bb2cde3419e9556049fe12bf27a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 24 Jun 2010 08:07:28 +0200 Subject: ALSA: usb - Fix compile error with CONFIG_SND_DEBUG_VERBOSE=y Replaced the forgotten cval->mixer->ctrlif. Signed-off-by: Takashi Iwai --- sound/usb/mixer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 035a77b..c166db0 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -306,7 +306,7 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v } } snd_printdd(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", - request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type); + request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type); return -EINVAL; } -- cgit v1.1 From 5daeba34d2aab669aea07abee13d53cd116578fb Mon Sep 17 00:00:00 2001 From: David Dillow Date: Sun, 27 Jun 2010 00:13:20 +0200 Subject: ALSA: pcm_lib: avoid timing jitter in snd_pcm_read/write() When using poll() to wait for the next period -- or avail_min samples -- one gets a consistent delay for each system call that is usually just a little short of the selected period time. However, When using snd_pcm_read/write(), one gets a jittery delay that alternates between less than a millisecond and approximately two period times. This is caused by snd_pcm_lib_{read,write}1() transferring any available samples to the user's buffer and adjusting the application pointer prior to sleeping to the end of the current period. When the next period interrupt occurs, there is then less than avail_min samples remaining to be transferred in the period, so we end up sleeping until a second period occurs. This is solved by using runtime->twake as the number of samples needed for a wakeup in addition to selecting the proper wait queue to wake in snd_pcm_update_state(). This requires twake to be non-zero when used by snd_pcm_lib_{read,write}1() even if avail_min is zero. Signed-off-by: Dave Dillow Signed-off-by: Jaroslav Kysela --- sound/core/pcm_lib.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index e9d98be..bcf95d3 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -287,8 +287,11 @@ int snd_pcm_update_state(struct snd_pcm_substream *substream, return -EPIPE; } } - if (avail >= runtime->control->avail_min) - wake_up(runtime->twake ? &runtime->tsleep : &runtime->sleep); + if (runtime->twake) { + if (avail >= runtime->twake) + wake_up(&runtime->tsleep); + } else if (avail >= runtime->control->avail_min) + wake_up(&runtime->sleep); return 0; } @@ -1707,7 +1710,7 @@ EXPORT_SYMBOL(snd_pcm_period_elapsed); * The available space is stored on availp. When err = 0 and avail = 0 * on the capture stream, it indicates the stream is in DRAINING state. */ -static int wait_for_avail_min(struct snd_pcm_substream *substream, +static int wait_for_avail(struct snd_pcm_substream *substream, snd_pcm_uframes_t *availp) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -1757,7 +1760,7 @@ static int wait_for_avail_min(struct snd_pcm_substream *substream, avail = snd_pcm_playback_avail(runtime); else avail = snd_pcm_capture_avail(runtime); - if (avail >= runtime->control->avail_min) + if (avail >= runtime->twake) break; } _endloop: @@ -1820,7 +1823,7 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream, goto _end_unlock; } - runtime->twake = 1; + runtime->twake = runtime->control->avail_min ? : 1; while (size > 0) { snd_pcm_uframes_t frames, appl_ptr, appl_ofs; snd_pcm_uframes_t avail; @@ -1833,7 +1836,9 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream, err = -EAGAIN; goto _end_unlock; } - err = wait_for_avail_min(substream, &avail); + runtime->twake = min_t(snd_pcm_uframes_t, size, + runtime->control->avail_min ? : 1); + err = wait_for_avail(substream, &avail); if (err < 0) goto _end_unlock; } @@ -2042,7 +2047,7 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream, goto _end_unlock; } - runtime->twake = 1; + runtime->twake = runtime->control->avail_min ? : 1; while (size > 0) { snd_pcm_uframes_t frames, appl_ptr, appl_ofs; snd_pcm_uframes_t avail; @@ -2060,7 +2065,9 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream, err = -EAGAIN; goto _end_unlock; } - err = wait_for_avail_min(substream, &avail); + runtime->twake = min_t(snd_pcm_uframes_t, size, + runtime->control->avail_min ? : 1); + err = wait_for_avail(substream, &avail); if (err < 0) goto _end_unlock; if (!avail) -- cgit v1.1 From 3a3d5fd125f82200019ef406c4d51ba4d9f0a604 Mon Sep 17 00:00:00 2001 From: David Dillow Date: Sun, 27 Jun 2010 00:04:32 +0200 Subject: sis7019: fix capture issues with multiple periods per buffer When using a timing voice to clock out periods during capture, the driver would slowly loose synchronization and never catch up, eventually reaching a point where it no longer generated interrupts. To avoid this situation, the virtual period clocking was changed to shorten the next timing period when our timing voice falls too far behind the capture voice. In addition, the first virtual period for the timing voice was slightly too short, causing the timing voice to initially be ahead of the capture voice. While tracking down this problem, I noticed that the expected sample offset was being incorrectly initialized, causing an overrun to be incorrectly reported when the timing voice happened to be perfectly synchronized. Reported-by: Hans Schou Signed-off-by: Dave Dillow Signed-off-by: Jaroslav Kysela --- sound/pci/sis7019.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index 9cc1b5a..614ff6e 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -264,11 +264,13 @@ static void sis_update_voice(struct voice *voice) * if using small periods. * * If we're less than 9 samples behind, we're on target. + * Otherwise, shorten the next vperiod by the amount we've + * been delayed. */ if (sync > -9) voice->vperiod = voice->sync_period_size + 1; else - voice->vperiod = voice->sync_period_size - 4; + voice->vperiod = voice->sync_period_size + sync + 10; if (voice->vperiod < voice->buffer_size) { sis_update_sso(voice, voice->vperiod); @@ -736,7 +738,7 @@ static void sis_prepare_timing_voice(struct voice *voice, period_size = buffer_size; /* Initially, we want to interrupt just a bit behind the end of - * the period we're clocking out. 10 samples seems to give a good + * the period we're clocking out. 12 samples seems to give a good * delay. * * We want to spread our interrupts throughout the virtual period, @@ -747,7 +749,7 @@ static void sis_prepare_timing_voice(struct voice *voice, * * This is all moot if we don't need to use virtual periods. */ - vperiod = runtime->period_size + 10; + vperiod = runtime->period_size + 12; if (vperiod > period_size) { u16 tail = vperiod % period_size; u16 quarter_period = period_size / 4; @@ -776,7 +778,7 @@ static void sis_prepare_timing_voice(struct voice *voice, */ timing->flags |= VOICE_SYNC_TIMING; timing->sync_base = voice->ctrl_base; - timing->sync_cso = runtime->period_size - 1; + timing->sync_cso = runtime->period_size; timing->sync_period_size = runtime->period_size; timing->sync_buffer_size = runtime->buffer_size; timing->period_size = period_size; -- cgit v1.1 From 08b450988905505d12f7671bc24b8da73631d327 Mon Sep 17 00:00:00 2001 From: David Dillow Date: Sun, 27 Jun 2010 00:07:57 +0200 Subject: sis7019: increase reset delays A few boards using this controller are reported to need a little extra time during their reset cycle. Reported-by: Michael Goeke Signed-off-by: Dave Dillow Signed-off-by: Jaroslav Kysela --- sound/pci/sis7019.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c index 614ff6e..1b8f674 100644 --- a/sound/pci/sis7019.c +++ b/sound/pci/sis7019.c @@ -1049,7 +1049,7 @@ static int sis_chip_free(struct sis7019 *sis) /* Reset the chip, and disable all interrputs. */ outl(SIS_GCR_SOFTWARE_RESET, sis->ioport + SIS_GCR); - udelay(10); + udelay(25); outl(0, sis->ioport + SIS_GCR); outl(0, sis->ioport + SIS_GIER); @@ -1085,7 +1085,7 @@ static int sis_chip_init(struct sis7019 *sis) /* Reset the audio controller */ outl(SIS_GCR_SOFTWARE_RESET, io + SIS_GCR); - udelay(10); + udelay(25); outl(0, io + SIS_GCR); /* Get the AC-link semaphore, and reset the codecs @@ -1098,7 +1098,7 @@ static int sis_chip_init(struct sis7019 *sis) return -EIO; outl(SIS_AC97_CMD_CODEC_COLD_RESET, io + SIS_AC97_CMD); - udelay(10); + udelay(250); count = 0xffff; while ((inw(io + SIS_AC97_STATUS) & SIS_AC97_STATUS_BUSY) && --count) -- cgit v1.1 From 1636f8ac2b08410df4766449f7c86b912443cd99 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Fri, 18 Jun 2010 11:09:58 -0600 Subject: sparc/of: Move of_device fields into struct pdev_archdata This patch moves SPARC architecture specific data members out of struct of_device and into the pdev_archdata structure. The reason for this change is to unify the struct of_device definition amongst all the architectures. It also remvoes the .sysdata, .slot, .portid and .clock_freq properties because they aren't actually used by anything. A subsequent patch will replace struct of_device entirely with struct platform_device and the of_platform support code will share common routines with the platform bus (but the bus instances themselves can remain separate). This patch also adds 'struct resources *resource' and num_resources to match the fields defined in struct platform_device. After this change, 'struct platform_device' can be used as a drop-in replacement for 'struct of_platform'. This change is in preparation for merging the of_platform_bus_type with the platform_bus_type. Signed-off-by: Grant Likely Acked-by: David S. Miller Cc: Stephen Rothwell --- sound/sparc/amd7930.c | 2 +- sound/sparc/cs4231.c | 14 +++++++------- sound/sparc/dbri.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'sound') diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index 71221fd..43c63d4 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -1010,7 +1010,7 @@ static int __devinit amd7930_sbus_probe(struct of_device *op, const struct of_de struct snd_amd7930 *amd; int err, irq; - irq = op->irqs[0]; + irq = op->archdata.irqs[0]; if (dev_num >= SNDRV_CARDS) return -ENODEV; diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index fb4c6f2..f7f05c2 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -1832,14 +1832,14 @@ static int __devinit snd_cs4231_sbus_create(struct snd_card *card, chip->c_dma.request = sbus_dma_request; chip->c_dma.address = sbus_dma_addr; - if (request_irq(op->irqs[0], snd_cs4231_sbus_interrupt, + if (request_irq(op->archdata.irqs[0], snd_cs4231_sbus_interrupt, IRQF_SHARED, "cs4231", chip)) { snd_printdd("cs4231-%d: Unable to grab SBUS IRQ %d\n", - dev, op->irqs[0]); + dev, op->archdata.irqs[0]); snd_cs4231_sbus_free(chip); return -EBUSY; } - chip->irq[0] = op->irqs[0]; + chip->irq[0] = op->archdata.irqs[0]; if (snd_cs4231_probe(chip) < 0) { snd_cs4231_sbus_free(chip); @@ -1870,7 +1870,7 @@ static int __devinit cs4231_sbus_probe(struct of_device *op, const struct of_dev card->shortname, rp->flags & 0xffL, (unsigned long long)rp->start, - op->irqs[0]); + op->archdata.irqs[0]); err = snd_cs4231_sbus_create(card, op, dev); if (err < 0) { @@ -1979,12 +1979,12 @@ static int __devinit snd_cs4231_ebus_create(struct snd_card *card, chip->c_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER; chip->c_dma.ebus_info.callback = snd_cs4231_ebus_capture_callback; chip->c_dma.ebus_info.client_cookie = chip; - chip->c_dma.ebus_info.irq = op->irqs[0]; + chip->c_dma.ebus_info.irq = op->archdata.irqs[0]; strcpy(chip->p_dma.ebus_info.name, "cs4231(play)"); chip->p_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER; chip->p_dma.ebus_info.callback = snd_cs4231_ebus_play_callback; chip->p_dma.ebus_info.client_cookie = chip; - chip->p_dma.ebus_info.irq = op->irqs[1]; + chip->p_dma.ebus_info.irq = op->archdata.irqs[1]; chip->p_dma.prepare = _ebus_dma_prepare; chip->p_dma.enable = _ebus_dma_enable; @@ -2060,7 +2060,7 @@ static int __devinit cs4231_ebus_probe(struct of_device *op, const struct of_dev sprintf(card->longname, "%s at 0x%llx, irq %d", card->shortname, op->resource[0].start, - op->irqs[0]); + op->archdata.irqs[0]); err = snd_cs4231_ebus_create(card, op, dev); if (err < 0) { diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 1557bf1..491ce71 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2608,7 +2608,7 @@ static int __devinit dbri_probe(struct of_device *op, const struct of_device_id return -ENOENT; } - irq = op->irqs[0]; + irq = op->archdata.irqs[0]; if (irq <= 0) { printk(KERN_ERR "DBRI-%d: No IRQ.\n", dev); return -ENODEV; -- cgit v1.1 From f189efcd1cc06b75fe18642c9751d26aa5ed2b54 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 5 Jul 2010 17:28:17 +0200 Subject: ALSA: hda - Enable beep on Realtek codecs with PCI SSID override When the PCI SSID gives an overriding SKU assno, PC-beep bit isn't detected (since it's located over 16bit), resulting in no PC beep. Also, many devices seem ignoring the requirement by Realtek's spec for SSID numbers, and it also confuses the PC beep detection. This patch assumes the PC beep is available on every machine with PCI SSID override. It's a regression fix from 2.6.34. Reference: Kernel bug 16251 http://bugzilla.kernel.org/show_bug.cgi?id=16251 Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 32299ee..ff614dd8 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1268,8 +1268,10 @@ static int alc_auto_parse_customize_define(struct hda_codec *codec) struct alc_spec *spec = codec->spec; ass = codec->subsystem_id & 0xffff; - if (ass != codec->bus->pci->subsystem_device && (ass & 1)) + if (ass != codec->bus->pci->subsystem_device && (ass & 1)) { + spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ goto do_sku; + } nid = 0x1d; if (codec->vendor_id == 0x10ec0260) -- cgit v1.1 From 171d9f7d786681e76bb289d01d8f897cbc50de57 Mon Sep 17 00:00:00 2001 From: John Kacur Date: Sun, 4 Jul 2010 00:02:31 +0200 Subject: soundcore_open: Reduce the area BKL coverage Most of this function is protected by the sound_loader_lock. We can push down the BKL to this call out err = file->f_op->open(inode,file); In order to build the sound core without the BKL, we will need to push the lock_kernel() call into the ~20 device drivers that register their file operations. Signed-off-by: John Kacur Signed-off-by: Arnd Bergmann Acked-by: Alan Cox Signed-off-by: Takashi Iwai --- sound/sound_core.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/sound_core.c b/sound/sound_core.c index 7c2d677..c8627fc 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c @@ -576,8 +576,6 @@ static int soundcore_open(struct inode *inode, struct file *file) struct sound_unit *s; const struct file_operations *new_fops = NULL; - lock_kernel (); - chain=unit&0x0F; if(chain==4 || chain==5) /* dsp/audio/dsp16 */ { @@ -630,18 +628,23 @@ static int soundcore_open(struct inode *inode, struct file *file) const struct file_operations *old_fops = file->f_op; file->f_op = new_fops; spin_unlock(&sound_loader_lock); - if(file->f_op->open) + + if (file->f_op->open) { + /* TODO: push down BKL into indivial open functions */ + lock_kernel(); err = file->f_op->open(inode,file); + unlock_kernel(); + } + if (err) { fops_put(file->f_op); file->f_op = fops_get(old_fops); } + fops_put(old_fops); - unlock_kernel(); return err; } spin_unlock(&sound_loader_lock); - unlock_kernel(); return -ENODEV; } -- cgit v1.1 From 168f1b07ccc0e8edecb67fab2d0670861853e2fd Mon Sep 17 00:00:00 2001 From: Eliot Blennerhassett Date: Tue, 6 Jul 2010 08:37:06 +1200 Subject: ALSA: asihpi - HPI API updates Remove some deprecated items. Change compander api to one function per parameter. Add a version string define. Signed-off-by: Eliot Blennerhassett Signed-off-by: Takashi Iwai --- sound/pci/asihpi/asihpi.c | 10 +++---- sound/pci/asihpi/hpi.h | 68 ++++++++++++++++++++++++++++++++------------- sound/pci/asihpi/hpidebug.h | 4 +-- 3 files changed, 55 insertions(+), 27 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index 1db586a..91218f7 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c @@ -1383,7 +1383,7 @@ static char *asihpi_src_names[] = compile_time_assert( (ARRAY_SIZE(asihpi_src_names) == - (HPI_SOURCENODE_LAST_INDEX-HPI_SOURCENODE_BASE+1)), + (HPI_SOURCENODE_LAST_INDEX-HPI_SOURCENODE_NONE+1)), assert_src_names_size); #if ASI_STYLE_NAMES @@ -1414,7 +1414,7 @@ static char *asihpi_dst_names[] = compile_time_assert( (ARRAY_SIZE(asihpi_dst_names) == - (HPI_DESTNODE_LAST_INDEX-HPI_DESTNODE_BASE+1)), + (HPI_DESTNODE_LAST_INDEX-HPI_DESTNODE_NONE+1)), assert_dst_names_size); static inline int ctl_add(struct snd_card *card, struct snd_kcontrol_new *ctl, @@ -2171,7 +2171,7 @@ static int snd_asihpi_mux_info(struct snd_kcontrol *kcontrol, &src_node_type, &src_node_index); sprintf(uinfo->value.enumerated.name, "%s %d", - asihpi_src_names[src_node_type - HPI_SOURCENODE_BASE], + asihpi_src_names[src_node_type - HPI_SOURCENODE_NONE], src_node_index); return 0; } @@ -2603,8 +2603,8 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) } - hpi_ctl.src_node_type -= HPI_SOURCENODE_BASE; - hpi_ctl.dst_node_type -= HPI_DESTNODE_BASE; + hpi_ctl.src_node_type -= HPI_SOURCENODE_NONE; + hpi_ctl.dst_node_type -= HPI_DESTNODE_NONE; /* ASI50xx in SSX mode has multiple meters on the same node. Use subindex to create distinct ALSA controls diff --git a/sound/pci/asihpi/hpi.h b/sound/pci/asihpi/hpi.h index 0173bbe..cee4df4 100644 --- a/sound/pci/asihpi/hpi.h +++ b/sound/pci/asihpi/hpi.h @@ -50,7 +50,8 @@ i.e 3.05.02 is a development version #define HPI_VER_RELEASE(v) ((int)(v & 0xFF)) /* Use single digits for versions less that 10 to avoid octal. */ -#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 3, 25) +#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 3, 36) +#define HPI_VER_STRING "4.03.36" /* Library version as documented in hpi-api-versions.txt */ #define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0) @@ -203,8 +204,6 @@ enum HPI_SOURCENODES { exists on a destination node can be searched for using a source node value of either 0, or HPI_SOURCENODE_NONE */ HPI_SOURCENODE_NONE = 100, - /** \deprecated Use HPI_SOURCENODE_NONE instead. */ - HPI_SOURCENODE_BASE = 100, /** Out Stream (Play) node. */ HPI_SOURCENODE_OSTREAM = 101, /** Line in node - could be analog, AES/EBU or network. */ @@ -235,8 +234,6 @@ enum HPI_DESTNODES { exists on a source node can be searched for using a destination node value of either 0, or HPI_DESTNODE_NONE */ HPI_DESTNODE_NONE = 200, - /** \deprecated Use HPI_DESTNODE_NONE instead. */ - HPI_DESTNODE_BASE = 200, /** In Stream (Record) node. */ HPI_DESTNODE_ISTREAM = 201, HPI_DESTNODE_LINEOUT = 202, /**< line out node. */ @@ -432,7 +429,18 @@ Property 2 - adapter can do stream grouping (supports SSX2) Property 1 - adapter can do samplerate conversion (MRX) Property 2 - adapter can do timestretch (TSX) */ - HPI_ADAPTER_PROPERTY_CAPS2 = 269 + HPI_ADAPTER_PROPERTY_CAPS2 = 269, + +/** Readonly adapter sync header connection count. +*/ + HPI_ADAPTER_PROPERTY_SYNC_HEADER_CONNECTIONS = 270, +/** Readonly supports SSX2 property. +Indicates the adapter supports SSX2 in some mode setting. The +return value is true (1) or false (0). If the current adapter +mode is MONO SSX2 is disabled, even though this property will +return true. +*/ + HPI_ADAPTER_PROPERTY_SUPPORTS_SSX2 = 271 }; /** Adapter mode commands @@ -813,8 +821,6 @@ enum HPI_SAMPLECLOCK_SOURCES { /** The sampleclock output is derived from its local samplerate generator. The local samplerate may be set using HPI_SampleClock_SetLocalRate(). */ HPI_SAMPLECLOCK_SOURCE_LOCAL = 1, -/** \deprecated Use HPI_SAMPLECLOCK_SOURCE_LOCAL instead */ - HPI_SAMPLECLOCK_SOURCE_ADAPTER = 1, /** The adapter is clocked from a dedicated AES/EBU SampleClock input.*/ HPI_SAMPLECLOCK_SOURCE_AESEBU_SYNC = 2, /** From external wordclock connector */ @@ -825,10 +831,6 @@ enum HPI_SAMPLECLOCK_SOURCES { HPI_SAMPLECLOCK_SOURCE_SMPTE = 5, /** One of the aesebu inputs */ HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT = 6, -/** \deprecated The first aesebu input with a valid signal -Superseded by separate Auto enable flag -*/ - HPI_SAMPLECLOCK_SOURCE_AESEBU_AUTO = 7, /** From a network interface e.g. Cobranet or Livewire at either 48 or 96kHz */ HPI_SAMPLECLOCK_SOURCE_NETWORK = 8, /** From previous adjacent module (ASI2416 only)*/ @@ -1015,8 +1017,6 @@ enum HPI_ERROR_CODES { HPI_ERROR_CONTROL_DISABLED = 404, /** I2C transaction failed due to a missing ACK. */ HPI_ERROR_CONTROL_I2C_MISSING_ACK = 405, - /** Control attribute is valid, but not supported by this hardware. */ - HPI_ERROR_UNSUPPORTED_CONTROL_ATTRIBUTE = 406, /** Control is busy, or coming out of reset and cannot be accessed at this time. */ HPI_ERROR_CONTROL_NOT_READY = 407, @@ -1827,13 +1827,41 @@ u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys, Compressor Expander control *******************************/ -u16 hpi_compander_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, - u16 attack, u16 decay, short ratio100, short threshold0_01dB, - short makeup_gain0_01dB); +u16 hpi_compander_set_enable(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 on); + +u16 hpi_compander_get_enable(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *pon); + +u16 hpi_compander_set_makeup_gain(const struct hpi_hsubsys *ph_subsys, + u32 h_control, short makeup_gain0_01dB); + +u16 hpi_compander_get_makeup_gain(const struct hpi_hsubsys *ph_subsys, + u32 h_control, short *pn_makeup_gain0_01dB); + +u16 hpi_compander_set_attack_time_constant(const struct hpi_hsubsys + *ph_subsys, u32 h_control, u32 index, u32 attack); + +u16 hpi_compander_get_attack_time_constant(const struct hpi_hsubsys + *ph_subsys, u32 h_control, u32 index, u32 *pw_attack); + +u16 hpi_compander_set_decay_time_constant(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 index, u32 decay); + +u16 hpi_compander_get_decay_time_constant(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 index, u32 *pw_decay); + +u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 index, short threshold0_01dB); + +u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 index, short *pn_threshold0_01dB); + +u16 hpi_compander_set_ratio(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 index, u32 ratio100); -u16 hpi_compander_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, - u16 *pw_attack, u16 *pw_decay, short *pw_ratio100, - short *pn_threshold0_01dB, short *pn_makeup_gain0_01dB); +u16 hpi_compander_get_ratio(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 index, u32 *pw_ratio100); /******************************* Cobranet HMI control diff --git a/sound/pci/asihpi/hpidebug.h b/sound/pci/asihpi/hpidebug.h index 44dccad..a2f0952 100644 --- a/sound/pci/asihpi/hpidebug.h +++ b/sound/pci/asihpi/hpidebug.h @@ -356,7 +356,7 @@ compile_time_assert((HPI_CONTROL_LAST_INDEX + 1 == 27), "HPI_SOURCENODE_ADAPTER" \ } -compile_time_assert((HPI_SOURCENODE_LAST_INDEX - HPI_SOURCENODE_BASE + 1) == +compile_time_assert((HPI_SOURCENODE_LAST_INDEX - HPI_SOURCENODE_NONE + 1) == (12), sourcenode_strings_match_defs); #define HPI_DESTNODE_STRINGS \ @@ -370,7 +370,7 @@ compile_time_assert((HPI_SOURCENODE_LAST_INDEX - HPI_SOURCENODE_BASE + 1) == "HPI_DESTNODE_COBRANET", \ "HPI_DESTNODE_ANALOG" \ } -compile_time_assert((HPI_DESTNODE_LAST_INDEX - HPI_DESTNODE_BASE + 1) == (8), +compile_time_assert((HPI_DESTNODE_LAST_INDEX - HPI_DESTNODE_NONE + 1) == (8), destnode_strings_match_defs); #define HPI_CONTROL_CHANNEL_MODE_STRINGS \ -- cgit v1.1 From 1dd6aaaafc930dd9bfaa6ea1d21bac2b4ec12527 Mon Sep 17 00:00:00 2001 From: Eliot Blennerhassett Date: Tue, 6 Jul 2010 08:37:07 +1200 Subject: ALSA: asihpi - Use version string instead of printf formatting Signed-off-by: Eliot Blennerhassett Signed-off-by: Takashi Iwai --- sound/pci/asihpi/hpioctl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c index 7396ac5..3114999 100644 --- a/sound/pci/asihpi/hpioctl.c +++ b/sound/pci/asihpi/hpioctl.c @@ -464,9 +464,7 @@ void __init asihpi_init(void) memset(adapters, 0, sizeof(adapters)); - printk(KERN_INFO "ASIHPI driver %d.%02d.%02d\n", - HPI_VER_MAJOR(HPI_VER), HPI_VER_MINOR(HPI_VER), - HPI_VER_RELEASE(HPI_VER)); + printk(KERN_INFO "ASIHPI driver " HPI_VER_STRING "\n"); hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_DRIVER_LOAD); -- cgit v1.1 From 38439146355de2c10c369f93136333be6107a16b Mon Sep 17 00:00:00 2001 From: Eliot Blennerhassett Date: Tue, 6 Jul 2010 08:37:08 +1200 Subject: ALSA: asihpi - Add ASI5200 family Signed-off-by: Eliot Blennerhassett Signed-off-by: Takashi Iwai --- sound/pci/asihpi/hpi6000.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sound') diff --git a/sound/pci/asihpi/hpi6000.c b/sound/pci/asihpi/hpi6000.c index 12dab5e..f7e374e 100644 --- a/sound/pci/asihpi/hpi6000.c +++ b/sound/pci/asihpi/hpi6000.c @@ -687,6 +687,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, switch (pao->pci.subsys_device_id) { case 0x5100: case 0x5110: /* ASI5100 revB or higher with C6711D */ + case 0x5200: /* ASI5200 PC_ie version of ASI5100 */ case 0x6100: case 0x6200: boot_load_family = HPI_ADAPTER_FAMILY_ASI(0x6200); @@ -1133,6 +1134,12 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, subsys_device_id) == HPI_ADAPTER_FAMILY_ASI(0x5100)) mask = 0x00000000L; + /* ASI5200 uses AX6 code, */ + /* but has no PLD r/w register to test */ + if (HPI_ADAPTER_FAMILY_ASI(pao->pci. + subsys_device_id) == + HPI_ADAPTER_FAMILY_ASI(0x5200)) + mask = 0x00000000L; break; case HPI_ADAPTER_FAMILY_ASI(0x8800): /* ASI8800 has 16bit path to FPGA */ -- cgit v1.1 From 108ccb3f0fa617a003c6b076b73b74d4f85e4cde Mon Sep 17 00:00:00 2001 From: Eliot Blennerhassett Date: Tue, 6 Jul 2010 08:37:09 +1200 Subject: ALSA: asihpi - Change compander API and tidy Compander API changed to one function per parameter. Factor out some common code for stereo log value reading. Make some more entity functions static. Signed-off-by: Eliot Blennerhassett Signed-off-by: Takashi Iwai --- sound/pci/asihpi/hpi_internal.h | 30 ++-- sound/pci/asihpi/hpifunc.c | 324 ++++++++++++++++++++++++---------------- 2 files changed, 211 insertions(+), 143 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/hpi_internal.h b/sound/pci/asihpi/hpi_internal.h index fdd0ce0..7ae7a1d 100644 --- a/sound/pci/asihpi/hpi_internal.h +++ b/sound/pci/asihpi/hpi_internal.h @@ -142,12 +142,15 @@ enum HPI_BUSES { /******************************************* CONTROL ATTRIBUTES ****/ /* (in order of control type ID */ - /* This allows for 255 control types, 256 unique attributes each */ +/* This allows for 255 control types, 256 unique attributes each */ #define HPI_CTL_ATTR(ctl, ai) (HPI_CONTROL_##ctl * 0x100 + ai) /* Get the sub-index of the attribute for a control type */ #define HPI_CTL_ATTR_INDEX(i) (i&0xff) +/* Extract the control from the control attribute */ +#define HPI_CTL_ATTR_CONTROL(i) (i>>8) + /* Generic control attributes. */ /** Enable a control. @@ -311,8 +314,7 @@ Used for HPI_ChannelModeSet/Get() /* Microphone control attributes */ #define HPI_MICROPHONE_PHANTOM_POWER HPI_CTL_ATTR(MICROPHONE, 1) -/** Equalizer control attributes -*/ +/** Equalizer control attributes */ /** Used to get number of filters in an EQ. (Can't set) */ #define HPI_EQUALIZER_NUM_FILTERS HPI_CTL_ATTR(EQUALIZER, 1) /** Set/get the filter by type, freq, Q, gain */ @@ -320,13 +322,15 @@ Used for HPI_ChannelModeSet/Get() /** Get the biquad coefficients */ #define HPI_EQUALIZER_COEFFICIENTS HPI_CTL_ATTR(EQUALIZER, 3) -#define HPI_COMPANDER_PARAMS HPI_CTL_ATTR(COMPANDER, 1) +/* Note compander also uses HPI_GENERIC_ENABLE */ +#define HPI_COMPANDER_PARAMS HPI_CTL_ATTR(COMPANDER, 1) +#define HPI_COMPANDER_MAKEUPGAIN HPI_CTL_ATTR(COMPANDER, 2) +#define HPI_COMPANDER_THRESHOLD HPI_CTL_ATTR(COMPANDER, 3) +#define HPI_COMPANDER_RATIO HPI_CTL_ATTR(COMPANDER, 4) +#define HPI_COMPANDER_ATTACK HPI_CTL_ATTR(COMPANDER, 5) +#define HPI_COMPANDER_DECAY HPI_CTL_ATTR(COMPANDER, 6) -/* Cobranet control attributes. - MUST be distinct from all other control attributes. - This is so that host side processing can easily identify a Cobranet control - and apply additional host side operations (like copying data) as required. -*/ +/* Cobranet control attributes. */ #define HPI_COBRANET_SET HPI_CTL_ATTR(COBRANET, 1) #define HPI_COBRANET_GET HPI_CTL_ATTR(COBRANET, 2) #define HPI_COBRANET_SET_DATA HPI_CTL_ATTR(COBRANET, 3) @@ -1512,11 +1516,11 @@ struct hpi_control_cache_single { struct hpi_control_cache_info i; union { struct { /* volume */ - u16 an_log[2]; + short an_log[2]; } v; struct { /* peak meter */ - u16 an_log_peak[2]; - u16 an_logRMS[2]; + short an_log_peak[2]; + short an_logRMS[2]; } p; struct { /* channel mode */ u16 mode; @@ -1526,7 +1530,7 @@ struct hpi_control_cache_single { u16 source_node_index; } x; struct { /* level/trim */ - u16 an_log[2]; + short an_log[2]; } l; struct { /* tuner - partial caching. some attributes go to the DSP. */ diff --git a/sound/pci/asihpi/hpifunc.c b/sound/pci/asihpi/hpifunc.c index 298eef3..9c6958a 100644 --- a/sound/pci/asihpi/hpifunc.c +++ b/sound/pci/asihpi/hpifunc.c @@ -96,8 +96,7 @@ void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR) static struct hpi_hsubsys gh_subsys; -struct hpi_hsubsys *hpi_subsys_create(void - ) +struct hpi_hsubsys *hpi_subsys_create(void) { struct hpi_message hm; struct hpi_response hr; @@ -302,6 +301,7 @@ u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER, HPI_ADAPTER_SET_MODE); hm.adapter_index = adapter_index; @@ -510,7 +510,7 @@ u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys, hm.adapter_index = adapter_index; hm.u.ax.debug_read.dsp_address = dsp_address; - if (*count_bytes > sizeof(hr.u.bytes)) + if (*count_bytes > (int)sizeof(hr.u.bytes)) *count_bytes = sizeof(hr.u.bytes); hm.u.ax.debug_read.count_bytes = *count_bytes; @@ -976,6 +976,7 @@ u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM, HPI_OSTREAM_ANC_READ); u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index); @@ -1581,6 +1582,7 @@ u16 hpi_control_param_set(const struct hpi_hsubsys *ph_subsys, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -1591,6 +1593,22 @@ u16 hpi_control_param_set(const struct hpi_hsubsys *ph_subsys, return hr.error; } +static u16 hpi_control_log_set2(u32 h_control, u16 attrib, short sv0, + short sv1) +{ + struct hpi_message hm; + struct hpi_response hr; + + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, + HPI_CONTROL_SET_STATE); + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = attrib; + hm.u.c.an_log_value[0] = sv0; + hm.u.c.an_log_value[1] = sv1; + hpi_send_recv(&hm, &hr); + return hr.error; +} + static u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys, const u32 h_control, const u16 attrib, u32 param1, u32 param2, @@ -1598,6 +1616,7 @@ u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -1605,8 +1624,8 @@ u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys, hm.u.c.param1 = param1; hm.u.c.param2 = param2; hpi_send_recv(&hm, &hr); - if (pparam1) - *pparam1 = hr.u.c.param1; + + *pparam1 = hr.u.c.param1; if (pparam2) *pparam2 = hr.u.c.param2; @@ -1617,10 +1636,23 @@ u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys, hpi_control_param_get(s, h, a, 0, 0, p1, NULL) #define hpi_control_param2_get(s, h, a, p1, p2) \ hpi_control_param_get(s, h, a, 0, 0, p1, p2) -#define hpi_control_ex_param1_get(s, h, a, p1) \ - hpi_control_ex_param_get(s, h, a, 0, 0, p1, NULL) -#define hpi_control_ex_param2_get(s, h, a, p1, p2) \ - hpi_control_ex_param_get(s, h, a, 0, 0, p1, p2) + +static u16 hpi_control_log_get2(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u16 attrib, short *sv0, short *sv1) +{ + struct hpi_message hm; + struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, + HPI_CONTROL_GET_STATE); + u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); + hm.u.c.attribute = attrib; + + hpi_send_recv(&hm, &hr); + *sv0 = hr.u.c.an_log_value[0]; + if (sv1) + *sv1 = hr.u.c.an_log_value[1]; + return hr.error; +} static u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys, @@ -1629,6 +1661,7 @@ u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_INFO); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -1643,9 +1676,8 @@ u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys, return hr.error; } -static u16 hpi_control_get_string(const struct hpi_hsubsys *ph_subsys, - const u32 h_control, const u16 attribute, char *psz_string, - const u32 string_length) +static u16 hpi_control_get_string(const u32 h_control, const u16 attribute, + char *psz_string, const u32 string_length) { unsigned int sub_string_index = 0, j = 0; char c = 0; @@ -1916,6 +1948,7 @@ u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, HPI_CONTROL_SET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -1941,6 +1974,7 @@ u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, HPI_CONTROL_GET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -1980,6 +2014,7 @@ u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, HPI_CONTROL_GET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -2006,6 +2041,7 @@ u16 hpi_cobranet_getI_paddress(const struct hpi_hsubsys *ph_subsys, u32 byte_count; u32 iP; u16 error; + error = hpi_cobranet_hmi_read(ph_subsys, h_control, HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count, (u8 *)&iP); @@ -2082,6 +2118,7 @@ u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys, u32 byte_count; u16 error; u32 mAC; + error = hpi_cobranet_hmi_read(ph_subsys, h_control, HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count, (u8 *)&mAC); @@ -2103,53 +2140,111 @@ u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys, return error; } -u16 hpi_compander_set(const struct hpi_hsubsys *ph_subsys, u32 h_control, - u16 attack, u16 decay, short ratio100, short threshold0_01dB, - short makeup_gain0_01dB) +u16 hpi_compander_set_enable(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 enable) +{ + return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE, + enable, 0); +} + +u16 hpi_compander_get_enable(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 *enable) +{ + return hpi_control_param1_get(ph_subsys, h_control, + HPI_GENERIC_ENABLE, enable); +} + +u16 hpi_compander_set_makeup_gain(const struct hpi_hsubsys *ph_subsys, + u32 h_control, short makeup_gain0_01dB) +{ + return hpi_control_log_set2(h_control, HPI_COMPANDER_MAKEUPGAIN, + makeup_gain0_01dB, 0); +} + +u16 hpi_compander_get_makeup_gain(const struct hpi_hsubsys *ph_subsys, + u32 h_control, short *makeup_gain0_01dB) +{ + return hpi_control_log_get2(ph_subsys, h_control, + HPI_COMPANDER_MAKEUPGAIN, makeup_gain0_01dB, NULL); +} + +u16 hpi_compander_set_attack_time_constant(const struct hpi_hsubsys + *ph_subsys, u32 h_control, unsigned int index, u32 attack) +{ + return hpi_control_param_set(ph_subsys, h_control, + HPI_COMPANDER_ATTACK, attack, index); +} + +u16 hpi_compander_get_attack_time_constant(const struct hpi_hsubsys + *ph_subsys, u32 h_control, unsigned int index, u32 *attack) +{ + return hpi_control_param_get(ph_subsys, h_control, + HPI_COMPANDER_ATTACK, 0, index, attack, &index); +} + +u16 hpi_compander_set_decay_time_constant(const struct hpi_hsubsys *ph_subsys, + u32 h_control, unsigned int index, u32 decay) +{ + return hpi_control_param_set(ph_subsys, h_control, + HPI_COMPANDER_DECAY, decay, index); +} + +u16 hpi_compander_get_decay_time_constant(const struct hpi_hsubsys *ph_subsys, + u32 h_control, unsigned int index, u32 *decay) +{ + return hpi_control_param_get(ph_subsys, h_control, + HPI_COMPANDER_DECAY, 0, index, decay, &index); + +} + +u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys, + u32 h_control, unsigned int index, short threshold0_01dB) { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); - - hm.u.c.param1 = attack + ((u32)ratio100 << 16); - hm.u.c.param2 = (decay & 0xFFFFL); + hm.u.c.attribute = HPI_COMPANDER_THRESHOLD; + hm.u.c.param2 = index; hm.u.c.an_log_value[0] = threshold0_01dB; - hm.u.c.an_log_value[1] = makeup_gain0_01dB; - hm.u.c.attribute = HPI_COMPANDER_PARAMS; hpi_send_recv(&hm, &hr); return hr.error; } -u16 hpi_compander_get(const struct hpi_hsubsys *ph_subsys, u32 h_control, - u16 *pw_attack, u16 *pw_decay, short *pw_ratio100, - short *pn_threshold0_01dB, short *pn_makeup_gain0_01dB) +u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys, + u32 h_control, unsigned int index, short *threshold0_01dB) { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); - hm.u.c.attribute = HPI_COMPANDER_PARAMS; + hm.u.c.attribute = HPI_COMPANDER_THRESHOLD; + hm.u.c.param2 = index; hpi_send_recv(&hm, &hr); + *threshold0_01dB = hr.u.c.an_log_value[0]; - if (pw_attack) - *pw_attack = (short)(hr.u.c.param1 & 0xFFFF); - if (pw_decay) - *pw_decay = (short)(hr.u.c.param2 & 0xFFFF); - if (pw_ratio100) - *pw_ratio100 = (short)(hr.u.c.param1 >> 16); + return hr.error; +} - if (pn_threshold0_01dB) - *pn_threshold0_01dB = hr.u.c.an_log_value[0]; - if (pn_makeup_gain0_01dB) - *pn_makeup_gain0_01dB = hr.u.c.an_log_value[1]; +u16 hpi_compander_set_ratio(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 index, u32 ratio100) +{ + return hpi_control_param_set(ph_subsys, h_control, + HPI_COMPANDER_RATIO, ratio100, index); +} - return hr.error; +u16 hpi_compander_get_ratio(const struct hpi_hsubsys *ph_subsys, + u32 h_control, u32 index, u32 *ratio100) +{ + return hpi_control_param_get(ph_subsys, h_control, + HPI_COMPANDER_RATIO, 0, index, ratio100, &index); } u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, @@ -2157,6 +2252,7 @@ u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -2181,37 +2277,16 @@ u16 hpi_level_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS] ) { - struct hpi_message hm; - struct hpi_response hr; - - hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, - HPI_CONTROL_SET_STATE); - u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); - memcpy(hm.u.c.an_log_value, an_gain0_01dB, - sizeof(short) * HPI_MAX_CHANNELS); - hm.u.c.attribute = HPI_LEVEL_GAIN; - - hpi_send_recv(&hm, &hr); - - return hr.error; + return hpi_control_log_set2(h_control, HPI_LEVEL_GAIN, + an_gain0_01dB[0], an_gain0_01dB[1]); } u16 hpi_level_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS] ) { - struct hpi_message hm; - struct hpi_response hr; - hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, - HPI_CONTROL_GET_STATE); - u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); - hm.u.c.attribute = HPI_LEVEL_GAIN; - - hpi_send_recv(&hm, &hr); - - memcpy(an_gain0_01dB, hr.u.c.an_log_value, - sizeof(short) * HPI_MAX_CHANNELS); - return hr.error; + return hpi_control_log_get2(ph_subsys, h_control, HPI_LEVEL_GAIN, + &an_gain0_01dB[0], &an_gain0_01dB[1]); } u16 hpi_meter_query_channels(const struct hpi_hsubsys *ph_subsys, @@ -2413,6 +2488,7 @@ u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -2439,6 +2515,7 @@ u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -2460,6 +2537,7 @@ u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -2623,8 +2701,8 @@ u16 hpi_tone_detector_get_frequency(const struct hpi_hsubsys *ph_subsys, u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 *state) { - return hpi_control_param_get(ph_subsys, h_control, - HPI_TONEDETECTOR_STATE, 0, 0, (u32 *)state, NULL); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_TONEDETECTOR_STATE, state); } u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys, @@ -2637,8 +2715,8 @@ u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys, u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 *enable) { - return hpi_control_param_get(ph_subsys, h_control, HPI_GENERIC_ENABLE, - 0, 0, (u32 *)enable, NULL); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_GENERIC_ENABLE, enable); } u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, @@ -2651,8 +2729,8 @@ u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 *event_enable) { - return hpi_control_param_get(ph_subsys, h_control, - HPI_GENERIC_EVENT_ENABLE, 0, 0, (u32 *)event_enable, NULL); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_GENERIC_EVENT_ENABLE, event_enable); } u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, @@ -2665,15 +2743,15 @@ u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, int *threshold) { - return hpi_control_param_get(ph_subsys, h_control, - HPI_TONEDETECTOR_THRESHOLD, 0, 0, (u32 *)threshold, NULL); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_TONEDETECTOR_THRESHOLD, (u32 *)threshold); } u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 *state) { - return hpi_control_param_get(ph_subsys, h_control, - HPI_SILENCEDETECTOR_STATE, 0, 0, (u32 *)state, NULL); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_SILENCEDETECTOR_STATE, state); } u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys, @@ -2686,50 +2764,50 @@ u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys, u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 *enable) { - return hpi_control_param_get(ph_subsys, h_control, HPI_GENERIC_ENABLE, - 0, 0, (u32 *)enable, NULL); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_GENERIC_ENABLE, enable); } u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 event_enable) { return hpi_control_param_set(ph_subsys, h_control, - HPI_GENERIC_EVENT_ENABLE, (u32)event_enable, 0); + HPI_GENERIC_EVENT_ENABLE, event_enable, 0); } u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 *event_enable) { - return hpi_control_param_get(ph_subsys, h_control, - HPI_GENERIC_EVENT_ENABLE, 0, 0, (u32 *)event_enable, NULL); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_GENERIC_EVENT_ENABLE, event_enable); } u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 delay) { return hpi_control_param_set(ph_subsys, h_control, - HPI_SILENCEDETECTOR_DELAY, (u32)delay, 0); + HPI_SILENCEDETECTOR_DELAY, delay, 0); } u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 *delay) { - return hpi_control_param_get(ph_subsys, h_control, - HPI_SILENCEDETECTOR_DELAY, 0, 0, (u32 *)delay, NULL); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_SILENCEDETECTOR_DELAY, delay); } u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, int threshold) { return hpi_control_param_set(ph_subsys, h_control, - HPI_SILENCEDETECTOR_THRESHOLD, (u32)threshold, 0); + HPI_SILENCEDETECTOR_THRESHOLD, threshold, 0); } u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, int *threshold) { - return hpi_control_param_get(ph_subsys, h_control, - HPI_SILENCEDETECTOR_THRESHOLD, 0, 0, (u32 *)threshold, NULL); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_SILENCEDETECTOR_THRESHOLD, (u32 *)threshold); } u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys, @@ -2822,6 +2900,7 @@ u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -2838,6 +2917,7 @@ u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -2894,14 +2974,14 @@ u16 hpi_tuner_get_program(const struct hpi_hsubsys *ph_subsys, u32 h_control, u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys, u32 h_control, char *psz_dsp_version, const u32 string_size) { - return hpi_control_get_string(ph_subsys, h_control, + return hpi_control_get_string(h_control, HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size); } u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys, u32 h_control, char *psz_sdk_version, const u32 string_size) { - return hpi_control_get_string(ph_subsys, h_control, + return hpi_control_get_string(h_control, HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size); } @@ -2942,15 +3022,15 @@ u16 hpi_tuner_get_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control, u16 hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 *pquality) { - return hpi_control_param_get(ph_subsys, h_control, - HPI_TUNER_HDRADIO_SIGNAL_QUALITY, 0, 0, pquality, NULL); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_TUNER_HDRADIO_SIGNAL_QUALITY, pquality); } u16 hpi_tuner_get_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 *pblend) { - return hpi_control_param_get(ph_subsys, h_control, - HPI_TUNER_HDRADIO_BLEND, 0, 0, pblend, NULL); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_TUNER_HDRADIO_BLEND, pblend); } u16 hpi_tuner_set_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys, @@ -2965,6 +3045,7 @@ u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -2981,43 +3062,43 @@ u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control, u16 HPI_PAD__get_channel_name(const struct hpi_hsubsys *ph_subsys, u32 h_control, char *psz_string, const u32 data_length) { - return hpi_control_get_string(ph_subsys, h_control, - HPI_PAD_CHANNEL_NAME, psz_string, data_length); + return hpi_control_get_string(h_control, HPI_PAD_CHANNEL_NAME, + psz_string, data_length); } u16 HPI_PAD__get_artist(const struct hpi_hsubsys *ph_subsys, u32 h_control, char *psz_string, const u32 data_length) { - return hpi_control_get_string(ph_subsys, h_control, HPI_PAD_ARTIST, - psz_string, data_length); + return hpi_control_get_string(h_control, HPI_PAD_ARTIST, psz_string, + data_length); } u16 HPI_PAD__get_title(const struct hpi_hsubsys *ph_subsys, u32 h_control, char *psz_string, const u32 data_length) { - return hpi_control_get_string(ph_subsys, h_control, HPI_PAD_TITLE, - psz_string, data_length); + return hpi_control_get_string(h_control, HPI_PAD_TITLE, psz_string, + data_length); } u16 HPI_PAD__get_comment(const struct hpi_hsubsys *ph_subsys, u32 h_control, char *psz_string, const u32 data_length) { - return hpi_control_get_string(ph_subsys, h_control, HPI_PAD_COMMENT, - psz_string, data_length); + return hpi_control_get_string(h_control, HPI_PAD_COMMENT, psz_string, + data_length); } u16 HPI_PAD__get_program_type(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 *ppTY) { - return hpi_control_param_get(ph_subsys, h_control, - HPI_PAD_PROGRAM_TYPE, 0, 0, ppTY, NULL); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_PAD_PROGRAM_TYPE, ppTY); } u16 HPI_PAD__get_rdsPI(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 *ppI) { - return hpi_control_param_get(ph_subsys, h_control, HPI_PAD_PROGRAM_ID, - 0, 0, ppI, NULL); + return hpi_control_param1_get(ph_subsys, h_control, + HPI_PAD_PROGRAM_ID, ppI); } u16 hpi_volume_query_channels(const struct hpi_hsubsys *ph_subsys, @@ -3031,36 +3112,16 @@ u16 hpi_volume_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, short an_log_gain[HPI_MAX_CHANNELS] ) { - struct hpi_message hm; - struct hpi_response hr; - hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, - HPI_CONTROL_SET_STATE); - u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); - memcpy(hm.u.c.an_log_value, an_log_gain, - sizeof(short) * HPI_MAX_CHANNELS); - hm.u.c.attribute = HPI_VOLUME_GAIN; - - hpi_send_recv(&hm, &hr); - - return hr.error; + return hpi_control_log_set2(h_control, HPI_VOLUME_GAIN, + an_log_gain[0], an_log_gain[1]); } u16 hpi_volume_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control, short an_log_gain[HPI_MAX_CHANNELS] ) { - struct hpi_message hm; - struct hpi_response hr; - hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, - HPI_CONTROL_GET_STATE); - u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); - hm.u.c.attribute = HPI_VOLUME_GAIN; - - hpi_send_recv(&hm, &hr); - - memcpy(an_log_gain, hr.u.c.an_log_value, - sizeof(short) * HPI_MAX_CHANNELS); - return hr.error; + return hpi_control_log_get2(ph_subsys, h_control, HPI_VOLUME_GAIN, + &an_log_gain[0], &an_log_gain[1]); } u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, @@ -3068,6 +3129,7 @@ u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -3094,6 +3156,7 @@ u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys, { struct hpi_message hm; struct hpi_response hr; + hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index); @@ -3170,43 +3233,43 @@ static size_t entity_type_to_size[LAST_ENTITY_TYPE] = { 6 * sizeof(char), }; -inline size_t hpi_entity_size(struct hpi_entity *entity_ptr) +static inline size_t hpi_entity_size(struct hpi_entity *entity_ptr) { return entity_ptr->header.size; } -inline size_t hpi_entity_header_size(struct hpi_entity *entity_ptr) +static inline size_t hpi_entity_header_size(struct hpi_entity *entity_ptr) { return sizeof(entity_ptr->header); } -inline size_t hpi_entity_value_size(struct hpi_entity *entity_ptr) +static inline size_t hpi_entity_value_size(struct hpi_entity *entity_ptr) { return hpi_entity_size(entity_ptr) - hpi_entity_header_size(entity_ptr); } -inline size_t hpi_entity_item_count(struct hpi_entity *entity_ptr) +static inline size_t hpi_entity_item_count(struct hpi_entity *entity_ptr) { return hpi_entity_value_size(entity_ptr) / entity_type_to_size[entity_ptr->header.type]; } -inline struct hpi_entity *hpi_entity_ptr_to_next(struct hpi_entity +static inline struct hpi_entity *hpi_entity_ptr_to_next(struct hpi_entity *entity_ptr) { return (void *)(((uint8_t *) entity_ptr) + hpi_entity_size(entity_ptr)); } -inline u16 hpi_entity_check_type(const enum e_entity_type t) +static inline u16 hpi_entity_check_type(const enum e_entity_type t) { if (t >= 0 && t < STR_TYPE_FIELD_MAX) return 0; return HPI_ERROR_ENTITY_TYPE_INVALID; } -inline u16 hpi_entity_check_role(const enum e_entity_role r) +static inline u16 hpi_entity_check_role(const enum e_entity_role r) { if (r >= 0 && r < STR_ROLE_FIELD_MAX) return 0; @@ -3624,6 +3687,7 @@ u16 hpi_async_event_wait(const struct hpi_hsubsys *ph_subsys, u32 h_async, u16 maximum_events, struct hpi_async_event *p_events, u16 *pw_number_returned) { + return 0; } -- cgit v1.1 From 36ed8bdd867314660b8dca2d1b6d9e92352b319b Mon Sep 17 00:00:00 2001 From: Eliot Blennerhassett Date: Tue, 6 Jul 2010 08:37:10 +1200 Subject: ALSA: asihpi - Minor HPI error handling fixes Handle errors in tuner level caching, Ccorrect error code for aesebu rx status. Signed-off-by: Eliot Blennerhassett Signed-off-by: Takashi Iwai --- sound/pci/asihpi/hpicmn.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/hpicmn.c b/sound/pci/asihpi/hpicmn.c index fcd6453..dda4f1c 100644 --- a/sound/pci/asihpi/hpicmn.c +++ b/sound/pci/asihpi/hpicmn.c @@ -353,7 +353,12 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache, phr->u.c.param1 = pC->u.t.band; else if ((phm->u.c.attribute == HPI_TUNER_LEVEL) && (phm->u.c.param1 == HPI_TUNER_LEVEL_AVERAGE)) - phr->u.c.param1 = pC->u.t.level; + if (pC->u.t.level == HPI_ERROR_ILLEGAL_CACHE_VALUE) { + phr->u.c.param1 = 0; + phr->error = + HPI_ERROR_INVALID_CONTROL_ATTRIBUTE; + } else + phr->u.c.param1 = pC->u.t.level; else found = 0; break; @@ -397,7 +402,8 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache, if (pC->u.clk.source_index == HPI_ERROR_ILLEGAL_CACHE_VALUE) { phr->u.c.param1 = 0; - phr->error = HPI_ERROR_INVALID_OPERATION; + phr->error = + HPI_ERROR_INVALID_CONTROL_ATTRIBUTE; } else phr->u.c.param1 = pC->u.clk.source_index; } else if (phm->u.c.attribute == HPI_SAMPLECLOCK_SAMPLERATE) -- cgit v1.1 From f978d36da4024ee22957f74276e944624a8c7f6d Mon Sep 17 00:00:00 2001 From: Eliot Blennerhassett Date: Tue, 6 Jul 2010 08:37:11 +1200 Subject: ALSA: asihpi - Remove unneeded ; Signed-off-by: Eliot Blennerhassett Signed-off-by: Takashi Iwai --- sound/pci/asihpi/hpidebug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/asihpi/hpidebug.c b/sound/pci/asihpi/hpidebug.c index 4cd85a4..949836e 100644 --- a/sound/pci/asihpi/hpidebug.c +++ b/sound/pci/asihpi/hpidebug.c @@ -111,7 +111,7 @@ make_treenode_from_array(hpi_control_type_strings, HPI_CONTROL_TYPE_STRINGS) &hpi_profile_strings,\ &hpi_control_strings, \ &hpi_asyncevent_strings \ -}; +} make_treenode_from_array(hpi_function_strings, HPI_FUNCTION_STRINGS) compile_time_assert(HPI_OBJ_MAXINDEX == 14, obj_list_doesnt_match); -- cgit v1.1 From ac0547dc62e67a3e0b0c1628b6e49efba8f517db Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 5 Jul 2010 16:50:13 +0200 Subject: ALSA: hda - Restore cleared pin controls on resume Many codecs now clear the pin controls at suspend via snd_hda_shutup_pins() for reducing the click noise at power-off. But this leaves some pins uninitialized, and they'll be never recovered after resume. This patch adds the proper recovery of cleared pin controls on resume. Also it adds a check of bus->shutdown so that pins won't be cleared at module unloading. Reference: Kernel bug 16339 http://bugzilla.kernel.org/show_bug.cgi?id=16339 Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 27 +++++++++++++++++++++++++++ sound/pci/hda/hda_codec.h | 5 ++++- 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index a3d638c..ba2098d 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -784,6 +784,9 @@ static int read_pin_defaults(struct hda_codec *codec) pin->nid = nid; pin->cfg = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); + pin->ctrl = snd_hda_codec_read(codec, nid, 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, + 0); } return 0; } @@ -912,15 +915,38 @@ static void restore_pincfgs(struct hda_codec *codec) void snd_hda_shutup_pins(struct hda_codec *codec) { int i; + /* don't shut up pins when unloading the driver; otherwise it breaks + * the default pin setup at the next load of the driver + */ + if (codec->bus->shutdown) + return; for (i = 0; i < codec->init_pins.used; i++) { struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); /* use read here for syncing after issuing each verb */ snd_hda_codec_read(codec, pin->nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0); } + codec->pins_shutup = 1; } EXPORT_SYMBOL_HDA(snd_hda_shutup_pins); +/* Restore the pin controls cleared previously via snd_hda_shutup_pins() */ +static void restore_shutup_pins(struct hda_codec *codec) +{ + int i; + if (!codec->pins_shutup) + return; + if (codec->bus->shutdown) + return; + for (i = 0; i < codec->init_pins.used; i++) { + struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); + snd_hda_codec_write(codec, pin->nid, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, + pin->ctrl); + } + codec->pins_shutup = 0; +} + static void init_hda_cache(struct hda_cache_rec *cache, unsigned int record_size); static void free_hda_cache(struct hda_cache_rec *cache); @@ -2907,6 +2933,7 @@ static void hda_call_codec_resume(struct hda_codec *codec) codec->afg ? codec->afg : codec->mfg, AC_PWRST_D0); restore_pincfgs(codec); /* restore all current pin configs */ + restore_shutup_pins(codec); hda_exec_init_verbs(codec); if (codec->patch_ops.resume) codec->patch_ops.resume(codec); diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 49e939e..5991d14 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -821,6 +821,7 @@ struct hda_codec { unsigned int pin_amp_workaround:1; /* pin out-amp takes index * (e.g. Conexant codecs) */ + unsigned int pins_shutup:1; /* pins are shut up */ unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */ #ifdef CONFIG_SND_HDA_POWER_SAVE unsigned int power_on :1; /* current (global) power-state */ @@ -897,7 +898,9 @@ void snd_hda_codec_resume_cache(struct hda_codec *codec); /* the struct for codec->pin_configs */ struct hda_pincfg { hda_nid_t nid; - unsigned int cfg; + unsigned char ctrl; /* current pin control value */ + unsigned char pad; /* reserved */ + unsigned int cfg; /* default configuration */ }; unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid); -- cgit v1.1 From 3507e2a8f171f4322bf78f9d618a4e435de843ce Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jul 2010 18:39:00 +0200 Subject: ALSA: hda - Add beep mixer support to Conexant codecs Added the beep mixer controls to Conexant codecs. They simply control the digital beep generator widget. For cx5047, I couldn't find any beep generator, so it's not implemented there. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 55 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 54f7419..3b789ee 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -131,6 +131,8 @@ struct conexant_spec { unsigned int dc_enable; unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */ unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ + + unsigned int beep_amp; }; static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo, @@ -515,6 +517,15 @@ static struct snd_kcontrol_new cxt_capture_mixers[] = { {} }; +#ifdef CONFIG_SND_HDA_INPUT_BEEP +/* additional beep mixers; the actual parameters are overwritten at build */ +static struct snd_kcontrol_new cxt_beep_mixer[] = { + HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), + HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), + { } /* end */ +}; +#endif + static const char *slave_vols[] = { "Headphone Playback Volume", "Speaker Playback Volume", @@ -580,6 +591,23 @@ static int conexant_build_controls(struct hda_codec *codec) return err; } +#ifdef CONFIG_SND_HDA_INPUT_BEEP + /* create beep controls if needed */ + if (spec->beep_amp) { + struct snd_kcontrol_new *knew; + for (knew = cxt_beep_mixer; knew->name; knew++) { + struct snd_kcontrol *kctl; + kctl = snd_ctl_new1(knew, codec); + if (!kctl) + return -ENOMEM; + kctl->private_value = spec->beep_amp; + err = snd_hda_ctl_add(codec, 0, kctl); + if (err < 0) + return err; + } + } +#endif + return 0; } @@ -590,6 +618,13 @@ static struct hda_codec_ops conexant_patch_ops = { .free = conexant_free, }; +#ifdef CONFIG_SND_HDA_INPUT_BEEP +#define set_beep_amp(spec, nid, idx, dir) \ + ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) +#else +#define set_beep_amp(spec, nid, idx, dir) /* NOP */ +#endif + /* * EAPD control * the private value = nid | (invert << 8) @@ -1130,9 +1165,10 @@ static int patch_cxt5045(struct hda_codec *codec) spec->num_init_verbs = 1; spec->init_verbs[0] = cxt5045_init_verbs; spec->spdif_route = 0; - spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes), - spec->channel_mode = cxt5045_modes, + spec->num_channel_mode = ARRAY_SIZE(cxt5045_modes); + spec->channel_mode = cxt5045_modes; + set_beep_amp(spec, 0x16, 0, 1); codec->patch_ops = conexant_patch_ops; @@ -1211,6 +1247,9 @@ static int patch_cxt5045(struct hda_codec *codec) break; } + if (spec->beep_amp) + snd_hda_attach_beep_device(codec, spec->beep_amp); + return 0; } @@ -1987,6 +2026,8 @@ static int patch_cxt5051(struct hda_codec *codec) spec->cur_adc = 0; spec->cur_adc_idx = 0; + set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); + codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, @@ -2021,6 +2062,9 @@ static int patch_cxt5051(struct hda_codec *codec) break; } + if (spec->beep_amp) + snd_hda_attach_beep_device(codec, spec->beep_amp); + return 0; } @@ -2636,7 +2680,6 @@ static struct snd_kcontrol_new cxt5066_vostro_mixers[] = { .put = cxt5066_mic_boost_mux_enum_put, .private_value = 0x23 | 0x100, }, - HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT), {} }; @@ -3034,6 +3077,8 @@ static int patch_cxt5066(struct hda_codec *codec) spec->cur_adc = 0; spec->cur_adc_idx = 0; + set_beep_amp(spec, 0x13, 0, HDA_OUTPUT); + board_config = snd_hda_check_board_config(codec, CXT5066_MODELS, cxt5066_models, cxt5066_cfg_tbl); switch (board_config) { @@ -3082,7 +3127,6 @@ static int patch_cxt5066(struct hda_codec *codec) spec->port_d_mode = 0; spec->dell_vostro = 1; spec->mic_boost = 3; /* default 30dB gain */ - snd_hda_attach_beep_device(codec, 0x13); /* no S/PDIF out */ spec->multiout.dig_out_nid = 0; @@ -3124,6 +3168,9 @@ static int patch_cxt5066(struct hda_codec *codec) break; } + if (spec->beep_amp) + snd_hda_attach_beep_device(codec, spec->beep_amp); + return 0; } -- cgit v1.1 From afbd9b8448f4b7d15673c6858012f384f18d28b8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 8 Jul 2010 18:40:37 +0200 Subject: ALSA: hda - Limit the amp value to write Check the amp max value at put callbacks and set the upper limit so that the driver won't write any invalid value over the defined range. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index a3d638c..88a1c6a 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1539,6 +1539,17 @@ void snd_hda_codec_resume_amp(struct hda_codec *codec) EXPORT_SYMBOL_HDA(snd_hda_codec_resume_amp); #endif /* SND_HDA_NEEDS_RESUME */ +static u32 get_amp_max_value(struct hda_codec *codec, hda_nid_t nid, int dir, + unsigned int ofs) +{ + u32 caps = query_amp_caps(codec, nid, dir); + /* get num steps */ + caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; + if (ofs < caps) + caps -= ofs; + return caps; +} + /** * snd_hda_mixer_amp_volume_info - Info callback for a standard AMP mixer * @@ -1553,23 +1564,17 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, u8 chs = get_amp_channels(kcontrol); int dir = get_amp_direction(kcontrol); unsigned int ofs = get_amp_offset(kcontrol); - u32 caps; - caps = query_amp_caps(codec, nid, dir); - /* num steps */ - caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; - if (!caps) { + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = chs == 3 ? 2 : 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = get_amp_max_value(codec, nid, dir, ofs); + if (!uinfo->value.integer.max) { printk(KERN_WARNING "hda_codec: " "num_steps = 0 for NID=0x%x (ctl = %s)\n", nid, kcontrol->id.name); return -EINVAL; } - if (ofs < caps) - caps -= ofs; - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = chs == 3 ? 2 : 1; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = caps; return 0; } EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_info); @@ -1594,8 +1599,13 @@ update_amp_value(struct hda_codec *codec, hda_nid_t nid, int ch, int dir, int idx, unsigned int ofs, unsigned int val) { + unsigned int maxval; + if (val > 0) val += ofs; + maxval = get_amp_max_value(codec, nid, dir, ofs); + if (val > maxval) + val = maxval; return snd_hda_codec_amp_update(codec, nid, ch, dir, idx, HDA_AMP_VOLMASK, val); } -- cgit v1.1 From d32d552e665dc07384208108165592d0b524dba2 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 8 Jul 2010 16:38:01 +0200 Subject: ALSA: usb-audio: silence a superfluous warning It is not advisable to print a warning when a device does not support setting the sample rate because this is perfectly valid for devices with a single rate or where rates are implicitly changed by selecting another alternate setting. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/usb/clock.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/usb/clock.c b/sound/usb/clock.c index 66bd157..b853f8d 100644 --- a/sound/usb/clock.c +++ b/sound/usb/clock.c @@ -204,11 +204,8 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface, ep = get_endpoint(alts, 0)->bEndpointAddress; /* if endpoint doesn't have sampling rate control, bail out */ - if (!(fmt->attributes & UAC_EP_CS_ATTR_SAMPLE_RATE)) { - snd_printk(KERN_WARNING "%d:%d:%d: endpoint lacks sample rate attribute bit, cannot set.\n", - dev->devnum, iface, fmt->altsetting); + if (!(fmt->attributes & UAC_EP_CS_ATTR_SAMPLE_RATE)) return 0; - } data[0] = rate; data[1] = rate >> 8; -- cgit v1.1 From 395c61d19621e80b763810cc988416dc1b6bfd3e Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 12 Jul 2010 16:27:24 +0200 Subject: ALSA: via82xx: allow changing the initial DXS volume As per-stream volume controls, the DXS controls are not intended to adjust the overall sound level and so are initialized every time a stream is opened. However, there are special situations where one wants to reduce the overall volume in the digital domain, i.e., before the AC'97 codec's PCM volume control. To allow this, add a module parameter that sets the initial DXS volume. Signed-off-by: Clemens Ladisch Tested-by: Soeren D. Schulze Signed-off-by: Takashi Iwai --- sound/pci/via82xx.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 7e494b6..8c5f8b5 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -85,6 +85,7 @@ static int joystick; static int ac97_clock = 48000; static char *ac97_quirk; static int dxs_support; +static int dxs_init_volume = 31; static int nodelay; module_param(index, int, 0444); @@ -103,6 +104,8 @@ module_param(ac97_quirk, charp, 0444); MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); module_param(dxs_support, int, 0444); MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)"); +module_param(dxs_init_volume, int, 0644); +MODULE_PARM_DESC(dxs_init_volume, "initial DXS volume (0-31)"); module_param(nodelay, int, 0444); MODULE_PARM_DESC(nodelay, "Disable 500ms init delay"); @@ -1245,8 +1248,10 @@ static int snd_via8233_playback_open(struct snd_pcm_substream *substream) return err; stream = viadev->reg_offset / 0x10; if (chip->dxs_controls[stream]) { - chip->playback_volume[stream][0] = 0; - chip->playback_volume[stream][1] = 0; + chip->playback_volume[stream][0] = + VIA_DXS_MAX_VOLUME - (dxs_init_volume & 31); + chip->playback_volume[stream][1] = + VIA_DXS_MAX_VOLUME - (dxs_init_volume & 31); chip->dxs_controls[stream]->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | -- cgit v1.1 From 32e0191d7909022e5016beb75dda6710a28b3c61 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 12 Jul 2010 16:28:50 +0200 Subject: ALSA: HDA: VT1708S: fix Smart5.1 mode Correctly configure bidirectional pins when resuming; do not power down widgets when they are needed for Smart5.1 output; and on 3-jack boards, create the streams and controls needed for six channels. Signed-off-by: Clemens Ladisch Reported-and-tested-by: Viliam Kubis Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_via.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 7345381..ae3acb2 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -552,24 +552,30 @@ static void via_auto_init_hp_out(struct hda_codec *codec) } } +static int is_smart51_pins(struct via_spec *spec, hda_nid_t pin); + static void via_auto_init_analog_input(struct hda_codec *codec) { struct via_spec *spec = codec->spec; + unsigned int ctl; int i; for (i = 0; i < AUTO_PIN_LAST; i++) { hda_nid_t nid = spec->autocfg.input_pins[i]; + if (!nid) + continue; + if (spec->smart51_enabled && is_smart51_pins(spec, nid)) + ctl = PIN_OUT; + else if (i <= AUTO_PIN_FRONT_MIC) + ctl = PIN_VREF50; + else + ctl = PIN_IN; snd_hda_codec_write(codec, nid, 0, - AC_VERB_SET_PIN_WIDGET_CONTROL, - (i <= AUTO_PIN_FRONT_MIC ? - PIN_VREF50 : PIN_IN)); - + AC_VERB_SET_PIN_WIDGET_CONTROL, ctl); } } -static int is_smart51_pins(struct via_spec *spec, hda_nid_t pin); - static void set_pin_power_state(struct hda_codec *codec, hda_nid_t nid, unsigned int *affected_parm) { @@ -658,6 +664,8 @@ static void set_jack_power_state(struct hda_codec *codec) /* PW0 (19h), SW1 (18h), AOW1 (11h) */ parm = AC_PWRST_D3; set_pin_power_state(codec, 0x19, &parm); + if (spec->smart51_enabled) + parm = AC_PWRST_D0; snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_POWER_STATE, parm); snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_POWER_STATE, @@ -667,6 +675,8 @@ static void set_jack_power_state(struct hda_codec *codec) if (is_8ch) { parm = AC_PWRST_D3; set_pin_power_state(codec, 0x22, &parm); + if (spec->smart51_enabled) + parm = AC_PWRST_D0; snd_hda_codec_write(codec, 0x26, 0, AC_VERB_SET_POWER_STATE, parm); snd_hda_codec_write(codec, 0x24, 0, @@ -3915,6 +3925,13 @@ static int vt1708S_auto_fill_dac_nids(struct via_spec *spec, } } + /* for Smart 5.1, line/mic inputs double as output pins */ + if (cfg->line_outs == 1) { + spec->multiout.num_dacs = 3; + spec->multiout.dac_nids[AUTO_SEQ_SURROUND] = 0x11; + spec->multiout.dac_nids[AUTO_SEQ_CENLFE] = 0x24; + } + return 0; } @@ -3932,7 +3949,8 @@ static int vt1708S_auto_create_multi_out_ctls(struct via_spec *spec, for (i = 0; i <= AUTO_SEQ_SIDE; i++) { nid = cfg->line_out_pins[i]; - if (!nid) + /* for Smart 5.1, there are always at least six channels */ + if (!nid && i > AUTO_SEQ_CENLFE) continue; nid_vol = nid_vols[i]; -- cgit v1.1 From 90dc763fef4c869e60b2a7ad92e1a7dab68575ea Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Sun, 11 Jul 2010 12:16:36 +0200 Subject: sound: push BKL into open functions This moves the lock_kernel() call from soundcore_open to the individual OSS device drivers, where we can deal with it one driver at a time if needed, or just kill off the drivers. All core components in ALSA already provide adequate locking in their open()-functions and do not require the big kernel lock, so there is no need to add the BKL there. Signed-off-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/oss/au1550_ac97.c | 26 +++++++++++++++++--------- sound/oss/dmasound/dmasound_core.c | 28 ++++++++++++++++++++++------ sound/oss/msnd_pinnacle.c | 10 +++++++--- sound/oss/sh_dac_audio.c | 9 +++++++-- sound/oss/soundcard.c | 20 +++++++++++--------- sound/oss/swarm_cs4297a.c | 17 ++++++++++++++++- sound/oss/vwsnd.c | 8 ++++++++ sound/sound_core.c | 6 +----- 8 files changed, 89 insertions(+), 35 deletions(-) (limited to 'sound') diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c index c1070e3..fb913e5 100644 --- a/sound/oss/au1550_ac97.c +++ b/sound/oss/au1550_ac97.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -807,7 +808,9 @@ au1550_llseek(struct file *file, loff_t offset, int origin) static int au1550_open_mixdev(struct inode *inode, struct file *file) { + lock_kernel(); file->private_data = &au1550_state; + unlock_kernel(); return 0; } @@ -1797,21 +1800,22 @@ au1550_open(struct inode *inode, struct file *file) #endif file->private_data = s; + lock_kernel(); /* wait for device to become free */ mutex_lock(&s->open_mutex); while (s->open_mode & file->f_mode) { - if (file->f_flags & O_NONBLOCK) { - mutex_unlock(&s->open_mutex); - return -EBUSY; - } + ret = -EBUSY; + if (file->f_flags & O_NONBLOCK) + goto out; add_wait_queue(&s->open_wait, &wait); __set_current_state(TASK_INTERRUPTIBLE); mutex_unlock(&s->open_mutex); schedule(); remove_wait_queue(&s->open_wait, &wait); set_current_state(TASK_RUNNING); + ret = -ERESTARTSYS; if (signal_pending(current)) - return -ERESTARTSYS; + goto out2; mutex_lock(&s->open_mutex); } @@ -1840,17 +1844,21 @@ au1550_open(struct inode *inode, struct file *file) if (file->f_mode & FMODE_READ) { if ((ret = prog_dmabuf_adc(s))) - return ret; + goto out; } if (file->f_mode & FMODE_WRITE) { if ((ret = prog_dmabuf_dac(s))) - return ret; + goto out; } s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE); - mutex_unlock(&s->open_mutex); mutex_init(&s->sem); - return 0; + ret = 0; +out: + mutex_unlock(&s->open_mutex); +out2: + unlock_kernel(); + return ret; } static int diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c index 3f3c3f7..5a4f38c 100644 --- a/sound/oss/dmasound/dmasound_core.c +++ b/sound/oss/dmasound/dmasound_core.c @@ -323,9 +323,13 @@ static struct { static int mixer_open(struct inode *inode, struct file *file) { - if (!try_module_get(dmasound.mach.owner)) + lock_kernel(); + if (!try_module_get(dmasound.mach.owner)) { + unlock_kernel(); return -ENODEV; + } mixer.busy = 1; + unlock_kernel(); return 0; } @@ -737,8 +741,11 @@ static int sq_open(struct inode *inode, struct file *file) { int rc; - if (!try_module_get(dmasound.mach.owner)) + lock_kernel(); + if (!try_module_get(dmasound.mach.owner)) { + unlock_kernel(); return -ENODEV; + } rc = write_sq_open(file); /* checks the f_mode */ if (rc) @@ -781,10 +788,11 @@ static int sq_open(struct inode *inode, struct file *file) sound_set_format(AFMT_MU_LAW); } #endif - + unlock_kernel(); return 0; out: module_put(dmasound.mach.owner); + unlock_kernel(); return rc; } @@ -1226,12 +1234,17 @@ static int state_open(struct inode *inode, struct file *file) { char *buffer = state.buf; int len = 0; + int ret; + lock_kernel(); + ret = -EBUSY; if (state.busy) - return -EBUSY; + goto out; + ret = -ENODEV; if (!try_module_get(dmasound.mach.owner)) - return -ENODEV; + goto out; + state.ptr = 0; state.busy = 1; @@ -1293,7 +1306,10 @@ printk("dmasound: stat buffer used %d bytes\n", len) ; printk(KERN_ERR "dmasound_core: stat buffer overflowed!\n"); state.len = len; - return 0; + ret = 0; +out: + unlock_kernel(); + return ret; } static int state_release(struct inode *inode, struct file *file) diff --git a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c index a1e3f96..153d822 100644 --- a/sound/oss/msnd_pinnacle.c +++ b/sound/oss/msnd_pinnacle.c @@ -756,12 +756,15 @@ static int dev_open(struct inode *inode, struct file *file) int minor = iminor(inode); int err = 0; + lock_kernel(); if (minor == dev.dsp_minor) { if ((file->f_mode & FMODE_WRITE && test_bit(F_AUDIO_WRITE_INUSE, &dev.flags)) || (file->f_mode & FMODE_READ && - test_bit(F_AUDIO_READ_INUSE, &dev.flags))) - return -EBUSY; + test_bit(F_AUDIO_READ_INUSE, &dev.flags))) { + err = -EBUSY; + goto out; + } if ((err = dsp_open(file)) >= 0) { dev.nresets = 0; @@ -782,7 +785,8 @@ static int dev_open(struct inode *inode, struct file *file) /* nothing */ } else err = -EINVAL; - +out: + unlock_kernel(); return err; } diff --git a/sound/oss/sh_dac_audio.c b/sound/oss/sh_dac_audio.c index 4153752..8f0be40 100644 --- a/sound/oss/sh_dac_audio.c +++ b/sound/oss/sh_dac_audio.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -216,13 +217,17 @@ static int dac_audio_open(struct inode *inode, struct file *file) { if (file->f_mode & FMODE_READ) return -ENODEV; - if (in_use) + + lock_kernel(); + if (in_use) { + unlock_kernel(); return -EBUSY; + } in_use = 1; dac_audio_start(); - + unlock_kernel(); return 0; } diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c index 2d9c513..92aa762 100644 --- a/sound/oss/soundcard.c +++ b/sound/oss/soundcard.c @@ -210,42 +210,44 @@ static int sound_open(struct inode *inode, struct file *file) printk(KERN_ERR "Invalid minor device %d\n", dev); return -ENXIO; } + lock_kernel(); switch (dev & 0x0f) { case SND_DEV_CTL: dev >>= 4; if (dev >= 0 && dev < MAX_MIXER_DEV && mixer_devs[dev] == NULL) { request_module("mixer%d", dev); } + retval = -ENXIO; if (dev && (dev >= num_mixers || mixer_devs[dev] == NULL)) - return -ENXIO; + break; if (!try_module_get(mixer_devs[dev]->owner)) - return -ENXIO; + break; + + retval = 0; break; case SND_DEV_SEQ: case SND_DEV_SEQ2: - if ((retval = sequencer_open(dev, file)) < 0) - return retval; + retval = sequencer_open(dev, file); break; case SND_DEV_MIDIN: - if ((retval = MIDIbuf_open(dev, file)) < 0) - return retval; + retval = MIDIbuf_open(dev, file); break; case SND_DEV_DSP: case SND_DEV_DSP16: case SND_DEV_AUDIO: - if ((retval = audio_open(dev, file)) < 0) - return retval; + retval = audio_open(dev, file); break; default: printk(KERN_ERR "Invalid minor device %d\n", dev); - return -ENXIO; + retval = -ENXIO; } + unlock_kernel(); return 0; } diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c index 3136c88..34b0838 100644 --- a/sound/oss/swarm_cs4297a.c +++ b/sound/oss/swarm_cs4297a.c @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -1534,6 +1535,7 @@ static int cs4297a_open_mixdev(struct inode *inode, struct file *file) CS_DBGOUT(CS_FUNCTION | CS_OPEN, 4, printk(KERN_INFO "cs4297a: cs4297a_open_mixdev()+\n")); + lock_kernel(); list_for_each(entry, &cs4297a_devs) { s = list_entry(entry, struct cs4297a_state, list); @@ -1544,6 +1546,8 @@ static int cs4297a_open_mixdev(struct inode *inode, struct file *file) { CS_DBGOUT(CS_FUNCTION | CS_OPEN | CS_ERROR, 2, printk(KERN_INFO "cs4297a: cs4297a_open_mixdev()- -ENODEV\n")); + + unlock_kernel(); return -ENODEV; } VALIDATE_STATE(s); @@ -1551,6 +1555,7 @@ static int cs4297a_open_mixdev(struct inode *inode, struct file *file) CS_DBGOUT(CS_FUNCTION | CS_OPEN, 4, printk(KERN_INFO "cs4297a: cs4297a_open_mixdev()- 0\n")); + unlock_kernel(); return nonseekable_open(inode, file); } @@ -2369,7 +2374,7 @@ static int cs4297a_release(struct inode *inode, struct file *file) return 0; } -static int cs4297a_open(struct inode *inode, struct file *file) +static int cs4297a_locked_open(struct inode *inode, struct file *file) { int minor = iminor(inode); struct cs4297a_state *s=NULL; @@ -2486,6 +2491,16 @@ static int cs4297a_open(struct inode *inode, struct file *file) return nonseekable_open(inode, file); } +static int cs4297a_open(struct inode *inode, struct file *file) +{ + int ret; + + lock_kernel(); + ret = cs4297a_open(inode, file); + unlock_kernel(); + + return ret; +} // ****************************************************************************************** // Wave (audio) file operations struct. diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c index 20b3b32..99c94c4 100644 --- a/sound/oss/vwsnd.c +++ b/sound/oss/vwsnd.c @@ -2921,6 +2921,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) DBGE("(inode=0x%p, file=0x%p)\n", inode, file); + lock_kernel(); INC_USE_COUNT; for (devc = vwsnd_dev_list; devc; devc = devc->next_dev) if ((devc->audio_minor & ~0x0F) == (minor & ~0x0F)) @@ -2928,6 +2929,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) if (devc == NULL) { DEC_USE_COUNT; + unlock_kernel(); return -ENODEV; } @@ -2936,11 +2938,13 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) mutex_unlock(&devc->open_mutex); if (file->f_flags & O_NONBLOCK) { DEC_USE_COUNT; + unlock_kernel(); return -EBUSY; } interruptible_sleep_on(&devc->open_wait); if (signal_pending(current)) { DEC_USE_COUNT; + unlock_kernel(); return -ERESTARTSYS; } mutex_lock(&devc->open_mutex); @@ -2993,6 +2997,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file) file->private_data = devc; DBGRV(); + unlock_kernel(); return 0; } @@ -3062,15 +3067,18 @@ static int vwsnd_mixer_open(struct inode *inode, struct file *file) DBGEV("(inode=0x%p, file=0x%p)\n", inode, file); INC_USE_COUNT; + lock_kernel(); for (devc = vwsnd_dev_list; devc; devc = devc->next_dev) if (devc->mixer_minor == iminor(inode)) break; if (devc == NULL) { DEC_USE_COUNT; + unlock_kernel(); return -ENODEV; } file->private_data = devc; + unlock_kernel(); return 0; } diff --git a/sound/sound_core.c b/sound/sound_core.c index c8627fc..cb61317 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c @@ -629,12 +629,8 @@ static int soundcore_open(struct inode *inode, struct file *file) file->f_op = new_fops; spin_unlock(&sound_loader_lock); - if (file->f_op->open) { - /* TODO: push down BKL into indivial open functions */ - lock_kernel(); + if (file->f_op->open) err = file->f_op->open(inode,file); - unlock_kernel(); - } if (err) { fops_put(file->f_op); -- cgit v1.1 From a7ce2e0d04b1a6ee8056e7fea5ea96566d33a6f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Mon, 12 Jul 2010 17:15:44 +0200 Subject: fix comnment/printk typos concerning "empty" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-König Signed-off-by: Jiri Kosina --- sound/usb/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 4568298..3634ced 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -636,7 +636,7 @@ static int hw_rule_period_time(struct snd_pcm_hw_params *params, min_datainterval = min(min_datainterval, fp->datainterval); } if (min_datainterval == 0xff) { - hwc_debug(" --> get emtpy\n"); + hwc_debug(" --> get empty\n"); it->empty = 1; return -EINVAL; } -- cgit v1.1 From d209974cdc36aeeef406fa2019e9e1dacecbb979 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 12 Jul 2010 19:53:18 +0200 Subject: sound/oss: convert to unlocked_ioctl These are the final conversions for the ioctl file operation so we can remove it in the next merge window. Signed-off-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/oss/au1550_ac97.c | 54 ++++++++++++++++++++++++-------------- sound/oss/dmasound/dmasound_core.c | 35 +++++++++++++++++++----- sound/oss/msnd_pinnacle.c | 15 +++++++---- sound/oss/sh_dac_audio.c | 18 ++++++++++--- sound/oss/swarm_cs4297a.c | 24 +++++++++++++---- sound/oss/vwsnd.c | 24 +++++++++-------- 6 files changed, 119 insertions(+), 51 deletions(-) (limited to 'sound') diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c index fb913e5..0fd256c 100644 --- a/sound/oss/au1550_ac97.c +++ b/sound/oss/au1550_ac97.c @@ -827,22 +827,26 @@ mixdev_ioctl(struct ac97_codec *codec, unsigned int cmd, return codec->mixer_ioctl(codec, cmd, arg); } -static int -au1550_ioctl_mixdev(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) +static long +au1550_ioctl_mixdev(struct file *file, unsigned int cmd, unsigned long arg) { struct au1550_state *s = (struct au1550_state *)file->private_data; struct ac97_codec *codec = s->codec; + int ret; + + lock_kernel(); + ret = mixdev_ioctl(codec, cmd, arg); + unlock_kernel(); - return mixdev_ioctl(codec, cmd, arg); + return ret; } static /*const */ struct file_operations au1550_mixer_fops = { - owner:THIS_MODULE, - llseek:au1550_llseek, - ioctl:au1550_ioctl_mixdev, - open:au1550_open_mixdev, - release:au1550_release_mixdev, + .owner = THIS_MODULE, + .llseek = au1550_llseek, + .unlocked_ioctl = au1550_ioctl_mixdev, + .open = au1550_open_mixdev, + .release = au1550_release_mixdev, }; static int @@ -1346,8 +1350,7 @@ dma_count_done(struct dmabuf *db) static int -au1550_ioctl(struct inode *inode, struct file *file, unsigned int cmd, - unsigned long arg) +au1550_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct au1550_state *s = (struct au1550_state *)file->private_data; unsigned long flags; @@ -1783,6 +1786,17 @@ au1550_ioctl(struct inode *inode, struct file *file, unsigned int cmd, return mixdev_ioctl(s->codec, cmd, arg); } +static long +au1550_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + int ret; + + lock_kernel(); + ret = au1550_ioctl(file, cmd, arg); + unlock_kernel(); + + return ret; +} static int au1550_open(struct inode *inode, struct file *file) @@ -1893,15 +1907,15 @@ au1550_release(struct inode *inode, struct file *file) } static /*const */ struct file_operations au1550_audio_fops = { - owner: THIS_MODULE, - llseek: au1550_llseek, - read: au1550_read, - write: au1550_write, - poll: au1550_poll, - ioctl: au1550_ioctl, - mmap: au1550_mmap, - open: au1550_open, - release: au1550_release, + .owner = THIS_MODULE, + .llseek = au1550_llseek, + .read = au1550_read, + .write = au1550_write, + .poll = au1550_poll, + .unlocked_ioctl = au1550_unlocked_ioctl, + .mmap = au1550_mmap, + .open = au1550_open, + .release = au1550_release, }; MODULE_AUTHOR("Advanced Micro Devices (AMD), dan@embeddededge.com"); diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c index 5a4f38c..6ecd41a 100644 --- a/sound/oss/dmasound/dmasound_core.c +++ b/sound/oss/dmasound/dmasound_core.c @@ -341,8 +341,8 @@ static int mixer_release(struct inode *inode, struct file *file) unlock_kernel(); return 0; } -static int mixer_ioctl(struct inode *inode, struct file *file, u_int cmd, - u_long arg) + +static int mixer_ioctl(struct file *file, u_int cmd, u_long arg) { if (_SIOC_DIR(cmd) & _SIOC_WRITE) mixer.modify_counter++; @@ -366,11 +366,22 @@ static int mixer_ioctl(struct inode *inode, struct file *file, u_int cmd, return -EINVAL; } +static long mixer_unlocked_ioctl(struct file *file, u_int cmd, u_long arg) +{ + int ret; + + lock_kernel(); + ret = mixer_ioctl(file, cmd, arg); + unlock_kernel(); + + return ret; +} + static const struct file_operations mixer_fops = { .owner = THIS_MODULE, .llseek = no_llseek, - .ioctl = mixer_ioctl, + .unlocked_ioctl = mixer_unlocked_ioctl, .open = mixer_open, .release = mixer_release, }; @@ -963,8 +974,7 @@ printk("dmasound_core: tried to set_queue_frags on a locked queue\n") ; return 0 ; } -static int sq_ioctl(struct inode *inode, struct file *file, u_int cmd, - u_long arg) +static int sq_ioctl(struct file *file, u_int cmd, u_long arg) { int val, result; u_long fmt; @@ -1122,18 +1132,29 @@ static int sq_ioctl(struct inode *inode, struct file *file, u_int cmd, return IOCTL_OUT(arg,val); default: - return mixer_ioctl(inode, file, cmd, arg); + return mixer_ioctl(file, cmd, arg); } return -EINVAL; } +static long sq_unlocked_ioctl(struct file *file, u_int cmd, u_long arg) +{ + int ret; + + lock_kernel(); + ret = sq_ioctl(file, cmd, arg); + unlock_kernel(); + + return ret; +} + static const struct file_operations sq_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = sq_write, .poll = sq_poll, - .ioctl = sq_ioctl, + .unlocked_ioctl = sq_unlocked_ioctl, .open = sq_open, .release = sq_release, }; diff --git a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c index 153d822..9ffd29f 100644 --- a/sound/oss/msnd_pinnacle.c +++ b/sound/oss/msnd_pinnacle.c @@ -639,21 +639,26 @@ static int mixer_ioctl(unsigned int cmd, unsigned long arg) return -EINVAL; } -static int dev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +static long dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int minor = iminor(inode); + int ret; if (cmd == OSS_GETVERSION) { int sound_version = SOUND_VERSION; return put_user(sound_version, (int __user *)arg); } + ret = -EINVAL; + + lock_kernel(); if (minor == dev.dsp_minor) - return dsp_ioctl(file, cmd, arg); + ret = dsp_ioctl(file, cmd, arg); else if (minor == dev.mixer_minor) - return mixer_ioctl(cmd, arg); + ret = mixer_ioctl(cmd, arg); + unlock_kernel(); - return -EINVAL; + return ret; } static void dsp_write_flush(void) @@ -1109,7 +1114,7 @@ static const struct file_operations dev_fileops = { .owner = THIS_MODULE, .read = dev_read, .write = dev_write, - .ioctl = dev_ioctl, + .unlocked_ioctl = dev_ioctl, .open = dev_open, .release = dev_release, }; diff --git a/sound/oss/sh_dac_audio.c b/sound/oss/sh_dac_audio.c index 8f0be40..fdb58eb 100644 --- a/sound/oss/sh_dac_audio.c +++ b/sound/oss/sh_dac_audio.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -93,7 +94,7 @@ static void dac_audio_set_rate(void) wakeups_per_second = ktime_set(0, 1000000000 / rate); } -static int dac_audio_ioctl(struct inode *inode, struct file *file, +static int dac_audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int val; @@ -159,6 +160,17 @@ static int dac_audio_ioctl(struct inode *inode, struct file *file, return -EINVAL; } +static long dac_audio_unlocked_ioctl(struct file *file, u_int cmd, u_long arg) +{ + int ret; + + lock_kernel(); + ret = dac_audio_ioctl(file, cmd, arg); + unlock_kernel(); + + return ret; +} + static ssize_t dac_audio_write(struct file *file, const char *buf, size_t count, loff_t * ppos) { @@ -242,8 +254,8 @@ static int dac_audio_release(struct inode *inode, struct file *file) const struct file_operations dac_audio_fops = { .read = dac_audio_read, - .write = dac_audio_write, - .ioctl = dac_audio_ioctl, + .write = dac_audio_write, + .unlocked_ioctl = dac_audio_unlocked_ioctl, .open = dac_audio_open, .release = dac_audio_release, }; diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c index 34b0838..b15840a 100644 --- a/sound/oss/swarm_cs4297a.c +++ b/sound/oss/swarm_cs4297a.c @@ -1571,11 +1571,15 @@ static int cs4297a_release_mixdev(struct inode *inode, struct file *file) } -static int cs4297a_ioctl_mixdev(struct inode *inode, struct file *file, +static int cs4297a_ioctl_mixdev(struct file *file, unsigned int cmd, unsigned long arg) { - return mixer_ioctl((struct cs4297a_state *) file->private_data, cmd, + int ret; + lock_kernel(); + ret = mixer_ioctl((struct cs4297a_state *) file->private_data, cmd, arg); + unlock_kernel(); + return ret; } @@ -1585,7 +1589,7 @@ static int cs4297a_ioctl_mixdev(struct inode *inode, struct file *file, static const struct file_operations cs4297a_mixer_fops = { .owner = THIS_MODULE, .llseek = no_llseek, - .ioctl = cs4297a_ioctl_mixdev, + .unlocked_ioctl = cs4297a_ioctl_mixdev, .open = cs4297a_open_mixdev, .release = cs4297a_release_mixdev, }; @@ -1949,7 +1953,7 @@ static int cs4297a_mmap(struct file *file, struct vm_area_struct *vma) } -static int cs4297a_ioctl(struct inode *inode, struct file *file, +static int cs4297a_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct cs4297a_state *s = @@ -2342,6 +2346,16 @@ static int cs4297a_ioctl(struct inode *inode, struct file *file, return mixer_ioctl(s, cmd, arg); } +static long cs4297a_unlocked_ioctl(struct file *file, u_int cmd, u_long arg) +{ + int ret; + + lock_kernel(); + ret = cs4297a_ioctl(file, cmd, arg); + unlock_kernel(); + + return ret; +} static int cs4297a_release(struct inode *inode, struct file *file) { @@ -2511,7 +2525,7 @@ static const struct file_operations cs4297a_audio_fops = { .read = cs4297a_read, .write = cs4297a_write, .poll = cs4297a_poll, - .ioctl = cs4297a_ioctl, + .unlocked_ioctl = cs4297a_unlocked_ioctl, .mmap = cs4297a_mmap, .open = cs4297a_open, .release = cs4297a_release, diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c index 99c94c4..8cd73cd 100644 --- a/sound/oss/vwsnd.c +++ b/sound/oss/vwsnd.c @@ -2429,8 +2429,7 @@ static unsigned int vwsnd_audio_poll(struct file *file, return mask; } -static int vwsnd_audio_do_ioctl(struct inode *inode, - struct file *file, +static int vwsnd_audio_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -2446,8 +2445,8 @@ static int vwsnd_audio_do_ioctl(struct inode *inode, int ival; - DBGEV("(inode=0x%p, file=0x%p, cmd=0x%x, arg=0x%lx)\n", - inode, file, cmd, arg); + DBGEV("(file=0x%p, cmd=0x%x, arg=0x%lx)\n", + file, cmd, arg); switch (cmd) { case OSS_GETVERSION: /* _SIOR ('M', 118, int) */ DBGX("OSS_GETVERSION\n"); @@ -2885,17 +2884,19 @@ static int vwsnd_audio_do_ioctl(struct inode *inode, return -EINVAL; } -static int vwsnd_audio_ioctl(struct inode *inode, - struct file *file, +static long vwsnd_audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { vwsnd_dev_t *devc = (vwsnd_dev_t *) file->private_data; int ret; + lock_kernel(); mutex_lock(&devc->io_mutex); - ret = vwsnd_audio_do_ioctl(inode, file, cmd, arg); + ret = vwsnd_audio_do_ioctl(file, cmd, arg); mutex_unlock(&devc->io_mutex); + unlock_kernel(); + return ret; } @@ -3049,7 +3050,7 @@ static const struct file_operations vwsnd_audio_fops = { .read = vwsnd_audio_read, .write = vwsnd_audio_write, .poll = vwsnd_audio_poll, - .ioctl = vwsnd_audio_ioctl, + .unlocked_ioctl = vwsnd_audio_ioctl, .mmap = vwsnd_audio_mmap, .open = vwsnd_audio_open, .release = vwsnd_audio_release, @@ -3211,8 +3212,7 @@ static int mixer_write_ioctl(vwsnd_dev_t *devc, unsigned int nr, void __user *ar /* This is the ioctl entry to the mixer driver. */ -static int vwsnd_mixer_ioctl(struct inode *ioctl, - struct file *file, +static long vwsnd_mixer_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -3223,6 +3223,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl, DBGEV("(devc=0x%p, cmd=0x%x, arg=0x%lx)\n", devc, cmd, arg); + lock_kernel(); mutex_lock(&devc->mix_mutex); { if ((cmd & ~nrmask) == MIXER_READ(0)) @@ -3233,13 +3234,14 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl, retval = -EINVAL; } mutex_unlock(&devc->mix_mutex); + unlock_kernel(); return retval; } static const struct file_operations vwsnd_mixer_fops = { .owner = THIS_MODULE, .llseek = no_llseek, - .ioctl = vwsnd_mixer_ioctl, + .unlocked_ioctl = vwsnd_mixer_ioctl, .open = vwsnd_mixer_open, .release = vwsnd_mixer_release, }; -- cgit v1.1 From 840b64c08032a86ab39b85ddd342918da0d559c8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 13 Jul 2010 22:49:01 +0200 Subject: ALSA: hda - Add support of dual-ADCs for Realtek ALC275 Some VAIO models with ALC275 have dual ADCs for both internal and external mics, and the driver needs to switch one of them appropriately. This patch adds a basic support for this functionality, dynamic switching between two ADCs per jack plug state. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 178 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 154 insertions(+), 24 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index a7592f5..ca1a87a 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -333,6 +333,12 @@ struct alc_spec { hda_nid_t *capsrc_nids; hda_nid_t dig_in_nid; /* digital-in NID; optional */ + /* capture setup for dynamic dual-adc switch */ + unsigned int cur_adc_idx; + hda_nid_t cur_adc; + unsigned int cur_adc_stream_tag; + unsigned int cur_adc_format; + /* capture source */ unsigned int num_mux_defs; const struct hda_input_mux *input_mux; @@ -374,6 +380,7 @@ struct alc_spec { /* other flags */ unsigned int no_analog :1; /* digital I/O only */ + unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */ int init_amp; /* for virtual master */ @@ -1010,6 +1017,29 @@ static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, return -1; } +/* switch the current ADC according to the jack state */ +static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + unsigned int present; + hda_nid_t new_adc; + + present = snd_hda_jack_detect(codec, spec->ext_mic.pin); + if (present) + spec->cur_adc_idx = 1; + else + spec->cur_adc_idx = 0; + new_adc = spec->adc_nids[spec->cur_adc_idx]; + if (spec->cur_adc && spec->cur_adc != new_adc) { + /* stream is running, let's swap the current ADC */ + snd_hda_codec_cleanup_stream(codec, spec->cur_adc); + spec->cur_adc = new_adc; + snd_hda_codec_setup_stream(codec, new_adc, + spec->cur_adc_stream_tag, 0, + spec->cur_adc_format); + } +} + static void alc_mic_automute(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; @@ -1024,6 +1054,11 @@ static void alc_mic_automute(struct hda_codec *codec) if (snd_BUG_ON(!spec->adc_nids)) return; + if (spec->dual_adc_switch) { + alc_dual_mic_adc_auto_switch(codec); + return; + } + cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0]; present = snd_hda_jack_detect(codec, spec->ext_mic.pin); @@ -3614,6 +3649,41 @@ static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, return 0; } +/* analog capture with dynamic dual-adc changes */ +static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + unsigned int stream_tag, + unsigned int format, + struct snd_pcm_substream *substream) +{ + struct alc_spec *spec = codec->spec; + spec->cur_adc = spec->adc_nids[spec->cur_adc_idx]; + spec->cur_adc_stream_tag = stream_tag; + spec->cur_adc_format = format; + snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); + return 0; +} + +static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct alc_spec *spec = codec->spec; + snd_hda_codec_cleanup_stream(codec, spec->cur_adc); + spec->cur_adc = 0; + return 0; +} + +static struct hda_pcm_stream dualmic_pcm_analog_capture = { + .substreams = 1, + .channels_min = 2, + .channels_max = 2, + .nid = 0, /* fill later */ + .ops = { + .prepare = dualmic_capture_pcm_prepare, + .cleanup = dualmic_capture_pcm_cleanup + }, +}; /* */ @@ -5052,24 +5122,12 @@ static void fixup_automic_adc(struct hda_codec *codec) spec->auto_mic = 0; /* disable auto-mic to be sure */ } -/* choose the ADC/MUX containing the input pin and initialize the setup */ -static void fixup_single_adc(struct hda_codec *codec) +/* set the default connection to that pin */ +static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) { struct alc_spec *spec = codec->spec; - hda_nid_t pin = 0; int i; - /* search for the input pin; there must be only one */ - for (i = 0; i < AUTO_PIN_LAST; i++) { - if (spec->autocfg.input_pins[i]) { - pin = spec->autocfg.input_pins[i]; - break; - } - } - if (!pin) - return; - - /* set the default connection to that pin */ for (i = 0; i < spec->num_adc_nids; i++) { hda_nid_t cap = spec->capsrc_nids ? spec->capsrc_nids[i] : spec->adc_nids[i]; @@ -5078,11 +5136,6 @@ static void fixup_single_adc(struct hda_codec *codec) idx = get_connection_index(codec, cap, pin); if (idx < 0) continue; - /* use only this ADC */ - if (spec->capsrc_nids) - spec->capsrc_nids += i; - spec->adc_nids += i; - spec->num_adc_nids = 1; /* select or unmute this route */ if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) { snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx, @@ -5091,10 +5144,45 @@ static void fixup_single_adc(struct hda_codec *codec) snd_hda_codec_write_cache(codec, cap, 0, AC_VERB_SET_CONNECT_SEL, idx); } + return i; /* return the found index */ + } + return -1; /* not found */ +} + +/* choose the ADC/MUX containing the input pin and initialize the setup */ +static void fixup_single_adc(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + hda_nid_t pin = 0; + int i; + + /* search for the input pin; there must be only one */ + for (i = 0; i < AUTO_PIN_LAST; i++) { + if (spec->autocfg.input_pins[i]) { + pin = spec->autocfg.input_pins[i]; + break; + } + } + if (!pin) return; + i = init_capsrc_for_pin(codec, pin); + if (i >= 0) { + /* use only this ADC */ + if (spec->capsrc_nids) + spec->capsrc_nids += i; + spec->adc_nids += i; + spec->num_adc_nids = 1; } } +/* initialize dual adcs */ +static void fixup_dual_adc_switch(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + init_capsrc_for_pin(codec, spec->ext_mic.pin); + init_capsrc_for_pin(codec, spec->int_mic.pin); +} + static void set_capture_mixer(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; @@ -5108,7 +5196,10 @@ static void set_capture_mixer(struct hda_codec *codec) }; if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) { int mux = 0; - if (spec->auto_mic) + int num_adcs = spec->num_adc_nids; + if (spec->dual_adc_switch) + fixup_dual_adc_switch(codec); + else if (spec->auto_mic) fixup_automic_adc(codec); else if (spec->input_mux) { if (spec->input_mux->num_items > 1) @@ -5116,7 +5207,9 @@ static void set_capture_mixer(struct hda_codec *codec) else if (spec->input_mux->num_items == 1) fixup_single_adc(codec); } - spec->cap_mixer = caps[mux][spec->num_adc_nids - 1]; + if (spec->dual_adc_switch) + num_adcs = 1; + spec->cap_mixer = caps[mux][num_adcs - 1]; } } @@ -14141,6 +14234,36 @@ static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid) } #endif /* CONFIG_SND_HDA_POWER_SAVE */ +static int alc275_setup_dual_adc(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + + if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic) + return 0; + if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) || + (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) { + if (spec->ext_mic.pin <= 0x12) { + spec->private_adc_nids[0] = 0x08; + spec->private_adc_nids[1] = 0x11; + spec->private_capsrc_nids[0] = 0x23; + spec->private_capsrc_nids[1] = 0x22; + } else { + spec->private_adc_nids[0] = 0x11; + spec->private_adc_nids[1] = 0x08; + spec->private_capsrc_nids[0] = 0x22; + spec->private_capsrc_nids[1] = 0x23; + } + spec->adc_nids = spec->private_adc_nids; + spec->capsrc_nids = spec->private_capsrc_nids; + spec->num_adc_nids = 2; + spec->dual_adc_switch = 1; + snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n", + spec->adc_nids[0], spec->adc_nids[1]); + return 1; + } + return 0; +} + /* * BIOS auto configuration */ @@ -14180,11 +14303,14 @@ static int alc269_parse_auto_config(struct hda_codec *codec) spec->num_mux_defs = 1; spec->input_mux = &spec->private_imux[0]; - fillup_priv_adc_nids(codec, alc269_adc_candidates, - sizeof(alc269_adc_candidates)); + + if (!alc275_setup_dual_adc(codec)) + fillup_priv_adc_nids(codec, alc269_adc_candidates, + sizeof(alc269_adc_candidates)); /* set default input source */ - snd_hda_codec_write_cache(codec, spec->capsrc_nids[0], + if (!spec->dual_adc_switch) + snd_hda_codec_write_cache(codec, spec->capsrc_nids[0], 0, AC_VERB_SET_CONNECT_SEL, spec->input_mux->items[0].index); @@ -14480,6 +14606,10 @@ static int patch_alc269(struct hda_codec *codec) */ spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; + } else if (spec->dual_adc_switch) { + spec->stream_analog_playback = &alc269_pcm_analog_playback; + /* switch ADC dynamically */ + spec->stream_analog_capture = &dualmic_pcm_analog_capture; } else { spec->stream_analog_playback = &alc269_pcm_analog_playback; spec->stream_analog_capture = &alc269_pcm_analog_capture; -- cgit v1.1 From 992cbf743862916dfbfdd3238fe3fecffbab5dd3 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Wed, 14 Jul 2010 15:11:39 +0200 Subject: sound/oss-msnd-pinnacle: ioctl needs the inode This broke in sound/oss: convert to unlocked_ioctl, when I missed one of the ioctl functions still using the inode pointer. Signed-off-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/oss/msnd_pinnacle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c index 9ffd29f..bfaac5f 100644 --- a/sound/oss/msnd_pinnacle.c +++ b/sound/oss/msnd_pinnacle.c @@ -641,7 +641,7 @@ static int mixer_ioctl(unsigned int cmd, unsigned long arg) static long dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - int minor = iminor(inode); + int minor = iminor(file->f_path.dentry->d_inode); int ret; if (cmd == OSS_GETVERSION) { -- cgit v1.1 From 7a53cd16d4d9968d1962e378b14eec2d99aa43e0 Mon Sep 17 00:00:00 2001 From: Michael Witten Date: Wed, 14 Jul 2010 23:56:56 +0000 Subject: Kconfig: fixo typo in "Xilinx'" Signed-off-by: Michael Witten Signed-off-by: Jiri Kosina --- sound/drivers/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig index 84714a6..c290cee 100644 --- a/sound/drivers/Kconfig +++ b/sound/drivers/Kconfig @@ -155,7 +155,7 @@ config SND_ML403_AC97CR select SND_AC97_CODEC help Say Y here to include support for the - opb_ac97_controller_ref_v1_00_a ip core found in Xilinx' ML403 + opb_ac97_controller_ref_v1_00_a ip core found in Xilinx's ML403 reference design. To compile this driver as a module, choose M here: the module -- cgit v1.1 From 1d8c1100fbf956b9c5994077a4d3c6490c23e087 Mon Sep 17 00:00:00 2001 From: Michael Witten Date: Wed, 14 Jul 2010 23:54:21 +0000 Subject: ALSA: Kconfig: SND_AC97_POWER_SAVE description improvement The description has been expanded to explain the time-out value provided by the power_save module parameter. Signed-off-by: Michael Witten Signed-off-by: Takashi Iwai --- sound/drivers/Kconfig | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig index 84714a6..3264600 100644 --- a/sound/drivers/Kconfig +++ b/sound/drivers/Kconfig @@ -170,9 +170,25 @@ config SND_AC97_POWER_SAVE AC97 codecs. In this mode, the power-mode is dynamically controlled at each open/close. - The mode is activated by passing power_save=1 option to - snd-ac97-codec driver. You can toggle it dynamically over - sysfs, too. + The mode is activated by passing 'power_save=X' to the + snd-ac97-codec driver module, where 'X' is the time-out + value, a nonnegative integer that specifies how many + seconds of idle time the driver must count before it may + put the AC97 into power-save mode; a value of 0 (zero) + disables the use of this power-save mode. + + After the snd-ac97-codec driver module has been loaded, + the 'power_save' parameter can be set via sysfs as follows: + + echo 10 > /sys/module/snd_ac97_codec/parameters/power_save + + In this case, the time-out is set to 10 seconds; setting + the time-out to 1 second (the minimum activation value) + isn't recommended because many applications try to reopen + the device frequently. A value of 10 seconds would be a + good choice for normal operations. + + See Documentation/sound/alsa/powersave.txt for more details. config SND_AC97_POWER_SAVE_DEFAULT int "Default time-out for AC97 power-save mode" @@ -182,4 +198,6 @@ config SND_AC97_POWER_SAVE_DEFAULT The default time-out value in seconds for AC97 automatic power-save mode. 0 means to disable the power-save mode. + See SND_AC97_POWER_SAVE for more details. + endif # SND_DRIVERS -- cgit v1.1 From 315e8f7501ad929acacfa94c251283e837f281ed Mon Sep 17 00:00:00 2001 From: Kulikov Vasiliy Date: Thu, 15 Jul 2010 22:48:19 +0400 Subject: ALSA: asihpi: fix sign bug bytes_per_sec is unsigned, so if snd_pcm_format_width() return error we would not see it. Signed-off-by: Kulikov Vasiliy Signed-off-by: Takashi Iwai --- sound/pci/asihpi/asihpi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index 91218f7..c80b0b8 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c @@ -460,6 +460,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); int err; u16 format; + int width; unsigned int bytes_per_sec; print_hwparams(params); @@ -512,9 +513,10 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, dpcm->hpi_buffer_attached); } bytes_per_sec = params_rate(params) * params_channels(params); - bytes_per_sec *= snd_pcm_format_width(params_format(params)); + width = snd_pcm_format_width(params_format(params)); + bytes_per_sec *= width; bytes_per_sec /= 8; - if (bytes_per_sec <= 0) + if (width < 0 || bytes_per_sec == 0) return -EINVAL; dpcm->bytes_per_sec = bytes_per_sec; -- cgit v1.1 From 8d4bbee77e63981b91e4af7c569dc6a585ee0eb0 Mon Sep 17 00:00:00 2001 From: Eliot Blennerhassett Date: Fri, 16 Jul 2010 17:50:59 +1200 Subject: ALSA: asihpi - HPI version 4.04.01 Signed-off-by: Eliot Blennerhassett Signed-off-by: Takashi Iwai --- sound/pci/asihpi/hpi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/hpi.h b/sound/pci/asihpi/hpi.h index cee4df4..23399d0 100644 --- a/sound/pci/asihpi/hpi.h +++ b/sound/pci/asihpi/hpi.h @@ -50,8 +50,8 @@ i.e 3.05.02 is a development version #define HPI_VER_RELEASE(v) ((int)(v & 0xFF)) /* Use single digits for versions less that 10 to avoid octal. */ -#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 3, 36) -#define HPI_VER_STRING "4.03.36" +#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 4, 1) +#define HPI_VER_STRING "4.04.01" /* Library version as documented in hpi-api-versions.txt */ #define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0) -- cgit v1.1 From 604a440a9dd08d45570c555d78a17a4602c843d5 Mon Sep 17 00:00:00 2001 From: Eliot Blennerhassett Date: Fri, 16 Jul 2010 17:51:00 +1200 Subject: ALSA: asihpi - Avoid using c99 uintX types. Signed-off-by: Eliot Blennerhassett Signed-off-by: Takashi Iwai --- sound/pci/asihpi/hpi_internal.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/hpi_internal.h b/sound/pci/asihpi/hpi_internal.h index 7ae7a1d..16f502d 100644 --- a/sound/pci/asihpi/hpi_internal.h +++ b/sound/pci/asihpi/hpi_internal.h @@ -104,9 +104,9 @@ typedef void hpi_handler_func(struct hpi_message *, struct hpi_response *); #define STR_ROLE_FIELD_MAX 255U struct hpi_entity_str { - uint16_t size; - uint8_t type; - uint8_t role; + u16 size; + u8 type; + u8 role; }; #if defined(_MSC_VER) @@ -119,11 +119,11 @@ struct hpi_entity { #if ! defined(HPI_OS_DSP_C6000) || (defined(HPI_OS_DSP_C6000) && (__TI_COMPILER_VERSION__ > 6000008)) /* DSP C6000 compiler v6.0.8 and lower do not support flexible array member */ - uint8_t value[]; + u8 value[]; #else /* NOTE! Using sizeof(struct hpi_entity) will give erroneous results */ #define HPI_INTERNAL_WARN_ABOUT_ENTITY_VALUE - uint8_t value[1]; + u8 value[1]; #endif }; -- cgit v1.1 From e2768c0c223d86a20ec392528bafd25996ce7585 Mon Sep 17 00:00:00 2001 From: Eliot Blennerhassett Date: Fri, 16 Jul 2010 17:51:01 +1200 Subject: ALSA: asihpi - Avoid useless assignment of returned index values. Signed-off-by: Eliot Blennerhassett Signed-off-by: Takashi Iwai --- sound/pci/asihpi/hpifunc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/hpifunc.c b/sound/pci/asihpi/hpifunc.c index 9c6958a..1e92eb6 100644 --- a/sound/pci/asihpi/hpifunc.c +++ b/sound/pci/asihpi/hpifunc.c @@ -2179,7 +2179,7 @@ u16 hpi_compander_get_attack_time_constant(const struct hpi_hsubsys *ph_subsys, u32 h_control, unsigned int index, u32 *attack) { return hpi_control_param_get(ph_subsys, h_control, - HPI_COMPANDER_ATTACK, 0, index, attack, &index); + HPI_COMPANDER_ATTACK, 0, index, attack, NULL); } u16 hpi_compander_set_decay_time_constant(const struct hpi_hsubsys *ph_subsys, @@ -2193,7 +2193,7 @@ u16 hpi_compander_get_decay_time_constant(const struct hpi_hsubsys *ph_subsys, u32 h_control, unsigned int index, u32 *decay) { return hpi_control_param_get(ph_subsys, h_control, - HPI_COMPANDER_DECAY, 0, index, decay, &index); + HPI_COMPANDER_DECAY, 0, index, decay, NULL); } @@ -2244,7 +2244,7 @@ u16 hpi_compander_get_ratio(const struct hpi_hsubsys *ph_subsys, u32 h_control, u32 index, u32 *ratio100) { return hpi_control_param_get(ph_subsys, h_control, - HPI_COMPANDER_RATIO, 0, index, ratio100, &index); + HPI_COMPANDER_RATIO, 0, index, ratio100, NULL); } u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, @@ -3258,8 +3258,7 @@ static inline size_t hpi_entity_item_count(struct hpi_entity *entity_ptr) static inline struct hpi_entity *hpi_entity_ptr_to_next(struct hpi_entity *entity_ptr) { - return (void *)(((uint8_t *) entity_ptr) + - hpi_entity_size(entity_ptr)); + return (void *)(((u8 *)entity_ptr) + hpi_entity_size(entity_ptr)); } static inline u16 hpi_entity_check_type(const enum e_entity_type t) -- cgit v1.1 From 82f682514a5df89ffb3890627eebf0897b7a84ec Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Mon, 5 Jul 2010 22:53:06 +0200 Subject: pm_qos: Get rid of the allocation in pm_qos_add_request() All current users of pm_qos_add_request() have the ability to supply the memory required by the pm_qos routines, so make them do this and eliminate the kmalloc() with pm_qos_add_request(). This has the double benefit of making the call never fail and allowing it to be called from atomic context. Signed-off-by: James Bottomley Signed-off-by: mark gross Signed-off-by: Rafael J. Wysocki --- sound/core/pcm_native.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 303ac04..a3b2a64 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -451,13 +451,11 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream, snd_pcm_timer_resolution_change(substream); runtime->status->state = SNDRV_PCM_STATE_SETUP; - if (substream->latency_pm_qos_req) { - pm_qos_remove_request(substream->latency_pm_qos_req); - substream->latency_pm_qos_req = NULL; - } + if (pm_qos_request_active(&substream->latency_pm_qos_req)) + pm_qos_remove_request(&substream->latency_pm_qos_req); if ((usecs = period_to_usecs(runtime)) >= 0) - substream->latency_pm_qos_req = pm_qos_add_request( - PM_QOS_CPU_DMA_LATENCY, usecs); + pm_qos_add_request(&substream->latency_pm_qos_req, + PM_QOS_CPU_DMA_LATENCY, usecs); return 0; _error: /* hardware might be unuseable from this time, @@ -512,8 +510,7 @@ static int snd_pcm_hw_free(struct snd_pcm_substream *substream) if (substream->ops->hw_free) result = substream->ops->hw_free(substream); runtime->status->state = SNDRV_PCM_STATE_OPEN; - pm_qos_remove_request(substream->latency_pm_qos_req); - substream->latency_pm_qos_req = NULL; + pm_qos_remove_request(&substream->latency_pm_qos_req); return result; } -- cgit v1.1 From 25d1fbfdd98e6547f2ba3e36787f20d251019591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Tue, 13 Jul 2010 11:27:58 +0200 Subject: fix comment typos concerning "challenge" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-König Signed-off-by: Jiri Kosina --- sound/soc/imx/imx-ssi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/imx/imx-ssi.c b/sound/soc/imx/imx-ssi.c index 80b4fee..4fd13d0 100644 --- a/sound/soc/imx/imx-ssi.c +++ b/sound/soc/imx/imx-ssi.c @@ -23,7 +23,7 @@ * between pcm data and GPIO status data changes. Our FIQ handler is not * able to handle this, hence this driver only works with 48000Hz sampling * rate. - * Reading and writing AC97 registers is another challange. The core + * Reading and writing AC97 registers is another challenge. The core * provides us status bits when the read register is updated with *another* * value. When we read the same register two times (and the register still * contains the same value) these status bits are not set. We work -- cgit v1.1 From 79c944ad136c4d14388d803b51113dcaaa1d179d Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 19 Jul 2010 15:52:39 +0200 Subject: ALSA: hda-intel - do not mix audio and modem function IDs The function IDs are different for audio and modem. Do not mix them. Also, show the unsolicited bit in the function_id register. Signed-off-by: Jaroslav Kysela --- sound/pci/hda/hda_codec.c | 8 +++++--- sound/pci/hda/hda_codec.h | 5 ++++- sound/pci/hda/hda_proc.c | 7 ++++++- 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index a3d638c..6e0de65 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -730,15 +730,17 @@ static void /*__devinit*/ setup_fg_nodes(struct hda_codec *codec) total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid); for (i = 0; i < total_nodes; i++, nid++) { function_id = snd_hda_param_read(codec, nid, - AC_PAR_FUNCTION_TYPE) & 0xff; + AC_PAR_FUNCTION_TYPE); switch (function_id) { case AC_GRP_AUDIO_FUNCTION: codec->afg = nid; - codec->function_id = function_id; + codec->afg_function_id = function_id & 0xff; + codec->afg_unsol = (function_id >> 8) & 1; break; case AC_GRP_MODEM_FUNCTION: codec->mfg = nid; - codec->function_id = function_id; + codec->mfg_function_id = function_id & 0xff; + codec->mfg_unsol = (function_id >> 8) & 1; break; default: break; diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 49e939e..f96e909 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -760,7 +760,10 @@ struct hda_codec { hda_nid_t mfg; /* MFG node id */ /* ids */ - u32 function_id; + u8 afg_function_id; + u8 mfg_function_id; + u8 afg_unsol; + u8 mfg_unsol; u32 vendor_id; u32 subsystem_id; u32 revision_id; diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index f97d35d..f025200 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c @@ -557,7 +557,12 @@ static void print_codec_info(struct snd_info_entry *entry, else snd_iprintf(buffer, "Not Set\n"); snd_iprintf(buffer, "Address: %d\n", codec->addr); - snd_iprintf(buffer, "Function Id: 0x%x\n", codec->function_id); + if (codec->afg) + snd_iprintf(buffer, "AFG Function Id: 0x%x (unsol %u)\n", + codec->afg_function_id, codec->afg_unsol); + if (codec->mfg) + snd_iprintf(buffer, "MFG Function Id: 0x%x (unsol %u)\n", + codec->mfg_function_id, codec->mfg_unsol); snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id); snd_iprintf(buffer, "Subsystem Id: 0x%08x\n", codec->subsystem_id); snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id); -- cgit v1.1 From 9e216e8a40428cbf689222148c28d0256fbd0186 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 19 Jul 2010 16:37:39 +0200 Subject: ALSA: pcm core - add a safe check to the silence filling function In situation when appl_ptr is far greater then hw_ptr, the hw_avail value can be greater than buffer_size. Check for this. Signed-off-by: Jaroslav Kysela --- sound/core/pcm_lib.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index bcf95d3..e23e0e7 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -67,6 +67,8 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram } else { if (new_hw_ptr == ULONG_MAX) { /* initialization */ snd_pcm_sframes_t avail = snd_pcm_playback_hw_avail(runtime); + if (avail > runtime->buffer_size) + avail = runtime->buffer_size; runtime->silence_filled = avail > 0 ? avail : 0; runtime->silence_start = (runtime->status->hw_ptr + runtime->silence_filled) % -- cgit v1.1 From 0b6d092c8eeeb43893503afd2f6c1c67ceafc863 Mon Sep 17 00:00:00 2001 From: Kulikov Vasiliy Date: Fri, 16 Jul 2010 20:15:43 +0400 Subject: ALSA: echoaudio: check kmalloc() result If kmalloc() fails exit with -ENOMEM. Signed-off-by: Kulikov Vasiliy Ack-by: Giuliano Pochini Signed-off-by: Takashi Iwai --- sound/pci/echoaudio/echoaudio.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c index 668a5ec..20763dd 100644 --- a/sound/pci/echoaudio/echoaudio.c +++ b/sound/pci/echoaudio/echoaudio.c @@ -2250,6 +2250,8 @@ static int snd_echo_resume(struct pci_dev *pci) DE_INIT(("resume start\n")); pci_restore_state(pci); commpage_bak = kmalloc(sizeof(struct echoaudio), GFP_KERNEL); + if (commpage_bak == NULL) + return -ENOMEM; commpage = chip->comm_page; memcpy(commpage_bak, commpage, sizeof(struct comm_page)); -- cgit v1.1 From 68bf57001f4995a25ca65f3711ff05b6ea25e8b6 Mon Sep 17 00:00:00 2001 From: Kulikov Vasiliy Date: Fri, 16 Jul 2010 20:15:59 +0400 Subject: ALSA: riptide: check kzalloc() result If kzalloc() fails exit with -ENOMEM. Signed-off-by: Kulikov Vasiliy Signed-off-by: Takashi Iwai --- sound/pci/riptide/riptide.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sound') diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 59d7996..f64fb7d 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -1615,7 +1615,10 @@ static int snd_riptide_playback_open(struct snd_pcm_substream *substream) chip->playback_substream[sub_num] = substream; runtime->hw = snd_riptide_playback; + data = kzalloc(sizeof(struct pcmhw), GFP_KERNEL); + if (data == NULL) + return -ENOMEM; data->paths = lbus_play_paths[sub_num]; data->id = play_ids[sub_num]; data->source = play_sources[sub_num]; @@ -1635,7 +1638,10 @@ static int snd_riptide_capture_open(struct snd_pcm_substream *substream) chip->capture_substream = substream; runtime->hw = snd_riptide_capture; + data = kzalloc(sizeof(struct pcmhw), GFP_KERNEL); + if (data == NULL) + return -ENOMEM; data->paths = lbus_rec_path; data->id = PADC; data->source = ACLNK2PADC; -- cgit v1.1 From ab85457f0a46b9dab17aaa01ceefc755b124d48d Mon Sep 17 00:00:00 2001 From: Jerone Young Date: Mon, 19 Jul 2010 08:30:58 -0500 Subject: ALSA: hda - Add conexant quirk for AMD based Lenovo G series machines This is a follow on patch adds support for AMD based Lenovo G series machines, such as the Lenovo G555. Signed-off-by: Jerone Young Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 3b789ee..c99425a 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3040,8 +3040,10 @@ static struct snd_pci_quirk cxt5066_cfg_tbl[] = { SND_PCI_QUIRK(0x17aa, 0x21b2, "Thinkpad X100e", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x17aa, 0x21b3, "Thinkpad Edge 13 (197)", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x17aa, 0x21b4, "Thinkpad Edge", CXT5066_IDEAPAD), + SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD), + SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G series", CXT5066_IDEAPAD), + SND_PCI_QUIRK(0x17aa, 0x3938, "Lenovo G series (AMD)", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x17aa, 0x3a0d, "ideapad", CXT5066_IDEAPAD), - SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD), {} }; -- cgit v1.1 From cd7643bfb772dc7103ed6fc8dda6b233a8e14178 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 20 Jul 2010 12:11:25 +0200 Subject: ALSA: hda-intel - fix function_id rework (add missing bitmask) Signed-off-by: Jaroslav Kysela --- sound/pci/hda/hda_codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 6e0de65..3252945 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -731,7 +731,7 @@ static void /*__devinit*/ setup_fg_nodes(struct hda_codec *codec) for (i = 0; i < total_nodes; i++, nid++) { function_id = snd_hda_param_read(codec, nid, AC_PAR_FUNCTION_TYPE); - switch (function_id) { + switch (function_id & 0xff) { case AC_GRP_AUDIO_FUNCTION: codec->afg = nid; codec->afg_function_id = function_id & 0xff; -- cgit v1.1 From ff388f270d926d95d70e5b3d373c9cb97b38c8b1 Mon Sep 17 00:00:00 2001 From: Christian Dietrich Date: Wed, 21 Jul 2010 14:35:17 +0200 Subject: sound/oss: Remove dead CONFIG_SOFTOSS* CONFIG_SOFTOSS* doesn't exist in Kconfig or somewhere else, therefore removing all references for it from the source code. Signed-off-by: Christian Dietrich Signed-off-by: Takashi Iwai --- sound/oss/vidc.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'sound') diff --git a/sound/oss/vidc.c b/sound/oss/vidc.c index ac39a53..f0e0caa 100644 --- a/sound/oss/vidc.c +++ b/sound/oss/vidc.c @@ -491,9 +491,6 @@ static void __init attach_vidc(struct address_info *hw_config) vidc_adev = adev; vidc_mixer_set(SOUND_MIXER_VOLUME, (85 | 85 << 8)); -#if defined(CONFIG_SOUND_SOFTOSS) || defined(CONFIG_SOUND_SOFTOSS_MODULE) - softoss_dev = adev; -#endif return; irq_failed: -- cgit v1.1 From 1ab1d63a85cee2545272f63a7644e9f855cb65d0 Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Thu, 24 Jun 2010 15:14:37 -0600 Subject: of/platform: remove all of_bus_type and of_platform_bus_type references Both of_bus_type and of_platform_bus_type are just #define aliases for the platform bus. This patch removes all references to them and switches to the of_register_platform_driver()/of_unregister_platform_driver() API for registering. Subsequent patches will convert each user of of_register_platform_driver() into plain platform_drivers without the of_platform_driver shim. At which point the of_register_platform_driver()/of_unregister_platform_driver() functions can be removed. Signed-off-by: Grant Likely Acked-by: David S. Miller --- sound/sparc/amd7930.c | 4 ++-- sound/sparc/cs4231.c | 4 ++-- sound/sparc/dbri.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index 43c63d4..9eb1a4e 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -1075,7 +1075,7 @@ static struct of_platform_driver amd7930_sbus_driver = { static int __init amd7930_init(void) { - return of_register_driver(&amd7930_sbus_driver, &of_bus_type); + return of_register_platform_driver(&amd7930_sbus_driver); } static void __exit amd7930_exit(void) @@ -1092,7 +1092,7 @@ static void __exit amd7930_exit(void) amd7930_list = NULL; - of_unregister_driver(&amd7930_sbus_driver); + of_unregister_platform_driver(&amd7930_sbus_driver); } module_init(amd7930_init); diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index f7f05c2..68570ee 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -2120,12 +2120,12 @@ static struct of_platform_driver cs4231_driver = { static int __init cs4231_init(void) { - return of_register_driver(&cs4231_driver, &of_bus_type); + return of_register_platform_driver(&cs4231_driver); } static void __exit cs4231_exit(void) { - of_unregister_driver(&cs4231_driver); + of_unregister_platform_driver(&cs4231_driver); } module_init(cs4231_init); diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 491ce71..c421901 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2699,12 +2699,12 @@ static struct of_platform_driver dbri_sbus_driver = { /* Probe for the dbri chip and then attach the driver. */ static int __init dbri_init(void) { - return of_register_driver(&dbri_sbus_driver, &of_bus_type); + return of_register_platform_driver(&dbri_sbus_driver); } static void __exit dbri_exit(void) { - of_unregister_driver(&dbri_sbus_driver); + of_unregister_platform_driver(&dbri_sbus_driver); } module_init(dbri_init); -- cgit v1.1 From 2385b789f1525542396d8f6b0cc37c1eb2493b4c Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Wed, 2 Jun 2010 16:56:41 +0200 Subject: ALSA: hda - Ensure codec patch files are checked for the correct codec ID Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_hwdep.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c index a1fc837..bf3ced5 100644 --- a/sound/pci/hda/hda_hwdep.c +++ b/sound/pci/hda/hda_hwdep.c @@ -649,7 +649,9 @@ static void parse_codec_mode(char *buf, struct hda_bus *bus, *codecp = NULL; if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) { list_for_each_entry(codec, &bus->codec_list, list) { - if (codec->addr == caddr) { + if (codec->vendor_id == vendorid && + codec->subsystem_id == subid && + codec->addr == caddr) { *codecp = codec; break; } -- cgit v1.1 From 2232e238295d8ea707fe4271ffbfd4f32346aa81 Mon Sep 17 00:00:00 2001 From: Kulikov Vasiliy Date: Mon, 26 Jul 2010 12:28:32 +0400 Subject: sound: oss: au1550_ac97: simplify au1550_delay() au1550_delay() uses loop with schedule_timeout() to unconditionally wait for msec. Use schedule_timeout_uninteruptible() instead. Signed-off-by: Kulikov Vasiliy Signed-off-by: Takashi Iwai --- sound/oss/au1550_ac97.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'sound') diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c index 0fd256c..c4a4cdc 100644 --- a/sound/oss/au1550_ac97.c +++ b/sound/oss/au1550_ac97.c @@ -163,19 +163,10 @@ ld2(unsigned int x) static void au1550_delay(int msec) { - unsigned long tmo; - signed long tmo2; - if (in_interrupt()) return; - tmo = jiffies + (msec * HZ) / 1000; - for (;;) { - tmo2 = tmo - jiffies; - if (tmo2 <= 0) - break; - schedule_timeout(tmo2); - } + schedule_timeout_uninterruptible(msecs_to_jiffies(msec)); } static u16 -- cgit v1.1 From e5de3dfc391cceff6a4a3a0bb9c9c349a2e7c275 Mon Sep 17 00:00:00 2001 From: Kulikov Vasiliy Date: Mon, 26 Jul 2010 12:29:22 +0400 Subject: sound: oss: waveartist: simplify waveartist_sleep() waveartist_sleep() uses loop with schedule_timeout() to unconditionally wait for msec. Use schedule_timeout_uninteruptible() instead. Signed-off-by: Kulikov Vasiliy Signed-off-by: Takashi Iwai --- sound/oss/waveartist.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/oss/waveartist.c b/sound/oss/waveartist.c index e688dde..5246874 100644 --- a/sound/oss/waveartist.c +++ b/sound/oss/waveartist.c @@ -184,14 +184,8 @@ waveartist_iack(wavnc_info *devc) static inline int waveartist_sleep(int timeout_ms) { - unsigned int timeout = timeout_ms * 10 * HZ / 100; - - do { - set_current_state(TASK_INTERRUPTIBLE); - timeout = schedule_timeout(timeout); - } while (timeout); - - return 0; + unsigned int timeout = msecs_to_jiffies(timeout_ms*100); + return schedule_timeout_interruptible(timeout); } static int -- cgit v1.1 From 7ccc3eface57b6e1773fce009dac8a3da081b8b1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 26 Jul 2010 17:00:15 +0200 Subject: ALSA: hda - Fix max amp cap calculation for IDT/STAC codecs The commit afbd9b8448f4b7d15673c6858012f384f18d28b8 ALSA: hda - Limit the amp value to write introduced a regression for codec setups with amp offsets like IDT/STAC codecs. The limit value should be a raw value without offset calculation. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 501cbc4..e5c3484 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1629,7 +1629,8 @@ update_amp_value(struct hda_codec *codec, hda_nid_t nid, if (val > 0) val += ofs; - maxval = get_amp_max_value(codec, nid, dir, ofs); + /* ofs = 0: raw max value */ + maxval = get_amp_max_value(codec, nid, dir, 0); if (val > maxval) val = maxval; return snd_hda_codec_amp_update(codec, nid, ch, dir, idx, -- cgit v1.1 From 93871603a74563b3683d09ef13da954670829c45 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 26 Jul 2010 19:08:15 +0100 Subject: SOUND: Au1000: Fix section mismatch WARNING: sound/soc/au1x/snd-soc-au1xpsc-i2s.o(.data+0xa8): Section mismatch in reference from the variable au1xpsc_i2s_driver to the function .init.text:au1xpsc_i2s_drvprobe() The variable au1xpsc_i2s_driver references the function __init au1xpsc_i2s_drvprobe() If the reference is valid then annotate the variable with __init* or __refdata (see linux/init.h) or name the variable: *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console, Signed-off-by: Ralf Baechle --- sound/soc/au1x/psc-i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/au1x/psc-i2s.c b/sound/soc/au1x/psc-i2s.c index 495be6e..24454c9 100644 --- a/sound/soc/au1x/psc-i2s.c +++ b/sound/soc/au1x/psc-i2s.c @@ -300,7 +300,7 @@ struct snd_soc_dai au1xpsc_i2s_dai = { }; EXPORT_SYMBOL(au1xpsc_i2s_dai); -static int __init au1xpsc_i2s_drvprobe(struct platform_device *pdev) +static int __devinit au1xpsc_i2s_drvprobe(struct platform_device *pdev) { struct resource *r; unsigned long sel; -- cgit v1.1 From 63818c448ac6f4dd75aa42997acaa746f86acb6b Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 28 Jul 2010 16:58:42 +0800 Subject: ALSA: hpimsgx: fix wrong sizeof The correct size should be sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS), sizeof(&gRESP_HPI_SUBSYS_FIND_ADAPTERS) is incorrect. Signed-off-by: Axel Lin Signed-off-by: Takashi Iwai --- sound/pci/asihpi/hpimsgx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/asihpi/hpimsgx.c b/sound/pci/asihpi/hpimsgx.c index 2ee90dc..f01ab96 100644 --- a/sound/pci/asihpi/hpimsgx.c +++ b/sound/pci/asihpi/hpimsgx.c @@ -741,7 +741,7 @@ static void HPIMSGX__reset(u16 adapter_index) hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_FIND_ADAPTERS, 0); memcpy(&gRESP_HPI_SUBSYS_FIND_ADAPTERS, &hr, - sizeof(&gRESP_HPI_SUBSYS_FIND_ADAPTERS)); + sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS)); for (adapter = 0; adapter < HPI_MAX_ADAPTERS; adapter++) { -- cgit v1.1 From 38faddb1afdd37218c196ac3db1cb5fbe7fc9c75 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jul 2010 14:21:55 +0200 Subject: ALSA: hda - Fix pin-detection of Nvidia HDMI The behavior of Nvidia HDMI codec regarding the pin-detection unsol events is based on the old HD-audio spec, i.e. PD bit indicates only the update and doesn't show the current state. Since the current code assumes the new behavior, the pin-detection doesn't work relialby with these h/w. This patch adds a flag for indicating the old spec, and fixes the issue by checking the pin-detection explicitly for such hardware. Tested-by: Wei Ni Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_hdmi.c | 13 +++++++++++++ sound/pci/hda/patch_nvhdmi.c | 3 +++ 2 files changed, 16 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 86067ee7..2fc5396 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -52,6 +52,10 @@ struct hdmi_spec { */ struct hda_multi_out multiout; unsigned int codec_type; + + /* misc flags */ + /* PD bit indicates only the update, not the current state */ + unsigned int old_pin_detect:1; }; @@ -616,6 +620,9 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, * Unsolicited events */ +static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid, + struct hdmi_eld *eld); + static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) { struct hdmi_spec *spec = codec->spec; @@ -632,6 +639,12 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) if (index < 0) return; + if (spec->old_pin_detect) { + if (pind) + hdmi_present_sense(codec, tag, &spec->sink_eld[index]); + pind = spec->sink_eld[index].monitor_present; + } + spec->sink_eld[index].monitor_present = pind; spec->sink_eld[index].eld_valid = eldv; diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c index 3c10c0b..b0652ac 100644 --- a/sound/pci/hda/patch_nvhdmi.c +++ b/sound/pci/hda/patch_nvhdmi.c @@ -478,6 +478,7 @@ static int patch_nvhdmi_8ch_89(struct hda_codec *codec) codec->spec = spec; spec->codec_type = HDA_CODEC_NVIDIA_MCP89; + spec->old_pin_detect = 1; if (hdmi_parse_codec(codec) < 0) { codec->spec = NULL; @@ -508,6 +509,7 @@ static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) spec->multiout.max_channels = 8; spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; spec->codec_type = HDA_CODEC_NVIDIA_MCP7X; + spec->old_pin_detect = 1; codec->patch_ops = nvhdmi_patch_ops_8ch_7x; @@ -528,6 +530,7 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec) spec->multiout.max_channels = 2; spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; spec->codec_type = HDA_CODEC_NVIDIA_MCP7X; + spec->old_pin_detect = 1; codec->patch_ops = nvhdmi_patch_ops_2ch; -- cgit v1.1 From 8af2591d6342a9e4bb79b4f1236246a79d20ebee Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jul 2010 17:37:16 +0200 Subject: ALSA: hda - Don't register beep input device when no beep is available We check now the availability of PC beep and skip the build of beep mixers, but the driver still registers the input device. This should be checked as well. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index ff614dd8..d7fd846 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -10566,10 +10566,12 @@ static int patch_alc882(struct hda_codec *codec) } } - err = snd_hda_attach_beep_device(codec, 0x1); - if (err < 0) { - alc_free(codec); - return err; + if (spec->cdefine.enable_pcbeep) { + err = snd_hda_attach_beep_device(codec, 0x1); + if (err < 0) { + alc_free(codec); + return err; + } } if (board_config != ALC882_AUTO) @@ -12435,7 +12437,7 @@ static int patch_alc262(struct hda_codec *codec) } } - if (!spec->no_analog) { + if (!spec->no_analog && spec->cdefine.enable_pcbeep) { err = snd_hda_attach_beep_device(codec, 0x1); if (err < 0) { alc_free(codec); @@ -14458,10 +14460,12 @@ static int patch_alc269(struct hda_codec *codec) } } - err = snd_hda_attach_beep_device(codec, 0x1); - if (err < 0) { - alc_free(codec); - return err; + if (spec->cdefine.enable_pcbeep) { + err = snd_hda_attach_beep_device(codec, 0x1); + if (err < 0) { + alc_free(codec); + return err; + } } if (board_config != ALC269_AUTO) @@ -18691,10 +18695,12 @@ static int patch_alc662(struct hda_codec *codec) } } - err = snd_hda_attach_beep_device(codec, 0x1); - if (err < 0) { - alc_free(codec); - return err; + if (spec->cdefine.enable_pcbeep) { + err = snd_hda_attach_beep_device(codec, 0x1); + if (err < 0) { + alc_free(codec); + return err; + } } if (board_config != ALC662_AUTO) -- cgit v1.1 From b6cbe517b9a4f21e1ca5e58356929383974500f3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 28 Jul 2010 17:43:36 +0200 Subject: ALSA: hda - Assume PC-beep as default for Realtek Enable PC-beep as default for hardwares that aren't compliant with the SSID value Realtek requires. In such a case, better to enable the beep to avoid a regression. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index d7fd846..9295527 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1267,11 +1267,11 @@ static int alc_auto_parse_customize_define(struct hda_codec *codec) unsigned nid = 0; struct alc_spec *spec = codec->spec; + spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ + ass = codec->subsystem_id & 0xffff; - if (ass != codec->bus->pci->subsystem_device && (ass & 1)) { - spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ + if (ass != codec->bus->pci->subsystem_device && (ass & 1)) goto do_sku; - } nid = 0x1d; if (codec->vendor_id == 0x10ec0260) -- cgit v1.1 From 5157cc8113db3de60ab6320965331c63bc77003c Mon Sep 17 00:00:00 2001 From: Kulikov Vasiliy Date: Wed, 28 Jul 2010 20:40:51 +0400 Subject: ALSA: sb: check get_user() return value get_user() may fail, if so return -EFAULT. [Fixed one missing place by tiwai] Signed-off-by: Kulikov Vasiliy Signed-off-by: Takashi Iwai --- sound/isa/sb/emu8000_pcm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c index ccedbfe..2f85c66 100644 --- a/sound/isa/sb/emu8000_pcm.c +++ b/sound/isa/sb/emu8000_pcm.c @@ -433,7 +433,8 @@ static int emu8k_transfer_block(struct snd_emu8000 *emu, int offset, unsigned sh while (count > 0) { unsigned short sval; CHECK_SCHEDULER(); - get_user(sval, buf); + if (get_user(sval, buf)) + return -EFAULT; EMU8000_SMLD_WRITE(emu, sval); buf++; count--; @@ -525,12 +526,14 @@ static int emu8k_pcm_copy(struct snd_pcm_substream *subs, while (count-- > 0) { unsigned short sval; CHECK_SCHEDULER(); - get_user(sval, buf); + if (get_user(sval, buf)) + return -EFAULT; EMU8000_SMLD_WRITE(emu, sval); buf++; if (rec->voices > 1) { CHECK_SCHEDULER(); - get_user(sval, buf); + if (get_user(sval, buf)) + return -EFAULT; EMU8000_SMRD_WRITE(emu, sval); buf++; } -- cgit v1.1 From b3390ceab95601afc12213c3ec5551d3bc7b638f Mon Sep 17 00:00:00 2001 From: Kulikov Vasiliy Date: Wed, 28 Jul 2010 20:41:17 +0400 Subject: sound: oss: midi_synth: check get_user() return value get_user() may fail, if so return -EFAULT. Signed-off-by: Kulikov Vasiliy Signed-off-by: Takashi Iwai --- sound/oss/midi_synth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/oss/midi_synth.c b/sound/oss/midi_synth.c index 3bc7104..3c09374 100644 --- a/sound/oss/midi_synth.c +++ b/sound/oss/midi_synth.c @@ -523,7 +523,9 @@ midi_synth_load_patch(int dev, int format, const char __user *addr, { unsigned char data; - get_user(*(unsigned char *) &data, (unsigned char __user *) &((addr)[hdr_size + i])); + if (get_user(data, + (unsigned char __user *)(addr + hdr_size + i))) + return -EFAULT; eox_seen = (i > 0 && data & 0x80); /* End of sysex */ -- cgit v1.1 From ec9d04b2a8f00b14a3df4714820cb2cda46dc4d6 Mon Sep 17 00:00:00 2001 From: Kulikov Vasiliy Date: Wed, 28 Jul 2010 20:41:56 +0400 Subject: ALSA: asihpi: check return value of get_user() get_user() may fail, if so return -EFAULT. Signed-off-by: Kulikov Vasiliy Signed-off-by: Takashi Iwai --- sound/pci/asihpi/hpioctl.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/pci/asihpi/hpioctl.c b/sound/pci/asihpi/hpioctl.c index 3114999..62895a7 100644 --- a/sound/pci/asihpi/hpioctl.c +++ b/sound/pci/asihpi/hpioctl.c @@ -121,11 +121,17 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) phpi_ioctl_data = (struct hpi_ioctl_linux __user *)arg; /* Read the message and response pointers from user space. */ - get_user(puhm, &phpi_ioctl_data->phm); - get_user(puhr, &phpi_ioctl_data->phr); + if (get_user(puhm, &phpi_ioctl_data->phm) || + get_user(puhr, &phpi_ioctl_data->phr)) { + err = -EFAULT; + goto out; + } /* Now read the message size and data from user space. */ - get_user(hm->h.size, (u16 __user *)puhm); + if (get_user(hm->h.size, (u16 __user *)puhm)) { + err = -EFAULT; + goto out; + } if (hm->h.size > sizeof(*hm)) hm->h.size = sizeof(*hm); @@ -138,7 +144,10 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) goto out; } - get_user(res_max_size, (u16 __user *)puhr); + if (get_user(res_max_size, (u16 __user *)puhr)) { + err = -EFAULT; + goto out; + } /* printk(KERN_INFO "user response size %d\n", res_max_size); */ if (res_max_size < sizeof(struct hpi_response_header)) { HPI_DEBUG_LOG(WARNING, "small res size %d\n", res_max_size); -- cgit v1.1 From fa95a6471ffaa6f40d71f44fc4d4636ee17280f5 Mon Sep 17 00:00:00 2001 From: Kulikov Vasiliy Date: Thu, 29 Jul 2010 14:45:24 +0400 Subject: ALSA: msnd: check request_region() return value request_region() may fail, if so return -EBUSY. Signed-off-by: Kulikov Vasiliy Signed-off-by: Takashi Iwai --- sound/isa/msnd/msnd_pinnacle.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c index 60b6abd..5f3e684 100644 --- a/sound/isa/msnd/msnd_pinnacle.c +++ b/sound/isa/msnd/msnd_pinnacle.c @@ -549,7 +549,10 @@ static int __devinit snd_msnd_attach(struct snd_card *card) printk(KERN_ERR LOGNAME ": Couldn't grab IRQ %d\n", chip->irq); return err; } - request_region(chip->io, DSP_NUMIO, card->shortname); + if (request_region(chip->io, DSP_NUMIO, card->shortname) == NULL) { + free_irq(chip->irq, chip); + return -EBUSY; + } if (!request_mem_region(chip->base, BUFFSIZE, card->shortname)) { printk(KERN_ERR LOGNAME -- cgit v1.1 From 9c29490246ed80975ab8b87bcd4ebe5b87c1c1d6 Mon Sep 17 00:00:00 2001 From: Kulikov Vasiliy Date: Thu, 29 Jul 2010 14:45:50 +0400 Subject: sound: oss: msnd: check request_region() return value request_region() may fail, if so return -EBUSY. Signed-off-by: Kulikov Vasiliy Signed-off-by: Takashi Iwai --- sound/oss/msnd_pinnacle.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c index bfaac5f..2e48b17 100644 --- a/sound/oss/msnd_pinnacle.c +++ b/sound/oss/msnd_pinnacle.c @@ -1400,9 +1400,13 @@ static int __init attach_multisound(void) printk(KERN_ERR LOGNAME ": Couldn't grab IRQ %d\n", dev.irq); return err; } - request_region(dev.io, dev.numio, dev.name); + if (request_region(dev.io, dev.numio, dev.name) == NULL) { + free_irq(dev.irq, &dev); + return -EBUSY; + } - if ((err = dsp_full_reset()) < 0) { + err = dsp_full_reset(); + if (err < 0) { release_region(dev.io, dev.numio); free_irq(dev.irq, &dev); return err; -- cgit v1.1 From dc1eae256cfac03bf17bf3eb016e3a6423d3f9d5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 29 Jul 2010 15:30:02 +0200 Subject: ALSA: hda - Add a PC-beep workaround for ASUS P5-V ASUS P5-V provides a SSID that unexpectedly matches with the value compilant with Realtek's specification. Thus the driver interprets it badly, resulting in non-working PC beep. This patch adds a white-list for such a case; a white-list of known devices with working PC beep. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 9295527..596ea2f 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -5180,8 +5180,24 @@ static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids, #ifdef CONFIG_SND_HDA_INPUT_BEEP #define set_beep_amp(spec, nid, idx, dir) \ ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) + +static struct snd_pci_quirk beep_white_list[] = { + SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), + {} +}; + +static inline int has_cdefine_beep(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + const struct snd_pci_quirk *q; + q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); + if (q) + return q->value; + return spec->cdefine.enable_pcbeep; +} #else #define set_beep_amp(spec, nid, idx, dir) /* NOP */ +#define has_cdefine_beep(codec) 0 #endif /* @@ -10566,7 +10582,7 @@ static int patch_alc882(struct hda_codec *codec) } } - if (spec->cdefine.enable_pcbeep) { + if (has_cdefine_beep(codec)) { err = snd_hda_attach_beep_device(codec, 0x1); if (err < 0) { alc_free(codec); @@ -10621,7 +10637,7 @@ static int patch_alc882(struct hda_codec *codec) set_capture_mixer(codec); - if (spec->cdefine.enable_pcbeep) + if (has_cdefine_beep(codec)) set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); if (board_config == ALC882_AUTO) @@ -12437,7 +12453,7 @@ static int patch_alc262(struct hda_codec *codec) } } - if (!spec->no_analog && spec->cdefine.enable_pcbeep) { + if (!spec->no_analog && has_cdefine_beep(codec)) { err = snd_hda_attach_beep_device(codec, 0x1); if (err < 0) { alc_free(codec); @@ -12488,7 +12504,7 @@ static int patch_alc262(struct hda_codec *codec) } if (!spec->cap_mixer && !spec->no_analog) set_capture_mixer(codec); - if (!spec->no_analog && spec->cdefine.enable_pcbeep) + if (!spec->no_analog && has_cdefine_beep(codec)) set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); spec->vmaster_nid = 0x0c; @@ -14460,7 +14476,7 @@ static int patch_alc269(struct hda_codec *codec) } } - if (spec->cdefine.enable_pcbeep) { + if (has_cdefine_beep(codec)) { err = snd_hda_attach_beep_device(codec, 0x1); if (err < 0) { alc_free(codec); @@ -14498,7 +14514,7 @@ static int patch_alc269(struct hda_codec *codec) if (!spec->cap_mixer) set_capture_mixer(codec); - if (spec->cdefine.enable_pcbeep) + if (has_cdefine_beep(codec)) set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); if (board_config == ALC269_AUTO) @@ -18695,7 +18711,7 @@ static int patch_alc662(struct hda_codec *codec) } } - if (spec->cdefine.enable_pcbeep) { + if (has_cdefine_beep(codec)) { err = snd_hda_attach_beep_device(codec, 0x1); if (err < 0) { alc_free(codec); @@ -18722,7 +18738,7 @@ static int patch_alc662(struct hda_codec *codec) if (!spec->cap_mixer) set_capture_mixer(codec); - if (spec->cdefine.enable_pcbeep) { + if (has_cdefine_beep(codec)) { switch (codec->vendor_id) { case 0x10ec0662: set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); -- cgit v1.1 From 150b432f448281d5518f5229d240923f9a9c5459 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Thu, 29 Jul 2010 14:46:42 +0200 Subject: ALSA: hda - Rename iMic to Int Mic on Lenovo NB0763 The non-standard name "iMic" makes PulseAudio ignore the microphone. BugLink: https://launchpad.net/bugs/605101 Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 439d6e7..14ef383 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -7103,7 +7103,7 @@ static struct hda_input_mux alc883_lenovo_nb0763_capture_source = { .num_items = 4, .items = { { "Mic", 0x0 }, - { "iMic", 0x1 }, + { "Int Mic", 0x1 }, { "Line", 0x2 }, { "CD", 0x4 }, }, @@ -8673,8 +8673,8 @@ static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = { HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), - HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT), - HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT), + HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), + HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), { } /* end */ }; -- cgit v1.1 From 5aacc2186cc075880a9eca42e6b7f9bb3096d0ea Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jul 2010 10:36:29 +0200 Subject: ALSA: hda - Make error messages more verbose Add a prefix and more information for error messages regarding the connection-list in hda_codec.c. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index e5c3484..d9d1c91 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -396,15 +396,18 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, } for (n = prev_nid + 1; n <= val; n++) { if (conns >= max_conns) { - snd_printk(KERN_ERR - "Too many connections\n"); + snd_printk(KERN_ERR "hda_codec: " + "Too many connections %d for NID 0x%x\n", + conns, nid); return -EINVAL; } conn_list[conns++] = n; } } else { if (conns >= max_conns) { - snd_printk(KERN_ERR "Too many connections\n"); + snd_printk(KERN_ERR "hda_codec: " + "Too many connections %d for NID 0x%x\n", + conns, nid); return -EINVAL; } conn_list[conns++] = val; -- cgit v1.1 From ce503f38bdb59c9175a9076215a3ba579fad4e64 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jul 2010 10:37:29 +0200 Subject: ALSA: hda - Increase the connection list size for ALC662 Some ALC662-compatible codecs like ALC892 may have more than 4 connections for the input source. Use HDA_MAX_CONNECTIONS instead of the fixed magic number 4. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 14ef383..cf9f208 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -18657,7 +18657,7 @@ static void alc662_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t dac) { int i, num; - hda_nid_t srcs[4]; + hda_nid_t srcs[HDA_MAX_CONNECTIONS]; alc_set_pin_output(codec, nid, pin_type); /* need the manual connection? */ -- cgit v1.1 From 757899aceebc33d9f86bbc481be7b7bf861e89ac Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jul 2010 10:48:14 +0200 Subject: ALSA: hda - Share digital I/O parser in patch_realtek.c Make a helper function to parse the digital I/Os of all Realtek codecs to simplify the code and to ensure the setups. Also, initialize digital I/O pins properly in init callbacks. Some BIOS seem to leave pins uninitialized. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 140 +++++++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 62 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index cf9f208..442adef 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1541,6 +1541,63 @@ static int alc_read_coef_idx(struct hda_codec *codec, return val; } +/* set right pin controls for digital I/O */ +static void alc_auto_init_digital(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + int i; + hda_nid_t pin; + + for (i = 0; i < spec->autocfg.dig_outs; i++) { + pin = spec->autocfg.dig_out_pins[i]; + if (pin) { + snd_hda_codec_write(codec, pin, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, + PIN_OUT); + } + } + pin = spec->autocfg.dig_in_pin; + if (pin) + snd_hda_codec_write(codec, pin, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, + PIN_IN); +} + +/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ +static void alc_auto_parse_digital(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + int i, err; + hda_nid_t dig_nid; + + /* support multiple SPDIFs; the secondary is set up as a slave */ + for (i = 0; i < spec->autocfg.dig_outs; i++) { + err = snd_hda_get_connections(codec, + spec->autocfg.dig_out_pins[i], + &dig_nid, 1); + if (err < 0) + continue; + if (!i) { + spec->multiout.dig_out_nid = dig_nid; + spec->dig_out_type = spec->autocfg.dig_out_type[0]; + } else { + spec->multiout.slave_dig_outs = spec->slave_dig_outs; + if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1) + break; + spec->slave_dig_outs[i - 1] = dig_nid; + } + } + + if (spec->autocfg.dig_in_pin) { + hda_nid_t dig_nid; + err = snd_hda_get_connections(codec, + spec->autocfg.dig_in_pin, + &dig_nid, 1); + if (err > 0) + spec->dig_in_nid = dig_nid; + } +} + /* * ALC888 */ @@ -5013,7 +5070,7 @@ static void alc880_auto_init_input_src(struct hda_codec *codec) static int alc880_parse_auto_config(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; - int i, err; + int err; static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, @@ -5044,25 +5101,7 @@ static int alc880_parse_auto_config(struct hda_codec *codec) spec->multiout.max_channels = spec->multiout.num_dacs * 2; - /* check multiple SPDIF-out (for recent codecs) */ - for (i = 0; i < spec->autocfg.dig_outs; i++) { - hda_nid_t dig_nid; - err = snd_hda_get_connections(codec, - spec->autocfg.dig_out_pins[i], - &dig_nid, 1); - if (err < 0) - continue; - if (!i) - spec->multiout.dig_out_nid = dig_nid; - else { - spec->multiout.slave_dig_outs = spec->slave_dig_outs; - if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1) - break; - spec->slave_dig_outs[i - 1] = dig_nid; - } - } - if (spec->autocfg.dig_in_pin) - spec->dig_in_nid = ALC880_DIGIN_NID; + alc_auto_parse_digital(codec); if (spec->kctls.list) add_mixer(spec, spec->kctls.list); @@ -5085,6 +5124,7 @@ static void alc880_auto_init(struct hda_codec *codec) alc880_auto_init_extra_out(codec); alc880_auto_init_analog_input(codec); alc880_auto_init_input_src(codec); + alc_auto_init_digital(codec); if (spec->unsol_event) alc_inithook(codec); } @@ -6724,6 +6764,7 @@ static void alc260_auto_init(struct hda_codec *codec) alc260_auto_init_multi_out(codec); alc260_auto_init_analog_input(codec); alc260_auto_init_input_src(codec); + alc_auto_init_digital(codec); if (spec->unsol_event) alc_inithook(codec); } @@ -10546,7 +10587,7 @@ static int alc882_parse_auto_config(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; static hda_nid_t alc882_ignore[] = { 0x1d, 0 }; - int i, err; + int err; err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, alc882_ignore); @@ -10576,25 +10617,7 @@ static int alc882_parse_auto_config(struct hda_codec *codec) spec->multiout.max_channels = spec->multiout.num_dacs * 2; - /* check multiple SPDIF-out (for recent codecs) */ - for (i = 0; i < spec->autocfg.dig_outs; i++) { - hda_nid_t dig_nid; - err = snd_hda_get_connections(codec, - spec->autocfg.dig_out_pins[i], - &dig_nid, 1); - if (err < 0) - continue; - if (!i) - spec->multiout.dig_out_nid = dig_nid; - else { - spec->multiout.slave_dig_outs = spec->slave_dig_outs; - if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1) - break; - spec->slave_dig_outs[i - 1] = dig_nid; - } - } - if (spec->autocfg.dig_in_pin) - spec->dig_in_nid = ALC880_DIGIN_NID; + alc_auto_parse_digital(codec); if (spec->kctls.list) add_mixer(spec, spec->kctls.list); @@ -10624,6 +10647,7 @@ static void alc882_auto_init(struct hda_codec *codec) alc882_auto_init_hp_out(codec); alc882_auto_init_analog_input(codec); alc882_auto_init_input_src(codec); + alc_auto_init_digital(codec); if (spec->unsol_event) alc_inithook(codec); } @@ -12154,12 +12178,7 @@ static int alc262_parse_auto_config(struct hda_codec *codec) spec->multiout.max_channels = spec->multiout.num_dacs * 2; dig_only: - if (spec->autocfg.dig_outs) { - spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; - spec->dig_out_type = spec->autocfg.dig_out_type[0]; - } - if (spec->autocfg.dig_in_pin) - spec->dig_in_nid = ALC262_DIGIN_NID; + alc_auto_parse_digital(codec); if (spec->kctls.list) add_mixer(spec, spec->kctls.list); @@ -12191,6 +12210,7 @@ static void alc262_auto_init(struct hda_codec *codec) alc262_auto_init_hp_out(codec); alc262_auto_init_analog_input(codec); alc262_auto_init_input_src(codec); + alc_auto_init_digital(codec); if (spec->unsol_event) alc_inithook(codec); } @@ -13327,10 +13347,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec) dig_only: /* digital only support output */ - if (spec->autocfg.dig_outs) { - spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; - spec->dig_out_type = spec->autocfg.dig_out_type[0]; - } + alc_auto_parse_digital(codec); if (spec->kctls.list) add_mixer(spec, spec->kctls.list); @@ -13360,6 +13377,7 @@ static void alc268_auto_init(struct hda_codec *codec) alc268_auto_init_hp_out(codec); alc268_auto_init_mono_speaker_out(codec); alc268_auto_init_analog_input(codec); + alc_auto_init_digital(codec); if (spec->unsol_event) alc_inithook(codec); } @@ -14305,8 +14323,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec) spec->multiout.max_channels = spec->multiout.num_dacs * 2; - if (spec->autocfg.dig_outs) - spec->multiout.dig_out_nid = ALC269_DIGOUT_NID; + alc_auto_parse_digital(codec); if (spec->kctls.list) add_mixer(spec, spec->kctls.list); @@ -14354,6 +14371,7 @@ static void alc269_auto_init(struct hda_codec *codec) alc269_auto_init_multi_out(codec); alc269_auto_init_hp_out(codec); alc269_auto_init_analog_input(codec); + alc_auto_init_digital(codec); if (spec->unsol_event) alc_inithook(codec); } @@ -15515,8 +15533,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec) spec->multiout.max_channels = spec->multiout.num_dacs * 2; - if (spec->autocfg.dig_outs) - spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; + alc_auto_parse_digital(codec); if (spec->kctls.list) add_mixer(spec, spec->kctls.list); @@ -15542,6 +15559,7 @@ static void alc861_auto_init(struct hda_codec *codec) alc861_auto_init_multi_out(codec); alc861_auto_init_hp_out(codec); alc861_auto_init_analog_input(codec); + alc_auto_init_digital(codec); if (spec->unsol_event) alc_inithook(codec); } @@ -16646,8 +16664,7 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec) spec->multiout.max_channels = spec->multiout.num_dacs * 2; - if (spec->autocfg.dig_outs) - spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; + alc_auto_parse_digital(codec); if (spec->kctls.list) add_mixer(spec, spec->kctls.list); @@ -16674,6 +16691,7 @@ static void alc861vd_auto_init(struct hda_codec *codec) alc861vd_auto_init_hp_out(codec); alc861vd_auto_init_analog_input(codec); alc861vd_auto_init_input_src(codec); + alc_auto_init_digital(codec); if (spec->unsol_event) alc_inithook(codec); } @@ -18761,8 +18779,7 @@ static int alc662_parse_auto_config(struct hda_codec *codec) spec->multiout.max_channels = spec->multiout.num_dacs * 2; - if (spec->autocfg.dig_outs) - spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; + alc_auto_parse_digital(codec); if (spec->kctls.list) add_mixer(spec, spec->kctls.list); @@ -18799,6 +18816,7 @@ static void alc662_auto_init(struct hda_codec *codec) alc662_auto_init_hp_out(codec); alc662_auto_init_analog_input(codec); alc662_auto_init_input_src(codec); + alc_auto_init_digital(codec); if (spec->unsol_event) alc_inithook(codec); } @@ -19124,10 +19142,7 @@ static int alc680_parse_auto_config(struct hda_codec *codec) dig_only: /* digital only support output */ - if (spec->autocfg.dig_outs) { - spec->multiout.dig_out_nid = ALC680_DIGOUT_NID; - spec->dig_out_type = spec->autocfg.dig_out_type[0]; - } + alc_auto_parse_digital(codec); if (spec->kctls.list) add_mixer(spec, spec->kctls.list); @@ -19151,6 +19166,7 @@ static void alc680_auto_init(struct hda_codec *codec) alc680_auto_init_multi_out(codec); alc680_auto_init_hp_out(codec); alc680_auto_init_analog_input(codec); + alc_auto_init_digital(codec); if (spec->unsol_event) alc_inithook(codec); } -- cgit v1.1 From 5d4abf93ea3192cc666430225a29a4978c97c57d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jul 2010 10:51:10 +0200 Subject: ALSA: hda - Handle missing NID 0x1b on ALC259 codec Since ALC259/269 use the same parser of ALC268, the pin 0x1b was ignored as an invalid widget. Just add this NID to handle properly. This will add the missing mixer controls for some devices. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 442adef..bdea95ae 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -13144,6 +13144,7 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, dac = 0x02; break; case 0x15: + case 0x1b: case 0x21: /* ALC269vb has this pin, too */ dac = 0x03; break; -- cgit v1.1 From 954a29c881bd0c61352af0946f2c39d738d43c1b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jul 2010 10:55:44 +0200 Subject: ALSA: hda - Prefer VREF50 if BIOS sets for Realtek codecs If BIOS sets up the input pin as VREF 50, use the value as is instead of overriding forcibly to VREF 80. This fixes the quality of inputs on some devices like Packard-Bell M5210. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index bdea95ae..4d3a6f0 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -847,9 +847,13 @@ static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, if (auto_pin_type <= AUTO_PIN_FRONT_MIC) { unsigned int pincap; + unsigned int oldval; + oldval = snd_hda_codec_read(codec, nid, 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, 0); pincap = snd_hda_query_pin_caps(codec, nid); pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; - if (pincap & AC_PINCAP_VREF_80) + /* if the default pin setup is vref50, we give it priority */ + if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50) val = PIN_VREF80; else if (pincap & AC_PINCAP_VREF_50) val = PIN_VREF50; @@ -10406,7 +10410,8 @@ static struct alc_config_preset alc882_presets[] = { * Pin config fixes */ enum { - PINFIX_ABIT_AW9D_MAX + PINFIX_ABIT_AW9D_MAX, + PINFIX_PB_M5210, }; static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { @@ -10416,13 +10421,22 @@ static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { { } }; +static const struct hda_verb pb_m5210_verbs[] = { + { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, + {} +}; + static const struct alc_fixup alc882_fixups[] = { [PINFIX_ABIT_AW9D_MAX] = { .pins = alc882_abit_aw9d_pinfix }, + [PINFIX_PB_M5210] = { + .verbs = pb_m5210_verbs + }, }; static struct snd_pci_quirk alc882_fixup_tbl[] = { + SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210), SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), {} }; -- cgit v1.1 From 697c373e34613609cb5450f98b91fefb6e910588 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jul 2010 11:28:02 +0200 Subject: ALSA: hda - Shut up pins at power-saving mode with Conexnat codecs Call snd_hda_shutup_pins() for power-saving and reboot-notifier in patch_conexant.c as well as other codecs. This will reduce the pop noise in power-save mode. Reference: bnc#624896 https://bugzilla.novell.com/show_bug.cgi?id=624896 Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index c99425a..d6341f3 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -611,11 +611,23 @@ static int conexant_build_controls(struct hda_codec *codec) return 0; } +#ifdef CONFIG_SND_HDA_POWER_SAVE +static int conexant_suspend(struct hda_codec *codec, pm_message_t state) +{ + snd_hda_shutup_pins(codec); + return 0; +} +#endif + static struct hda_codec_ops conexant_patch_ops = { .build_controls = conexant_build_controls, .build_pcms = conexant_build_pcms, .init = conexant_init, .free = conexant_free, +#ifdef CONFIG_SND_HDA_POWER_SAVE + .suspend = conexant_suspend, +#endif + .reboot_notify = snd_hda_shutup_pins, }; #ifdef CONFIG_SND_HDA_INPUT_BEEP -- cgit v1.1 From b08b1637ce1c0196970348bcabf40f04b6b3d58e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jul 2010 14:08:25 +0200 Subject: ALSA: hda - Handle pin NID 0x1a on ALC259/269 The pin NID 0x1a should be handled as well as NID 0x1b. Also added comments. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 4d3a6f0..ce6c3a9 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -13158,7 +13158,8 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, dac = 0x02; break; case 0x15: - case 0x1b: + case 0x1a: /* ALC259/269 only */ + case 0x1b: /* ALC259/269 only */ case 0x21: /* ALC269vb has this pin, too */ dac = 0x03; break; -- cgit v1.1 From c7a9434dd6ea74464b0419a274463c914197bc98 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 30 Jul 2010 14:10:43 +0200 Subject: ALSA: hda - Add a warning for ignored pins with ALC259/268/269 The current ALC259/268/269 parser ignores some pins as unhandled, but user won't notice what goes wrong. So, added a warning message for the ignored pins as a hint. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index ce6c3a9..49c04fc 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -13164,6 +13164,8 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid, dac = 0x03; break; default: + snd_printd(KERN_WARNING "hda_codec: " + "ignoring pin 0x%x as unknown\n", nid); return 0; } if (spec->multiout.dac_nids[0] != dac && -- cgit v1.1 From ac8b422838046ffc26be4874a3cbae0d313f4209 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Wed, 21 Jul 2010 22:38:13 +0200 Subject: pcmcia: remove cs_types.h Remove cs_types.h which is no longer needed: Most definitions aren't used at all, a few can be made away with, and two remaining definitions (typedefs, unfortunatley) may be moved to more specific places. CC: linux-ide@vger.kernel.org CC: linux-usb@vger.kernel.org CC: laforge@gnumonks.org CC: linux-mtd@lists.infradead.org CC: alsa-devel@alsa-project.org CC: linux-serial@vger.kernel.org Acked-by: Marcel Holtmann (for drivers/bluetooth/) Acked-by: David S. Miller Signed-off-by: Dominik Brodowski --- sound/pcmcia/pdaudiocf/pdaudiocf.h | 1 - sound/pcmcia/vx/vxpocket.h | 1 - 2 files changed, 2 deletions(-) (limited to 'sound') diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.h b/sound/pcmcia/pdaudiocf/pdaudiocf.h index a0a7ec6..5cc3e45 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.h +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/sound/pcmcia/vx/vxpocket.h b/sound/pcmcia/vx/vxpocket.h index ea4df16..d911066 100644 --- a/sound/pcmcia/vx/vxpocket.h +++ b/sound/pcmcia/vx/vxpocket.h @@ -23,7 +23,6 @@ #include -#include #include #include #include -- cgit v1.1 From dd2f8c2f811b14f97a572edb0da4cfe776e20052 Mon Sep 17 00:00:00 2001 From: John S Gruber Date: Sun, 1 Aug 2010 09:53:37 -0400 Subject: ALSA: usb - Correct audio problem for Hauppage HVR-850 and others rel. to urb data align Match usb ids in usb/quirks-table.h for some Hauppage HVR-950Q models and for the HVR850 model to those ids at the end of au0828-cards.c Thanks to nhJm449 for pointing out the problem. Signed-off-by: John S Gruber Signed-off-by: Takashi Iwai --- sound/usb/quirks-table.h | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'sound') diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h index f8797f6..2e8003f 100644 --- a/sound/usb/quirks-table.h +++ b/sound/usb/quirks-table.h @@ -2152,7 +2152,21 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - USB_DEVICE_VENDOR_SPEC(0x2040, 0x7201), + USB_DEVICE_VENDOR_SPEC(0x2040, 0x7240), + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | + USB_DEVICE_ID_MATCH_INT_CLASS | + USB_DEVICE_ID_MATCH_INT_SUBCLASS, + .bInterfaceClass = USB_CLASS_AUDIO, + .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, + .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { + .vendor_name = "Hauppauge", + .product_name = "HVR-850", + .ifnum = QUIRK_ANY_INTERFACE, + .type = QUIRK_AUDIO_ALIGN_TRANSFER, + } +}, +{ + USB_DEVICE_VENDOR_SPEC(0x2040, 0x7210), .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS, @@ -2166,7 +2180,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - USB_DEVICE_VENDOR_SPEC(0x2040, 0x7202), + USB_DEVICE_VENDOR_SPEC(0x2040, 0x7217), .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS, @@ -2180,7 +2194,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - USB_DEVICE_VENDOR_SPEC(0x2040, 0x7203), + USB_DEVICE_VENDOR_SPEC(0x2040, 0x721b), .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS, @@ -2194,7 +2208,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - USB_DEVICE_VENDOR_SPEC(0x2040, 0x7204), + USB_DEVICE_VENDOR_SPEC(0x2040, 0x721e), .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS, @@ -2208,7 +2222,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - USB_DEVICE_VENDOR_SPEC(0x2040, 0x7205), + USB_DEVICE_VENDOR_SPEC(0x2040, 0x721f), .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS, @@ -2222,7 +2236,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - USB_DEVICE_VENDOR_SPEC(0x2040, 0x7250), + USB_DEVICE_VENDOR_SPEC(0x2040, 0x7280), .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS, @@ -2236,7 +2250,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), } }, { - USB_DEVICE_VENDOR_SPEC(0x2040, 0x7230), + USB_DEVICE_VENDOR_SPEC(0x0fd9, 0x0008), .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS, @@ -2244,7 +2258,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { .vendor_name = "Hauppauge", - .product_name = "HVR-850", + .product_name = "HVR-950Q", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_AUDIO_ALIGN_TRANSFER, } -- cgit v1.1 From 7bfb9c031ec2d220d48bf679553d6177c2e66625 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Mon, 2 Aug 2010 13:13:25 +0200 Subject: ALSA: hda - Do not try to create speaker NIDs for ALC268 if there aren't any Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 49c04fc..cf14b00 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -13216,7 +13216,7 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec, HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); if (err < 0) return err; - } else { + } else if (nid) { err = alc268_new_analog_output(spec, nid, "Speaker", 0); if (err < 0) return err; -- cgit v1.1 From 607bc3e4888443cdd21a795f7312f64c2de26b5c Mon Sep 17 00:00:00 2001 From: Jerone Young Date: Tue, 3 Aug 2010 01:46:42 -0500 Subject: ALSA: hda - FIX to not expose SPDIF on Thinkpad X301, since it does not have the ability to use SPDIF The Lenovo X301 does not have the ability to connect to a docking station to use the SPDIF port. It also does not have the ability to do SPDIF though the headphone jack or Display Port jacks. This patch fixes it so this is not exposed for the X301 and users do think it has the ability to do SPDIF. I tested both headphone & display port jacks and it is not there. I have tested this patch and it works great. Also to add the other Thinkpads have different subsystem codec IDs. Here are examples: X301: http://launchpadlibrarian.net/31561902/Card0.Codecs.codec.0.txt X200: http://launchpadlibrarian.net/49055036/Card0.Codecs.codec.0.txt W500: http://launchpadlibrarian.net/36276057/Card0.Codecs.codec.0.txt Signed-off-by: Jerone Young Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index d6341f3..df8b19b 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -2057,6 +2057,10 @@ static int patch_cxt5051(struct hda_codec *codec) break; case CXT5051_LENOVO_X200: spec->init_verbs[0] = cxt5051_lenovo_x200_init_verbs; + /* Thinkpad X301 does not have S/PDIF wired and no ability + to use a docking station. */ + if (codec->subsystem_id == 0x17aa211f) + spec->multiout.dig_out_nid = 0; break; case CXT5051_F700: spec->init_verbs[0] = cxt5051_f700_init_verbs; -- cgit v1.1 From 68c18697910fdcacea36bd58d2d3d8febfa199a2 Mon Sep 17 00:00:00 2001 From: Jerone Young Date: Tue, 3 Aug 2010 01:46:44 -0500 Subject: ALSA: hda - Fix Thinkpad X300 so SPDIF is not exposed Just as with the X301. The X300 does not have a way to do SPDIF either. It does not have a dock connector, nor does it have the SPDIF through the headphone jack. This patch fixes it so X300 does not show SPDIF, since it cannot do it. To add all Lenovo Thinkpads had different codec subsytem IDs: X300: http://launchpadlibrarian.net/34862838/Card0.Codecs.codec.0.txt Signed-off-by: Jerone Young Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_analog.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index afbe314..b697fd2 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -3662,7 +3662,12 @@ static int patch_ad1984(struct hda_codec *codec) codec->patch_ops.build_pcms = ad1984_build_pcms; break; case AD1984_THINKPAD: - spec->multiout.dig_out_nid = AD1884_SPDIF_OUT; + if (codec->subsystem_id == 0x17aa20fb) { + /* Thinpad X300 does not have the ability to do SPDIF, + or attach to docking station to use SPDIF */ + spec->multiout.dig_out_nid = 0; + } else + spec->multiout.dig_out_nid = AD1884_SPDIF_OUT; spec->input_mux = &ad1984_thinkpad_capture_source; spec->mixers[0] = ad1984_thinkpad_mixers; spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs; -- cgit v1.1 From 9a017a910346afd88ec2e065989903bf211a7d37 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sat, 24 Jul 2010 15:58:54 +0200 Subject: pcmcia: do not use io_req_t after call to pcmcia_request_io() After pcmcia_request_io(), do not make use of the values stored in io_req_t, but instead use those found in struct pcmcia_device->resource[]. CC: netdev@vger.kernel.org CC: linux-wireless@vger.kernel.org CC: linux-ide@vger.kernel.org CC: linux-usb@vger.kernel.org CC: laforge@gnumonks.org CC: linux-mtd@lists.infradead.org CC: alsa-devel@alsa-project.org CC: linux-serial@vger.kernel.org Acked-by: Marcel Holtmann (for drivers/bluetooth/) Signed-off-by: Dominik Brodowski --- sound/pcmcia/pdaudiocf/pdaudiocf.c | 3 ++- sound/pcmcia/vx/vxpocket.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index df110df..9f897bc 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c @@ -231,7 +231,8 @@ static int pdacf_config(struct pcmcia_device *link) if (ret) goto failed; - if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq) < 0) + if (snd_pdacf_assign_resources(pdacf, link->resource[0]->start, + link->irq) < 0) goto failed; return 0; diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index 624b47a..f23c235 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -241,7 +241,8 @@ static int vxpocket_config(struct pcmcia_device *link) chip->dev = &link->dev; snd_card_set_dev(chip->card, chip->dev); - if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq) < 0) + if (snd_vxpocket_assign_resources(chip, link->resource[0]->start, + link->irq) < 0) goto failed; return 0; -- cgit v1.1 From 90abdc3b973229bae98dd96649d9f7106cc177a4 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sat, 24 Jul 2010 17:23:51 +0200 Subject: pcmcia: do not use io_req_t when calling pcmcia_request_io() Instead of io_req_t, drivers are now requested to fill out struct pcmcia_device *p_dev->resource[0,1] for up to two ioport ranges. After a call to pcmcia_request_io(), the ports found there are reserved, after calling pcmcia_request_configuration(), they may be used. CC: netdev@vger.kernel.org CC: linux-wireless@vger.kernel.org CC: linux-ide@vger.kernel.org CC: linux-usb@vger.kernel.org CC: laforge@gnumonks.org CC: linux-mtd@lists.infradead.org CC: alsa-devel@alsa-project.org CC: linux-serial@vger.kernel.org CC: Michael Buesch Acked-by: Marcel Holtmann (for drivers/bluetooth/) Signed-off-by: Dominik Brodowski --- sound/pcmcia/pdaudiocf/pdaudiocf.c | 6 +++--- sound/pcmcia/vx/vxpocket.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index 9f897bc..7ab9174 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c @@ -139,8 +139,8 @@ static int snd_pdacf_probe(struct pcmcia_device *link) pdacf->p_dev = link; link->priv = pdacf; - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; - link->io.NumPorts1 = 16; + link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; + link->resource[0]->end = 16; link->conf.Attributes = CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ; link->conf.IntType = INT_MEMORY_AND_IO; @@ -219,7 +219,7 @@ static int pdacf_config(struct pcmcia_device *link) snd_printdd(KERN_DEBUG "pdacf_config called\n"); link->conf.ConfigIndex = 0x5; - ret = pcmcia_request_io(link, &link->io); + ret = pcmcia_request_io(link); if (ret) goto failed; diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index f23c235..a6edfc3 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -159,8 +159,8 @@ static int snd_vxpocket_new(struct snd_card *card, int ibl, vxp->p_dev = link; link->priv = chip; - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; - link->io.NumPorts1 = 16; + link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; + link->resource[0]->end = 16; link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.IntType = INT_MEMORY_AND_IO; @@ -226,7 +226,7 @@ static int vxpocket_config(struct pcmcia_device *link) strcpy(chip->card->driver, vxp440_hw.name); } - ret = pcmcia_request_io(link, &link->io); + ret = pcmcia_request_io(link); if (ret) goto failed; -- cgit v1.1 From 32c168c892e2c6936c714d1653ba5e19e07d5c26 Mon Sep 17 00:00:00 2001 From: Anssi Hannula Date: Tue, 3 Aug 2010 13:28:57 +0300 Subject: ALSA: hda - Set Stream Type in Stream Format according to AES0 Set bit 15 (Stream Type) of HDA Stream Format to 1 (Non-PCM) when IEC958 channel status bit 1 (AES0 & 0x02) is set to 1 (non-audio). This is a prequisite for HDMI HBR passthrough. Signed-off-by: Anssi Hannula Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 6 +++++- sound/pci/hda/hda_codec.h | 3 ++- sound/pci/hda/hda_intel.c | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index d9d1c91..bd8d7a6 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3051,7 +3051,8 @@ static struct hda_rate_tbl rate_bits[] = { unsigned int snd_hda_calc_stream_format(unsigned int rate, unsigned int channels, unsigned int format, - unsigned int maxbps) + unsigned int maxbps, + unsigned short spdif_ctls) { int i; unsigned int val = 0; @@ -3095,6 +3096,9 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate, return 0; } + if (spdif_ctls & AC_DIG1_NONAUDIO) + val |= 0x8000; + return val; } EXPORT_SYMBOL_HDA(snd_hda_calc_stream_format); diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 5991d14..4797416 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -928,7 +928,8 @@ void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid); unsigned int snd_hda_calc_stream_format(unsigned int rate, unsigned int channels, unsigned int format, - unsigned int maxbps); + unsigned int maxbps, + unsigned short spdif_ctls); int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid, unsigned int format); diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 1df25cf..f8a2f5a 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1653,7 +1653,8 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) format_val = snd_hda_calc_stream_format(runtime->rate, runtime->channels, runtime->format, - hinfo->maxbps); + hinfo->maxbps, + apcm->codec->spdif_ctls); if (!format_val) { snd_printk(KERN_ERR SFX "invalid format_val, rate=%d, ch=%d, format=%d\n", -- cgit v1.1 From ea87d1c493aba9cf3f645eae0d6d9c0fd44d3189 Mon Sep 17 00:00:00 2001 From: Anssi Hannula Date: Tue, 3 Aug 2010 13:28:58 +0300 Subject: ALSA: hda - Add support for HDMI HBR passthrough Passing IEC 61937 encapsulated compressed audio at bitrates over 6.144 Mbps (i.e. more than a single 2-channel 16-bit 192kHz IEC 60958 link) over HDMI requires the use of HBR Audio Stream Packets instead of Audio Sample Packets. Enable HBR mode when the stream has 8 channels and the Non-PCM bit is set. If the audio converter is not connected to any HBR-capable pins, return -EINVAL in prepare(). Signed-off-by: Anssi Hannula Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.h | 3 +++ sound/pci/hda/patch_hdmi.c | 40 +++++++++++++++++++++++++++++++++++++++- sound/pci/hda/patch_intelhdmi.c | 3 +-- sound/pci/hda/patch_nvhdmi.c | 3 +-- 4 files changed, 44 insertions(+), 5 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 4797416..48b3367 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -364,6 +364,9 @@ enum { #define AC_DIG2_CC (0x7f<<0) /* Pin widget control - 8bit */ +#define AC_PINCTL_EPT (0x3<<0) +#define AC_PINCTL_EPT_NATIVE 0 +#define AC_PINCTL_EPT_HBR 3 #define AC_PINCTL_VREFEN (0x7<<0) #define AC_PINCTL_VREF_HIZ 0 /* Hi-Z */ #define AC_PINCTL_VREF_50 1 /* 50% */ diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 2fc5396..8534792 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -698,11 +698,48 @@ static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) * Callbacks */ -static void hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, +static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, int format) { + struct hdmi_spec *spec = codec->spec; int tag; int fmt; + int pinctl; + int new_pinctl = 0; + int i; + + for (i = 0; i < spec->num_pins; i++) { + if (spec->pin_cvt[i] != nid) + continue; + if (!(snd_hda_query_pin_caps(codec, spec->pin[i]) & AC_PINCAP_HBR)) + continue; + + pinctl = snd_hda_codec_read(codec, spec->pin[i], 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, 0); + + new_pinctl = pinctl & ~AC_PINCTL_EPT; + /* Non-PCM, 8 channels */ + if ((format & 0x8000) && (format & 0x0f) == 7) + new_pinctl |= AC_PINCTL_EPT_HBR; + else + new_pinctl |= AC_PINCTL_EPT_NATIVE; + + snd_printdd("hdmi_setup_stream: " + "NID=0x%x, %spinctl=0x%x\n", + spec->pin[i], + pinctl == new_pinctl ? "" : "new-", + new_pinctl); + + if (pinctl != new_pinctl) + snd_hda_codec_write(codec, spec->pin[i], 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, + new_pinctl); + } + + if ((format & 0x8000) && (format & 0x0f) == 7 && !new_pinctl) { + snd_printdd("hdmi_setup_stream: HBR is not supported\n"); + return -EINVAL; + } tag = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0) >> 4; fmt = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_STREAM_FORMAT, 0); @@ -722,6 +759,7 @@ static void hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, if (fmt != format) snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format); + return 0; } /* diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c index b81d23e..5972d5e 100644 --- a/sound/pci/hda/patch_intelhdmi.c +++ b/sound/pci/hda/patch_intelhdmi.c @@ -66,8 +66,7 @@ static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, hdmi_setup_audio_infoframe(codec, hinfo->nid, substream); - hdmi_setup_stream(codec, hinfo->nid, stream_tag, format); - return 0; + return hdmi_setup_stream(codec, hinfo->nid, stream_tag, format); } static int intel_hdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c index b0652ac..a281836 100644 --- a/sound/pci/hda/patch_nvhdmi.c +++ b/sound/pci/hda/patch_nvhdmi.c @@ -202,8 +202,7 @@ static int nvhdmi_dig_playback_pcm_prepare_8ch_89(struct hda_pcm_stream *hinfo, hdmi_setup_audio_infoframe(codec, hinfo->nid, substream); - hdmi_setup_stream(codec, hinfo->nid, stream_tag, format); - return 0; + return hdmi_setup_stream(codec, hinfo->nid, stream_tag, format); } static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream *hinfo, -- cgit v1.1 From 1b0e372d7b52c9fc96348779015a6db7df7f286e Mon Sep 17 00:00:00 2001 From: Daniel J Blueman Date: Tue, 3 Aug 2010 11:09:13 +0100 Subject: ALSA: hda - Fix beep frequency on IDT 92HD73xx and 92HD71Bxx codecs Fix HDA beep frequency on IDT 92HD73xx and 92HD71Bxx codecs. These codecs use the standard beep frequency calculation although the datasheet says it's linear frequency. Other IDT/STAC codecs might have the same problem. They should be fixed individually later. Signed-off-by: Daniel J Blueman Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_sigmatel.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index f1e7bab..b8d730c 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -202,6 +202,7 @@ struct sigmatel_spec { unsigned int spdif_mute: 1; unsigned int check_volume_offset:1; unsigned int auto_mic:1; + unsigned int linear_tone_beep:1; /* gpio lines */ unsigned int eapd_mask; @@ -3802,7 +3803,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out return err; if (codec->beep) { /* IDT/STAC codecs have linear beep tone parameter */ - codec->beep->linear_tone = 1; + codec->beep->linear_tone = spec->linear_tone_beep; /* if no beep switch is available, make its own one */ caps = query_amp_caps(codec, nid, HDA_OUTPUT); if (!(caps & AC_AMPCAP_MUTE)) { @@ -5005,6 +5006,7 @@ static int patch_stac9200(struct hda_codec *codec) codec->no_trigger_sense = 1; codec->spec = spec; + spec->linear_tone_beep = 1; spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); spec->pin_nids = stac9200_pin_nids; spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, @@ -5068,6 +5070,7 @@ static int patch_stac925x(struct hda_codec *codec) codec->no_trigger_sense = 1; codec->spec = spec; + spec->linear_tone_beep = 1; spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); spec->pin_nids = stac925x_pin_nids; @@ -5153,6 +5156,7 @@ static int patch_stac92hd73xx(struct hda_codec *codec) codec->no_trigger_sense = 1; codec->spec = spec; + spec->linear_tone_beep = 0; codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); spec->pin_nids = stac92hd73xx_pin_nids; @@ -5300,6 +5304,7 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) codec->no_trigger_sense = 1; codec->spec = spec; + spec->linear_tone_beep = 1; codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; spec->digbeep_nid = 0x21; spec->mux_nids = stac92hd83xxx_mux_nids; @@ -5522,6 +5527,7 @@ static int patch_stac92hd71bxx(struct hda_codec *codec) codec->no_trigger_sense = 1; codec->spec = spec; + spec->linear_tone_beep = 0; codec->patch_ops = stac92xx_patch_ops; spec->num_pins = STAC92HD71BXX_NUM_PINS; switch (codec->vendor_id) { @@ -5779,6 +5785,7 @@ static int patch_stac922x(struct hda_codec *codec) codec->no_trigger_sense = 1; codec->spec = spec; + spec->linear_tone_beep = 1; spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); spec->pin_nids = stac922x_pin_nids; spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, @@ -5883,6 +5890,7 @@ static int patch_stac927x(struct hda_codec *codec) codec->no_trigger_sense = 1; codec->spec = spec; + spec->linear_tone_beep = 1; codec->slave_dig_outs = stac927x_slave_dig_outs; spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); spec->pin_nids = stac927x_pin_nids; @@ -6018,6 +6026,7 @@ static int patch_stac9205(struct hda_codec *codec) codec->no_trigger_sense = 1; codec->spec = spec; + spec->linear_tone_beep = 1; spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); spec->pin_nids = stac9205_pin_nids; spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, @@ -6174,6 +6183,7 @@ static int patch_stac9872(struct hda_codec *codec) return -ENOMEM; codec->no_trigger_sense = 1; codec->spec = spec; + spec->linear_tone_beep = 1; spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); spec->pin_nids = stac9872_pin_nids; -- cgit v1.1 From 92f10b3f5d53f9e35da5285eb8ea4bc88082b71e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 3 Aug 2010 14:21:00 +0200 Subject: ALSA: hda - Define AC_FMT_* constants Define constants for the HD-audio stream format bits, and replace the magic numbers in codes. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 41 +++++++++++++++++++++++------------------ sound/pci/hda/hda_codec.h | 21 +++++++++++++++++++++ sound/pci/hda/patch_hdmi.c | 9 ++++++--- 3 files changed, 50 insertions(+), 21 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index bd8d7a6..05e8995 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3013,26 +3013,31 @@ struct hda_rate_tbl { unsigned int hda_fmt; }; +/* rate = base * mult / div */ +#define HDA_RATE(base, mult, div) \ + (AC_FMT_BASE_##base##K | (((mult) - 1) << AC_FMT_MULT_SHIFT) | \ + (((div) - 1) << AC_FMT_DIV_SHIFT)) + static struct hda_rate_tbl rate_bits[] = { /* rate in Hz, ALSA rate bitmask, HDA format value */ /* autodetected value used in snd_hda_query_supported_pcm */ - { 8000, SNDRV_PCM_RATE_8000, 0x0500 }, /* 1/6 x 48 */ - { 11025, SNDRV_PCM_RATE_11025, 0x4300 }, /* 1/4 x 44 */ - { 16000, SNDRV_PCM_RATE_16000, 0x0200 }, /* 1/3 x 48 */ - { 22050, SNDRV_PCM_RATE_22050, 0x4100 }, /* 1/2 x 44 */ - { 32000, SNDRV_PCM_RATE_32000, 0x0a00 }, /* 2/3 x 48 */ - { 44100, SNDRV_PCM_RATE_44100, 0x4000 }, /* 44 */ - { 48000, SNDRV_PCM_RATE_48000, 0x0000 }, /* 48 */ - { 88200, SNDRV_PCM_RATE_88200, 0x4800 }, /* 2 x 44 */ - { 96000, SNDRV_PCM_RATE_96000, 0x0800 }, /* 2 x 48 */ - { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */ - { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */ + { 8000, SNDRV_PCM_RATE_8000, HDA_RATE(48, 1, 6) }, + { 11025, SNDRV_PCM_RATE_11025, HDA_RATE(44, 1, 4) }, + { 16000, SNDRV_PCM_RATE_16000, HDA_RATE(48, 1, 3) }, + { 22050, SNDRV_PCM_RATE_22050, HDA_RATE(44, 1, 2) }, + { 32000, SNDRV_PCM_RATE_32000, HDA_RATE(48, 2, 3) }, + { 44100, SNDRV_PCM_RATE_44100, HDA_RATE(44, 1, 1) }, + { 48000, SNDRV_PCM_RATE_48000, HDA_RATE(48, 1, 1) }, + { 88200, SNDRV_PCM_RATE_88200, HDA_RATE(44, 2, 1) }, + { 96000, SNDRV_PCM_RATE_96000, HDA_RATE(48, 2, 1) }, + { 176400, SNDRV_PCM_RATE_176400, HDA_RATE(44, 4, 1) }, + { 192000, SNDRV_PCM_RATE_192000, HDA_RATE(48, 4, 1) }, #define AC_PAR_PCM_RATE_BITS 11 /* up to bits 10, 384kHZ isn't supported properly */ /* not autodetected value */ - { 9600, SNDRV_PCM_RATE_KNOT, 0x0400 }, /* 1/5 x 48 */ + { 9600, SNDRV_PCM_RATE_KNOT, HDA_RATE(48, 1, 5) }, { 0 } /* terminator */ }; @@ -3075,20 +3080,20 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate, switch (snd_pcm_format_width(format)) { case 8: - val |= 0x00; + val |= AC_FMT_BITS_8; break; case 16: - val |= 0x10; + val |= AC_FMT_BITS_16; break; case 20: case 24: case 32: if (maxbps >= 32 || format == SNDRV_PCM_FORMAT_FLOAT_LE) - val |= 0x40; + val |= AC_FMT_BITS_32; else if (maxbps >= 24) - val |= 0x30; + val |= AC_FMT_BITS_24; else - val |= 0x20; + val |= AC_FMT_BITS_20; break; default: snd_printdd("invalid format width %d\n", @@ -3097,7 +3102,7 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate, } if (spdif_ctls & AC_DIG1_NONAUDIO) - val |= 0x8000; + val |= AC_FMT_TYPE_NON_PCM; return val; } diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 48b3367..46f75bc 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -224,6 +224,27 @@ enum { /* Input converter SDI select */ #define AC_SDI_SELECT (0xf<<0) +/* stream format id */ +#define AC_FMT_CHAN_SHIFT 0 +#define AC_FMT_CHAN_MASK (0x0f << 0) +#define AC_FMT_BITS_SHIFT 4 +#define AC_FMT_BITS_MASK (7 << 4) +#define AC_FMT_BITS_8 (0 << 4) +#define AC_FMT_BITS_16 (1 << 4) +#define AC_FMT_BITS_20 (2 << 4) +#define AC_FMT_BITS_24 (3 << 4) +#define AC_FMT_BITS_32 (4 << 4) +#define AC_FMT_DIV_SHIFT 8 +#define AC_FMT_DIV_MASK (7 << 8) +#define AC_FMT_MULT_SHIFT 11 +#define AC_FMT_MULT_MASK (7 << 11) +#define AC_FMT_BASE_SHIFT 14 +#define AC_FMT_BASE_48K (0 << 14) +#define AC_FMT_BASE_44K (1 << 14) +#define AC_FMT_TYPE_SHIFT 15 +#define AC_FMT_TYPE_PCM (0 << 15) +#define AC_FMT_TYPE_NON_PCM (1 << 15) + /* Unsolicited response control */ #define AC_UNSOL_TAG (0x3f<<0) #define AC_UNSOL_ENABLED (1<<7) diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 8534792..522e074 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -698,6 +698,10 @@ static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) * Callbacks */ +/* HBR should be Non-PCM, 8 channels */ +#define is_hbr_format(format) \ + ((format & AC_FMT_TYPE_NON_PCM) && (format & AC_FMT_CHAN_MASK) == 7) + static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, int format) { @@ -718,8 +722,7 @@ static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); new_pinctl = pinctl & ~AC_PINCTL_EPT; - /* Non-PCM, 8 channels */ - if ((format & 0x8000) && (format & 0x0f) == 7) + if (is_hbr_format(format)) new_pinctl |= AC_PINCTL_EPT_HBR; else new_pinctl |= AC_PINCTL_EPT_NATIVE; @@ -736,7 +739,7 @@ static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, new_pinctl); } - if ((format & 0x8000) && (format & 0x0f) == 7 && !new_pinctl) { + if (is_hbr_format(format) && !new_pinctl) { snd_printdd("hdmi_setup_stream: HBR is not supported\n"); return -EINVAL; } -- cgit v1.1 From 08af495f22f43eff3b5a347dc10384ebcf356e41 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 3 Aug 2010 14:39:04 +0200 Subject: ALSA: hda - More relax for pending period handling Since the pending periods are often bogus and take long time until actually processed, it often results in a high CPU usage of the hd-audio workq. Overall it's better to have low CPU consumption by avoiding a too tight loop rather than the wake-up timing accuracy. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index f8a2f5a..66d4202 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1961,7 +1961,7 @@ static void azx_irq_pending_work(struct work_struct *work) spin_unlock_irq(&chip->reg_lock); if (!pending) return; - cond_resched(); + msleep(1); } } -- cgit v1.1 From e096c8e6d5ed965f346d94befbbec2275dde3621 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 3 Aug 2010 17:20:35 +0200 Subject: ALSA: hda - Add PC-beep whitelist for an Intel board An Intel board needs a white-list entry to enable PC-beep. Otherwise the driver misdetects (due to bogus BIOS info) and ignores the PC-beep on 2.6.35. Reported-and-tested-by: Leandro Lucarella Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index cf14b00..6c588ef 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -5327,6 +5327,7 @@ static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids, static struct snd_pci_quirk beep_white_list[] = { SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), + SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), {} }; -- cgit v1.1 From 748cce431eb413e794c8f1d1974b78b47a6174ef Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 4 Aug 2010 07:37:39 +0200 Subject: ALSA: hda - Fix initial capsrc selection in patch_alc269() In patch_alc269(), we initialize the primary capsrc so that the device works from the beginning. It issues CONNECT_SEL verb no matter which widget is although some widget (e.g. 0x23) has no connection selection but a mixer, which requires unmuting instead. This patch fixes the initialization of capsrc by re-using the code as a helper function. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 6c588ef..c807062 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -5166,6 +5166,19 @@ static void fixup_automic_adc(struct hda_codec *codec) spec->auto_mic = 0; /* disable auto-mic to be sure */ } +/* select or unmute the given capsrc route */ +static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap, + int idx) +{ + if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) { + snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx, + HDA_AMP_MUTE, 0); + } else { + snd_hda_codec_write_cache(codec, cap, 0, + AC_VERB_SET_CONNECT_SEL, idx); + } +} + /* set the default connection to that pin */ static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) { @@ -5180,14 +5193,7 @@ static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) idx = get_connection_index(codec, cap, pin); if (idx < 0) continue; - /* select or unmute this route */ - if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) { - snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx, - HDA_AMP_MUTE, 0); - } else { - snd_hda_codec_write_cache(codec, cap, 0, - AC_VERB_SET_CONNECT_SEL, idx); - } + select_or_unmute_capsrc(codec, cap, idx); return i; /* return the found index */ } return -1; /* not found */ @@ -14364,9 +14370,8 @@ static int alc269_parse_auto_config(struct hda_codec *codec) /* set default input source */ if (!spec->dual_adc_switch) - snd_hda_codec_write_cache(codec, spec->capsrc_nids[0], - 0, AC_VERB_SET_CONNECT_SEL, - spec->input_mux->items[0].index); + select_or_unmute_capsrc(codec, spec->capsrc_nids[0], + spec->input_mux->items[0].index); err = alc_auto_add_mic_boost(codec); if (err < 0) -- cgit v1.1 From b9619230e1f55a763bc41848c1cd971a394c878c Mon Sep 17 00:00:00 2001 From: Ondrej Zary Date: Tue, 3 Aug 2010 23:57:05 +0200 Subject: ALSA: als4000: enable burst mode Enable burst mode to prevent dropouts during high PCI bus usage. The card is useless in X without this because of dropouts when anything moves on the screen (at least with PCI VGA card). Enabling this is also recommended by the datasheet (page 48). Signed-off-by: Ondrej Zary Signed-off-by: Takashi Iwai --- sound/pci/als4000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound') diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index 6cf1de8..036a9ba 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -763,9 +763,9 @@ static void snd_als4000_configure(struct snd_sb *chip) /* SPECS_PAGE: 39 */ for (i = ALS4K_GCR91_DMA0_ADDR; i <= ALS4K_GCR96_DMA3_MODE_COUNT; ++i) snd_als4k_gcr_write(chip, i, 0); - + /* enable burst mode to prevent dropouts during high PCI bus usage */ snd_als4k_gcr_write(chip, ALS4K_GCR99_DMA_EMULATION_CTRL, - snd_als4k_gcr_read(chip, ALS4K_GCR99_DMA_EMULATION_CTRL)); + snd_als4k_gcr_read(chip, ALS4K_GCR99_DMA_EMULATION_CTRL) | 0x04); spin_unlock_irq(&chip->reg_lock); } -- cgit v1.1 From c4685849b4d725ab80cd29f5e09f5f128b4724b5 Mon Sep 17 00:00:00 2001 From: Ondrej Zary Date: Wed, 4 Aug 2010 21:56:44 +0200 Subject: ALSA: als4000: Fix potentially invalid DMA mode setup My previous patch assumed that the DMA mode (represented by 3 lowest bits of ALS4K_GCR99_DMA_EMULATION_CTRL register) is set to the default value 0. If that's not the case, it might result in invalid mode to be set. This patch fixes this potential problem. Signed-off-by: Ondrej Zary Signed-off-by: Takashi Iwai --- sound/pci/als4000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index 036a9ba..0e247cb 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -765,7 +765,7 @@ static void snd_als4000_configure(struct snd_sb *chip) snd_als4k_gcr_write(chip, i, 0); /* enable burst mode to prevent dropouts during high PCI bus usage */ snd_als4k_gcr_write(chip, ALS4K_GCR99_DMA_EMULATION_CTRL, - snd_als4k_gcr_read(chip, ALS4K_GCR99_DMA_EMULATION_CTRL) | 0x04); + (snd_als4k_gcr_read(chip, ALS4K_GCR99_DMA_EMULATION_CTRL) & ~0x07) | 0x04); spin_unlock_irq(&chip->reg_lock); } -- cgit v1.1 From fc091769a5aa65c045bfbda149c424ba33d0abbb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 4 Aug 2010 23:53:36 +0200 Subject: ALSA: hda - Add pin-fix for HP dc5750 The NID 0x11 on HP dc5750 with ALC260 should be a speaker although BIOS gives it as a line-out. This patch adds a quirk to fix the pin config so that the real line-out is used properly. Reference: bnc#624118 https://bugzilla.novell.com/show_bug.cgi?id=624118 Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index c807062..6ac53f7 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -6792,6 +6792,29 @@ static struct hda_amp_list alc260_loopbacks[] = { #endif /* + * Pin config fixes + */ +enum { + PINFIX_HP_DC5750, +}; + +static struct alc_pincfg alc260_hp_dc5750_pinfix[] = { + { 0x11, 0x90130110 }, /* speaker */ + { } +}; + +static const struct alc_fixup alc260_fixups[] = { + [PINFIX_HP_DC5750] = { + .pins = alc260_hp_dc5750_pinfix + }, +}; + +static struct snd_pci_quirk alc260_fixup_tbl[] = { + SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750), + {} +}; + +/* * ALC260 configurations */ static const char *alc260_models[ALC260_MODEL_LAST] = { @@ -6990,6 +7013,9 @@ static int patch_alc260(struct hda_codec *codec) board_config = ALC260_AUTO; } + if (board_config == ALC260_AUTO) + alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1); + if (board_config == ALC260_AUTO) { /* automatic parse from the BIOS config */ err = alc260_parse_auto_config(codec); @@ -7035,6 +7061,9 @@ static int patch_alc260(struct hda_codec *codec) set_capture_mixer(codec); set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); + if (board_config == ALC260_AUTO) + alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0); + spec->vmaster_nid = 0x08; codec->patch_ops = alc_patch_ops; -- cgit v1.1 From 2d00775c58325f63ad44702b3d9a1e2171536193 Mon Sep 17 00:00:00 2001 From: Andrea Gelmini Date: Thu, 5 Aug 2010 15:51:37 +0200 Subject: sound: oss: au1550_ac97.c removed duplicated #include Signed-off-by: Andrea Gelmini Signed-off-by: Takashi Iwai --- sound/oss/au1550_ac97.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c index c4a4cdc..c6f2621 100644 --- a/sound/oss/au1550_ac97.c +++ b/sound/oss/au1550_ac97.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include -- cgit v1.1 From dc386c4f6f3e6f495d1c6f72602c065153814385 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 5 Aug 2010 22:27:32 +0200 Subject: sound/oss: Adjust confusing if indentation Indent the branch of an if. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r disable braces4@ position p1,p2; statement S1,S2; @@ ( if (...) { ... } | if (...) S1@p1 S2@p2 ) @script:python@ p1 << r.p1; p2 << r.p2; @@ if (p1[0].column == p2[0].column): cocci.print_main("branch",p1) cocci.print_secs("after",p2) // Signed-off-by: Julia Lawall Signed-off-by: Takashi Iwai --- sound/oss/ad1848.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c index 24793c5..4d2a6ae9 100644 --- a/sound/oss/ad1848.c +++ b/sound/oss/ad1848.c @@ -716,7 +716,7 @@ static int ad1848_mixer_ioctl(int dev, unsigned int cmd, void __user *arg) default: if (get_user(val, (int __user *)arg)) - return -EFAULT; + return -EFAULT; val = ad1848_mixer_set(devc, cmd & 0xff, val); break; } -- cgit v1.1 From fe3eb0a73ca052ee9346a1544f4c00e697cc9a4e Mon Sep 17 00:00:00 2001 From: Kailang Yang Date: Fri, 6 Aug 2010 10:02:57 +0200 Subject: ALSA: hda - Add support for Acer ZGA ALC271 (1025:047c) Signed-off-by: Kailang Yang Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 6ac53f7..2891571 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -137,6 +137,7 @@ enum { ALC269VB_DMIC, ALC269_FUJITSU, ALC269_LIFEBOOK, + ALC271_ACER, ALC269_AUTO, ALC269_MODEL_LAST /* last tag */ }; @@ -13866,6 +13867,12 @@ static struct snd_kcontrol_new alc269vb_laptop_mixer[] = { { } /* end */ }; +static struct snd_kcontrol_new alc269_asus_mixer[] = { + HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT), + { } /* end */ +}; + /* capture mixer elements */ static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = { HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), @@ -14086,6 +14093,20 @@ static struct hda_verb alc269vb_laptop_amic_init_verbs[] = { {} }; +static struct hda_verb alc271_acer_dmic_verbs[] = { + {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, + {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, + {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, + {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT}, + {0x22, AC_VERB_SET_CONNECT_SEL, 6}, + { } +}; + /* toggle speaker-output according to the hp-jack state */ static void alc269_speaker_automute(struct hda_codec *codec) { @@ -14465,6 +14486,7 @@ static const char *alc269_models[ALC269_MODEL_LAST] = { static struct snd_pci_quirk alc269_cfg_tbl[] = { SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1), + SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER), SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", ALC269_AMIC), SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC), @@ -14626,6 +14648,23 @@ static struct alc_config_preset alc269_presets[] = { .unsol_event = alc269_lifebook_unsol_event, .init_hook = alc269_lifebook_init_hook, }, + [ALC271_ACER] = { + .mixers = { alc269_asus_mixer }, + .cap_mixer = alc269vb_laptop_digital_capture_mixer, + .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs }, + .num_dacs = ARRAY_SIZE(alc269_dac_nids), + .dac_nids = alc269_dac_nids, + .adc_nids = alc262_dmic_adc_nids, + .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids), + .capsrc_nids = alc262_dmic_capsrc_nids, + .num_channel_mode = ARRAY_SIZE(alc269_modes), + .channel_mode = alc269_modes, + .input_mux = &alc269_capture_source, + .dig_out_nid = ALC880_DIGOUT_NID, + .unsol_event = alc_sku_unsol_event, + .setup = alc269vb_laptop_dmic_setup, + .init_hook = alc_inithook, + }, }; static int patch_alc269(struct hda_codec *codec) -- cgit v1.1 From eb541337b7a43822fce7d0c9d967ee149b2d9a96 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 6 Aug 2010 13:48:11 +0200 Subject: ALSA: hda - Make converter setups sticky So far, we reset the converter setups like the stream-tag, the channel-id and format-id in prepare callbacks, and clear them in cleanup callbacks. This often causes a silence of the digital receiver for a couple of seconds. This patch tries to delay the converter setup changes as much as possible. The converter setups are cached and aren't reset as long as the same values are used. At suspend/resume, they are cleared to be recovered properly, too. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 150 +++++++++++++++++++++++++++++++++++++++++++--- sound/pci/hda/hda_codec.h | 12 ++++ sound/pci/hda/hda_intel.c | 6 +- 3 files changed, 157 insertions(+), 11 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index a7802b9..720a81d 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -971,6 +971,36 @@ static void restore_init_pincfgs(struct hda_codec *codec) } /* + * audio-converter setup caches + */ +struct hda_cvt_setup { + hda_nid_t nid; + u8 stream_tag; + u8 channel_id; + u16 format_id; + unsigned char active; /* cvt is currently used */ + unsigned char dirty; /* setups should be cleared */ +}; + +/* get or create a cache entry for the given audio converter NID */ +static struct hda_cvt_setup * +get_hda_cvt_setup(struct hda_codec *codec, hda_nid_t nid) +{ + struct hda_cvt_setup *p; + int i; + + for (i = 0; i < codec->cvt_setups.used; i++) { + p = snd_array_elem(&codec->cvt_setups, i); + if (p->nid == nid) + return p; + } + p = snd_array_new(&codec->cvt_setups); + if (p) + p->nid = nid; + return p; +} + +/* * codec destructor */ static void snd_hda_codec_free(struct hda_codec *codec) @@ -1038,12 +1068,14 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, codec->addr = codec_addr; mutex_init(&codec->spdif_mutex); mutex_init(&codec->control_mutex); + mutex_init(&codec->prepare_mutex); init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 32); snd_array_init(&codec->nids, sizeof(struct hda_nid_item), 32); snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16); snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16); + snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8); if (codec->bus->modelname) { codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); if (!codec->modelname) { @@ -1181,16 +1213,51 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, int channel_id, int format) { + struct hda_cvt_setup *p; + unsigned int oldval, newval; + int i; + if (!nid) return; snd_printdd("hda_codec_setup_stream: " "NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n", nid, stream_tag, channel_id, format); - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, - (stream_tag << 4) | channel_id); - msleep(1); - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format); + p = get_hda_cvt_setup(codec, nid); + if (!p) + return; + /* update the stream-id if changed */ + if (p->stream_tag != stream_tag || p->channel_id != channel_id) { + oldval = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0); + newval = (stream_tag << 4) | channel_id; + if (oldval != newval) + snd_hda_codec_write(codec, nid, 0, + AC_VERB_SET_CHANNEL_STREAMID, + newval); + p->stream_tag = stream_tag; + p->channel_id = channel_id; + } + /* update the format-id if changed */ + if (p->format_id != format) { + oldval = snd_hda_codec_read(codec, nid, 0, + AC_VERB_GET_STREAM_FORMAT, 0); + if (oldval != format) { + msleep(1); + snd_hda_codec_write(codec, nid, 0, + AC_VERB_SET_STREAM_FORMAT, + format); + } + p->format_id = format; + } + p->active = 1; + p->dirty = 0; + + /* make other inactive cvts with the same stream-tag dirty */ + for (i = 0; i < codec->cvt_setups.used; i++) { + p = snd_array_elem(&codec->cvt_setups, i); + if (!p->active && p->stream_tag == stream_tag) + p->dirty = 1; + } } EXPORT_SYMBOL_HDA(snd_hda_codec_setup_stream); @@ -1201,17 +1268,54 @@ EXPORT_SYMBOL_HDA(snd_hda_codec_setup_stream); */ void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid) { + struct hda_cvt_setup *p; + if (!nid) return; snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid); + /* here we just clear the active flag; actual clean-ups will be done + * in purify_inactive_streams() + */ + p = get_hda_cvt_setup(codec, nid); + if (p) + p->active = 0; +} +EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream); + +static void really_cleanup_stream(struct hda_codec *codec, + struct hda_cvt_setup *q) +{ + hda_nid_t nid = q->nid; snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 0); -#if 0 /* keep the format */ - msleep(1); snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0); -#endif + memset(q, 0, sizeof(*q)); + q->nid = nid; +} + +/* clean up the all conflicting obsolete streams */ +static void purify_inactive_streams(struct hda_codec *codec) +{ + int i; + + for (i = 0; i < codec->cvt_setups.used; i++) { + struct hda_cvt_setup *p = snd_array_elem(&codec->cvt_setups, i); + if (p->dirty) + really_cleanup_stream(codec, p); + } +} + +/* clean up all streams; called from suspend */ +static void hda_cleanup_all_streams(struct hda_codec *codec) +{ + int i; + + for (i = 0; i < codec->cvt_setups.used; i++) { + struct hda_cvt_setup *p = snd_array_elem(&codec->cvt_setups, i); + if (p->stream_tag) + really_cleanup_stream(codec, p); + } } -EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream); /* * amp access functions @@ -2928,6 +3032,7 @@ static void hda_call_codec_suspend(struct hda_codec *codec) { if (codec->patch_ops.suspend) codec->patch_ops.suspend(codec, PMSG_SUSPEND); + hda_cleanup_all_streams(codec); hda_set_power_state(codec, codec->afg ? codec->afg : codec->mfg, AC_PWRST_D3); @@ -3377,6 +3482,35 @@ static int set_pcm_default_values(struct hda_codec *codec, return 0; } +/* + * codec prepare/cleanup entries + */ +int snd_hda_codec_prepare(struct hda_codec *codec, + struct hda_pcm_stream *hinfo, + unsigned int stream, + unsigned int format, + struct snd_pcm_substream *substream) +{ + int ret; + mutex_lock(&codec->prepare_mutex); + ret = hinfo->ops.prepare(hinfo, codec, stream, format, substream); + if (ret >= 0) + purify_inactive_streams(codec); + mutex_unlock(&codec->prepare_mutex); + return ret; +} +EXPORT_SYMBOL_HDA(snd_hda_codec_prepare); + +void snd_hda_codec_cleanup(struct hda_codec *codec, + struct hda_pcm_stream *hinfo, + struct snd_pcm_substream *substream) +{ + mutex_lock(&codec->prepare_mutex); + hinfo->ops.cleanup(hinfo, codec, substream); + mutex_unlock(&codec->prepare_mutex); +} +EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup); + /* global */ const char *snd_hda_pcm_type_name[HDA_PCM_NTYPES] = { "Audio", "SPDIF", "HDMI", "Modem" diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 0328cf5..3f7a479 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -826,12 +826,14 @@ struct hda_codec { struct mutex spdif_mutex; struct mutex control_mutex; + struct mutex prepare_mutex; unsigned int spdif_status; /* IEC958 status bits */ unsigned short spdif_ctls; /* SPDIF control bits */ unsigned int spdif_in_enable; /* SPDIF input enable? */ hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */ struct snd_array init_pins; /* initial (BIOS) pin configurations */ struct snd_array driver_pins; /* pin configs set by codec parser */ + struct snd_array cvt_setups; /* audio convert setups */ #ifdef CONFIG_SND_HDA_HWDEP struct snd_hwdep *hwdep; /* assigned hwdep device */ @@ -948,6 +950,16 @@ int snd_hda_codec_build_controls(struct hda_codec *codec); */ int snd_hda_build_pcms(struct hda_bus *bus); int snd_hda_codec_build_pcms(struct hda_codec *codec); + +int snd_hda_codec_prepare(struct hda_codec *codec, + struct hda_pcm_stream *hinfo, + unsigned int stream, + unsigned int format, + struct snd_pcm_substream *substream); +void snd_hda_codec_cleanup(struct hda_codec *codec, + struct hda_pcm_stream *hinfo, + struct snd_pcm_substream *substream); + void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, int channel_id, int format); diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 66d4202..1053fff 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1634,7 +1634,7 @@ static int azx_pcm_hw_free(struct snd_pcm_substream *substream) azx_dev->period_bytes = 0; azx_dev->format_val = 0; - hinfo->ops.cleanup(hinfo, apcm->codec, substream); + snd_hda_codec_cleanup(apcm->codec, hinfo, substream); return snd_pcm_lib_free_pages(substream); } @@ -1688,8 +1688,8 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) else azx_dev->fifo_size = 0; - return hinfo->ops.prepare(hinfo, apcm->codec, azx_dev->stream_tag, - azx_dev->format_val, substream); + return snd_hda_codec_prepare(apcm->codec, hinfo, azx_dev->stream_tag, + azx_dev->format_val, substream); } static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -- cgit v1.1 From 2dc11581376829303b98eadb2de253bee065a56a Mon Sep 17 00:00:00 2001 From: Grant Likely Date: Fri, 6 Aug 2010 09:25:50 -0600 Subject: of/device: Replace struct of_device with struct platform_device of_device is just an alias for platform_device, so remove it entirely. Also replace to_of_device() with to_platform_device() and update comment blocks. This patch was initially generated from the following semantic patch, and then edited by hand to pick up the bits that coccinelle didn't catch. @@ @@ -struct of_device +struct platform_device Signed-off-by: Grant Likely Reviewed-by: David S. Miller --- sound/aoa/soundbus/core.c | 2 +- sound/aoa/soundbus/soundbus.h | 2 +- sound/aoa/soundbus/sysfs.c | 2 +- sound/soc/fsl/mpc5200_dma.c | 4 ++-- sound/soc/fsl/mpc5200_dma.h | 4 ++-- sound/soc/fsl/mpc5200_psc_ac97.c | 4 ++-- sound/soc/fsl/mpc5200_psc_i2s.c | 4 ++-- sound/soc/fsl/mpc8610_hpcd.c | 4 ++-- sound/sparc/amd7930.c | 8 ++++---- sound/sparc/cs4231.c | 18 +++++++++--------- sound/sparc/dbri.c | 8 ++++---- 11 files changed, 30 insertions(+), 30 deletions(-) (limited to 'sound') diff --git a/sound/aoa/soundbus/core.c b/sound/aoa/soundbus/core.c index 99ca712..7487eb7 100644 --- a/sound/aoa/soundbus/core.c +++ b/sound/aoa/soundbus/core.c @@ -59,7 +59,7 @@ static int soundbus_probe(struct device *dev) static int soundbus_uevent(struct device *dev, struct kobj_uevent_env *env) { struct soundbus_dev * soundbus_dev; - struct of_device * of; + struct platform_device * of; const char *compat; int retval = 0; int cplen, seen = 0; diff --git a/sound/aoa/soundbus/soundbus.h b/sound/aoa/soundbus/soundbus.h index a0f223c..adecbf3 100644 --- a/sound/aoa/soundbus/soundbus.h +++ b/sound/aoa/soundbus/soundbus.h @@ -141,7 +141,7 @@ struct soundbus_dev { struct list_head onbuslist; /* the of device it represents */ - struct of_device ofdev; + struct platform_device ofdev; /* what modules go by */ char modalias[32]; diff --git a/sound/aoa/soundbus/sysfs.c b/sound/aoa/soundbus/sysfs.c index 6496e75..e0980b5 100644 --- a/sound/aoa/soundbus/sysfs.c +++ b/sound/aoa/soundbus/sysfs.c @@ -16,7 +16,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { struct soundbus_dev *sdev = to_soundbus_device(dev); - struct of_device *of = &sdev->ofdev; + struct platform_device *of = &sdev->ofdev; int length; if (*sdev->modalias) { diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index 1d4e716..3dcd146 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -369,7 +369,7 @@ struct snd_soc_platform mpc5200_audio_dma_platform = { }; EXPORT_SYMBOL_GPL(mpc5200_audio_dma_platform); -int mpc5200_audio_dma_create(struct of_device *op) +int mpc5200_audio_dma_create(struct platform_device *op) { phys_addr_t fifo; struct psc_dma *psc_dma; @@ -488,7 +488,7 @@ out_unmap: } EXPORT_SYMBOL_GPL(mpc5200_audio_dma_create); -int mpc5200_audio_dma_destroy(struct of_device *op) +int mpc5200_audio_dma_destroy(struct platform_device *op) { struct psc_dma *psc_dma = dev_get_drvdata(&op->dev); diff --git a/sound/soc/fsl/mpc5200_dma.h b/sound/soc/fsl/mpc5200_dma.h index e1ec6d9..ca99586 100644 --- a/sound/soc/fsl/mpc5200_dma.h +++ b/sound/soc/fsl/mpc5200_dma.h @@ -81,8 +81,8 @@ to_psc_dma_stream(struct snd_pcm_substream *substream, struct psc_dma *psc_dma) return &psc_dma->playback; } -int mpc5200_audio_dma_create(struct of_device *op); -int mpc5200_audio_dma_destroy(struct of_device *op); +int mpc5200_audio_dma_create(struct platform_device *op); +int mpc5200_audio_dma_destroy(struct platform_device *op); extern struct snd_soc_platform mpc5200_audio_dma_platform; diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c index e2ee220..a031017 100644 --- a/sound/soc/fsl/mpc5200_psc_ac97.c +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -263,7 +263,7 @@ EXPORT_SYMBOL_GPL(psc_ac97_dai); * - Probe/remove operations * - OF device match table */ -static int __devinit psc_ac97_of_probe(struct of_device *op, +static int __devinit psc_ac97_of_probe(struct platform_device *op, const struct of_device_id *match) { int rc, i; @@ -303,7 +303,7 @@ static int __devinit psc_ac97_of_probe(struct of_device *op, return 0; } -static int __devexit psc_ac97_of_remove(struct of_device *op) +static int __devexit psc_ac97_of_remove(struct platform_device *op) { return mpc5200_audio_dma_destroy(op); } diff --git a/sound/soc/fsl/mpc5200_psc_i2s.c b/sound/soc/fsl/mpc5200_psc_i2s.c index 4f455bd..9aee748 100644 --- a/sound/soc/fsl/mpc5200_psc_i2s.c +++ b/sound/soc/fsl/mpc5200_psc_i2s.c @@ -153,7 +153,7 @@ EXPORT_SYMBOL_GPL(psc_i2s_dai); * - Probe/remove operations * - OF device match table */ -static int __devinit psc_i2s_of_probe(struct of_device *op, +static int __devinit psc_i2s_of_probe(struct platform_device *op, const struct of_device_id *match) { int rc; @@ -206,7 +206,7 @@ static int __devinit psc_i2s_of_probe(struct of_device *op, } -static int __devexit psc_i2s_of_remove(struct of_device *op) +static int __devexit psc_i2s_of_remove(struct platform_device *op) { return mpc5200_audio_dma_destroy(op); } diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c index 3a50106..3b13b8d 100644 --- a/sound/soc/fsl/mpc8610_hpcd.c +++ b/sound/soc/fsl/mpc8610_hpcd.c @@ -200,7 +200,7 @@ static struct snd_soc_ops mpc8610_hpcd_ops = { * SSI devices. We also probably aren't compatible with the generic Elo DMA * device driver. */ -static int mpc8610_hpcd_probe(struct of_device *ofdev, +static int mpc8610_hpcd_probe(struct platform_device *ofdev, const struct of_device_id *match) { struct device_node *np = ofdev->dev.of_node; @@ -534,7 +534,7 @@ error: * * This function is called when the OF device is removed. */ -static int mpc8610_hpcd_remove(struct of_device *ofdev) +static int mpc8610_hpcd_remove(struct platform_device *ofdev) { struct platform_device *sound_device = dev_get_drvdata(&ofdev->dev); struct mpc8610_hpcd_data *machine_data = diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index 9eb1a4e..f8bcfc3 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -336,7 +336,7 @@ struct snd_amd7930 { int pgain; int mgain; - struct of_device *op; + struct platform_device *op; unsigned int irq; struct snd_amd7930 *next; }; @@ -906,7 +906,7 @@ static int __devinit snd_amd7930_mixer(struct snd_amd7930 *amd) static int snd_amd7930_free(struct snd_amd7930 *amd) { - struct of_device *op = amd->op; + struct platform_device *op = amd->op; amd7930_idle(amd); @@ -934,7 +934,7 @@ static struct snd_device_ops snd_amd7930_dev_ops = { }; static int __devinit snd_amd7930_create(struct snd_card *card, - struct of_device *op, + struct platform_device *op, int irq, int dev, struct snd_amd7930 **ramd) { @@ -1002,7 +1002,7 @@ static int __devinit snd_amd7930_create(struct snd_card *card, return 0; } -static int __devinit amd7930_sbus_probe(struct of_device *op, const struct of_device_id *match) +static int __devinit amd7930_sbus_probe(struct platform_device *op, const struct of_device_id *match) { struct resource *rp = &op->resource[0]; static int dev_num; diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 68570ee..c276086 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -111,7 +111,7 @@ struct snd_cs4231 { struct mutex mce_mutex; /* mutex for mce register */ struct mutex open_mutex; /* mutex for ALSA open/close */ - struct of_device *op; + struct platform_device *op; unsigned int irq[2]; unsigned int regs_size; struct snd_cs4231 *next; @@ -1771,7 +1771,7 @@ static unsigned int sbus_dma_addr(struct cs4231_dma_control *dma_cont) static int snd_cs4231_sbus_free(struct snd_cs4231 *chip) { - struct of_device *op = chip->op; + struct platform_device *op = chip->op; if (chip->irq[0]) free_irq(chip->irq[0], chip); @@ -1794,7 +1794,7 @@ static struct snd_device_ops snd_cs4231_sbus_dev_ops = { }; static int __devinit snd_cs4231_sbus_create(struct snd_card *card, - struct of_device *op, + struct platform_device *op, int dev) { struct snd_cs4231 *chip = card->private_data; @@ -1856,7 +1856,7 @@ static int __devinit snd_cs4231_sbus_create(struct snd_card *card, return 0; } -static int __devinit cs4231_sbus_probe(struct of_device *op, const struct of_device_id *match) +static int __devinit cs4231_sbus_probe(struct platform_device *op, const struct of_device_id *match) { struct resource *rp = &op->resource[0]; struct snd_card *card; @@ -1931,7 +1931,7 @@ static unsigned int _ebus_dma_addr(struct cs4231_dma_control *dma_cont) static int snd_cs4231_ebus_free(struct snd_cs4231 *chip) { - struct of_device *op = chip->op; + struct platform_device *op = chip->op; if (chip->c_dma.ebus_info.regs) { ebus_dma_unregister(&chip->c_dma.ebus_info); @@ -1960,7 +1960,7 @@ static struct snd_device_ops snd_cs4231_ebus_dev_ops = { }; static int __devinit snd_cs4231_ebus_create(struct snd_card *card, - struct of_device *op, + struct platform_device *op, int dev) { struct snd_cs4231 *chip = card->private_data; @@ -2048,7 +2048,7 @@ static int __devinit snd_cs4231_ebus_create(struct snd_card *card, return 0; } -static int __devinit cs4231_ebus_probe(struct of_device *op, const struct of_device_id *match) +static int __devinit cs4231_ebus_probe(struct platform_device *op, const struct of_device_id *match) { struct snd_card *card; int err; @@ -2072,7 +2072,7 @@ static int __devinit cs4231_ebus_probe(struct of_device *op, const struct of_dev } #endif -static int __devinit cs4231_probe(struct of_device *op, const struct of_device_id *match) +static int __devinit cs4231_probe(struct platform_device *op, const struct of_device_id *match) { #ifdef EBUS_SUPPORT if (!strcmp(op->dev.of_node->parent->name, "ebus")) @@ -2086,7 +2086,7 @@ static int __devinit cs4231_probe(struct of_device *op, const struct of_device_i return -ENODEV; } -static int __devexit cs4231_remove(struct of_device *op) +static int __devexit cs4231_remove(struct platform_device *op) { struct snd_cs4231 *chip = dev_get_drvdata(&op->dev); diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index c421901..39cd5d6 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -299,7 +299,7 @@ struct dbri_streaminfo { /* This structure holds the information for both chips (DBRI & CS4215) */ struct snd_dbri { int regs_size, irq; /* Needed for unload */ - struct of_device *op; /* OF device info */ + struct platform_device *op; /* OF device info */ spinlock_t lock; struct dbri_dma *dma; /* Pointer to our DMA block */ @@ -2523,7 +2523,7 @@ static void __devinit snd_dbri_proc(struct snd_card *card) static void snd_dbri_free(struct snd_dbri *dbri); static int __devinit snd_dbri_create(struct snd_card *card, - struct of_device *op, + struct platform_device *op, int irq, int dev) { struct snd_dbri *dbri = card->private_data; @@ -2592,7 +2592,7 @@ static void snd_dbri_free(struct snd_dbri *dbri) (void *)dbri->dma, dbri->dma_dvma); } -static int __devinit dbri_probe(struct of_device *op, const struct of_device_id *match) +static int __devinit dbri_probe(struct platform_device *op, const struct of_device_id *match) { struct snd_dbri *dbri; struct resource *rp; @@ -2662,7 +2662,7 @@ _err: return err; } -static int __devexit dbri_remove(struct of_device *op) +static int __devexit dbri_remove(struct platform_device *op) { struct snd_card *card = dev_get_drvdata(&op->dev); -- cgit v1.1 From 949ad0a783729ad8c2e8e5bcbbad5d05a60de616 Mon Sep 17 00:00:00 2001 From: Eric Millbrandt Date: Fri, 6 Aug 2010 20:49:19 -0600 Subject: sound/soc: mpc5200_psc_ac97: Use gpio pins for cold reset Call the gpio reset platform function instead of using the flawed ac97 functionality of the MPC5200(b) From MPC5200B User's Manual: "Some AC97 devices goes to a test mode, if the Sync line is high during the Res line is low (reset phase). To avoid this behavior the Sync line must be also forced to zero during the reset phase. To do that, the pin muxing should switch to GPIO mode and the GPIO control register should be used to control the output lines." Signed-off-by: Eric Millbrandt Signed-off-by: Grant Likely --- sound/soc/fsl/mpc5200_psc_ac97.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'sound') diff --git a/sound/soc/fsl/mpc5200_psc_ac97.c b/sound/soc/fsl/mpc5200_psc_ac97.c index e2ee220..e7f5d50 100644 --- a/sound/soc/fsl/mpc5200_psc_ac97.c +++ b/sound/soc/fsl/mpc5200_psc_ac97.c @@ -20,6 +20,7 @@ #include #include +#include #include #include "mpc5200_dma.h" @@ -100,19 +101,32 @@ static void psc_ac97_warm_reset(struct snd_ac97 *ac97) { struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs; + mutex_lock(&psc_dma->mutex); + out_be32(®s->sicr, psc_dma->sicr | MPC52xx_PSC_SICR_AWR); udelay(3); out_be32(®s->sicr, psc_dma->sicr); + + mutex_unlock(&psc_dma->mutex); } static void psc_ac97_cold_reset(struct snd_ac97 *ac97) { struct mpc52xx_psc __iomem *regs = psc_dma->psc_regs; - /* Do a cold reset */ - out_8(®s->op1, MPC52xx_PSC_OP_RES); - udelay(10); - out_8(®s->op0, MPC52xx_PSC_OP_RES); + mutex_lock(&psc_dma->mutex); + dev_dbg(psc_dma->dev, "cold reset\n"); + + mpc5200_psc_ac97_gpio_reset(psc_dma->id); + + /* Notify the PSC that a reset has occurred */ + out_be32(®s->sicr, psc_dma->sicr | MPC52xx_PSC_SICR_ACRB); + + /* Re-enable RX and TX */ + out_8(®s->command, MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE); + + mutex_unlock(&psc_dma->mutex); + msleep(1); psc_ac97_warm_reset(ac97); } -- cgit v1.1 From 53bacfbbb2ddd981287b58a511c8b8f5df179886 Mon Sep 17 00:00:00 2001 From: Jonathan Woithe Date: Sun, 8 Aug 2010 00:17:05 +0930 Subject: ALSA: hda - Fix missing stream for second ADC on Realtek ALC260 HDA codec I discovered tonight that ALSA no longer sets up a stream for the second ADC provided by the Realtek ALC260 HDA codec. At some point alc_build_pcms() started using stream_analog_alt_capture when constructing the second ADC stream, but patch_alc260() was never updated accordingly. I have no idea when this regression occurred. The trivial patch to patch_alc260() given below fixes the problem as far as I can tell. The patch is against 2.6.35. Signed-off-by: Jonathan Woithe Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 2891571..6b00a23 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -7042,6 +7042,7 @@ static int patch_alc260(struct hda_codec *codec) spec->stream_analog_playback = &alc260_pcm_analog_playback; spec->stream_analog_capture = &alc260_pcm_analog_capture; + spec->stream_analog_alt_capture = &alc260_pcm_analog_capture; spec->stream_digital_playback = &alc260_pcm_digital_playback; spec->stream_digital_capture = &alc260_pcm_digital_capture; -- cgit v1.1 From 48315590186f0f9f5653dd7c35623e66ca4dd91a Mon Sep 17 00:00:00 2001 From: Steven Eastland Date: Fri, 6 Aug 2010 15:07:35 -0600 Subject: ALSA: hda - New snd-hda-intel model/pin config for hp dv7-4000 This provides a new model and pin config for the snd-hda-intel 92HD83XXX codec for hp laptop model dv7-4000, enabling the subwoofer. Signed-off-by: Steven Eastland Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_sigmatel.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index b8d730c..a664367 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -94,6 +94,7 @@ enum { STAC_92HD83XXX_PWR_REF, STAC_DELL_S14, STAC_92HD83XXX_HP, + STAC_HP_DV7_4000, STAC_92HD83XXX_MODELS }; @@ -1632,10 +1633,17 @@ static unsigned int dell_s14_pin_configs[10] = { 0x40f000f0, 0x40f000f0, }; +static unsigned int hp_dv7_4000_pin_configs[10] = { + 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110, + 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140, + 0x40f000f0, 0x40f000f0, +}; + static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, [STAC_DELL_S14] = dell_s14_pin_configs, + [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs, }; static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { @@ -1644,6 +1652,7 @@ static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { [STAC_92HD83XXX_PWR_REF] = "mic-ref", [STAC_DELL_S14] = "dell-s14", [STAC_92HD83XXX_HP] = "hp", + [STAC_HP_DV7_4000] = "hp-dv7-4000", }; static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { -- cgit v1.1 From 850eab9d1b74f4ec9de16df68f008d0a65aafae7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 9 Aug 2010 13:44:27 +0200 Subject: ALSA: hda - add support for Conexant CX20584 The Conexant CX20584 with 141f:5068 seems compatible with other cxt5066 code. Just add the missing id. Tested-by: Cristopher Camacho Leandro Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index df8b19b..f7e234e 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3206,6 +3206,8 @@ static struct hda_codec_preset snd_hda_preset_conexant[] = { .patch = patch_cxt5066 }, { .id = 0x14f15067, .name = "CX20583 (Pebble HSF)", .patch = patch_cxt5066 }, + { .id = 0x14f15068, .name = "CX20584", + .patch = patch_cxt5066 }, { .id = 0x14f15069, .name = "CX20585", .patch = patch_cxt5066 }, {} /* terminator */ @@ -3216,6 +3218,7 @@ MODULE_ALIAS("snd-hda-codec-id:14f15047"); MODULE_ALIAS("snd-hda-codec-id:14f15051"); MODULE_ALIAS("snd-hda-codec-id:14f15066"); MODULE_ALIAS("snd-hda-codec-id:14f15067"); +MODULE_ALIAS("snd-hda-codec-id:14f15068"); MODULE_ALIAS("snd-hda-codec-id:14f15069"); MODULE_LICENSE("GPL"); -- cgit v1.1 From 9cf2657d05f9f9e04c3e113d68bf7cef5a942070 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 9 Aug 2010 22:41:40 -0600 Subject: ALSA: hda - patch_nvhdmi.c: Add missing codec IDs, unify names * Add missing codec IDs. * Modify some existing codec names for discrete GPUs to match newly added IDs. Note: existing names were a mixture of marketing and engineering GPU names. Equally, there's no reason that codec IDs have to be specific to a particular GPU or board, so identify codecs in a less marketing-oriented fashion. * Reformat codec ID table so it's easier to read, for me at least. Signed-off-by: Stephen Warren Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_nvhdmi.c | 61 +++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 20 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c index a281836..77e2b40 100644 --- a/sound/pci/hda/patch_nvhdmi.c +++ b/sound/pci/hda/patch_nvhdmi.c @@ -540,26 +540,32 @@ static int patch_nvhdmi_2ch(struct hda_codec *codec) * patch entries */ static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { - { .id = 0x10de0002, .name = "MCP77/78 HDMI", - .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de0003, .name = "MCP77/78 HDMI", - .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de0005, .name = "MCP77/78 HDMI", - .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de0006, .name = "MCP77/78 HDMI", - .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de0007, .name = "MCP79/7A HDMI", - .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de000a, .name = "GT220 HDMI", - .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de000b, .name = "GT21x HDMI", - .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de000c, .name = "MCP89 HDMI", - .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de000d, .name = "GT240 HDMI", - .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, - { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, + { .id = 0x10de0002, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, + { .id = 0x10de0003, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, + { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, + { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, + { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x }, + { .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, + { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, + { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, {} /* terminator */ }; @@ -572,6 +578,21 @@ MODULE_ALIAS("snd-hda-codec-id:10de000a"); MODULE_ALIAS("snd-hda-codec-id:10de000b"); MODULE_ALIAS("snd-hda-codec-id:10de000c"); MODULE_ALIAS("snd-hda-codec-id:10de000d"); +MODULE_ALIAS("snd-hda-codec-id:10de0010"); +MODULE_ALIAS("snd-hda-codec-id:10de0011"); +MODULE_ALIAS("snd-hda-codec-id:10de0012"); +MODULE_ALIAS("snd-hda-codec-id:10de0013"); +MODULE_ALIAS("snd-hda-codec-id:10de0014"); +MODULE_ALIAS("snd-hda-codec-id:10de0018"); +MODULE_ALIAS("snd-hda-codec-id:10de0019"); +MODULE_ALIAS("snd-hda-codec-id:10de001a"); +MODULE_ALIAS("snd-hda-codec-id:10de001b"); +MODULE_ALIAS("snd-hda-codec-id:10de001c"); +MODULE_ALIAS("snd-hda-codec-id:10de0040"); +MODULE_ALIAS("snd-hda-codec-id:10de0041"); +MODULE_ALIAS("snd-hda-codec-id:10de0042"); +MODULE_ALIAS("snd-hda-codec-id:10de0043"); +MODULE_ALIAS("snd-hda-codec-id:10de0044"); MODULE_ALIAS("snd-hda-codec-id:10de0067"); MODULE_ALIAS("snd-hda-codec-id:10de8001"); -- cgit v1.1 From 81cd3fca642cecb40a1ccef099799dcb5730734b Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Tue, 10 Aug 2010 09:18:00 +0200 Subject: ALSA: HDA: Use model=auto for LG R510 Two users report model=auto is needed to make the internal mic work properly. BugLink: https://bugs.launchpad.net/bugs/495134 Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 6b00a23..55d6e5b 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -13477,7 +13477,6 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = { SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), - SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL), {} }; -- cgit v1.1 From 8a345a042ae75097fd493633633382644257cfc3 Mon Sep 17 00:00:00 2001 From: Charles Chin Date: Tue, 10 Aug 2010 11:43:25 +0200 Subject: ALSA: hda - Adding support for new IDT 92HD87XX codecs Added the entries for 92HD87B1/3 and 92HD87B2/4 codecs. These are compatible with existing 83xxx codecs. Signed-off-by: Charles Chin Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_sigmatel.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sound') diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index a664367..f3f861b 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -5349,6 +5349,8 @@ again: case 0x111d7667: case 0x111d7668: case 0x111d7669: + case 0x111d76d1: + case 0x111d76d9: spec->num_pins = ARRAY_SIZE(stac92hd88xxx_pin_nids); spec->pin_nids = stac92hd88xxx_pin_nids; spec->mono_nid = 0; @@ -6283,6 +6285,8 @@ static struct hda_codec_preset snd_hda_preset_sigmatel[] = { { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx}, { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx}, + { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx}, + { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx}, { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx}, { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx}, { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx}, -- cgit v1.1 From 31cbd97726207b483a1731562559fabd4e2efdd0 Mon Sep 17 00:00:00 2001 From: Andrea Gelmini Date: Wed, 11 Aug 2010 21:07:33 +0200 Subject: sound: oss: sh_dac_audio.c removed duplicated #include Signed-off-by: Andrea Gelmini Signed-off-by: Takashi Iwai --- sound/oss/sh_dac_audio.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sound') diff --git a/sound/oss/sh_dac_audio.c b/sound/oss/sh_dac_audio.c index fdb58eb..479e302 100644 --- a/sound/oss/sh_dac_audio.c +++ b/sound/oss/sh_dac_audio.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include -- cgit v1.1 From bbbe33900d1f3c4402148ccb85234a741a6606a3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 13 Aug 2010 08:45:23 +0200 Subject: ALSA: hda - Restrict PCM parameters per ELD information over HDMI When a device is plugged over HDMI, it passes some information in ELD including the supported PCM parameters like formats, rates, channels. This patch adds the check to PCM open callback of HDMI streams so that only valid parameters the device supports are used. When no device is plugged, the parameters the codec supports are used; it's mostly all parameters the hardware can work. This is for apps that are started before device plugging and do probing (e.g. a sound daemon), so that at least, probing would work even before the device plugging. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_eld.c | 49 +++++++++++++++++++++++++++++++++++++++++ sound/pci/hda/hda_local.h | 2 ++ sound/pci/hda/patch_hdmi.c | 42 +++++++++++++++++++++++++++++++++++ sound/pci/hda/patch_intelhdmi.c | 1 + sound/pci/hda/patch_nvhdmi.c | 4 +--- 5 files changed, 95 insertions(+), 3 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index d8da18a..803b298 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c @@ -596,4 +596,53 @@ void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) } EXPORT_SYMBOL_HDA(snd_hda_eld_proc_free); +/* update PCM info based on ELD */ +void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm, + struct hda_pcm_stream *codec_pars) +{ + int i; + + pcm->rates = 0; + pcm->formats = 0; + pcm->maxbps = 0; + pcm->channels_min = -1; + pcm->channels_max = 0; + for (i = 0; i < eld->sad_count; i++) { + struct cea_sad *a = &eld->sad[i]; + pcm->rates |= a->rates; + if (a->channels < pcm->channels_min) + pcm->channels_min = a->channels; + if (a->channels > pcm->channels_max) + pcm->channels_max = a->channels; + if (a->format == AUDIO_CODING_TYPE_LPCM) { + if (a->sample_bits & AC_SUPPCM_BITS_16) { + pcm->formats |= SNDRV_PCM_FMTBIT_S16_LE; + if (pcm->maxbps < 16) + pcm->maxbps = 16; + } + if (a->sample_bits & AC_SUPPCM_BITS_20) { + pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE; + if (pcm->maxbps < 20) + pcm->maxbps = 20; + } + if (a->sample_bits & AC_SUPPCM_BITS_24) { + pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE; + if (pcm->maxbps < 24) + pcm->maxbps = 24; + } + } + } + + if (!codec_pars) + return; + + /* restrict the parameters by the values the codec provides */ + pcm->rates &= codec_pars->rates; + pcm->formats &= codec_pars->formats; + pcm->channels_min = max(pcm->channels_min, codec_pars->channels_min); + pcm->channels_max = min(pcm->channels_max, codec_pars->channels_max); + pcm->maxbps = min(pcm->maxbps, codec_pars->maxbps); +} +EXPORT_SYMBOL_HDA(hdmi_eld_update_pcm_info); + #endif /* CONFIG_PROC_FS */ diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 7a97f12..28ab4ae 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -604,6 +604,8 @@ struct hdmi_eld { int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid); int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t); void snd_hdmi_show_eld(struct hdmi_eld *eld); +void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm, + struct hda_pcm_stream *codec_pars); #ifdef CONFIG_PROC_FS int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 522e074..2bc0f07 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -46,6 +46,7 @@ struct hdmi_spec { * export one pcm per pipe */ struct hda_pcm pcm_rec[MAX_HDMI_CVTS]; + struct hda_pcm_stream codec_pcm_pars[MAX_HDMI_CVTS]; /* * nvhdmi specific @@ -766,6 +767,47 @@ static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, } /* + * HDA PCM callbacks + */ +static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct hdmi_spec *spec = codec->spec; + struct hdmi_eld *eld; + struct hda_pcm_stream *codec_pars; + unsigned int idx; + + for (idx = 0; idx < spec->num_cvts; idx++) + if (hinfo->nid == spec->cvt[idx]) + break; + if (snd_BUG_ON(idx >= spec->num_cvts) || + snd_BUG_ON(idx >= spec->num_pins)) + return -EINVAL; + + /* save the PCM info the codec provides */ + codec_pars = &spec->codec_pcm_pars[idx]; + if (!codec_pars->rates) + *codec_pars = *hinfo; + + eld = &spec->sink_eld[idx]; + if (eld->sad_count > 0) { + hdmi_eld_update_pcm_info(eld, hinfo, codec_pars); + if (hinfo->channels_min > hinfo->channels_max || + !hinfo->rates || !hinfo->formats) + return -ENODEV; + } else { + /* fallback to the codec default */ + hinfo->channels_min = codec_pars->channels_min; + hinfo->channels_max = codec_pars->channels_max; + hinfo->rates = codec_pars->rates; + hinfo->formats = codec_pars->formats; + hinfo->maxbps = codec_pars->maxbps; + } + return 0; +} + +/* * HDA/HDMI auto parsing */ diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c index 5972d5e..d382d3c 100644 --- a/sound/pci/hda/patch_intelhdmi.c +++ b/sound/pci/hda/patch_intelhdmi.c @@ -80,6 +80,7 @@ static struct hda_pcm_stream intel_hdmi_pcm_playback = { .substreams = 1, .channels_min = 2, .ops = { + .open = hdmi_pcm_open, .prepare = intel_hdmi_playback_pcm_prepare, .cleanup = intel_hdmi_playback_pcm_cleanup, }, diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c index 77e2b40..f636870 100644 --- a/sound/pci/hda/patch_nvhdmi.c +++ b/sound/pci/hda/patch_nvhdmi.c @@ -347,10 +347,8 @@ static int nvhdmi_dig_playback_pcm_prepare_2ch(struct hda_pcm_stream *hinfo, static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_89 = { .substreams = 1, .channels_min = 2, - .rates = SUPPORTED_RATES, - .maxbps = SUPPORTED_MAXBPS, - .formats = SUPPORTED_FORMATS, .ops = { + .open = hdmi_pcm_open, .prepare = nvhdmi_dig_playback_pcm_prepare_8ch_89, .cleanup = nvhdmi_playback_pcm_cleanup, }, -- cgit v1.1 From f0cea79724f03ee55e7b5933b6a6f6a3fd177710 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 13 Aug 2010 11:56:53 +0200 Subject: ALSA: hda - Fix dynamic ADC change working again The commit eb541337b7a43822fce7d0c9d967ee149b2d9a96 ALSA: hda - Make converter setups sticky changes the semantics of snd_hda_codec_cleanup_stream() not to clean up the stream at that moment but delay the action. This broke the codes expecting that the clean-up is done immediately, such as dynamic ADC changes in some codec drivers. This patch fixes the issue by introducing a lower helper, __snd_hda_codec_cleanup_stream(), to allow the immediate clean up. The original snd_hda_codec_cleanup_stream() is kept as is now. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 26 ++++++++++++++++++-------- sound/pci/hda/hda_codec.h | 5 ++++- sound/pci/hda/patch_cirrus.c | 2 +- sound/pci/hda/patch_conexant.c | 2 +- sound/pci/hda/patch_realtek.c | 2 +- 5 files changed, 25 insertions(+), 12 deletions(-) (limited to 'sound') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 720a81d..dd8fb86 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1261,12 +1261,17 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, } EXPORT_SYMBOL_HDA(snd_hda_codec_setup_stream); +static void really_cleanup_stream(struct hda_codec *codec, + struct hda_cvt_setup *q); + /** - * snd_hda_codec_cleanup_stream - clean up the codec for closing + * __snd_hda_codec_cleanup_stream - clean up the codec for closing * @codec: the CODEC to clean up * @nid: the NID to clean up + * @do_now: really clean up the stream instead of clearing the active flag */ -void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid) +void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid, + int do_now) { struct hda_cvt_setup *p; @@ -1274,14 +1279,19 @@ void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid) return; snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid); - /* here we just clear the active flag; actual clean-ups will be done - * in purify_inactive_streams() - */ p = get_hda_cvt_setup(codec, nid); - if (p) - p->active = 0; + if (p) { + /* here we just clear the active flag when do_now isn't set; + * actual clean-ups will be done later in + * purify_inactive_streams() called from snd_hda_codec_prpapre() + */ + if (do_now) + really_cleanup_stream(codec, p); + else + p->active = 0; + } } -EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream); +EXPORT_SYMBOL_HDA(__snd_hda_codec_cleanup_stream); static void really_cleanup_stream(struct hda_codec *codec, struct hda_cvt_setup *q) diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 3f7a479..4303353 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -963,7 +963,10 @@ void snd_hda_codec_cleanup(struct hda_codec *codec, void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, int channel_id, int format); -void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid); +void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid, + int do_now); +#define snd_hda_codec_cleanup_stream(codec, nid) \ + __snd_hda_codec_cleanup_stream(codec, nid, 0) unsigned int snd_hda_calc_stream_format(unsigned int rate, unsigned int channels, unsigned int format, diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 350ee8a..4ef5efa 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -656,7 +656,7 @@ static int change_cur_input(struct hda_codec *codec, unsigned int idx, return 0; if (spec->cur_adc && spec->cur_adc != spec->adc_nid[idx]) { /* stream is running, let's swap the current ADC */ - snd_hda_codec_cleanup_stream(codec, spec->cur_adc); + __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); spec->cur_adc = spec->adc_nid[idx]; snd_hda_codec_setup_stream(codec, spec->cur_adc, spec->cur_adc_stream_tag, 0, diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index f7e234e..31b5d9e 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -1733,7 +1733,7 @@ static void cxt5051_portc_automic(struct hda_codec *codec) new_adc = spec->adc_nids[spec->cur_adc_idx]; if (spec->cur_adc && spec->cur_adc != new_adc) { /* stream is running, let's swap the current ADC */ - snd_hda_codec_cleanup_stream(codec, spec->cur_adc); + __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); spec->cur_adc = new_adc; snd_hda_codec_setup_stream(codec, new_adc, spec->cur_adc_stream_tag, 0, diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 55d6e5b..2cd1ae8 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1037,7 +1037,7 @@ static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec) new_adc = spec->adc_nids[spec->cur_adc_idx]; if (spec->cur_adc && spec->cur_adc != new_adc) { /* stream is running, let's swap the current ADC */ - snd_hda_codec_cleanup_stream(codec, spec->cur_adc); + __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); spec->cur_adc = new_adc; snd_hda_codec_setup_stream(codec, new_adc, spec->cur_adc_stream_tag, 0, -- cgit v1.1 From 38d7b08f374b640b00d350ac2d12ffed5d723423 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 14 Aug 2010 19:29:53 +0200 Subject: ALSA: sound/usb/format: silence uninitialized variable warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gcc complains that ret might be used uninitialized: sound/usb/format.c: In function ‘snd_usb_parse_audio_format’: sound/usb/format.c:354: warning: ‘ret’ may be used uninitialized in this function sound/usb/format.c:354: note: ‘ret’ was declared here sound/usb/format.c:414: warning: ‘ret’ may be used uninitialized in this function sound/usb/format.c:414: note: ‘ret’ was declared here I suppose it could be uninitialized if there is ever a UAC_VERSION_3 released. Anyway this patch is worthwhile if only to silence the gcc warning. Signed-off-by: Dan Carpenter Acked-by: Daniel Mack Signed-off-by: Takashi Iwai --- sound/usb/format.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sound') diff --git a/sound/usb/format.c b/sound/usb/format.c index 4387f54..3a13754 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -392,6 +392,10 @@ static int parse_audio_format_i(struct snd_usb_audio *chip, /* fp->channels is already set in this case */ ret = parse_audio_format_rates_v2(chip, fp); break; + default: + snd_printk(KERN_ERR "%d:%u:%d : invalid protocol version %d\n", + chip->dev->devnum, fp->iface, fp->altsetting, protocol); + return -EINVAL; } if (fp->channels < 1) { @@ -452,6 +456,10 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip, ret = parse_audio_format_rates_v2(chip, fp); break; } + default: + snd_printk(KERN_ERR "%d:%u:%d : invalid protocol version %d\n", + chip->dev->devnum, fp->iface, fp->altsetting, protocol); + return -EINVAL; } return ret; -- cgit v1.1 From b2c1e07b81a126e5846dfc3d36f559d861df59f4 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Aug 2010 11:46:57 +0100 Subject: ASoC: Remove DSP mode support for WM8776 This is not supported by current hardware revisions. Signed-off-by: Mark Brown Acked-by: Liam Girdwood Cc: stable@kernel.org --- sound/soc/codecs/wm8776.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c index 4e212ed..f8154e6 100644 --- a/sound/soc/codecs/wm8776.c +++ b/sound/soc/codecs/wm8776.c @@ -178,13 +178,6 @@ static int wm8776_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) case SND_SOC_DAIFMT_LEFT_J: iface |= 0x0001; break; - /* FIXME: CHECK A/B */ - case SND_SOC_DAIFMT_DSP_A: - iface |= 0x0003; - break; - case SND_SOC_DAIFMT_DSP_B: - iface |= 0x0007; - break; default: return -EINVAL; } -- cgit v1.1