Skip to content

Commit bdd0340

Browse files
RockchipWindowsTeammchehab
authored andcommitted
media: hantro: Add support for VP8 decoding on rk3288
Introduce VP8 decoding support in RK3288. Signed-off-by: ZhiChao Yu <[email protected]> Signed-off-by: Tomasz Figa <[email protected]> Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Ezequiel Garcia <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 298c62d commit bdd0340

File tree

8 files changed

+789
-2
lines changed

8 files changed

+789
-2
lines changed

drivers/staging/media/hantro/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ hantro-vpu-y += \
55
hantro_v4l2.o \
66
hantro_h1_jpeg_enc.o \
77
hantro_g1_mpeg2_dec.o \
8+
hantro_g1_vp8_dec.o \
89
rk3399_vpu_hw_jpeg_enc.o \
910
rk3399_vpu_hw_mpeg2_dec.o \
1011
hantro_jpeg.o \
11-
hantro_mpeg2.o
12+
hantro_mpeg2.o \
13+
hantro_vp8.o
1214

1315
hantro-vpu-$(CONFIG_VIDEO_HANTRO_ROCKCHIP) += \
1416
rk3288_vpu_hw.o \

drivers/staging/media/hantro/hantro.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525

2626
#include "hantro_hw.h"
2727

28+
#define VP8_MB_DIM 16
29+
#define VP8_MB_WIDTH(w) DIV_ROUND_UP(w, VP8_MB_DIM)
30+
#define VP8_MB_HEIGHT(h) DIV_ROUND_UP(h, VP8_MB_DIM)
31+
2832
#define MPEG2_MB_DIM 16
2933
#define MPEG2_MB_WIDTH(w) DIV_ROUND_UP(w, MPEG2_MB_DIM)
3034
#define MPEG2_MB_HEIGHT(h) DIV_ROUND_UP(h, MPEG2_MB_DIM)
@@ -40,6 +44,7 @@ struct hantro_codec_ops;
4044
#define HANTRO_ENCODERS 0x0000ffff
4145

4246
#define HANTRO_MPEG2_DECODER BIT(16)
47+
#define HANTRO_VP8_DECODER BIT(17)
4348
#define HANTRO_DECODERS 0xffff0000
4449

4550
/**
@@ -97,11 +102,13 @@ struct hantro_variant {
97102
* @HANTRO_MODE_NONE: No operating mode. Used for RAW video formats.
98103
* @HANTRO_MODE_JPEG_ENC: JPEG encoder.
99104
* @HANTRO_MODE_MPEG2_DEC: MPEG-2 decoder.
105+
* @HANTRO_MODE_VP8_DEC: VP8 decoder.
100106
*/
101107
enum hantro_codec_mode {
102108
HANTRO_MODE_NONE = -1,
103109
HANTRO_MODE_JPEG_ENC,
104110
HANTRO_MODE_MPEG2_DEC,
111+
HANTRO_MODE_VP8_DEC,
105112
};
106113

107114
/*
@@ -215,6 +222,7 @@ struct hantro_dev {
215222
* @codec_ops: Set of operations related to codec mode.
216223
* @jpeg_enc: JPEG-encoding context.
217224
* @mpeg2_dec: MPEG-2-decoding context.
225+
* @vp8_dec: VP8-decoding context.
218226
*/
219227
struct hantro_ctx {
220228
struct hantro_dev *dev;
@@ -241,6 +249,7 @@ struct hantro_ctx {
241249
union {
242250
struct hantro_jpeg_enc_hw_ctx jpeg_enc;
243251
struct hantro_mpeg2_dec_hw_ctx mpeg2_dec;
252+
struct hantro_vp8_dec_hw_ctx vp8_dec;
244253
};
245254
};
246255

@@ -265,6 +274,12 @@ struct hantro_fmt {
265274
struct v4l2_frmsize_stepwise frmsize;
266275
};
267276

277+
struct hantro_reg {
278+
u32 base;
279+
u32 shift;
280+
u32 mask;
281+
};
282+
268283
/* Logging helpers */
269284

270285
/**
@@ -343,6 +358,18 @@ static inline u32 vdpu_read(struct hantro_dev *vpu, u32 reg)
343358
return val;
344359
}
345360

361+
static inline void hantro_reg_write(struct hantro_dev *vpu,
362+
const struct hantro_reg *reg,
363+
u32 val)
364+
{
365+
u32 v;
366+
367+
v = vdpu_read(vpu, reg->base);
368+
v &= ~(reg->mask << reg->shift);
369+
v |= ((val & reg->mask) << reg->shift);
370+
vdpu_write_relaxed(vpu, v, reg->base);
371+
}
372+
346373
bool hantro_is_encoder_ctx(const struct hantro_ctx *ctx);
347374

348375
void *hantro_get_ctrl(struct hantro_ctx *ctx, u32 id);

drivers/staging/media/hantro/hantro_drv.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ static struct hantro_ctrl controls[] = {
284284
.cfg = {
285285
.elem_size = sizeof(struct v4l2_ctrl_mpeg2_quantization),
286286
},
287+
}, {
288+
.id = V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER,
289+
.codec = HANTRO_VP8_DECODER,
290+
.cfg = {
291+
.elem_size = sizeof(struct v4l2_ctrl_vp8_frame_header),
292+
},
287293
},
288294
};
289295

0 commit comments

Comments
 (0)