phonepad: rt3261 add dsp read and write function for debug, add modify some dsp reg.
author宋秀杰 <sxj@rock-chips.com>
Tue, 18 Sep 2012 12:33:49 +0000 (20:33 +0800)
committer宋秀杰 <sxj@rock-chips.com>
Tue, 18 Sep 2012 12:33:49 +0000 (20:33 +0800)
arch/arm/mach-rk30/board-rk30-phonepad.c
sound/soc/codecs/rt3261-dsp.c
sound/soc/codecs/rt3261-dsp.h
sound/soc/codecs/rt3261.c

index c612ecf3dd747a6a50fc8d480c49ef7298dc8aaf..8eb0b714a96c092c3cde8725ad45c901cc8a383b 100755 (executable)
@@ -2239,7 +2239,7 @@ static struct i2c_board_info __initdata i2c0_info[] = {
                 .flags                  = 0,
         },
 #endif
-#if defined (CONFIG_SND_SOC_RT3261)
+#if defined (CONFIG_SND_SOC_RT3224) || defined (CONFIG_SND_SOC_RT3261)
         {
                 .type                   = "rt3261",
                 .addr                   = 0x1c,
index af4d6fad1afa50ae6872a0dd93f3608a9d77e447..a732acb8af63fa97c985a6a951c2e454a0e69388 100644 (file)
@@ -25,7 +25,7 @@
 #include "rt3261-dsp.h"
 
 static const u16 rt3261_dsp_init[][2] = {
-       {0x3fd2, 0x0038}, {0x229C, 0x0fa0}, {0x22d2, 0x8400}, {0x22ee, 0x0001},
+       {0x3fd2, 0x0038}, {0x229C, 0x0fa0}, {0x22d2, 0x8400}, {0x22ee, 0x0000},
        {0x22f2, 0x0040}, {0x22f5, 0x8000}, {0x22f6, 0x0000}, {0x22f9, 0x007f},
        {0x2310, 0x0880},
 };
@@ -42,7 +42,7 @@ unsigned short rt3261_dsp_48[][2] = {
 //static const u16 rt3261_dsp_441[][2] = {
 unsigned short rt3261_dsp_441[][2] = {
        {0x22c6, 0x0031}, {0x22c7, 0x0050}, {0x22c8, 0x0009}, {0x22fe, 0x0e5b},
-       {0x22ff, 0x3c83}, {0x22fa, 0x2484}, {0x2301, 0x0001},
+       {0x22ff, 0x3883}, {0x22fa, 0x2484}, {0x2301, 0x0001},
 };
 #define RT3261_DSP_441_NUM (sizeof(rt3261_dsp_441) / sizeof(rt3261_dsp_441[0]))
 
@@ -222,6 +222,7 @@ static int rt3261_dsp_done(struct snd_soc_codec *codec)
        return 0;
 }
 
+
 /**
  * rt3261_dsp_write - Write DSP register.
  * @codec: SoC audio codec device.
@@ -233,7 +234,7 @@ static int rt3261_dsp_done(struct snd_soc_codec *codec)
  *
  * Returns 0 for success or negative error code.
  */
-static int rt3261_dsp_write(struct snd_soc_codec *codec,
+int rt3261_dsp_write(struct snd_soc_codec *codec,
                struct rt3261_dsp_param *param)
 {
        unsigned int dsp_val = snd_soc_read(codec, RT3261_DSP_CTRL3);
@@ -273,6 +274,8 @@ err:
        return ret;
 }
 
+EXPORT_SYMBOL_GPL(rt3261_dsp_write);
+
 /**
  * rt3261_dsp_read - Read DSP register.
  * @codec: SoC audio codec device.
@@ -284,7 +287,7 @@ err:
  *
  * Returns DSP register value or negative error code.
  */
-static unsigned int rt3261_dsp_read(
+unsigned int rt3261_dsp_read(
        struct snd_soc_codec *codec, unsigned int reg)
 {
        unsigned int val_h, val_l, value;
@@ -373,6 +376,7 @@ static unsigned int rt3261_dsp_read(
 err:
        return ret;
 }
+EXPORT_SYMBOL_GPL(rt3261_dsp_read);
 
 static int rt3261_dsp_get(struct snd_kcontrol *kcontrol,
                struct snd_ctl_elem_value *ucontrol)
@@ -1055,12 +1059,12 @@ int rt3261_dsp_probe(struct snd_soc_codec *codec)
        rt3261_dsp_conf(codec);
        ret = rt3261_dsp_read(codec, 0x3800);
        pr_info("DSP version code = 0x%04x\n",ret);
-       if(ret != 0x501a) {
+       /*if(ret != 0x501a) {
                rt3261 = snd_soc_codec_get_drvdata(codec);
                INIT_DELAYED_WORK(&rt3261->patch_work, rt3261_do_dsp_patch);
                schedule_delayed_work(&rt3261->patch_work,
                                msecs_to_jiffies(100));
-       }
+       }*/
        snd_soc_update_bits(codec, RT3261_PWR_DIG2,
                RT3261_PWR_I2S_DSP, 0);
 
index 443cfdab21494dc5323237e634fccc33ab2f8e5a..1ba6872cea96ee1e8aed154dc7651ce2c3e80edb 100644 (file)
@@ -29,6 +29,8 @@ struct rt3261_dsp_param {
        u8 cmd;
 };
 
+int rt3261_dsp_write(struct snd_soc_codec *codec, struct rt3261_dsp_param *param);
+unsigned int rt3261_dsp_read(struct snd_soc_codec *codec, unsigned int reg);
 int rt3261_dsp_probe(struct snd_soc_codec *codec);
 #ifdef CONFIG_PM
 int rt3261_dsp_suspend(struct snd_soc_codec *codec, pm_message_t state);
index b6c60d5b1086f60a87f2b4b9687e441f60d18893..8fcb4a1d6e69261b631370f859f99f2465156190 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/vmalloc.h>
-char debug_write_read = 0;
 #endif
 
 static struct snd_soc_codec *rt3261_codec;
@@ -2945,7 +2944,11 @@ static int rt3261_probe(struct snd_soc_codec *codec)
        int ret;
        struct clk *iis_clk;
 
-       pr_info("Codec driver version %s\n", VERSION);
+       #if defined (CONFIG_SND_SOC_RT3224)
+       pr_info("Codec driver version %s, in fact you choose rt3224, no dsp!\n", VERSION);
+       #else
+       pr_info("Codec driver version %s, in fact you choose rt3261 with a dsp!\n", VERSION);
+       #endif
 
        ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C);
        if (ret != 0) {
@@ -3241,6 +3244,7 @@ static ssize_t rt3261_proc_write(struct file *file, const char __user *buffer,
        int reg;
        int i;
        int value;
+       struct rt3261_dsp_param param;
 
        cookie_pot = (char *)vmalloc( len );
        if (!cookie_pot) 
@@ -3255,21 +3259,11 @@ static ssize_t rt3261_proc_write(struct file *file, const char __user *buffer,
 
        switch(cookie_pot[0])
        {
-               case 'd':
-               case 'D':
-                       debug_write_read ++;
-                       debug_write_read %= 2;
-                       if(debug_write_read != 0)
-                               printk("Debug read and write reg on\n");
-                       else    
-                               printk("Debug read and write reg off\n");       
-                       break;  
                case 'r':
                case 'R':
                        printk("Read reg debug\n");             
                        if(cookie_pot[1] ==':')
                        {
-                               debug_write_read = 1;
                                strsep(&cookie_pot,":");
                                while((p=strsep(&cookie_pot,",")))
                                {
@@ -3277,7 +3271,6 @@ static ssize_t rt3261_proc_write(struct file *file, const char __user *buffer,
                                        value = rt3261_read(rt3261_codec,reg);
                                        printk("rt3261_read:0x%04x = 0x%04x\n",reg,value);
                                }
-                               debug_write_read = 0;
                                printk("\n");
                        }
                        else
@@ -3291,7 +3284,6 @@ static ssize_t rt3261_proc_write(struct file *file, const char __user *buffer,
                        printk("Write reg debug\n");            
                        if(cookie_pot[1] ==':')
                        {
-                               debug_write_read = 1;
                                strsep(&cookie_pot,":");
                                while((p=strsep(&cookie_pot,"=")))
                                {
@@ -3301,7 +3293,6 @@ static ssize_t rt3261_proc_write(struct file *file, const char __user *buffer,
                                        rt3261_write(rt3261_codec,reg,value);
                                        printk("rt3261_write:0x%04x = 0x%04x\n",reg,value);
                                }
-                               debug_write_read = 0;
                                printk("\n");
                        }
                        else
@@ -3311,15 +3302,48 @@ static ssize_t rt3261_proc_write(struct file *file, const char __user *buffer,
                        }
                        break;
                case 'a':
-                       printk("Dump rt3261 dsp reg \n");               
+                       printk("Dump rt3261 index reg \n");             
 
                        for (i = 0; i < 0xb4; i++) 
                        {
                                value = rt3261_index_read(rt3261_codec, i);
                                printk("rt3261_index_read:0x%04x = 0x%04x\n",i,value);
                        }
-
-                       break;          
+                       break;  
+               #if defined (CONFIG_SND_SOC_RT3261)
+               case 'b':
+                       param.cmd_fmt =  0x00e0;
+                       param.cmd = RT3261_DSP_CMD_MW;
+                       printk("Write dsp reg debug\n");                
+                       if(cookie_pot[1] ==':')
+                       {
+                               strsep(&cookie_pot,":");
+                               while((p=strsep(&cookie_pot,"=")))
+                               {
+                                       param.addr = simple_strtol(p,NULL,16);
+                                       p=strsep(&cookie_pot,",");
+                                       param.data = simple_strtol(p,NULL,16);
+                                       rt3261_dsp_write(rt3261_codec,&param);
+                                       printk("rt3261_dsp_write:0x%04x = 0x%04x\n",param.addr,param.data);
+                               }
+                               printk("\n");
+                       }
+                       break;
+               case 'c':
+                       printk("Read dsp reg debug\n");         
+                       if(cookie_pot[1] ==':')
+                       {
+                               strsep(&cookie_pot,":");
+                               while((p=strsep(&cookie_pot,",")))
+                               {
+                                       reg = simple_strtol(p,NULL,16);
+                                       value = rt3261_dsp_read(rt3261_codec,reg);
+                                       printk("rt3261_dsp_read:0x%04x = 0x%04x\n",reg,value);
+                               }
+                               printk("\n");
+                       }
+                       break;
+               #endif
                default:
                        printk("Help for rt3261_ts .\n-->The Cmd list: \n");
                        printk("-->'d&&D' Open or Off the debug\n");