Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: tegra: Add support for WM8962 and CPCAP

Merge series from Svyatoslav Ryhel <clamor95@gmail.com>:

Add support for WM8962 and CPCAP codecs found in various Tegra devices.

+421
+90
Documentation/devicetree/bindings/sound/nvidia,tegra-audio-cpcap.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-cpcap.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: NVIDIA Tegra audio complex with CPCAP CODEC 8 + 9 + maintainers: 10 + - Svyatoslav Ryhel <clamor95@gmail.com> 11 + 12 + allOf: 13 + - $ref: nvidia,tegra-audio-common.yaml# 14 + 15 + properties: 16 + compatible: 17 + items: 18 + - pattern: '^motorola,tegra-audio-cpcap(-[a-z0-9]+)+$' 19 + - const: nvidia,tegra-audio-cpcap 20 + 21 + nvidia,audio-routing: 22 + $ref: /schemas/types.yaml#/definitions/non-unique-string-array 23 + description: 24 + A list of the connections between audio components. Each entry is a 25 + pair of strings, the first being the connection's sink, the second 26 + being the connection's source. Valid names for sources and sinks are 27 + the pins (documented in the binding document), and the jacks on the 28 + board. 29 + minItems: 2 30 + items: 31 + enum: 32 + # Board Connectors 33 + - Speakers 34 + - Int Spk 35 + - Earpiece 36 + - Int Mic 37 + - Headset Mic 38 + - Internal Mic 1 39 + - Internal Mic 2 40 + - Headphone 41 + - Headphones 42 + - Headphone Jack 43 + - Mic Jack 44 + 45 + # CODEC Pins 46 + - MICR 47 + - HSMIC 48 + - EMUMIC 49 + - MICL 50 + - EXTR 51 + - EXTL 52 + - EP 53 + - SPKR 54 + - SPKL 55 + - LINER 56 + - LINEL 57 + - HSR 58 + - HSL 59 + - EMUR 60 + - EMUL 61 + 62 + unevaluatedProperties: false 63 + 64 + examples: 65 + - | 66 + #include <dt-bindings/clock/tegra20-car.h> 67 + #include <dt-bindings/soc/tegra-pmc.h> 68 + sound { 69 + compatible = "motorola,tegra-audio-cpcap-olympus", 70 + "nvidia,tegra-audio-cpcap"; 71 + nvidia,model = "Motorola Atrix 4G (MB860) CPCAP"; 72 + 73 + nvidia,audio-routing = 74 + "Headphones", "HSR", 75 + "Headphones", "HSL", 76 + "Int Spk", "SPKR", 77 + "Int Spk", "SPKL", 78 + "Earpiece", "EP", 79 + "HSMIC", "Mic Jack", 80 + "MICR", "Internal Mic 1", 81 + "MICL", "Internal Mic 2"; 82 + 83 + nvidia,i2s-controller = <&tegra_i2s1>; 84 + nvidia,audio-codec = <&cpcap_audio>; 85 + 86 + clocks = <&tegra_car TEGRA20_CLK_PLL_A>, 87 + <&tegra_car TEGRA20_CLK_PLL_A_OUT0>, 88 + <&tegra_car TEGRA20_CLK_CDEV1>; 89 + clock-names = "pll_a", "pll_a_out0", "mclk"; 90 + };
+5
Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max9808x.yaml
··· 35 35 items: 36 36 enum: 37 37 # Board Connectors 38 + - Speakers 38 39 - Int Spk 40 + - Headphone 41 + - Headphones 39 42 - Headphone Jack 40 43 - Earpiece 41 44 - Headset Mic 45 + - Mic Jack 46 + - Int Mic 42 47 - Internal Mic 1 43 48 - Internal Mic 2 44 49
+88
Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm8962.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-wm8962.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: NVIDIA Tegra audio complex with WM8962 CODEC 8 + 9 + maintainers: 10 + - Svyatoslav Ryhel <clamor95@gmail.com> 11 + 12 + allOf: 13 + - $ref: nvidia,tegra-audio-common.yaml# 14 + 15 + properties: 16 + compatible: 17 + items: 18 + - pattern: '^[a-z0-9]+,tegra-audio-wm8962(-[a-z0-9]+)+$' 19 + - const: nvidia,tegra-audio-wm8962 20 + 21 + nvidia,audio-routing: 22 + $ref: /schemas/types.yaml#/definitions/non-unique-string-array 23 + description: 24 + A list of the connections between audio components. Each entry is a 25 + pair of strings, the first being the connection's sink, the second 26 + being the connection's source. Valid names for sources and sinks are 27 + the pins (documented in the binding document), and the jacks on the 28 + board. 29 + minItems: 2 30 + items: 31 + enum: 32 + # Board Connectors 33 + - Speakers 34 + - Int Spk 35 + - Earpiece 36 + - Int Mic 37 + - Headset Mic 38 + - Internal Mic 1 39 + - Internal Mic 2 40 + - Headphone 41 + - Headphones 42 + - Headphone Jack 43 + - Mic Jack 44 + 45 + # CODEC Pins 46 + - IN1L 47 + - IN1R 48 + - IN2L 49 + - IN2R 50 + - IN3L 51 + - IN3R 52 + - IN4L 53 + - IN4R 54 + - DMICDAT 55 + - HPOUTL 56 + - HPOUTR 57 + - SPKOUT 58 + - SPKOUTL 59 + - SPKOUTR 60 + 61 + required: 62 + - nvidia,i2s-controller 63 + 64 + unevaluatedProperties: false 65 + 66 + examples: 67 + - | 68 + #include <dt-bindings/clock/tegra30-car.h> 69 + #include <dt-bindings/soc/tegra-pmc.h> 70 + sound { 71 + compatible = "microsoft,tegra-audio-wm8962-surface-rt", 72 + "nvidia,tegra-audio-wm8962"; 73 + nvidia,model = "Microsoft Surface RT WM8962"; 74 + 75 + nvidia,audio-routing = 76 + "Headphone Jack", "HPOUTR", 77 + "Headphone Jack", "HPOUTL", 78 + "Int Spk", "SPKOUTR", 79 + "Int Spk", "SPKOUTL"; 80 + 81 + nvidia,i2s-controller = <&tegra_i2s1>; 82 + nvidia,audio-codec = <&wm8962>; 83 + 84 + clocks = <&tegra_car TEGRA30_CLK_PLL_A>, 85 + <&tegra_car TEGRA30_CLK_PLL_A_OUT0>, 86 + <&tegra_pmc TEGRA_PMC_CLK_OUT_1>; 87 + clock-names = "pll_a", "pll_a_out0", "mclk"; 88 + };
+19
sound/soc/tegra/Kconfig
··· 229 229 boards using the WM8093 codec. Currently, the supported boards are 230 230 Harmony, Ventana, Seaboard, Kaen, and Aebl. 231 231 232 + config SND_SOC_TEGRA_WM8962 233 + tristate "SoC Audio support for Tegra boards using a WM8962 codec" 234 + depends on I2C && INPUT && GPIOLIB 235 + select SND_SOC_TEGRA_MACHINE_DRV 236 + select SND_SOC_WM8962 237 + help 238 + Say Y or M here if you want to add support for SoC audio on Tegra 239 + boards using the WM8962 codec. Currently, the supported boards are 240 + Microsoft Surface RT. 241 + 232 242 config SND_SOC_TEGRA_WM9712 233 243 tristate "SoC Audio support for Tegra boards using a WM9712 codec" 234 244 depends on GPIOLIB ··· 303 293 Say Y or M here if you want to add support for SoC audio on Tegra 304 294 boards using the SGTL5000 codec, such as Apalis T30, Apalis TK1 or 305 295 Colibri T30. 296 + 297 + config SND_SOC_TEGRA_CPCAP 298 + tristate "SoC Audio support for Tegra boards using a CPCAP codec" 299 + depends on I2C && GPIOLIB && MFD_CPCAP 300 + select SND_SOC_TEGRA_MACHINE_DRV 301 + select SND_SOC_CPCAP 302 + help 303 + Say Y or M here if you want to add support for SoC audio on Tegra 304 + boards using the CPCAP codec, such as Motorola Atrix 4G or Droid X2. 306 305 307 306 endif 308 307
+2
sound/soc/tegra/Makefile
··· 43 43 44 44 # Tegra machine Support 45 45 snd-soc-tegra-wm8903-y := tegra_wm8903.o 46 + snd-soc-tegra-wm8962-y := tegra_wm8962.o 46 47 snd-soc-tegra-machine-y := tegra_asoc_machine.o 47 48 snd-soc-tegra-audio-graph-card-y := tegra_audio_graph_card.o 48 49 49 50 obj-$(CONFIG_SND_SOC_TEGRA_WM8903) += snd-soc-tegra-wm8903.o 51 + obj-$(CONFIG_SND_SOC_TEGRA_WM8962) += snd-soc-tegra-wm8962.o 50 52 obj-$(CONFIG_SND_SOC_TEGRA_MACHINE_DRV) += snd-soc-tegra-machine.o 51 53 obj-$(CONFIG_SND_SOC_TEGRA_AUDIO_GRAPH_CARD) += snd-soc-tegra-audio-graph-card.o
+52
sound/soc/tegra/tegra_asoc_machine.c
··· 287 287 return mclk; 288 288 } 289 289 290 + static unsigned int tegra_machine_mclk_rate_cpcap(unsigned int srate) 291 + { 292 + unsigned int mclk; 293 + 294 + switch (srate) { 295 + case 11025: 296 + case 22050: 297 + case 44100: 298 + case 88200: 299 + mclk = 26000000; 300 + break; 301 + default: 302 + mclk = 256 * srate; 303 + break; 304 + } 305 + 306 + return mclk; 307 + } 308 + 290 309 static int tegra_machine_hw_params(struct snd_pcm_substream *substream, 291 310 struct snd_pcm_hw_params *params) 292 311 { ··· 1004 985 .add_hp_jack = true, 1005 986 }; 1006 987 988 + /* CPCAP machine */ 989 + 990 + SND_SOC_DAILINK_DEFS(cpcap_hifi, 991 + DAILINK_COMP_ARRAY(COMP_EMPTY()), 992 + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "cpcap-hifi")), 993 + DAILINK_COMP_ARRAY(COMP_EMPTY())); 994 + 995 + static struct snd_soc_dai_link tegra_cpcap_dai = { 996 + .name = "CPCAP", 997 + .stream_name = "CPCAP PCM", 998 + .init = tegra_asoc_machine_init, 999 + .dai_fmt = SND_SOC_DAIFMT_I2S | 1000 + SND_SOC_DAIFMT_NB_NF | 1001 + SND_SOC_DAIFMT_CBP_CFP, 1002 + SND_SOC_DAILINK_REG(cpcap_hifi), 1003 + }; 1004 + 1005 + static struct snd_soc_card snd_soc_tegra_cpcap = { 1006 + .components = "codec:cpcap", 1007 + .dai_link = &tegra_cpcap_dai, 1008 + .num_links = 1, 1009 + .fully_routed = true, 1010 + }; 1011 + 1012 + static const struct tegra_asoc_data tegra_cpcap_data = { 1013 + .mclk_rate = tegra_machine_mclk_rate_cpcap, 1014 + .card = &snd_soc_tegra_cpcap, 1015 + .add_common_dapm_widgets = true, 1016 + .add_common_controls = true, 1017 + .add_common_snd_ops = true, 1018 + }; 1019 + 1007 1020 static const struct of_device_id tegra_machine_of_match[] = { 1008 1021 { .compatible = "nvidia,tegra-audio-trimslice", .data = &tegra_trimslice_data }, 1009 1022 { .compatible = "nvidia,tegra-audio-max98090", .data = &tegra_max98090_data }, ··· 1048 997 { .compatible = "nvidia,tegra-audio-rt5640", .data = &tegra_rt5640_data }, 1049 998 { .compatible = "nvidia,tegra-audio-alc5632", .data = &tegra_rt5632_data }, 1050 999 { .compatible = "nvidia,tegra-audio-rt5631", .data = &tegra_rt5631_data }, 1000 + { .compatible = "nvidia,tegra-audio-cpcap", .data = &tegra_cpcap_data }, 1051 1001 {}, 1052 1002 }; 1053 1003 MODULE_DEVICE_TABLE(of, tegra_machine_of_match);
+165
sound/soc/tegra/tegra_wm8962.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * tegra_wm8962.c - Tegra machine ASoC driver for boards using WM8962 codec. 4 + * 5 + * Copyright (C) 2021-2024 Jonas Schwöbel <jonasschwoebel@yahoo.de> 6 + * Svyatoslav Ryhel <clamor95@gmail.com> 7 + * 8 + * Based on tegra_wm8903 code copyright/by: 9 + * 10 + * Author: Stephen Warren <swarren@nvidia.com> 11 + * Copyright (C) 2010-2012 - NVIDIA, Inc. 12 + * 13 + * Based on code copyright/by: 14 + * 15 + * (c) 2009, 2010 Nvidia Graphics Pvt. Ltd. 16 + * 17 + * Copyright 2007 Wolfson Microelectronics PLC. 18 + * Author: Graeme Gregory 19 + * graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com 20 + */ 21 + 22 + #include <linux/gpio/consumer.h> 23 + #include <linux/of.h> 24 + #include <linux/module.h> 25 + #include <linux/platform_device.h> 26 + 27 + #include <sound/core.h> 28 + #include <sound/jack.h> 29 + #include <sound/soc.h> 30 + 31 + #include "../codecs/wm8962.h" 32 + 33 + #include "tegra_asoc_machine.h" 34 + 35 + static struct snd_soc_jack_pin tegra_wm8962_mic_jack_pins[] = { 36 + { .pin = "Mic Jack", .mask = SND_JACK_MICROPHONE }, 37 + }; 38 + 39 + static unsigned int tegra_wm8962_mclk_rate(unsigned int srate) 40 + { 41 + unsigned int mclk; 42 + 43 + switch (srate) { 44 + case 8000: 45 + case 16000: 46 + case 24000: 47 + case 32000: 48 + case 48000: 49 + case 64000: 50 + case 96000: 51 + mclk = 12288000; 52 + break; 53 + case 11025: 54 + case 22050: 55 + case 44100: 56 + case 88200: 57 + mclk = 11289600; 58 + break; 59 + default: 60 + mclk = 12000000; 61 + break; 62 + } 63 + 64 + return mclk; 65 + } 66 + 67 + static int tegra_wm8962_init(struct snd_soc_pcm_runtime *rtd) 68 + { 69 + struct tegra_machine *machine = snd_soc_card_get_drvdata(rtd->card); 70 + struct snd_soc_card *card = rtd->card; 71 + struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card); 72 + int err; 73 + 74 + err = tegra_asoc_machine_init(rtd); 75 + if (err) 76 + return err; 77 + 78 + if (!machine->gpiod_mic_det && machine->asoc->add_mic_jack) { 79 + struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); 80 + struct snd_soc_component *component = codec_dai->component; 81 + 82 + err = snd_soc_card_jack_new_pins(rtd->card, "Mic Jack", 83 + SND_JACK_MICROPHONE, 84 + machine->mic_jack, 85 + tegra_wm8962_mic_jack_pins, 86 + ARRAY_SIZE(tegra_wm8962_mic_jack_pins)); 87 + if (err) { 88 + dev_err(rtd->dev, "Mic Jack creation failed: %d\n", err); 89 + return err; 90 + } 91 + 92 + wm8962_mic_detect(component, machine->mic_jack); 93 + } 94 + 95 + snd_soc_dapm_force_enable_pin(dapm, "MICBIAS"); 96 + 97 + return 0; 98 + } 99 + 100 + static int tegra_wm8962_remove(struct snd_soc_card *card) 101 + { 102 + struct snd_soc_dai_link *link = &card->dai_link[0]; 103 + struct snd_soc_pcm_runtime *rtd = snd_soc_get_pcm_runtime(card, link); 104 + struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); 105 + struct snd_soc_component *component = codec_dai->component; 106 + 107 + wm8962_mic_detect(component, NULL); 108 + 109 + return 0; 110 + } 111 + 112 + SND_SOC_DAILINK_DEFS(wm8962_hifi, 113 + DAILINK_COMP_ARRAY(COMP_EMPTY()), 114 + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8962")), 115 + DAILINK_COMP_ARRAY(COMP_EMPTY())); 116 + 117 + static struct snd_soc_dai_link tegra_wm8962_dai = { 118 + .name = "WM8962", 119 + .stream_name = "WM8962 PCM", 120 + .init = tegra_wm8962_init, 121 + .dai_fmt = SND_SOC_DAIFMT_I2S | 122 + SND_SOC_DAIFMT_NB_NF | 123 + SND_SOC_DAIFMT_CBC_CFC, 124 + SND_SOC_DAILINK_REG(wm8962_hifi), 125 + }; 126 + 127 + static struct snd_soc_card snd_soc_tegra_wm8962 = { 128 + .components = "codec:wm8962", 129 + .owner = THIS_MODULE, 130 + .dai_link = &tegra_wm8962_dai, 131 + .num_links = 1, 132 + .remove = tegra_wm8962_remove, 133 + .fully_routed = true, 134 + }; 135 + 136 + static const struct tegra_asoc_data tegra_wm8962_data = { 137 + .mclk_rate = tegra_wm8962_mclk_rate, 138 + .card = &snd_soc_tegra_wm8962, 139 + .add_common_dapm_widgets = true, 140 + .add_common_controls = true, 141 + .add_common_snd_ops = true, 142 + .add_mic_jack = true, 143 + .add_hp_jack = true, 144 + }; 145 + 146 + static const struct of_device_id tegra_wm8962_of_match[] = { 147 + { .compatible = "nvidia,tegra-audio-wm8962", .data = &tegra_wm8962_data }, 148 + {}, 149 + }; 150 + MODULE_DEVICE_TABLE(of, tegra_wm8962_of_match); 151 + 152 + static struct platform_driver tegra_wm8962_driver = { 153 + .driver = { 154 + .name = "tegra-wm8962", 155 + .of_match_table = tegra_wm8962_of_match, 156 + .pm = &snd_soc_pm_ops, 157 + }, 158 + .probe = tegra_asoc_machine_probe, 159 + }; 160 + module_platform_driver(tegra_wm8962_driver); 161 + 162 + MODULE_AUTHOR("Jonas Schwöbel <jonasschwoebel@yahoo.de>"); 163 + MODULE_AUTHOR("Svyatoslav Ryhel <clamor95@gmail.com>"); 164 + MODULE_DESCRIPTION("Tegra+WM8962 machine ASoC driver"); 165 + MODULE_LICENSE("GPL");