drivers/media/usb/pvrusb2/pvrusb2-io.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/pvrusb2/pvrusb2-io.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/pvrusb2/pvrusb2-io.c- Extension
.c- Size
- 17826 bytes
- Lines
- 673
- Domain
- Driver Families
- Bucket
- drivers/media
- 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
pvrusb2-io.hpvrusb2-debug.hlinux/errno.hlinux/string.hlinux/slab.hlinux/mutex.h
Detected Declarations
struct pvr2_streamstruct pvr2_bufferfunction pvr2_buffer_describefunction pvr2_buffer_removefunction pvr2_buffer_set_nonefunction pvr2_buffer_set_readyfunction pvr2_buffer_set_idlefunction pvr2_buffer_set_queuedfunction pvr2_buffer_wipefunction pvr2_buffer_initfunction pvr2_buffer_donefunction pvr2_stream_buffer_countfunction pvr2_stream_achieve_buffer_countfunction pvr2_stream_internal_flushfunction pvr2_stream_initfunction pvr2_stream_donefunction buffer_completefunction pvr2_stream_destroyfunction pvr2_stream_setupfunction pvr2_stream_set_callbackfunction pvr2_stream_get_statsfunction pvr2_stream_get_buffer_countfunction pvr2_stream_set_buffer_countfunction pvr2_stream_get_ready_countfunction pvr2_stream_killfunction pvr2_buffer_queuefunction pvr2_buffer_set_bufferfunction pvr2_buffer_get_countfunction pvr2_buffer_get_statusfunction pvr2_buffer_get_id
Annotated Snippet
struct pvr2_stream {
/* Buffers queued for reading */
struct list_head queued_list;
unsigned int q_count;
unsigned int q_bcount;
/* Buffers with retrieved data */
struct list_head ready_list;
unsigned int r_count;
unsigned int r_bcount;
/* Buffers available for use */
struct list_head idle_list;
unsigned int i_count;
unsigned int i_bcount;
/* Pointers to all buffers */
struct pvr2_buffer **buffers;
/* Array size of buffers */
unsigned int buffer_slot_count;
/* Total buffers actually in circulation */
unsigned int buffer_total_count;
/* Designed number of buffers to be in circulation */
unsigned int buffer_target_count;
/* Executed when ready list become non-empty */
pvr2_stream_callback callback_func;
void *callback_data;
/* Context for transfer endpoint */
struct usb_device *dev;
int endpoint;
/* Overhead for mutex enforcement */
spinlock_t list_lock;
struct mutex mutex;
/* Tracking state for tolerating errors */
unsigned int fail_count;
unsigned int fail_tolerance;
unsigned int buffers_processed;
unsigned int buffers_failed;
unsigned int bytes_processed;
};
struct pvr2_buffer {
int id;
int signature;
enum pvr2_buffer_state state;
void *ptr; /* Pointer to storage area */
unsigned int max_count; /* Size of storage area */
unsigned int used_count; /* Amount of valid data in storage area */
int status; /* Transfer result status */
struct pvr2_stream *stream;
struct list_head list_overhead;
struct urb *purb;
};
static const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st)
{
switch (st) {
case pvr2_buffer_state_none: return "none";
case pvr2_buffer_state_idle: return "idle";
case pvr2_buffer_state_queued: return "queued";
case pvr2_buffer_state_ready: return "ready";
}
return "unknown";
}
#ifdef SANITY_CHECK_BUFFERS
static void pvr2_buffer_describe(struct pvr2_buffer *bp, const char *msg)
{
pvr2_trace(PVR2_TRACE_INFO,
"buffer%s%s %p state=%s id=%d status=%d stream=%p purb=%p sig=0x%x",
(msg ? " " : ""),
(msg ? msg : ""),
bp,
(bp ? pvr2_buffer_state_decode(bp->state) : "(invalid)"),
(bp ? bp->id : 0),
(bp ? bp->status : 0),
(bp ? bp->stream : NULL),
(bp ? bp->purb : NULL),
(bp ? bp->signature : 0));
}
#endif /* SANITY_CHECK_BUFFERS */
static void pvr2_buffer_remove(struct pvr2_buffer *bp)
{
unsigned int *cnt;
unsigned int *bcnt;
unsigned int ccnt;
struct pvr2_stream *sp = bp->stream;
switch (bp->state) {
case pvr2_buffer_state_idle:
cnt = &sp->i_count;
bcnt = &sp->i_bcount;
Annotation
- Immediate include surface: `pvrusb2-io.h`, `pvrusb2-debug.h`, `linux/errno.h`, `linux/string.h`, `linux/slab.h`, `linux/mutex.h`.
- Detected declarations: `struct pvr2_stream`, `struct pvr2_buffer`, `function pvr2_buffer_describe`, `function pvr2_buffer_remove`, `function pvr2_buffer_set_none`, `function pvr2_buffer_set_ready`, `function pvr2_buffer_set_idle`, `function pvr2_buffer_set_queued`, `function pvr2_buffer_wipe`, `function pvr2_buffer_init`.
- Atlas domain: Driver Families / drivers/media.
- 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.