drivers/media/usb/pvrusb2/pvrusb2-context.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/pvrusb2/pvrusb2-context.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/pvrusb2/pvrusb2-context.c- Extension
.c- Size
- 9629 bytes
- Lines
- 410
- 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-context.hpvrusb2-io.hpvrusb2-ioread.hpvrusb2-hdw.hpvrusb2-debug.hlinux/wait.hlinux/kthread.hlinux/errno.hlinux/string.hlinux/slab.h
Detected Declarations
function pvr2_context_set_notifyfunction pvr2_context_destroyfunction pvr2_context_notifyfunction pvr2_context_checkfunction pvr2_context_shutokfunction pvr2_context_thread_funcfunction pvr2_context_global_initfunction pvr2_context_global_donefunction pvr2_context_reset_input_limitsfunction pvr2_context_enterfunction pvr2_context_exitfunction pvr2_context_disconnectfunction pvr2_channel_initfunction pvr2_channel_disclaim_streamfunction pvr2_channel_donefunction pvr2_channel_limit_inputsfunction pvr2_channel_get_limited_inputsfunction pvr2_channel_claim_stream
Annotated Snippet
if (!mp->notify_flag) {
signal_flag = (pvr2_context_notify_first == NULL);
mp->notify_prev = pvr2_context_notify_last;
mp->notify_next = NULL;
pvr2_context_notify_last = mp;
if (mp->notify_prev) {
mp->notify_prev->notify_next = mp;
} else {
pvr2_context_notify_first = mp;
}
mp->notify_flag = !0;
}
} else {
if (mp->notify_flag) {
mp->notify_flag = 0;
if (mp->notify_next) {
mp->notify_next->notify_prev = mp->notify_prev;
} else {
pvr2_context_notify_last = mp->notify_prev;
}
if (mp->notify_prev) {
mp->notify_prev->notify_next = mp->notify_next;
} else {
pvr2_context_notify_first = mp->notify_next;
}
}
}
mutex_unlock(&pvr2_context_mutex);
if (signal_flag) wake_up(&pvr2_context_sync_data);
}
static void pvr2_context_destroy(struct pvr2_context *mp)
{
pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context %p (destroy)",mp);
pvr2_hdw_destroy(mp->hdw);
pvr2_context_set_notify(mp, 0);
mutex_lock(&pvr2_context_mutex);
if (mp->exist_next) {
mp->exist_next->exist_prev = mp->exist_prev;
} else {
pvr2_context_exist_last = mp->exist_prev;
}
if (mp->exist_prev) {
mp->exist_prev->exist_next = mp->exist_next;
} else {
pvr2_context_exist_first = mp->exist_next;
}
if (!pvr2_context_exist_first) {
/* Trigger wakeup on control thread in case it is waiting
for an exit condition. */
wake_up(&pvr2_context_sync_data);
}
mutex_unlock(&pvr2_context_mutex);
kfree(mp);
}
static void pvr2_context_notify(void *ptr)
{
struct pvr2_context *mp = ptr;
pvr2_context_set_notify(mp,!0);
}
static void pvr2_context_check(struct pvr2_context *mp)
{
struct pvr2_channel *ch1, *ch2;
pvr2_trace(PVR2_TRACE_CTXT,
"pvr2_context %p (notify)", mp);
if (!mp->initialized_flag && !mp->disconnect_flag) {
mp->initialized_flag = !0;
pvr2_trace(PVR2_TRACE_CTXT,
"pvr2_context %p (initialize)", mp);
/* Finish hardware initialization */
if (pvr2_hdw_initialize(mp->hdw, pvr2_context_notify, mp)) {
mp->video_stream.stream =
pvr2_hdw_get_video_stream(mp->hdw);
/* Trigger interface initialization. By doing this
here initialization runs in our own safe and
cozy thread context. */
if (mp->setup_func) mp->setup_func(mp);
} else {
pvr2_trace(PVR2_TRACE_CTXT,
"pvr2_context %p (thread skipping setup)",
mp);
/* Even though initialization did not succeed,
we're still going to continue anyway. We need
to do this in order to await the expected
Annotation
- Immediate include surface: `pvrusb2-context.h`, `pvrusb2-io.h`, `pvrusb2-ioread.h`, `pvrusb2-hdw.h`, `pvrusb2-debug.h`, `linux/wait.h`, `linux/kthread.h`, `linux/errno.h`.
- Detected declarations: `function pvr2_context_set_notify`, `function pvr2_context_destroy`, `function pvr2_context_notify`, `function pvr2_context_check`, `function pvr2_context_shutok`, `function pvr2_context_thread_func`, `function pvr2_context_global_init`, `function pvr2_context_global_done`, `function pvr2_context_reset_input_limits`, `function pvr2_context_enter`.
- 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.