2 * Copyright Samsung Electronics Co.,LTD.
3 * Copyright (C) 2011 The Android Open Source Project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef __EXYNOS_JPEG_BASE_H__
19 #define __EXYNOS_JPEG_BASE_H__
21 #include <linux/videodev2.h>
22 #include "videodev2_exynos_media.h"
24 #define JPEG_CACHE_OFF (0)
25 #define JPEG_CACHE_ON (1)
26 #define KERNEL_33_JPEG_API (1)
28 class ExynosJpegBase
{
31 #define JPEG_MAX_PLANE_CNT (3)
33 virtual ~ExynosJpegBase();
36 ERROR_JPEG_DEVICE_ALREADY_CREATE
= -0x100,
37 ERROR_INVALID_JPEG_MODE
,
38 ERROR_CANNOT_OPEN_JPEG_DEVICE
,
39 ERROR_JPEG_DEVICE_ALREADY_CLOSED
,
40 ERROR_JPEG_DEVICE_ALREADY_DESTROY
,
41 ERROR_JPEG_DEVICE_NOT_CREATE_YET
,
42 ERROR_INVALID_COLOR_FORMAT
,
43 ERROR_INVALID_JPEG_FORMAT
,
44 ERROR_INVALID_IMAGE_SIZE
,
45 ERROR_JPEG_CONFIG_POINTER_NULL
,
46 ERROR_INVALID_JPEG_CONFIG
,
47 ERROR_IN_BUFFER_CREATE_FAIL
,
48 ERROR_OUT_BUFFER_CREATE_FAIL
,
50 ERROR_JPEG_SIZE_TOO_SMALL
,
51 ERROR_CANNOT_CHANGE_CACHE_SETTING
,
52 ERROR_SIZE_NOT_SET_YET
,
54 ERROR_BUFFER_TOO_SMALL
,
56 ERROR_BUF_NOT_SET_YET
,
58 ERROR_INVALID_V4l2_BUF_TYPE
= -0x80,
71 int addr
[JPEG_MAX_PLANE_CNT
];
72 int size
[JPEG_MAX_PLANE_CNT
];
77 enum v4l2_memory memory
;
78 enum v4l2_buf_type buf_type
;
109 int setSize(int iW
, int iH
);
110 int setCache(int iValue
);
111 void *getJpegConfig(void);
116 bool t_bFlagCreateInBuf
;
117 bool t_bFlagCreateOutBuf
;
123 struct CONFIG t_stJpegConfig
;
124 struct BUFFER t_stJpegInbuf
;
125 struct BUFFER t_stJpegOutbuf
;
128 int t_v4l2Querycap(int iFd
);
129 int t_v4l2SetJpegcomp(int iFd
, int iQuality
);
130 int t_v4l2SetFmt(int iFd
, enum v4l2_buf_type eType
, struct CONFIG
*pstConfig
);
131 int t_v4l2GetFmt(int iFd
, enum v4l2_buf_type eType
, struct CONFIG
*pstConfig
);
132 int t_v4l2Reqbufs(int iFd
, int iBufCount
, struct BUF_INFO
*pstBufInfo
);
133 int t_v4l2Qbuf(int iFd
, struct BUF_INFO
*pstBufInfo
, struct BUFFER
*pstBuf
);
134 int t_v4l2Dqbuf(int iFd
, enum v4l2_buf_type eType
, enum v4l2_memory eMemory
, int iNumPlanes
);
135 int t_v4l2StreamOn(int iFd
, enum v4l2_buf_type eType
);
136 int t_v4l2StreamOff(int iFd
, enum v4l2_buf_type eType
);
137 int t_v4l2SetCtrl(int iFd
, int iCid
, int iValue
);
138 int t_v4l2GetCtrl(int iFd
, int iCid
);
140 int create(enum MODE eMode
);
141 int destroy(int iInBufs
, int iOutBufs
);
142 int setJpegConfig(enum MODE eMode
, void *pConfig
);
143 int setColorFormat(enum MODE eMode
, int iV4l2ColorFormat
);
144 int setJpegFormat(enum MODE eMode
, int iV4l2JpegFormat
);
145 int setColorBufSize(enum MODE eMode
, int *piBufSize
, int iSize
);
146 int setColorBufSize(int iFormat
, int *piBufSize
, int iSize
, int width
, int height
);
147 int getBuf(bool bCreateBuf
, struct BUFFER
*pstBuf
, int *piBuf
, int *iBufSize
, int iSize
, int iPlaneNum
);
148 int setBuf(struct BUFFER
*pstBuf
, int *piBuf
, int *iSize
, int iPlaneNum
);
149 int updateConfig(enum MODE eMode
, int iInBufs
, int iOutBufs
, int iInBufPlanes
, int iOutBufPlanes
);
150 int execute(int iInBufPlanes
, int iOutBufPlanes
);
153 //! ExynosJpegEncoder class
157 class ExynosJpegEncoder
: public ExynosJpegBase
{
161 virtual ~ExynosJpegEncoder();
164 QUALITY_LEVEL_1
= 0, /* high */
167 QUALITY_LEVEL_4
, /* low */
173 int setJpegConfig(void* pConfig
);
175 int getInBuf(int *piBuf
, int *piInputSize
, int iSize
);
176 int getOutBuf(int *piBuf
, int *piOutputSize
);
178 int setInBuf(int *piBuf
, int *iSize
);
179 int setOutBuf(int iBuf
, int iSize
);
181 int getSize(int *piWidth
, int *piHeight
);
182 int getColorFormat(void);
183 int setColorFormat(int iV4l2ColorFormat
);
184 int setJpegFormat(int iV4l2JpegFormat
);
185 int setColorBufSize(int *piBufSize
, int iSize
);
186 int updateConfig(void);
188 int setQuality(int iQuality
);
189 int getJpegSize(void);
194 //! ExynosJpegDecoder class
198 class ExynosJpegDecoder
: public ExynosJpegBase
{
202 virtual ~ExynosJpegDecoder();
207 int setJpegConfig(void* pConfig
);
209 int getInBuf(int *piBuf
, int *piInputSize
);
210 int getOutBuf(int *picBuf
, int *piOutputSize
, int iSize
);
212 int setInBuf(int iBuf
, int iSize
);
213 int setOutBuf(int *piBuf
, int *iSize
);
215 int getSize(int *piWidth
, int *piHeight
);
216 int setColorFormat(int iV4l2ColorFormat
);
217 int setJpegFormat(int iV4l2JpegFormat
);
218 int updateConfig(void);
220 int setScaledSize(int iW
, int iH
);
221 int setJpegSize(int iJpegSize
);
224 #ifdef WA_BLOCKING_ARTIFACT
226 void reduceBlockingArtifact(unsigned char *addr
, int iColor
, int width
, int height
);
230 #endif /* __EXYNOS_JPEG_BASE_H__ */