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

TOMOYO Linux Cross Reference
Linux/sound/soc/codecs/rt1015p.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/rt1015p.c (Version linux-6.12-rc7) and /sound/soc/codecs/rt1015p.c (Version linux-6.9.12)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 // SPDX-License-Identifier: GPL-2.0-only
  2 //                                                  2 //
  3 // rt1015p.c  --  RT1015P ALSA SoC audio ampli      3 // rt1015p.c  --  RT1015P ALSA SoC audio amplifier driver
  4 //                                                  4 //
  5 // Copyright 2020 The Linux Foundation. All ri      5 // Copyright 2020 The Linux Foundation. All rights reserved.
  6                                                     6 
  7 #include <linux/acpi.h>                             7 #include <linux/acpi.h>
  8 #include <linux/delay.h>                            8 #include <linux/delay.h>
  9 #include <linux/device.h>                           9 #include <linux/device.h>
 10 #include <linux/err.h>                             10 #include <linux/err.h>
 11 #include <linux/gpio/consumer.h>                   11 #include <linux/gpio/consumer.h>
 12 #include <linux/kernel.h>                          12 #include <linux/kernel.h>
 13 #include <linux/module.h>                          13 #include <linux/module.h>
 14 #include <linux/of.h>                              14 #include <linux/of.h>
 15 #include <linux/platform_device.h>                 15 #include <linux/platform_device.h>
 16 #include <sound/pcm.h>                             16 #include <sound/pcm.h>
 17 #include <sound/soc.h>                             17 #include <sound/soc.h>
 18 #include <sound/soc-dai.h>                         18 #include <sound/soc-dai.h>
 19 #include <sound/soc-dapm.h>                        19 #include <sound/soc-dapm.h>
 20                                                    20 
 21 struct rt1015p_priv {                              21 struct rt1015p_priv {
 22         struct gpio_desc *sdb;                     22         struct gpio_desc *sdb;
 23         bool calib_done;                           23         bool calib_done;
 24 };                                                 24 };
 25                                                    25 
 26 static int rt1015p_sdb_event(struct snd_soc_da     26 static int rt1015p_sdb_event(struct snd_soc_dapm_widget *w,
 27                 struct snd_kcontrol *kcontrol,     27                 struct snd_kcontrol *kcontrol, int event)
 28 {                                                  28 {
 29         struct snd_soc_component *component =      29         struct snd_soc_component *component =
 30                 snd_soc_dapm_to_component(w->d     30                 snd_soc_dapm_to_component(w->dapm);
 31         struct rt1015p_priv *rt1015p =             31         struct rt1015p_priv *rt1015p =
 32                 snd_soc_component_get_drvdata(     32                 snd_soc_component_get_drvdata(component);
 33                                                    33 
 34         if (!rt1015p->sdb)                         34         if (!rt1015p->sdb)
 35                 return 0;                          35                 return 0;
 36                                                    36 
 37         switch (event) {                           37         switch (event) {
 38         case SND_SOC_DAPM_PRE_PMU:                 38         case SND_SOC_DAPM_PRE_PMU:
 39                 gpiod_set_value_cansleep(rt101     39                 gpiod_set_value_cansleep(rt1015p->sdb, 1);
 40                 dev_dbg(component->dev, "set s     40                 dev_dbg(component->dev, "set sdb to 1");
 41                                                    41 
 42                 if (!rt1015p->calib_done) {        42                 if (!rt1015p->calib_done) {
 43                         msleep(300);               43                         msleep(300);
 44                         rt1015p->calib_done =      44                         rt1015p->calib_done = true;
 45                 }                                  45                 }
 46                 break;                             46                 break;
 47         case SND_SOC_DAPM_POST_PMD:                47         case SND_SOC_DAPM_POST_PMD:
 48                 gpiod_set_value_cansleep(rt101     48                 gpiod_set_value_cansleep(rt1015p->sdb, 0);
 49                 dev_dbg(component->dev, "set s     49                 dev_dbg(component->dev, "set sdb to 0");
 50                 break;                             50                 break;
 51         default:                                   51         default:
 52                 break;                             52                 break;
 53         }                                          53         }
 54                                                    54 
 55         return 0;                                  55         return 0;
 56 }                                                  56 }
 57                                                    57 
 58 static const struct snd_soc_dapm_widget rt1015     58 static const struct snd_soc_dapm_widget rt1015p_dapm_widgets[] = {
 59         SND_SOC_DAPM_OUTPUT("Speaker"),            59         SND_SOC_DAPM_OUTPUT("Speaker"),
 60         SND_SOC_DAPM_OUT_DRV_E("SDB", SND_SOC_     60         SND_SOC_DAPM_OUT_DRV_E("SDB", SND_SOC_NOPM, 0, 0, NULL, 0,
 61                         rt1015p_sdb_event,         61                         rt1015p_sdb_event,
 62                         SND_SOC_DAPM_PRE_PMU |     62                         SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
 63 };                                                 63 };
 64                                                    64 
 65 static const struct snd_soc_dapm_route rt1015p     65 static const struct snd_soc_dapm_route rt1015p_dapm_routes[] = {
 66         {"SDB", NULL, "HiFi Playback"},            66         {"SDB", NULL, "HiFi Playback"},
 67         {"Speaker", NULL, "SDB"},                  67         {"Speaker", NULL, "SDB"},
 68 };                                                 68 };
 69                                                    69 
 70 #ifdef CONFIG_PM                                   70 #ifdef CONFIG_PM
 71 static int rt1015p_suspend(struct snd_soc_comp     71 static int rt1015p_suspend(struct snd_soc_component *component)
 72 {                                                  72 {
 73         struct rt1015p_priv *rt1015p = snd_soc     73         struct rt1015p_priv *rt1015p = snd_soc_component_get_drvdata(component);
 74                                                    74 
 75         rt1015p->calib_done = false;               75         rt1015p->calib_done = false;
 76         return 0;                                  76         return 0;
 77 }                                                  77 }
 78 #else                                              78 #else
 79 #define rt1015p_suspend NULL                       79 #define rt1015p_suspend NULL
 80 #endif                                             80 #endif
 81                                                    81 
 82 static const struct snd_soc_component_driver r     82 static const struct snd_soc_component_driver rt1015p_component_driver = {
 83         .suspend                = rt1015p_susp     83         .suspend                = rt1015p_suspend,
 84         .dapm_widgets           = rt1015p_dapm     84         .dapm_widgets           = rt1015p_dapm_widgets,
 85         .num_dapm_widgets       = ARRAY_SIZE(r     85         .num_dapm_widgets       = ARRAY_SIZE(rt1015p_dapm_widgets),
 86         .dapm_routes            = rt1015p_dapm     86         .dapm_routes            = rt1015p_dapm_routes,
 87         .num_dapm_routes        = ARRAY_SIZE(r     87         .num_dapm_routes        = ARRAY_SIZE(rt1015p_dapm_routes),
 88         .idle_bias_on           = 1,               88         .idle_bias_on           = 1,
 89         .use_pmdown_time        = 1,               89         .use_pmdown_time        = 1,
 90         .endianness             = 1,               90         .endianness             = 1,
 91 };                                                 91 };
 92                                                    92 
 93 static struct snd_soc_dai_driver rt1015p_dai_d     93 static struct snd_soc_dai_driver rt1015p_dai_driver = {
 94         .name = "HiFi",                            94         .name = "HiFi",
 95         .playback = {                              95         .playback = {
 96                 .stream_name    = "HiFi Playba     96                 .stream_name    = "HiFi Playback",
 97                 .formats        = SNDRV_PCM_FM     97                 .formats        = SNDRV_PCM_FMTBIT_S24 |
 98                                         SNDRV_     98                                         SNDRV_PCM_FMTBIT_S32,
 99                 .rates          = SNDRV_PCM_RA     99                 .rates          = SNDRV_PCM_RATE_48000,
100                 .channels_min   = 1,              100                 .channels_min   = 1,
101                 .channels_max   = 2,              101                 .channels_max   = 2,
102         },                                        102         },
103 };                                                103 };
104                                                   104 
105 static int rt1015p_platform_probe(struct platf    105 static int rt1015p_platform_probe(struct platform_device *pdev)
106 {                                                 106 {
107         struct rt1015p_priv *rt1015p;             107         struct rt1015p_priv *rt1015p;
108                                                   108 
109         rt1015p = devm_kzalloc(&pdev->dev, siz    109         rt1015p = devm_kzalloc(&pdev->dev, sizeof(*rt1015p), GFP_KERNEL);
110         if (!rt1015p)                             110         if (!rt1015p)
111                 return -ENOMEM;                   111                 return -ENOMEM;
112                                                   112 
113         rt1015p->sdb = devm_gpiod_get_optional    113         rt1015p->sdb = devm_gpiod_get_optional(&pdev->dev,
114                                 "sdb", GPIOD_O    114                                 "sdb", GPIOD_OUT_LOW);
115         if (IS_ERR(rt1015p->sdb))                 115         if (IS_ERR(rt1015p->sdb))
116                 return PTR_ERR(rt1015p->sdb);     116                 return PTR_ERR(rt1015p->sdb);
117                                                   117 
118         dev_set_drvdata(&pdev->dev, rt1015p);     118         dev_set_drvdata(&pdev->dev, rt1015p);
119                                                   119 
120         return devm_snd_soc_register_component    120         return devm_snd_soc_register_component(&pdev->dev,
121                         &rt1015p_component_dri    121                         &rt1015p_component_driver,
122                         &rt1015p_dai_driver, 1    122                         &rt1015p_dai_driver, 1);
123 }                                                 123 }
124                                                   124 
125 #ifdef CONFIG_OF                                  125 #ifdef CONFIG_OF
126 static const struct of_device_id rt1015p_devic    126 static const struct of_device_id rt1015p_device_id[] = {
127         { .compatible = "realtek,rt1015p" },      127         { .compatible = "realtek,rt1015p" },
128         { .compatible = "realtek,rt1019p" },      128         { .compatible = "realtek,rt1019p" },
129         {}                                        129         {}
130 };                                                130 };
131 MODULE_DEVICE_TABLE(of, rt1015p_device_id);       131 MODULE_DEVICE_TABLE(of, rt1015p_device_id);
132 #endif                                            132 #endif
133                                                   133 
134 #ifdef CONFIG_ACPI                                134 #ifdef CONFIG_ACPI
135 static const struct acpi_device_id rt1015p_acp    135 static const struct acpi_device_id rt1015p_acpi_match[] = {
136         { "RTL1015", 0},                          136         { "RTL1015", 0},
137         { "RTL1019", 0},                          137         { "RTL1019", 0},
138         { },                                      138         { },
139 };                                                139 };
140 MODULE_DEVICE_TABLE(acpi, rt1015p_acpi_match);    140 MODULE_DEVICE_TABLE(acpi, rt1015p_acpi_match);
141 #endif                                            141 #endif
142                                                   142 
143 static struct platform_driver rt1015p_platform    143 static struct platform_driver rt1015p_platform_driver = {
144         .driver = {                               144         .driver = {
145                 .name = "rt1015p",                145                 .name = "rt1015p",
146                 .of_match_table = of_match_ptr    146                 .of_match_table = of_match_ptr(rt1015p_device_id),
147                 .acpi_match_table = ACPI_PTR(r    147                 .acpi_match_table = ACPI_PTR(rt1015p_acpi_match),
148         },                                        148         },
149         .probe = rt1015p_platform_probe,          149         .probe = rt1015p_platform_probe,
150 };                                                150 };
151 module_platform_driver(rt1015p_platform_driver    151 module_platform_driver(rt1015p_platform_driver);
152                                                   152 
153 MODULE_DESCRIPTION("ASoC RT1015P driver");        153 MODULE_DESCRIPTION("ASoC RT1015P driver");
154 MODULE_LICENSE("GPL v2");                         154 MODULE_LICENSE("GPL v2");
155                                                   155 

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