1bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz/* linux/drivers/media/video/s5p-jpeg/jpeg-core.h 2bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * 3bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * Copyright (c) 2011 Samsung Electronics Co., Ltd. 4bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * http://www.samsung.com 5bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * 6bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com> 7bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * 8bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * This program is free software; you can redistribute it and/or modify 9bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * it under the terms of the GNU General Public License version 2 as 10bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * published by the Free Software Foundation. 11bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz */ 12bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 13bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#ifndef JPEG_CORE_H_ 14bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define JPEG_CORE_H_ 15bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 16bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#include <media/v4l2-device.h> 17275de24dc0076fac25e86e586c9577b8caee28ceSylwester Nawrocki#include <media/v4l2-fh.h> 1815f4bc3b1f42ca73ad073d7390aa34fa358f02a3Sylwester Nawrocki#include <media/v4l2-ctrls.h> 19bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 20bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_M2M_NAME "s5p-jpeg" 21bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 22bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz/* JPEG compression quality setting */ 23bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_COMPR_QUAL_BEST 0 24bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_COMPR_QUAL_WORST 3 25bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 26bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz/* JPEG RGB to YCbCr conversion matrix coefficients */ 27bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_COEF11 0x4d 28bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_COEF12 0x97 29bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_COEF13 0x1e 30bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_COEF21 0x2c 31bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_COEF22 0x57 32bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_COEF23 0x83 33bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_COEF31 0x83 34bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_COEF32 0x6e 35bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define S5P_JPEG_COEF33 0x13 36bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 37bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz/* a selection of JPEG markers */ 38bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define TEM 0x01 39bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define SOF0 0xc0 40bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define RST 0xd0 41bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define SOI 0xd8 42bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define EOI 0xd9 43bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define DHP 0xde 44bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 45bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz/* Flags that indicate a format can be used for capture/output */ 46bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define MEM2MEM_CAPTURE (1 << 0) 47bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#define MEM2MEM_OUTPUT (1 << 1) 48bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 49bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz/** 50bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * struct s5p_jpeg - JPEG IP abstraction 51bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @lock: the mutex protecting this structure 5215f4bc3b1f42ca73ad073d7390aa34fa358f02a3Sylwester Nawrocki * @slock: spinlock protecting the device contexts 53bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @v4l2_dev: v4l2 device for mem2mem mode 54bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @vfd_encoder: video device node for encoder mem2mem mode 55bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @vfd_decoder: video device node for decoder mem2mem mode 56bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @m2m_dev: v4l2 mem2mem device data 57bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @ioarea: JPEG IP memory region 58bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @regs: JPEG IP registers mapping 59bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @irq: JPEG IP irq 60bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @clk: JPEG IP clock 61bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @dev: JPEG IP struct device 62bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @alloc_ctx: videobuf2 memory allocator's context 63bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz */ 64bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstruct s5p_jpeg { 65bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz struct mutex lock; 6615f4bc3b1f42ca73ad073d7390aa34fa358f02a3Sylwester Nawrocki struct spinlock slock; 67bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 68bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz struct v4l2_device v4l2_dev; 69bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz struct video_device *vfd_encoder; 70bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz struct video_device *vfd_decoder; 71bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz struct v4l2_m2m_dev *m2m_dev; 72bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 73bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz struct resource *ioarea; 74bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz void __iomem *regs; 75bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned int irq; 76bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz struct clk *clk; 77bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz struct device *dev; 78bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz void *alloc_ctx; 79bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz}; 80bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 81bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz/** 82bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * struct jpeg_fmt - driver's internal color format data 83bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @name: format descritpion 84bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @fourcc: the fourcc code, 0 if not applicable 85bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @depth: number of bits per pixel 86bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @colplanes: number of color planes (1 for packed formats) 87bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @h_align: horizontal alignment order (align to 2^h_align) 88bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @v_align: vertical alignment order (align to 2^v_align) 89bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @types: types of queue this format is applicable to 90bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz */ 91bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstruct s5p_jpeg_fmt { 92bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz char *name; 93bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz u32 fourcc; 94bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz int depth; 95bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz int colplanes; 96bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz int h_align; 97bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz int v_align; 98bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz u32 types; 99bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz}; 100bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 101bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz/** 102bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * s5p_jpeg_q_data - parameters of one queue 103bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @fmt: driver-specific format of this queue 104bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @w: image width 105bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @h: image height 106bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @size: image buffer size in bytes 107bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz */ 108bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstruct s5p_jpeg_q_data { 109bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz struct s5p_jpeg_fmt *fmt; 110bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz u32 w; 111bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz u32 h; 112bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz u32 size; 113bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz}; 114bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 115bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz/** 116bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * s5p_jpeg_ctx - the device context data 117bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @jpeg: JPEG IP device for this context 118bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @mode: compression (encode) operation or decompression (decode) 119bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @compr_quality: destination image quality in compression (encode) mode 120bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @m2m_ctx: mem2mem device context 121bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @out_q: source (output) queue information 122bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @cap_fmt: destination (capture) queue queue information 123bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @hdr_parsed: set if header has been parsed during decompression 12415f4bc3b1f42ca73ad073d7390aa34fa358f02a3Sylwester Nawrocki * @ctrl_handler: controls handler 125bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz */ 126bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstruct s5p_jpeg_ctx { 127bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz struct s5p_jpeg *jpeg; 128bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned int mode; 12915f4bc3b1f42ca73ad073d7390aa34fa358f02a3Sylwester Nawrocki unsigned short compr_quality; 13015f4bc3b1f42ca73ad073d7390aa34fa358f02a3Sylwester Nawrocki unsigned short restart_interval; 13115f4bc3b1f42ca73ad073d7390aa34fa358f02a3Sylwester Nawrocki unsigned short subsampling; 132bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz struct v4l2_m2m_ctx *m2m_ctx; 133bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz struct s5p_jpeg_q_data out_q; 134bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz struct s5p_jpeg_q_data cap_q; 135275de24dc0076fac25e86e586c9577b8caee28ceSylwester Nawrocki struct v4l2_fh fh; 136bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz bool hdr_parsed; 13715f4bc3b1f42ca73ad073d7390aa34fa358f02a3Sylwester Nawrocki struct v4l2_ctrl_handler ctrl_handler; 138bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz}; 139bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 140bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz/** 141bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * s5p_jpeg_buffer - description of memory containing input JPEG data 142bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @size: buffer size 143bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @curr: current position in the buffer 144bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz * @data: pointer to the data 145bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz */ 146bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewiczstruct s5p_jpeg_buffer { 147bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long size; 148bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long curr; 149bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz unsigned long data; 150bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz}; 151bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz 152bb677f3ac434cb1708938f1e76a41d9098affd05Andrzej Pietrasiewicz#endif /* JPEG_CORE_H */ 153