dmic.c (2ac5e38ea4203852d6e99edd3cf11f044b0a409f) | dmic.c (bc0a7dbc5a54a06b925064adba8b07d65acf8718) |
---|---|
1/* 2 * dmic.c -- SoC audio for Generic Digital MICs 3 * 4 * Author: Liam Girdwood <lrg@slimlogic.co.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * version 2 as published by the Free Software Foundation. --- 16 unchanged lines hidden (view full) --- 25#include <linux/platform_device.h> 26#include <linux/slab.h> 27#include <linux/module.h> 28#include <sound/core.h> 29#include <sound/pcm.h> 30#include <sound/soc.h> 31#include <sound/soc-dapm.h> 32 | 1/* 2 * dmic.c -- SoC audio for Generic Digital MICs 3 * 4 * Author: Liam Girdwood <lrg@slimlogic.co.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * version 2 as published by the Free Software Foundation. --- 16 unchanged lines hidden (view full) --- 25#include <linux/platform_device.h> 26#include <linux/slab.h> 27#include <linux/module.h> 28#include <sound/core.h> 29#include <sound/pcm.h> 30#include <sound/soc.h> 31#include <sound/soc-dapm.h> 32 |
33#define MAX_MODESWITCH_DELAY 70 34static int modeswitch_delay; 35module_param(modeswitch_delay, uint, 0644); 36 |
|
33struct dmic { 34 struct gpio_desc *gpio_en; 35 int wakeup_delay; | 37struct dmic { 38 struct gpio_desc *gpio_en; 39 int wakeup_delay; |
40 /* Delay after DMIC mode switch */ 41 int modeswitch_delay; |
|
36}; 37 | 42}; 43 |
44int dmic_daiops_trigger(struct snd_pcm_substream *substream, 45 int cmd, struct snd_soc_dai *dai) 46{ 47 struct snd_soc_component *component = dai->component; 48 struct dmic *dmic = snd_soc_component_get_drvdata(component); 49 50 switch (cmd) { 51 case SNDRV_PCM_TRIGGER_STOP: 52 if (dmic->modeswitch_delay) 53 mdelay(dmic->modeswitch_delay); 54 55 break; 56 } 57 58 return 0; 59} 60 61static const struct snd_soc_dai_ops dmic_dai_ops = { 62 .trigger = dmic_daiops_trigger, 63}; 64 |
|
38static int dmic_aif_event(struct snd_soc_dapm_widget *w, 39 struct snd_kcontrol *kcontrol, int event) { 40 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 41 struct dmic *dmic = snd_soc_component_get_drvdata(component); 42 43 switch (event) { 44 case SND_SOC_DAPM_POST_PMU: 45 if (dmic->gpio_en) --- 17 unchanged lines hidden (view full) --- 63 .stream_name = "Capture", 64 .channels_min = 1, 65 .channels_max = 8, 66 .rates = SNDRV_PCM_RATE_CONTINUOUS, 67 .formats = SNDRV_PCM_FMTBIT_S32_LE 68 | SNDRV_PCM_FMTBIT_S24_LE 69 | SNDRV_PCM_FMTBIT_S16_LE, 70 }, | 65static int dmic_aif_event(struct snd_soc_dapm_widget *w, 66 struct snd_kcontrol *kcontrol, int event) { 67 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 68 struct dmic *dmic = snd_soc_component_get_drvdata(component); 69 70 switch (event) { 71 case SND_SOC_DAPM_POST_PMU: 72 if (dmic->gpio_en) --- 17 unchanged lines hidden (view full) --- 90 .stream_name = "Capture", 91 .channels_min = 1, 92 .channels_max = 8, 93 .rates = SNDRV_PCM_RATE_CONTINUOUS, 94 .formats = SNDRV_PCM_FMTBIT_S32_LE 95 | SNDRV_PCM_FMTBIT_S24_LE 96 | SNDRV_PCM_FMTBIT_S16_LE, 97 }, |
98 .ops = &dmic_dai_ops, |
|
71}; 72 73static int dmic_component_probe(struct snd_soc_component *component) 74{ 75 struct dmic *dmic; 76 77 dmic = devm_kzalloc(component->dev, sizeof(*dmic), GFP_KERNEL); 78 if (!dmic) 79 return -ENOMEM; 80 81 dmic->gpio_en = devm_gpiod_get_optional(component->dev, 82 "dmicen", GPIOD_OUT_LOW); 83 if (IS_ERR(dmic->gpio_en)) 84 return PTR_ERR(dmic->gpio_en); 85 86 device_property_read_u32(component->dev, "wakeup-delay-ms", 87 &dmic->wakeup_delay); | 99}; 100 101static int dmic_component_probe(struct snd_soc_component *component) 102{ 103 struct dmic *dmic; 104 105 dmic = devm_kzalloc(component->dev, sizeof(*dmic), GFP_KERNEL); 106 if (!dmic) 107 return -ENOMEM; 108 109 dmic->gpio_en = devm_gpiod_get_optional(component->dev, 110 "dmicen", GPIOD_OUT_LOW); 111 if (IS_ERR(dmic->gpio_en)) 112 return PTR_ERR(dmic->gpio_en); 113 114 device_property_read_u32(component->dev, "wakeup-delay-ms", 115 &dmic->wakeup_delay); |
116 device_property_read_u32(component->dev, "modeswitch-delay-ms", 117 &dmic->modeswitch_delay); 118 if (modeswitch_delay) 119 dmic->modeswitch_delay = modeswitch_delay; |
|
88 | 120 |
121 if (dmic->modeswitch_delay > MAX_MODESWITCH_DELAY) 122 dmic->modeswitch_delay = MAX_MODESWITCH_DELAY; 123 |
|
89 snd_soc_component_set_drvdata(component, dmic); 90 91 return 0; 92} 93 94static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = { 95 SND_SOC_DAPM_AIF_OUT_E("DMIC AIF", "Capture", 0, 96 SND_SOC_NOPM, 0, 0, dmic_aif_event, --- 69 unchanged lines hidden --- | 124 snd_soc_component_set_drvdata(component, dmic); 125 126 return 0; 127} 128 129static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = { 130 SND_SOC_DAPM_AIF_OUT_E("DMIC AIF", "Capture", 0, 131 SND_SOC_NOPM, 0, 0, dmic_aif_event, --- 69 unchanged lines hidden --- |