phonepad: support for realtek APK to read and write regs.
author宋秀杰 <sxj@rock-chips.com>
Thu, 6 Dec 2012 11:31:26 +0000 (19:31 +0800)
committer宋秀杰 <sxj@rock-chips.com>
Thu, 6 Dec 2012 11:31:26 +0000 (19:31 +0800)
sound/soc/codecs/Kconfig [changed mode: 0755->0644]
sound/soc/codecs/rt3261-dsp.h
sound/soc/codecs/rt3261.c [changed mode: 0755->0644]
sound/soc/codecs/rt3261_ioctl.c
sound/soc/codecs/rt3261_ioctl.h

old mode 100755 (executable)
new mode 100644 (file)
index 4a6be74..0f7a879
@@ -336,9 +336,11 @@ config SND_SOC_RT5625
        tristate
 
 config SND_SOC_RT3224
+       select SND_HWDEP
        tristate
 
 config SND_SOC_RT3261
+       select SND_HWDEP
        tristate
 
 config SND_SOC_WM8903
index e7c2da403b024609f3625de7c29817f2535a7d33..adf4d23fdbb2b630993710cb72465eb530c374fc 100644 (file)
@@ -32,6 +32,7 @@ struct rt3261_dsp_param {
 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);
+int rt_codec_dsp_ioctl_common(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg);
 #ifdef CONFIG_PM
 int rt3261_dsp_suspend(struct snd_soc_codec *codec, pm_message_t state);
 int rt3261_dsp_resume(struct snd_soc_codec *codec);
old mode 100755 (executable)
new mode 100644 (file)
index abc1b65..564180c
@@ -49,7 +49,7 @@ static struct snd_soc_codec *rt3261_codec;
 #define DBG(x...)
 #endif
 
-//#define RTK_IOCTL
+#define RTK_IOCTL
 #ifdef RTK_IOCTL
 #if defined(CONFIG_SND_HWDEP) || defined(CONFIG_SND_HWDEP_MODULE)
 #include "rt_codec_ioctl.h"
@@ -3175,7 +3175,6 @@ static int rt3261_probe(struct snd_soc_codec *codec)
 {
        struct rt3261_priv *rt3261 = snd_soc_codec_get_drvdata(codec);
        int ret;
-       struct clk *iis_clk;
 
        #if defined (CONFIG_SND_SOC_RT3224)
        pr_info("Codec driver version %s, in fact you choose rt3224, no dsp!\n", VERSION);
@@ -3195,6 +3194,7 @@ static int rt3261_probe(struct snd_soc_codec *codec)
        #endif
 
        #if defined (CONFIG_SND_SOC_RT5623)
+       struct clk *iis_clk;
        //for rt5623 MCLK use
        iis_clk = clk_get_sys("rk29_i2s.2", "i2s");
        if (IS_ERR(iis_clk)) {
index e8a7e3f60506257e4987702bd4d3d9c4546a5052..7408647c9c3218bfed282237b7ced0c8b39eca57 100644 (file)
@@ -14,6 +14,9 @@
 #include "rt_codec_ioctl.h"
 #include "rt3261_ioctl.h"
 #include "rt3261.h"
+#if defined (CONFIG_SND_SOC_RT3261)
+#include "rt3261-dsp.h"
+#endif
 
 hweq_t hweq_param[] = {
        {/* NORMAL */
@@ -21,62 +24,35 @@ hweq_t hweq_param[] = {
                {0},
                0x0000,
        },
-       {/* CLUB */
-               {0xa0,  0xa2,   0xa3,   0xa4,   0xa5,   0xa6,   0xa7,   0xa8,   0xa9,   0xaa,   0xaf},
-               {0x1c10,        0xc1cc, 0x1e5d, 0x0699, 0xcd48, 0x188d, 0x0699, 0xc3b6, 0x1cd0, 0x0699, 0x0436},
-               0x000e,
-       },
-       {/* DANCE */
-               {0xa0,  0xa1,   0xa2,   0xa3,   0xa4,   0xa5,   0xa6,   0xa7,   0xa8,   0xa9,   0xaa,   0xae},
-               {0x1f2c,        0x095b, 0xc071, 0x1f95, 0x0616, 0xc96e, 0x1b11, 0xfc91, 0xdcf2, 0x1194, 0xfaf2, 0x0436},
-               0x000f,
-       },
-       {/* LIVE */
-               {0xa0,  0xa1,   0xa2,   0xa3,   0xa4,   0xa5,   0xa6,   0xa7,   0xa8,   0xa9,   0xaa,   0xae},
-               {0x1eb5,        0xfcb6, 0xc24a, 0x1df8, 0x0e7c, 0xc883, 0x1c10, 0x0699, 0xda41, 0x1561, 0xd295, 0x0436},
-               0x000f,
-       },
-       {/* POP */
-               {0xa0,  0xa1,   0xa2,   0xa3,   0xa4,   0xa5,   0xa6,   0xa7,   0xa9,   0xaa,   0xae},
-               {0x1eb5,        0xfcb6, 0xc1d4, 0x1e5d, 0x0e23, 0xd92e, 0x16e6, 0xfcb6, 0x0969, 0xf988, 0x0436},
-               0x000f,
-       },
-       {/* ROCK */
-               {0xa0,  0xa1,   0xa2,   0xa3,   0xa4,   0xa5,   0xa6,   0xa7,   0xa8,   0xa9,   0xaa,   0xae},
-               {0x1eb5,        0xfcb6, 0xc071, 0x1f95, 0x0424, 0xc30a, 0x1d27, 0xf900, 0x0c5d, 0x0fc7, 0x0e23, 0x0436},
-               0x000f,
-       },
-       {/* OPPO */
-               {0xa2,  0xa3,   0xa4,   0xa5,   0xa6},
-               {0xca4a,        0x17f8, 0x0fec, 0xca4a, 0x17f8},
-               0x000f,
-       },
-       {/* TREBLE */
-               {0xae,  0xaf},
-               {0x188d,        0x1699},
-               0x0020,
+       {/* SPK */
+               {0xa0,  0xa1,   0xa2,   0xa3,   0xa4,   0xa5,   0xa6,   0xa7,   0xa8,   0xa9,   0xaa,   0xab,   0xac,   0xad,   0xae,   0xaf,   0xb0,   0xb1,   0xb2},
+               {0x1c10,0x01f4, 0xc5e9, 0x1a98, 0x1d2c, 0xc882, 0x1c10, 0x01f4, 0xe904, 0x1c10, 0x01f4, 0xe904, 0x1c10, 0x01f4, 0x1c10, 0x01f4, 0x2000, 0x0000, 0x2000},
+               0x0000,
        },
-       {/* BASS */
-               {0xa0,  0xa1,},
-               {0x1a43,        0x0c00},
-               0x0001,
+       {/* HP */
+               {0xa0,  0xa1,   0xa2,   0xa3,   0xa4,   0xa5,   0xa6,   0xa7,   0xa8,   0xa9,   0xaa,   0xab,   0xac,   0xad,   0xae,   0xaf,   0xb0,   0xb1,   0xb2},
+               {0x1c10,0x01f4, 0xc5e9, 0x1a98, 0x1d2c, 0xc882, 0x1c10, 0x01f4, 0xe904, 0x1c10, 0x01f4, 0xe904, 0x1c10, 0x01f4, 0x1c10, 0x01f4, 0x2000, 0x0000, 0x2000},
+               0x0000,
        },
 };
 #define RT3261_HWEQ_LEN ARRAY_SIZE(hweq_param)
 
-static int rt3261_update_eqmode(
+int rt3261_update_eqmode(
        struct snd_soc_codec *codec, int mode)
 {
        struct rt_codec_ops *ioctl_ops = rt_codec_get_ioctl_ops();
        int i;
+       static int eq_mode;
 
        if(codec == NULL ||  mode >= RT3261_HWEQ_LEN)
                return -EINVAL;
 
        dev_dbg(codec->dev, "%s(): mode=%d\n", __func__, mode);
 
+       if(mode == eq_mode)
+               return 0;
        for(i = 0; i <= EQ_REG_NUM; i++) {
-               if(hweq_param[mode].value[i])
+               if(hweq_param[mode].reg[i])
                        ioctl_ops->index_write(codec, hweq_param[mode].reg[i],
                                        hweq_param[mode].value[i]);
                else
@@ -88,6 +64,7 @@ static int rt3261_update_eqmode(
                RT3261_EQ_UPD, RT3261_EQ_UPD);
        snd_soc_update_bits(codec, RT3261_EQ_CTRL1, RT3261_EQ_UPD, 0);
 
+       eq_mode = mode;
        return 0;
 }
 
@@ -464,7 +441,12 @@ int rt3261_ioctl_common(struct snd_hwdep *hw, struct file *file,
                if (copy_to_user(rt_codec.buf, buf, sizeof(*buf) * rt_codec.number))
                        goto err;
                break;
-
+#if defined (CONFIG_SND_SOC_RT3261)
+       case RT_READ_CODEC_DSP_IOCTL:
+       case RT_WRITE_CODEC_DSP_IOCTL:
+       case RT_GET_CODEC_DSP_MODE_IOCTL:
+               return rt_codec_dsp_ioctl_common(hw, file, cmd, arg);
+#endif
        case RT_GET_CODEC_HWEQ_IOCTL:
        case RT_GET_CODEC_3D_SPK_IOCTL:
        case RT_GET_CODEC_MP3PLUS_IOCTL:
index 1f6946e5472d9d28787a5db2776acb0931bcb7e2..98981160c133568ac407bc651b686946c0885e6e 100644 (file)
 
 enum {
        NORMAL=0,
-       CLUB,
-       DANCE,
-       LIVE,
-       POP,
-       ROCK,
-       OPPO,
-       TREBLE,
-       BASS,
+       SPK,
+       HP,
        MODE_NUM,
 };
 
-#define EQ_REG_NUM 16
+#define EQ_REG_NUM 19
 typedef struct  hweq_s {
        unsigned int reg[EQ_REG_NUM];
        unsigned int value[EQ_REG_NUM];
@@ -37,5 +31,5 @@ typedef struct  hweq_s {
 
 int rt3261_ioctl_common(struct snd_hwdep *hw, struct file *file,
                        unsigned int cmd, unsigned long arg);
-
+int rt3261_update_eqmode(struct snd_soc_codec *codec, int mode);
 #endif /* __RT3261_IOCTL_H__ */