ASoC: rt5670: add set_bclk_ratio in dai ops
Subsystems (3)
PATCH v2 1/1 ASoC: rt5670: add set_bclk_ratio in dai ops
We need to set a specific bit for 50 bclk rate. So add set_bclk_ratio function to set the bit.
---
v2:
* add define for tdm data format select bit.
--- sound/soc/codecs/rt5670.c | 19 +++++++++++++++++++ sound/soc/codecs/rt5670.h | 4 ++++ 2 files changed, 23 insertions(+)
sound/soc/codecs/rt5670.c +19 -0
@@ -2582,6 +2582,24 @@ static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,return 0 ; } +static int rt5670_set_bclk_ratio (struct snd_soc_dai *dai,unsigned int ratio) +{ +struct snd_soc_codec *codec = dai->codec; + +dev_dbg (codec->dev,"%s ratio=%d\n" , __func__, ratio); +if (dai->id !=RT5670_AIF1 ) +return 0 ; + +if (ratio ==50 ) +snd_soc_update_bits (codec,RT5670_GEN_CTRL3 , +RT5670_TDM_DATA_MODE_SEL ,RT5670_TDM_DATA_MODE_50FS ); +else +snd_soc_update_bits (codec,RT5670_GEN_CTRL3 , +RT5670_TDM_DATA_MODE_SEL ,RT5670_TDM_DATA_MODE_NOR ); + +return 0 ; +} +static int rt5670_set_bias_level (struct snd_soc_codec *codec,enum snd_soc_bias_level level) {
@@ -2712,6 +2730,7 @@ static const struct snd_soc_dai_ops rt5670_aif_dai_ops = { .set_fmt = rt5670_set_dai_fmt, .set_tdm_slot = rt5670_set_tdm_slot, .set_pll = rt5670_set_dai_pll, + .set_bclk_ratio = rt5670_set_bclk_ratio, };static struct snd_soc_dai_driver rt5670_dai[] = {
sound/soc/codecs/rt5670.h +4 -0
@@ -1816,6 +1816,10 @@#define RT5670_ZCD_HP_DIS (0x0 << 15)#define RT5670_ZCD_HP_EN (0x1 << 15) +/* General Control 3 (0xfc) */ +#define RT5670_TDM_DATA_MODE_SEL (0x1 << 11) +#define RT5670_TDM_DATA_MODE_NOR (0x0 << 11) +#define RT5670_TDM_DATA_MODE_50FS (0x1 << 11)/* Codec Private Register definition */ /* 3D Speaker Control (0x63) */
Signature · 1 line
2.7.4
Quoted 2 lines · Bard Liao
We need to set a specific bit for 50 bclk rate. So add
set_bclk_ratiofunction to set the bit.
When is this supposed to be used? the cht_bsw_rt5672 machine driver uses a 19.2MHz MCLK/2.4 MHz bclk, so there's a typical 50x ratio.
Quoted 63 lines
Signed-off-by Bard Liao <[email protected]>---
v2:
* add define for tdm data format select bit.--- sound/soc/codecs/rt5670.c | 19 +++++++++++++++++++ sound/soc/codecs/rt5670.h | 4 ++++ 2 files changed, 23 insertions(+)sound/soc/codecs/rt5670.c +19
-0@@ -2582,6 +2582,24 @@ static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,return 0 ; } +static int rt5670_set_bclk_ratio (struct snd_soc_dai *dai,unsigned int ratio) +{ +struct snd_soc_codec *codec = dai->codec; + +dev_dbg (codec->dev,"%s ratio=%d\n" , __func__, ratio); +if (dai->id !=RT5670_AIF1 ) +return 0 ; + +if (ratio ==50 ) +snd_soc_update_bits (codec,RT5670_GEN_CTRL3 , +RT5670_TDM_DATA_MODE_SEL ,RT5670_TDM_DATA_MODE_50FS ); +else +snd_soc_update_bits (codec,RT5670_GEN_CTRL3 , +RT5670_TDM_DATA_MODE_SEL ,RT5670_TDM_DATA_MODE_NOR ); + +return 0 ; +} +static int rt5670_set_bias_level (struct snd_soc_codec *codec,enum snd_soc_bias_level level) {@@ -2712,6 +2730,7 @@ static const struct snd_soc_dai_ops rt5670_aif_dai_ops = { .set_fmt = rt5670_set_dai_fmt, .set_tdm_slot = rt5670_set_tdm_slot, .set_pll = rt5670_set_dai_pll, + .set_bclk_ratio = rt5670_set_bclk_ratio, };static struct snd_soc_dai_driver rt5670_dai[] = {sound/soc/codecs/rt5670.h +4
-0@@ -1816,6 +1816,10 @@#define RT5670_ZCD_HP_DIS (0x0 << 15)#define RT5670_ZCD_HP_EN (0x1 << 15) +/* General Control 3 (0xfc) */ +#define RT5670_TDM_DATA_MODE_SEL (0x1 << 11) +#define RT5670_TDM_DATA_MODE_NOR (0x0 << 11) +#define RT5670_TDM_DATA_MODE_50FS (0x1 << 11)/* Codec Private Register definition */ /* 3D Speaker Control (0x63) */
Quoted 8 lines
-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Tuesday, September 12, 2017 10:54 PM
To: Bard Liao; [email protected]; [email protected]
Cc: Oder Chiou; Jack Yu; [email protected]; [email protected]; [email protected]; Shuming [范書銘]; Flove(HsinFu)
Subject: Re: [alsa-devel] [PATCH v2] ASoC: rt5670: addset_bclk_ratioin dai ops
Quoted 6 lines
Quoted 2 lines · Bard Liao
We need to set a specific bit for 50 bclk rate. So add
set_bclk_ratiofunction to set the bit.When is this supposed to be used? the
cht_bsw_rt5672machine driver uses a 19.2MHz MCLK/2.4 MHz bclk, so there's a typical 50x ratio.
I think it should be used for all Intel platform. The bit will only be effective in PCM mode with TDM enabled. It will influence the data allocation format.
0: the dummy bits will be allocate at the end of each slot. 1: the dummy bits will be allocate at the end of all slots. For example, 50fs with 24 bits data length.
0: 24 bits slot0 data + 1 dummy bit + 24 bits slot1 data + 1 dummy bit 1: 24 bits slot0 data + 24 bits slot1 data + 2 dummy bits
I will do slight modification on the patch since the bit should be set for all bclk rate which is divisible by 50.
Quoted 65 lines
sound/soc/codecs/rt5670.c static int rt5670_set_tdm_slot(struct snd_soc_dai
Quoted 16 lines
Signed-off-by Bard Liao <[email protected]>---
v2:
* add define for tdm data format select bit.--- sound/soc/codecs/rt5670.c | 19 +++++++++++++++++++ sound/soc/codecs/rt5670.h | 4 ++++ 2 files changed, 23 insertions(+)sound/soc/codecs/rt5670.c +0
-0@@ -2582,6 +2582,24 @@ static int rt5670_set_tdm_slot(struct snd_soc_dai*dai, unsigned int
tx_mask,Quoted 4 lines
sound/soc/codecs/rt5670.c +1
-0return 0 ; } +static int rt5670_set_bclk_ratio (struct snd_soc_dai *dai,unsigned int ratio)sound/soc/codecs/rt5670.c static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
Quoted 10 lines
sound/soc/codecs/rt5670.c +10
-0+{ +struct snd_soc_codec *codec = dai->codec; + +dev_dbg (codec->dev,"%s ratio=%d\n" , __func__, ratio); +if (dai->id !=RT5670_AIF1 ) +return 0 ; + +if (ratio ==50 ) + snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + RT5670_TDM_DATA_MODE_SEL,
RT5670_TDM_DATA_MODE_50FS);sound/soc/codecs/rt5670.c static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
Quoted 3 lines
sound/soc/codecs/rt5670.c +3
-0+else + snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + RT5670_TDM_DATA_MODE_SEL,
RT5670_TDM_DATA_MODE_NOR);sound/soc/codecs/rt5670.c static const struct snd_soc_dai_ops
Quoted 8 lines
sound/soc/codecs/rt5670.c +4
-0+ +return 0 ; +} +static int rt5670_set_bias_level (struct snd_soc_codec *codec,enum snd_soc_bias_level level) {@@ -2712,6 +2730,7 @@ static const struct snd_soc_dai_ops
rt5670_aif_dai_ops= {Quoted 20 lines
sound/soc/codecs/rt5670.c +1
-0.set_fmt = rt5670_set_dai_fmt, .set_tdm_slot = rt5670_set_tdm_slot, .set_pll = rt5670_set_dai_pll, + .set_bclk_ratio = rt5670_set_bclk_ratio, };static struct snd_soc_dai_driver rt5670_dai[] = {sound/soc/codecs/rt5670.h +4
-0@@ -1816,6 +1816,10 @@#define RT5670_ZCD_HP_DIS (0x0 << 15)#define RT5670_ZCD_HP_EN (0x1 << 15) +/* General Control 3 (0xfc) */ +#define RT5670_TDM_DATA_MODE_SEL (0x1 << 11) +#define RT5670_TDM_DATA_MODE_NOR (0x0 << 11) +#define RT5670_TDM_DATA_MODE_50FS (0x1 << 11)
Quoted 6 lines
sound/soc/codecs/rt5670.h line 1825
Quoted 3 lines
sound/soc/codecs/rt5670.h +0
-0/* Codec Private Register definition */ /* 3D Speaker Control (0x63) */ ------Please consider the environment before printing this e-mail.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 24 lines · Bard Liao
Quoted 8 lines
-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Tuesday, September 12, 2017 10:54 PM
To: Bard Liao; [email protected]; [email protected]
Cc: Oder Chiou; Jack Yu; [email protected]; [email protected]; [email protected]; Shuming [范書銘]; Flove(HsinFu)
Subject: Re: [alsa-devel] [PATCH v2] ASoC: rt5670: addset_bclk_ratioin dai opsQuoted 6 lines
Quoted 2 lines · Bard Liao
We need to set a specific bit for 50 bclk rate. So add
set_bclk_ratiofunction to set the bit.When is this supposed to be used? the
cht_bsw_rt5672machine driver uses a 19.2MHz MCLK/2.4 MHz bclk, so there's a typical 50x ratio.I think it should be used for all Intel platform. The bit will only be effective in PCM mode with TDM enabled. It will influence the data allocation format.
0: the dummy bits will be allocate at the end of each slot. 1: the dummy bits will be allocate at the end of all slots. For example, 50fs with 24 bits data length.
0: 24 bits slot0 data + 1 dummy bit + 24 bits slot1 data + 1 dummy bit 1: 24 bits slot0 data + 24 bits slot1 data + 2 dummy bits
Quoted 2 lines
I will do slight modification on the patch since the bit should be set for all bclk rate which is divisible by 50.
I am not sure I understand the 0: and 1: cases, and since we get audio today with this codec and a ratio of 200 (4 24-bit slots in DSP_B) I don't get what happens with this fix.
Quoted 72 lines
Quoted 66 lines
sound/soc/codecs/rt5670.c static int rt5670_set_tdm_slot(struct snd_soc_dai
Quoted 17 lines
Signed-off-by Bard Liao <[email protected]>---
v2:
* add define for tdm data format select bit.--- sound/soc/codecs/rt5670.c | 19 +++++++++++++++++++ sound/soc/codecs/rt5670.h | 4 ++++ 2 files changed, 23 insertions(+)sound/soc/codecs/rt5670.c +0
-0@@ -2582,6 +2582,24 @@ static int rt5670_set_tdm_slot(struct snd_soc_dai*dai, unsigned int
tx_mask,Quoted 4 lines
sound/soc/codecs/rt5670.c +1
-0return 0 ; } +static int rt5670_set_bclk_ratio (struct snd_soc_dai *dai,unsigned int ratio)sound/soc/codecs/rt5670.c static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
Quoted 10 lines
sound/soc/codecs/rt5670.c +10
-0+{ +struct snd_soc_codec *codec = dai->codec; + +dev_dbg (codec->dev,"%s ratio=%d\n" , __func__, ratio); +if (dai->id !=RT5670_AIF1 ) +return 0 ; + +if (ratio ==50 ) + snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + RT5670_TDM_DATA_MODE_SEL,
RT5670_TDM_DATA_MODE_50FS);sound/soc/codecs/rt5670.c static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
Quoted 3 lines
sound/soc/codecs/rt5670.c +3
-0+else + snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + RT5670_TDM_DATA_MODE_SEL,
RT5670_TDM_DATA_MODE_NOR);sound/soc/codecs/rt5670.c static const struct snd_soc_dai_ops
Quoted 8 lines
sound/soc/codecs/rt5670.c +4
-0+ +return 0 ; +} +static int rt5670_set_bias_level (struct snd_soc_codec *codec,enum snd_soc_bias_level level) {@@ -2712,6 +2730,7 @@ static const struct snd_soc_dai_ops
rt5670_aif_dai_ops= {Quoted 20 lines
sound/soc/codecs/rt5670.c +1
-0.set_fmt = rt5670_set_dai_fmt, .set_tdm_slot = rt5670_set_tdm_slot, .set_pll = rt5670_set_dai_pll, + .set_bclk_ratio = rt5670_set_bclk_ratio, };static struct snd_soc_dai_driver rt5670_dai[] = {sound/soc/codecs/rt5670.h +4
-0@@ -1816,6 +1816,10 @@#define RT5670_ZCD_HP_DIS (0x0 << 15)#define RT5670_ZCD_HP_EN (0x1 << 15) +/* General Control 3 (0xfc) */ +#define RT5670_TDM_DATA_MODE_SEL (0x1 << 11) +#define RT5670_TDM_DATA_MODE_NOR (0x0 << 11) +#define RT5670_TDM_DATA_MODE_50FS (0x1 << 11)Quoted 6 lines
sound/soc/codecs/rt5670.h line 1825
Quoted 3 lines
sound/soc/codecs/rt5670.h +0
-0/* Codec Private Register definition */ /* 3D Speaker Control (0x63) */ ------Please consider the environment before printing this e-mail.
Quoted 5 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 34 lines
-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Thursday, September 14, 2017 1:45 AM
To: Bard Liao; [email protected]; [email protected]
Cc: Oder Chiou; Jack Yu; [email protected]; [email protected]; [email protected]; Shuming [范書銘]; Flove(HsinFu)
Subject: Re: [alsa-devel] [PATCH v2] ASoC: rt5670: addset_bclk_ratioin dai opsQuoted 7 lines · Bard Liao
Quoted 7 lines
-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Tuesday, September 12, 2017 10:54 PM
To: Bard Liao; [email protected]; [email protected]
Cc: Oder Chiou; Jack Yu; [email protected]; [email protected]; [email protected]; Shuming [范書銘]; Flove(HsinFu)
Subject: Re: [alsa-devel] [PATCH v2] ASoC: rt5670: addset_bclk_ratioin daiops
Quoted 17 lines
Quoted 7 lines · Bard Liao
Quoted 2 lines
We need to set a specific bit for 50 bclk rate. So add
set_bclk_ratiofunction to set the bit.When is this supposed to be used? the
cht_bsw_rt5672machine driver uses a 19.2MHz MCLK/2.4 MHz bclk, so there's a typical 50x ratio.I think it should be used for all Intel platform. The bit will only be effective in PCM mode with TDM enabled. It will influence the data allocation format.
0: the dummy bits will be allocate at the end of each slot. 1: the dummy bits will be allocate at the end of all slots. For example, 50fs with 24 bits data length.
0: 24 bits slot0 data + 1 dummy bit + 24 bits slot1 data + 1 dummy bit 1: 24 bits slot0 data + 24 bits slot1 data + 2 dummy bits
Quoted 6 lines
Quoted 2 lines
I will do slight modification on the patch since the bit should be set for all bclk rate which is divisible by 50.
I am not sure I understand the 0: and 1: cases, and since we get audio today with this codec and a ratio of 200 (4 24-bit slots in
DSP_B) I don't get what happens with this fix.
From my experience, most Intel platforms use case 1 format. The issue will be incorrect recording volume due to bit allocation is shifted.
If Intel expected case 1 format but Realtek send case 0 format. It would be no problem with slot 0. But for slot 1, it will be:
Intel expected: 24 bits valid data for slot 1
Realtek sent: 1 dummy bit for slot 0 + 24 bits data for slot 1 So what Intel actually received will be 1 dummy bit + 23 bits data And it is similar to other slots.
BTW, if you don't meet the issue, you don't need to call snd_soc_dai_set_bclk_ratio on your machine driver.
Quoted 19 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Signed-off-by Bard Liao <[email protected]>---
v2:
* add define for tdm data format select bit.--- sound/soc/codecs/rt5670.c | 19 +++++++++++++++++++ sound/soc/codecs/rt5670.h | 4 ++++ 2 files changed, 23 insertions(+)Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/rt5670.c static int rt5670_set_tdm_slot(struct
Quoted 5 lines
sound/soc/codecs/rt5670.c +0
-0@@ -2582,6 +2582,24 @@ static int rt5670_set_tdm_slot(struct
snd_soc_dai
Quoted 61 lines
Quoted 5 lines
Quoted 5 lines
*dai, unsigned int
tx_mask,Quoted 4 lines
sound/soc/codecs/rt5670.c +1
-0return 0 ; } +static int rt5670_set_bclk_ratio(struct snd_soc_dai *dai, unsigned intratio)
Quoted 55 lines
Quoted 44 lines
sound/soc/codecs/rt5670.c static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
Quoted 10 lines
sound/soc/codecs/rt5670.c +10
-0+{ +struct snd_soc_codec *codec = dai->codec; + +dev_dbg (codec->dev,"%s ratio=%d\n" , __func__, ratio); +if (dai->id !=RT5670_AIF1 ) +return 0 ; + +if (ratio ==50 ) + snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + RT5670_TDM_DATA_MODE_SEL,
RT5670_TDM_DATA_MODE_50FS);sound/soc/codecs/rt5670.c static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
Quoted 3 lines
sound/soc/codecs/rt5670.c +3
-0+else + snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + RT5670_TDM_DATA_MODE_SEL,
RT5670_TDM_DATA_MODE_NOR);sound/soc/codecs/rt5670.c static const struct snd_soc_dai_ops
Quoted 8 lines
sound/soc/codecs/rt5670.c +4
-0+ +return 0 ; +} +static int rt5670_set_bias_level (struct snd_soc_codec *codec,enum snd_soc_bias_level level) {@@ -2712,6 +2730,7 @@ static const struct snd_soc_dai_ops
rt5670_aif_dai_ops= {Quoted 20 lines
sound/soc/codecs/rt5670.c +1
-0.set_fmt = rt5670_set_dai_fmt, .set_tdm_slot = rt5670_set_tdm_slot, .set_pll = rt5670_set_dai_pll, + .set_bclk_ratio = rt5670_set_bclk_ratio, };static struct snd_soc_dai_driver rt5670_dai[] = {sound/soc/codecs/rt5670.h +4
-0@@ -1816,6 +1816,10 @@#define RT5670_ZCD_HP_DIS (0x0 << 15)#define RT5670_ZCD_HP_EN (0x1 << 15) +/* General Control 3 (0xfc) */ +#define RT5670_TDM_DATA_MODE_SEL (0x1 << 11) +#define RT5670_TDM_DATA_MODE_NOR (0x0 << 11) +#define RT5670_TDM_DATA_MODE_50FS (0x1 << 11)Quoted 6 lines
sound/soc/codecs/rt5670.h line 1825
Quoted 3 lines
sound/soc/codecs/rt5670.h +0
-0/* Codec Private Register definition */ /* 3D Speaker Control (0x63) */ ------Please consider the environment before printing this e-mail.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 41 lines · Bard Liao
Quoted 34 lines
-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Thursday, September 14, 2017 1:45 AM
To: Bard Liao; [email protected]; [email protected]
Cc: Oder Chiou; Jack Yu; [email protected]; [email protected]; [email protected]; Shuming [范書銘]; Flove(HsinFu)
Subject: Re: [alsa-devel] [PATCH v2] ASoC: rt5670: addset_bclk_ratioin dai opsQuoted 7 lines · Bard Liao
Quoted 7 lines
-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Tuesday, September 12, 2017 10:54 PM
To: Bard Liao; [email protected]; [email protected]
Cc: Oder Chiou; Jack Yu; [email protected]; [email protected]; [email protected]; Shuming [范書銘]; Flove(HsinFu)
Subject: Re: [alsa-devel] [PATCH v2] ASoC: rt5670: addset_bclk_ratioin daiops
Quoted 17 lines
Quoted 7 lines · Bard Liao
Quoted 2 lines
We need to set a specific bit for 50 bclk rate. So add
set_bclk_ratiofunction to set the bit.When is this supposed to be used? the
cht_bsw_rt5672machine driver uses a 19.2MHz MCLK/2.4 MHz bclk, so there's a typical 50x ratio.I think it should be used for all Intel platform. The bit will only be effective in PCM mode with TDM enabled. It will influence the data allocation format.
0: the dummy bits will be allocate at the end of each slot. 1: the dummy bits will be allocate at the end of all slots. For example, 50fs with 24 bits data length.
0: 24 bits slot0 data + 1 dummy bit + 24 bits slot1 data + 1 dummy bit 1: 24 bits slot0 data + 24 bits slot1 data + 2 dummy bitsQuoted 6 lines
Quoted 2 lines
I will do slight modification on the patch since the bit should be set for all bclk rate which is divisible by 50.
I am not sure I understand the 0: and 1: cases, and since we get audio today with this codec and a ratio of 200 (4 24-bit slots in
DSP_B) I don't get what happens with this fix.
Quoted 11 lines
From my experience, most Intel platforms use case 1 format. The
issue will be incorrect recording volume due to bit allocation is shifted.
If Intel expected case 1 format but Realtek send case 0 format. It would be no problem with slot 0. But for slot 1, it will be:
Intel expected: 24 bits valid data for slot 1
Realtek sent: 1 dummy bit for slot 0 + 24 bits data for slot 1 So what Intel actually received will be 1 dummy bit + 23 bits data And it is similar to other slots.
BTW, if you don't meet the issue, you don't need to callsnd_soc_dai_set_bclk_ratioon your machine driver.
Yes, the Intel SSP will push out all slots and dummy bits at the end of the frame. But if this was never enabled we should have seen noise on the right channel on playback - this sort of misalignment is pretty obvious to spot. I also see a mention of limitation to 50fs resulting in ASRC being required.
http://elixir.free-electrons.com/linux/latest/source/sound/soc/intel/boards/cht_bsw_rt5672.c#L211
Quoted 76 lines
Quoted 76 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Signed-off-by Bard Liao <[email protected]>---
v2:
* add define for tdm data format select bit.--- sound/soc/codecs/rt5670.c | 19 +++++++++++++++++++ sound/soc/codecs/rt5670.h | 4 ++++ 2 files changed, 23 insertions(+)Quoted 5 lines
Quoted 5 lines
sound/soc/codecs/rt5670.c static int rt5670_set_tdm_slot(struct
Quoted 5 lines
sound/soc/codecs/rt5670.c +0
-0@@ -2582,6 +2582,24 @@ static int rt5670_set_tdm_slot(struct
snd_soc_daiQuoted 5 lines
Quoted 5 lines
*dai, unsigned int
tx_mask,Quoted 4 lines
sound/soc/codecs/rt5670.c +1
-0return 0 ; } +static int rt5670_set_bclk_ratio(struct snd_soc_dai *dai, unsigned intratio)
Quoted 50 lines
Quoted 50 lines
sound/soc/codecs/rt5670.c static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
Quoted 10 lines
sound/soc/codecs/rt5670.c +10
-0+{ +struct snd_soc_codec *codec = dai->codec; + +dev_dbg (codec->dev,"%s ratio=%d\n" , __func__, ratio); +if (dai->id !=RT5670_AIF1 ) +return 0 ; + +if (ratio ==50 ) + snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + RT5670_TDM_DATA_MODE_SEL,
RT5670_TDM_DATA_MODE_50FS);sound/soc/codecs/rt5670.c static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
Quoted 3 lines
sound/soc/codecs/rt5670.c +3
-0+else + snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + RT5670_TDM_DATA_MODE_SEL,
RT5670_TDM_DATA_MODE_NOR);sound/soc/codecs/rt5670.c static const struct snd_soc_dai_ops
Quoted 8 lines
sound/soc/codecs/rt5670.c +4
-0+ +return 0 ; +} +static int rt5670_set_bias_level (struct snd_soc_codec *codec,enum snd_soc_bias_level level) {@@ -2712,6 +2730,7 @@ static const struct snd_soc_dai_ops
rt5670_aif_dai_ops= {Quoted 13 lines
sound/soc/codecs/rt5670.c +1
-0.set_fmt = rt5670_set_dai_fmt, .set_tdm_slot = rt5670_set_tdm_slot, .set_pll = rt5670_set_dai_pll, + .set_bclk_ratio = rt5670_set_bclk_ratio, };static struct snd_soc_dai_driver rt5670_dai[] = {sound/soc/codecs/rt5670.h +0
-0sound/soc/codecs/rt5670.h line 1825
Quoted 10 lines
sound/soc/codecs/rt5670.h +4
-0@@ -1816,6 +1816,10 @@#define RT5670_ZCD_HP_DIS (0x0 << 15)#define RT5670_ZCD_HP_EN (0x1 << 15) +/* General Control 3 (0xfc) */ +#define RT5670_TDM_DATA_MODE_SEL (0x1 << 11) +#define RT5670_TDM_DATA_MODE_NOR (0x0 << 11) +#define RT5670_TDM_DATA_MODE_50FS (0x1 << 11)/* Codec Private Register definition */ /* 3D Speaker Control (0x63) */ ------Please consider the environment before printing this e-mail.
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 65 lines
-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Thursday, September 14, 2017 9:48 PM
To: Bard Liao; [email protected]; [email protected]
Cc: Oder Chiou; Jack Yu; [email protected]; [email protected]; [email protected]; Shuming [范書銘]; Flove(HsinFu)
Subject: Re: [alsa-devel] [PATCH v2] ASoC: rt5670: addset_bclk_ratioin dai opsQuoted 7 lines · Bard Liao
Quoted 7 lines
-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Thursday, September 14, 2017 1:45 AM
To: Bard Liao; [email protected]; [email protected]
Cc: Oder Chiou; Jack Yu; [email protected]; [email protected]; [email protected]; Shuming [范書銘]; Flove(HsinFu)
Subject: Re: [alsa-devel] [PATCH v2] ASoC: rt5670: addset_bclk_ratioin daiops
Quoted 9 lines
Quoted 9 lines · Bard Liao
Quoted 7 lines
Quoted 7 lines
-----Original Message-----
From: Pierre-Louis Bossart [mailto:[email protected]]
Sent: Tuesday, September 12, 2017 10:54 PM
To: Bard Liao; [email protected]; [email protected]
Cc: Oder Chiou; Jack Yu; [email protected]; [email protected]; [email protected]; Shuming [范書銘]; Flove(HsinFu)
Subject: Re: [alsa-devel] [PATCH v2] ASoC: rt5670: addset_bclk_ratioindai
Quoted 7 lines
Quoted 7 lines
ops
Quoted 6 lines
Quoted 6 lines · Bard Liao
Quoted 2 lines
We need to set a specific bit for 50 bclk rate. So add
set_bclk_ratiofunction to set the bit.When is this supposed to be used? the
cht_bsw_rt5672machine driveruses
Quoted 18 lines
Quoted 11 lines
Quoted 11 lines
Quoted 1 line
a 19.2MHz MCLK/2.4 MHz bclk, so there's a typical 50x ratio.
I think it should be used for all Intel platform. The bit will only be effective in PCM mode with TDM enabled. It will influence the data allocation format.
0: the dummy bits will be allocate at the end of each slot. 1: the dummy bits will be allocate at the end of all slots. For example, 50fs with 24 bits data length.
0: 24 bits slot0 data + 1 dummy bit + 24 bits slot1 data + 1 dummy bit 1: 24 bits slot0 data + 24 bits slot1 data + 2 dummy bitsQuoted 6 lines
Quoted 2 lines
I will do slight modification on the patch since the bit should be set for all bclk rate which is divisible by 50.
I am not sure I understand the 0: and 1: cases, and since we get audio today with this codec and a ratio of 200 (4 24-bit slots in
DSP_B) I don't get what happens with this fix.Quoted 11 lines
From my experience, most Intel platforms use case 1 format. The
issue will be incorrect recording volume due to bit allocation is shifted.
If Intel expected case 1 format but Realtek send case 0 format. It would be no problem with slot 0. But for slot 1, it will be:
Intel expected: 24 bits valid data for slot 1
Realtek sent: 1 dummy bit for slot 0 + 24 bits data for slot 1 So what Intel actually received will be 1 dummy bit + 23 bits data And it is similar to other slots.
BTW, if you don't meet the issue, you don't need to callsnd_soc_dai_set_bclk_ratioon your machine driver.
Quoted 9 lines
Yes, the Intel SSP will push out all slots and dummy bits at the end of the frame. But if this was never enabled we should have seen noise on the right channel on playback - this sort of misalignment is pretty obvious to spot. I also see a mention of limitation to 50fs resulting in ASRC being required.
http://elixir.free-electrons.com/linux/latest/source/sound/soc/intel/boards/cht
_bsw_rt5672.c#L211
The ASRC setting is for clock issue, and this patch is for format issue. There is no issue on playback side is because the circuit of sending and receiving data are different.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel