diff options
author | Michael Grzeschik <m.grzeschik@pengutronix.de> | 2022-11-22 00:29:41 +0100 |
---|---|---|
committer | Michael Grzeschik <m.grzeschik@pengutronix.de> | 2023-02-22 15:43:46 +0100 |
commit | 4a5e1ee50e5bf062da091c44861aea390fd6dc28 (patch) | |
tree | 79b55e2b3e0eeb28b5d90aa3ce4308aaa2b2b958 | |
parent | 1b3f8cd8f77ddf55cbabb1394116a15d50775469 (diff) | |
download | linux-4a5e1ee50e5bf062da091c44861aea390fd6dc28.tar.gz |
rkvdec: rename to rkvpu
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
-rw-r--r-- | drivers/staging/media/rkvdec/Makefile | 4 | ||||
-rw-r--r-- | drivers/staging/media/rkvdec/rkvdec-h264.c | 100 | ||||
-rw-r--r-- | drivers/staging/media/rkvdec/rkvdec-vp9.c | 142 | ||||
-rw-r--r-- | drivers/staging/media/rkvdec/rkvpu.c (renamed from drivers/staging/media/rkvdec/rkvdec.c) | 510 | ||||
-rw-r--r-- | drivers/staging/media/rkvdec/rkvpu.h (renamed from drivers/staging/media/rkvdec/rkvdec.h) | 66 |
5 files changed, 411 insertions, 411 deletions
diff --git a/drivers/staging/media/rkvdec/Makefile b/drivers/staging/media/rkvdec/Makefile index cb86b429cfaac2..d09c3495b31aed 100644 --- a/drivers/staging/media/rkvdec/Makefile +++ b/drivers/staging/media/rkvdec/Makefile @@ -1,3 +1,3 @@ -obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC) += rockchip-vdec.o +obj-$(CONFIG_VIDEO_ROCKCHIP_VDEC) += rockchip-vpu.o -rockchip-vdec-y += rkvdec.o rkvdec-h264.o rkvdec-vp9.o +rockchip-vpu-y += rkvpu.o rkvdec-h264.o rkvdec-vp9.o diff --git a/drivers/staging/media/rkvdec/rkvdec-h264.c b/drivers/staging/media/rkvdec/rkvdec-h264.c index 4fc167b42cf0c7..2b0f5965195453 100644 --- a/drivers/staging/media/rkvdec/rkvdec-h264.c +++ b/drivers/staging/media/rkvdec/rkvdec-h264.c @@ -12,7 +12,7 @@ #include <media/v4l2-h264.h> #include <media/v4l2-mem2mem.h> -#include "rkvdec.h" +#include "rkvpu.h" #include "rkvdec-regs.h" /* Size with u32 units. */ @@ -104,7 +104,7 @@ struct rkvdec_h264_reflists { }; struct rkvdec_h264_run { - struct rkvdec_run base; + struct rkvpu_run base; const struct v4l2_ctrl_h264_decode_params *decode_params; const struct v4l2_ctrl_h264_sps *sps; const struct v4l2_ctrl_h264_pps *pps; @@ -113,7 +113,7 @@ struct rkvdec_h264_run { }; struct rkvdec_h264_ctx { - struct rkvdec_aux_buf priv_tbl; + struct rkvpu_aux_buf priv_tbl; struct rkvdec_h264_reflists reflists; }; @@ -630,7 +630,7 @@ static void set_ps_field(u32 *buf, struct rkvdec_ps_field field, u32 value) } } -static void assemble_hw_pps(struct rkvdec_ctx *ctx, +static void assemble_hw_pps(struct rkvpu_ctx *ctx, struct rkvdec_h264_run *run) { struct rkvdec_h264_ctx *h264_ctx = ctx->priv; @@ -732,7 +732,7 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx, } } -static void lookup_ref_buf_idx(struct rkvdec_ctx *ctx, +static void lookup_ref_buf_idx(struct rkvpu_ctx *ctx, struct rkvdec_h264_run *run) { const struct v4l2_ctrl_h264_decode_params *dec_params = run->decode_params; @@ -755,7 +755,7 @@ static void lookup_ref_buf_idx(struct rkvdec_ctx *ctx, } } -static void assemble_hw_rps(struct rkvdec_ctx *ctx, +static void assemble_hw_rps(struct rkvpu_ctx *ctx, struct v4l2_h264_reflist_builder *builder, struct rkvdec_h264_run *run) { @@ -814,7 +814,7 @@ static void assemble_hw_rps(struct rkvdec_ctx *ctx, } } -static void assemble_hw_scaling_list(struct rkvdec_ctx *ctx, +static void assemble_hw_scaling_list(struct rkvpu_ctx *ctx, struct rkvdec_h264_run *run) { const struct v4l2_ctrl_h264_scaling_matrix *scaling = run->scaling_matrix; @@ -880,10 +880,10 @@ static const u32 poc_reg_tbl_bottom_field[16] = { RKVDEC_REG_H264_POC_REFER2(1) }; -static void config_registers(struct rkvdec_ctx *ctx, +static void config_registers(struct rkvpu_ctx *ctx, struct rkvdec_h264_run *run) { - struct rkvdec_dev *rkvdec = ctx->dev; + struct rkvpu_dev *rkvpu = ctx->dev; const struct v4l2_ctrl_h264_decode_params *dec_params = run->decode_params; const struct v4l2_ctrl_h264_sps *sps = run->sps; const struct v4l2_h264_dpb_entry *dpb = dec_params->dpb; @@ -905,7 +905,7 @@ static void config_registers(struct rkvdec_ctx *ctx, u32 reg, i; reg = RKVDEC_MODE(RKVDEC_MODE_H264); - writel_relaxed(reg, rkvdec->regs + RKVDEC_REG_SYSCTRL); + writel_relaxed(reg, rkvpu->regs + RKVDEC_REG_SYSCTRL); f = &ctx->decoded_fmt; dst_fmt = &f->fmt.pix_mp; @@ -924,31 +924,31 @@ static void config_registers(struct rkvdec_ctx *ctx, RKVDEC_UV_HOR_VIRSTRIDE(hor_virstride / 16) | RKVDEC_SLICE_NUM_HIGHBIT | RKVDEC_SLICE_NUM_LOWBITS(0x7ff); - writel_relaxed(reg, rkvdec->regs + RKVDEC_REG_PICPAR); + writel_relaxed(reg, rkvpu->regs + RKVDEC_REG_PICPAR); /* config rlc base address */ rlc_addr = vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, 0); - writel_relaxed(rlc_addr, rkvdec->regs + RKVDEC_REG_STRM_RLC_BASE); - writel_relaxed(rlc_addr, rkvdec->regs + RKVDEC_REG_RLCWRITE_BASE); + writel_relaxed(rlc_addr, rkvpu->regs + RKVDEC_REG_STRM_RLC_BASE); + writel_relaxed(rlc_addr, rkvpu->regs + RKVDEC_REG_RLCWRITE_BASE); rlc_len = vb2_get_plane_payload(&src_buf->vb2_buf, 0); reg = RKVDEC_STRM_LEN(rlc_len); - writel_relaxed(reg, rkvdec->regs + RKVDEC_REG_STRM_LEN); + writel_relaxed(reg, rkvpu->regs + RKVDEC_REG_STRM_LEN); /* config cabac table */ offset = offsetof(struct rkvdec_h264_priv_tbl, cabac_table); writel_relaxed(priv_start_addr + offset, - rkvdec->regs + RKVDEC_REG_CABACTBL_PROB_BASE); + rkvpu->regs + RKVDEC_REG_CABACTBL_PROB_BASE); /* config output base address */ dst_addr = vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0); - writel_relaxed(dst_addr, rkvdec->regs + RKVDEC_REG_DECOUT_BASE); + writel_relaxed(dst_addr, rkvpu->regs + RKVDEC_REG_DECOUT_BASE); reg = RKVDEC_Y_VIRSTRIDE(y_virstride / 16); - writel_relaxed(reg, rkvdec->regs + RKVDEC_REG_Y_VIRSTRIDE); + writel_relaxed(reg, rkvpu->regs + RKVDEC_REG_Y_VIRSTRIDE); reg = RKVDEC_YUV_VIRSTRIDE(yuv_virstride / 16); - writel_relaxed(reg, rkvdec->regs + RKVDEC_REG_YUV_VIRSTRIDE); + writel_relaxed(reg, rkvpu->regs + RKVDEC_REG_YUV_VIRSTRIDE); /* config ref pic address & poc */ for (i = 0; i < ARRAY_SIZE(dec_params->dpb); i++) { @@ -973,48 +973,48 @@ static void config_registers(struct rkvdec_ctx *ctx, refer_addr |= RKVDEC_BOTFIELD_USED_REF; writel_relaxed(dpb[i].top_field_order_cnt, - rkvdec->regs + poc_reg_tbl_top_field[i]); + rkvpu->regs + poc_reg_tbl_top_field[i]); writel_relaxed(dpb[i].bottom_field_order_cnt, - rkvdec->regs + poc_reg_tbl_bottom_field[i]); + rkvpu->regs + poc_reg_tbl_bottom_field[i]); if (i < V4L2_H264_NUM_DPB_ENTRIES - 1) writel_relaxed(refer_addr, - rkvdec->regs + RKVDEC_REG_H264_BASE_REFER(i)); + rkvpu->regs + RKVDEC_REG_H264_BASE_REFER(i)); else writel_relaxed(refer_addr, - rkvdec->regs + RKVDEC_REG_H264_BASE_REFER15); + rkvpu->regs + RKVDEC_REG_H264_BASE_REFER15); } reg = RKVDEC_CUR_POC(dec_params->top_field_order_cnt); - writel_relaxed(reg, rkvdec->regs + RKVDEC_REG_CUR_POC0); + writel_relaxed(reg, rkvpu->regs + RKVDEC_REG_CUR_POC0); reg = RKVDEC_CUR_POC(dec_params->bottom_field_order_cnt); - writel_relaxed(reg, rkvdec->regs + RKVDEC_REG_CUR_POC1); + writel_relaxed(reg, rkvpu->regs + RKVDEC_REG_CUR_POC1); /* config hw pps address */ offset = offsetof(struct rkvdec_h264_priv_tbl, param_set); writel_relaxed(priv_start_addr + offset, - rkvdec->regs + RKVDEC_REG_PPS_BASE); + rkvpu->regs + RKVDEC_REG_PPS_BASE); /* config hw rps address */ offset = offsetof(struct rkvdec_h264_priv_tbl, rps); writel_relaxed(priv_start_addr + offset, - rkvdec->regs + RKVDEC_REG_RPS_BASE); + rkvpu->regs + RKVDEC_REG_RPS_BASE); reg = RKVDEC_AXI_DDR_RDATA(0); - writel_relaxed(reg, rkvdec->regs + RKVDEC_REG_AXI_DDR_RDATA); + writel_relaxed(reg, rkvpu->regs + RKVDEC_REG_AXI_DDR_RDATA); reg = RKVDEC_AXI_DDR_WDATA(0); - writel_relaxed(reg, rkvdec->regs + RKVDEC_REG_AXI_DDR_WDATA); + writel_relaxed(reg, rkvpu->regs + RKVDEC_REG_AXI_DDR_WDATA); offset = offsetof(struct rkvdec_h264_priv_tbl, err_info); writel_relaxed(priv_start_addr + offset, - rkvdec->regs + RKVDEC_REG_H264_ERRINFO_BASE); + rkvpu->regs + RKVDEC_REG_H264_ERRINFO_BASE); } #define RKVDEC_H264_MAX_DEPTH_IN_BYTES 2 -static int rkvdec_h264_adjust_fmt(struct rkvdec_ctx *ctx, +static int rkvdec_h264_adjust_fmt(struct rkvpu_ctx *ctx, struct v4l2_format *f) { struct v4l2_pix_format_mplane *fmt = &f->fmt.pix_mp; @@ -1026,7 +1026,7 @@ static int rkvdec_h264_adjust_fmt(struct rkvdec_ctx *ctx, return 0; } -static int rkvdec_h264_validate_sps(struct rkvdec_ctx *ctx, +static int rkvdec_h264_validate_sps(struct rkvpu_ctx *ctx, const struct v4l2_ctrl_h264_sps *sps) { unsigned int width, height; @@ -1064,9 +1064,9 @@ static int rkvdec_h264_validate_sps(struct rkvdec_ctx *ctx, return 0; } -static int rkvdec_h264_start(struct rkvdec_ctx *ctx) +static int rkvdec_h264_start(struct rkvpu_ctx *ctx) { - struct rkvdec_dev *rkvdec = ctx->dev; + struct rkvpu_dev *rkvpu = ctx->dev; struct rkvdec_h264_priv_tbl *priv_tbl; struct rkvdec_h264_ctx *h264_ctx; struct v4l2_ctrl *ctrl; @@ -1085,7 +1085,7 @@ static int rkvdec_h264_start(struct rkvdec_ctx *ctx) if (!h264_ctx) return -ENOMEM; - priv_tbl = dma_alloc_coherent(rkvdec->dev, sizeof(*priv_tbl), + priv_tbl = dma_alloc_coherent(rkvpu->dev, sizeof(*priv_tbl), &h264_ctx->priv_tbl.dma, GFP_KERNEL); if (!priv_tbl) { ret = -ENOMEM; @@ -1105,17 +1105,17 @@ err_free_ctx: return ret; } -static void rkvdec_h264_stop(struct rkvdec_ctx *ctx) +static void rkvdec_h264_stop(struct rkvpu_ctx *ctx) { struct rkvdec_h264_ctx *h264_ctx = ctx->priv; - struct rkvdec_dev *rkvdec = ctx->dev; + struct rkvpu_dev *rkvpu = ctx->dev; - dma_free_coherent(rkvdec->dev, h264_ctx->priv_tbl.size, + dma_free_coherent(rkvpu->dev, h264_ctx->priv_tbl.size, h264_ctx->priv_tbl.cpu, h264_ctx->priv_tbl.dma); kfree(h264_ctx); } -static void rkvdec_h264_run_preamble(struct rkvdec_ctx *ctx, +static void rkvdec_h264_run_preamble(struct rkvpu_ctx *ctx, struct rkvdec_h264_run *run) { struct v4l2_ctrl *ctrl; @@ -1133,13 +1133,13 @@ static void rkvdec_h264_run_preamble(struct rkvdec_ctx *ctx, V4L2_CID_STATELESS_H264_SCALING_MATRIX); run->scaling_matrix = ctrl ? ctrl->p_cur.p : NULL; - rkvdec_run_preamble(ctx, &run->base); + rkvpu_run_preamble(ctx, &run->base); } -static int rkvdec_h264_run(struct rkvdec_ctx *ctx) +static int rkvdec_h264_run(struct rkvpu_ctx *ctx) { struct v4l2_h264_reflist_builder reflist_builder; - struct rkvdec_dev *rkvdec = ctx->dev; + struct rkvpu_dev *rkvpu = ctx->dev; struct rkvdec_h264_ctx *h264_ctx = ctx->priv; struct rkvdec_h264_run run; @@ -1158,24 +1158,24 @@ static int rkvdec_h264_run(struct rkvdec_ctx *ctx) assemble_hw_rps(ctx, &reflist_builder, &run); config_registers(ctx, &run); - rkvdec_run_postamble(ctx, &run.base); + rkvpu_run_postamble(ctx, &run.base); - schedule_delayed_work(&rkvdec->watchdog_work, msecs_to_jiffies(2000)); + schedule_delayed_work(&rkvpu->watchdog_work, msecs_to_jiffies(2000)); - writel(0, rkvdec->regs + RKVDEC_REG_STRMD_ERR_EN); - writel(0, rkvdec->regs + RKVDEC_REG_H264_ERR_E); - writel(1, rkvdec->regs + RKVDEC_REG_PREF_LUMA_CACHE_COMMAND); - writel(1, rkvdec->regs + RKVDEC_REG_PREF_CHR_CACHE_COMMAND); + writel(0, rkvpu->regs + RKVDEC_REG_STRMD_ERR_EN); + writel(0, rkvpu->regs + RKVDEC_REG_H264_ERR_E); + writel(1, rkvpu->regs + RKVDEC_REG_PREF_LUMA_CACHE_COMMAND); + writel(1, rkvpu->regs + RKVDEC_REG_PREF_CHR_CACHE_COMMAND); /* Start decoding! */ writel(RKVDEC_INTERRUPT_DEC_E | RKVDEC_CONFIG_DEC_CLK_GATE_E | RKVDEC_TIMEOUT_E | RKVDEC_BUF_EMPTY_E, - rkvdec->regs + RKVDEC_REG_INTERRUPT); + rkvpu->regs + RKVDEC_REG_INTERRUPT); return 0; } -static int rkvdec_h264_try_ctrl(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl) +static int rkvdec_h264_try_ctrl(struct rkvpu_ctx *ctx, struct v4l2_ctrl *ctrl) { if (ctrl->id == V4L2_CID_STATELESS_H264_SPS) return rkvdec_h264_validate_sps(ctx, ctrl->p_new.p_h264_sps); @@ -1183,7 +1183,7 @@ static int rkvdec_h264_try_ctrl(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl) return 0; } -const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops = { +const struct rkvpu_coded_fmt_ops rkvdec_h264_fmt_ops = { .adjust_fmt = rkvdec_h264_adjust_fmt, .start = rkvdec_h264_start, .stop = rkvdec_h264_stop, diff --git a/drivers/staging/media/rkvdec/rkvdec-vp9.c b/drivers/staging/media/rkvdec/rkvdec-vp9.c index cfae99b40ccb4e..8af888085e5106 100644 --- a/drivers/staging/media/rkvdec/rkvdec-vp9.c +++ b/drivers/staging/media/rkvdec/rkvdec-vp9.c @@ -21,7 +21,7 @@ #include <media/v4l2-mem2mem.h> #include <media/v4l2-vp9.h> -#include "rkvdec.h" +#include "rkvpu.h" #include "rkvdec-regs.h" #define RKVDEC_VP9_PROBE_SIZE 4864 @@ -137,7 +137,7 @@ struct rkvdec_vp9_intra_frame_symbol_counts { }; struct rkvdec_vp9_run { - struct rkvdec_run base; + struct rkvpu_run base; const struct v4l2_ctrl_vp9_frame *decode_params; }; @@ -155,8 +155,8 @@ struct rkvdec_vp9_frame_info { }; struct rkvdec_vp9_ctx { - struct rkvdec_aux_buf priv_tbl; - struct rkvdec_aux_buf count_tbl; + struct rkvpu_aux_buf priv_tbl; + struct rkvpu_aux_buf count_tbl; struct v4l2_vp9_frame_symbol_counts inter_cnts; struct v4l2_vp9_frame_symbol_counts intra_cnts; struct v4l2_vp9_frame_context probability_tables; @@ -186,7 +186,7 @@ static void write_coeff_plane(const u8 coef[6][6][3], u8 *coeff_plane) } } -static void init_intra_only_probs(struct rkvdec_ctx *ctx, +static void init_intra_only_probs(struct rkvpu_ctx *ctx, const struct rkvdec_vp9_run *run) { struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; @@ -237,7 +237,7 @@ static void init_intra_only_probs(struct rkvdec_ctx *ctx, } } -static void init_inter_probs(struct rkvdec_ctx *ctx, +static void init_inter_probs(struct rkvpu_ctx *ctx, const struct rkvdec_vp9_run *run) { struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; @@ -308,7 +308,7 @@ static void init_inter_probs(struct rkvdec_ctx *ctx, sizeof(rkprobs->mv.hp)); } -static void init_probs(struct rkvdec_ctx *ctx, +static void init_probs(struct rkvpu_ctx *ctx, const struct rkvdec_vp9_run *run) { const struct v4l2_ctrl_vp9_frame *dec_params; @@ -380,7 +380,7 @@ static struct rkvdec_vp9_ref_reg ref_regs[] = { } }; -static struct rkvdec_decoded_buffer * +static struct rkvpu_decoded_buffer * get_ref_buf(struct rkvdec_ctx *ctx, struct vb2_v4l2_buffer *dst, u64 timestamp) { struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; @@ -395,7 +395,7 @@ get_ref_buf(struct rkvdec_ctx *ctx, struct vb2_v4l2_buffer *dst, u64 timestamp) if (!buf) buf = &dst->vb2_buf; - return vb2_to_rkvdec_decoded_buf(buf); + return vb2_to_rkvpu_decoded_buf(buf); } static dma_addr_t get_mv_base_addr(struct rkvdec_decoded_buffer *buf) @@ -410,21 +410,21 @@ static dma_addr_t get_mv_base_addr(struct rkvdec_decoded_buffer *buf) yuv_len; } -static void config_ref_registers(struct rkvdec_ctx *ctx, +static void config_ref_registers(struct rkvpu_ctx *ctx, const struct rkvdec_vp9_run *run, - struct rkvdec_decoded_buffer *ref_buf, + struct rkvpu_decoded_buffer *ref_buf, struct rkvdec_vp9_ref_reg *ref_reg) { unsigned int aligned_pitch, aligned_height, y_len, yuv_len; - struct rkvdec_dev *rkvdec = ctx->dev; + struct rkvpu_dev *rkvpu = ctx->dev; aligned_height = round_up(ref_buf->vp9.height, 64); writel_relaxed(RKVDEC_VP9_FRAMEWIDTH(ref_buf->vp9.width) | RKVDEC_VP9_FRAMEHEIGHT(ref_buf->vp9.height), - rkvdec->regs + ref_reg->reg_frm_size); + rkvpu->regs + ref_reg->reg_frm_size); writel_relaxed(vb2_dma_contig_plane_dma_addr(&ref_buf->base.vb.vb2_buf, 0), - rkvdec->regs + ref_reg->reg_ref_base); + rkvpu->regs + ref_reg->reg_ref_base); if (&ref_buf->base.vb == run->base.bufs.dst) return; @@ -435,22 +435,22 @@ static void config_ref_registers(struct rkvdec_ctx *ctx, writel_relaxed(RKVDEC_HOR_Y_VIRSTRIDE(aligned_pitch / 16) | RKVDEC_HOR_UV_VIRSTRIDE(aligned_pitch / 16), - rkvdec->regs + ref_reg->reg_hor_stride); + rkvpu->regs + ref_reg->reg_hor_stride); writel_relaxed(RKVDEC_VP9_REF_YSTRIDE(y_len / 16), - rkvdec->regs + ref_reg->reg_y_stride); + rkvpu->regs + ref_reg->reg_y_stride); if (!ref_reg->reg_yuv_stride) return; writel_relaxed(RKVDEC_VP9_REF_YUVSTRIDE(yuv_len / 16), - rkvdec->regs + ref_reg->reg_yuv_stride); + rkvpu->regs + ref_reg->reg_yuv_stride); } -static void config_seg_registers(struct rkvdec_ctx *ctx, unsigned int segid) +static void config_seg_registers(struct rkvpu_ctx *ctx, unsigned int segid) { struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; const struct v4l2_vp9_segmentation *seg; - struct rkvdec_dev *rkvdec = ctx->dev; + struct rkvpu_dev *rkvpu = ctx->dev; s16 feature_val; int feature_id; u32 val = 0; @@ -485,10 +485,10 @@ static void config_seg_registers(struct rkvdec_ctx *ctx, unsigned int segid) (seg->flags & V4L2_VP9_SEGMENTATION_FLAG_ABS_OR_DELTA_UPDATE)) val |= RKVDEC_SEGID_ABS_DELTA(1); - writel_relaxed(val, rkvdec->regs + RKVDEC_VP9_SEGID_GRP(segid)); + writel_relaxed(val, rkvpu->regs + RKVDEC_VP9_SEGID_GRP(segid)); } -static void update_dec_buf_info(struct rkvdec_decoded_buffer *buf, +static void update_dec_buf_info(struct rkvpu_decoded_buffer *buf, const struct v4l2_ctrl_vp9_frame *dec_params) { buf->vp9.width = dec_params->frame_width_minus_1 + 1; @@ -497,7 +497,7 @@ static void update_dec_buf_info(struct rkvdec_decoded_buffer *buf, } static void update_ctx_cur_info(struct rkvdec_vp9_ctx *vp9_ctx, - struct rkvdec_decoded_buffer *buf, + struct rkvpu_decoded_buffer *buf, const struct v4l2_ctrl_vp9_frame *dec_params) { vp9_ctx->cur.valid = true; @@ -514,23 +514,23 @@ static void update_ctx_last_info(struct rkvdec_vp9_ctx *vp9_ctx) vp9_ctx->last = vp9_ctx->cur; } -static void config_registers(struct rkvdec_ctx *ctx, +static void config_registers(struct rkvpu_ctx *ctx, const struct rkvdec_vp9_run *run) { unsigned int y_len, uv_len, yuv_len, bit_depth, aligned_height, aligned_pitch, stream_len; const struct v4l2_ctrl_vp9_frame *dec_params; - struct rkvdec_decoded_buffer *ref_bufs[3]; - struct rkvdec_decoded_buffer *dst, *last, *mv_ref; + struct rkvpu_decoded_buffer *ref_bufs[3]; + struct rkvpu_decoded_buffer *dst, *last, *mv_ref; struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; u32 val, last_frame_info = 0; const struct v4l2_vp9_segmentation *seg; - struct rkvdec_dev *rkvdec = ctx->dev; + struct rkvpu_dev *rkvpu = ctx->dev; dma_addr_t addr; bool intra_only; unsigned int i; dec_params = run->decode_params; - dst = vb2_to_rkvdec_decoded_buf(&run->base.bufs.dst->vb2_buf); + dst = vb2_to_rkvpu_decoded_buf(&run->base.bufs.dst->vb2_buf); ref_bufs[0] = get_ref_buf(ctx, &dst->base.vb, dec_params->last_frame_ts); ref_bufs[1] = get_ref_buf(ctx, &dst->base.vb, dec_params->golden_frame_ts); ref_bufs[2] = get_ref_buf(ctx, &dst->base.vb, dec_params->alt_frame_ts); @@ -549,7 +549,7 @@ static void config_registers(struct rkvdec_ctx *ctx, V4L2_VP9_FRAME_FLAG_INTRA_ONLY)); writel_relaxed(RKVDEC_MODE(RKVDEC_MODE_VP9), - rkvdec->regs + RKVDEC_REG_SYSCTRL); + rkvpu->regs + RKVDEC_REG_SYSCTRL); bit_depth = dec_params->bit_depth; aligned_height = round_up(ctx->decoded_fmt.fmt.pix_mp.height, 64); @@ -563,15 +563,15 @@ static void config_registers(struct rkvdec_ctx *ctx, writel_relaxed(RKVDEC_Y_HOR_VIRSTRIDE(aligned_pitch / 16) | RKVDEC_UV_HOR_VIRSTRIDE(aligned_pitch / 16), - rkvdec->regs + RKVDEC_REG_PICPAR); + rkvpu->regs + RKVDEC_REG_PICPAR); writel_relaxed(RKVDEC_Y_VIRSTRIDE(y_len / 16), - rkvdec->regs + RKVDEC_REG_Y_VIRSTRIDE); + rkvpu->regs + RKVDEC_REG_Y_VIRSTRIDE); writel_relaxed(RKVDEC_YUV_VIRSTRIDE(yuv_len / 16), - rkvdec->regs + RKVDEC_REG_YUV_VIRSTRIDE); + rkvpu->regs + RKVDEC_REG_YUV_VIRSTRIDE); stream_len = vb2_get_plane_payload(&run->base.bufs.src->vb2_buf, 0); writel_relaxed(RKVDEC_STRM_LEN(stream_len), - rkvdec->regs + RKVDEC_REG_STRM_LEN); + rkvpu->regs + RKVDEC_REG_STRM_LEN); /* * Reset count buffer, because decoder only output intra related syntax @@ -596,7 +596,7 @@ static void config_registers(struct rkvdec_ctx *ctx, writel_relaxed(RKVDEC_VP9_TX_MODE(vp9_ctx->cur.tx_mode) | RKVDEC_VP9_FRAME_REF_MODE(dec_params->reference_mode), - rkvdec->regs + RKVDEC_VP9_CPRHEADER_CONFIG); + rkvpu->regs + RKVDEC_VP9_CPRHEADER_CONFIG); if (!intra_only) { const struct v4l2_vp9_loop_filter *lf; @@ -614,7 +614,7 @@ static void config_registers(struct rkvdec_ctx *ctx, } writel_relaxed(val, - rkvdec->regs + RKVDEC_VP9_REF_DELTAS_LASTFRAME); + rkvpu->regs + RKVDEC_VP9_REF_DELTAS_LASTFRAME); for (i = 0; i < ARRAY_SIZE(lf->mode_deltas); i++) { delta = lf->mode_deltas[i]; @@ -642,11 +642,11 @@ static void config_registers(struct rkvdec_ctx *ctx, last_frame_info |= RKVDEC_LAST_WIDHHEIGHT_EQCUR; writel_relaxed(last_frame_info, - rkvdec->regs + RKVDEC_VP9_INFO_LASTFRAME); + rkvpu->regs + RKVDEC_VP9_INFO_LASTFRAME); writel_relaxed(stream_len - dec_params->compressed_header_size - dec_params->uncompressed_header_size, - rkvdec->regs + RKVDEC_VP9_LASTTILE_SIZE); + rkvpu->regs + RKVDEC_VP9_LASTTILE_SIZE); for (i = 0; !intra_only && i < ARRAY_SIZE(ref_bufs); i++) { unsigned int refw = ref_bufs[i]->vp9.width; @@ -657,27 +657,27 @@ static void config_registers(struct rkvdec_ctx *ctx, vscale = (refh << 14) / dst->vp9.height; writel_relaxed(RKVDEC_VP9_REF_HOR_SCALE(hscale) | RKVDEC_VP9_REF_VER_SCALE(vscale), - rkvdec->regs + RKVDEC_VP9_REF_SCALE(i)); + rkvpu->regs + RKVDEC_VP9_REF_SCALE(i)); } addr = vb2_dma_contig_plane_dma_addr(&dst->base.vb.vb2_buf, 0); - writel_relaxed(addr, rkvdec->regs + RKVDEC_REG_DECOUT_BASE); + writel_relaxed(addr, rkvpu->regs + RKVDEC_REG_DECOUT_BASE); addr = vb2_dma_contig_plane_dma_addr(&run->base.bufs.src->vb2_buf, 0); - writel_relaxed(addr, rkvdec->regs + RKVDEC_REG_STRM_RLC_BASE); + writel_relaxed(addr, rkvpu->regs + RKVDEC_REG_STRM_RLC_BASE); writel_relaxed(vp9_ctx->priv_tbl.dma + offsetof(struct rkvdec_vp9_priv_tbl, probs), - rkvdec->regs + RKVDEC_REG_CABACTBL_PROB_BASE); + rkvpu->regs + RKVDEC_REG_CABACTBL_PROB_BASE); writel_relaxed(vp9_ctx->count_tbl.dma, - rkvdec->regs + RKVDEC_REG_VP9COUNT_BASE); + rkvpu->regs + RKVDEC_REG_VP9COUNT_BASE); writel_relaxed(vp9_ctx->priv_tbl.dma + offsetof(struct rkvdec_vp9_priv_tbl, segmap) + (RKVDEC_VP9_MAX_SEGMAP_SIZE * vp9_ctx->cur.segmapid), - rkvdec->regs + RKVDEC_REG_VP9_SEGIDCUR_BASE); + rkvpu->regs + RKVDEC_REG_VP9_SEGIDCUR_BASE); writel_relaxed(vp9_ctx->priv_tbl.dma + offsetof(struct rkvdec_vp9_priv_tbl, segmap) + (RKVDEC_VP9_MAX_SEGMAP_SIZE * (!vp9_ctx->cur.segmapid)), - rkvdec->regs + RKVDEC_REG_VP9_SEGIDLAST_BASE); + rkvpu->regs + RKVDEC_REG_VP9_SEGIDLAST_BASE); if (!intra_only && !(dec_params->flags & V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT) && @@ -687,14 +687,14 @@ static void config_registers(struct rkvdec_ctx *ctx, mv_ref = dst; writel_relaxed(get_mv_base_addr(mv_ref), - rkvdec->regs + RKVDEC_VP9_REF_COLMV_BASE); + rkvpu->regs + RKVDEC_VP9_REF_COLMV_BASE); writel_relaxed(ctx->decoded_fmt.fmt.pix_mp.width | (ctx->decoded_fmt.fmt.pix_mp.height << 16), - rkvdec->regs + RKVDEC_REG_PERFORMANCE_CYCLE); + rkvpu->regs + RKVDEC_REG_PERFORMANCE_CYCLE); } -static int validate_dec_params(struct rkvdec_ctx *ctx, +static int validate_dec_params(struct rkvpu_ctx *ctx, const struct v4l2_ctrl_vp9_frame *dec_params) { unsigned int aligned_width, aligned_height; @@ -725,7 +725,7 @@ static int validate_dec_params(struct rkvdec_ctx *ctx, return 0; } -static int rkvdec_vp9_run_preamble(struct rkvdec_ctx *ctx, +static int rkvdec_vp9_run_preamble(struct rkvpu_ctx *ctx, struct rkvdec_vp9_run *run) { const struct v4l2_ctrl_vp9_frame *dec_params; @@ -736,7 +736,7 @@ static int rkvdec_vp9_run_preamble(struct rkvdec_ctx *ctx, int ret; /* v4l2-specific stuff */ - rkvdec_run_preamble(ctx, &run->base); + rkvpu_run_preamble(ctx, &run->base); ctrl = v4l2_ctrl_find(&ctx->ctrl_hdl, V4L2_CID_STATELESS_VP9_FRAME); @@ -799,15 +799,15 @@ static int rkvdec_vp9_run_preamble(struct rkvdec_ctx *ctx, return 0; } -static int rkvdec_vp9_run(struct rkvdec_ctx *ctx) +static int rkvdec_vp9_run(struct rkvpu_ctx *ctx) { - struct rkvdec_dev *rkvdec = ctx->dev; + struct rkvpu_dev *rkvpu = ctx->dev; struct rkvdec_vp9_run run = { }; int ret; ret = rkvdec_vp9_run_preamble(ctx, &run); if (ret) { - rkvdec_run_postamble(ctx, &run.base); + rkvpu_run_postamble(ctx, &run.base); return ret; } @@ -817,18 +817,18 @@ static int rkvdec_vp9_run(struct rkvdec_ctx *ctx) /* Configure hardware registers. */ config_registers(ctx, &run); - rkvdec_run_postamble(ctx, &run.base); + rkvpu_run_postamble(ctx, &run.base); - schedule_delayed_work(&rkvdec->watchdog_work, msecs_to_jiffies(2000)); + schedule_delayed_work(&rkvpu->watchdog_work, msecs_to_jiffies(2000)); - writel(1, rkvdec->regs + RKVDEC_REG_PREF_LUMA_CACHE_COMMAND); - writel(1, rkvdec->regs + RKVDEC_REG_PREF_CHR_CACHE_COMMAND); + writel(1, rkvpu->regs + RKVDEC_REG_PREF_LUMA_CACHE_COMMAND); + writel(1, rkvpu->regs + RKVDEC_REG_PREF_CHR_CACHE_COMMAND); - writel(0xe, rkvdec->regs + RKVDEC_REG_STRMD_ERR_EN); + writel(0xe, rkvpu->regs + RKVDEC_REG_STRMD_ERR_EN); /* Start decoding! */ writel(RKVDEC_INTERRUPT_DEC_E | RKVDEC_CONFIG_DEC_CLK_GATE_E | RKVDEC_TIMEOUT_E | RKVDEC_BUF_EMPTY_E, - rkvdec->regs + RKVDEC_REG_INTERRUPT); + rkvpu->regs + RKVDEC_REG_INTERRUPT); return 0; } @@ -841,7 +841,7 @@ do { \ memcpy((p1)->skip, (p2)->skip, sizeof((p1)->skip)); \ } while (0) -static void rkvdec_vp9_done(struct rkvdec_ctx *ctx, +static void rkvdec_vp9_done(struct rkvpu_ctx *ctx, struct vb2_v4l2_buffer *src_buf, struct vb2_v4l2_buffer *dst_buf, enum vb2_buffer_state result) @@ -924,7 +924,7 @@ out_update_last: update_ctx_last_info(vp9_ctx); } -static void rkvdec_init_v4l2_vp9_count_tbl(struct rkvdec_ctx *ctx) +static void rkvpu_init_v4l2_vp9_count_tbl(struct rkvpu_ctx *ctx) { struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; struct rkvdec_vp9_intra_frame_symbol_counts *intra_cnts = vp9_ctx->count_tbl.cpu; @@ -994,9 +994,9 @@ static void rkvdec_init_v4l2_vp9_count_tbl(struct rkvdec_ctx *ctx) #undef INNERMOST_LOOP } -static int rkvdec_vp9_start(struct rkvdec_ctx *ctx) +static int rkvdec_vp9_start(struct rkvpu_ctx *ctx) { - struct rkvdec_dev *rkvdec = ctx->dev; + struct rkvpu_dev *rkvpu = ctx->dev; struct rkvdec_vp9_priv_tbl *priv_tbl; struct rkvdec_vp9_ctx *vp9_ctx; unsigned char *count_tbl; @@ -1009,7 +1009,7 @@ static int rkvdec_vp9_start(struct rkvdec_ctx *ctx) ctx->priv = vp9_ctx; BUILD_BUG_ON(sizeof(priv_tbl->probs) % 16); /* ensure probs size is 128-bit aligned */ - priv_tbl = dma_alloc_coherent(rkvdec->dev, sizeof(*priv_tbl), + priv_tbl = dma_alloc_coherent(rkvpu->dev, sizeof(*priv_tbl), &vp9_ctx->priv_tbl.dma, GFP_KERNEL); if (!priv_tbl) { ret = -ENOMEM; @@ -1019,7 +1019,7 @@ static int rkvdec_vp9_start(struct rkvdec_ctx *ctx) vp9_ctx->priv_tbl.size = sizeof(*priv_tbl); vp9_ctx->priv_tbl.cpu = priv_tbl; - count_tbl = dma_alloc_coherent(rkvdec->dev, RKVDEC_VP9_COUNT_SIZE, + count_tbl = dma_alloc_coherent(rkvpu->dev, RKVDEC_VP9_COUNT_SIZE, &vp9_ctx->count_tbl.dma, GFP_KERNEL); if (!count_tbl) { ret = -ENOMEM; @@ -1028,12 +1028,12 @@ static int rkvdec_vp9_start(struct rkvdec_ctx *ctx) vp9_ctx->count_tbl.size = RKVDEC_VP9_COUNT_SIZE; vp9_ctx->count_tbl.cpu = count_tbl; - rkvdec_init_v4l2_vp9_count_tbl(ctx); + rkvpu_init_v4l2_vp9_count_tbl(ctx); return 0; err_free_priv_tbl: - dma_free_coherent(rkvdec->dev, vp9_ctx->priv_tbl.size, + dma_free_coherent(rkvpu->dev, vp9_ctx->priv_tbl.size, vp9_ctx->priv_tbl.cpu, vp9_ctx->priv_tbl.dma); err_free_ctx: @@ -1041,19 +1041,19 @@ err_free_ctx: return ret; } -static void rkvdec_vp9_stop(struct rkvdec_ctx *ctx) +static void rkvdec_vp9_stop(struct rkvpu_ctx *ctx) { struct rkvdec_vp9_ctx *vp9_ctx = ctx->priv; - struct rkvdec_dev *rkvdec = ctx->dev; + struct rkvpu_dev *rkvpu = ctx->dev; - dma_free_coherent(rkvdec->dev, vp9_ctx->count_tbl.size, + dma_free_coherent(rkvpu->dev, vp9_ctx->count_tbl.size, vp9_ctx->count_tbl.cpu, vp9_ctx->count_tbl.dma); - dma_free_coherent(rkvdec->dev, vp9_ctx->priv_tbl.size, + dma_free_coherent(rkvpu->dev, vp9_ctx->priv_tbl.size, vp9_ctx->priv_tbl.cpu, vp9_ctx->priv_tbl.dma); kfree(vp9_ctx); } -static int rkvdec_vp9_adjust_fmt(struct rkvdec_ctx *ctx, +static int rkvdec_vp9_adjust_fmt(struct rkvpu_ctx *ctx, struct v4l2_format *f) { struct v4l2_pix_format_mplane *fmt = &f->fmt.pix_mp; @@ -1064,7 +1064,7 @@ static int rkvdec_vp9_adjust_fmt(struct rkvdec_ctx *ctx, return 0; } -const struct rkvdec_coded_fmt_ops rkvdec_vp9_fmt_ops = { +const struct rkvpu_coded_fmt_ops rkvdec_vp9_fmt_ops = { .adjust_fmt = rkvdec_vp9_adjust_fmt, .start = rkvdec_vp9_start, .stop = rkvdec_vp9_stop, diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvpu.c index 7bab7586918c11..e6ee77f5fb03a3 100644 --- a/drivers/staging/media/rkvdec/rkvdec.c +++ b/drivers/staging/media/rkvdec/rkvpu.c @@ -4,7 +4,7 @@ * * Copyright (C) 2019 Collabora, Ltd. * - * Based on rkvdec driver by Google LLC. (Tomasz Figa <tfiga@chromium.org>) + * Based on rkvpu driver by Google LLC. (Tomasz Figa <tfiga@chromium.org>) * Based on s5p-mfc driver by Samsung Electronics Co., Ltd. * Copyright (C) 2011 Samsung Electronics Co., Ltd. */ @@ -24,13 +24,13 @@ #include <media/videobuf2-core.h> #include <media/videobuf2-vmalloc.h> -#include "rkvdec.h" -#include "rkvdec-regs.h" +#include "rkvpu.h" +#include "rkvpu-regs.h" -static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl) +static int rkvpu_try_ctrl(struct v4l2_ctrl *ctrl) { - struct rkvdec_ctx *ctx = container_of(ctrl->handler, struct rkvdec_ctx, ctrl_hdl); - const struct rkvdec_coded_fmt_desc *desc = ctx->coded_fmt_desc; + struct rkvpu_ctx *ctx = container_of(ctrl->handler, struct rkvpu_ctx, ctrl_hdl); + const struct rkvpu_coded_fmt_desc *desc = ctx->coded_fmt_desc; if (desc->ops->try_ctrl) return desc->ops->try_ctrl(ctx, ctrl); @@ -38,17 +38,17 @@ static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl) return 0; } -static const struct v4l2_ctrl_ops rkvdec_ctrl_ops = { - .try_ctrl = rkvdec_try_ctrl, +static const struct v4l2_ctrl_ops rkvpu_ctrl_ops = { + .try_ctrl = rkvpu_try_ctrl, }; -static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = { +static const struct rkvpu_ctrl_desc rkvdec_h264_ctrl_descs[] = { { .cfg.id = V4L2_CID_STATELESS_H264_DECODE_PARAMS, }, { .cfg.id = V4L2_CID_STATELESS_H264_SPS, - .cfg.ops = &rkvdec_ctrl_ops, + .cfg.ops = &rkvpu_ctrl_ops, }, { .cfg.id = V4L2_CID_STATELESS_H264_PPS, @@ -83,16 +83,16 @@ static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = { }, }; -static const struct rkvdec_ctrls rkvdec_h264_ctrls = { +static const struct rkvpu_ctrls rkvdec_h264_ctrls = { .ctrls = rkvdec_h264_ctrl_descs, .num_ctrls = ARRAY_SIZE(rkvdec_h264_ctrl_descs), }; -static const u32 rkvdec_h264_vp9_decoded_fmts[] = { +static const u32 rkvpu_h264_vp9_decoded_fmts[] = { V4L2_PIX_FMT_NV12, }; -static const struct rkvdec_ctrl_desc rkvdec_vp9_ctrl_descs[] = { +static const struct rkvpu_ctrl_desc rkvdec_vp9_ctrl_descs[] = { { .cfg.id = V4L2_CID_STATELESS_VP9_FRAME, }, @@ -107,12 +107,12 @@ static const struct rkvdec_ctrl_desc rkvdec_vp9_ctrl_descs[] = { }, }; -static const struct rkvdec_ctrls rkvdec_vp9_ctrls = { +static const struct rkvpu_ctrls rkvdec_vp9_ctrls = { .ctrls = rkvdec_vp9_ctrl_descs, .num_ctrls = ARRAY_SIZE(rkvdec_vp9_ctrl_descs), }; -static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = { +static const struct rkvpu_coded_fmt_desc rkvdec_coded_fmts[] = { { .fourcc = V4L2_PIX_FMT_H264_SLICE, .frmsize = { @@ -125,8 +125,8 @@ static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = { }, .ctrls = &rkvdec_h264_ctrls, .ops = &rkvdec_h264_fmt_ops, - .num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_vp9_decoded_fmts), - .decoded_fmts = rkvdec_h264_vp9_decoded_fmts, + .num_decoded_fmts = ARRAY_SIZE(rkvpu_h264_vp9_decoded_fmts), + .decoded_fmts = rkvpu_h264_vp9_decoded_fmts, .subsystem_flags = VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF, }, { @@ -141,25 +141,25 @@ static const struct rkvdec_coded_fmt_desc rkvdec_coded_fmts[] = { }, .ctrls = &rkvdec_vp9_ctrls, .ops = &rkvdec_vp9_fmt_ops, - .num_decoded_fmts = ARRAY_SIZE(rkvdec_h264_vp9_decoded_fmts), - .decoded_fmts = rkvdec_h264_vp9_decoded_fmts, + .num_decoded_fmts = ARRAY_SIZE(rkvpu_h264_vp9_decoded_fmts), + .decoded_fmts = rkvpu_h264_vp9_decoded_fmts, } }; -static const struct rkvdec_coded_fmt_desc * -rkvdec_find_coded_fmt_desc(u32 fourcc) +static const struct rkvpu_coded_fmt_desc * +rkvpu_find_coded_fmt_desc(u32 fourcc) { unsigned int i; - for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) { - if (rkvdec_coded_fmts[i].fourcc == fourcc) - return &rkvdec_coded_fmts[i]; + for (i = 0; i < ARRAY_SIZE(rkvpu_coded_fmts); i++) { + if (rkvpu_coded_fmts[i].fourcc == fourcc) + return &rkvpu_coded_fmts[i]; } return NULL; } -static void rkvdec_reset_fmt(struct rkvdec_ctx *ctx, struct v4l2_format *f, +static void rkvpu_reset_fmt(struct rkvpu_ctx *ctx, struct v4l2_format *f, u32 fourcc) { memset(f, 0, sizeof(*f)); @@ -171,12 +171,12 @@ static void rkvdec_reset_fmt(struct rkvdec_ctx *ctx, struct v4l2_format *f, f->fmt.pix_mp.xfer_func = V4L2_XFER_FUNC_DEFAULT; } -static void rkvdec_reset_coded_fmt(struct rkvdec_ctx *ctx) +static void rkvpu_reset_coded_fmt(struct rkvdec_ctx *ctx) { struct v4l2_format *f = &ctx->coded_fmt; - ctx->coded_fmt_desc = &rkvdec_coded_fmts[0]; - rkvdec_reset_fmt(ctx, f, ctx->coded_fmt_desc->fourcc); + ctx->coded_fmt_desc = &rkvpu_coded_fmts[0]; + rkvpu_reset_fmt(ctx, f, ctx->coded_fmt_desc->fourcc); f->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; f->fmt.pix_mp.width = ctx->coded_fmt_desc->frmsize.min_width; @@ -186,11 +186,11 @@ static void rkvdec_reset_coded_fmt(struct rkvdec_ctx *ctx) ctx->coded_fmt_desc->ops->adjust_fmt(ctx, f); } -static void rkvdec_reset_decoded_fmt(struct rkvdec_ctx *ctx) +static void rkvpu_reset_decoded_fmt(struct rkvdec_ctx *ctx) { struct v4l2_format *f = &ctx->decoded_fmt; - rkvdec_reset_fmt(ctx, f, ctx->coded_fmt_desc->decoded_fmts[0]); + rkvpu_reset_fmt(ctx, f, ctx->coded_fmt_desc->decoded_fmts[0]); f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; v4l2_fill_pixfmt_mp(&f->fmt.pix_mp, ctx->coded_fmt_desc->decoded_fmts[0], @@ -201,15 +201,15 @@ static void rkvdec_reset_decoded_fmt(struct rkvdec_ctx *ctx) DIV_ROUND_UP(f->fmt.pix_mp.height, 16); } -static int rkvdec_enum_framesizes(struct file *file, void *priv, +static int rkvpu_enum_framesizes(struct file *file, void *priv, struct v4l2_frmsizeenum *fsize) { - const struct rkvdec_coded_fmt_desc *fmt; + const struct rkvpu_coded_fmt_desc *fmt; if (fsize->index != 0) return -EINVAL; - fmt = rkvdec_find_coded_fmt_desc(fsize->pixel_format); + fmt = rkvpu_find_coded_fmt_desc(fsize->pixel_format); if (!fmt) return -EINVAL; @@ -218,26 +218,26 @@ static int rkvdec_enum_framesizes(struct file *file, void *priv, return 0; } -static int rkvdec_querycap(struct file *file, void *priv, +static int rkvpu_querycap(struct file *file, void *priv, struct v4l2_capability *cap) { - struct rkvdec_dev *rkvdec = video_drvdata(file); + struct rkvpu_dev *rkvpu = video_drvdata(file); struct video_device *vdev = video_devdata(file); - strscpy(cap->driver, rkvdec->dev->driver->name, + strscpy(cap->driver, rkvpu->dev->driver->name, sizeof(cap->driver)); strscpy(cap->card, vdev->name, sizeof(cap->card)); snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s", - rkvdec->dev->driver->name); + rkvpu->dev->driver->name); return 0; } -static int rkvdec_try_capture_fmt(struct file *file, void *priv, +static int rkvpu_try_capture_fmt(struct file *file, void *priv, struct v4l2_format *f) { struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv); - const struct rkvdec_coded_fmt_desc *coded_desc; + struct rkvpu_ctx *ctx = fh_to_rkvpu_ctx(priv); + const struct rkvpu_coded_fmt_desc *coded_desc; unsigned int i; /* @@ -275,17 +275,17 @@ static int rkvdec_try_capture_fmt(struct file *file, void *priv, return 0; } -static int rkvdec_try_output_fmt(struct file *file, void *priv, +static int rkvpu_try_output_fmt(struct file *file, void *priv, struct v4l2_format *f) { struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv); - const struct rkvdec_coded_fmt_desc *desc; + struct rkvpu_ctx *ctx = fh_to_rkvpu_ctx(priv); + const struct rkvpu_coded_fmt_desc *desc; - desc = rkvdec_find_coded_fmt_desc(pix_mp->pixelformat); + desc = rkvpu_find_coded_fmt_desc(pix_mp->pixelformat); if (!desc) { - pix_mp->pixelformat = rkvdec_coded_fmts[0].fourcc; - desc = &rkvdec_coded_fmts[0]; + pix_mp->pixelformat = rkvpu_coded_fmts[0].fourcc; + desc = &rkvpu_coded_fmts[0]; } v4l2_apply_frmsize_constraints(&pix_mp->width, @@ -307,10 +307,10 @@ static int rkvdec_try_output_fmt(struct file *file, void *priv, return 0; } -static int rkvdec_s_capture_fmt(struct file *file, void *priv, +static int rkvpu_s_capture_fmt(struct file *file, void *priv, struct v4l2_format *f) { - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv); + struct rkvpu_ctx *ctx = fh_to_rkvpu_ctx(priv); struct vb2_queue *vq; int ret; @@ -320,7 +320,7 @@ static int rkvdec_s_capture_fmt(struct file *file, void *priv, if (vb2_is_busy(vq)) return -EBUSY; - ret = rkvdec_try_capture_fmt(file, priv, f); + ret = rkvpu_try_capture_fmt(file, priv, f); if (ret) return ret; @@ -328,12 +328,12 @@ static int rkvdec_s_capture_fmt(struct file *file, void *priv, return 0; } -static int rkvdec_s_output_fmt(struct file *file, void *priv, +static int rkvpu_s_output_fmt(struct file *file, void *priv, struct v4l2_format *f) { - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv); + struct rkvpu_ctx *ctx = fh_to_rkvpu_ctx(priv); struct v4l2_m2m_ctx *m2m_ctx = ctx->fh.m2m_ctx; - const struct rkvdec_coded_fmt_desc *desc; + const struct rkvpu_coded_fmt_desc *desc; struct v4l2_format *cap_fmt; struct vb2_queue *peer_vq, *vq; int ret; @@ -358,11 +358,11 @@ static int rkvdec_s_output_fmt(struct file *file, void *priv, if (vb2_is_busy(peer_vq)) return -EBUSY; - ret = rkvdec_try_output_fmt(file, priv, f); + ret = rkvpu_try_output_fmt(file, priv, f); if (ret) return ret; - desc = rkvdec_find_coded_fmt_desc(f->fmt.pix_mp.pixelformat); + desc = rkvpu_find_coded_fmt_desc(f->fmt.pix_mp.pixelformat); if (!desc) return -EINVAL; ctx->coded_fmt_desc = desc; @@ -377,7 +377,7 @@ static int rkvdec_s_output_fmt(struct file *file, void *priv, * * Note that this will propagates any size changes to the decoded format. */ - rkvdec_reset_decoded_fmt(ctx); + rkvpu_reset_decoded_fmt(ctx); /* Propagate colorspace information to capture. */ cap_fmt = &ctx->decoded_fmt; @@ -392,38 +392,38 @@ static int rkvdec_s_output_fmt(struct file *file, void *priv, return 0; } -static int rkvdec_g_output_fmt(struct file *file, void *priv, +static int rkvpu_g_output_fmt(struct file *file, void *priv, struct v4l2_format *f) { - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv); + struct rkvpu_ctx *ctx = fh_to_rkvpu_ctx(priv); *f = ctx->coded_fmt; return 0; } -static int rkvdec_g_capture_fmt(struct file *file, void *priv, +static int rkvpu_g_capture_fmt(struct file *file, void *priv, struct v4l2_format *f) { - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv); + struct rkvpu_ctx *ctx = fh_to_rkvpu_ctx(priv); *f = ctx->decoded_fmt; return 0; } -static int rkvdec_enum_output_fmt(struct file *file, void *priv, +static int rkvpu_enum_output_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f) { - if (f->index >= ARRAY_SIZE(rkvdec_coded_fmts)) + if (f->index >= ARRAY_SIZE(rkvpu_coded_fmts)) return -EINVAL; - f->pixelformat = rkvdec_coded_fmts[f->index].fourcc; + f->pixelformat = rkvpu_coded_fmts[f->index].fourcc; return 0; } -static int rkvdec_enum_capture_fmt(struct file *file, void *priv, +static int rkvpu_enum_capture_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f) { - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(priv); + struct rkvpu_ctx *ctx = fh_to_rkvpu_ctx(priv); if (WARN_ON(!ctx->coded_fmt_desc)) return -EINVAL; @@ -435,18 +435,18 @@ static int rkvdec_enum_capture_fmt(struct file *file, void *priv, return 0; } -static const struct v4l2_ioctl_ops rkvdec_ioctl_ops = { - .vidioc_querycap = rkvdec_querycap, - .vidioc_enum_framesizes = rkvdec_enum_framesizes, +static const struct v4l2_ioctl_ops rkvpu_ioctl_ops = { + .vidioc_querycap = rkvpu_querycap, + .vidioc_enum_framesizes = rkvpu_enum_framesizes, - .vidioc_try_fmt_vid_cap_mplane = rkvdec_try_capture_fmt, - .vidioc_try_fmt_vid_out_mplane = rkvdec_try_output_fmt, - .vidioc_s_fmt_vid_out_mplane = rkvdec_s_output_fmt, - .vidioc_s_fmt_vid_cap_mplane = rkvdec_s_capture_fmt, - .vidioc_g_fmt_vid_out_mplane = rkvdec_g_output_fmt, - .vidioc_g_fmt_vid_cap_mplane = rkvdec_g_capture_fmt, - .vidioc_enum_fmt_vid_out = rkvdec_enum_output_fmt, - .vidioc_enum_fmt_vid_cap = rkvdec_enum_capture_fmt, + .vidioc_try_fmt_vid_cap_mplane = rkvpu_try_capture_fmt, + .vidioc_try_fmt_vid_out_mplane = rkvpu_try_output_fmt, + .vidioc_s_fmt_vid_out_mplane = rkvpu_s_output_fmt, + .vidioc_s_fmt_vid_cap_mplane = rkvpu_s_capture_fmt, + .vidioc_g_fmt_vid_out_mplane = rkvpu_g_output_fmt, + .vidioc_g_fmt_vid_cap_mplane = rkvpu_g_capture_fmt, + .vidioc_enum_fmt_vid_out = rkvpu_enum_output_fmt, + .vidioc_enum_fmt_vid_cap = rkvpu_enum_capture_fmt, .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs, .vidioc_querybuf = v4l2_m2m_ioctl_querybuf, @@ -463,11 +463,11 @@ static const struct v4l2_ioctl_ops rkvdec_ioctl_ops = { .vidioc_streamoff = v4l2_m2m_ioctl_streamoff, }; -static int rkvdec_queue_setup(struct vb2_queue *vq, unsigned int *num_buffers, +static int rkvpu_queue_setup(struct vb2_queue *vq, unsigned int *num_buffers, unsigned int *num_planes, unsigned int sizes[], struct device *alloc_devs[]) { - struct rkvdec_ctx *ctx = vb2_get_drv_priv(vq); + struct rkvpu_ctx *ctx = vb2_get_drv_priv(vq); struct v4l2_format *f; unsigned int i; @@ -493,10 +493,10 @@ static int rkvdec_queue_setup(struct vb2_queue *vq, unsigned int *num_buffers, return 0; } -static int rkvdec_buf_prepare(struct vb2_buffer *vb) +static int rkvpu_buf_prepare(struct vb2_buffer *vb) { struct vb2_queue *vq = vb->vb2_queue; - struct rkvdec_ctx *ctx = vb2_get_drv_priv(vq); + struct rkvpu_ctx *ctx = vb2_get_drv_priv(vq); struct v4l2_format *f; unsigned int i; @@ -523,15 +523,15 @@ static int rkvdec_buf_prepare(struct vb2_buffer *vb) return 0; } -static void rkvdec_buf_queue(struct vb2_buffer *vb) +static void rkvpu_buf_queue(struct vb2_buffer *vb) { - struct rkvdec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); + struct rkvpu_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); } -static int rkvdec_buf_out_validate(struct vb2_buffer *vb) +static int rkvpu_buf_out_validate(struct vb2_buffer *vb) { struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); @@ -539,17 +539,17 @@ static int rkvdec_buf_out_validate(struct vb2_buffer *vb) return 0; } -static void rkvdec_buf_request_complete(struct vb2_buffer *vb) +static void rkvpu_buf_request_complete(struct vb2_buffer *vb) { - struct rkvdec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); + struct rkvpu_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); v4l2_ctrl_request_complete(vb->req_obj.req, &ctx->ctrl_hdl); } -static int rkvdec_start_streaming(struct vb2_queue *q, unsigned int count) +static int rkvpu_start_streaming(struct vb2_queue *q, unsigned int count) { - struct rkvdec_ctx *ctx = vb2_get_drv_priv(q); - const struct rkvdec_coded_fmt_desc *desc; + struct rkvpu_ctx *ctx = vb2_get_drv_priv(q); + const struct rkvpu_coded_fmt_desc *desc; int ret; if (V4L2_TYPE_IS_CAPTURE(q->type)) @@ -568,9 +568,9 @@ static int rkvdec_start_streaming(struct vb2_queue *q, unsigned int count) return 0; } -static void rkvdec_queue_cleanup(struct vb2_queue *vq, u32 state) +static void rkvpu_queue_cleanup(struct vb2_queue *vq, u32 state) { - struct rkvdec_ctx *ctx = vb2_get_drv_priv(vq); + struct rkvpu_ctx *ctx = vb2_get_drv_priv(vq); while (true) { struct vb2_v4l2_buffer *vbuf; @@ -589,12 +589,12 @@ static void rkvdec_queue_cleanup(struct vb2_queue *vq, u32 state) } } -static void rkvdec_stop_streaming(struct vb2_queue *q) +static void rkvpu_stop_streaming(struct vb2_queue *q) { - struct rkvdec_ctx *ctx = vb2_get_drv_priv(q); + struct rkvpu_ctx *ctx = vb2_get_drv_priv(q); if (V4L2_TYPE_IS_OUTPUT(q->type)) { - const struct rkvdec_coded_fmt_desc *desc = ctx->coded_fmt_desc; + const struct rkvpu_coded_fmt_desc *desc = ctx->coded_fmt_desc; if (WARN_ON(!desc)) return; @@ -603,22 +603,22 @@ static void rkvdec_stop_streaming(struct vb2_queue *q) desc->ops->stop(ctx); } - rkvdec_queue_cleanup(q, VB2_BUF_STATE_ERROR); + rkvpu_queue_cleanup(q, VB2_BUF_STATE_ERROR); } -static const struct vb2_ops rkvdec_queue_ops = { - .queue_setup = rkvdec_queue_setup, - .buf_prepare = rkvdec_buf_prepare, - .buf_queue = rkvdec_buf_queue, - .buf_out_validate = rkvdec_buf_out_validate, - .buf_request_complete = rkvdec_buf_request_complete, - .start_streaming = rkvdec_start_streaming, - .stop_streaming = rkvdec_stop_streaming, +static const struct vb2_ops rkvpu_queue_ops = { + .queue_setup = rkvpu_queue_setup, + .buf_prepare = rkvpu_buf_prepare, + .buf_queue = rkvpu_buf_queue, + .buf_out_validate = rkvpu_buf_out_validate, + .buf_request_complete = rkvpu_buf_request_complete, + .start_streaming = rkvpu_start_streaming, + .stop_streaming = rkvpu_stop_streaming, .wait_prepare = vb2_ops_wait_prepare, .wait_finish = vb2_ops_wait_finish, }; -static int rkvdec_request_validate(struct media_request *req) +static int rkvpu_request_validate(struct media_request *req) { unsigned int count; @@ -631,12 +631,12 @@ static int rkvdec_request_validate(struct media_request *req) return vb2_request_validate(req); } -static const struct media_device_ops rkvdec_media_ops = { - .req_validate = rkvdec_request_validate, +static const struct media_device_ops rkvpu_media_ops = { + .req_validate = rkvpu_request_validate, .req_queue = v4l2_m2m_request_queue, }; -static void rkvdec_job_finish_no_pm(struct rkvdec_ctx *ctx, +static void rkvpu_job_finish_no_pm(struct rkvpu_ctx *ctx, enum vb2_buffer_state result) { if (ctx->coded_fmt_desc->ops->done) { @@ -651,17 +651,17 @@ static void rkvdec_job_finish_no_pm(struct rkvdec_ctx *ctx, result); } -static void rkvdec_job_finish(struct rkvdec_ctx *ctx, +static void rkvpu_job_finish(struct rkvpu_ctx *ctx, enum vb2_buffer_state result) { - struct rkvdec_dev *rkvdec = ctx->dev; + struct rkvpu_dev *rkvpu = ctx->dev; - pm_runtime_mark_last_busy(rkvdec->dev); - pm_runtime_put_autosuspend(rkvdec->dev); - rkvdec_job_finish_no_pm(ctx, result); + pm_runtime_mark_last_busy(rkvpu->dev); + pm_runtime_put_autosuspend(rkvpu->dev); + rkvpu_job_finish_no_pm(ctx, result); } -void rkvdec_run_preamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run) +void rkvpu_run_preamble(struct rkvpu_ctx *ctx, struct rkvpu_run *run) { struct media_request *src_req; @@ -678,7 +678,7 @@ void rkvdec_run_preamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run) v4l2_m2m_buf_copy_metadata(run->bufs.src, run->bufs.dst, true); } -void rkvdec_run_postamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run) +void rkvpu_run_postamble(struct rkvpu_ctx *ctx, struct rkvpu_run *run) { struct media_request *src_req = run->bufs.src->vb2_buf.req_obj.req; @@ -686,43 +686,43 @@ void rkvdec_run_postamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run) v4l2_ctrl_request_complete(src_req, &ctx->ctrl_hdl); } -static void rkvdec_device_run(void *priv) +static void rkvpu_device_run(void *priv) { - struct rkvdec_ctx *ctx = priv; - struct rkvdec_dev *rkvdec = ctx->dev; - const struct rkvdec_coded_fmt_desc *desc = ctx->coded_fmt_desc; + struct rkvpu_ctx *ctx = priv; + struct rkvpu_dev *rkvpu = ctx->dev; + const struct rkvpu_coded_fmt_desc *desc = ctx->coded_fmt_desc; int ret; if (WARN_ON(!desc)) return; - ret = pm_runtime_resume_and_get(rkvdec->dev); + ret = pm_runtime_resume_and_get(rkvpu->dev); if (ret < 0) { - rkvdec_job_finish_no_pm(ctx, VB2_BUF_STATE_ERROR); + rkvpu_job_finish_no_pm(ctx, VB2_BUF_STATE_ERROR); return; } ret = desc->ops->run(ctx); if (ret) - rkvdec_job_finish(ctx, VB2_BUF_STATE_ERROR); + rkvpu_job_finish(ctx, VB2_BUF_STATE_ERROR); } -static const struct v4l2_m2m_ops rkvdec_m2m_ops = { - .device_run = rkvdec_device_run, +static const struct v4l2_m2m_ops rkvpu_m2m_ops = { + .device_run = rkvpu_device_run, }; -static int rkvdec_queue_init(void *priv, +static int rkvpu_queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq) { - struct rkvdec_ctx *ctx = priv; - struct rkvdec_dev *rkvdec = ctx->dev; + struct rkvpu_ctx *ctx = priv; + struct rkvpu_dev *rkvpu = ctx->dev; int ret; src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; src_vq->io_modes = VB2_MMAP | VB2_DMABUF; src_vq->drv_priv = ctx; - src_vq->ops = &rkvdec_queue_ops; + src_vq->ops = &rkvpu_queue_ops; src_vq->mem_ops = &vb2_dma_contig_memops; /* @@ -734,8 +734,8 @@ static int rkvdec_queue_init(void *priv, DMA_ATTR_NO_KERNEL_MAPPING; src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; - src_vq->lock = &rkvdec->vdev_lock; - src_vq->dev = rkvdec->v4l2_dev.dev; + src_vq->lock = &rkvpu->vdev_lock; + src_vq->dev = rkvpu->v4l2_dev.dev; src_vq->supports_requests = true; src_vq->requires_requests = true; @@ -750,17 +750,17 @@ static int rkvdec_queue_init(void *priv, dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; dst_vq->io_modes = VB2_MMAP | VB2_DMABUF; dst_vq->drv_priv = ctx; - dst_vq->ops = &rkvdec_queue_ops; - dst_vq->buf_struct_size = sizeof(struct rkvdec_decoded_buffer); + dst_vq->ops = &rkvpu_queue_ops; + dst_vq->buf_struct_size = sizeof(struct rkvpu_decoded_buffer); dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; - dst_vq->lock = &rkvdec->vdev_lock; - dst_vq->dev = rkvdec->v4l2_dev.dev; + dst_vq->lock = &rkvpu->vdev_lock; + dst_vq->dev = rkvpu->v4l2_dev.dev; return vb2_queue_init(dst_vq); } -static int rkvdec_add_ctrls(struct rkvdec_ctx *ctx, - const struct rkvdec_ctrls *ctrls) +static int rkvpu_add_ctrls(struct rkvpu_ctx *ctx, + const struct rkvpu_ctrls *ctrls) { unsigned int i; @@ -775,18 +775,18 @@ static int rkvdec_add_ctrls(struct rkvdec_ctx *ctx, return 0; } -static int rkvdec_init_ctrls(struct rkvdec_ctx *ctx) +static int rkvpu_init_ctrls(struct rkvpu_ctx *ctx) { unsigned int i, nctrls = 0; int ret; - for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) - nctrls += rkvdec_coded_fmts[i].ctrls->num_ctrls; + for (i = 0; i < ARRAY_SIZE(rkvpu_coded_fmts); i++) + nctrls += rkvpu_coded_fmts[i].ctrls->num_ctrls; v4l2_ctrl_handler_init(&ctx->ctrl_hdl, nctrls); - for (i = 0; i < ARRAY_SIZE(rkvdec_coded_fmts); i++) { - ret = rkvdec_add_ctrls(ctx, rkvdec_coded_fmts[i].ctrls); + for (i = 0; i < ARRAY_SIZE(rkvpu_coded_fmts); i++) { + ret = rkvpu_add_ctrls(ctx, rkvpu_coded_fmts[i].ctrls); if (ret) goto err_free_handler; } @@ -803,27 +803,27 @@ err_free_handler: return ret; } -static int rkvdec_open(struct file *filp) +static int rkvpu_open(struct file *filp) { - struct rkvdec_dev *rkvdec = video_drvdata(filp); - struct rkvdec_ctx *ctx; + struct rkvpu_dev *rkvpu = video_drvdata(filp); + struct rkvpu_ctx *ctx; int ret; ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; - ctx->dev = rkvdec; - rkvdec_reset_coded_fmt(ctx); - rkvdec_reset_decoded_fmt(ctx); + ctx->dev = rkvpu; + rkvpu_reset_coded_fmt(ctx); + rkvpu_reset_decoded_fmt(ctx); v4l2_fh_init(&ctx->fh, video_devdata(filp)); - ret = rkvdec_init_ctrls(ctx); + ret = rkvpu_init_ctrls(ctx); if (ret) goto err_free_ctx; - ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(rkvdec->m2m_dev, ctx, - rkvdec_queue_init); + ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(rkvpu->m2m_dev, ctx, + rkvpu_queue_init); if (IS_ERR(ctx->fh.m2m_ctx)) { ret = PTR_ERR(ctx->fh.m2m_ctx); goto err_cleanup_ctrls; @@ -842,9 +842,9 @@ err_free_ctx: return ret; } -static int rkvdec_release(struct file *filp) +static int rkvpu_release(struct file *filp) { - struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(filp->private_data); + struct rkvpu_ctx *ctx = fh_to_rkvpu_ctx(filp->private_data); v4l2_fh_del(&ctx->fh); v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); @@ -855,176 +855,176 @@ static int rkvdec_release(struct file *filp) return 0; } -static const struct v4l2_file_operations rkvdec_fops = { +static const struct v4l2_file_operations rkvpu_fops = { .owner = THIS_MODULE, - .open = rkvdec_open, - .release = rkvdec_release, + .open = rkvpu_open, + .release = rkvpu_release, .poll = v4l2_m2m_fop_poll, .unlocked_ioctl = video_ioctl2, .mmap = v4l2_m2m_fop_mmap, }; -static int rkvdec_v4l2_init(struct rkvdec_dev *rkvdec) +static int rkvpu_v4l2_init(struct rkvpu_dev *rkvpu) { int ret; - ret = v4l2_device_register(rkvdec->dev, &rkvdec->v4l2_dev); + ret = v4l2_device_register(rkvpu->dev, &rkvpu->v4l2_dev); if (ret) { - dev_err(rkvdec->dev, "Failed to register V4L2 device\n"); + dev_err(rkvpu->dev, "Failed to register V4L2 device\n"); return ret; } - rkvdec->m2m_dev = v4l2_m2m_init(&rkvdec_m2m_ops); - if (IS_ERR(rkvdec->m2m_dev)) { - v4l2_err(&rkvdec->v4l2_dev, "Failed to init mem2mem device\n"); - ret = PTR_ERR(rkvdec->m2m_dev); + rkvpu->m2m_dev = v4l2_m2m_init(&rkvpu_m2m_ops); + if (IS_ERR(rkvpu->m2m_dev)) { + v4l2_err(&rkvpu->v4l2_dev, "Failed to init mem2mem device\n"); + ret = PTR_ERR(rkvpu->m2m_dev); goto err_unregister_v4l2; } - rkvdec->mdev.dev = rkvdec->dev; - strscpy(rkvdec->mdev.model, "rkvdec", sizeof(rkvdec->mdev.model)); - strscpy(rkvdec->mdev.bus_info, "platform:rkvdec", - sizeof(rkvdec->mdev.bus_info)); - media_device_init(&rkvdec->mdev); - rkvdec->mdev.ops = &rkvdec_media_ops; - rkvdec->v4l2_dev.mdev = &rkvdec->mdev; - - rkvdec->vdev.lock = &rkvdec->vdev_lock; - rkvdec->vdev.v4l2_dev = &rkvdec->v4l2_dev; - rkvdec->vdev.fops = &rkvdec_fops; - rkvdec->vdev.release = video_device_release_empty; - rkvdec->vdev.vfl_dir = VFL_DIR_M2M; - rkvdec->vdev.device_caps = V4L2_CAP_STREAMING | + rkvpu->mdev.dev = rkvpu->dev; + strscpy(rkvpu->mdev.model, "rkvpu", sizeof(rkvpu->mdev.model)); + strscpy(rkvpu->mdev.bus_info, "platform:rkvpu", + sizeof(rkvpu->mdev.bus_info)); + media_device_init(&rkvpu->mdev); + rkvpu->mdev.ops = &rkvpu_media_ops; + rkvpu->v4l2_dev.mdev = &rkvpu->mdev; + + rkvpu->vdev.lock = &rkvpu->vdev_lock; + rkvpu->vdev.v4l2_dev = &rkvpu->v4l2_dev; + rkvpu->vdev.fops = &rkvpu_fops; + rkvpu->vdev.release = video_device_release_empty; + rkvpu->vdev.vfl_dir = VFL_DIR_M2M; + rkvpu->vdev.device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M_MPLANE; - rkvdec->vdev.ioctl_ops = &rkvdec_ioctl_ops; - video_set_drvdata(&rkvdec->vdev, rkvdec); - strscpy(rkvdec->vdev.name, "rkvdec", sizeof(rkvdec->vdev.name)); + rkvpu->vdev.ioctl_ops = &rkvpu_ioctl_ops; + video_set_drvdata(&rkvpu->vdev, rkvpu); + strscpy(rkvpu->vdev.name, "rkvpu", sizeof(rkvpu->vdev.name)); - ret = video_register_device(&rkvdec->vdev, VFL_TYPE_VIDEO, -1); + ret = video_register_device(&rkvpu->vdev, VFL_TYPE_VIDEO, -1); if (ret) { - v4l2_err(&rkvdec->v4l2_dev, "Failed to register video device\n"); + v4l2_err(&rkvpu->v4l2_dev, "Failed to register video device\n"); goto err_cleanup_mc; } - ret = v4l2_m2m_register_media_controller(rkvdec->m2m_dev, &rkvdec->vdev, + ret = v4l2_m2m_register_media_controller(rkvpu->m2m_dev, &rkvpu->vdev, MEDIA_ENT_F_PROC_VIDEO_DECODER); if (ret) { - v4l2_err(&rkvdec->v4l2_dev, + v4l2_err(&rkvpu->v4l2_dev, "Failed to initialize V4L2 M2M media controller\n"); goto err_unregister_vdev; } - ret = media_device_register(&rkvdec->mdev); + ret = media_device_register(&rkvpu->mdev); if (ret) { - v4l2_err(&rkvdec->v4l2_dev, "Failed to register media device\n"); + v4l2_err(&rkvpu->v4l2_dev, "Failed to register media device\n"); goto err_unregister_mc; } return 0; err_unregister_mc: - v4l2_m2m_unregister_media_controller(rkvdec->m2m_dev); + v4l2_m2m_unregister_media_controller(rkvpu->m2m_dev); err_unregister_vdev: - video_unregister_device(&rkvdec->vdev); + video_unregister_device(&rkvpu->vdev); err_cleanup_mc: - media_device_cleanup(&rkvdec->mdev); - v4l2_m2m_release(rkvdec->m2m_dev); + media_device_cleanup(&rkvpu->mdev); + v4l2_m2m_release(rkvpu->m2m_dev); err_unregister_v4l2: - v4l2_device_unregister(&rkvdec->v4l2_dev); + v4l2_device_unregister(&rkvpu->v4l2_dev); return ret; } -static void rkvdec_v4l2_cleanup(struct rkvdec_dev *rkvdec) +static void rkvpu_v4l2_cleanup(struct rkvpu_dev *rkvpu) { - media_device_unregister(&rkvdec->mdev); - v4l2_m2m_unregister_media_controller(rkvdec->m2m_dev); - video_unregister_device(&rkvdec->vdev); - media_device_cleanup(&rkvdec->mdev); - v4l2_m2m_release(rkvdec->m2m_dev); - v4l2_device_unregister(&rkvdec->v4l2_dev); + media_device_unregister(&rkvpu->mdev); + v4l2_m2m_unregister_media_controller(rkvpu->m2m_dev); + video_unregister_device(&rkvpu->vdev); + media_device_cleanup(&rkvpu->mdev); + v4l2_m2m_release(rkvpu->m2m_dev); + v4l2_device_unregister(&rkvpu->v4l2_dev); } -static irqreturn_t rkvdec_irq_handler(int irq, void *priv) +static irqreturn_t rkvpu_irq_handler(int irq, void *priv) { - struct rkvdec_dev *rkvdec = priv; + struct rkvpu_dev *rkvpu = priv; enum vb2_buffer_state state; u32 status; - status = readl(rkvdec->regs + RKVDEC_REG_INTERRUPT); + status = readl(rkvpu->regs + RKVDEC_REG_INTERRUPT); state = (status & RKVDEC_RDY_STA) ? VB2_BUF_STATE_DONE : VB2_BUF_STATE_ERROR; - writel(0, rkvdec->regs + RKVDEC_REG_INTERRUPT); - if (cancel_delayed_work(&rkvdec->watchdog_work)) { - struct rkvdec_ctx *ctx; + writel(0, rkvpu->regs + RKVDEC_REG_INTERRUPT); + if (cancel_delayed_work(&rkvpu->watchdog_work)) { + struct rkvpu_ctx *ctx; - ctx = v4l2_m2m_get_curr_priv(rkvdec->m2m_dev); - rkvdec_job_finish(ctx, state); + ctx = v4l2_m2m_get_curr_priv(rkvpu->m2m_dev); + rkvpu_job_finish(ctx, state); } return IRQ_HANDLED; } -static void rkvdec_watchdog_func(struct work_struct *work) +static void rkvpu_watchdog_func(struct work_struct *work) { - struct rkvdec_dev *rkvdec; - struct rkvdec_ctx *ctx; + struct rkvpu_dev *rkvpu; + struct rkvpu_ctx *ctx; - rkvdec = container_of(to_delayed_work(work), struct rkvdec_dev, + rkvpu = container_of(to_delayed_work(work), struct rkvpu_dev, watchdog_work); - ctx = v4l2_m2m_get_curr_priv(rkvdec->m2m_dev); + ctx = v4l2_m2m_get_curr_priv(rkvpu->m2m_dev); if (ctx) { - dev_err(rkvdec->dev, "Frame processing timed out!\n"); - writel(RKVDEC_IRQ_DIS, rkvdec->regs + RKVDEC_REG_INTERRUPT); - writel(0, rkvdec->regs + RKVDEC_REG_SYSCTRL); - rkvdec_job_finish(ctx, VB2_BUF_STATE_ERROR); + dev_err(rkvpu->dev, "Frame processing timed out!\n"); + writel(RKVDEC_IRQ_DIS, rkvpu->regs + RKVDEC_REG_INTERRUPT); + writel(0, rkvpu->regs + RKVDEC_REG_SYSCTRL); + rkvpu_job_finish(ctx, VB2_BUF_STATE_ERROR); } } -static const struct of_device_id of_rkvdec_match[] = { +static const struct of_device_id of_rkvpu_match[] = { { .compatible = "rockchip,rk3399-vdec" }, { /* sentinel */ } }; -MODULE_DEVICE_TABLE(of, of_rkvdec_match); +MODULE_DEVICE_TABLE(of, of_rkvpu_match); -static const char * const rkvdec_clk_names[] = { +static const char * const rkvpu_clk_names[] = { "axi", "ahb", "cabac", "core" }; -static int rkvdec_probe(struct platform_device *pdev) +static int rkvpu_probe(struct platform_device *pdev) { - struct rkvdec_dev *rkvdec; + struct rkvpu_dev *rkvpu; unsigned int i; int ret, irq; - rkvdec = devm_kzalloc(&pdev->dev, sizeof(*rkvdec), GFP_KERNEL); - if (!rkvdec) + rkvpu = devm_kzalloc(&pdev->dev, sizeof(*rkvpu), GFP_KERNEL); + if (!rkvpu) return -ENOMEM; - platform_set_drvdata(pdev, rkvdec); - rkvdec->dev = &pdev->dev; - mutex_init(&rkvdec->vdev_lock); - INIT_DELAYED_WORK(&rkvdec->watchdog_work, rkvdec_watchdog_func); + platform_set_drvdata(pdev, rkvpu); + rkvpu->dev = &pdev->dev; + mutex_init(&rkvpu->vdev_lock); + INIT_DELAYED_WORK(&rkvpu->watchdog_work, rkvpu_watchdog_func); - rkvdec->clocks = devm_kcalloc(&pdev->dev, ARRAY_SIZE(rkvdec_clk_names), - sizeof(*rkvdec->clocks), GFP_KERNEL); - if (!rkvdec->clocks) + rkvpu->clocks = devm_kcalloc(&pdev->dev, ARRAY_SIZE(rkvpu_clk_names), + sizeof(*rkvpu->clocks), GFP_KERNEL); + if (!rkvpu->clocks) return -ENOMEM; - for (i = 0; i < ARRAY_SIZE(rkvdec_clk_names); i++) - rkvdec->clocks[i].id = rkvdec_clk_names[i]; + for (i = 0; i < ARRAY_SIZE(rkvpu_clk_names); i++) + rkvpu->clocks[i].id = rkvpu_clk_names[i]; - ret = devm_clk_bulk_get(&pdev->dev, ARRAY_SIZE(rkvdec_clk_names), - rkvdec->clocks); + ret = devm_clk_bulk_get(&pdev->dev, ARRAY_SIZE(rkvpu_clk_names), + rkvpu->clocks); if (ret) return ret; - rkvdec->regs = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(rkvdec->regs)) - return PTR_ERR(rkvdec->regs); + rkvpu->regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(rkvpu->regs)) + return PTR_ERR(rkvpu->regs); ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); if (ret) { @@ -1039,8 +1039,8 @@ static int rkvdec_probe(struct platform_device *pdev) return -ENXIO; ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, - rkvdec_irq_handler, IRQF_ONESHOT, - dev_name(&pdev->dev), rkvdec); + rkvpu_irq_handler, IRQF_ONESHOT, + dev_name(&pdev->dev), rkvpu); if (ret) { dev_err(&pdev->dev, "Could not request vdec IRQ\n"); return ret; @@ -1050,7 +1050,7 @@ static int rkvdec_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); - ret = rkvdec_v4l2_init(rkvdec); + ret = rkvpu_v4l2_init(rkvpu); if (ret) goto err_disable_runtime_pm; @@ -1062,51 +1062,51 @@ err_disable_runtime_pm: return ret; } -static int rkvdec_remove(struct platform_device *pdev) +static int rkvpu_remove(struct platform_device *pdev) { - struct rkvdec_dev *rkvdec = platform_get_drvdata(pdev); + struct rkvpu_dev *rkvpu = platform_get_drvdata(pdev); - rkvdec_v4l2_cleanup(rkvdec); + rkvpu_v4l2_cleanup(rkvpu); pm_runtime_disable(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); return 0; } #ifdef CONFIG_PM -static int rkvdec_runtime_resume(struct device *dev) +static int rkvpu_runtime_resume(struct device *dev) { - struct rkvdec_dev *rkvdec = dev_get_drvdata(dev); + struct rkvpu_dev *rkvpu = dev_get_drvdata(dev); - return clk_bulk_prepare_enable(ARRAY_SIZE(rkvdec_clk_names), - rkvdec->clocks); + return clk_bulk_prepare_enable(ARRAY_SIZE(rkvpu_clk_names), + rkvpu->clocks); } -static int rkvdec_runtime_suspend(struct device *dev) +static int rkvpu_runtime_suspend(struct device *dev) { - struct rkvdec_dev *rkvdec = dev_get_drvdata(dev); + struct rkvpu_dev *rkvpu = dev_get_drvdata(dev); - clk_bulk_disable_unprepare(ARRAY_SIZE(rkvdec_clk_names), - rkvdec->clocks); + clk_bulk_disable_unprepare(ARRAY_SIZE(rkvpu_clk_names), + rkvpu->clocks); return 0; } #endif -static const struct dev_pm_ops rkvdec_pm_ops = { +static const struct dev_pm_ops rkvpu_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) - SET_RUNTIME_PM_OPS(rkvdec_runtime_suspend, rkvdec_runtime_resume, NULL) + SET_RUNTIME_PM_OPS(rkvpu_runtime_suspend, rkvpu_runtime_resume, NULL) }; -static struct platform_driver rkvdec_driver = { - .probe = rkvdec_probe, - .remove = rkvdec_remove, +static struct platform_driver rkvpu_driver = { + .probe = rkvpu_probe, + .remove = rkvpu_remove, .driver = { - .name = "rkvdec", - .of_match_table = of_rkvdec_match, - .pm = &rkvdec_pm_ops, + .name = "rkvpu", + .of_match_table = of_rkvpu_match, + .pm = &rkvpu_pm_ops, }, }; -module_platform_driver(rkvdec_driver); +module_platform_driver(rkvpu_driver); MODULE_AUTHOR("Boris Brezillon <boris.brezillon@collabora.com>"); MODULE_DESCRIPTION("Rockchip Video Decoder driver"); diff --git a/drivers/staging/media/rkvdec/rkvdec.h b/drivers/staging/media/rkvdec/rkvpu.h index 633335ebb9c498..9e237c3c6942a9 100644 --- a/drivers/staging/media/rkvdec/rkvdec.h +++ b/drivers/staging/media/rkvdec/rkvpu.h @@ -4,7 +4,7 @@ * * Copyright (C) 2019 Collabora, Ltd. * - * Based on rkvdec driver by Google LLC. (Tomasz Figa <tfiga@chromium.org>) + * Based on rkvpu driver by Google LLC. (Tomasz Figa <tfiga@chromium.org>) * Based on s5p-mfc driver by Samsung Electronics Co., Ltd. * Copyright (C) 2011 Samsung Electronics Co., Ltd. */ @@ -22,70 +22,70 @@ #include <media/videobuf2-core.h> #include <media/videobuf2-dma-contig.h> -struct rkvdec_ctx; +struct rkvpu_ctx; -struct rkvdec_ctrl_desc { +struct rkvpu_ctrl_desc { struct v4l2_ctrl_config cfg; }; -struct rkvdec_ctrls { - const struct rkvdec_ctrl_desc *ctrls; +struct rkvpu_ctrls { + const struct rkvpu_ctrl_desc *ctrls; unsigned int num_ctrls; }; -struct rkvdec_run { +struct rkvpu_run { struct { struct vb2_v4l2_buffer *src; struct vb2_v4l2_buffer *dst; } bufs; }; -struct rkvdec_vp9_decoded_buffer_info { +struct rkvpu_vp9_decoded_buffer_info { /* Info needed when the decoded frame serves as a reference frame. */ unsigned short width; unsigned short height; unsigned int bit_depth : 4; }; -struct rkvdec_decoded_buffer { +struct rkvpu_decoded_buffer { /* Must be the first field in this struct. */ struct v4l2_m2m_buffer base; union { - struct rkvdec_vp9_decoded_buffer_info vp9; + struct rkvpu_vp9_decoded_buffer_info vp9; }; }; -static inline struct rkvdec_decoded_buffer * -vb2_to_rkvdec_decoded_buf(struct vb2_buffer *buf) +static inline struct rkvpu_decoded_buffer * +vb2_to_rkvpu_decoded_buf(struct vb2_buffer *buf) { - return container_of(buf, struct rkvdec_decoded_buffer, + return container_of(buf, struct rkvpu_decoded_buffer, base.vb.vb2_buf); } -struct rkvdec_coded_fmt_ops { - int (*adjust_fmt)(struct rkvdec_ctx *ctx, +struct rkvpu_coded_fmt_ops { + int (*adjust_fmt)(struct rkvpu_ctx *ctx, struct v4l2_format *f); - int (*start)(struct rkvdec_ctx *ctx); - void (*stop)(struct rkvdec_ctx *ctx); - int (*run)(struct rkvdec_ctx *ctx); - void (*done)(struct rkvdec_ctx *ctx, struct vb2_v4l2_buffer *src_buf, + int (*start)(struct rkvpu_ctx *ctx); + void (*stop)(struct rkvpu_ctx *ctx); + int (*run)(struct rkvpu_ctx *ctx); + void (*done)(struct rkvpu_ctx *ctx, struct vb2_v4l2_buffer *src_buf, struct vb2_v4l2_buffer *dst_buf, enum vb2_buffer_state result); - int (*try_ctrl)(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl); + int (*try_ctrl)(struct rkvpu_ctx *ctx, struct v4l2_ctrl *ctrl); }; -struct rkvdec_coded_fmt_desc { +struct rkvpu_coded_fmt_desc { u32 fourcc; struct v4l2_frmsize_stepwise frmsize; - const struct rkvdec_ctrls *ctrls; - const struct rkvdec_coded_fmt_ops *ops; + const struct rkvpu_ctrls *ctrls; + const struct rkvpu_coded_fmt_ops *ops; unsigned int num_decoded_fmts; const u32 *decoded_fmts; u32 subsystem_flags; }; -struct rkvdec_dev { +struct rkvpu_dev { struct v4l2_device v4l2_dev; struct media_device mdev; struct video_device vdev; @@ -97,31 +97,31 @@ struct rkvdec_dev { struct delayed_work watchdog_work; }; -struct rkvdec_ctx { +struct rkvpu_ctx { struct v4l2_fh fh; struct v4l2_format coded_fmt; struct v4l2_format decoded_fmt; - const struct rkvdec_coded_fmt_desc *coded_fmt_desc; + const struct rkvpu_coded_fmt_desc *coded_fmt_desc; struct v4l2_ctrl_handler ctrl_hdl; - struct rkvdec_dev *dev; + struct rkvpu_dev *dev; void *priv; }; -static inline struct rkvdec_ctx *fh_to_rkvdec_ctx(struct v4l2_fh *fh) +static inline struct rkvpu_ctx *fh_to_rkvpu_ctx(struct v4l2_fh *fh) { - return container_of(fh, struct rkvdec_ctx, fh); + return container_of(fh, struct rkvpu_ctx, fh); } -struct rkvdec_aux_buf { +struct rkvpu_aux_buf { void *cpu; dma_addr_t dma; size_t size; }; -void rkvdec_run_preamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run); -void rkvdec_run_postamble(struct rkvdec_ctx *ctx, struct rkvdec_run *run); +void rkvpu_run_preamble(struct rkvpu_ctx *ctx, struct rkvpu_run *run); +void rkvpu_run_postamble(struct rkvpu_ctx *ctx, struct rkvpu_run *run); -extern const struct rkvdec_coded_fmt_ops rkvdec_h264_fmt_ops; -extern const struct rkvdec_coded_fmt_ops rkvdec_vp9_fmt_ops; +extern const struct rkvpu_coded_fmt_ops rkvdec_h264_fmt_ops; +extern const struct rkvpu_coded_fmt_ops rkvdec_vp9_fmt_ops; #endif /* RKVDEC_H_ */ |