audio: meson: sdd sound card support for txl
authorXing Wang <xing.wang@amlogic.com>
Thu, 12 Jul 2018 14:17:24 +0000 (22:17 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Wed, 18 Jul 2018 09:52:22 +0000 (02:52 -0700)
PD#168480: audio: meson: add sound card support for txl

Change-Id: I89117e1cfee2bc99289b00f8ead4acb2f1b13a98
Signed-off-by: Xing Wang <xing.wang@amlogic.com>
arch/arm64/configs/meson64_defconfig
arch/arm64/configs/meson64_smarthome_defconfig
drivers/amlogic/pinctrl/pinctrl-meson-txl.c
sound/soc/amlogic/meson/i2s_dai.c
sound/soc/amlogic/meson/tv.c
sound/soc/codecs/amlogic/Kconfig
sound/soc/codecs/amlogic/Makefile
sound/soc/codecs/amlogic/aml_codec_t9015S.c

index a44a080b3c8d7f7e181d0eeeb3f619038143f1bb..a3e1cd43ae29ac30bcdcc0110a58f6b7984b001e 100644 (file)
@@ -463,6 +463,7 @@ CONFIG_AMLOGIC_SND_CODEC_DUMMY_CODEC=y
 CONFIG_AMLOGIC_SND_CODEC_PCM2BT=y
 CONFIG_AMLOGIC_SND_CODEC_PDM_DUMMY_CODEC=y
 CONFIG_AMLOGIC_SND_CODEC_AMLT9015=y
+CONFIG_AMLOGIC_SND_CODEC_AMLT9015S=y
 CONFIG_AMLOGIC_SND_CODEC_TXLX_ACODEC=y
 CONFIG_AMLOGIC_SND_SOC_TAS5707=y
 CONFIG_AMLOGIC_SND_SOC_TLV320ADC3101=y
index 2db73b444abebdbd47242e815fcfa6b67c0a3d23..4adbfee827e10d7f64966b31c2d80b46f28738f6 100644 (file)
@@ -407,6 +407,7 @@ CONFIG_AMLOGIC_SND_CODEC_DUMMY_CODEC=y
 CONFIG_AMLOGIC_SND_CODEC_PCM2BT=y
 CONFIG_AMLOGIC_SND_CODEC_PDM_DUMMY_CODEC=y
 CONFIG_AMLOGIC_SND_CODEC_AMLT9015=y
+CONFIG_AMLOGIC_SND_CODEC_AMLT9015S=y
 CONFIG_AMLOGIC_SND_CODEC_TXLX_ACODEC=y
 CONFIG_AMLOGIC_SND_SOC_TAS5707=y
 CONFIG_AMLOGIC_SND_SOC_TLV320ADC3101=y
index 9e63dd910ddde06e70c59ab98a8f091306198c8a..8732de076319e872756ad220bfda750b6cc4aede 100644 (file)
@@ -494,6 +494,7 @@ static struct meson_pmx_group meson_txl_periphs_groups[] = {
        GROUP(uart_rts_c,       4,      22),
        GROUP(spdif_out,        3,      30),
        GROUP(spdif_in,         3,      31),
+       GROUP(i2s_aoclk_out_z,  4,  9),
        GROUP(i2s_lrclk_out_z,  4,      8),
        GROUP(i2s_aoclk_in_z,   4,      3),
        GROUP(i2s_lrclk_in_z,   4,      2),
@@ -812,7 +813,7 @@ static const char * const hdmirx_d_groups[] = {
 static const char * const i2s_groups[] = {
        "i2s_lrclk_out_dv", "i2s_aoclk_in_dv", "i2s_lrclk_in_dv",
        "i2s_amclk_dv", "i2s_out_ch01_dv", "i2s_in_ch01_dv",
-
+       "i2s_aoclk_out_z",
        "i2s_lrclk_out_z", "i2s_aoclk_in_z", "i2s_lrclk_in_z",
        "i2s_amclk_z", "i2s_out_ch01_z", "i2s_in_ch01_z",
 
index af4bd4e2564d24108e1602e797341b4dc5a5b539..79a54e96f80cc58987cce8981f781c0a0608d885 100644 (file)
@@ -405,7 +405,7 @@ static const struct snd_soc_component_driver aml_component = {
 /*
  * vdac_clk should be managed in audio module for kernel4.9,
  * not in vpu for kernel3.14
- * aud_buf has been remove from txlx/txhd
+ * aud_buf has been remove from txl/txlx/txhd
  */
 static const char *const gate_names[] = {
        "top_glue", "aud_buf", "i2s_out", "amclk_measure",
index 69fd5ef4943daf492b03b6b6b73953abea69df54..a8841135a7dccf010c3bbcc80474f76bd8f08c11 100644 (file)
@@ -1963,6 +1963,13 @@ int txhd_set_audin_source(int audin_src)
        return 0;
 }
 
+int txl_set_resample_param(int index)
+{
+       set_hw_resample_param(index);
+
+       return 0;
+}
+
 int txlx_set_resample_param(int index)
 {
        set_hw_resample_param(index);
@@ -1994,6 +2001,7 @@ static struct aml_card_info tv_txl_info = {
        },
        .chipset_init        = txl_chipset_init,
        .set_audin_source    = txl_set_audin_source,
+       .set_resample_param  = txl_set_resample_param,
 };
 
 static struct aml_card_info tv_txlx_info = {
index b87ae1d9e58b7c16b9617d04e57fadc6835555af..e88add8c43bd2f00186f468c0b1b91ea4f60bfdb 100644 (file)
@@ -48,6 +48,16 @@ config AMLOGIC_SND_CODEC_AMLT9015
                AMLT9015 codec,
                this codec is internal
 
+config AMLOGIC_SND_CODEC_AMLT9015S
+        bool "Amlogic Audio AMLT9015S codec"
+        depends on AMLOGIC_SND_SOC_CODECS
+        default n
+        help
+                Amlogic Audio codec,
+                AMLT9015S codec,
+                AMLT9015S codec,
+                this codec is internal
+
 config AMLOGIC_SND_CODEC_PMU3
         bool "Amlogic Audio AML PMU3 codec"
         depends on AMLOGIC_SND_SOC_CODECS
index 400211135f36f51e7928502390a1371c185fa8fe..c64a36c89898fc30c327e8aa7f05effa73bcfd56 100644 (file)
@@ -6,6 +6,7 @@ snd-soc-dummy_codec-objs := dummy_codec.o
 snd-soc-pdm-dummy-objs := pdm_dummy.o
 snd-soc-pcm2bt-objs  := pcm2bt.o
 snd-soc-aml_t9015-objs := aml_codec_t9015.o
+snd-soc-aml_t9015s-objs := aml_codec_t9015S.o
 snd-soc-pmu3-objs := aml_pmu3.o
 snd-soc-aml_codec_txlx_acodec-objs := aml_codec_txlx_acodec.o
 
@@ -22,6 +23,7 @@ obj-$(CONFIG_AMLOGIC_SND_CODEC_DUMMY_CODEC) += snd-soc-dummy_codec.o
 obj-$(CONFIG_AMLOGIC_SND_CODEC_PDM_DUMMY_CODEC) += snd-soc-pdm-dummy.o
 obj-$(CONFIG_AMLOGIC_SND_CODEC_PCM2BT) += snd-soc-pcm2bt.o
 obj-$(CONFIG_AMLOGIC_SND_CODEC_AMLT9015) += snd-soc-aml_t9015.o
+obj-$(CONFIG_AMLOGIC_SND_CODEC_AMLT9015S) += snd-soc-aml_t9015s.o
 obj-$(CONFIG_AMLOGIC_SND_CODEC_PMU3) += snd-soc-pmu3.o
 obj-$(CONFIG_AMLOGIC_SND_CODEC_TXLX_ACODEC) += snd-soc-aml_codec_txlx_acodec.o
 
index a180fb05b6bd03460520997aedb6fe77e52aad74..cd3704db908eb3cd1b4f2aa74f4b5e7198821b05 100644 (file)
@@ -46,7 +46,7 @@ struct aml_T9015S_audio_priv {
 };
 
 static const struct reg_default t9015s_init_list[] = {
-       {AUDIO_CONFIG_BLOCK_ENABLE, 0x1403BCFF},
+       {AUDIO_CONFIG_BLOCK_ENABLE, 0x34003CFF},
        {ADC_VOL_CTR_PGA_IN_CONFIG, 0x50502929},
        {DAC_VOL_CTR_DAC_SOFT_MUTE, 0xFBFB0000},
        {LINE_OUT_CONFIG, 0x00004444},
@@ -106,7 +106,7 @@ static int aml_DAC_Gain_set_enum(
                pr_info("It has risk of distortion!\n");
        }
 
-       snd_soc_write(codec, val, add);
+       snd_soc_write(codec, add, val);
        return 0;
 }
 
@@ -230,7 +230,7 @@ static const struct snd_soc_dapm_widget T9015S_audio_dapm_widgets[] = {
        SND_SOC_DAPM_PGA("PGAL_IN_EN", AUDIO_CONFIG_BLOCK_ENABLE,
                         PGAL_IN_EN, 0, NULL, 0),
        SND_SOC_DAPM_PGA("PGAR_IN_EN", AUDIO_CONFIG_BLOCK_ENABLE,
-                        PGAL_IN_EN, 0, NULL, 0),
+                        PGAR_IN_EN, 0, NULL, 0),
 
        /*PGA input source select */
        SND_SOC_DAPM_MUX("Linein left switch", SND_SOC_NOPM,
@@ -381,11 +381,8 @@ static int aml_T9015S_audio_set_bias_level(struct snd_soc_codec *codec,
                break;
 
        case SND_SOC_BIAS_STANDBY:
-               if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
-                       codec->cache_only = false;
-                       codec->cache_sync = 1;
+               if (codec->component.dapm.bias_level == SND_SOC_BIAS_OFF)
                        snd_soc_cache_sync(codec);
-               }
                break;
 
        case SND_SOC_BIAS_OFF:
@@ -395,7 +392,7 @@ static int aml_T9015S_audio_set_bias_level(struct snd_soc_codec *codec,
        default:
                break;
        }
-       codec->dapm.bias_level = level;
+       codec->component.dapm.bias_level = level;
 
        return 0;
 }
@@ -403,7 +400,23 @@ static int aml_T9015S_audio_set_bias_level(struct snd_soc_codec *codec,
 static int aml_T9015S_prepare(struct snd_pcm_substream *substream,
                            struct snd_soc_dai *dai)
 {
-       /*struct snd_soc_codec *codec = dai->codec;*/
+       struct snd_soc_codec *codec = dai->codec;
+       u32 value = snd_soc_read(codec, AUDIO_CONFIG_BLOCK_ENABLE);
+       bool Vmid_eanble = (bool)((value >> VMID_GEN_EN) & 0x1);
+
+       if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && !Vmid_eanble) {
+               pr_info("aml_T9015S_prepare caputre!\n");
+               value |= 0x1 << VMID_GEN_EN;
+               snd_soc_write(codec, AUDIO_CONFIG_BLOCK_ENABLE, value);
+       } else if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+               pr_info("aml_T9015S_prepare playback!\n");
+               value &= ~(0x1 << VMID_GEN_EN);
+               snd_soc_write(codec, AUDIO_CONFIG_BLOCK_ENABLE, value);
+               msleep(20);
+               value |= 0x1 << VMID_GEN_EN;
+               snd_soc_write(codec, AUDIO_CONFIG_BLOCK_ENABLE, value);
+       }
+
        return 0;
 
 }
@@ -466,7 +479,7 @@ static int aml_T9015S_audio_probe(struct snd_soc_codec *codec)
 
        aml_audin_update_bits(AUDIN_SOURCE_SEL, 3, 3);
 
-       codec->dapm.bias_level = SND_SOC_BIAS_STANDBY;
+       codec->component.dapm.bias_level = SND_SOC_BIAS_STANDBY;
        T9015S_audio->codec = codec;
 
        return 0;
@@ -492,7 +505,7 @@ static int aml_T9015S_audio_resume(struct snd_soc_codec *codec)
        aml_T9015S_audio_reset(codec);
        aml_T9015S_audio_start_up(codec);
        aml_T9015S_audio_reg_init(codec);
-       codec->dapm.bias_level = SND_SOC_BIAS_STANDBY;
+       codec->component.dapm.bias_level = SND_SOC_BIAS_STANDBY;
        aml_T9015S_audio_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
        return 0;
 }