1 // SPDX-License-Identifier: GPL-2.0
3 * Hantro VPU codec driver
5 * Copyright (C) 2018 Rockchip Electronics Co., Ltd.
10 static const u8 zigzag[64] = {
11 0, 1, 8, 16, 9, 2, 3, 10,
12 17, 24, 32, 25, 18, 11, 4, 5,
13 12, 19, 26, 33, 40, 48, 41, 34,
14 27, 20, 13, 6, 7, 14, 21, 28,
15 35, 42, 49, 56, 57, 50, 43, 36,
16 29, 22, 15, 23, 30, 37, 44, 51,
17 58, 59, 52, 45, 38, 31, 39, 46,
18 53, 60, 61, 54, 47, 55, 62, 63
21 void hantro_mpeg2_dec_copy_qtable(u8 *qtable,
22 const struct v4l2_ctrl_mpeg2_quantisation *ctrl)
29 for (i = 0; i < ARRAY_SIZE(zigzag); i++) {
31 qtable[n + 0] = ctrl->intra_quantiser_matrix[i];
32 qtable[n + 64] = ctrl->non_intra_quantiser_matrix[i];
33 qtable[n + 128] = ctrl->chroma_intra_quantiser_matrix[i];
34 qtable[n + 192] = ctrl->chroma_non_intra_quantiser_matrix[i];
38 int hantro_mpeg2_dec_init(struct hantro_ctx *ctx)
40 struct hantro_dev *vpu = ctx->dev;
42 ctx->mpeg2_dec.qtable.size = ARRAY_SIZE(zigzag) * 4;
43 ctx->mpeg2_dec.qtable.cpu =
44 dma_alloc_coherent(vpu->dev,
45 ctx->mpeg2_dec.qtable.size,
46 &ctx->mpeg2_dec.qtable.dma,
48 if (!ctx->mpeg2_dec.qtable.cpu)
53 void hantro_mpeg2_dec_exit(struct hantro_ctx *ctx)
55 struct hantro_dev *vpu = ctx->dev;
57 dma_free_coherent(vpu->dev,
58 ctx->mpeg2_dec.qtable.size,
59 ctx->mpeg2_dec.qtable.cpu,
60 ctx->mpeg2_dec.qtable.dma);