~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/meson/gx-card.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/soc/meson/gx-card.c (Version linux-6.11.5) and /sound/soc/meson/gx-card.c (Version linux-6.4.16)


  1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)        1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
  2 //                                                  2 //
  3 // Copyright (c) 2020 BayLibre, SAS.                3 // Copyright (c) 2020 BayLibre, SAS.
  4 // Author: Jerome Brunet <jbrunet@baylibre.com      4 // Author: Jerome Brunet <jbrunet@baylibre.com>
  5                                                     5 
  6 #include <linux/module.h>                           6 #include <linux/module.h>
  7 #include <linux/of_platform.h>                      7 #include <linux/of_platform.h>
  8 #include <sound/soc.h>                              8 #include <sound/soc.h>
  9 #include <sound/soc-dai.h>                          9 #include <sound/soc-dai.h>
 10                                                    10 
 11 #include "meson-card.h"                            11 #include "meson-card.h"
 12                                                    12 
 13 struct gx_dai_link_i2s_data {                      13 struct gx_dai_link_i2s_data {
 14         unsigned int mclk_fs;                      14         unsigned int mclk_fs;
 15 };                                                 15 };
 16                                                    16 
 17 /*                                                 17 /*
 18  * Base params for the codec to codec links        18  * Base params for the codec to codec links
 19  * Those will be over-written by the CPU side      19  * Those will be over-written by the CPU side of the link
 20  */                                                20  */
 21 static const struct snd_soc_pcm_stream codec_p     21 static const struct snd_soc_pcm_stream codec_params = {
 22         .formats = SNDRV_PCM_FMTBIT_S24_LE,        22         .formats = SNDRV_PCM_FMTBIT_S24_LE,
 23         .rate_min = 5525,                          23         .rate_min = 5525,
 24         .rate_max = 192000,                        24         .rate_max = 192000,
 25         .channels_min = 1,                         25         .channels_min = 1,
 26         .channels_max = 8,                         26         .channels_max = 8,
 27 };                                                 27 };
 28                                                    28 
 29 static int gx_card_i2s_be_hw_params(struct snd     29 static int gx_card_i2s_be_hw_params(struct snd_pcm_substream *substream,
 30                                     struct snd     30                                     struct snd_pcm_hw_params *params)
 31 {                                                  31 {
 32         struct snd_soc_pcm_runtime *rtd = snd_ !!  32         struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
 33         struct meson_card *priv = snd_soc_card     33         struct meson_card *priv = snd_soc_card_get_drvdata(rtd->card);
 34         struct gx_dai_link_i2s_data *be =          34         struct gx_dai_link_i2s_data *be =
 35                 (struct gx_dai_link_i2s_data *     35                 (struct gx_dai_link_i2s_data *)priv->link_data[rtd->num];
 36                                                    36 
 37         return meson_card_i2s_set_sysclk(subst     37         return meson_card_i2s_set_sysclk(substream, params, be->mclk_fs);
 38 }                                                  38 }
 39                                                    39 
 40 static const struct snd_soc_ops gx_card_i2s_be     40 static const struct snd_soc_ops gx_card_i2s_be_ops = {
 41         .hw_params = gx_card_i2s_be_hw_params,     41         .hw_params = gx_card_i2s_be_hw_params,
 42 };                                                 42 };
 43                                                    43 
 44 static int gx_card_parse_i2s(struct snd_soc_ca     44 static int gx_card_parse_i2s(struct snd_soc_card *card,
 45                              struct device_nod     45                              struct device_node *node,
 46                              int *index)           46                              int *index)
 47 {                                                  47 {
 48         struct meson_card *priv = snd_soc_card     48         struct meson_card *priv = snd_soc_card_get_drvdata(card);
 49         struct snd_soc_dai_link *link = &card-     49         struct snd_soc_dai_link *link = &card->dai_link[*index];
 50         struct gx_dai_link_i2s_data *be;           50         struct gx_dai_link_i2s_data *be;
 51                                                    51 
 52         /* Allocate i2s link parameters */         52         /* Allocate i2s link parameters */
 53         be = devm_kzalloc(card->dev, sizeof(*b     53         be = devm_kzalloc(card->dev, sizeof(*be), GFP_KERNEL);
 54         if (!be)                                   54         if (!be)
 55                 return -ENOMEM;                    55                 return -ENOMEM;
 56         priv->link_data[*index] = be;              56         priv->link_data[*index] = be;
 57                                                    57 
 58         /* Setup i2s link */                       58         /* Setup i2s link */
 59         link->ops = &gx_card_i2s_be_ops;           59         link->ops = &gx_card_i2s_be_ops;
 60         link->dai_fmt = meson_card_parse_daifm     60         link->dai_fmt = meson_card_parse_daifmt(node, link->cpus->of_node);
 61                                                    61 
 62         of_property_read_u32(node, "mclk-fs",      62         of_property_read_u32(node, "mclk-fs", &be->mclk_fs);
 63                                                    63 
 64         return 0;                                  64         return 0;
 65 }                                                  65 }
 66                                                    66 
 67 static int gx_card_cpu_identify(struct snd_soc     67 static int gx_card_cpu_identify(struct snd_soc_dai_link_component *c,
 68                                 char *match)       68                                 char *match)
 69 {                                                  69 {
 70         if (of_device_is_compatible(c->of_node     70         if (of_device_is_compatible(c->of_node, DT_PREFIX "aiu")) {
 71                 if (strstr(c->dai_name, match)     71                 if (strstr(c->dai_name, match))
 72                         return 1;                  72                         return 1;
 73         }                                          73         }
 74                                                    74 
 75         /* dai not matched */                      75         /* dai not matched */
 76         return 0;                                  76         return 0;
 77 }                                                  77 }
 78                                                    78 
 79 static int gx_card_add_link(struct snd_soc_car     79 static int gx_card_add_link(struct snd_soc_card *card, struct device_node *np,
 80                             int *index)            80                             int *index)
 81 {                                                  81 {
 82         struct snd_soc_dai_link *dai_link = &c     82         struct snd_soc_dai_link *dai_link = &card->dai_link[*index];
 83         struct snd_soc_dai_link_component *cpu     83         struct snd_soc_dai_link_component *cpu;
 84         int ret;                                   84         int ret;
 85                                                    85 
 86         cpu = devm_kzalloc(card->dev, sizeof(*     86         cpu = devm_kzalloc(card->dev, sizeof(*cpu), GFP_KERNEL);
 87         if (!cpu)                                  87         if (!cpu)
 88                 return -ENOMEM;                    88                 return -ENOMEM;
 89                                                    89 
 90         dai_link->cpus = cpu;                      90         dai_link->cpus = cpu;
 91         dai_link->num_cpus = 1;                    91         dai_link->num_cpus = 1;
 92                                                    92 
 93         ret = meson_card_parse_dai(card, np, d !!  93         ret = meson_card_parse_dai(card, np, &dai_link->cpus->of_node,
                                                   >>  94                                    &dai_link->cpus->dai_name);
 94         if (ret)                                   95         if (ret)
 95                 return ret;                        96                 return ret;
 96                                                    97 
 97         if (gx_card_cpu_identify(dai_link->cpu     98         if (gx_card_cpu_identify(dai_link->cpus, "FIFO"))
 98                 return  meson_card_set_fe_link     99                 return  meson_card_set_fe_link(card, dai_link, np, true);
 99                                                   100 
100         ret = meson_card_set_be_link(card, dai    101         ret = meson_card_set_be_link(card, dai_link, np);
101         if (ret)                                  102         if (ret)
102                 return ret;                       103                 return ret;
103                                                   104 
104         /* Or apply codec to codec params if n    105         /* Or apply codec to codec params if necessary */
105         if (gx_card_cpu_identify(dai_link->cpu    106         if (gx_card_cpu_identify(dai_link->cpus, "CODEC CTRL")) {
106                 dai_link->c2c_params = &codec_    107                 dai_link->c2c_params = &codec_params;
107                 dai_link->num_c2c_params = 1;     108                 dai_link->num_c2c_params = 1;
108         } else {                                  109         } else {
109                 dai_link->no_pcm = 1;             110                 dai_link->no_pcm = 1;
110                 snd_soc_dai_link_set_capabilit    111                 snd_soc_dai_link_set_capabilities(dai_link);
111                 /* Check if the cpu is the i2s    112                 /* Check if the cpu is the i2s encoder and parse i2s data */
112                 if (gx_card_cpu_identify(dai_l    113                 if (gx_card_cpu_identify(dai_link->cpus, "I2S Encoder"))
113                         ret = gx_card_parse_i2    114                         ret = gx_card_parse_i2s(card, np, index);
114         }                                         115         }
115                                                   116 
116         return ret;                               117         return ret;
117 }                                                 118 }
118                                                   119 
119 static const struct meson_card_match_data gx_c    120 static const struct meson_card_match_data gx_card_match_data = {
120         .add_link = gx_card_add_link,             121         .add_link = gx_card_add_link,
121 };                                                122 };
122                                                   123 
123 static const struct of_device_id gx_card_of_ma    124 static const struct of_device_id gx_card_of_match[] = {
124         {                                         125         {
125                 .compatible = "amlogic,gx-soun    126                 .compatible = "amlogic,gx-sound-card",
126                 .data = &gx_card_match_data,      127                 .data = &gx_card_match_data,
127         }, {}                                     128         }, {}
128 };                                                129 };
129 MODULE_DEVICE_TABLE(of, gx_card_of_match);        130 MODULE_DEVICE_TABLE(of, gx_card_of_match);
130                                                   131 
131 static struct platform_driver gx_card_pdrv = {    132 static struct platform_driver gx_card_pdrv = {
132         .probe = meson_card_probe,                133         .probe = meson_card_probe,
133         .remove_new = meson_card_remove,       !! 134         .remove = meson_card_remove,
134         .driver = {                               135         .driver = {
135                 .name = "gx-sound-card",          136                 .name = "gx-sound-card",
136                 .of_match_table = gx_card_of_m    137                 .of_match_table = gx_card_of_match,
137         },                                        138         },
138 };                                                139 };
139 module_platform_driver(gx_card_pdrv);             140 module_platform_driver(gx_card_pdrv);
140                                                   141 
141 MODULE_DESCRIPTION("Amlogic GX ALSA machine dr    142 MODULE_DESCRIPTION("Amlogic GX ALSA machine driver");
142 MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre    143 MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre.com>");
143 MODULE_LICENSE("GPL v2");                         144 MODULE_LICENSE("GPL v2");
144                                                   145 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php