aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/emu10k1
diff options
context:
space:
mode:
authorJames Courtier-Dutton <James@superbug.co.uk>2007-07-26 13:31:39 -0400
committerJaroslav Kysela <perex@perex.cz>2007-10-16 09:58:03 -0400
commitf93abe51e8dc7e929d29e6a9a1991bf7fd234d4a (patch)
treee23ba606e72d14b59297a8d2937d1b76f34e5e2a /sound/pci/emu10k1
parent95a5b0850a96c155f6b8dac03f45c19bc482ced7 (diff)
[ALSA] snd-emu10k1:Implement SPDIF/ADAT status.
Signed-off-by: James Courtier-Dutton <James@superbug.co.uk> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/emu10k1')
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c10
-rw-r--r--sound/pci/emu10k1/emuproc.c48
-rw-r--r--sound/pci/emu10k1/io.c10
3 files changed, 53 insertions, 15 deletions
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index b985e660c60b..e22bb717e96a 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -873,7 +873,15 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
873 snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg); 873 snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg);
874 snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp ); 874 snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp );
875 /* Optical -> ADAT I/O */ 875 /* Optical -> ADAT I/O */
876 snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, EMU_HANA_OPTICAL_IN_ADAT | EMU_HANA_OPTICAL_OUT_ADAT ); 876 /* 0 : SPDIF
877 * 1 : ADAT
878 */
879 emu->emu1010.optical_in = 1; /* IN_ADAT */
880 emu->emu1010.optical_out = 1; /* IN_ADAT */
881 tmp = 0;
882 tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : 0) |
883 (emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : 0);
884 snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, tmp );
877 snd_emu1010_fpga_read(emu, EMU_HANA_ADC_PADS, &tmp ); 885 snd_emu1010_fpga_read(emu, EMU_HANA_ADC_PADS, &tmp );
878 /* Set no attenuation on Audio Dock pads. */ 886 /* Set no attenuation on Audio Dock pads. */
879 snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, 0x00 ); 887 snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, 0x00 );
diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c
index a0dae0d916cb..3e2ed1d9d5fe 100644
--- a/sound/pci/emu10k1/emuproc.c
+++ b/sound/pci/emu10k1/emuproc.c
@@ -240,8 +240,42 @@ static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry,
240 struct snd_info_buffer *buffer) 240 struct snd_info_buffer *buffer)
241{ 241{
242 struct snd_emu10k1 *emu = entry->private_data; 242 struct snd_emu10k1 *emu = entry->private_data;
243 snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS); 243 u32 value;
244 snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS); 244 u32 value2;
245 unsigned long flags;
246 u32 rate;
247
248 if (emu->card_capabilities->emu1010) {
249 spin_lock_irqsave(&emu->emu_lock, flags);
250 snd_emu1010_fpga_read(emu, 0x38, &value);
251 spin_unlock_irqrestore(&emu->emu_lock, flags);
252 if ((value & 0x1) == 0) {
253 spin_lock_irqsave(&emu->emu_lock, flags);
254 snd_emu1010_fpga_read(emu, 0x2a, &value);
255 snd_emu1010_fpga_read(emu, 0x2b, &value2);
256 spin_unlock_irqrestore(&emu->emu_lock, flags);
257 rate = 0x1770000 / (((value << 5) | value2)+1);
258 snd_iprintf(buffer, "ADAT Locked : %u\n", rate);
259 } else {
260 snd_iprintf(buffer, "ADAT Unlocked\n");
261 }
262 spin_lock_irqsave(&emu->emu_lock, flags);
263 snd_emu1010_fpga_read(emu, 0x20, &value);
264 spin_unlock_irqrestore(&emu->emu_lock, flags);
265 if ((value & 0x4) == 0) {
266 spin_lock_irqsave(&emu->emu_lock, flags);
267 snd_emu1010_fpga_read(emu, 0x28, &value);
268 snd_emu1010_fpga_read(emu, 0x29, &value2);
269 spin_unlock_irqrestore(&emu->emu_lock, flags);
270 rate = 0x1770000 / (((value << 5) | value2)+1);
271 snd_iprintf(buffer, "SPDIF Locked : %d\n", rate);
272 } else {
273 snd_iprintf(buffer, "SPDIF Unlocked\n");
274 }
275 } else {
276 snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS);
277 snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS);
278 }
245#if 0 279#if 0
246 val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0); 280 val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0);
247 snd_iprintf(buffer, "\nZoomed Video\n"); 281 snd_iprintf(buffer, "\nZoomed Video\n");
@@ -379,20 +413,16 @@ static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
379 struct snd_info_buffer *buffer) 413 struct snd_info_buffer *buffer)
380{ 414{
381 struct snd_emu10k1 *emu = entry->private_data; 415 struct snd_emu10k1 *emu = entry->private_data;
382 unsigned long value; 416 int value;
383 unsigned long flags; 417 unsigned long flags;
384 unsigned long regs;
385 int i; 418 int i;
386 snd_iprintf(buffer, "EMU1010 Registers:\n\n"); 419 snd_iprintf(buffer, "EMU1010 Registers:\n\n");
387 420
388 for(i = 0; i < 0x40; i+=1) { 421 for(i = 0; i < 0x40; i+=1) {
389 spin_lock_irqsave(&emu->emu_lock, flags); 422 spin_lock_irqsave(&emu->emu_lock, flags);
390 regs=i+0x40; /* 0x40 upwards are registers. */ 423 snd_emu1010_fpga_read(emu, i, &value);
391 outl(regs, emu->port + A_IOCFG);
392 outl(regs | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */
393 value = inl(emu->port + A_IOCFG);
394 spin_unlock_irqrestore(&emu->emu_lock, flags); 424 spin_unlock_irqrestore(&emu->emu_lock, flags);
395 snd_iprintf(buffer, "%02X: %08lX, %02lX\n", i, value, (value >> 8) & 0x7f); 425 snd_iprintf(buffer, "%02X: %08X, %02X\n", i, value, (value >> 8) & 0x7f);
396 } 426 }
397} 427}
398 428
diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c
index 116e1c8d9361..971458b45944 100644
--- a/sound/pci/emu10k1/io.c
+++ b/sound/pci/emu10k1/io.c
@@ -226,9 +226,9 @@ int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu,
226 return 0; 226 return 0;
227} 227}
228 228
229int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, int reg, int value) 229int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, u32 reg, u32 value)
230{ 230{
231 if (reg < 0 || reg > 0x3f) 231 if (reg > 0x3f)
232 return 1; 232 return 1;
233 reg += 0x40; /* 0x40 upwards are registers. */ 233 reg += 0x40; /* 0x40 upwards are registers. */
234 if (value < 0 || value > 0x3f) /* 0 to 0x3f are values */ 234 if (value < 0 || value > 0x3f) /* 0 to 0x3f are values */
@@ -244,9 +244,9 @@ int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, int reg, int value)
244 return 0; 244 return 0;
245} 245}
246 246
247int snd_emu1010_fpga_read(struct snd_emu10k1 * emu, int reg, int *value) 247int snd_emu1010_fpga_read(struct snd_emu10k1 * emu, u32 reg, u32 *value)
248{ 248{
249 if (reg < 0 || reg > 0x3f) 249 if (reg > 0x3f)
250 return 1; 250 return 1;
251 reg += 0x40; /* 0x40 upwards are registers. */ 251 reg += 0x40; /* 0x40 upwards are registers. */
252 outl(reg, emu->port + A_IOCFG); 252 outl(reg, emu->port + A_IOCFG);
@@ -261,7 +261,7 @@ int snd_emu1010_fpga_read(struct snd_emu10k1 * emu, int reg, int *value)
261/* Each Destination has one and only one Source, 261/* Each Destination has one and only one Source,
262 * but one Source can feed any number of Destinations simultaneously. 262 * but one Source can feed any number of Destinations simultaneously.
263 */ 263 */
264int snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 * emu, int dst, int src) 264int snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 * emu, u32 dst, u32 src)
265{ 265{
266 snd_emu1010_fpga_write(emu, 0x00, ((dst >> 8) & 0x3f) ); 266 snd_emu1010_fpga_write(emu, 0x00, ((dst >> 8) & 0x3f) );
267 snd_emu1010_fpga_write(emu, 0x01, (dst & 0x3f) ); 267 snd_emu1010_fpga_write(emu, 0x01, (dst & 0x3f) );