patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / sound / pci / ice1712 / hoontech.c
index cd60f56..6951c1a 100644 (file)
@@ -83,6 +83,7 @@ static void __devinit snd_ice1712_stdsp24_box_channel(ice1712_t *ice, int box, i
                ICE1712_STDSP24_2_CHN4(ice->hoontech_boxbits, 0);
        ICE1712_STDSP24_2_MIDI1(ice->hoontech_boxbits, activate);
        snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[2]);
+       snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[3]);
 
        ICE1712_STDSP24_1_CHN1(ice->hoontech_boxbits, 1);
        ICE1712_STDSP24_1_CHN2(ice->hoontech_boxbits, 1);
@@ -117,7 +118,7 @@ static void __devinit snd_ice1712_stdsp24_box_channel(ice1712_t *ice, int box, i
        up(&ice->gpio_mutex);
 }
 
-static void __devinit snd_ice1712_stdsp24_box_midi(ice1712_t *ice, int box, int master, int slave)
+static void __devinit snd_ice1712_stdsp24_box_midi(ice1712_t *ice, int box, int master)
 {
        down(&ice->gpio_mutex);
 
@@ -128,23 +129,26 @@ static void __devinit snd_ice1712_stdsp24_box_midi(ice1712_t *ice, int box, int
        ICE1712_STDSP24_2_MIDIIN(ice->hoontech_boxbits, 1);
        ICE1712_STDSP24_2_MIDI1(ice->hoontech_boxbits, master);
        snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[2]);
+       snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[3]);
 
        udelay(100);
        
        ICE1712_STDSP24_2_MIDIIN(ice->hoontech_boxbits, 0);
        snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[2]);
        
-       udelay(100);
+       mdelay(10);
        
        ICE1712_STDSP24_2_MIDIIN(ice->hoontech_boxbits, 1);
        snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[2]);
 
-       udelay(100);
+       up(&ice->gpio_mutex);
+}
 
-       /* MIDI2 is direct */
-       ICE1712_STDSP24_3_MIDI2(ice->hoontech_boxbits, slave);
+static void __devinit snd_ice1712_stdsp24_midi2(ice1712_t *ice, int activate)
+{
+       down(&ice->gpio_mutex);
+       ICE1712_STDSP24_3_MIDI2(ice->hoontech_boxbits, activate);
        snd_ice1712_stdsp24_gpio_write(ice, ice->hoontech_boxbits[3]);
-
        up(&ice->gpio_mutex);
 }
 
@@ -204,25 +208,118 @@ static int __devinit snd_ice1712_hoontech_init(ice1712_t *ice)
                for (chn = 0; chn < 4; chn++)
                        snd_ice1712_stdsp24_box_channel(ice, box, chn, (ice->hoontech_boxconfig[box] & (1 << chn)) ? 1 : 0);
                snd_ice1712_stdsp24_box_midi(ice, box,
-                               (ice->hoontech_boxconfig[box] & ICE1712_STDSP24_BOX_MIDI1) ? 1 : 0,
-                               (ice->hoontech_boxconfig[box] & ICE1712_STDSP24_BOX_MIDI2) ? 1 : 0);
+                               (ice->hoontech_boxconfig[box] & ICE1712_STDSP24_BOX_MIDI1) ? 1 : 0);
+               if (ice->hoontech_boxconfig[box] & ICE1712_STDSP24_BOX_MIDI2)
+                       snd_ice1712_stdsp24_midi2(ice, 1);
        }
 
        return 0;
 }
 
+/*
+ * AK4524 access
+ */
+
+/* start callback for STDSP24 with modified hardware */
+static void stdsp24_ak4524_lock(akm4xxx_t *ak, int chip)
+{
+       ice1712_t *ice = ak->private_data[0];
+       unsigned char tmp;
+       snd_ice1712_save_gpio_status(ice);
+       tmp =   ICE1712_STDSP24_SERIAL_DATA |
+               ICE1712_STDSP24_SERIAL_CLOCK |
+               ICE1712_STDSP24_AK4524_CS;
+       snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION,
+                         ice->gpio.direction | tmp);
+       snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~tmp);
+}
+
+static int __devinit snd_ice1712_value_init(ice1712_t *ice)
+{
+       /* Hoontech STDSP24 with modified hardware */
+       static akm4xxx_t akm_stdsp24_mv __devinitdata = {
+               .num_adcs = 2,
+               .num_dacs = 2,
+               .type = SND_AK4524,
+               .ops = {
+                       .lock = stdsp24_ak4524_lock
+               }
+       };
+
+       static struct snd_ak4xxx_private akm_stdsp24_mv_priv __devinitdata = {
+               .caddr = 2,
+               .cif = 1, /* CIF high */
+               .data_mask = ICE1712_STDSP24_SERIAL_DATA,
+               .clk_mask = ICE1712_STDSP24_SERIAL_CLOCK,
+               .cs_mask = ICE1712_STDSP24_AK4524_CS,
+               .cs_addr = ICE1712_STDSP24_AK4524_CS,
+               .cs_none = 0,
+               .add_flags = 0,
+       };
+
+       int err;
+       akm4xxx_t *ak;
+
+       /* set the analog DACs */
+       ice->num_total_dacs = 2;
+
+       /* set the analog ADCs */
+       ice->num_total_adcs = 2;
+       
+       /* analog section */
+       ak = ice->akm = kmalloc(sizeof(akm4xxx_t), GFP_KERNEL);
+       if (! ak)
+               return -ENOMEM;
+       ice->akm_codecs = 1;
+
+       err = snd_ice1712_akm4xxx_init(ak, &akm_stdsp24_mv, &akm_stdsp24_mv_priv, ice);
+       if (err < 0)
+               return err;
+
+       /* ak4524 controls */
+       err = snd_ice1712_akm4xxx_build_controls(ice);
+       if (err < 0)
+               return err;
+
+       return 0;
+}
+
+static int __devinit snd_ice1712_ez8_init(ice1712_t *ice)
+{
+       ice->gpio.write_mask = ice->eeprom.gpiomask;
+       ice->gpio.direction = ice->eeprom.gpiodir;
+       snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ice->eeprom.gpiomask);
+       snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, ice->eeprom.gpiodir);
+       snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, ice->eeprom.gpiostate);
+       return 0;
+}
+
 
 /* entry point */
 struct snd_ice1712_card_info snd_ice1712_hoontech_cards[] __devinitdata = {
        {
-               ICE1712_SUBDEVICE_STDSP24,
-               "Hoontech SoundTrack Audio DSP24",
-               snd_ice1712_hoontech_init,
+               .subvendor = ICE1712_SUBDEVICE_STDSP24,
+               .name = "Hoontech SoundTrack Audio DSP24",
+               .model = "dsp24",
+               .chip_init = snd_ice1712_hoontech_init,
+       },
+       {
+               .subvendor = ICE1712_SUBDEVICE_STDSP24_VALUE,   /* a dummy id */
+               .name = "Hoontech SoundTrack Audio DSP24 Value",
+               .model = "dsp24_value",
+               .chip_init = snd_ice1712_value_init,
+       },
+       {
+               .subvendor = ICE1712_SUBDEVICE_STDSP24_MEDIA7_1,
+               .name = "Hoontech STA DSP24 Media 7.1",
+               .model = "dsp24_71",
+               .chip_init = snd_ice1712_hoontech_init,
        },
        {
-               ICE1712_SUBDEVICE_STDSP24_MEDIA7_1,
-               "Hoontech STA DSP24 Media 7.1",
-               snd_ice1712_hoontech_init,
+               .subvendor = ICE1712_SUBDEVICE_EVENT_EZ8,       /* a dummy id */
+               .name = "Event Electronics EZ8",
+               .model = "ez8",
+               .chip_init = snd_ice1712_ez8_init,
        },
        { } /* terminator */
 };