sound/soc/codecs/sdw-mockup.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/sdw-mockup.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/sdw-mockup.c- Extension
.c- Size
- 6683 bytes
- Lines
- 270
- 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/mod_devicetable.hlinux/module.hlinux/soundwire/sdw.hlinux/soundwire/sdw_type.hlinux/soundwire/sdw_registers.hsound/core.hsound/pcm.hsound/pcm_params.hsound/sdw.hsound/soc.h
Detected Declarations
struct sdw_mockup_privfunction sdw_mockup_component_probefunction sdw_mockup_component_removefunction sdw_mockup_set_sdw_streamfunction sdw_mockup_shutdownfunction sdw_mockup_pcm_hw_paramsfunction sdw_mockup_pcm_hw_freefunction sdw_mockup_update_statusfunction sdw_mockup_read_propfunction sdw_mockup_bus_configfunction sdw_mockup_interrupt_callbackfunction sdw_mockup_sdw_probe
Annotated Snippet
struct sdw_mockup_priv {
struct sdw_slave *slave;
};
static int sdw_mockup_component_probe(struct snd_soc_component *component)
{
return 0;
}
static void sdw_mockup_component_remove(struct snd_soc_component *component)
{
}
static const struct snd_soc_component_driver snd_soc_sdw_mockup_component = {
.probe = sdw_mockup_component_probe,
.remove = sdw_mockup_component_remove,
.endianness = 1,
};
static int sdw_mockup_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream,
int direction)
{
snd_soc_dai_dma_data_set(dai, direction, sdw_stream);
return 0;
}
static void sdw_mockup_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
snd_soc_dai_set_dma_data(dai, substream, NULL);
}
static int sdw_mockup_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct sdw_mockup_priv *sdw_mockup = snd_soc_component_get_drvdata(component);
struct sdw_stream_config stream_config = {0};
struct sdw_port_config port_config = {0};
struct sdw_stream_runtime *sdw_stream = snd_soc_dai_get_dma_data(dai, substream);
int ret;
if (!sdw_stream)
return -EINVAL;
if (!sdw_mockup->slave)
return -EINVAL;
/* SoundWire specific configuration */
snd_sdw_params_to_config(substream, params, &stream_config, &port_config);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
port_config.num = 1;
else
port_config.num = 8;
ret = sdw_stream_add_slave(sdw_mockup->slave, &stream_config,
&port_config, 1, sdw_stream);
if (ret)
dev_err(dai->dev, "Unable to configure port\n");
return ret;
}
static int sdw_mockup_pcm_hw_free(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct sdw_mockup_priv *sdw_mockup = snd_soc_component_get_drvdata(component);
struct sdw_stream_runtime *sdw_stream = snd_soc_dai_get_dma_data(dai, substream);
if (!sdw_mockup->slave)
return -EINVAL;
sdw_stream_remove_slave(sdw_mockup->slave, sdw_stream);
return 0;
}
static const struct snd_soc_dai_ops sdw_mockup_ops = {
.hw_params = sdw_mockup_pcm_hw_params,
.hw_free = sdw_mockup_pcm_hw_free,
.set_stream = sdw_mockup_set_sdw_stream,
.shutdown = sdw_mockup_shutdown,
};
static struct snd_soc_dai_driver sdw_mockup_dai[] = {
{
.name = "sdw-mockup-aif1",
Annotation
- Immediate include surface: `linux/device.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/soundwire/sdw.h`, `linux/soundwire/sdw_type.h`, `linux/soundwire/sdw_registers.h`, `sound/core.h`, `sound/pcm.h`.
- Detected declarations: `struct sdw_mockup_priv`, `function sdw_mockup_component_probe`, `function sdw_mockup_component_remove`, `function sdw_mockup_set_sdw_stream`, `function sdw_mockup_shutdown`, `function sdw_mockup_pcm_hw_params`, `function sdw_mockup_pcm_hw_free`, `function sdw_mockup_update_status`, `function sdw_mockup_read_prop`, `function sdw_mockup_bus_config`.
- 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.