sound/soc/codecs/pm4125-sdw.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/pm4125-sdw.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/pm4125-sdw.c- Extension
.c- Size
- 16597 bytes
- Lines
- 494
- 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.
- 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/component.hlinux/device.hlinux/irq.hlinux/irqdomain.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hlinux/slab.hlinux/soundwire/sdw.hlinux/soundwire/sdw_registers.hlinux/soundwire/sdw_type.hsound/soc-dapm.hsound/soc.hpm4125.h
Detected Declarations
function pm4125_sdw_hw_paramsfunction pm4125_interrupt_callbackfunction pm4125_rdwr_registerfunction pm4125_readable_registerfunction pm4125_volatile_registerfunction pm4125_probefunction pm4125_removefunction pm4125_sdw_runtime_suspendfunction pm4125_sdw_runtime_resumeexport pm4125_sdw_hw_params
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
// Copyright, 2025 Linaro Ltd
#include <linux/component.h>
#include <linux/device.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_registers.h>
#include <linux/soundwire/sdw_type.h>
#include <sound/soc-dapm.h>
#include <sound/soc.h>
#include "pm4125.h"
static struct wcd_sdw_ch_info pm4125_sdw_rx_ch_info[] = {
WCD_SDW_CH(PM4125_HPH_L, PM4125_HPH_PORT, BIT(0)),
WCD_SDW_CH(PM4125_HPH_R, PM4125_HPH_PORT, BIT(1)),
};
static struct wcd_sdw_ch_info pm4125_sdw_tx_ch_info[] = {
WCD_SDW_CH(PM4125_ADC1, PM4125_ADC_1_2_DMIC1L_BCS_PORT, BIT(0)),
WCD_SDW_CH(PM4125_ADC2, PM4125_ADC_1_2_DMIC1L_BCS_PORT, BIT(1)),
};
static struct sdw_dpn_prop pm4125_dpn_prop[PM4125_MAX_SWR_PORTS] = {
{
.num = 1,
.type = SDW_DPN_SIMPLE,
.min_ch = 1,
.max_ch = 8,
.simple_ch_prep_sm = true,
}, {
.num = 2,
.type = SDW_DPN_SIMPLE,
.min_ch = 1,
.max_ch = 4,
.simple_ch_prep_sm = true,
}
};
int pm4125_sdw_hw_params(struct pm4125_sdw_priv *priv, struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{
struct sdw_port_config port_config[PM4125_MAX_SWR_PORTS];
unsigned long ch_mask;
int i, j;
priv->sconfig.ch_count = 1;
priv->active_ports = 0;
for (i = 0; i < PM4125_MAX_SWR_PORTS; i++) {
ch_mask = priv->port_config[i].ch_mask;
if (!ch_mask)
continue;
for_each_set_bit(j, &ch_mask, 4)
priv->sconfig.ch_count++;
port_config[priv->active_ports] = priv->port_config[i];
priv->active_ports++;
}
priv->sconfig.bps = 1;
priv->sconfig.frame_rate = params_rate(params);
priv->sconfig.direction = priv->is_tx ? SDW_DATA_DIR_TX : SDW_DATA_DIR_RX;
priv->sconfig.type = SDW_STREAM_PCM;
return sdw_stream_add_slave(priv->sdev, &priv->sconfig, &port_config[0], priv->active_ports,
priv->sruntime);
}
EXPORT_SYMBOL_GPL(pm4125_sdw_hw_params);
/*
* Handle Soundwire out-of-band interrupt event by triggering the first irq of the slave_irq
* irq domain, which then will be handled by the regmap_irq threaded irq.
* Looping is to ensure no interrupts were missed in the process.
*/
static int pm4125_interrupt_callback(struct sdw_slave *slave, struct sdw_slave_intr_status *status)
{
struct pm4125_sdw_priv *priv = dev_get_drvdata(&slave->dev);
return wcd_interrupt_callback(slave, priv->slave_irq, PM4125_DIG_SWR_INTR_STATUS_0,
PM4125_DIG_SWR_INTR_STATUS_1, PM4125_DIG_SWR_INTR_STATUS_2);
Annotation
- Immediate include surface: `linux/component.h`, `linux/device.h`, `linux/irq.h`, `linux/irqdomain.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`.
- Detected declarations: `function pm4125_sdw_hw_params`, `function pm4125_interrupt_callback`, `function pm4125_rdwr_register`, `function pm4125_readable_register`, `function pm4125_volatile_register`, `function pm4125_probe`, `function pm4125_remove`, `function pm4125_sdw_runtime_suspend`, `function pm4125_sdw_runtime_resume`, `export pm4125_sdw_hw_params`.
- 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.