drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/rockchip/rkvdec/rkvdec-h264.c- Extension
.c- Size
- 15442 bytes
- Lines
- 445
- 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
media/v4l2-h264.hmedia/v4l2-mem2mem.hrkvdec.hrkvdec-regs.hrkvdec-cabac.hrkvdec-h264-common.hrkvdec-bitwriter.h
Detected Declarations
struct rkvdec_sps_pps_packetstruct rkvdec_h264_priv_tblstruct rkvdec_h264_ctxfunction assemble_hw_ppsfunction set_poc_regfunction config_registersfunction rkvdec_h264_startfunction rkvdec_h264_stopfunction rkvdec_h264_runfunction rkvdec_h264_try_ctrl
Annotated Snippet
struct rkvdec_sps_pps_packet {
u32 info[8];
};
#define SEQ_PARAMETER_SET_ID BW_FIELD(0, 4)
#define PROFILE_IDC BW_FIELD(4, 8)
#define CONSTRAINT_SET3_FLAG BW_FIELD(12, 1)
#define CHROMA_FORMAT_IDC BW_FIELD(13, 2)
#define BIT_DEPTH_LUMA BW_FIELD(15, 3)
#define BIT_DEPTH_CHROMA BW_FIELD(18, 3)
#define QPPRIME_Y_ZERO_TRANSFORM_BYPASS_FLAG BW_FIELD(21, 1)
#define LOG2_MAX_FRAME_NUM_MINUS4 BW_FIELD(22, 4)
#define MAX_NUM_REF_FRAMES BW_FIELD(26, 5)
#define PIC_ORDER_CNT_TYPE BW_FIELD(31, 2)
#define LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4 BW_FIELD(33, 4)
#define DELTA_PIC_ORDER_ALWAYS_ZERO_FLAG BW_FIELD(37, 1)
#define PIC_WIDTH_IN_MBS BW_FIELD(38, 9)
#define PIC_HEIGHT_IN_MBS BW_FIELD(47, 9)
#define FRAME_MBS_ONLY_FLAG BW_FIELD(56, 1)
#define MB_ADAPTIVE_FRAME_FIELD_FLAG BW_FIELD(57, 1)
#define DIRECT_8X8_INFERENCE_FLAG BW_FIELD(58, 1)
#define MVC_EXTENSION_ENABLE BW_FIELD(59, 1)
#define NUM_VIEWS BW_FIELD(60, 2)
#define VIEW_ID(i) BW_FIELD(62 + ((i) * 10), 10)
#define NUM_ANCHOR_REFS_L(i) BW_FIELD(82 + ((i) * 11), 1)
#define ANCHOR_REF_L(i) BW_FIELD(83 + ((i) * 11), 10)
#define NUM_NON_ANCHOR_REFS_L(i) BW_FIELD(104 + ((i) * 11), 1)
#define NON_ANCHOR_REFS_L(i) BW_FIELD(105 + ((i) * 11), 10)
#define PIC_PARAMETER_SET_ID BW_FIELD(128, 8)
#define PPS_SEQ_PARAMETER_SET_ID BW_FIELD(136, 5)
#define ENTROPY_CODING_MODE_FLAG BW_FIELD(141, 1)
#define BOTTOM_FIELD_PIC_ORDER_IN_FRAME_PRESENT_FLAG BW_FIELD(142, 1)
#define NUM_REF_IDX_L_DEFAULT_ACTIVE_MINUS1(i) BW_FIELD(143 + ((i) * 5), 5)
#define WEIGHTED_PRED_FLAG BW_FIELD(153, 1)
#define WEIGHTED_BIPRED_IDC BW_FIELD(154, 2)
#define PIC_INIT_QP_MINUS26 BW_FIELD(156, 7)
#define PIC_INIT_QS_MINUS26 BW_FIELD(163, 6)
#define CHROMA_QP_INDEX_OFFSET BW_FIELD(169, 5)
#define DEBLOCKING_FILTER_CONTROL_PRESENT_FLAG BW_FIELD(174, 1)
#define CONSTRAINED_INTRA_PRED_FLAG BW_FIELD(175, 1)
#define REDUNDANT_PIC_CNT_PRESENT BW_FIELD(176, 1)
#define TRANSFORM_8X8_MODE_FLAG BW_FIELD(177, 1)
#define SECOND_CHROMA_QP_INDEX_OFFSET BW_FIELD(178, 5)
#define SCALING_LIST_ENABLE_FLAG BW_FIELD(183, 1)
#define SCALING_LIST_ADDRESS BW_FIELD(184, 32)
#define IS_LONG_TERM(i) BW_FIELD(216 + (i), 1)
/* Data structure describing auxiliary buffer format. */
struct rkvdec_h264_priv_tbl {
s8 cabac_table[4][464][2];
struct rkvdec_h264_scaling_list scaling_list;
struct rkvdec_rps rps;
struct rkvdec_sps_pps_packet param_set[256];
u8 err_info[RKV_ERROR_INFO_SIZE];
};
struct rkvdec_h264_ctx {
struct rkvdec_aux_buf priv_tbl;
struct rkvdec_h264_reflists reflists;
struct rkvdec_regs regs;
};
static void assemble_hw_pps(struct rkvdec_ctx *ctx,
struct rkvdec_h264_run *run)
{
struct rkvdec_h264_ctx *h264_ctx = ctx->priv;
const struct v4l2_ctrl_h264_sps *sps = run->sps;
const struct v4l2_ctrl_h264_pps *pps = run->pps;
const struct v4l2_ctrl_h264_decode_params *dec_params = run->decode_params;
const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb;
struct rkvdec_h264_priv_tbl *priv_tbl = h264_ctx->priv_tbl.cpu;
struct rkvdec_sps_pps_packet *hw_ps;
dma_addr_t scaling_list_address;
u32 scaling_distance;
u32 i;
/*
* HW read the SPS/PPS information from PPS packet index by PPS id.
* offset from the base can be calculated by PPS_id * 32 (size per PPS
* packet unit). so the driver copy SPS/PPS information to the exact PPS
* packet unit for HW accessing.
*/
hw_ps = &priv_tbl->param_set[pps->pic_parameter_set_id];
memset(hw_ps, 0, sizeof(*hw_ps));
#define WRITE_PPS(value, field) rkvdec_set_bw_field(hw_ps->info, field, value)
/* write sps */
WRITE_PPS(sps->seq_parameter_set_id, SEQ_PARAMETER_SET_ID);
WRITE_PPS(sps->profile_idc, PROFILE_IDC);
WRITE_PPS(!!(sps->constraint_set_flags & (1 << 3)), CONSTRAINT_SET3_FLAG);
Annotation
- Immediate include surface: `media/v4l2-h264.h`, `media/v4l2-mem2mem.h`, `rkvdec.h`, `rkvdec-regs.h`, `rkvdec-cabac.h`, `rkvdec-h264-common.h`, `rkvdec-bitwriter.h`.
- Detected declarations: `struct rkvdec_sps_pps_packet`, `struct rkvdec_h264_priv_tbl`, `struct rkvdec_h264_ctx`, `function assemble_hw_pps`, `function set_poc_reg`, `function config_registers`, `function rkvdec_h264_start`, `function rkvdec_h264_stop`, `function rkvdec_h264_run`, `function rkvdec_h264_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.