sound/usb/hiface/pcm.c
Source file repositories/reference/linux-study-clean/sound/usb/hiface/pcm.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/hiface/pcm.c- Extension
.c- Size
- 14271 bytes
- Lines
- 595
- Domain
- Driver Families
- Bucket
- sound/usb
- 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.
- 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/slab.hsound/pcm.hpcm.hchip.h
Detected Declarations
struct pcm_urbstruct pcm_substreamstruct pcm_runtimefunction hiface_pcm_set_ratefunction hiface_pcm_stream_stopfunction hiface_pcm_stream_startfunction memcpy_swahw32function hiface_pcm_playbackfunction hiface_pcm_out_urb_handlerfunction hiface_pcm_openfunction hiface_pcm_closefunction hiface_pcm_preparefunction hiface_pcm_triggerfunction scoped_guardfunction hiface_pcm_pointerfunction hiface_pcm_init_urbfunction hiface_pcm_abortfunction hiface_pcm_destroyfunction hiface_pcm_freefunction hiface_pcm_init
Annotated Snippet
struct pcm_urb {
struct hiface_chip *chip;
struct urb instance;
struct usb_anchor submitted;
u8 *buffer;
};
struct pcm_substream {
spinlock_t lock;
struct snd_pcm_substream *instance;
bool active;
snd_pcm_uframes_t dma_off; /* current position in alsa dma_area */
snd_pcm_uframes_t period_off; /* current position in current period */
};
enum { /* pcm streaming states */
STREAM_DISABLED, /* no pcm streaming */
STREAM_STARTING, /* pcm streaming requested, waiting to become ready */
STREAM_RUNNING, /* pcm streaming running */
STREAM_STOPPING
};
struct pcm_runtime {
struct hiface_chip *chip;
struct snd_pcm *instance;
struct pcm_substream playback;
bool panic; /* if set driver won't do anymore pcm on device */
struct pcm_urb out_urbs[PCM_N_URBS];
struct mutex stream_mutex;
u8 stream_state; /* one of STREAM_XXX */
u8 extra_freq;
wait_queue_head_t stream_wait_queue;
bool stream_wait_cond;
};
static const unsigned int rates[] = { 44100, 48000, 88200, 96000, 176400, 192000,
352800, 384000 };
static const struct snd_pcm_hw_constraint_list constraints_extra_rates = {
.count = ARRAY_SIZE(rates),
.list = rates,
.mask = 0,
};
static const struct snd_pcm_hardware pcm_hw = {
.info = SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_BLOCK_TRANSFER |
SNDRV_PCM_INFO_PAUSE |
SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_BATCH,
.formats = SNDRV_PCM_FMTBIT_S32_LE,
.rates = SNDRV_PCM_RATE_44100 |
SNDRV_PCM_RATE_48000 |
SNDRV_PCM_RATE_88200 |
SNDRV_PCM_RATE_96000 |
SNDRV_PCM_RATE_176400 |
SNDRV_PCM_RATE_192000,
.rate_min = 44100,
.rate_max = 192000, /* changes in hiface_pcm_open to support extra rates */
.channels_min = 2,
.channels_max = 2,
.buffer_bytes_max = PCM_BUFFER_SIZE,
.period_bytes_min = PCM_PACKET_SIZE,
.period_bytes_max = PCM_BUFFER_SIZE,
.periods_min = 2,
.periods_max = 1024
};
/* message values used to change the sample rate */
#define HIFACE_SET_RATE_REQUEST 0xb0
#define HIFACE_RATE_44100 0x43
#define HIFACE_RATE_48000 0x4b
#define HIFACE_RATE_88200 0x42
#define HIFACE_RATE_96000 0x4a
#define HIFACE_RATE_176400 0x40
#define HIFACE_RATE_192000 0x48
#define HIFACE_RATE_352800 0x58
#define HIFACE_RATE_384000 0x68
static int hiface_pcm_set_rate(struct pcm_runtime *rt, unsigned int rate)
{
Annotation
- Immediate include surface: `linux/slab.h`, `sound/pcm.h`, `pcm.h`, `chip.h`.
- Detected declarations: `struct pcm_urb`, `struct pcm_substream`, `struct pcm_runtime`, `function hiface_pcm_set_rate`, `function hiface_pcm_stream_stop`, `function hiface_pcm_stream_start`, `function memcpy_swahw32`, `function hiface_pcm_playback`, `function hiface_pcm_out_urb_handler`, `function hiface_pcm_open`.
- Atlas domain: Driver Families / sound/usb.
- Implementation status: source 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.