mm_jpeg_interface.h revision 6f83d735d8e3b918da42e6b559fcd0efb78133e5
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 38typedef enum { 39 MM_JPEG_FMT_YUV, 40 MM_JPEG_FMT_BITSTREAM 41} mm_jpeg_format_t; 42 43typedef 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 53typedef 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 59typedef 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 75typedef enum { 76 JPEG_JOB_STATUS_DONE = 0, 77 JPEG_JOB_STATUS_ERROR 78} jpeg_job_status_t; 79 80typedef 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 86typedef 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 97typedef struct { 98 /* num of buf in src img */ 99 uint32_t num_src_bufs; 100 101 /* num of buf in src img */ 102 uint32_t num_dst_bufs; 103 104 int8_t encode_thumbnail; 105 106 /* src img bufs */ 107 mm_jpeg_buf_t src_main_buf[MM_JPEG_MAX_BUF]; 108 109 /* this will be used only for bitstream */ 110 mm_jpeg_buf_t src_thumb_buf[MM_JPEG_MAX_BUF]; 111 112 /* this will be used only for bitstream */ 113 mm_jpeg_buf_t dest_buf[MM_JPEG_MAX_BUF]; 114 115 /* color format */ 116 mm_jpeg_color_format color_format; 117 118 /* jpeg quality: range 0~100 */ 119 uint32_t quality; 120 121 /* buf to exif entries, caller needs to 122 * take care of the memory manage with insider ptr */ 123 QOMX_EXIF_INFO exif_info; 124 125 jpeg_encode_callback_t jpeg_cb; 126 void* userdata; 127 128} mm_jpeg_encode_params_t; 129 130typedef struct { 131 /* active indices of the buffers for encoding */ 132 uint32_t src_index; 133 uint32_t dst_index; 134 uint32_t thumb_index; 135 mm_jpeg_dim_t thumb_dim; 136 137 /* rotation informaiton */ 138 int rotation; 139 140 /* main image dimension */ 141 mm_jpeg_dim_t main_dim; 142 143 /*session id*/ 144 uint32_t session_id; 145 146 /*Metadata stream*/ 147 cam_metadata_info_t *p_metadata; 148 149} mm_jpeg_encode_job_t; 150 151typedef enum { 152 JPEG_JOB_TYPE_ENCODE, 153 JPEG_JOB_TYPE_MAX 154} mm_jpeg_job_type_t; 155 156typedef struct { 157 mm_jpeg_job_type_t job_type; 158 union { 159 mm_jpeg_encode_job_t encode_job; 160 }; 161} mm_jpeg_job_t; 162 163typedef struct { 164 /* config a job -- async call */ 165 int (*start_job)(mm_jpeg_job_t* job, uint32_t* job_id); 166 167 /* abort a job -- sync call */ 168 int (*abort_job)(uint32_t job_id); 169 170 /* create a session */ 171 int (*create_session)(uint32_t client_hdl, 172 mm_jpeg_encode_params_t *p_params, uint32_t *p_session_id); 173 174 /* destroy session */ 175 int (*destroy_session)(uint32_t session_id); 176 177 /* close a jpeg client -- sync call */ 178 int (*close) (uint32_t clientHdl); 179} mm_jpeg_ops_t; 180 181/* open a jpeg client -- sync call 182 * returns client_handle. 183 * failed if client_handle=0 184 * jpeg ops tbl will be filled in if open succeeds */ 185uint32_t jpeg_open(mm_jpeg_ops_t *ops); 186 187#endif /* MM_JPEG_INTERFACE_H_ */ 188