ath79/mikrotik: use routerbootpart partitions
[oweals/openwrt.git] / target / linux / layerscape / patches-5.4 / 801-audio-0031-MLK-13975-ASoC-fsl_sai-Refine-master-flag-handling.patch
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
5
6 The patch introduces the master flag handling
7 as function of direction and the option to provide
8 the flag value from DTS.
9
10 Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
11 Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
12 ---
13  sound/soc/fsl/fsl_sai.c | 27 +++++++++++++++++++--------
14  sound/soc/fsl/fsl_sai.h |  2 +-
15  2 files changed, 20 insertions(+), 9 deletions(-)
16
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);
21         int ret;
22  
23 -       if (sai->i2s_xtor)
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];
29  
30         ret = fsl_sai_set_dai_fmt_tr(cpu_dai, fmt, FSL_FMT_TRANSMITTER);
31         if (ret) {
32 @@ -378,9 +378,9 @@ static int fsl_sai_set_dai_fmt(struct sn
33                 return ret;
34         }
35  
36 -       if (sai->i2s_xtor)
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];
42  
43         ret = fsl_sai_set_dai_fmt_tr(cpu_dai, fmt, FSL_FMT_RECEIVER);
44         if (ret)
45 @@ -1022,8 +1022,19 @@ static int fsl_sai_probe(struct platform
46                 return -EINVAL;
47         }
48  
49 -       /* I2S XTOR mode */
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))
53 +       {
54 +               sai->masterflag[FSL_FMT_TRANSMITTER] = SND_SOC_DAIFMT_CBS_CFS;
55 +               sai->masterflag[FSL_FMT_RECEIVER] = SND_SOC_DAIFMT_CBM_CFM;
56 +       } else {
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;
63 +       }
64  
65         irq = platform_get_irq(pdev, 0);
66         if (irq < 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 {
70         bool slave_mode[2];
71         bool is_lsb_first;
72         bool is_dsp_mode;
73 -       bool i2s_xtor;
74         bool synchronous[2];
75         bool is_stream_opened[2];
76         unsigned int dataline[2];
77 +       unsigned int masterflag[2];
78  
79         unsigned int mclk_id[2];
80         unsigned int mclk_streams;