drivers/media/pci/hws/hws_video.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/hws/hws_video.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/hws/hws_video.c- Extension
.c- Size
- 42250 bytes
- Lines
- 1491
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pci.hlinux/errno.hlinux/kernel.hlinux/compiler.hlinux/overflow.hlinux/delay.hlinux/bits.hlinux/jiffies.hlinux/ktime.hlinux/math64.hlinux/interrupt.hlinux/moduleparam.hmedia/v4l2-ioctl.hmedia/v4l2-ctrls.hmedia/v4l2-dev.hmedia/v4l2-event.hmedia/videobuf2-v4l2.hmedia/v4l2-device.hmedia/videobuf2-dma-contig.hhws.hhws_reg.hhws_video.hhws_irq.hhws_v4l2_ioctl.h
Detected Declarations
function hws_elapsed_usfunction list_node_unlinkedfunction hws_set_dma_doorbellfunction hws_program_dma_windowfunction hws_take_queued_buffer_lockedfunction hws_prime_next_lockedfunction hws_force_no_signal_framefunction hws_ctrls_initfunction hws_video_init_channelfunction hws_video_drain_queue_lockedfunction hws_video_release_registrationfunction hws_video_collect_done_lockedfunction hws_video_cleanup_channelfunction hws_buf_initfunction hws_buf_finishfunction hws_buf_cleanupfunction hws_program_dma_for_addrfunction hws_enable_video_capturefunction hws_seed_dma_windowsfunction hws_ack_all_irqsfunction hws_open_irq_fabricfunction hws_init_video_sysfunction hws_check_card_statusfunction check_video_formatfunction hws_write_if_difffunction hws_read_active_statefunction handle_hwv2_pathfunction handle_legacy_pathfunction hws_video_apply_mode_changefunction list_for_each_entry_safefunction update_live_resolutionfunction hws_openfunction hws_subscribe_eventfunction hws_calc_sizeimagefunction hws_queue_setupfunction hws_buffer_preparefunction hws_buffer_queuefunction hws_start_streamingfunction list_for_each_entry_safefunction hws_log_video_statefunction hws_stop_streamingfunction hws_video_registerfunction hws_video_unregisterfunction hws_video_quiescefunction hws_video_pm_resume
Annotated Snippet
if (err) {
dev_err(&pdev->pdev->dev,
"v4l2 ctrl init failed on ch%d: %d\n", ch, err);
return err;
}
}
return 0;
}
static void hws_video_drain_queue_locked(struct hws_video *vid)
{
/* Return in-flight first */
if (vid->active) {
vb2_buffer_done(&vid->active->vb.vb2_buf, VB2_BUF_STATE_ERROR);
vid->active = NULL;
}
/* Then everything queued */
while (!list_empty(&vid->capture_queue)) {
struct hwsvideo_buffer *b =
list_first_entry(&vid->capture_queue,
struct hwsvideo_buffer,
list);
list_del_init(&b->list);
vb2_buffer_done(&b->vb.vb2_buf, VB2_BUF_STATE_ERROR);
}
}
static void hws_video_release_registration(struct hws_video *vid)
{
if (vid->buffer_queue.ops) {
vb2_queue_release(&vid->buffer_queue);
vid->buffer_queue.ops = NULL;
}
if (!vid->video_device)
return;
if (video_is_registered(vid->video_device))
vb2_video_unregister_device(vid->video_device);
else
video_device_release(vid->video_device);
vid->video_device = NULL;
}
static void hws_video_collect_done_locked(struct hws_video *vid,
struct list_head *done)
{
struct hwsvideo_buffer *b;
if (vid->active) {
if (!list_node_unlinked(&vid->active->list)) {
list_move_tail(&vid->active->list, done);
} else {
INIT_LIST_HEAD(&vid->active->list);
list_add_tail(&vid->active->list, done);
}
vid->active = NULL;
}
if (vid->next_prepared) {
if (!list_node_unlinked(&vid->next_prepared->list)) {
list_move_tail(&vid->next_prepared->list, done);
} else {
INIT_LIST_HEAD(&vid->next_prepared->list);
list_add_tail(&vid->next_prepared->list, done);
}
vid->next_prepared = NULL;
}
while (!list_empty(&vid->capture_queue)) {
b = list_first_entry(&vid->capture_queue, struct hwsvideo_buffer,
list);
list_move_tail(&b->list, done);
}
vid->queued_count = 0;
}
void hws_video_cleanup_channel(struct hws_pcie_dev *pdev, int ch)
{
struct hws_video *vid;
unsigned long flags;
if (!pdev || ch < 0 || ch >= pdev->max_channels)
return;
vid = &pdev->video[ch];
Annotation
- Immediate include surface: `linux/pci.h`, `linux/errno.h`, `linux/kernel.h`, `linux/compiler.h`, `linux/overflow.h`, `linux/delay.h`, `linux/bits.h`, `linux/jiffies.h`.
- Detected declarations: `function hws_elapsed_us`, `function list_node_unlinked`, `function hws_set_dma_doorbell`, `function hws_program_dma_window`, `function hws_take_queued_buffer_locked`, `function hws_prime_next_locked`, `function hws_force_no_signal_frame`, `function hws_ctrls_init`, `function hws_video_init_channel`, `function hws_video_drain_queue_locked`.
- 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.