From 72c0f25381cd23994915d98dba3872cdf4b986c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=AE=8B=E7=A7=80=E6=9D=B0?= Date: Fri, 20 Jul 2012 21:12:20 +0800 Subject: [PATCH] codec: update rt3261.c and rt5623.c. --- sound/soc/codecs/rt3261.c | 15 ++-- sound/soc/codecs/rt5623.c | 158 ++++++++++++++++++++++++++++++++++---- 2 files changed, 154 insertions(+), 19 deletions(-) diff --git a/sound/soc/codecs/rt3261.c b/sound/soc/codecs/rt3261.c index 716287475ad1..a172c67c1f68 100644 --- a/sound/soc/codecs/rt3261.c +++ b/sound/soc/codecs/rt3261.c @@ -80,8 +80,10 @@ static struct rt3261_init_reg init_list[] = { {RT3261_PRIV_DATA , 0x6115}, {RT3261_PRIV_INDEX , 0x0023},//PR23 = 0804'h {RT3261_PRIV_DATA , 0x0804}, - {RT3261_SPK_VOL , 0x8b8b},//SPKMIX -> SPKVOL - {RT3261_HP_VOL , 0x8888}, + {RT3261_SPK_VOL , 0x8b8b},//SPKMIX -> SPKVOL + {RT3261_HP_VOL , 0x8888}, + {RT3261_OUTPUT , 0x8888},//unmute OUTVOLL/R + }; #define RT3261_INIT_REG_LEN ARRAY_SIZE(init_list) @@ -216,7 +218,6 @@ static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg, static int rt3261_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { - struct rt3261_priv *rt3261 = snd_soc_codec_get_drvdata(codec); u8 data[3]; data[0] = reg; @@ -1080,6 +1081,8 @@ static const struct snd_kcontrol_new rt3261_spk_r_mix[] = { static const struct snd_kcontrol_new rt3261_out_l_mix[] = { SOC_DAPM_SINGLE("SPK MIXL Switch", RT3261_OUT_L3_MIXER, RT3261_M_SM_L_OM_L_SFT, 1, 1), + SOC_DAPM_SINGLE("BST3 Switch", RT3261_OUT_L3_MIXER, + RT3261_M_BST2_OM_L_SFT, 1, 1), SOC_DAPM_SINGLE("BST1 Switch", RT3261_OUT_L3_MIXER, RT3261_M_BST1_OM_L_SFT, 1, 1), SOC_DAPM_SINGLE("INL Switch", RT3261_OUT_L3_MIXER, @@ -1097,6 +1100,8 @@ static const struct snd_kcontrol_new rt3261_out_l_mix[] = { static const struct snd_kcontrol_new rt3261_out_r_mix[] = { SOC_DAPM_SINGLE("SPK MIXR Switch", RT3261_OUT_R3_MIXER, RT3261_M_SM_L_OM_R_SFT, 1, 1), + SOC_DAPM_SINGLE("BST3 Switch", RT3261_OUT_R3_MIXER, + RT3261_M_BST2_OM_R_SFT, 1, 1), SOC_DAPM_SINGLE("BST2 Switch", RT3261_OUT_R3_MIXER, RT3261_M_BST4_OM_R_SFT, 1, 1), SOC_DAPM_SINGLE("BST1 Switch", RT3261_OUT_R3_MIXER, @@ -2198,7 +2203,7 @@ static const struct snd_soc_dapm_route rt3261_dapm_routes[] = { {"SPK MIXR", "DAC R2 Switch", "DAC R2"}, {"SPK MIXR", "OUT MIXR Switch", "OUT MIXR"}, - {"OUT MIXL", "SPK MIXL Switch", "SPK MIXL"}, + {"OUT MIXL", "BST3 Switch", "BST3"}, {"OUT MIXL", "BST1 Switch", "BST1"}, {"OUT MIXL", "INL Switch", "INL VOL"}, {"OUT MIXL", "REC MIXL Switch", "RECMIXL"}, @@ -2206,7 +2211,7 @@ static const struct snd_soc_dapm_route rt3261_dapm_routes[] = { {"OUT MIXL", "DAC L2 Switch", "DAC L2"}, {"OUT MIXL", "DAC L1 Switch", "DAC L1"}, - {"OUT MIXR", "SPK MIXR Switch", "SPK MIXR"}, + {"OUT MIXR", "BST3 Switch", "BST3"}, {"OUT MIXR", "BST2 Switch", "BST2"}, {"OUT MIXR", "BST1 Switch", "BST1"}, {"OUT MIXR", "INR Switch", "INR VOL"}, diff --git a/sound/soc/codecs/rt5623.c b/sound/soc/codecs/rt5623.c index e9c017ccc914..602ad39870e4 100644 --- a/sound/soc/codecs/rt5623.c +++ b/sound/soc/codecs/rt5623.c @@ -27,13 +27,19 @@ #include "rt5623.h" +#define RT5623_PROC +#ifdef RT5623_PROC +#include +#include +#include +#endif + static struct i2c_client *i2c_client; static int codec_write(struct i2c_client *client, unsigned int reg, unsigned int value) { u8 data[3]; - int ret; data[0] = reg; data[1] = (value >> 8) & 0xff; @@ -59,12 +65,14 @@ static unsigned int codec_read(struct i2c_client *client, xfer[0].flags = 0; xfer[0].len = 1; xfer[0].buf = ® + xfer[0].scl_rate = 100 * 1000; /* Read data */ xfer[1].addr = client->addr; xfer[1].flags = I2C_M_RD; xfer[1].len = 2; xfer[1].buf = (u8 *)&data; + xfer[1].scl_rate = 100 * 1000; ret = i2c_transfer(client->adapter, xfer, 2); if (ret != 2) { @@ -82,19 +90,22 @@ struct rt5623_reg { }; static struct rt5623_reg init_data[] = { - {RT5623_PWR_MANAG_ADD3 , 0x8000}, - {RT5623_PWR_MANAG_ADD2 , 0x2000}, - {RT5623_LINE_IN_VOL , 0xe808}, - {RT5623_STEREO_DAC_VOL , 0x6808}, - {RT5623_OUTPUT_MIXER_CTRL , 0x1400}, - {RT5623_ADC_REC_GAIN , 0xf58b}, - {RT5623_ADC_REC_MIXER , 0x6f6f}, - {RT5623_AUDIO_INTERFACE , 0x8000}, + {RT5623_PWR_MANAG_ADD3 , 0x8000}, + {RT5623_PWR_MANAG_ADD2 , 0x2000}, + {RT5623_LINE_IN_VOL , 0xe808}, + {RT5623_STEREO_DAC_VOL , 0x6808}, + {RT5623_OUTPUT_MIXER_CTRL , 0x1400}, + {RT5623_ADC_REC_GAIN , 0xf58b}, + {RT5623_ADC_REC_MIXER , 0x6f6f}, + {RT5623_AUDIO_INTERFACE , 0x8083}, {RT5623_STEREO_AD_DA_CLK_CTRL , 0x0a2d}, - {RT5623_PWR_MANAG_ADD1 , 0x8000}, - {RT5623_PWR_MANAG_ADD2 , 0x27f3}, - {RT5623_PWR_MANAG_ADD3 , 0x9c00}, - {RT5623_SPK_OUT_VOL , 0x0000}, + {RT5623_PWR_MANAG_ADD1 , 0x8000}, + {RT5623_PWR_MANAG_ADD2 , 0xb7f3}, + {RT5623_PWR_MANAG_ADD3 , 0x90c0}, + {RT5623_SPK_OUT_VOL , 0x0000}, + {RT5623_PLL_CTRL , 0x481f}, + {RT5623_GLOBAL_CLK_CTRL_REG , 0x8000}, + {RT5623_STEREO_AD_DA_CLK_CTRL , 0x3a2d}, }; #define RT5623_INIT_REG_NUM ARRAY_SIZE(init_data) @@ -139,11 +150,17 @@ static const struct i2c_device_id rt5623_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5623_i2c_id); +static int rt5623_proc_init(void); + static int __devinit rt5623_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { pr_info("%s(%d)\n", __func__, __LINE__); + #ifdef RT5623_PROC + rt5623_proc_init(); + #endif + i2c_client = i2c; rt5623_reset(i2c); @@ -171,7 +188,7 @@ static int __init rt5623_modinit(void) { return i2c_add_driver(&rt5623_i2c_driver); } -module_init(rt5623_modinit); +late_initcall(rt5623_modinit); static void __exit rt5623_modexit(void) { @@ -182,3 +199,116 @@ module_exit(rt5623_modexit); MODULE_DESCRIPTION("ASoC RT5623 driver"); MODULE_AUTHOR("Johnny Hsu "); MODULE_LICENSE("GPL"); + + +#ifdef RT5623_PROC + +static ssize_t rt5623_proc_write(struct file *file, const char __user *buffer, + unsigned long len, void *data) +{ + char *cookie_pot; + char *p; + int reg; + int value; + + cookie_pot = (char *)vmalloc( len ); + if (!cookie_pot) + { + return -ENOMEM; + } + else + { + if (copy_from_user( cookie_pot, buffer, len )) + return -EFAULT; + } + + switch(cookie_pot[0]) + { + case 'r': + case 'R': + printk("Read reg debug\n"); + if(cookie_pot[1] ==':') + { + strsep(&cookie_pot,":"); + while((p=strsep(&cookie_pot,","))) + { + reg = simple_strtol(p,NULL,16); + value = codec_read(i2c_client,reg); + printk("codec_read:0x%04x = 0x%04x\n",reg,value); + } + printk("\n"); + } + else + { + printk("Error Read reg debug.\n"); + printk("For example: echo r:22,23,24,25>rt5623_ts\n"); + } + break; + case 'w': + case 'W': + printk("Write reg debug\n"); + if(cookie_pot[1] ==':') + { + strsep(&cookie_pot,":"); + while((p=strsep(&cookie_pot,"="))) + { + reg = simple_strtol(p,NULL,16); + p=strsep(&cookie_pot,","); + value = simple_strtol(p,NULL,16); + codec_write(i2c_client,reg,value); + printk("codec_write:0x%04x = 0x%04x\n",reg,value); + } + printk("\n"); + } + else + { + printk("Error Write reg debug.\n"); + printk("For example: w:22=0,23=0,24=0,25=0>rt5623_ts\n"); + } + break; + case 'a': + printk("Dump reg \n"); + + for(reg = 0; reg < 0x6e; reg+=2) + { + value = codec_read(i2c_client,reg); + printk("codec_read:0x%04x = 0x%04x\n",reg,value); + } + + break; + default: + printk("Help for rt5623_ts .\n-->The Cmd list: \n"); + printk("-->'d&&D' Open or Off the debug\n"); + printk("-->'r&&R' Read reg debug,Example: echo 'r:22,23,24,25'>rt5623_ts\n"); + printk("-->'w&&W' Write reg debug,Example: echo 'w:22=0,23=0,24=0,25=0'>rt5623_ts\n"); + break; + } + + return len; +} + +static const struct file_operations rt5623_proc_fops = { + .owner = THIS_MODULE, +}; + +static int rt5623_proc_init(void) +{ + struct proc_dir_entry *rt5623_proc_entry; + rt5623_proc_entry = create_proc_entry("driver/rt5623_ts", 0777, NULL); + if(rt5623_proc_entry != NULL) + { + rt5623_proc_entry->write_proc = rt5623_proc_write; + return 0; + } + else + { + printk("create proc error !\n"); + return -1; + } +} +#endif + + + + + -- 2.34.1