mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-02 13:23:35 -04:00
media: hantro: jpeg: Add COM segment to JPEG header to align image scan
The JPEG header size is not 64-bit aligned. This makes the driver require a bounce buffer for the encoded JPEG image scan output. Add a COM (comment) segment to the JPEG header so that the header size is a multiple of 64 bits. This will then allow dropping the use of the bounce buffer, and instead have the hardware write out to the capture buffer directly. Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
e90410d130
commit
00b5359bac
@@ -6,6 +6,9 @@
|
||||
* Copyright (C) Jean-Francois Moine (http://moinejf.free.fr)
|
||||
* Copyright (C) 2014 Philipp Zabel, Pengutronix
|
||||
*/
|
||||
|
||||
#include <linux/align.h>
|
||||
#include <linux/build_bug.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
@@ -140,7 +143,7 @@ static const unsigned char chroma_ac_table[] = {
|
||||
* and we'll use fixed offsets to change the width, height
|
||||
* quantization tables, etc.
|
||||
*/
|
||||
static const unsigned char hantro_jpeg_header[JPEG_HEADER_SIZE] = {
|
||||
static const unsigned char hantro_jpeg_header[] = {
|
||||
/* SOI */
|
||||
0xff, 0xd8,
|
||||
|
||||
@@ -247,11 +250,29 @@ static const unsigned char hantro_jpeg_header[JPEG_HEADER_SIZE] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
/* COM */
|
||||
0xff, 0xfe, 0x00, 0x03, 0x00,
|
||||
|
||||
/* SOS */
|
||||
0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02,
|
||||
0x11, 0x03, 0x11, 0x00, 0x3f, 0x00,
|
||||
};
|
||||
|
||||
/*
|
||||
* JPEG_HEADER_SIZE is used in other parts of the driver in lieu of
|
||||
* "sizeof(hantro_jpeg_header)". The two must be equal.
|
||||
*/
|
||||
static_assert(sizeof(hantro_jpeg_header) == JPEG_HEADER_SIZE);
|
||||
|
||||
/*
|
||||
* hantro_jpeg_header is padded with a COM segment, so that the payload
|
||||
* of the SOS segment (the entropy-encoded image scan), which should
|
||||
* trail the whole header, is 8-byte aligned for the hardware to write
|
||||
* to directly.
|
||||
*/
|
||||
static_assert(IS_ALIGNED(sizeof(hantro_jpeg_header), 8),
|
||||
"Hantro JPEG header size needs to be 8-byte aligned.");
|
||||
|
||||
static unsigned char jpeg_scale_qp(const unsigned char qp, int scale)
|
||||
{
|
||||
unsigned int temp;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
|
||||
#define JPEG_HEADER_SIZE 619
|
||||
#define JPEG_HEADER_SIZE 624
|
||||
#define JPEG_QUANT_SIZE 64
|
||||
|
||||
struct hantro_jpeg_ctx {
|
||||
|
||||
Reference in New Issue
Block a user