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

TOMOYO Linux Cross Reference
Linux/sound/soc/jz4740/qi_lb60.c

Version: ~ [ linux-5.15-rc1 ] ~ [ linux-5.14.5 ] ~ [ linux-5.13.18 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.66 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.147 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.206 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.246 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.282 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.283 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ 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.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Copyright (C) 2009, Lars-Peter Clausen <lars@metafoo.de>
  4  */
  5 
  6 #include <linux/module.h>
  7 #include <linux/moduleparam.h>
  8 #include <linux/timer.h>
  9 #include <linux/interrupt.h>
 10 #include <linux/platform_device.h>
 11 #include <sound/core.h>
 12 #include <sound/pcm.h>
 13 #include <sound/soc.h>
 14 #include <linux/gpio/consumer.h>
 15 
 16 struct qi_lb60 {
 17         struct gpio_desc *snd_gpio;
 18         struct gpio_desc *amp_gpio;
 19 };
 20 
 21 static int qi_lb60_spk_event(struct snd_soc_dapm_widget *widget,
 22                              struct snd_kcontrol *ctrl, int event)
 23 {
 24         struct qi_lb60 *qi_lb60 = snd_soc_card_get_drvdata(widget->dapm->card);
 25         int on = !SND_SOC_DAPM_EVENT_OFF(event);
 26 
 27         gpiod_set_value_cansleep(qi_lb60->snd_gpio, on);
 28         gpiod_set_value_cansleep(qi_lb60->amp_gpio, on);
 29 
 30         return 0;
 31 }
 32 
 33 static const struct snd_soc_dapm_widget qi_lb60_widgets[] = {
 34         SND_SOC_DAPM_SPK("Speaker", qi_lb60_spk_event),
 35         SND_SOC_DAPM_MIC("Mic", NULL),
 36 };
 37 
 38 static const struct snd_soc_dapm_route qi_lb60_routes[] = {
 39         {"Mic", NULL, "MIC"},
 40         {"Speaker", NULL, "LOUT"},
 41         {"Speaker", NULL, "ROUT"},
 42 };
 43 
 44 SND_SOC_DAILINK_DEFS(hifi,
 45         DAILINK_COMP_ARRAY(COMP_CPU("jz4740-i2s")),
 46         DAILINK_COMP_ARRAY(COMP_CODEC("jz4740-codec", "jz4740-hifi")),
 47         DAILINK_COMP_ARRAY(COMP_PLATFORM("jz4740-i2s")));
 48 
 49 static struct snd_soc_dai_link qi_lb60_dai = {
 50         .name = "jz4740",
 51         .stream_name = "jz4740",
 52         .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
 53                 SND_SOC_DAIFMT_CBM_CFM,
 54         SND_SOC_DAILINK_REG(hifi),
 55 };
 56 
 57 static struct snd_soc_card qi_lb60_card = {
 58         .name = "QI LB60",
 59         .owner = THIS_MODULE,
 60         .dai_link = &qi_lb60_dai,
 61         .num_links = 1,
 62 
 63         .dapm_widgets = qi_lb60_widgets,
 64         .num_dapm_widgets = ARRAY_SIZE(qi_lb60_widgets),
 65         .dapm_routes = qi_lb60_routes,
 66         .num_dapm_routes = ARRAY_SIZE(qi_lb60_routes),
 67         .fully_routed = true,
 68 };
 69 
 70 static int qi_lb60_probe(struct platform_device *pdev)
 71 {
 72         struct qi_lb60 *qi_lb60;
 73         struct snd_soc_card *card = &qi_lb60_card;
 74 
 75         qi_lb60 = devm_kzalloc(&pdev->dev, sizeof(*qi_lb60), GFP_KERNEL);
 76         if (!qi_lb60)
 77                 return -ENOMEM;
 78 
 79         qi_lb60->snd_gpio = devm_gpiod_get(&pdev->dev, "snd", GPIOD_OUT_LOW);
 80         if (IS_ERR(qi_lb60->snd_gpio))
 81                 return PTR_ERR(qi_lb60->snd_gpio);
 82 
 83         qi_lb60->amp_gpio = devm_gpiod_get(&pdev->dev, "amp", GPIOD_OUT_LOW);
 84         if (IS_ERR(qi_lb60->amp_gpio))
 85                 return PTR_ERR(qi_lb60->amp_gpio);
 86 
 87         card->dev = &pdev->dev;
 88 
 89         snd_soc_card_set_drvdata(card, qi_lb60);
 90 
 91         return devm_snd_soc_register_card(&pdev->dev, card);
 92 }
 93 
 94 static struct platform_driver qi_lb60_driver = {
 95         .driver         = {
 96                 .name   = "qi-lb60-audio",
 97         },
 98         .probe          = qi_lb60_probe,
 99 };
100 
101 module_platform_driver(qi_lb60_driver);
102 
103 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
104 MODULE_DESCRIPTION("ALSA SoC QI LB60 Audio support");
105 MODULE_LICENSE("GPL v2");
106 MODULE_ALIAS("platform:qi-lb60-audio");
107 

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp