Commit 879dee56 authored by Jonas Karlman's avatar Jonas Karlman Committed by Mauro Carvalho Chehab

media: rockchip/vpu: Add MPEG2 decoding support to RK3399

Add the necessary bits to support MPEG2 decoding on RK3399.
Signed-off-by: default avatarJonas Karlman <jonas@kwiboo.se>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 7cdedc3f
...@@ -8,5 +8,6 @@ rockchip-vpu-y += \ ...@@ -8,5 +8,6 @@ rockchip-vpu-y += \
rk3288_vpu_hw_jpeg_enc.o \ rk3288_vpu_hw_jpeg_enc.o \
rk3399_vpu_hw.o \ rk3399_vpu_hw.o \
rk3399_vpu_hw_jpeg_enc.o \ rk3399_vpu_hw_jpeg_enc.o \
rk3399_vpu_hw_mpeg2_dec.o \
rockchip_vpu_jpeg.o \ rockchip_vpu_jpeg.o \
rockchip_vpu_mpeg2.o rockchip_vpu_mpeg2.o
...@@ -55,6 +55,26 @@ static const struct rockchip_vpu_fmt rk3399_vpu_enc_fmts[] = { ...@@ -55,6 +55,26 @@ static const struct rockchip_vpu_fmt rk3399_vpu_enc_fmts[] = {
}, },
}; };
static const struct rockchip_vpu_fmt rk3399_vpu_dec_fmts[] = {
{
.fourcc = V4L2_PIX_FMT_NV12,
.codec_mode = RK_VPU_MODE_NONE,
},
{
.fourcc = V4L2_PIX_FMT_MPEG2_SLICE,
.codec_mode = RK_VPU_MODE_MPEG2_DEC,
.max_depth = 2,
.frmsize = {
.min_width = 48,
.max_width = 1920,
.step_width = MPEG2_MB_DIM,
.min_height = 48,
.max_height = 1088,
.step_height = MPEG2_MB_DIM,
},
},
};
static irqreturn_t rk3399_vepu_irq(int irq, void *dev_id) static irqreturn_t rk3399_vepu_irq(int irq, void *dev_id)
{ {
struct rockchip_vpu_dev *vpu = dev_id; struct rockchip_vpu_dev *vpu = dev_id;
...@@ -74,6 +94,24 @@ static irqreturn_t rk3399_vepu_irq(int irq, void *dev_id) ...@@ -74,6 +94,24 @@ static irqreturn_t rk3399_vepu_irq(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static irqreturn_t rk3399_vdpu_irq(int irq, void *dev_id)
{
struct rockchip_vpu_dev *vpu = dev_id;
enum vb2_buffer_state state;
u32 status;
status = vdpu_read(vpu, VDPU_REG_INTERRUPT);
state = (status & VDPU_REG_INTERRUPT_DEC_IRQ) ?
VB2_BUF_STATE_DONE : VB2_BUF_STATE_ERROR;
vdpu_write(vpu, 0, VDPU_REG_INTERRUPT);
vdpu_write(vpu, 0, VDPU_REG_AXI_CTRL);
rockchip_vpu_irq_done(vpu, 0, state);
return IRQ_HANDLED;
}
static int rk3399_vpu_hw_init(struct rockchip_vpu_dev *vpu) static int rk3399_vpu_hw_init(struct rockchip_vpu_dev *vpu)
{ {
/* Bump ACLK to max. possible freq. to improve performance. */ /* Bump ACLK to max. possible freq. to improve performance. */
...@@ -90,6 +128,15 @@ static void rk3399_vpu_enc_reset(struct rockchip_vpu_ctx *ctx) ...@@ -90,6 +128,15 @@ static void rk3399_vpu_enc_reset(struct rockchip_vpu_ctx *ctx)
vepu_write(vpu, 0, VEPU_REG_AXI_CTRL); vepu_write(vpu, 0, VEPU_REG_AXI_CTRL);
} }
static void rk3399_vpu_dec_reset(struct rockchip_vpu_ctx *ctx)
{
struct rockchip_vpu_dev *vpu = ctx->dev;
vdpu_write(vpu, VDPU_REG_INTERRUPT_DEC_IRQ_DIS, VDPU_REG_INTERRUPT);
vdpu_write(vpu, 0, VDPU_REG_EN_FLAGS);
vdpu_write(vpu, 1, VDPU_REG_SOFT_RESET);
}
/* /*
* Supported codec ops. * Supported codec ops.
*/ */
...@@ -101,6 +148,12 @@ static const struct rockchip_vpu_codec_ops rk3399_vpu_codec_ops[] = { ...@@ -101,6 +148,12 @@ static const struct rockchip_vpu_codec_ops rk3399_vpu_codec_ops[] = {
.init = rockchip_vpu_jpeg_enc_init, .init = rockchip_vpu_jpeg_enc_init,
.exit = rockchip_vpu_jpeg_enc_exit, .exit = rockchip_vpu_jpeg_enc_exit,
}, },
[RK_VPU_MODE_MPEG2_DEC] = {
.run = rk3399_vpu_mpeg2_dec_run,
.reset = rk3399_vpu_dec_reset,
.init = rockchip_vpu_mpeg2_dec_init,
.exit = rockchip_vpu_mpeg2_dec_exit,
},
}; };
/* /*
...@@ -111,9 +164,13 @@ const struct rockchip_vpu_variant rk3399_vpu_variant = { ...@@ -111,9 +164,13 @@ const struct rockchip_vpu_variant rk3399_vpu_variant = {
.enc_offset = 0x0, .enc_offset = 0x0,
.enc_fmts = rk3399_vpu_enc_fmts, .enc_fmts = rk3399_vpu_enc_fmts,
.num_enc_fmts = ARRAY_SIZE(rk3399_vpu_enc_fmts), .num_enc_fmts = ARRAY_SIZE(rk3399_vpu_enc_fmts),
.codec = RK_VPU_JPEG_ENCODER, .dec_offset = 0x400,
.dec_fmts = rk3399_vpu_dec_fmts,
.num_dec_fmts = ARRAY_SIZE(rk3399_vpu_dec_fmts),
.codec = RK_VPU_JPEG_ENCODER | RK_VPU_MPEG2_DECODER,
.codec_ops = rk3399_vpu_codec_ops, .codec_ops = rk3399_vpu_codec_ops,
.vepu_irq = rk3399_vepu_irq, .vepu_irq = rk3399_vepu_irq,
.vdpu_irq = rk3399_vdpu_irq,
.init = rk3399_vpu_hw_init, .init = rk3399_vpu_hw_init,
.clk_names = {"aclk", "hclk"}, .clk_names = {"aclk", "hclk"},
.num_clocks = 2 .num_clocks = 2
......
This diff is collapsed.
...@@ -92,6 +92,7 @@ void rk3399_vpu_jpeg_enc_run(struct rockchip_vpu_ctx *ctx); ...@@ -92,6 +92,7 @@ void rk3399_vpu_jpeg_enc_run(struct rockchip_vpu_ctx *ctx);
int rockchip_vpu_jpeg_enc_init(struct rockchip_vpu_ctx *ctx); int rockchip_vpu_jpeg_enc_init(struct rockchip_vpu_ctx *ctx);
void rockchip_vpu_jpeg_enc_exit(struct rockchip_vpu_ctx *ctx); void rockchip_vpu_jpeg_enc_exit(struct rockchip_vpu_ctx *ctx);
void rk3399_vpu_mpeg2_dec_run(struct rockchip_vpu_ctx *ctx);
void rockchip_vpu_mpeg2_dec_copy_qtable(u8 *qtable, void rockchip_vpu_mpeg2_dec_copy_qtable(u8 *qtable,
const struct v4l2_ctrl_mpeg2_quantization *ctrl); const struct v4l2_ctrl_mpeg2_quantization *ctrl);
int rockchip_vpu_mpeg2_dec_init(struct rockchip_vpu_ctx *ctx); int rockchip_vpu_mpeg2_dec_init(struct rockchip_vpu_ctx *ctx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment