#define RT3261_DSP_INIT_NUM \
(sizeof(rt3261_dsp_init) / sizeof(rt3261_dsp_init[0]))
-static const u16 rt3261_dsp_48[][2] = {
+//static const u16 rt3261_dsp_48[][2] = {
+unsigned short rt3261_dsp_48[][2] = {
{0x22c8, 0x0026}, {0x22fe, 0x0fa0}, {0x22ff, 0x3893}, {0x22fa, 0x2487},
{0x2301, 0x0002},
};
#define RT3261_DSP_48_NUM (sizeof(rt3261_dsp_48) / sizeof(rt3261_dsp_48[0]))
-static const u16 rt3261_dsp_441[][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},
};
#define RT3261_DSP_441_NUM (sizeof(rt3261_dsp_441) / sizeof(rt3261_dsp_441[0]))
-static const u16 rt3261_dsp_16[][2] = {
+//static const u16 rt3261_dsp_16[][2] = {
+unsigned short rt3261_dsp_16[][2] = {
{0x22c8, 0x0026}, {0x22fa, 0x2484}, {0x2301, 0x0002},
};
#define RT3261_DSP_16_NUM (sizeof(rt3261_dsp_16) / sizeof(rt3261_dsp_16[0]))
return 0;
}
-static int rt3261_dsp_play_bp_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
- struct rt3261_priv *rt3261 = snd_soc_codec_get_drvdata(codec);
-
- ucontrol->value.integer.value[0] = rt3261->dsp_play_pass;
-
- return 0;
-}
-
-static int rt3261_dsp_play_bp_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
- struct rt3261_priv *rt3261 = snd_soc_codec_get_drvdata(codec);
-
- if (rt3261->dsp_play_pass == ucontrol->value.integer.value[0])
- return 0;
- rt3261->dsp_play_pass = ucontrol->value.integer.value[0];
-
- rt3261_conn_mux_path(codec, "DAC L2 Mux",
- rt3261->dsp_play_pass ? "IF2" : "TxDC");
- rt3261_conn_mux_path(codec, "DAC R2 Mux",
- rt3261->dsp_play_pass ? "IF2" : "TxDC");
-
- return 0;
-}
-
-static int rt3261_dsp_rec_bp_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
- struct rt3261_priv *rt3261 = snd_soc_codec_get_drvdata(codec);
-
- ucontrol->value.integer.value[0] = rt3261->dsp_rec_pass;
-
- return 0;
-}
-
-static int rt3261_dsp_rec_bp_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
- struct rt3261_priv *rt3261 = snd_soc_codec_get_drvdata(codec);
-
- if (rt3261->dsp_rec_pass == ucontrol->value.integer.value[0])
- return 0;
- rt3261->dsp_rec_pass = ucontrol->value.integer.value[0];
-
- rt3261_conn_mux_path(codec, "IF2 ADC L Mux",
- rt3261->dsp_rec_pass ? "Mono ADC MIXL" : "TxDP");
- rt3261_conn_mux_path(codec, "IF2 ADC R Mux",
- rt3261->dsp_rec_pass ? "Mono ADC MIXR" : "TxDP");
-
- return 0;
-}
-
-static int rt3261_dac_active_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
- struct snd_soc_dapm_context *dapm = &codec->dapm;
- struct snd_soc_dapm_widget *w;
-
- list_for_each_entry(w, &dapm->card->widgets, list)
- {
- if (!w->sname || w->dapm != dapm)
- continue;
- if (strstr(w->sname, "Playback")) {
- pr_info("widget %s %s\n", w->name, w->sname);
- ucontrol->value.integer.value[0] = w->active;
- break;
- }
- }
- return 0;
-}
-
-static int rt3261_dac_active_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
- struct snd_soc_dapm_context *dapm = &codec->dapm;
- struct snd_soc_dapm_widget *w;
-
- list_for_each_entry(w, &dapm->card->widgets, list)
- {
- if (!w->sname || w->dapm != dapm)
- continue;
- if (strstr(w->sname, "Playback")) {
- pr_info("widget %s %s\n", w->name, w->sname);
- w->active = 1;
- }
- }
- return 0;
-}
-
-static int rt3261_adc_active_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
- struct snd_soc_dapm_context *dapm = &codec->dapm;
- struct snd_soc_dapm_widget *w;
-
- list_for_each_entry(w, &dapm->card->widgets, list)
- {
- if (!w->sname || w->dapm != dapm)
- continue;
- if (strstr(w->sname, "Capture")) {
- pr_info("widget %s %s\n", w->name, w->sname);
- ucontrol->value.integer.value[0] = w->active;
- break;
- }
- }
- return 0;
-}
-
-static int rt3261_adc_active_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
- struct snd_soc_dapm_context *dapm = &codec->dapm;
- struct snd_soc_dapm_widget *w;
-
- list_for_each_entry(w, &dapm->card->widgets, list)
- {
- if (!w->sname || w->dapm != dapm)
- continue;
- if (strstr(w->sname, "Capture")) {
- pr_info("widget %s %s\n", w->name, w->sname);
- w->active = 1;
- }
- }
- return 0;
-}
-
/* DSP Path Control 1 */
static const char *rt3261_src_rxdp_mode[] = {
"Normal", "Divided by 3"};
/* AEC */
SOC_ENUM_EXT("DSP Function Switch", rt3261_dsp_enum,
rt3261_dsp_get, rt3261_dsp_put),
- SOC_SINGLE_EXT("DSP Playback Bypass", 0, 0, 1, 0,
- rt3261_dsp_play_bp_get, rt3261_dsp_play_bp_put),
- SOC_SINGLE_EXT("DSP Record Bypass", 0, 0, 1, 0,
- rt3261_dsp_rec_bp_get, rt3261_dsp_rec_bp_put),
- SOC_SINGLE_EXT("DAC Switch", 0, 0, 1, 0,
- rt3261_dac_active_get, rt3261_dac_active_put),
- SOC_SINGLE_EXT("ADC Switch", 0, 0, 1, 0,
- rt3261_adc_active_get, rt3261_adc_active_put),
};
static int rt3261_dsp_patch_3(struct snd_soc_codec *codec)
static int rt3261_dsp_set_mode(struct snd_soc_codec *codec, int mode)
{
struct rt3261_dsp_param param;
- int ret, i, tab_num;
+ int ret, i;
+/*
unsigned short (*mode_tab)[2];
switch (mode) {
dev_info(codec->dev, "Disable\n");
return 0;
}
-
+*/
param.cmd_fmt = 0x00e0;
param.cmd = RT3261_DSP_CMD_MW;
- for (i = 0; i < tab_num; i++) {
- param.addr = mode_tab[i][0];
- param.data = mode_tab[i][1];
+ for (i = 0; i < RT3261_DSP_AEC_NUM; i++) {
+ param.addr = rt3261_dsp_aec_ns_fens[i][0];
+ param.data = rt3261_dsp_aec_ns_fens[i][1];
ret = rt3261_dsp_write(codec, ¶m);
if (ret < 0)
goto mode_err;
struct i2c_client *client = to_i2c_client(dev);
struct rt3261_priv *rt3261 = i2c_get_clientdata(client);
struct snd_soc_codec *codec = rt3261->codec;
- unsigned short (*rt3261_dsp_tab)[2];
+// unsigned short (*rt3261_dsp_tab)[2];
unsigned int val;
- int cnt = 0, i, tab_num;
+ int cnt = 0, i;
switch (rt3261->dsp_sw) {
case RT3261_DSP_AEC_NS_FENS:
cnt += sprintf(buf, "[ RT3261 DSP 'AEC' ]\n");
- rt3261_dsp_tab = rt3261_dsp_aec_ns_fens;
- tab_num = RT3261_DSP_AEC_NUM;
break;
case RT3261_DSP_HFBF:
cnt += sprintf(buf, "[ RT3261 DSP 'Beamforming' ]\n");
- rt3261_dsp_tab = rt3261_dsp_hfbf;
- tab_num = RT3261_DSP_HFBF_NUM;
break;
case RT3261_DSP_FFP:
cnt += sprintf(buf, "[ RT3261 DSP 'Far Field Pick-up' ]\n");
- rt3261_dsp_tab = rt3261_dsp_ffp;
- tab_num = RT3261_DSP_FFP_NUM;
break;
case RT3261_DSP_DIS:
goto dsp_done;
}
- for (i = 0; i < tab_num; i++) {
+ for (i = 0; i < RT3261_DSP_AEC_NUM; i++) {
if (cnt + RT3261_DSP_REG_DISP_LEN >= PAGE_SIZE)
break;
- val = rt3261_dsp_read(codec, rt3261_dsp_tab[i][0]);
+ val = rt3261_dsp_read(codec, rt3261_dsp_aec_ns_fens[i][0]);
if (!val)
continue;
cnt += snprintf(buf + cnt, RT3261_DSP_REG_DISP_LEN,
- "%04x: %04x\n", rt3261_dsp_tab[i][0], val);
+ "%04x: %04x\n", rt3261_dsp_aec_ns_fens[i][0], val);
}
dsp_done:
}
EXPORT_SYMBOL_GPL(rt3261_dsp_probe);
-int do_rt3261_dsp_set_mode(struct snd_soc_codec *codec, int mode) {
- struct rt3261_priv *rt3261 = snd_soc_codec_get_drvdata(codec);
- dev_dbg(codec->dev, "%s mode=%d\n",__func__,mode);
- if(rt3261->dsp_sw == mode)
- return 0;
- rt3261->dsp_sw = mode;
- if(rt3261->dsp_sw == RT3261_DSP_DIS)
- rt3261->dsp_play_pass = rt3261->dsp_rec_pass = 1;
- else
- rt3261->dsp_play_pass = rt3261->dsp_rec_pass = 0;
- rt3261_conn_mux_path(codec, "DAC L2 Mux",
- rt3261->dsp_play_pass ? "IF2" : "TxDC");
- rt3261_conn_mux_path(codec, "DAC R2 Mux",
- rt3261->dsp_play_pass ? "IF2" : "TxDC");
- rt3261_conn_mux_path(codec, "IF2 ADC L Mux",
- rt3261->dsp_rec_pass ? "Mono ADC MIXL" : "TxDP");
- rt3261_conn_mux_path(codec, "IF2 ADC R Mux",
- rt3261->dsp_rec_pass ? "Mono ADC MIXR" : "TxDP");
-
- if(rt3261->dsp_sw != RT3261_DSP_DIS)
- rt3261_dsp_snd_effect(codec);
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(do_rt3261_dsp_set_mode);
-
#ifdef RTK_IOCTL
int rt_codec_dsp_ioctl_common(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg)
{
#endif
#include "rt3261.h"
-#if (CONFIG_SND_SOC_RT3261_MODULE | CONFIG_SND_SOC_RT3261)
+#if defined (CONFIG_SND_SOC_RT3261)
#include "rt3261-dsp.h"
#endif
}
EXPORT_SYMBOL(rt3261_headset_detect);
-/**
- * rt3261_conn_mux_path - connect MUX widget path.
- * @codec: SoC audio codec device.
- * @widget_name: widget name.
- * @path_name: path name.
- *
- * Make MUX path connected and update register.
- *
- * Returns 0 for success or negative error code.
- */
-int rt3261_conn_mux_path(struct snd_soc_codec *codec,
- char *widget_name, char *path_name)
-{
- struct snd_soc_dapm_context *dapm = &codec->dapm;
- struct snd_soc_dapm_widget *w;
- struct snd_soc_dapm_path *path;
- struct snd_kcontrol_new *kcontrol;
- struct soc_enum *em;
- unsigned int val, mask, bitmask;
- int i, update = 0;
-
- if (codec == NULL || widget_name == NULL || path_name == NULL)
- return -EINVAL;
-
- list_for_each_entry(w, &dapm->card->widgets, list)
- {
- if (!w->name || w->dapm != dapm)
- continue;
- if (!(strcmp(w->name, widget_name))) {
- if (w->id != snd_soc_dapm_mux)
- return -EINVAL;
- dev_info(codec->dev, "w->name=%s\n", w->name);
- list_for_each_entry(path, &w->sources, list_sink)
- {
- if (!(strcmp(path->name, path_name)))
- path->connect = 1;
- else
- path->connect = 0;
- dev_info(codec->dev,
- "path->name=%s path->connect=%d\n",
- path->name, path->connect);
- }
- update = 1;
- break;
- }
- }
-
- if (update) {
- snd_soc_dapm_sync(dapm);
-
- kcontrol = &w->kcontrols[0];
- em = (struct soc_enum *)kcontrol->private_value;
- for (i = 0; i < em->max; i++)
- if (!(strcmp(path_name, em->texts[i])))
- break;
- for (bitmask = 1; bitmask < em->max; bitmask <<= 1)
- ;
- val = i << em->shift_l;
- mask = (bitmask - 1) << em->shift_l;
- snd_soc_update_bits(codec, em->reg, mask, val);
- }
-
- return 0;
-}
-EXPORT_SYMBOL(rt3261_conn_mux_path);
-
static const char *rt3261_dacr2_src[] = { "TxDC_R", "TxDP_R" };
static const SOC_ENUM_SINGLE_DECL(rt3261_dacr2_enum,RT3261_DUMMY_PR3F,
{"DAC R2 Mux", "IF2", "IF2 DAC R"},
{"DAC R2 Mux", "IF3", "IF3 DAC R"},
-#if (CONFIG_SND_SOC_RT3261_MODULE | CONFIG_SND_SOC_RT3261)
+#if defined (CONFIG_SND_SOC_RT3261)
{"DAC R2 Volume", NULL, "Mono dacr Mux"},
{"Mono dacr Mux", "TxDC_R", "DAC R2 Mux"},
{"Mono dacr Mux", "TxDP_R", "IF2 ADC R Mux"},
ARRAY_SIZE(rt3261_dapm_routes));
#if 0
-#if (CONFIG_SND_SOC_RT3261_MODULE | CONFIG_SND_SOC_RT3261)
+#if defined (CONFIG_SND_SOC_RT3261)
rt3261->dsp_sw = RT3261_DSP_AEC_NS_FENS;
rt3261_dsp_probe(codec);
#endif
ioctl_ops->ioctl_common = rt3261_ioctl_common;
realtek_ce_init_hwdep(codec);
#endif
+#endif
#endif
ret = device_create_file(codec->dev, &dev_attr_index_reg);
"Failed to create index_reg sysfs files: %d\n", ret);
return ret;
}
-#endif
rt3261_codec = codec;
return 0;
}
#ifdef CONFIG_PM
static int rt3261_suspend(struct snd_soc_codec *codec, pm_message_t state)
{
-#if (CONFIG_SND_SOC_RT3261_MODULE | CONFIG_SND_SOC_RT3261)
+#if defined (CONFIG_SND_SOC_RT3261)
/* After opening LDO of DSP, then close LDO of codec.
* (1) DSP LDO power on
* (2) DSP core power off
static int rt3261_resume(struct snd_soc_codec *codec)
{
rt3261_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
-#if (CONFIG_SND_SOC_RT3261_MODULE | CONFIG_SND_SOC_RT3261)
+#if defined (CONFIG_SND_SOC_RT3261)
/* After opening LDO of codec, then close LDO of DSP. */
//rt3261_dsp_resume(codec);
#endif