summaryrefslogtreecommitdiff
path: root/drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c
diff options
context:
space:
mode:
authorAndrzej Pietrasiewicz <andrzej.p@collabora.com>2020-01-27 17:30:08 +0300
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-02-24 19:19:32 +0300
commit85bdcb7eaae7c39dba9420de6df1cb227cf05732 (patch)
tree8311278427882eccf6ef96e1de4f145ba0319901 /drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c
parent801fccf48940c6733aad922f7b9e81f6d7f84cf6 (diff)
downloadlinux-85bdcb7eaae7c39dba9420de6df1cb227cf05732.tar.xz
media: hantro: Write the quantization tables in proper order
The quantization tables as defined in the file (luma_q_table, chroma_q_table) are in fact in linear order. The JPEG file header, which is not generated by the hardware, but must be programatically created with the CPU, expects the table in zigzag order. On the other hand, the hardware doesn't expect neither linear, nor zigzag order. Instead it expects the quantization tables in vertical groups of four quantization parameters, and the groups are organized in blocks of two vertically adjacent groups. On top of that the blocks must be provided to the hardware in this order: leftmost top block, leftmost bottom block, second leftmost top block, second leftmost bottom block and so on. So, if this is the quantization table in linear order: 0x10, 0x0b, 0x0a, 0x10, 0x18, 0x28, 0x33, 0x3d, 0x0c, 0x0c, 0x0e, 0x13, 0x1a, 0x3a, 0x3c, 0x37, 0x0e, 0x0d, 0x10, 0x18, 0x28, 0x39, 0x45, 0x38, 0x0e, 0x11, 0x16, 0x1d, 0x33, 0x57, 0x50, 0x3e, 0x12, 0x16, 0x25, 0x38, 0x44, 0x6d, 0x67, 0x4d, 0x18, 0x23, 0x37, 0x40, 0x51, 0x68, 0x71, 0x5c, 0x31, 0x40, 0x4e, 0x57, 0x67, 0x79, 0x78, 0x65, 0x48, 0x5c, 0x5f, 0x62, 0x70, 0x64, 0x67, 0x63 then the hardware expects this in its consecutive registers: 0x100c0e0e, 0x0b0c0d11, 0x12183148, 0x1623405c, 0x0a0e1016, 0x1013181d, 0x25374e5f, 0x38405762, and so on. Consequently, the same area of memory cannot be used both for dumping it into the JPEG file header and writing its contents to the hardware registers. Instead, a separate pair of arrays is added for properly reordered quantization tables, to be read with get_unaligned_be32() and linearly written to the registers. The "ctx" parameter is not needed any more for hantro_jpeg_get_qtable(). Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> Tested-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c')
-rw-r--r--drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c b/drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c
index a85c4f9fd10a..d248979908c3 100644
--- a/drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c
+++ b/drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c
@@ -18,9 +18,8 @@
*
* Quantization luma table values are written to registers
* VEPU_swreg_0-VEPU_swreg_15, and chroma table values to
- * VEPU_swreg_16-VEPU_swreg_31.
- *
- * JPEG zigzag order is expected on the quantization tables.
+ * VEPU_swreg_16-VEPU_swreg_31. A special order is needed, neither
+ * zigzag, nor linear.
*/
#include <asm/unaligned.h>
@@ -139,8 +138,8 @@ void rk3399_vpu_jpeg_enc_run(struct hantro_ctx *ctx)
rk3399_vpu_set_src_img_ctrl(vpu, ctx);
rk3399_vpu_jpeg_enc_set_buffers(vpu, ctx, &src_buf->vb2_buf);
rk3399_vpu_jpeg_enc_set_qtable(vpu,
- hantro_jpeg_get_qtable(&jpeg_ctx, 0),
- hantro_jpeg_get_qtable(&jpeg_ctx, 1));
+ hantro_jpeg_get_qtable(0),
+ hantro_jpeg_get_qtable(1));
reg = VEPU_REG_OUTPUT_SWAP32
| VEPU_REG_OUTPUT_SWAP16