]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/pci/ice1712/revo.c
[ALSA] ice1724 - Enable AK4114 support for Audiophile192
[linux-2.6-omap-h63xx.git] / sound / pci / ice1712 / revo.c
index 025a7e8497c30cbb44a847a722a04bd264a33213..1d3b1ebf9c9b6e2b76e771182eb2d2b51804c48e 100644 (file)
@@ -21,7 +21,6 @@
  *
  */      
 
-#include <sound/driver.h>
 #include <asm/io.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #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;
+};
+
 static void revo_i2s_mclk_changed(struct snd_ice1712 *ice)
 {
        /* assert PRST# to converters; MT05 bit 7 */
@@ -153,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)
@@ -164,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);
 
@@ -186,7 +196,12 @@ static int revo51_i2c_init(struct snd_ice1712 *ice,
 #define AK_DAC(xname,xch) { .name = xname, .num_channels = xch }
 
 static const struct snd_akm4xxx_dac_channel revo71_front[] = {
-       AK_DAC("PCM Playback Volume", 2)
+       {
+               .name = "PCM Playback Volume",
+               .num_channels = 2,
+               /* front channels DAC supports muting */
+               .switch_name = "PCM Playback Switch",
+       },
 };
 
 static const struct snd_akm4xxx_dac_channel revo71_surround[] = {
@@ -219,7 +234,7 @@ static const struct snd_akm4xxx_adc_channel revo51_adc[] = {
        },
 };
 
-static const struct snd_akm4xxx akm_revo_front __devinitdata = {
+static struct snd_akm4xxx akm_revo_front __devinitdata = {
        .type = SND_AK4381,
        .num_dacs = 2,
        .ops = {
@@ -228,7 +243,7 @@ static const struct snd_akm4xxx akm_revo_front __devinitdata = {
        .dac_info = revo71_front,
 };
 
-static const struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
+static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
        .caddr = 1,
        .cif = 0,
        .data_mask = VT1724_REVO_CDOUT,
@@ -240,7 +255,7 @@ static const struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
        .mask_flags = 0,
 };
 
-static const struct snd_akm4xxx akm_revo_surround __devinitdata = {
+static struct snd_akm4xxx akm_revo_surround __devinitdata = {
        .type = SND_AK4355,
        .idx_offset = 1,
        .num_dacs = 6,
@@ -250,7 +265,7 @@ static const struct snd_akm4xxx akm_revo_surround __devinitdata = {
        .dac_info = revo71_surround,
 };
 
-static const struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
+static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
        .caddr = 3,
        .cif = 0,
        .data_mask = VT1724_REVO_CDOUT,
@@ -262,7 +277,7 @@ static const struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
        .mask_flags = 0,
 };
 
-static const struct snd_akm4xxx akm_revo51 __devinitdata = {
+static struct snd_akm4xxx akm_revo51 __devinitdata = {
        .type = SND_AK4358,
        .num_dacs = 6,
        .ops = {
@@ -271,7 +286,7 @@ static const struct snd_akm4xxx akm_revo51 __devinitdata = {
        .dac_info = revo51_dac,
 };
 
-static const struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
+static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
        .caddr = 2,
        .cif = 0,
        .data_mask = VT1724_REVO_CDOUT,
@@ -283,13 +298,13 @@ static const struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
        .mask_flags = 0,
 };
 
-static const struct snd_akm4xxx akm_revo51_adc __devinitdata = {
+static struct snd_akm4xxx akm_revo51_adc __devinitdata = {
        .type = SND_AK5365,
        .num_adcs = 2,
        .adc_info = revo51_adc,
 };
 
-static const struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = {
+static struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = {
        .caddr = 2,
        .cif = 0,
        .data_mask = VT1724_REVO_CDOUT,
@@ -324,7 +339,7 @@ static const struct snd_akm4xxx_dac_channel ap192_dac[] = {
        AK_DAC("PCM Playback Volume", 2)
 };
 
-static const struct snd_akm4xxx akm_ap192 __devinitdata = {
+static struct snd_akm4xxx akm_ap192 __devinitdata = {
        .type = SND_AK4358,
        .num_dacs = 2,
        .ops = {
@@ -333,33 +348,25 @@ static const struct snd_akm4xxx akm_ap192 __devinitdata = {
        .dac_info = ap192_dac,
 };
 
-static const struct snd_ak4xxx_private akm_ap192_priv __devinitdata = {
+static struct snd_ak4xxx_private akm_ap192_priv __devinitdata = {
        .caddr = 2,
        .cif = 0,
        .data_mask = VT1724_REVO_CDOUT,
        .clk_mask = VT1724_REVO_CCLK,
-       .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS3,
-       .cs_addr = VT1724_REVO_CS3,
-       .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS3,
+       .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1,
+       .cs_addr = VT1724_REVO_CS1,
+       .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1,
        .add_flags = VT1724_REVO_CCLK, /* high at init */
        .mask_flags = 0,
 };
 
-#if 0
-/* FIXME: ak4114 makes the sound much lower due to some confliction,
- *        so let's disable it right now...
- */
-#define BUILD_AK4114_AP192
-#endif
-
-#ifdef BUILD_AK4114_AP192
 /* AK4114 support on Audiophile 192 */
 /* CDTO (pin 32) -- GPIO2 pin 52
  * CDTI (pin 33) -- GPIO3 pin 53 (shared with AK4358)
  * CCLK (pin 34) -- GPIO1 pin 51 (shared with AK4358)
  * CSN  (pin 35) -- GPIO7 pin 59
  */
-#define AK4114_ADDR    0x00
+#define AK4114_ADDR    0x02
 
 static void write_data(struct snd_ice1712 *ice, unsigned int gpio,
                       unsigned int data, int idx)
@@ -405,7 +412,7 @@ static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio,
        return data;
 }
 
-static unsigned char ap192_4wire_start(struct snd_ice1712 *ice)
+static unsigned int ap192_4wire_start(struct snd_ice1712 *ice)
 {
        unsigned int tmp;
 
@@ -413,7 +420,7 @@ static unsigned char ap192_4wire_start(struct snd_ice1712 *ice)
        tmp = snd_ice1712_gpio_read(ice);
        tmp |= VT1724_REVO_CCLK; /* high at init */
        tmp |= VT1724_REVO_CS0;
-       tmp &= ~VT1724_REVO_CS3;
+       tmp &= ~VT1724_REVO_CS1;
        snd_ice1712_gpio_write(ice, tmp);
        udelay(1);
        return tmp;
@@ -421,7 +428,7 @@ static unsigned char ap192_4wire_start(struct snd_ice1712 *ice)
 
 static void ap192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp)
 {
-       tmp |= VT1724_REVO_CS3;
+       tmp |= VT1724_REVO_CS1;
        tmp |= VT1724_REVO_CS0;
        snd_ice1712_gpio_write(ice, tmp);
        udelay(1);
@@ -454,7 +461,7 @@ static unsigned char ap192_ak4114_read(void *private_data, unsigned char addr)
        return data;
 }
 
-static int ap192_ak4114_init(struct snd_ice1712 *ice)
+static int __devinit ap192_ak4114_init(struct snd_ice1712 *ice)
 {
        static const unsigned char ak4114_init_vals[] = {
                AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
@@ -470,13 +477,13 @@ static int ap192_ak4114_init(struct snd_ice1712 *ice)
        struct ak4114 *ak;
        int err;
 
-       return snd_ak4114_create(ice->card,
+       err = snd_ak4114_create(ice->card,
                                 ap192_ak4114_read,
                                 ap192_ak4114_write,
                                 ak4114_init_vals, ak4114_init_txcsb,
                                 ice, &ak);
+       return 0; /* error ignored; it's no fatal error */
 }
-#endif /* BUILD_AK4114_AP192 */
 
 static int __devinit revo_init(struct snd_ice1712 *ice)
 {
@@ -551,6 +558,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) {
@@ -563,7 +571,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;
@@ -571,18 +580,16 @@ static int __devinit revo_add_controls(struct snd_ice1712 *ice)
                err = snd_ice1712_akm4xxx_build_controls(ice);
                if (err < 0)
                        return err;
-#ifdef BUILD_AK4114_AP192
                err = ap192_ak4114_init(ice);
                if (err < 0)
                        return err;
-#endif
                break;
        }
        return 0;
 }
 
 /* entry point */
-const struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = {
+struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = {
        {
                .subvendor = VT1724_SUBDEVICE_REVOLUTION71,
                .name = "M Audio Revolution-7.1",