sound/soc/samsung/midas_wm1811.c
Source file repositories/reference/linux-study-clean/sound/soc/samsung/midas_wm1811.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/samsung/midas_wm1811.c- Extension
.c- Size
- 20756 bytes
- Lines
- 776
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/gpio/consumer.hlinux/iio/consumer.hlinux/mfd/wm8994/registers.hlinux/input-event-codes.hlinux/module.hlinux/of.hsound/jack.hsound/soc.hsound/soc-dapm.hi2s.h../codecs/wm8994.h
Detected Declarations
struct midas_privfunction headset_jack_checkfunction headset_key_checkfunction midas_start_fll1function midas_stop_fll1function midas_aif1_hw_paramsfunction midas_ext_spkmodefunction midas_fm_setfunction midas_line_setfunction midas_set_bias_levelfunction midas_late_probefunction midas_probefunction for_each_card_prelinks
Annotated Snippet
struct midas_priv {
struct gpio_desc *gpio_fm_sel;
struct gpio_desc *gpio_lineout_sel;
struct gpio_desc *gpio_headset_detect;
struct gpio_desc *gpio_headset_key;
struct iio_channel *adc_headset_detect;
unsigned int fll1_rate;
struct snd_soc_jack headset_jack;
};
static struct snd_soc_jack_pin headset_jack_pins[] = {
{
.pin = "Headphone",
.mask = SND_JACK_HEADPHONE,
},
{
.pin = "Headset Mic",
.mask = SND_JACK_MICROPHONE,
},
};
/*
* min_mv/max_mv values in this struct are set up based on DT values.
*/
static struct snd_soc_jack_zone headset_jack_zones[] = {
{ .jack_type = SND_JACK_HEADPHONE, },
{ .jack_type = SND_JACK_HEADSET, },
{ .jack_type = SND_JACK_HEADPHONE, },
};
/*
* This is used for manual detection in headset_key_check, we reuse the
* structure since it's convenient.
*
* min_mv/max_mv values in this struct are set up based on DT values.
*/
static struct snd_soc_jack_zone headset_key_zones[] = {
{ .jack_type = SND_JACK_BTN_0, }, /* Media */
{ .jack_type = SND_JACK_BTN_1, }, /* Volume Up */
{ .jack_type = SND_JACK_BTN_2, }, /* Volume Down */
};
static int headset_jack_check(void *data)
{
struct snd_soc_component *codec = data;
struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(codec);
struct midas_priv *priv = snd_soc_card_get_drvdata(codec->card);
int adc, ret;
int jack_type = 0;
if (!gpiod_get_value_cansleep(priv->gpio_headset_detect))
return 0;
/* Enable headset mic bias regulator so that the ADC reading works */
ret = snd_soc_dapm_force_enable_pin(dapm, "headset-mic-bias");
if (ret < 0) {
pr_err("%s: Failed to enable headset mic bias regulator (%d), assuming headphones\n",
__func__, ret);
return SND_JACK_HEADPHONE;
}
snd_soc_dapm_sync(dapm);
/* Sleep for a small amount of time to get the value to stabilize */
msleep(20);
ret = iio_read_channel_processed(priv->adc_headset_detect, &adc);
if (ret) {
pr_err("%s: Failed to read ADC (%d), assuming headphones\n",
__func__, ret);
jack_type = SND_JACK_HEADPHONE;
goto out;
}
pr_debug("%s: ADC value is %d\n", __func__, adc);
jack_type = snd_soc_jack_get_type(&priv->headset_jack, adc);
out:
ret = snd_soc_dapm_disable_pin(dapm, "headset-mic-bias");
if (ret < 0)
pr_err("%s: Failed to disable headset mic bias regulator (%d)\n",
__func__, ret);
snd_soc_dapm_sync(dapm);
return jack_type;
}
static int headset_key_check(void *data)
{
struct snd_soc_component *codec = data;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/gpio/consumer.h`, `linux/iio/consumer.h`, `linux/mfd/wm8994/registers.h`, `linux/input-event-codes.h`, `linux/module.h`, `linux/of.h`, `sound/jack.h`.
- Detected declarations: `struct midas_priv`, `function headset_jack_check`, `function headset_key_check`, `function midas_start_fll1`, `function midas_stop_fll1`, `function midas_aif1_hw_params`, `function midas_ext_spkmode`, `function midas_fm_set`, `function midas_line_set`, `function midas_set_bias_level`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.