drivers/media/usb/pvrusb2/pvrusb2-dvb.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/pvrusb2/pvrusb2-dvb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/pvrusb2/pvrusb2-dvb.c- Extension
.c- Size
- 11877 bytes
- Lines
- 471
- 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
linux/kthread.hlinux/freezer.hlinux/slab.hlinux/mm.hmedia/dvbdev.hpvrusb2-debug.hpvrusb2-hdw-internal.hpvrusb2-hdw.hpvrusb2-io.hpvrusb2-dvb.h
Detected Declarations
function pvr2_dvb_feed_funcfunction pvr2_dvb_feed_threadfunction pvr2_dvb_notifyfunction pvr2_dvb_stream_endfunction pvr2_dvb_stream_do_startfunction pvr2_dvb_stream_startfunction pvr2_dvb_ctrl_feedfunction pvr2_dvb_start_feedfunction pvr2_dvb_stop_feedfunction pvr2_dvb_bus_ctrlfunction pvr2_dvb_adapter_initfunction pvr2_dvb_adapter_exitfunction pvr2_dvb_frontend_initfunction pvr2_dvb_frontend_exitfunction pvr2_dvb_destroyfunction pvr2_dvb_internal_check
Annotated Snippet
if (bp != NULL) {
count = pvr2_buffer_get_count(bp);
if (count) {
dvb_dmx_swfilter(
&adap->demux,
adap->buffer_storage[
pvr2_buffer_get_id(bp)],
count);
} else {
ret = pvr2_buffer_get_status(bp);
if (ret < 0) break;
}
ret = pvr2_buffer_queue(bp);
if (ret < 0) break;
/* Since we know we did something to a buffer,
just go back and try again. No point in
blocking unless we really ran out of
buffers to process. */
continue;
}
/* Wait until more buffers become available or we're
told not to wait any longer. */
ret = wait_event_freezable(adap->buffer_wait_data,
(pvr2_stream_get_ready_count(stream) > 0) ||
kthread_should_stop());
if (ret < 0) break;
}
/* If we get here and ret is < 0, then an error has occurred.
Probably would be a good idea to communicate that to DVB core... */
pvr2_trace(PVR2_TRACE_DVB_FEED, "dvb feed thread stopped");
return 0;
}
static int pvr2_dvb_feed_thread(void *data)
{
int stat = pvr2_dvb_feed_func(data);
while (!kthread_should_stop()) {
set_current_state(TASK_INTERRUPTIBLE);
schedule();
}
return stat;
}
static void pvr2_dvb_notify(void *ptr)
{
struct pvr2_dvb_adapter *adap = ptr;
wake_up(&adap->buffer_wait_data);
}
static void pvr2_dvb_stream_end(struct pvr2_dvb_adapter *adap)
{
unsigned int idx;
struct pvr2_stream *stream;
if (adap->thread) {
kthread_stop(adap->thread);
adap->thread = NULL;
}
if (adap->channel.stream) {
stream = adap->channel.stream->stream;
} else {
stream = NULL;
}
if (stream) {
pvr2_hdw_set_streaming(adap->channel.hdw, 0);
pvr2_stream_set_callback(stream, NULL, NULL);
pvr2_stream_kill(stream);
pvr2_stream_set_buffer_count(stream, 0);
pvr2_channel_claim_stream(&adap->channel, NULL);
}
if (adap->stream_run) {
for (idx = 0; idx < PVR2_DVB_BUFFER_COUNT; idx++) {
if (!(adap->buffer_storage[idx])) continue;
kfree(adap->buffer_storage[idx]);
adap->buffer_storage[idx] = NULL;
}
adap->stream_run = 0;
}
}
Annotation
- Immediate include surface: `linux/kthread.h`, `linux/freezer.h`, `linux/slab.h`, `linux/mm.h`, `media/dvbdev.h`, `pvrusb2-debug.h`, `pvrusb2-hdw-internal.h`, `pvrusb2-hdw.h`.
- Detected declarations: `function pvr2_dvb_feed_func`, `function pvr2_dvb_feed_thread`, `function pvr2_dvb_notify`, `function pvr2_dvb_stream_end`, `function pvr2_dvb_stream_do_start`, `function pvr2_dvb_stream_start`, `function pvr2_dvb_ctrl_feed`, `function pvr2_dvb_start_feed`, `function pvr2_dvb_stop_feed`, `function pvr2_dvb_bus_ctrl`.
- 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.