1
0
Fork 0

MLK-17817-1: ASoC: ak4458: enable daisy chain

Enable Daisy Chain if in TDM mode and the number of played
channels is bigger than the maximum supported number of channels.

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
(cherry picked from commit 5ae97f159bfd9c4a37e7e60cd20aa3437041b251)
(Vipul: apply manually whilre rebase on v4.19)
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
5.4-rM2-2.2.x-imx-squashed
Viorel Suman 2019-01-29 12:24:38 +05:30 committed by Dong Aisheng
parent d9b9ac9fb4
commit d87a95d612
2 changed files with 33 additions and 17 deletions

View File

@ -298,6 +298,20 @@ static const struct snd_soc_dapm_route ak4497_intercon[] = {
};
static int ak4458_get_tdm_mode(struct ak4458_priv *ak4458)
{
switch (ak4458->slots * ak4458->slot_width) {
case 128:
return 1;
case 256:
return 2;
case 512:
return 3;
default:
return 0;
}
}
static int ak4458_rstn_control(struct snd_soc_component *component, int bit)
{
int ret;
@ -326,10 +340,13 @@ static int ak4458_hw_params(struct snd_pcm_substream *substream,
struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component);
int pcm_width = max(params_physical_width(params), ak4458->slot_width);
int nfs1;
u8 format, dsdsel0, dsdsel1;
int ret, dsd_bclk;
u8 format, dsdsel0, dsdsel1, dchn;
int ret, dsd_bclk, channels, channels_max;
bool is_dsd = false;
channels = params_channels(params);
channels_max = dai->driver->playback.channels_max;
switch (params_format(params)) {
case SNDRV_PCM_FORMAT_DSD_U8:
case SNDRV_PCM_FORMAT_DSD_U16_LE:
@ -407,6 +424,17 @@ static int ak4458_hw_params(struct snd_pcm_substream *substream,
snd_soc_component_update_bits(component, AK4458_00_CONTROL1,
AK4458_DIF_MASK, format);
/*
* Enable/disable Daisy Chain if in TDM mode and the number of played
* channels is bigger than the maximum supported number of channels
*/
dchn = ak4458_get_tdm_mode(ak4458) &&
(ak4458->fmt == SND_SOC_DAIFMT_DSP_B) &&
(channels > channels_max) ? AK4458_DCHAIN_MASK : 0;
snd_soc_component_update_bits(component, AK4458_0B_CONTROL7,
AK4458_DCHAIN_MASK, dchn);
ret = ak4458_rstn_control(component, 0);
if (ret)
return ret;
@ -501,25 +529,11 @@ static int ak4458_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
ak4458->slots = slots;
ak4458->slot_width = slot_width;
switch (slots * slot_width) {
case 128:
mode = AK4458_MODE_TDM128;
break;
case 256:
mode = AK4458_MODE_TDM256;
break;
case 512:
mode = AK4458_MODE_TDM512;
break;
default:
mode = AK4458_MODE_NORMAL;
break;
}
mode = ak4458_get_tdm_mode(ak4458) << AK4458_MODE_SHIFT;
snd_soc_component_update_bits(component, AK4458_0A_CONTROL6,
AK4458_MODE_MASK,
mode);
return 0;
}

View File

@ -86,4 +86,6 @@
#define AK4458_DSDSEL_MASK (0x1 << 0)
#define AK4458_DP_MASK (0x1 << 7)
#define AK4458_DCHAIN_MASK (0x1 << 1)
#endif