drivers/slimbus/stream.c
Source file repositories/reference/linux-study-clean/drivers/slimbus/stream.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/slimbus/stream.c- Extension
.c- Size
- 12643 bytes
- Lines
- 493
- Domain
- Driver Families
- Bucket
- drivers/slimbus
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/kernel.hlinux/errno.hlinux/slab.hlinux/list.hlinux/slimbus.huapi/sound/asound.hslimbus.h
Detected Declarations
struct segdist_codefunction slim_stream_allocatefunction slim_connect_port_channelfunction slim_disconnect_portfunction slim_deactivate_remove_channelfunction slim_get_prate_codefunction slim_stream_preparefunction slim_define_channel_contentfunction slim_get_segdist_codefunction slim_define_channelfunction slim_activate_channelfunction slim_stream_enablefunction slim_stream_disablefunction slim_stream_unpreparefunction slim_stream_freeexport slim_stream_allocateexport slim_stream_prepareexport slim_stream_enableexport slim_stream_disableexport slim_stream_unprepareexport slim_stream_free
Annotated Snippet
struct segdist_code {
int ratem;
int seg_interval;
int segdist_code;
u32 seg_offset_mask;
};
/* segdist_codes - List of all possible Segment Distribution codes. */
static const struct segdist_code segdist_codes[] = {
{1, 1536, 0x200, 0xdff},
{2, 768, 0x100, 0xcff},
{4, 384, 0x080, 0xc7f},
{8, 192, 0x040, 0xc3f},
{16, 96, 0x020, 0xc1f},
{32, 48, 0x010, 0xc0f},
{64, 24, 0x008, 0xc07},
{128, 12, 0x004, 0xc03},
{256, 6, 0x002, 0xc01},
{512, 3, 0x001, 0xc00},
{3, 512, 0xe00, 0x1ff},
{6, 256, 0xd00, 0x0ff},
{12, 128, 0xc80, 0x07f},
{24, 64, 0xc40, 0x03f},
{48, 32, 0xc20, 0x01f},
{96, 16, 0xc10, 0x00f},
{192, 8, 0xc08, 0x007},
{364, 4, 0xc04, 0x003},
{768, 2, 0xc02, 0x001},
};
/*
* Presence Rate table for all Natural Frequencies
* The Presence rate of a constant bitrate stream is mean flow rate of the
* stream expressed in occupied Segments of that Data Channel per second.
* Table 66 from SLIMbus 2.0 Specs
*
* Index of the table corresponds to Presence rate code for the respective rate
* in the table.
*/
static const int slim_presence_rate_table[] = {
0, /* Not Indicated */
12000,
24000,
48000,
96000,
192000,
384000,
768000,
0, /* Reserved */
11025,
22050,
44100,
88200,
176400,
352800,
705600,
4000,
8000,
16000,
32000,
64000,
128000,
256000,
512000,
};
/**
* slim_stream_allocate() - Allocate a new SLIMbus Stream
* @dev:Slim device to be associated with
* @name: name of the stream
*
* This is very first call for SLIMbus streaming, this API will allocate
* a new SLIMbus stream and return a valid stream runtime pointer for client
* to use it in subsequent stream apis. state of stream is set to ALLOCATED
*
* Return: valid pointer on success and error code on failure.
* From ASoC DPCM framework, this state is linked to startup() operation.
*/
struct slim_stream_runtime *slim_stream_allocate(struct slim_device *dev,
const char *name)
{
struct slim_stream_runtime *rt;
rt = kzalloc_obj(*rt);
if (!rt)
return ERR_PTR(-ENOMEM);
rt->name = kasprintf(GFP_KERNEL, "slim-%s", name);
if (!rt->name) {
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/slab.h`, `linux/list.h`, `linux/slimbus.h`, `uapi/sound/asound.h`, `slimbus.h`.
- Detected declarations: `struct segdist_code`, `function slim_stream_allocate`, `function slim_connect_port_channel`, `function slim_disconnect_port`, `function slim_deactivate_remove_channel`, `function slim_get_prate_code`, `function slim_stream_prepare`, `function slim_define_channel_content`, `function slim_get_segdist_code`, `function slim_define_channel`.
- Atlas domain: Driver Families / drivers/slimbus.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.