drivers/media/platform/rockchip/rkvdec/rkvdec.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/rockchip/rkvdec/rkvdec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/rockchip/rkvdec/rkvdec.c- Extension
.c- Size
- 51289 bytes
- Lines
- 1917
- 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.
- 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/hw_bitfield.hlinux/clk.hlinux/genalloc.hlinux/interrupt.hlinux/iommu.hlinux/module.hlinux/of.hlinux/of_device.hlinux/platform_device.hlinux/pm.hlinux/pm_runtime.hlinux/slab.hlinux/videodev2.hlinux/workqueue.hmedia/v4l2-event.hmedia/v4l2-mem2mem.hmedia/videobuf2-core.hmedia/videobuf2-vmalloc.hrkvdec.hrkvdec-regs.hrkvdec-vdpu381-regs.hrkvdec-vdpu383-regs.hrkvdec-rcb.h
Detected Declarations
function Copyrightfunction rkvdec_image_fmt_changedfunction rkvdec_enum_decoded_fmtfunction rkvdec_is_valid_fmtfunction rkvdec_colmv_sizefunction vdpu383_colmv_sizefunction rkvdec_fill_decoded_pixfmtfunction rkvdec_reset_fmtfunction rkvdec_reset_decoded_fmtfunction rkvdec_try_ctrlfunction rkvdec_s_ctrlfunction rkvdec_enum_coded_fmt_descfunction rkvdec_find_coded_fmt_descfunction rkvdec_reset_coded_fmtfunction rkvdec_enum_framesizesfunction rkvdec_querycapfunction rkvdec_try_capture_fmtfunction rkvdec_try_output_fmtfunction rkvdec_s_capture_fmtfunction rkvdec_s_output_fmtfunction rkvdec_g_output_fmtfunction rkvdec_g_capture_fmtfunction rkvdec_enum_output_fmtfunction rkvdec_enum_capture_fmtfunction rkvdec_queue_setupfunction rkvdec_buf_preparefunction rkvdec_buf_queuefunction rkvdec_buf_out_validatefunction rkvdec_buf_request_completefunction rkvdec_start_streamingfunction rkvdec_queue_cleanupfunction rkvdec_stop_streamingfunction rkvdec_request_validatefunction rkvdec_job_finish_no_pmfunction rkvdec_job_finishfunction rkvdec_run_preamblefunction rkvdec_run_postamblefunction rkvdec_quirks_disable_qosfunction rkvdec_memcpy_toiofunction rkvdec_schedule_watchdogfunction rkvdec_device_runfunction rkvdec_queue_initfunction rkvdec_add_ctrlsfunction rkvdec_init_ctrlsfunction rkvdec_openfunction rkvdec_releasefunction rkvdec_v4l2_initfunction rkvdec_v4l2_cleanup
Annotated Snippet
if ((j + 1) % row_length == 0) {
row += 1;
x_offset += 1;
}
}
}
}
/*
* VDPU383 needs a specific order:
* The 8x8 flatten matrix is based on 4x4 blocks.
* Each 4x4 block is written separately in order.
*
* Base data => Transposed VDPU383 transposed
*
* ABCDEFGH AIQYaiqy AIQYBJRZ
* IJKLMNOP BJRZbjrz CKS0DLT1
* QRSTUVWX CKS0cks6 aiqybjrz
* YZ012345 => DLT1dlt7 cks6dlt7
* abcdefgh EMU2emu8 EMU2FNV3
* ijklmnop FNV3fnv9 GOW4HPX5
* qrstuvwx GOW4gow# emu8fnv9
* yz6789#$ HPX5hpx$ gow#hpx$
*
* As the function reads block of 4x4 it can be used for both 4x4 and 8x8 matrices.
*
*/
static void vdpu383_flatten_matrices(u8 *output, const u8 *input, int matrices, int row_length)
{
u8 block;
int i, j, matrix_offset, matrix_size, new_value, input_idx, line_offset, block_offset;
matrix_size = row_length * row_length;
for (i = 0; i < matrices; i++) {
matrix_offset = i * matrix_size;
for (j = 0; j < matrix_size; j++) {
block = j / 16;
line_offset = (j % 16) / 4;
block_offset = (block & 1) * 32 + (block & 2) * 2;
input_idx = ((j % 4) * row_length) + line_offset + block_offset;
new_value = *(input + i * matrix_size + input_idx);
output[matrix_offset + j] = new_value;
}
}
}
static void rkvdec_watchdog_func(struct work_struct *work)
{
struct rkvdec_dev *rkvdec;
struct rkvdec_ctx *ctx;
rkvdec = container_of(to_delayed_work(work), struct rkvdec_dev,
watchdog_work);
ctx = v4l2_m2m_get_curr_priv(rkvdec->m2m_dev);
if (ctx) {
dev_err(rkvdec->dev, "Frame processing timed out!\n");
writel(RKVDEC_IRQ_DIS, rkvdec->regs + RKVDEC_REG_INTERRUPT);
rkvdec_job_finish(ctx, VB2_BUF_STATE_ERROR);
}
}
/*
* Some SoCs, like RK3588 have multiple identical VDPU cores, but the
* kernel is currently missing support for multi-core handling. Exposing
* separate devices for each core to userspace is bad, since that does
* not allow scheduling tasks properly (and creates ABI). With this workaround
* the driver will only probe for the first core and early exit for the other
* cores. Once the driver gains multi-core support, the same technique
* for detecting the first core can be used to cluster all cores together.
*/
static int rkvdec_disable_multicore(struct rkvdec_dev *rkvdec)
{
struct device_node *node = NULL;
const char *compatible;
bool is_first_core;
int ret;
/* Intentionally ignores the fallback strings */
ret = of_property_read_string(rkvdec->dev->of_node, "compatible", &compatible);
if (ret)
return ret;
/* The first compatible and available node found is considered the main core */
do {
node = of_find_compatible_node(node, NULL, compatible);
if (of_device_is_available(node))
break;
} while (node);
Annotation
- Immediate include surface: `linux/hw_bitfield.h`, `linux/clk.h`, `linux/genalloc.h`, `linux/interrupt.h`, `linux/iommu.h`, `linux/module.h`, `linux/of.h`, `linux/of_device.h`.
- Detected declarations: `function Copyright`, `function rkvdec_image_fmt_changed`, `function rkvdec_enum_decoded_fmt`, `function rkvdec_is_valid_fmt`, `function rkvdec_colmv_size`, `function vdpu383_colmv_size`, `function rkvdec_fill_decoded_pixfmt`, `function rkvdec_reset_fmt`, `function rkvdec_reset_decoded_fmt`, `function rkvdec_try_ctrl`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- 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.