Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / sound / pci / ca0106 / ca0106_proc.c
index afb7114..6375727 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk>
  *  Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit
- *  Version: 0.0.17
+ *  Version: 0.0.18
  *
  *  FEATURES currently supported:
  *    See ca0106_main.c for features.
@@ -39,7 +39,9 @@
  *    Modified Copyright message.
  *  0.0.17
  *    Add iec958 file in proc file system to show status of SPDIF in.
- *    
+ *  0.0.18
+ *    Implement support for Line-in capture on SB Live 24bit.
+ *
  *  This code was initally based on code from ALSA's emu10k1x.c which is:
  *  Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com>
  *
@@ -75,6 +77,8 @@
 #include "ca0106.h"
 
 
+#ifdef CONFIG_PROC_FS
+
 struct snd_ca0106_category_str {
        int val;
        const char *name;
@@ -95,7 +99,7 @@ static struct snd_ca0106_category_str snd_ca0106_con_category[] = {
 };
 
 
-void snd_ca0106_proc_dump_iec958( snd_info_buffer_t *buffer, u32 value)
+static void snd_ca0106_proc_dump_iec958( struct snd_info_buffer *buffer, u32 value)
 {
        int i;
        u32 status[4];
@@ -269,10 +273,10 @@ void snd_ca0106_proc_dump_iec958( snd_info_buffer_t *buffer, u32 value)
        }
 }
 
-static void snd_ca0106_proc_iec958(snd_info_entry_t *entry, 
-                                      snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_iec958(struct snd_info_entry *entry, 
+                                      struct snd_info_buffer *buffer)
 {
-       ca0106_t *emu = entry->private_data;
+       struct snd_ca0106 *emu = entry->private_data;
        u32 value;
 
         value = snd_ca0106_ptr_read(emu, SAMPLE_RATE_TRACKER_STATUS, 0);
@@ -291,10 +295,10 @@ static void snd_ca0106_proc_iec958(snd_info_entry_t *entry,
        snd_iprintf(buffer, "\n");
 }
 
-static void snd_ca0106_proc_reg_write32(snd_info_entry_t *entry, 
-                                      snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_write32(struct snd_info_entry *entry, 
+                                      struct snd_info_buffer *buffer)
 {
-       ca0106_t *emu = entry->private_data;
+       struct snd_ca0106 *emu = entry->private_data;
        unsigned long flags;
         char line[64];
         u32 reg, val;
@@ -309,10 +313,10 @@ static void snd_ca0106_proc_reg_write32(snd_info_entry_t *entry,
         }
 }
 
-static void snd_ca0106_proc_reg_read32(snd_info_entry_t *entry, 
-                                      snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_read32(struct snd_info_entry *entry, 
+                                      struct snd_info_buffer *buffer)
 {
-       ca0106_t *emu = entry->private_data;
+       struct snd_ca0106 *emu = entry->private_data;
        unsigned long value;
        unsigned long flags;
        int i;
@@ -325,10 +329,10 @@ static void snd_ca0106_proc_reg_read32(snd_info_entry_t *entry,
        }
 }
 
-static void snd_ca0106_proc_reg_read16(snd_info_entry_t *entry, 
-                                      snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_read16(struct snd_info_entry *entry, 
+                                      struct snd_info_buffer *buffer)
 {
-       ca0106_t *emu = entry->private_data;
+       struct snd_ca0106 *emu = entry->private_data;
         unsigned int value;
        unsigned long flags;
        int i;
@@ -341,10 +345,10 @@ static void snd_ca0106_proc_reg_read16(snd_info_entry_t *entry,
        }
 }
 
-static void snd_ca0106_proc_reg_read8(snd_info_entry_t *entry, 
-                                      snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_read8(struct snd_info_entry *entry, 
+                                      struct snd_info_buffer *buffer)
 {
-       ca0106_t *emu = entry->private_data;
+       struct snd_ca0106 *emu = entry->private_data;
        unsigned int value;
        unsigned long flags;
        int i;
@@ -357,10 +361,10 @@ static void snd_ca0106_proc_reg_read8(snd_info_entry_t *entry,
        }
 }
 
-static void snd_ca0106_proc_reg_read1(snd_info_entry_t *entry, 
-                                      snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_read1(struct snd_info_entry *entry, 
+                                      struct snd_info_buffer *buffer)
 {
-       ca0106_t *emu = entry->private_data;
+       struct snd_ca0106 *emu = entry->private_data;
        unsigned long value;
        int i,j;
 
@@ -375,10 +379,10 @@ static void snd_ca0106_proc_reg_read1(snd_info_entry_t *entry,
        }
 }
 
-static void snd_ca0106_proc_reg_read2(snd_info_entry_t *entry, 
-                                      snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_read2(struct snd_info_entry *entry, 
+                                      struct snd_info_buffer *buffer)
 {
-       ca0106_t *emu = entry->private_data;
+       struct snd_ca0106 *emu = entry->private_data;
        unsigned long value;
        int i,j;
 
@@ -393,10 +397,10 @@ static void snd_ca0106_proc_reg_read2(snd_info_entry_t *entry,
        }
 }
 
-static void snd_ca0106_proc_reg_write(snd_info_entry_t *entry, 
-                                      snd_info_buffer_t * buffer)
+static void snd_ca0106_proc_reg_write(struct snd_info_entry *entry, 
+                                      struct snd_info_buffer *buffer)
 {
-       ca0106_t *emu = entry->private_data;
+       struct snd_ca0106 *emu = entry->private_data;
         char line[64];
         unsigned int reg, channel_id , val;
         while (!snd_info_get_line(buffer, line, sizeof(line))) {
@@ -407,10 +411,24 @@ static void snd_ca0106_proc_reg_write(snd_info_entry_t *entry,
         }
 }
 
+static void snd_ca0106_proc_i2c_write(struct snd_info_entry *entry, 
+                                      struct snd_info_buffer *buffer)
+{
+       struct snd_ca0106 *emu = entry->private_data;
+        char line[64];
+        unsigned int reg, val;
+        while (!snd_info_get_line(buffer, line, sizeof(line))) {
+                if (sscanf(line, "%x %x", &reg, &val) != 2)
+                        continue;
+                if ((reg <= 0x7f) || (val <= 0x1ff)) {
+                        snd_ca0106_i2c_write(emu, reg, val);
+               }
+        }
+}
 
-int __devinit snd_ca0106_proc_init(ca0106_t * emu)
+int __devinit snd_ca0106_proc_init(struct snd_ca0106 * emu)
 {
-       snd_info_entry_t *entry;
+       struct snd_info_entry *entry;
        
        if(! snd_card_proc_new(emu->card, "iec958", &entry))
                snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_iec958);
@@ -418,6 +436,7 @@ int __devinit snd_ca0106_proc_init(ca0106_t * emu)
                snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read32);
                entry->c.text.write_size = 64;
                entry->c.text.write = snd_ca0106_proc_reg_write32;
+               entry->mode |= S_IWUSR;
        }
        if(! snd_card_proc_new(emu->card, "ca0106_reg16", &entry))
                snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read16);
@@ -427,6 +446,14 @@ int __devinit snd_ca0106_proc_init(ca0106_t * emu)
                snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read1);
                entry->c.text.write_size = 64;
                entry->c.text.write = snd_ca0106_proc_reg_write;
+               entry->mode |= S_IWUSR;
+//             entry->private_data = emu;
+       }
+       if(! snd_card_proc_new(emu->card, "ca0106_i2c", &entry)) {
+               snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_i2c_write);
+               entry->c.text.write_size = 64;
+               entry->c.text.write = snd_ca0106_proc_i2c_write;
+               entry->mode |= S_IWUSR;
 //             entry->private_data = emu;
        }
        if(! snd_card_proc_new(emu->card, "ca0106_regs2", &entry)) 
@@ -434,3 +461,4 @@ int __devinit snd_ca0106_proc_init(ca0106_t * emu)
        return 0;
 }
 
+#endif /* CONFIG_PROC_FS */