);
}
+void auge_toacodec_ctrl_ext(int tdmout_id, int ch0_sel, int ch1_sel)
+{
+ // TODO: check skew for tl1/sm1
+ audiobus_write(EE_AUDIO_TOACODEC_CTRL0,
+ 1 << 31
+ | ((tdmout_id << 2) + ch1_sel) << 20 /* data 1 */
+ | ((tdmout_id << 2) + ch0_sel) << 16 /* data 0 */
+ | tdmout_id << 12 /* lrclk */
+ | 1 << 9 /* Bclk_cap_inv*/
+ | tdmout_id << 4 /* bclk */
+ | tdmout_id << 0 /* mclk */
+ );
+}
+
void fratv_enable(bool enable)
{
/* Need reset firstlry ? */
}
static int ad82584f_init(struct snd_soc_codec *codec)
{
+ struct ad82584f_priv *ad82584f = snd_soc_codec_get_drvdata(codec);
+
reset_ad82584f_GPIO(codec);
dev_info(codec->dev, "ad82584f_init!\n");
ad82584f_reg_init(codec);
+ /* Bclk system */
+ if (ad82584f->pdata->no_mclk)
+ snd_soc_write(codec,
+ 0x01,
+ 0x1 << 7 | /* Bclk system enable */
+ 0x1 << 0 /* 64x bclk/fs */
+ );
+
/*eq and drc*/
ad82584f_set_eq_drc(codec);
}
ad82584f->pdata->reset_pin = reset_pin;
+ ad82584f->pdata->no_mclk = of_property_read_bool(
+ np,
+ "no_mclk");
+ if (ad82584f->pdata->no_mclk)
+ pr_info("%s mclk is not connected.\n", __func__);
+
return ret;
}
/* codec is used by meson or auge arch */
bool is_auge_arch;
+ /* tocodec ctrl supports in and out data */
+ bool tocodec_inout;
+ /* attach which tdm when play */
int tdmout_index;
+ /* channel map */
+ int ch0_sel;
+ int ch1_sel;
};
static const struct reg_default t9015_init_list[] = {
struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
-#if 0
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
- u32 add, val, val1, val2;
-#endif
- /*TODO: return 0 for tmp, this wolud modified later */
- return 0;
-#if 0
- if (codec == NULL)
- return -1;
+ u32 reg_addr = ADC_VOL_CTR_PGA_IN_CONFIG;
+ u32 val = snd_soc_read(codec, reg_addr);
+ u32 val1 = (val & (0x1 << DAC_GAIN_SEL_L))
+ >> DAC_GAIN_SEL_L;
+ u32 val2 = (val & (0x1 << DAC_GAIN_SEL_H))
+ >> (DAC_GAIN_SEL_H);
- add = ADC_VOL_CTR_PGA_IN_CONFIG;
- val = snd_soc_read(codec, add);
- val1 = (val & (0x1 << DAC_GAIN_SEL_L)) >> DAC_GAIN_SEL_L;
- val2 = (val & (0x1 << DAC_GAIN_SEL_H)) >> (DAC_GAIN_SEL_H - 1);
+ val = val1 | (val2 << 1);
- val = val1 | val2;
ucontrol->value.enumerated.item[0] = val;
+
return 0;
- #endif
}
static int aml_DAC_Gain_set_enum(
{
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
- u32 add = ADC_VOL_CTR_PGA_IN_CONFIG;
- u32 val = snd_soc_read(codec, add);
+ u32 addr = ADC_VOL_CTR_PGA_IN_CONFIG;
+ u32 val = snd_soc_read(codec, addr);
if (ucontrol->value.enumerated.item[0] == 0) {
val &= ~(0x1 << DAC_GAIN_SEL_H);
pr_info("It has risk of distortion!\n");
}
- snd_soc_write(codec, val, add);
+ snd_soc_write(codec, addr, val);
return 0;
}
aml_T9015_audio_start_up(codec);
aml_T9015_audio_reg_init(codec);
- if (T9015_audio && T9015_audio->is_auge_arch)
- auge_toacodec_ctrl(T9015_audio->tdmout_index);
- else
+ if (T9015_audio && T9015_audio->is_auge_arch) {
+ if (T9015_audio->tocodec_inout)
+ auge_toacodec_ctrl_ext(
+ T9015_audio->tdmout_index,
+ T9015_audio->ch0_sel,
+ T9015_audio->ch1_sel);
+ else
+ auge_toacodec_ctrl(T9015_audio->tdmout_index);
+ } else
aml_write_cbus(AIU_ACODEC_CTRL,
(1 << 4)
|(1 << 6)
T9015_audio->is_auge_arch = of_property_read_bool(
pdev->dev.of_node,
"is_auge_used");
+
+ T9015_audio->tocodec_inout = of_property_read_bool(
+ pdev->dev.of_node,
+ "tocodec_inout");
+
of_property_read_u32(
pdev->dev.of_node,
"tdmout_index",
&T9015_audio->tdmout_index);
- pr_info("aml_codec_T9015 is used by %s chipset, tdmout:%d\n",
+ of_property_read_u32(
+ pdev->dev.of_node,
+ "ch0_sel",
+ &T9015_audio->ch0_sel);
+
+ of_property_read_u32(
+ pdev->dev.of_node,
+ "ch1_sel",
+ &T9015_audio->ch1_sel);
+
+ pr_info("T9015 acodec used by %s, tdmout:%d\n",
T9015_audio->is_auge_arch ? "auge" : "meson",
T9015_audio->tdmout_index);