drivers/media/platform/qcom/venus/hfi_venus.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/qcom/venus/hfi_venus.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/qcom/venus/hfi_venus.c- Extension
.c- Size
- 41870 bytes
- Lines
- 1779
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/delay.hlinux/device.hlinux/dma-mapping.hlinux/interrupt.hlinux/iopoll.hlinux/kernel.hlinux/slab.hcore.hhfi_cmds.hhfi_msgs.hhfi_venus.hhfi_venus_io.hfirmware.h
Detected Declarations
struct hfi_queue_table_headerstruct hfi_queue_headerstruct mem_descstruct iface_queuestruct venus_hfi_deviceenum venus_statefunction venus_set_statefunction venus_is_valid_statefunction venus_dump_packetfunction venus_write_queuefunction venus_read_queuefunction venus_allocfunction venus_freefunction venus_set_registersfunction venus_soft_intfunction venus_iface_cmdq_write_nolockfunction venus_iface_cmdq_writefunction venus_hfi_core_set_resourcefunction venus_boot_corefunction venus_hwversionfunction venus_runfunction venus_halt_axifunction venus_power_offfunction venus_power_onfunction venus_iface_msgq_read_nolockfunction venus_iface_msgq_readfunction venus_iface_dbgq_read_nolockfunction venus_iface_dbgq_readfunction venus_set_qhdr_defaultsfunction venus_interface_queues_releasefunction venus_interface_queues_initfunction venus_sys_set_debugfunction venus_sys_set_coveragefunction venus_sys_set_idle_messagefunction venus_sys_set_power_controlfunction venus_sys_set_ubwc_configfunction venus_get_queue_sizefunction venus_sys_set_default_propertiesfunction venus_session_cmdfunction venus_flush_debug_queuefunction venus_prepare_power_collapsefunction venus_are_queues_emptyfunction venus_sfr_printfunction venus_process_msg_sys_errorfunction venus_isr_threadfunction venus_isrfunction venus_core_initfunction venus_core_deinit
Annotated Snippet
struct hfi_queue_table_header {
u32 version;
u32 size;
u32 qhdr0_offset;
u32 qhdr_size;
u32 num_q;
u32 num_active_q;
};
struct hfi_queue_header {
u32 status;
u32 start_addr;
u32 type;
u32 q_size;
u32 pkt_size;
u32 pkt_drop_cnt;
u32 rx_wm;
u32 tx_wm;
u32 rx_req;
u32 tx_req;
u32 rx_irq_status;
u32 tx_irq_status;
u32 read_idx;
u32 write_idx;
};
#define IFACEQ_TABLE_SIZE \
(sizeof(struct hfi_queue_table_header) + \
sizeof(struct hfi_queue_header) * IFACEQ_NUM)
#define IFACEQ_QUEUE_SIZE (IFACEQ_MAX_PKT_SIZE * \
IFACEQ_MAX_BUF_COUNT * IFACEQ_MAX_PARALLEL_CLNTS)
#define IFACEQ_GET_QHDR_START_ADDR(ptr, i) \
(void *)(((ptr) + sizeof(struct hfi_queue_table_header)) + \
((i) * sizeof(struct hfi_queue_header)))
#define QDSS_SIZE SZ_4K
#define SFR_SIZE SZ_4K
#define QUEUE_SIZE \
(IFACEQ_TABLE_SIZE + (IFACEQ_QUEUE_SIZE * IFACEQ_NUM))
#define ALIGNED_QDSS_SIZE ALIGN(QDSS_SIZE, SZ_4K)
#define ALIGNED_SFR_SIZE ALIGN(SFR_SIZE, SZ_4K)
#define ALIGNED_QUEUE_SIZE ALIGN(QUEUE_SIZE, SZ_4K)
#define SHARED_QSIZE ALIGN(ALIGNED_SFR_SIZE + ALIGNED_QUEUE_SIZE + \
ALIGNED_QDSS_SIZE, SZ_1M)
struct mem_desc {
dma_addr_t da; /* device address */
void *kva; /* kernel virtual address */
u32 size;
unsigned long attrs;
};
struct iface_queue {
struct hfi_queue_header *qhdr;
struct mem_desc qmem;
};
enum venus_state {
VENUS_STATE_DEINIT = 1,
VENUS_STATE_INIT,
};
struct venus_hfi_device {
struct venus_core *core;
u32 irq_status;
u32 last_packet_type;
bool power_enabled;
bool suspended;
enum venus_state state;
/* serialize read / write to the shared memory */
struct mutex lock;
struct completion pwr_collapse_prep;
struct completion release_resource;
struct mem_desc ifaceq_table;
struct mem_desc sfr;
struct iface_queue queues[IFACEQ_NUM];
u8 pkt_buf[IFACEQ_VAR_HUGE_PKT_SIZE];
u8 dbg_buf[IFACEQ_VAR_HUGE_PKT_SIZE];
};
static bool venus_pkt_debug;
int venus_fw_debug = HFI_DEBUG_MSG_ERROR | HFI_DEBUG_MSG_FATAL;
static bool venus_fw_low_power_mode = true;
static int venus_hw_rsp_timeout = 1000;
static bool venus_fw_coverage;
static void venus_set_state(struct venus_hfi_device *hdev,
Annotation
- Immediate include surface: `linux/delay.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/iopoll.h`, `linux/kernel.h`, `linux/slab.h`, `core.h`.
- Detected declarations: `struct hfi_queue_table_header`, `struct hfi_queue_header`, `struct mem_desc`, `struct iface_queue`, `struct venus_hfi_device`, `enum venus_state`, `function venus_set_state`, `function venus_is_valid_state`, `function venus_dump_packet`, `function venus_write_queue`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.