From 5306f77ebae9f4d0589c20fb0c07bc3358225860 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=AE=8B=E7=A7=80=E6=9D=B0?= Date: Tue, 18 Sep 2012 20:33:49 +0800 Subject: [PATCH] phonepad: rt3261 add dsp read and write function for debug, add modify some dsp reg. --- arch/arm/mach-rk30/board-rk30-phonepad.c | 2 +- sound/soc/codecs/rt3261-dsp.c | 16 ++++--- sound/soc/codecs/rt3261-dsp.h | 2 + sound/soc/codecs/rt3261.c | 60 +++++++++++++++++------- 4 files changed, 55 insertions(+), 25 deletions(-) diff --git a/arch/arm/mach-rk30/board-rk30-phonepad.c b/arch/arm/mach-rk30/board-rk30-phonepad.c index c612ecf3dd74..8eb0b714a96c 100755 --- a/arch/arm/mach-rk30/board-rk30-phonepad.c +++ b/arch/arm/mach-rk30/board-rk30-phonepad.c @@ -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, diff --git a/sound/soc/codecs/rt3261-dsp.c b/sound/soc/codecs/rt3261-dsp.c index af4d6fad1afa..a732acb8af63 100644 --- a/sound/soc/codecs/rt3261-dsp.c +++ b/sound/soc/codecs/rt3261-dsp.c @@ -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); diff --git a/sound/soc/codecs/rt3261-dsp.h b/sound/soc/codecs/rt3261-dsp.h index 443cfdab2149..1ba6872cea96 100644 --- a/sound/soc/codecs/rt3261-dsp.h +++ b/sound/soc/codecs/rt3261-dsp.h @@ -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); diff --git a/sound/soc/codecs/rt3261.c b/sound/soc/codecs/rt3261.c index b6c60d5b1086..8fcb4a1d6e69 100644 --- a/sound/soc/codecs/rt3261.c +++ b/sound/soc/codecs/rt3261.c @@ -33,7 +33,6 @@ #include #include #include -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,¶m); + 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"); -- 2.34.1