]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/pci/ice1712/juli.c
[ARM] 4989/1: [AT91] SAM9 ClockSource / ClockEvents
[linux-2.6-omap-h63xx.git] / sound / pci / ice1712 / juli.c
index 5176b41ea9d37b8e86a1426d2d9b3d70bdb37083..e8038c0ceb721a0f9a3d881814f3bc40dcee34e2 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Lowlevel functions for ESI Juli@ cards
  *
- *     Copyright (c) 2004 Jaroslav Kysela <perex@suse.cz>
+ *     Copyright (c) 2004 Jaroslav Kysela <perex@perex.cz>
  *
  *   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
@@ -21,7 +21,6 @@
  *
  */      
 
-#include <sound/driver.h>
 #include <asm/io.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include "envy24ht.h"
 #include "juli.h"
 
+struct juli_spec {
+       struct ak4114 *ak4114;
+       unsigned int analog: 1;
+};
+
 /*
  * chip addresses on I2C bus
  */
@@ -138,7 +142,17 @@ static struct snd_akm4xxx akm_juli_dac __devinitdata = {
 
 static int __devinit juli_add_controls(struct snd_ice1712 *ice)
 {
-       return snd_ice1712_akm4xxx_build_controls(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(spec->ak4114, NULL,
+                              ice->pcm_pro->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
+       if (err < 0)
+               return err;
+       return 0;
 }
 
 /*
@@ -146,7 +160,7 @@ static int __devinit juli_add_controls(struct snd_ice1712 *ice)
  */
 static int __devinit juli_init(struct snd_ice1712 *ice)
 {
-       static unsigned char ak4114_init_vals[] = {
+       static const unsigned char ak4114_init_vals[] = {
                /* AK4117_REG_PWRDN */  AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
                /* AK4114_REQ_FORMAT */ AK4114_DIF_I24I2S,
                /* AK4114_REG_IO0 */    AK4114_TX1E,
@@ -154,24 +168,23 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
                /* AK4114_REG_INT0_MASK */ 0,
                /* AK4114_REG_INT1_MASK */ 0
        };
-       static unsigned char ak4114_init_txcsb[] = {
+       static const unsigned char ak4114_init_txcsb[] = {
                0x41, 0x02, 0x2c, 0x00, 0x00
        };
        int err;
+       struct juli_spec *spec;
        struct snd_akm4xxx *ak;
 
-#if 0
-       for (err = 0; err < 0x20; err++)
-               juli_ak4114_read(ice, err);
-       juli_ak4114_write(ice, 0, 0x0f);
-       juli_ak4114_read(ice, 0);
-       juli_ak4114_read(ice, 1);
-#endif
+       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;
 
@@ -179,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;
@@ -207,19 +220,19 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
  */
 
 static unsigned char juli_eeprom[] __devinitdata = {
-       0x20,   /* SYSCONF: clock 512, mpu401, 1xADC, 1xDACs */
-       0x80,   /* ACLINK: I2S */
-       0xf8,   /* I2S: vol, 96k, 24bit, 192k */
-       0xc3,   /* SPDIF: out-en, out-int, spdif-in */
-       0x9f,   /* GPIO_DIR */
-       0xff,   /* GPIO_DIR1 */
-       0x7f,   /* GPIO_DIR2 */
-       0x9f,   /* GPIO_MASK */
-       0xff,   /* GPIO_MASK1 */
-       0x7f,   /* GPIO_MASK2 */
-       0x16,   /* GPIO_STATE: internal clock, multiple 1x, 48kHz */
-       0x80,   /* GPIO_STATE1: mute */
-       0x00,   /* GPIO_STATE2 */
+       [ICE_EEP2_SYSCONF]     = 0x20,  /* clock 512, mpu401, 1xADC, 1xDACs */
+       [ICE_EEP2_ACLINK]      = 0x80,  /* I2S */
+       [ICE_EEP2_I2S]         = 0xf8,  /* vol, 96k, 24bit, 192k */
+       [ICE_EEP2_SPDIF]       = 0xc3,  /* out-en, out-int, spdif-in */
+       [ICE_EEP2_GPIO_DIR]    = 0x9f,
+       [ICE_EEP2_GPIO_DIR1]   = 0xff,
+       [ICE_EEP2_GPIO_DIR2]   = 0x7f,
+       [ICE_EEP2_GPIO_MASK]   = 0x9f,
+       [ICE_EEP2_GPIO_MASK1]  = 0xff,
+       [ICE_EEP2_GPIO_MASK2]  = 0x7f,
+       [ICE_EEP2_GPIO_STATE]  = 0x16,  /* internal clock, multiple 1x, 48kHz */
+       [ICE_EEP2_GPIO_STATE1] = 0x80,  /* mute */
+       [ICE_EEP2_GPIO_STATE2] = 0x00,
 };
 
 /* entry point */