1 /* Copyright (c) 2012, The Linux Foundation. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef MM_JPEG_INTERFACE_H_ 30 #define MM_JPEG_INTERFACE_H_ 31 #include "QCamera_Intf.h" 32 33 typedef struct { 34 int width; 35 int height; 36 } image_resolution; 37 38 typedef enum { 39 JPEG_SRC_IMAGE_FMT_YUV, 40 JPEG_SRC_IMAGE_FMT_BITSTREAM 41 } jpeg_enc_src_img_fmt_t; 42 43 typedef enum { 44 JPEG_SRC_IMAGE_TYPE_MAIN, 45 JPEG_SRC_IMAGE_TYPE_THUMB, 46 JPEG_SRC_IMAGE_TYPE_MAX 47 } jpeg_enc_src_img_type_t; 48 49 typedef struct { 50 int32_t offset_x; 51 int32_t offset_y; 52 int32_t width; 53 int32_t height; 54 } image_crop_t; 55 56 typedef struct { 57 uint8_t sequence; /*for jpeg bit streams, assembling is based on sequence. sequence starts from 0*/ 58 uint8_t *buf_vaddr; /*ptr to buf*/ 59 int fd; /*fd of buf*/ 60 uint32_t buf_size; /* total size of buf (header + image) */ 61 uint32_t data_offset; /*data offset*/ 62 } src_bitstream_buffer_t; 63 64 typedef struct { 65 uint8_t *buf_vaddr; /*ptr to buf*/ 66 int fd; /*fd of buf*/ 67 cam_frame_len_offset_t offset; /*alway use multi-planar, offset is used to skip the metadata header*/ 68 } src_image_buffer_t; 69 70 typedef enum { 71 MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2, 72 MM_JPEG_COLOR_FORMAT_YCBCRLP_H2V2, 73 MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V1, 74 MM_JPEG_COLOR_FORMAT_YCBCRLP_H2V1, 75 MM_JPEG_COLOR_FORMAT_YCRCBLP_H1V2, 76 MM_JPEG_COLOR_FORMAT_YCBCRLP_H1V2, 77 MM_JPEG_COLOR_FORMAT_YCRCBLP_H1V1, 78 MM_JPEG_COLOR_FORMAT_YCBCRLP_H1V1, 79 MM_JPEG_COLOR_FORMAT_RGB565, 80 MM_JPEG_COLOR_FORMAT_RGB888, 81 MM_JPEG_COLOR_FORMAT_RGBa, 82 MM_JPEG_COLOR_FORMAT_BITSTREAM, 83 MM_JPEG_COLOR_FORMAT_MAX 84 } mm_jpeg_color_format; 85 86 #define MAX_SRC_BUF_NUM 2 87 typedef struct { 88 /* src img format: YUV, Bitstream */ 89 jpeg_enc_src_img_fmt_t img_fmt; 90 91 /* num of buf in src img */ 92 uint8_t num_bufs; 93 94 /* src img bufs */ 95 union { 96 src_bitstream_buffer_t bit_stream[MAX_SRC_BUF_NUM]; 97 src_image_buffer_t src_image[MAX_SRC_BUF_NUM]; 98 }; 99 100 /* src img type: main or thumbnail */ 101 jpeg_enc_src_img_type_t type; 102 103 /* color format */ 104 mm_jpeg_color_format color_format; 105 106 /* src img dimension */ 107 image_resolution src_dim; 108 109 /* jpeg output dimension */ 110 image_resolution out_dim; 111 112 /* crop information */ 113 image_crop_t crop; 114 115 /* jpeg quality: range 0~100 */ 116 uint32_t quality; 117 } src_image_buffer_info; 118 119 typedef struct { 120 uint8_t *buf_vaddr; /*ptr to buf*/ 121 int fd; /*fd of buf*/ 122 int buf_len; 123 } out_image_buffer_info; 124 125 typedef struct { 126 /* num of src imgs: e.g. main/thumbnail img 127 * if main img only: src_img_num = 1; 128 * if main+thumbnail: src_img_num = 2; 129 * No support for thumbnail only case */ 130 uint8_t src_img_num; 131 132 /* index 0 is always for main image 133 * if thumbnail presented, it will be in index 1 */ 134 src_image_buffer_info src_img[JPEG_SRC_IMAGE_TYPE_MAX]; 135 } src_image_buffer_config; 136 137 typedef struct { 138 src_image_buffer_config src_imgs; 139 out_image_buffer_info sink_img; 140 } jpeg_image_buffer_config; 141 142 typedef struct { 143 /* config for scr images */ 144 jpeg_image_buffer_config buf_info; 145 146 /* rotation informaiton */ 147 int rotation; 148 149 /* num of exif entries */ 150 int exif_numEntries; 151 152 /* buf to exif entries, caller needs to 153 * take care of the memory manage with insider ptr */ 154 exif_tags_info_t *exif_data; 155 } mm_jpeg_encode_params; 156 157 typedef enum { 158 JPEG_JOB_STATUS_DONE = 0, 159 JPEG_JOB_STATUS_ERROR 160 } jpeg_job_status_t; 161 162 typedef void (*jpeg_encode_callback_t)(jpeg_job_status_t status, 163 uint8_t thumbnailDroppedFlag, 164 uint32_t client_hdl, 165 uint32_t jobId, 166 uint8_t* out_data, 167 uint32_t data_size, 168 void *userData); 169 170 typedef struct { 171 mm_jpeg_encode_params encode_parm; 172 jpeg_encode_callback_t jpeg_cb; 173 void* userdata; 174 } mm_jpeg_encode_job; 175 176 typedef enum { 177 JPEG_JOB_TYPE_ENCODE, 178 //JPEG_JOB_TYPE_DECODE, /*enable decode later*/ 179 JPEG_JOB_TYPE_MAX 180 } mm_jpeg_job_type_t; 181 182 typedef struct { 183 mm_jpeg_job_type_t job_type; 184 union { 185 mm_jpeg_encode_job encode_job; 186 }; 187 } mm_jpeg_job; 188 189 typedef struct { 190 /* start a job -- async call 191 * the result of job (DONE/ERROR) will rcvd through CB */ 192 int32_t (* start_job) (uint32_t client_hdl, mm_jpeg_job* job, uint32_t* jobId); 193 194 /* abort a job -- sync call */ 195 int32_t (* abort_job) (uint32_t client_hdl, uint32_t jobId); 196 197 /* close a jpeg client -- sync call */ 198 int32_t (* close) (uint32_t clientHdl); 199 } mm_jpeg_ops_t; 200 201 /* open a jpeg client -- sync call 202 * returns client_handle. 203 * failed if client_handle=0 204 * jpeg ops tbl will be filled in if open succeeds */ 205 uint32_t jpeg_open(mm_jpeg_ops_t *ops); 206 207 #endif /* MM_JPEG_INTERFACE_H_ */ 208 209 210