drivers/soundwire/generic_bandwidth_allocation.c
Source file repositories/reference/linux-study-clean/drivers/soundwire/generic_bandwidth_allocation.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soundwire/generic_bandwidth_allocation.c- Extension
.c- Size
- 17980 bytes
- Lines
- 693
- Domain
- Driver Families
- Bucket
- drivers/soundwire
- 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/bitops.hlinux/device.hlinux/module.hlinux/mod_devicetable.hlinux/slab.hlinux/soundwire/sdw.hbus.h
Detected Declarations
struct sdw_group_paramsstruct sdw_groupfunction sdw_compute_slave_portsfunction list_for_each_entryfunction list_for_each_entryfunction sdw_compute_dp0_slave_portsfunction list_for_each_entryfunction sdw_compute_dp0_master_portsfunction list_for_each_entryfunction sdw_compute_dp0_port_paramsfunction list_for_each_entryfunction sdw_compute_master_portsfunction list_for_each_entryfunction _sdw_compute_port_paramsfunction list_for_each_entryfunction sdw_compute_group_paramsfunction list_for_each_entryfunction list_for_each_entryfunction sdw_add_element_group_countfunction sdw_get_group_countfunction list_for_each_entryfunction list_for_each_entryfunction sdw_compute_port_paramsfunction sdw_select_row_colfunction is_clock_scaling_supportedfunction is_lane_connected_to_all_peripheralsfunction list_for_each_entryfunction get_manager_lanefunction list_for_each_entryfunction sdw_compute_bus_paramsfunction list_for_each_entryfunction list_for_each_entryfunction list_for_each_entryfunction sdw_compute_paramsexport sdw_compute_slave_portsexport sdw_compute_params
Annotated Snippet
struct sdw_group_params {
unsigned int rate;
unsigned int lane;
int full_bw;
int payload_bw;
int hwidth;
};
struct sdw_group {
unsigned int count;
unsigned int max_size;
unsigned int *rates;
unsigned int *lanes;
};
void sdw_compute_slave_ports(struct sdw_master_runtime *m_rt,
struct sdw_transport_data *t_data)
{
struct sdw_slave_runtime *s_rt = NULL;
struct sdw_port_runtime *p_rt;
int port_bo, sample_int;
unsigned int rate, bps, ch = 0;
unsigned int slave_total_ch;
struct sdw_bus_params *b_params = &m_rt->bus->params;
port_bo = t_data->block_offset;
list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) {
rate = m_rt->stream->params.rate;
bps = m_rt->stream->params.bps;
sample_int = (m_rt->bus->params.curr_dr_freq / rate);
slave_total_ch = 0;
list_for_each_entry(p_rt, &s_rt->port_list, port_node) {
if (p_rt->lane != t_data->lane)
continue;
ch = hweight32(p_rt->ch_mask);
sdw_fill_xport_params(&p_rt->transport_params,
p_rt->num, false,
SDW_BLK_GRP_CNT_1,
sample_int, port_bo, port_bo >> 8,
t_data->hstart,
t_data->hstop,
SDW_BLK_PKG_PER_PORT, p_rt->lane);
sdw_fill_port_params(&p_rt->port_params,
p_rt->num, bps,
SDW_PORT_FLOW_MODE_ISOCH,
b_params->s_data_mode);
port_bo += bps * ch;
slave_total_ch += ch;
}
if (m_rt->direction == SDW_DATA_DIR_TX &&
m_rt->ch_count == slave_total_ch) {
/*
* Slave devices were configured to access all channels
* of the stream, which indicates that they operate in
* 'mirror mode'. Make sure we reset the port offset for
* the next device in the list
*/
port_bo = t_data->block_offset;
}
}
}
EXPORT_SYMBOL(sdw_compute_slave_ports);
static void sdw_compute_dp0_slave_ports(struct sdw_master_runtime *m_rt)
{
struct sdw_bus *bus = m_rt->bus;
struct sdw_slave_runtime *s_rt;
struct sdw_port_runtime *p_rt;
list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) {
list_for_each_entry(p_rt, &s_rt->port_list, port_node) {
sdw_fill_xport_params(&p_rt->transport_params, p_rt->num, false,
SDW_BLK_GRP_CNT_1, bus->params.col, 0, 0, 1,
bus->params.col - 1, SDW_BLK_PKG_PER_PORT, 0x0);
sdw_fill_port_params(&p_rt->port_params, p_rt->num, bus->params.col - 1,
SDW_PORT_FLOW_MODE_ISOCH, SDW_PORT_DATA_MODE_NORMAL);
}
}
}
static void sdw_compute_dp0_master_ports(struct sdw_master_runtime *m_rt)
{
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/device.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/slab.h`, `linux/soundwire/sdw.h`, `bus.h`.
- Detected declarations: `struct sdw_group_params`, `struct sdw_group`, `function sdw_compute_slave_ports`, `function list_for_each_entry`, `function list_for_each_entry`, `function sdw_compute_dp0_slave_ports`, `function list_for_each_entry`, `function sdw_compute_dp0_master_ports`, `function list_for_each_entry`, `function sdw_compute_dp0_port_params`.
- Atlas domain: Driver Families / drivers/soundwire.
- 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.