1 From 45ef8360c3ce459342994cdcfbf140e876b5490b Mon Sep 17 00:00:00 2001
2 From: Viorel Suman <viorel.suman@nxp.com>
3 Date: Tue, 11 Jul 2017 08:26:44 +0300
4 Subject: [PATCH] MLK-13975: ASoC: fsl_sai: Refine master flag handling
6 The patch introduces the master flag handling
7 as function of direction and the option to provide
8 the flag value from DTS.
10 Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
11 Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
13 sound/soc/fsl/fsl_sai.c | 27 +++++++++++++++++++--------
14 sound/soc/fsl/fsl_sai.h | 2 +-
15 2 files changed, 20 insertions(+), 9 deletions(-)
17 --- a/sound/soc/fsl/fsl_sai.c
18 +++ b/sound/soc/fsl/fsl_sai.c
19 @@ -368,9 +368,9 @@ static int fsl_sai_set_dai_fmt(struct sn
20 struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai);
24 - fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
25 - SND_SOC_DAIFMT_CBS_CFS;
26 + if (sai->masterflag[FSL_FMT_TRANSMITTER])
27 + fmt = (fmt & (~SND_SOC_DAIFMT_MASTER_MASK)) |
28 + sai->masterflag[FSL_FMT_TRANSMITTER];
30 ret = fsl_sai_set_dai_fmt_tr(cpu_dai, fmt, FSL_FMT_TRANSMITTER);
32 @@ -378,9 +378,9 @@ static int fsl_sai_set_dai_fmt(struct sn
37 - fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
38 - SND_SOC_DAIFMT_CBM_CFM;
39 + if (sai->masterflag[FSL_FMT_RECEIVER])
40 + fmt = (fmt & (~SND_SOC_DAIFMT_MASTER_MASK)) |
41 + sai->masterflag[FSL_FMT_RECEIVER];
43 ret = fsl_sai_set_dai_fmt_tr(cpu_dai, fmt, FSL_FMT_RECEIVER);
45 @@ -1022,8 +1022,19 @@ static int fsl_sai_probe(struct platform
50 - sai->i2s_xtor = (of_find_property(np, "fsl,i2s-xtor", NULL) != NULL);
51 + if ((of_find_property(np, "fsl,i2s-xtor", NULL) != NULL) ||
52 + (of_find_property(np, "fsl,txm-rxs", NULL) != NULL))
54 + sai->masterflag[FSL_FMT_TRANSMITTER] = SND_SOC_DAIFMT_CBS_CFS;
55 + sai->masterflag[FSL_FMT_RECEIVER] = SND_SOC_DAIFMT_CBM_CFM;
57 + if (!of_property_read_u32(np, "fsl,txmasterflag",
58 + &sai->masterflag[FSL_FMT_TRANSMITTER]))
59 + sai->masterflag[FSL_FMT_TRANSMITTER] <<= 12;
60 + if (!of_property_read_u32(np, "fsl,rxmasterflag",
61 + &sai->masterflag[FSL_FMT_RECEIVER]))
62 + sai->masterflag[FSL_FMT_RECEIVER] <<= 12;
65 irq = platform_get_irq(pdev, 0);
67 --- a/sound/soc/fsl/fsl_sai.h
68 +++ b/sound/soc/fsl/fsl_sai.h
69 @@ -160,10 +160,10 @@ struct fsl_sai {
75 bool is_stream_opened[2];
76 unsigned int dataline[2];
77 + unsigned int masterflag[2];
79 unsigned int mclk_id[2];
80 unsigned int mclk_streams;