sound/soc/sdw_utils/soc_sdw_maxim.c
Source file repositories/reference/linux-study-clean/sound/soc/sdw_utils/soc_sdw_maxim.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sdw_utils/soc_sdw_maxim.c- Extension
.c- Size
- 3814 bytes
- Lines
- 140
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/errno.hsound/control.hsound/soc.hsound/soc-acpi.hsound/soc-dapm.hsound/soc_sdw_utils.h
Detected Declarations
function asoc_sdw_maxim_spk_rtd_initfunction asoc_sdw_mx8373_enable_spk_pinfunction asoc_sdw_mx8373_preparefunction asoc_sdw_mx8373_hw_freefunction asoc_sdw_mx8373_sdw_late_probefunction asoc_sdw_maxim_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
// This file incorporates work covered by the following copyright notice:
// Copyright (c) 2020 Intel Corporation
// Copyright (c) 2024 Advanced Micro Devices, Inc.
//
// soc_sdw_maxim - Helpers to handle maxim codecs
// codec devices from generic machine driver
#include <linux/device.h>
#include <linux/errno.h>
#include <sound/control.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>
#include <sound/soc-dapm.h>
#include <sound/soc_sdw_utils.h>
static int maxim_part_id;
#define SOC_SDW_PART_ID_MAX98363 0x8363
#define SOC_SDW_PART_ID_MAX98373 0x8373
static const struct snd_soc_dapm_route max_98373_dapm_routes[] = {
{ "Left Spk", NULL, "Left BE_OUT" },
{ "Right Spk", NULL, "Right BE_OUT" },
};
int asoc_sdw_maxim_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
{
struct snd_soc_card *card = rtd->card;
struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);
int ret;
ret = snd_soc_dapm_add_routes(dapm, max_98373_dapm_routes, 2);
if (ret)
dev_err(rtd->dev, "failed to add first SPK map: %d\n", ret);
return ret;
}
EXPORT_SYMBOL_NS(asoc_sdw_maxim_spk_rtd_init, "SND_SOC_SDW_UTILS");
static int asoc_sdw_mx8373_enable_spk_pin(struct snd_pcm_substream *substream, bool enable)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_dai *codec_dai;
struct snd_soc_dai *cpu_dai;
int ret;
int j;
/* set spk pin by playback only */
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
return 0;
cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
for_each_rtd_codec_dais(rtd, j, codec_dai) {
struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(cpu_dai->component);
char pin_name[16];
snprintf(pin_name, ARRAY_SIZE(pin_name), "%s Spk",
codec_dai->component->name_prefix);
if (enable)
ret = snd_soc_dapm_enable_pin(dapm, pin_name);
else
ret = snd_soc_dapm_disable_pin(dapm, pin_name);
if (!ret)
snd_soc_dapm_sync(dapm);
}
return 0;
}
static int asoc_sdw_mx8373_prepare(struct snd_pcm_substream *substream)
{
int ret;
/* according to soc_pcm_prepare dai link prepare is called first */
ret = asoc_sdw_prepare(substream);
if (ret < 0)
return ret;
return asoc_sdw_mx8373_enable_spk_pin(substream, true);
}
static int asoc_sdw_mx8373_hw_free(struct snd_pcm_substream *substream)
{
int ret;
/* according to soc_pcm_hw_free dai link free is called first */
ret = asoc_sdw_hw_free(substream);
if (ret < 0)
Annotation
- Immediate include surface: `linux/device.h`, `linux/errno.h`, `sound/control.h`, `sound/soc.h`, `sound/soc-acpi.h`, `sound/soc-dapm.h`, `sound/soc_sdw_utils.h`.
- Detected declarations: `function asoc_sdw_maxim_spk_rtd_init`, `function asoc_sdw_mx8373_enable_spk_pin`, `function asoc_sdw_mx8373_prepare`, `function asoc_sdw_mx8373_hw_free`, `function asoc_sdw_mx8373_sdw_late_probe`, `function asoc_sdw_maxim_init`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.