Commit 7cda8ba9 authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] ice1712, ice1724 - Code clean up

Clean up ice1712/ice1724 codes.  The board-specific data is allocated
locally in each code instead of having an ungly union in struct ice1712.
Also, fix coding issues in prodigy_hifi.c.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent 797760ab
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2490,6 +2490,7 @@ static int snd_ice1712_free(struct snd_ice1712 *ice)
pci_release_regions(ice->pci);
snd_ice1712_akm4xxx_free(ice);
pci_disable_device(ice->pci);
kfree(ice->spec);
kfree(ice);
return 0;
}
......
......@@ -366,56 +366,7 @@ struct snd_ice1712 {
struct mutex gpio_mutex;
/* other board-specific data */
union {
/* additional i2c devices for EWS boards */
struct snd_i2c_device *i2cdevs[3];
/* AC97 register cache for Aureon */
struct aureon_spec {
unsigned short stac9744[64];
unsigned int cs8415_mux;
unsigned short master[2];
unsigned short vol[8];
unsigned char pca9554_out;
} aureon;
/* AC97 register cache for Phase28 */
struct phase28_spec {
unsigned short master[2];
unsigned short vol[8];
} phase28;
/* a non-standard I2C device for revo51 */
struct revo51_spec {
struct snd_i2c_device *dev;
struct snd_pt2258 *pt2258;
} revo51;
/* Hoontech-specific setting */
struct hoontech_spec {
unsigned char boxbits[4];
unsigned int config;
unsigned short boxconfig[4];
} hoontech;
struct {
struct ak4114 *ak4114;
unsigned int analog: 1;
} juli;
struct {
struct ak4114 *ak4114;
/* rate change needs atomic mute/unmute of all dacs*/
struct mutex mute_mutex;
} prodigy192;
struct {
struct {
unsigned char ch1, ch2;
} vol[8];
} se;
struct prodigy_hifi_spec {
unsigned short master[2];
unsigned short vol[8];
} prodigy_hifi;
struct prodigy_hd2_spec {
unsigned short vol[2];
} prodigy_hd2;
} spec;
void *spec;
};
......
......@@ -2176,6 +2176,7 @@ static int snd_vt1724_free(struct snd_ice1712 *ice)
pci_release_regions(ice->pci);
snd_ice1712_akm4xxx_free(ice);
pci_disable_device(ice->pci);
kfree(ice->spec);
kfree(ice);
return 0;
}
......
......@@ -32,6 +32,11 @@
#include "envy24ht.h"
#include "juli.h"
struct juli_spec {
struct ak4114 *ak4114;
unsigned int analog: 1;
};
/*
* chip addresses on I2C bus
*/
......@@ -137,12 +142,13 @@ static struct snd_akm4xxx akm_juli_dac __devinitdata = {
static int __devinit juli_add_controls(struct snd_ice1712 *ice)
{
struct juli_spec *spec = ice->spec;
int err;
err = snd_ice1712_akm4xxx_build_controls(ice);
if (err < 0)
return err;
/* only capture SPDIF over AK4114 */
err = snd_ak4114_build(ice->spec.juli.ak4114, NULL,
err = snd_ak4114_build(spec->ak4114, NULL,
ice->pcm_pro->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
if (err < 0)
return err;
......@@ -166,13 +172,19 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
0x41, 0x02, 0x2c, 0x00, 0x00
};
int err;
struct juli_spec *spec;
struct snd_akm4xxx *ak;
spec = kzalloc(sizeof(*spec), GFP_KERNEL);
if (!spec)
return -ENOMEM;
ice->spec = spec;
err = snd_ak4114_create(ice->card,
juli_ak4114_read,
juli_ak4114_write,
ak4114_init_vals, ak4114_init_txcsb,
ice, &ice->spec.juli.ak4114);
ice, &spec->ak4114);
if (err < 0)
return err;
......@@ -180,12 +192,12 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
/* it seems that the analog doughter board detection does not work
reliably, so force the analog flag; it should be very rare
to use Juli@ without the analog doughter board */
ice->spec.juli.analog = (ice->gpio.get_data(ice) & GPIO_ANALOG_PRESENT) ? 0 : 1;
spec->analog = (ice->gpio.get_data(ice) & GPIO_ANALOG_PRESENT) ? 0 : 1;
#else
ice->spec.juli.analog = 1;
spec->analog = 1;
#endif
if (ice->spec.juli.analog) {
if (spec->analog) {
printk(KERN_INFO "juli@: analog I/O detected\n");
ice->num_total_dacs = 2;
ice->num_total_adcs = 2;
......
......@@ -47,6 +47,12 @@
#include "phase.h"
#include <sound/tlv.h>
/* AC97 register cache for Phase28 */
struct phase28_spec {
unsigned short master[2];
unsigned short vol[8];
} phase28;
/* WM8770 registers */
#define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */
#define WM_DAC_MASTER_ATTEN 0x08 /* DAC master analog attenuation */
......@@ -312,15 +318,17 @@ static int wm_master_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
static int wm_master_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
struct phase28_spec *spec = ice->spec;
int i;
for (i=0; i<2; i++)
ucontrol->value.integer.value[i] = ice->spec.phase28.master[i] & ~WM_VOL_MUTE;
ucontrol->value.integer.value[i] = spec->master[i] & ~WM_VOL_MUTE;
return 0;
}
static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
struct phase28_spec *spec = ice->spec;
int ch, change = 0;
snd_ice1712_save_gpio_status(ice);
......@@ -328,14 +336,14 @@ static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
unsigned int vol = ucontrol->value.integer.value[ch];
if (vol > WM_VOL_MAX)
continue;
vol |= ice->spec.phase28.master[ch] & WM_VOL_MUTE;
if (vol != ice->spec.phase28.master[ch]) {
vol |= spec->master[ch] & WM_VOL_MUTE;
if (vol != spec->master[ch]) {
int dac;
ice->spec.phase28.master[ch] = vol;
spec->master[ch] = vol;
for (dac = 0; dac < ice->num_total_dacs; dac += 2)
wm_set_vol(ice, WM_DAC_ATTEN + dac + ch,
ice->spec.phase28.vol[dac + ch],
ice->spec.phase28.master[ch]);
spec->vol[dac + ch],
spec->master[ch]);
change = 1;
}
}
......@@ -384,12 +392,18 @@ static int __devinit phase28_init(struct snd_ice1712 *ice)
unsigned int tmp;
struct snd_akm4xxx *ak;
struct phase28_spec *spec;
const unsigned short *p;
int i;
ice->num_total_dacs = 8;
ice->num_total_adcs = 2;
spec = kzalloc(sizeof(*spec), GFP_KERNEL);
if (!spec)
return -ENOMEM;
ice->spec = spec;
// Initialize analog chips
ak = ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
if (!ak)
......@@ -419,11 +433,11 @@ static int __devinit phase28_init(struct snd_ice1712 *ice)
snd_ice1712_restore_gpio_status(ice);
ice->spec.phase28.master[0] = WM_VOL_MUTE;
ice->spec.phase28.master[1] = WM_VOL_MUTE;
spec->master[0] = WM_VOL_MUTE;
spec->master[1] = WM_VOL_MUTE;
for (i = 0; i < ice->num_total_dacs; i++) {
ice->spec.phase28.vol[i] = WM_VOL_MUTE;
wm_set_vol(ice, i, ice->spec.phase28.vol[i], ice->spec.phase28.master[i % 2]);
spec->vol[i] = WM_VOL_MUTE;
wm_set_vol(ice, i, spec->vol[i], spec->master[i % 2]);
}
return 0;
......@@ -445,18 +459,21 @@ static int wm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *
static int wm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
struct phase28_spec *spec = ice->spec;
int i, ofs, voices;
voices = kcontrol->private_value >> 8;
ofs = kcontrol->private_value & 0xff;
for (i = 0; i < voices; i++)
ucontrol->value.integer.value[i] = ice->spec.phase28.vol[ofs+i] & ~WM_VOL_MUTE;
ucontrol->value.integer.value[i] =
spec->vol[ofs+i] & ~WM_VOL_MUTE;
return 0;
}
static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
struct phase28_spec *spec = ice->spec;
int i, idx, ofs, voices;
int change = 0;
......@@ -468,12 +485,12 @@ static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *
vol = ucontrol->value.integer.value[i];
if (vol > 0x7f)
continue;
vol |= ice->spec.phase28.vol[ofs+i] & WM_VOL_MUTE;
if (vol != ice->spec.phase28.vol[ofs+i]) {
ice->spec.phase28.vol[ofs+i] = vol;
vol |= spec->vol[ofs+i] & WM_VOL_MUTE;
if (vol != spec->vol[ofs+i]) {
spec->vol[ofs+i] = vol;
idx = WM_DAC_ATTEN + ofs + i;
wm_set_vol(ice, idx, ice->spec.phase28.vol[ofs+i],
ice->spec.phase28.master[i]);
wm_set_vol(ice, idx, spec->vol[ofs+i],
spec->master[i]);
change = 1;
}
}
......@@ -495,19 +512,22 @@ static int wm_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info
static int wm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
struct phase28_spec *spec = ice->spec;
int voices, ofs, i;
voices = kcontrol->private_value >> 8;
ofs = kcontrol->private_value & 0xFF;
for (i = 0; i < voices; i++)
ucontrol->value.integer.value[i] = (ice->spec.phase28.vol[ofs+i] & WM_VOL_MUTE) ? 0 : 1;
ucontrol->value.integer.value[i] =
(spec->vol[ofs+i] & WM_VOL_MUTE) ? 0 : 1;
return 0;
}
static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
struct phase28_spec *spec = ice->spec;
int change = 0, voices, ofs, i;
voices = kcontrol->private_value >> 8;
......@@ -515,13 +535,13 @@ static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
snd_ice1712_save_gpio_status(ice);
for (i = 0; i < voices; i++) {
int val = (ice->spec.phase28.vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1;
int val = (spec->vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1;
if (ucontrol->value.integer.value[i] != val) {
ice->spec.phase28.vol[ofs + i] &= ~WM_VOL_MUTE;
ice->spec.phase28.vol[ofs + i] |=
spec->vol[ofs + i] &= ~WM_VOL_MUTE;
spec->vol[ofs + i] |=
ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
wm_set_vol(ice, ofs + i, ice->spec.phase28.vol[ofs + i],
ice->spec.phase28.master[i]);
wm_set_vol(ice, ofs + i, spec->vol[ofs + i],
spec->master[i]);
change = 1;
}
}
......@@ -538,29 +558,33 @@ static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
static int wm_master_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
struct phase28_spec *spec = ice->spec;
ucontrol->value.integer.value[0] = (ice->spec.phase28.master[0] & WM_VOL_MUTE) ? 0 : 1;
ucontrol->value.integer.value[1] = (ice->spec.phase28.master[1] & WM_VOL_MUTE) ? 0 : 1;
ucontrol->value.integer.value[0] =
(spec->master[0] & WM_VOL_MUTE) ? 0 : 1;
ucontrol->value.integer.value[1] =
(spec->master[1] & WM_VOL_MUTE) ? 0 : 1;
return 0;
}
static int wm_master_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
struct phase28_spec *spec = ice->spec;
int change = 0, i;
snd_ice1712_save_gpio_status(ice);
for (i = 0; i < 2; i++) {
int val = (ice->spec.phase28.master[i] & WM_VOL_MUTE) ? 0 : 1;
int val = (spec->master[i] & WM_VOL_MUTE) ? 0 : 1;
if (ucontrol->value.integer.value[i] != val) {
int dac;
ice->spec.phase28.master[i] &= ~WM_VOL_MUTE;
ice->spec.phase28.master[i] |=
spec->master[i] &= ~WM_VOL_MUTE;
spec->master[i] |=
ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
for (dac = 0; dac < ice->num_total_dacs; dac += 2)
wm_set_vol(ice, WM_DAC_ATTEN + dac + i,
ice->spec.phase28.vol[dac + i],
ice->spec.phase28.master[i]);
spec->vol[dac + i],
spec->master[i]);
change = 1;
}
}
......
......@@ -67,6 +67,12 @@
#include "stac946x.h"
#include <sound/tlv.h>
struct prodigy192_spec {
struct ak4114 *ak4114;
/* rate change needs atomic mute/unmute of all dacs*/
struct mutex mute_mutex;
};
static inline void stac9460_put(struct snd_ice1712 *ice, int reg, unsigned char val)
{
snd_vt1724_write_i2c(ice, PRODIGY192_STAC9460_ADDR, reg, val);
......@@ -118,6 +124,7 @@ static int stac9460_dac_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
static int stac9460_dac_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
struct prodigy192_spec *spec = ice->spec;
int idx, change;
if (kcontrol->private_value)
......@@ -125,11 +132,11 @@ static int stac9460_dac_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
else
idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + STAC946X_LF_VOLUME;
/* due to possible conflicts with stac9460_set_rate_val, mutexing */
mutex_lock(&ice->spec.prodigy192.mute_mutex);
mutex_lock(&spec->mute_mutex);
/*printk("Mute put: reg 0x%02x, ctrl value: 0x%02x\n", idx,
ucontrol->value.integer.value[0]);*/
change = stac9460_dac_mute(ice, idx, ucontrol->value.integer.value[0]);
mutex_unlock(&ice->spec.prodigy192.mute_mutex);
mutex_unlock(&spec->mute_mutex);
return change;
}
......@@ -318,6 +325,7 @@ static void stac9460_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
int idx;
unsigned char changed[7];
struct snd_ice1712 *ice = ak->private_data[0];
struct prodigy192_spec *spec = ice->spec;
if (rate == 0) /* no hint - S/PDIF input is master, simply return */
return;
......@@ -332,7 +340,7 @@ static void stac9460_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
return;
/* change detected, setting master clock, muting first */
/* due to possible conflicts with mute controls - mutexing */
mutex_lock(&ice->spec.prodigy192.mute_mutex);
mutex_lock(&spec->mute_mutex);
/* we have to remember current mute status for each DAC */
for (idx = 0; idx < 7 ; ++idx)
changed[idx] = stac9460_dac_mute(ice,
......@@ -346,7 +354,7 @@ static void stac9460_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
if (changed[idx])
stac9460_dac_mute(ice, STAC946X_MASTER_VOLUME + idx, 1);
}
mutex_unlock(&ice->spec.prodigy192.mute_mutex);
mutex_unlock(&spec->mute_mutex);
}
/* using akm infrastructure for setting rate of the codec */
......@@ -633,12 +641,13 @@ static int prodigy192_ak4114_init(struct snd_ice1712 *ice)
static const unsigned char ak4114_init_txcsb[] = {
0x41, 0x02, 0x2c, 0x00, 0x00
};
struct prodigy192_spec *spec = ice->spec;
return snd_ak4114_create(ice->card,
prodigy192_ak4114_read,
prodigy192_ak4114_write,
ak4114_init_vals, ak4114_init_txcsb,
ice, &ice->spec.prodigy192.ak4114);
ice, &spec->ak4114);
}
static void stac9460_proc_regs_read(struct snd_info_entry *entry,
......@@ -664,6 +673,7 @@ static void stac9460_proc_init(struct snd_ice1712 *ice)
static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice)
{
struct prodigy192_spec *spec = ice->spec;
unsigned int i;
int err;
......@@ -673,7 +683,7 @@ static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice)
if (err < 0)
return err;
}
if (ice->spec.prodigy192.ak4114) {
if (spec->ak4114) {
/* ak4114 is connected */
for (i = 0; i < ARRAY_SIZE(ak4114_controls); i++) {
err = snd_ctl_add(ice->card,
......@@ -682,7 +692,7 @@ static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice)
if (err < 0)
return err;
}
err = snd_ak4114_build(ice->spec.prodigy192.ak4114,
err = snd_ak4114_build(spec->ak4114,
NULL, /* ak4114 in MIO/DI/O handles no IEC958 output */
ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
if (err < 0)
......@@ -734,12 +744,19 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
const unsigned short *p;
int err = 0;
struct snd_akm4xxx *ak;
struct prodigy192_spec *spec;
/* prodigy 192 */
ice->num_total_dacs = 6;
ice->num_total_adcs = 2;
ice->vt1720 = 0; /* ice1724, e.g. 23 GPIOs */
spec = kzalloc(sizeof(*spec), GFP_KERNEL);
if (!spec)
return -ENOMEM;
ice->spec = spec;
mutex_init(&spec->mute_mutex);
/* initialize codec */
p = stac_inits_prodigy;
for (; *p != (unsigned short)-1; p += 2)
......@@ -758,7 +775,7 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
if (prodigy192_miodio_exists(ice)) {
err = prodigy192_ak4114_init(ice);
/* from this moment if err = 0 then
* ice->spec.prodigy192.ak4114 should not be null
* spec->ak4114 should not be null
*/
snd_printdd("AK4114 initialized with status %d\n", err);
} else
......@@ -766,8 +783,6 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
if (err < 0)
return err;
mutex_init(&ice->spec.prodigy192.mute_mutex);
return 0;
}
......
This diff is collapsed.
......@@ -32,6 +32,12 @@
#include "envy24ht.h"
#include "revo.h"
/* a non-standard I2C device for revo51 */
struct revo51_spec {
struct snd_i2c_device *dev;
struct snd_pt2258 *pt2258;
} revo51;
static void revo_i2s_mclk_changed(struct snd_ice1712 *ice)
{
/* assert PRST# to converters; MT05 bit 7 */
......@@ -152,8 +158,14 @@ static struct snd_i2c_bit_ops revo51_bit_ops = {
static int revo51_i2c_init(struct snd_ice1712 *ice,
struct snd_pt2258 *pt)
{
struct revo51_spec *spec;
int err;
spec = kzalloc(sizeof(*spec), GFP_KERNEL);
if (!spec)
return -ENOMEM;
ice->spec = spec;
/* create the I2C bus */
err = snd_i2c_bus_create(ice->card, "ICE1724 GPIO6", NULL, &ice->i2c);
if (err < 0)
......@@ -163,15 +175,14 @@ static int revo51_i2c_init(struct snd_ice1712 *ice,
ice->i2c->hw_ops.bit = &revo51_bit_ops;
/* create the I2C device */
err = snd_i2c_device_create(ice->i2c, "PT2258", 0x40,
&ice->spec.revo51.dev);
err = snd_i2c_device_create(ice->i2c, "PT2258", 0x40, &spec->dev);
if (err < 0)
return err;
pt->card = ice->card;
pt->i2c_bus = ice->i2c;
pt->i2c_dev = ice->spec.revo51.dev;
ice->spec.revo51.pt2258 = pt;
pt->i2c_dev = spec->dev;
spec->pt2258 = pt;
snd_pt2258_reset(pt);
......@@ -555,6 +566,7 @@ static int __devinit revo_init(struct snd_ice1712 *ice)
static int __devinit revo_add_controls(struct snd_ice1712 *ice)
{
struct revo51_spec *spec;
int err;
switch (ice->eeprom.subvendor) {
......@@ -567,7 +579,8 @@ static int __devinit revo_add_controls(struct snd_ice1712 *ice)
err = snd_ice1712_akm4xxx_build_controls(ice);
if (err < 0)
return err;
err = snd_pt2258_build_controls(ice->spec.revo51.pt2258);
spec = ice->spec;
err = snd_pt2258_build_controls(spec->pt2258);
if (err < 0)
return err;
break;
......
......@@ -34,6 +34,11 @@
#include "envy24ht.h"
#include "se.h"
struct se_spec {
struct {
unsigned char ch1, ch2;
} vol[8];
};
/****************************************************************************/
/* ONKYO WAVIO SE-200PCI */
......@@ -462,9 +467,10 @@ static int se200pci_cont_volume_get(struct snd_kcontrol *kc,
struct snd_ctl_elem_value *uc)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
struct se_spec *spec = ice->spec;
int n = kc->private_value;
uc->value.integer.value[0] = ice->spec.se.vol[n].ch1;
uc->value.integer.value[1] = ice->spec.se.vol[n].ch2;
uc->value.integer.value[0] = spec->vol[n].ch1;
uc->value.integer.value[1] = spec->vol[n].ch2;
return 0;
}
......@@ -472,8 +478,9 @@ static int se200pci_cont_boolean_get(struct snd_kcontrol *kc,
struct snd_ctl_elem_value *uc)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
struct se_spec *spec = ice->spec;
int n = kc->private_value;
uc->value.integer.value[0] = ice->spec.se.vol[n].ch1;
uc->value.integer.value[0] = spec->vol[n].ch1;
return 0;
}
......@@ -481,44 +488,46 @@ static int se200pci_cont_enum_get(struct snd_kcontrol *kc,
struct snd_ctl_elem_value *uc)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
struct se_spec *spec = ice->spec;
int n = kc->private_value;
uc->value.enumerated.item[0] = ice->spec.se.vol[n].ch1;
uc->value.enumerated.item[0] = spec->vol[n].ch1;
return 0;
}
static void se200pci_cont_update(struct snd_ice1712 *ice, int n)
{
struct se_spec *spec = ice->spec;
switch (se200pci_cont[n].target) {
case WM8766:
se200pci_WM8766_set_volume(ice,
se200pci_cont[n].ch,
ice->spec.se.vol[n].ch1,
ice->spec.se.vol[n].ch2);
spec->vol[n].ch1,
spec->vol[n].ch2);
break;
case WM8776in:
se200pci_WM8776_set_input_volume(ice,
ice->spec.se.vol[n].ch1,
ice->spec.se.vol[n].ch2);
spec->vol[n].ch1,
spec->vol[n].ch2);
break;
case WM8776out:
se200pci_WM8776_set_output_volume(ice,
ice->spec.se.vol[n].ch1,
ice->spec.se.vol[n].ch2);
spec->vol[n].ch1,
spec->vol[n].ch2);
break;
case WM8776sel:
se200pci_WM8776_set_input_selector(ice,
ice->spec.se.vol[n].ch1);
spec->vol[n].ch1);
break;
case WM8776agc:
se200pci_WM8776_set_agc(ice, ice->spec.se.vol[n].ch1);
se200pci_WM8776_set_agc(ice, spec->vol[n].ch1);
break;
case WM8776afl:
se200pci_WM8776_set_afl(ice, ice->spec.se.vol[n].ch1);
se200pci_WM8776_set_afl(ice, spec->vol[n].ch1);
break;
default:
......@@ -530,6 +539,7 @@ static int se200pci_cont_volume_put(struct snd_kcontrol *kc,
struct snd_ctl_elem_value *uc)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
struct se_spec *spec = ice->spec;
int n = kc->private_value;
unsigned int vol1, vol2;
int changed;
......@@ -537,12 +547,12 @@ static int se200pci_cont_volume_put(struct snd_kcontrol *kc,
changed = 0;
vol1 = uc->value.integer.value[0] & 0xff;
vol2 = uc->value.integer.value[1] & 0xff;
if (ice->spec.se.vol[n].ch1 != vol1) {
ice->spec.se.vol[n].ch1 = vol1;
if (spec->vol[n].ch1 != vol1) {
spec->vol[n].ch1 = vol1;
changed = 1;
}
if (ice->spec.se.vol[n].ch2 != vol2) {
ice->spec.se.vol[n].ch2 = vol2;
if (spec->vol[n].ch2 != vol2) {
spec->vol[n].ch2 = vol2;
changed = 1;
}
if (changed)
......@@ -555,12 +565,13 @@ static int se200pci_cont_boolean_put(struct snd_kcontrol *kc,
struct snd_ctl_elem_value *uc)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
struct se_spec *spec = ice->spec;
int n = kc->private_value;
unsigned int vol1;
vol1 = !!uc->value.integer.value[0];
if (ice->spec.se.vol[n].ch1 != vol1) {
ice->spec.se.vol[n].ch1 = vol1;
if (spec->vol[n].ch1 != vol1) {
spec->vol[n].ch1 = vol1;
se200pci_cont_update(ice, n);
return 1;
}
......@@ -571,14 +582,15 @@ static int se200pci_cont_enum_put(struct snd_kcontrol *kc,
struct snd_ctl_elem_value *uc)
{
struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
struct se_spec *spec = ice->spec;
int n = kc->private_value;
unsigned int vol1;
vol1 = uc->value.enumerated.item[0];
if (vol1 >= se200pci_get_enum_count(n))
return -EINVAL;
if (ice->spec.se.vol[n].ch1 != vol1) {
ice->spec.se.vol[n].ch1 = vol1;
if (spec->vol[n].ch1 != vol1) {
spec->vol[n].ch1 = vol1;
se200pci_cont_update(ice, n);
return 1;
}
......@@ -668,6 +680,13 @@ static int __devinit se200pci_add_controls(struct snd_ice1712 *ice)
static int __devinit se_init(struct snd_ice1712 *ice)
{
struct se_spec *spec;
spec = kzalloc(sizeof(*spec), GFP_KERNEL);
if (!spec)
return -ENOMEM;
ice->spec = spec;
if (ice->eeprom.subvendor == VT1724_SUBDEVICE_SE90PCI) {
ice->num_total_dacs = 2;
ice->num_total_adcs = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment