diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-31 23:16:28 (GMT) |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-01-31 23:16:28 (GMT) |
commit | e1a9c9872dd004617555dff079b357a6ffd945e9 (patch) | |
tree | c34779e59712ff345f8e4ee97e74086a85b34974 /sound/i2c/other/ak4xxx-adda.c | |
parent | fcc3ff4f9d695a80dc6e6058e0d631a3026ed4c3 (diff) | |
parent | 2ecba4ffbbc6c85fce8c3878514be415edace413 (diff) | |
download | linux-fsl-qoriq-e1a9c9872dd004617555dff079b357a6ffd945e9.tar.xz |
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/perex/alsa
* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/perex/alsa: (299 commits)
[ALSA] version 1.0.16rc2
[ALSA] hda: fix Mic in as output
[ALSA] emu10k1 - Another EMU0404 Board ID
[ALSA] emu10k1 - Fix kthread handling at resume
[ALSA] emu10k1: General cleanup, add new locks, fix alsa bug#3501, kernel bug#9304.
[ALSA] emu10k1 - Use enum for emu_model types
[ALSA] emu10k1 - Don't create emu1010 controls for non-emu boards
[ALSA] emu10k1 - 1616(M) cardbus improvements
[ALSA] snd:emu10k1: E-Mu updates. Fixes to firmware loading and support for 0404.
[ALSA] emu10k1: Add comments regarding E-Mu ins and outs.
[ALSA] oxygen: revert SPI clock frequency change for AK4396/WM8785
[ALSA] es1938 - improve capture hw pointer reads
[ALSA] HDA-Intel - Add support for Intel SCH
[ALSA] hda: Add GPIO mute support to STAC9205
[ALSA] hda-codec - Add Dell T3400 support
[ALSA] hda-codec - Add model for HP DV9553EG laptop
[ALSA] hda-codec - Control SPDIF as slave
[ALSA] hda_intel: ALSA HD Audio patch for Intel ICH10 DeviceID's
[ALSA] Fix Oops with PCM OSS sync
[ALSA] hda-codec - Add speaker automute to ALC262 HP models
...
Diffstat (limited to 'sound/i2c/other/ak4xxx-adda.c')
-rw-r--r-- | sound/i2c/other/ak4xxx-adda.c | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c index de03f68..35fbbf2 100644 --- a/sound/i2c/other/ak4xxx-adda.c +++ b/sound/i2c/other/ak4xxx-adda.c @@ -21,7 +21,6 @@ * */ -#include <sound/driver.h> #include <asm/io.h> #include <linux/delay.h> #include <linux/interrupt.h> @@ -293,6 +292,11 @@ void snd_akm4xxx_init(struct snd_akm4xxx *ak) case SND_AK5365: /* FIXME: any init sequence? */ return; + case NON_AKM: + /* fake value for non-akm codecs using akm infrastructure + * (e.g. of ice1724) - certainly FIXME + */ + return; default: snd_BUG(); return; @@ -377,8 +381,11 @@ static int put_ak_reg(struct snd_kcontrol *kcontrol, int addr, static int snd_akm4xxx_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - return put_ak_reg(kcontrol, AK_GET_ADDR(kcontrol->private_value), - ucontrol->value.integer.value[0]); + unsigned int mask = AK_GET_MASK(kcontrol->private_value); + unsigned int val = ucontrol->value.integer.value[0]; + if (val > mask) + return -EINVAL; + return put_ak_reg(kcontrol, AK_GET_ADDR(kcontrol->private_value), val); } static int snd_akm4xxx_stereo_volume_info(struct snd_kcontrol *kcontrol, @@ -409,11 +416,16 @@ static int snd_akm4xxx_stereo_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int addr = AK_GET_ADDR(kcontrol->private_value); + unsigned int mask = AK_GET_MASK(kcontrol->private_value); + unsigned int val[2]; int change; - change = put_ak_reg(kcontrol, addr, ucontrol->value.integer.value[0]); - change |= put_ak_reg(kcontrol, addr + 1, - ucontrol->value.integer.value[1]); + val[0] = ucontrol->value.integer.value[0]; + val[1] = ucontrol->value.integer.value[1]; + if (val[0] > mask || val[1] > mask) + return -EINVAL; + change = put_ak_reg(kcontrol, addr, val[0]); + change |= put_ak_reg(kcontrol, addr + 1, val[1]); return change; } @@ -508,6 +520,18 @@ static int ak4xxx_switch_put(struct snd_kcontrol *kcontrol, #define AK5365_NUM_INPUTS 5 +static int ak4xxx_capture_num_inputs(struct snd_akm4xxx *ak, int mixer_ch) +{ + int num_names; + const char **input_names; + + input_names = ak->adc_info[mixer_ch].input_names; + num_names = 0; + while (num_names < AK5365_NUM_INPUTS && input_names[num_names]) + ++num_names; + return num_names; +} + static int ak4xxx_capture_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { @@ -516,18 +540,16 @@ static int ak4xxx_capture_source_info(struct snd_kcontrol *kcontrol, const char **input_names; int num_names, idx; - input_names = ak->adc_info[mixer_ch].input_names; - - num_names = 0; - while (num_names < AK5365_NUM_INPUTS && input_names[num_names]) - ++num_names; - + num_names = ak4xxx_capture_num_inputs(ak, mixer_ch); + if (!num_names) + return -EINVAL; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; uinfo->value.enumerated.items = num_names; idx = uinfo->value.enumerated.item; if (idx >= num_names) return -EINVAL; + input_names = ak->adc_info[mixer_ch].input_names; strncpy(uinfo->value.enumerated.name, input_names[idx], sizeof(uinfo->value.enumerated.name)); return 0; @@ -551,10 +573,15 @@ static int ak4xxx_capture_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol); + int mixer_ch = AK_GET_SHIFT(kcontrol->private_value); int chip = AK_GET_CHIP(kcontrol->private_value); int addr = AK_GET_ADDR(kcontrol->private_value); int mask = AK_GET_MASK(kcontrol->private_value); unsigned char oval, val; + int num_names = ak4xxx_capture_num_inputs(ak, mixer_ch); + + if (ucontrol->value.enumerated.item[0] >= num_names) + return -EINVAL; oval = snd_akm4xxx_get(ak, chip, addr); val = oval & ~mask; |