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

TOMOYO Linux Cross Reference
Linux/sound/soc/codecs/simple-mux.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/soc/codecs/simple-mux.c (Version linux-6.12-rc7) and /sound/soc/codecs/simple-mux.c (Version linux-6.5.13)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*                                                  2 /*
  3  * Copyright (c) 2020 Bootlin SA                    3  * Copyright (c) 2020 Bootlin SA
  4  * Author: Alexandre Belloni <alexandre.bellon      4  * Author: Alexandre Belloni <alexandre.belloni@bootlin.com>
  5  */                                                 5  */
  6                                                     6 
  7 #include <linux/gpio/consumer.h>                    7 #include <linux/gpio/consumer.h>
  8 #include <linux/module.h>                           8 #include <linux/module.h>
  9 #include <linux/regulator/consumer.h>               9 #include <linux/regulator/consumer.h>
 10 #include <sound/soc.h>                             10 #include <sound/soc.h>
 11                                                    11 
 12 #define MUX_TEXT_SIZE   2                      << 
 13 #define MUX_WIDGET_SIZE 4                      << 
 14 #define MUX_ROUTE_SIZE  3                      << 
 15 struct simple_mux {                                12 struct simple_mux {
 16         struct gpio_desc *gpiod_mux;               13         struct gpio_desc *gpiod_mux;
 17         unsigned int mux;                          14         unsigned int mux;
 18         const char *mux_texts[MUX_TEXT_SIZE];  << 
 19         struct soc_enum mux_enum;              << 
 20         struct snd_kcontrol_new mux_mux;       << 
 21         struct snd_soc_dapm_widget mux_widgets << 
 22         struct snd_soc_dapm_route mux_routes[M << 
 23         struct snd_soc_component_driver mux_dr << 
 24 };                                                 15 };
 25                                                    16 
 26 static const char * const simple_mux_texts[MUX !!  17 static const char * const simple_mux_texts[] = {
 27         "Input 1", "Input 2"                       18         "Input 1", "Input 2"
 28 };                                                 19 };
 29                                                    20 
 30 static SOC_ENUM_SINGLE_EXT_DECL(simple_mux_enu     21 static SOC_ENUM_SINGLE_EXT_DECL(simple_mux_enum, simple_mux_texts);
 31                                                    22 
 32 static int simple_mux_control_get(struct snd_k     23 static int simple_mux_control_get(struct snd_kcontrol *kcontrol,
 33                                   struct snd_c     24                                   struct snd_ctl_elem_value *ucontrol)
 34 {                                                  25 {
 35         struct snd_soc_dapm_context *dapm = sn     26         struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
 36         struct snd_soc_component *c = snd_soc_     27         struct snd_soc_component *c = snd_soc_dapm_to_component(dapm);
 37         struct simple_mux *priv = snd_soc_comp     28         struct simple_mux *priv = snd_soc_component_get_drvdata(c);
 38                                                    29 
 39         ucontrol->value.enumerated.item[0] = p     30         ucontrol->value.enumerated.item[0] = priv->mux;
 40                                                    31 
 41         return 0;                                  32         return 0;
 42 }                                                  33 }
 43                                                    34 
 44 static int simple_mux_control_put(struct snd_k     35 static int simple_mux_control_put(struct snd_kcontrol *kcontrol,
 45                                   struct snd_c     36                                   struct snd_ctl_elem_value *ucontrol)
 46 {                                                  37 {
 47         struct snd_soc_dapm_context *dapm = sn     38         struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
 48         struct soc_enum *e = (struct soc_enum      39         struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 49         struct snd_soc_component *c = snd_soc_     40         struct snd_soc_component *c = snd_soc_dapm_to_component(dapm);
 50         struct simple_mux *priv = snd_soc_comp     41         struct simple_mux *priv = snd_soc_component_get_drvdata(c);
 51                                                    42 
 52         if (ucontrol->value.enumerated.item[0]     43         if (ucontrol->value.enumerated.item[0] > e->items)
 53                 return -EINVAL;                    44                 return -EINVAL;
 54                                                    45 
 55         if (priv->mux == ucontrol->value.enume     46         if (priv->mux == ucontrol->value.enumerated.item[0])
 56                 return 0;                          47                 return 0;
 57                                                    48 
 58         priv->mux = ucontrol->value.enumerated     49         priv->mux = ucontrol->value.enumerated.item[0];
 59                                                    50 
 60         gpiod_set_value_cansleep(priv->gpiod_m     51         gpiod_set_value_cansleep(priv->gpiod_mux, priv->mux);
 61                                                    52 
 62         return snd_soc_dapm_mux_update_power(d     53         return snd_soc_dapm_mux_update_power(dapm, kcontrol,
 63                                              u     54                                              ucontrol->value.enumerated.item[0],
 64                                              e     55                                              e, NULL);
 65 }                                                  56 }
 66                                                    57 
 67 static unsigned int simple_mux_read(struct snd     58 static unsigned int simple_mux_read(struct snd_soc_component *component,
 68                                     unsigned i     59                                     unsigned int reg)
 69 {                                                  60 {
 70         struct simple_mux *priv = snd_soc_comp     61         struct simple_mux *priv = snd_soc_component_get_drvdata(component);
 71                                                    62 
 72         return priv->mux;                          63         return priv->mux;
 73 }                                                  64 }
 74                                                    65 
 75 static const struct snd_kcontrol_new simple_mu     66 static const struct snd_kcontrol_new simple_mux_mux =
 76         SOC_DAPM_ENUM_EXT("Muxer", simple_mux_     67         SOC_DAPM_ENUM_EXT("Muxer", simple_mux_enum, simple_mux_control_get, simple_mux_control_put);
 77                                                    68 
 78 static const struct snd_soc_dapm_widget simple !!  69 static const struct snd_soc_dapm_widget simple_mux_dapm_widgets[] = {
 79         SND_SOC_DAPM_INPUT("IN1"),                 70         SND_SOC_DAPM_INPUT("IN1"),
 80         SND_SOC_DAPM_INPUT("IN2"),                 71         SND_SOC_DAPM_INPUT("IN2"),
 81         SND_SOC_DAPM_MUX("MUX", SND_SOC_NOPM,  !!  72         SND_SOC_DAPM_MUX("MUX", SND_SOC_NOPM, 0, 0, &simple_mux_mux),
 82         SND_SOC_DAPM_OUTPUT("OUT"),                73         SND_SOC_DAPM_OUTPUT("OUT"),
 83 };                                                 74 };
 84                                                    75 
 85 static const struct snd_soc_dapm_route simple_ !!  76 static const struct snd_soc_dapm_route simple_mux_dapm_routes[] = {
 86         { "OUT", NULL, "MUX" },                    77         { "OUT", NULL, "MUX" },
 87         { "MUX", "Input 1", "IN1" }, // see si !!  78         { "MUX", "Input 1", "IN1" },
 88         { "MUX", "Input 2", "IN2" }, // see si !!  79         { "MUX", "Input 2", "IN2" },
                                                   >>  80 };
                                                   >>  81 
                                                   >>  82 static const struct snd_soc_component_driver simple_mux_component_driver = {
                                                   >>  83         .dapm_widgets           = simple_mux_dapm_widgets,
                                                   >>  84         .num_dapm_widgets       = ARRAY_SIZE(simple_mux_dapm_widgets),
                                                   >>  85         .dapm_routes            = simple_mux_dapm_routes,
                                                   >>  86         .num_dapm_routes        = ARRAY_SIZE(simple_mux_dapm_routes),
                                                   >>  87         .read                   = simple_mux_read,
 89 };                                                 88 };
 90                                                    89 
 91 static int simple_mux_probe(struct platform_de     90 static int simple_mux_probe(struct platform_device *pdev)
 92 {                                                  91 {
 93         struct device *dev = &pdev->dev;           92         struct device *dev = &pdev->dev;
 94         struct device_node *np = dev->of_node; << 
 95         struct simple_mux *priv;                   93         struct simple_mux *priv;
 96                                                    94 
 97         priv = devm_kzalloc(dev, sizeof(*priv)     95         priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 98         if (!priv)                                 96         if (!priv)
 99                 return -ENOMEM;                    97                 return -ENOMEM;
100                                                    98 
101         dev_set_drvdata(dev, priv);                99         dev_set_drvdata(dev, priv);
102                                                   100 
103         priv->gpiod_mux = devm_gpiod_get(dev,     101         priv->gpiod_mux = devm_gpiod_get(dev, "mux", GPIOD_OUT_LOW);
104         if (IS_ERR(priv->gpiod_mux))              102         if (IS_ERR(priv->gpiod_mux))
105                 return dev_err_probe(dev, PTR_    103                 return dev_err_probe(dev, PTR_ERR(priv->gpiod_mux),
106                                      "Failed t    104                                      "Failed to get 'mux' gpio");
107                                                   105 
108         /* Copy default settings */            !! 106         return devm_snd_soc_register_component(dev, &simple_mux_component_driver, NULL, 0);
109         memcpy(&priv->mux_texts,        &simpl << 
110         memcpy(&priv->mux_enum,         &simpl << 
111         memcpy(&priv->mux_mux,          &simpl << 
112         memcpy(&priv->mux_widgets,      &simpl << 
113         memcpy(&priv->mux_routes,       &simpl << 
114                                                << 
115         priv->mux_driver.dapm_widgets          << 
116         priv->mux_driver.num_dapm_widgets      << 
117         priv->mux_driver.dapm_routes           << 
118         priv->mux_driver.num_dapm_routes       << 
119         priv->mux_driver.read                  << 
120                                                << 
121         /* Overwrite text ("Input 1", "Input 2 << 
122         of_property_read_string_array(np, "sta << 
123                                                << 
124         /* switch to use priv data instead of  << 
125         priv->mux_enum.texts                   << 
126         priv->mux_mux.private_value            << 
127         priv->mux_widgets[2].kcontrol_news     << 
128         priv->mux_routes[1].control            << 
129         priv->mux_routes[2].control            << 
130                                                << 
131         return devm_snd_soc_register_component << 
132 }                                                 107 }
133                                                   108 
134 #ifdef CONFIG_OF                                  109 #ifdef CONFIG_OF
135 static const struct of_device_id simple_mux_id    110 static const struct of_device_id simple_mux_ids[] = {
136         { .compatible = "simple-audio-mux", },    111         { .compatible = "simple-audio-mux", },
137         { }                                       112         { }
138 };                                                113 };
139 MODULE_DEVICE_TABLE(of, simple_mux_ids);          114 MODULE_DEVICE_TABLE(of, simple_mux_ids);
140 #endif                                            115 #endif
141                                                   116 
142 static struct platform_driver simple_mux_drive    117 static struct platform_driver simple_mux_driver = {
143         .driver = {                               118         .driver = {
144                 .name = "simple-mux",             119                 .name = "simple-mux",
145                 .of_match_table = of_match_ptr    120                 .of_match_table = of_match_ptr(simple_mux_ids),
146         },                                        121         },
147         .probe = simple_mux_probe,                122         .probe = simple_mux_probe,
148 };                                                123 };
149                                                   124 
150 module_platform_driver(simple_mux_driver);        125 module_platform_driver(simple_mux_driver);
151                                                   126 
152 MODULE_DESCRIPTION("ASoC Simple Audio Mux driv    127 MODULE_DESCRIPTION("ASoC Simple Audio Mux driver");
153 MODULE_AUTHOR("Alexandre Belloni <alexandre.be    128 MODULE_AUTHOR("Alexandre Belloni <alexandre.belloni@bootlin.com>");
154 MODULE_LICENSE("GPL");                            129 MODULE_LICENSE("GPL");
155                                                   130 

~ [ 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