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 30 #ifndef MM_JPEG_INTERFACE_H_ 31 #define MM_JPEG_INTERFACE_H_ 32 #include "QOMX_JpegExtensions.h" 33 #include "cam_intf.h" 34 35 #define MM_JPEG_MAX_PLANES 3 36 #define MM_JPEG_MAX_BUF CAM_MAX_NUM_BUFS_PER_STREAM 37 38 typedef enum { 39 MM_JPEG_FMT_YUV, 40 MM_JPEG_FMT_BITSTREAM 41 } mm_jpeg_format_t; 42 43 typedef struct { 44 uint32_t sequence; /* for jpeg bit streams, assembling is based on sequence. sequence starts from 0 */ 45 uint8_t *buf_vaddr; /* ptr to buf */ 46 int fd; /* fd of buf */ 47 uint32_t buf_size; /* total size of buf (header + image) */ 48 mm_jpeg_format_t format; /* buffer format*/ 49 cam_frame_len_offset_t offset; /* offset of all the planes */ 50 int index; /* index used to identify the buffers */ 51 } mm_jpeg_buf_t; 52 53 typedef struct { 54 uint8_t *buf_vaddr; /* ptr to buf */ 55 int fd; /* fd of buf */ 56 uint32_t buf_filled_len; /* used for output image. filled by the client */ 57 } mm_jpeg_output_t; 58 59 typedef enum { 60 MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2, 61 MM_JPEG_COLOR_FORMAT_YCBCRLP_H2V2, 62 MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V1, 63 MM_JPEG_COLOR_FORMAT_YCBCRLP_H2V1, 64 MM_JPEG_COLOR_FORMAT_YCRCBLP_H1V2, 65 MM_JPEG_COLOR_FORMAT_YCBCRLP_H1V2, 66 MM_JPEG_COLOR_FORMAT_YCRCBLP_H1V1, 67 MM_JPEG_COLOR_FORMAT_YCBCRLP_H1V1, 68 MM_JPEG_COLOR_FORMAT_BITSTREAM_H2V2, 69 MM_JPEG_COLOR_FORMAT_BITSTREAM_H2V1, 70 MM_JPEG_COLOR_FORMAT_BITSTREAM_H1V2, 71 MM_JPEG_COLOR_FORMAT_BITSTREAM_H1V1, 72 MM_JPEG_COLOR_FORMAT_MAX 73 } mm_jpeg_color_format; 74 75 typedef enum { 76 JPEG_JOB_STATUS_DONE = 0, 77 JPEG_JOB_STATUS_ERROR 78 } jpeg_job_status_t; 79 80 typedef void (*jpeg_encode_callback_t)(jpeg_job_status_t status, 81 uint32_t client_hdl, 82 uint32_t jobId, 83 mm_jpeg_output_t *p_output, 84 void *userData); 85 86 typedef struct { 87 /* src img dimension */ 88 cam_dimension_t src_dim; 89 90 /* jpeg output dimension */ 91 cam_dimension_t dst_dim; 92 93 /* crop information */ 94 cam_rect_t crop; 95 } mm_jpeg_dim_t; 96 97 typedef struct { 98 /* num of buf in src img */ 99 uint32_t num_src_bufs; 100 101 /* num of src tmb bufs */ 102 uint32_t num_tmb_bufs; 103 104 /* num of buf in src img */ 105 uint32_t num_dst_bufs; 106 107 int8_t encode_thumbnail; 108 109 /* src img bufs */ 110 mm_jpeg_buf_t src_main_buf[MM_JPEG_MAX_BUF]; 111 112 /* this will be used only for bitstream */ 113 mm_jpeg_buf_t src_thumb_buf[MM_JPEG_MAX_BUF]; 114 115 /* this will be used only for bitstream */ 116 mm_jpeg_buf_t dest_buf[MM_JPEG_MAX_BUF]; 117 118 /* color format */ 119 mm_jpeg_color_format color_format; 120 121 /* jpeg quality: range 0~100 */ 122 uint32_t quality; 123 124 /* buf to exif entries, caller needs to 125 * take care of the memory manage with insider ptr */ 126 QOMX_EXIF_INFO exif_info; 127 128 jpeg_encode_callback_t jpeg_cb; 129 void* userdata; 130 131 } mm_jpeg_encode_params_t; 132 133 typedef struct { 134 /* active indices of the buffers for encoding */ 135 uint32_t src_index; 136 uint32_t dst_index; 137 uint32_t thumb_index; 138 mm_jpeg_dim_t thumb_dim; 139 140 /* rotation informaiton */ 141 int rotation; 142 143 /* main image dimension */ 144 mm_jpeg_dim_t main_dim; 145 146 /*session id*/ 147 uint32_t session_id; 148 149 /*Metadata stream*/ 150 cam_metadata_info_t *p_metadata; 151 152 } mm_jpeg_encode_job_t; 153 154 typedef enum { 155 JPEG_JOB_TYPE_ENCODE, 156 JPEG_JOB_TYPE_MAX 157 } mm_jpeg_job_type_t; 158 159 typedef struct { 160 mm_jpeg_job_type_t job_type; 161 union { 162 mm_jpeg_encode_job_t encode_job; 163 }; 164 } mm_jpeg_job_t; 165 166 typedef struct { 167 /* config a job -- async call */ 168 int (*start_job)(mm_jpeg_job_t* job, uint32_t* job_id); 169 170 /* abort a job -- sync call */ 171 int (*abort_job)(uint32_t job_id); 172 173 /* create a session */ 174 int (*create_session)(uint32_t client_hdl, 175 mm_jpeg_encode_params_t *p_params, uint32_t *p_session_id); 176 177 /* destroy session */ 178 int (*destroy_session)(uint32_t session_id); 179 180 /* close a jpeg client -- sync call */ 181 int (*close) (uint32_t clientHdl); 182 } mm_jpeg_ops_t; 183 184 /* open a jpeg client -- sync call 185 * returns client_handle. 186 * failed if client_handle=0 187 * jpeg ops tbl will be filled in if open succeeds */ 188 uint32_t jpeg_open(mm_jpeg_ops_t *ops); 189 190 #endif /* MM_JPEG_INTERFACE_H_ */ 191