drivers/media/platform/qcom/venus/hfi.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/qcom/venus/hfi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/qcom/venus/hfi.c- Extension
.c- Size
- 10687 bytes
- Lines
- 570
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/slab.hlinux/mutex.hlinux/list.hlinux/completion.hlinux/platform_device.hlinux/videodev2.hcore.hhfi.hhfi_cmds.hhfi_venus.h
Detected Declarations
function Copyrightfunction hfi_core_initfunction hfi_core_deinitfunction hfi_core_suspendfunction hfi_core_resumefunction hfi_core_trigger_ssrfunction wait_session_msgfunction hfi_session_createfunction hfi_session_initfunction hfi_session_destroyfunction hfi_session_deinitfunction hfi_session_startfunction hfi_session_stopfunction hfi_session_continuefunction hfi_session_abortfunction hfi_session_load_resfunction hfi_session_unload_resfunction hfi_session_flushfunction hfi_session_set_buffersfunction hfi_session_unset_buffersfunction hfi_session_get_propertyfunction hfi_session_set_propertyfunction hfi_session_process_buffunction hfi_isr_threadfunction hfi_isrfunction hfi_createfunction hfi_destroyfunction hfi_reinitexport hfi_session_createexport hfi_session_initexport hfi_session_destroyexport hfi_session_deinitexport hfi_session_startexport hfi_session_stopexport hfi_session_continueexport hfi_session_abortexport hfi_session_unload_resexport hfi_session_flushexport hfi_session_get_propertyexport hfi_session_set_propertyexport hfi_session_process_buf
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
* Copyright (C) 2017 Linaro Ltd.
*/
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/list.h>
#include <linux/completion.h>
#include <linux/platform_device.h>
#include <linux/videodev2.h>
#include "core.h"
#include "hfi.h"
#include "hfi_cmds.h"
#include "hfi_venus.h"
#define TIMEOUT msecs_to_jiffies(1000)
static u32 to_codec_type(u32 pixfmt)
{
switch (pixfmt) {
case V4L2_PIX_FMT_H264:
case V4L2_PIX_FMT_H264_NO_SC:
return HFI_VIDEO_CODEC_H264;
case V4L2_PIX_FMT_H263:
return HFI_VIDEO_CODEC_H263;
case V4L2_PIX_FMT_MPEG1:
return HFI_VIDEO_CODEC_MPEG1;
case V4L2_PIX_FMT_MPEG2:
return HFI_VIDEO_CODEC_MPEG2;
case V4L2_PIX_FMT_MPEG4:
return HFI_VIDEO_CODEC_MPEG4;
case V4L2_PIX_FMT_VC1_ANNEX_G:
case V4L2_PIX_FMT_VC1_ANNEX_L:
return HFI_VIDEO_CODEC_VC1;
case V4L2_PIX_FMT_VP8:
return HFI_VIDEO_CODEC_VP8;
case V4L2_PIX_FMT_VP9:
return HFI_VIDEO_CODEC_VP9;
case V4L2_PIX_FMT_XVID:
return HFI_VIDEO_CODEC_DIVX;
case V4L2_PIX_FMT_HEVC:
return HFI_VIDEO_CODEC_HEVC;
default:
return 0;
}
}
int hfi_core_init(struct venus_core *core)
{
int ret = 0;
mutex_lock(&core->lock);
if (core->state >= CORE_INIT)
goto unlock;
reinit_completion(&core->done);
ret = core->ops->core_init(core);
if (ret)
goto unlock;
ret = wait_for_completion_timeout(&core->done, TIMEOUT);
if (!ret) {
ret = -ETIMEDOUT;
goto unlock;
}
ret = 0;
if (core->error != HFI_ERR_NONE) {
ret = -EIO;
goto unlock;
}
core->state = CORE_INIT;
unlock:
mutex_unlock(&core->lock);
return ret;
}
int hfi_core_deinit(struct venus_core *core, bool blocking)
{
int ret = 0, empty;
mutex_lock(&core->lock);
if (core->state == CORE_UNINIT)
Annotation
- Immediate include surface: `linux/slab.h`, `linux/mutex.h`, `linux/list.h`, `linux/completion.h`, `linux/platform_device.h`, `linux/videodev2.h`, `core.h`, `hfi.h`.
- Detected declarations: `function Copyright`, `function hfi_core_init`, `function hfi_core_deinit`, `function hfi_core_suspend`, `function hfi_core_resume`, `function hfi_core_trigger_ssr`, `function wait_session_msg`, `function hfi_session_create`, `function hfi_session_init`, `function hfi_session_destroy`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.