sound/soc/qcom/apq8016_sbc.c
Source file repositories/reference/linux-study-clean/sound/soc/qcom/apq8016_sbc.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/qcom/apq8016_sbc.c- Extension
.c- Size
- 9699 bytes
- Lines
- 348
- 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/device.hlinux/module.hlinux/kernel.hlinux/io.hlinux/of.hlinux/clk.hlinux/platform_device.hsound/pcm.hsound/pcm_params.hsound/jack.hsound/soc.huapi/linux/input-event-codes.hdt-bindings/sound/apq8016-lpass.hdt-bindings/sound/qcom,q6afe.hcommon.hqdsp6/q6afe.h
Detected Declarations
struct apq8016_sbc_datafunction apq8016_dai_initfunction for_each_rtd_codec_daisfunction apq8016_sbc_dai_initfunction apq8016_sbc_add_opsfunction qdsp6_dai_get_lpass_idfunction msm8916_qdsp6_dai_initfunction msm8916_qdsp6_startupfunction msm8916_qdsp6_shutdownfunction msm8916_qdsp6_be_hw_params_fixupfunction msm8916_qdsp6_add_opsfunction for_each_card_prelinksfunction apq8016_sbc_platform_probe
Annotated Snippet
struct apq8016_sbc_data {
struct snd_soc_card card;
void __iomem *mic_iomux;
void __iomem *spkr_iomux;
struct snd_soc_jack jack;
bool jack_setup;
int mi2s_clk_count[MI2S_COUNT];
};
#define MIC_CTRL_TER_WS_SLAVE_SEL BIT(21)
#define MIC_CTRL_QUA_WS_SLAVE_SEL_10 BIT(17)
#define MIC_CTRL_TLMM_SCLK_EN BIT(1)
#define SPKR_CTL_PRI_WS_SLAVE_SEL_11 (BIT(17) | BIT(16))
#define SPKR_CTL_TLMM_MCLK_EN BIT(1)
#define SPKR_CTL_TLMM_SCLK_EN BIT(2)
#define SPKR_CTL_TLMM_DATA1_EN BIT(3)
#define SPKR_CTL_TLMM_WS_OUT_SEL_MASK GENMASK(7, 6)
#define SPKR_CTL_TLMM_WS_OUT_SEL_SEC BIT(6)
#define SPKR_CTL_TLMM_WS_EN_SEL_MASK GENMASK(19, 18)
#define SPKR_CTL_TLMM_WS_EN_SEL_SEC BIT(18)
#define DEFAULT_MCLK_RATE 9600000
#define MI2S_BCLK_RATE 1536000
static struct snd_soc_jack_pin apq8016_sbc_jack_pins[] = {
{
.pin = "Mic Jack",
.mask = SND_JACK_MICROPHONE,
},
{
.pin = "Headphone Jack",
.mask = SND_JACK_HEADPHONE,
},
};
static int apq8016_dai_init(struct snd_soc_pcm_runtime *rtd, int mi2s)
{
struct snd_soc_dai *codec_dai;
struct snd_soc_component *component;
struct snd_soc_card *card = rtd->card;
struct apq8016_sbc_data *pdata = snd_soc_card_get_drvdata(card);
int i, rval;
u32 value;
switch (mi2s) {
case MI2S_PRIMARY:
writel(readl(pdata->spkr_iomux) | SPKR_CTL_PRI_WS_SLAVE_SEL_11,
pdata->spkr_iomux);
break;
case MI2S_QUATERNARY:
/* Configure the Quat MI2S to TLMM */
writel(readl(pdata->mic_iomux) | MIC_CTRL_QUA_WS_SLAVE_SEL_10 |
MIC_CTRL_TLMM_SCLK_EN,
pdata->mic_iomux);
break;
case MI2S_SECONDARY:
/* Clear TLMM_WS_OUT_SEL and TLMM_WS_EN_SEL fields */
value = readl(pdata->spkr_iomux) &
~(SPKR_CTL_TLMM_WS_OUT_SEL_MASK | SPKR_CTL_TLMM_WS_EN_SEL_MASK);
/* Configure the Sec MI2S to TLMM */
writel(value | SPKR_CTL_TLMM_MCLK_EN | SPKR_CTL_TLMM_SCLK_EN |
SPKR_CTL_TLMM_DATA1_EN | SPKR_CTL_TLMM_WS_OUT_SEL_SEC |
SPKR_CTL_TLMM_WS_EN_SEL_SEC, pdata->spkr_iomux);
break;
case MI2S_TERTIARY:
writel(readl(pdata->mic_iomux) | MIC_CTRL_TER_WS_SLAVE_SEL |
MIC_CTRL_TLMM_SCLK_EN,
pdata->mic_iomux);
break;
default:
dev_err(card->dev, "unsupported cpu dai configuration\n");
return -EINVAL;
}
if (!pdata->jack_setup) {
struct snd_jack *jack;
rval = snd_soc_card_jack_new_pins(card, "Headset Jack",
SND_JACK_HEADSET |
SND_JACK_HEADPHONE |
SND_JACK_BTN_0 | SND_JACK_BTN_1 |
SND_JACK_BTN_2 | SND_JACK_BTN_3 |
SND_JACK_BTN_4,
&pdata->jack,
apq8016_sbc_jack_pins,
ARRAY_SIZE(apq8016_sbc_jack_pins));
Annotation
- Immediate include surface: `linux/device.h`, `linux/module.h`, `linux/kernel.h`, `linux/io.h`, `linux/of.h`, `linux/clk.h`, `linux/platform_device.h`, `sound/pcm.h`.
- Detected declarations: `struct apq8016_sbc_data`, `function apq8016_dai_init`, `function for_each_rtd_codec_dais`, `function apq8016_sbc_dai_init`, `function apq8016_sbc_add_ops`, `function qdsp6_dai_get_lpass_id`, `function msm8916_qdsp6_dai_init`, `function msm8916_qdsp6_startup`, `function msm8916_qdsp6_shutdown`, `function msm8916_qdsp6_be_hw_params_fixup`.
- 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.