sound/firewire/dice/dice-stream.c
Source file repositories/reference/linux-study-clean/sound/firewire/dice/dice-stream.c
File Facts
- System
- Linux kernel
- Corpus path
sound/firewire/dice/dice-stream.c- Extension
.c- Size
- 17313 bytes
- Lines
- 700
- Domain
- Driver Families
- Bucket
- sound/firewire
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
dice.h
Detected Declarations
struct reg_paramsfunction snd_dice_stream_get_rate_modefunction select_clockfunction get_register_paramsfunction release_resourcesfunction stop_streamsfunction keep_resourcesfunction keep_dual_resourcesfunction finish_sessionfunction snd_dice_stream_reserve_duplexfunction start_streamsfunction snd_dice_stream_start_duplexfunction snd_dice_stream_stop_duplexfunction init_streamfunction destroy_streamfunction snd_dice_stream_init_duplexfunction snd_dice_stream_destroy_duplexfunction snd_dice_stream_update_duplexfunction snd_dice_stream_detect_current_formatsfunction dice_lock_changedfunction snd_dice_stream_lock_tryfunction snd_dice_stream_lock_release
Annotated Snippet
struct reg_params {
unsigned int count;
unsigned int size;
};
const unsigned int snd_dice_rates[SND_DICE_RATES_COUNT] = {
/* mode 0 */
[0] = 32000,
[1] = 44100,
[2] = 48000,
/* mode 1 */
[3] = 88200,
[4] = 96000,
/* mode 2 */
[5] = 176400,
[6] = 192000,
};
int snd_dice_stream_get_rate_mode(struct snd_dice *dice, unsigned int rate,
enum snd_dice_rate_mode *mode)
{
/* Corresponding to each entry in snd_dice_rates. */
static const enum snd_dice_rate_mode modes[] = {
[0] = SND_DICE_RATE_MODE_LOW,
[1] = SND_DICE_RATE_MODE_LOW,
[2] = SND_DICE_RATE_MODE_LOW,
[3] = SND_DICE_RATE_MODE_MIDDLE,
[4] = SND_DICE_RATE_MODE_MIDDLE,
[5] = SND_DICE_RATE_MODE_HIGH,
[6] = SND_DICE_RATE_MODE_HIGH,
};
int i;
for (i = 0; i < ARRAY_SIZE(snd_dice_rates); i++) {
if (!(dice->clock_caps & BIT(i)))
continue;
if (snd_dice_rates[i] != rate)
continue;
*mode = modes[i];
return 0;
}
return -EINVAL;
}
static int select_clock(struct snd_dice *dice, unsigned int rate)
{
__be32 reg, new;
u32 data;
int i;
int err;
err = snd_dice_transaction_read_global(dice, GLOBAL_CLOCK_SELECT,
®, sizeof(reg));
if (err < 0)
return err;
data = be32_to_cpu(reg);
data &= ~CLOCK_RATE_MASK;
for (i = 0; i < ARRAY_SIZE(snd_dice_rates); ++i) {
if (snd_dice_rates[i] == rate)
break;
}
if (i == ARRAY_SIZE(snd_dice_rates))
return -EINVAL;
data |= i << CLOCK_RATE_SHIFT;
if (completion_done(&dice->clock_accepted))
reinit_completion(&dice->clock_accepted);
new = cpu_to_be32(data);
err = snd_dice_transaction_write_global(dice, GLOBAL_CLOCK_SELECT,
&new, sizeof(new));
if (err < 0)
return err;
if (wait_for_completion_timeout(&dice->clock_accepted,
msecs_to_jiffies(NOTIFICATION_TIMEOUT_MS)) == 0) {
if (reg != new)
return -ETIMEDOUT;
}
return 0;
}
static int get_register_params(struct snd_dice *dice,
struct reg_params *tx_params,
struct reg_params *rx_params)
Annotation
- Immediate include surface: `dice.h`.
- Detected declarations: `struct reg_params`, `function snd_dice_stream_get_rate_mode`, `function select_clock`, `function get_register_params`, `function release_resources`, `function stop_streams`, `function keep_resources`, `function keep_dual_resources`, `function finish_session`, `function snd_dice_stream_reserve_duplex`.
- Atlas domain: Driver Families / sound/firewire.
- 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.