Home | History | Annotate | Download | only in inc
      1 /* Copyright (c) 2015-2016, 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_LIB2D_H_
     31 #define MM_LIB2D_H_
     32 
     33 #include "cam_types.h"
     34 #ifdef QCAMERA_REDEFINE_LOG
     35 #ifndef CAM_MODULE
     36 #define CAM_MODULE CAM_NO_MODULE
     37 #endif
     38 // Camera dependencies
     39 #include "mm_camera_dbg.h"
     40 #endif
     41 
     42 /** lib2d_error
     43  * @MM_LIB2D_SUCCESS: Success
     44  * @MM_LIB2D_ERR_GENERAL: General Error
     45  * @MM_LIB2D_ERR_MEMORY: Insufficient memory error
     46  * @MM_LIB2D_ERR_BAD_PARAM: Bad params error
     47 **/
     48 typedef enum lib2d_error_t {
     49   MM_LIB2D_SUCCESS,
     50   MM_LIB2D_ERR_GENERAL,
     51   MM_LIB2D_ERR_MEMORY,
     52   MM_LIB2D_ERR_BAD_PARAM,
     53 } lib2d_error;
     54 
     55 /** lib2d_mode
     56  * @MM_LIB2D_SYNC_MODE: Synchronous mode
     57  * @MM_LIB2D_ASYNC_MODE: Asynchronous mode
     58 **/
     59 typedef enum mm_lib2d_mode_t {
     60   MM_LIB2D_SYNC_MODE,
     61   MM_LIB2D_ASYNC_MODE,
     62 } lib2d_mode;
     63 
     64 /** mm_lib2d_buffer_type
     65  * @MM_LIB2D_BUFFER_TYPE_RGB: RGB Buffer type
     66  * @MM_LIB2D_BUFFER_TYPE_YUV: YUV buffer type
     67 **/
     68 typedef enum mm_lib2d_buffer_type_t {
     69   MM_LIB2D_BUFFER_TYPE_RGB,
     70   MM_LIB2D_BUFFER_TYPE_YUV,
     71 } mm_lib2d_buffer_type;
     72 
     73 /** mm_lib2d_rgb_buffer
     74  * @fd: handle to the buffer memory
     75  * @format: RGB color format
     76  * @width: defines width in pixels
     77  * @height: defines height in pixels
     78  * @buffer: pointer to the RGB buffer
     79  * @phys: gpu mapped physical address
     80  * @stride: defines stride in bytes
     81 **/
     82 typedef struct mm_lib2d_rgb_buffer_t {
     83   int32_t      fd;
     84   cam_format_t format;
     85   uint32_t     width;
     86   uint32_t     height;
     87   void        *buffer;
     88   void        *phys;
     89   int32_t      stride;
     90 } mm_lib2d_rgb_buffer;
     91 
     92 /** mm_lib2d_yuv_buffer
     93  * @fd: handle to the buffer memory
     94  * @format: YUV color format
     95  * @width: defines width in pixels
     96  * @height: defines height in pixels
     97  * @plane0: holds the whole buffer if YUV format is not planar
     98  * @phys0: gpu mapped physical address
     99  * @stride0: stride in bytes
    100  * @plane1: holds UV or VU plane for planar interleaved
    101  * @phys2: gpu mapped physical address
    102  * @stride1: stride in bytes
    103  * @plane2: holds the 3. plane, ignored if YUV format is not planar
    104  * @phys2: gpu mapped physical address
    105  * @stride2: stride in bytes
    106 **/
    107 typedef struct mm_lib2d_yuv_buffer_t {
    108   int32_t      fd;
    109   cam_format_t format;
    110   uint32_t     width;
    111   uint32_t     height;
    112   void        *plane0;
    113   void        *phys0;
    114   int32_t      stride0;
    115   void        *plane1;
    116   void        *phys1;
    117   int32_t      stride1;
    118   void        *plane2;
    119   void        *phys2;
    120   int32_t      stride2;
    121 } mm_lib2d_yuv_buffer;
    122 
    123 /** mm_lib2d_buffer
    124  * @buffer_type: Buffer type. whether RGB or YUV
    125  * @rgb_buffer: RGB buffer handle
    126  * @yuv_buffer: YUV buffer handle
    127 **/
    128 typedef struct mm_lib2d_buffer_t {
    129   mm_lib2d_buffer_type buffer_type;
    130   union {
    131     mm_lib2d_rgb_buffer rgb_buffer;
    132     mm_lib2d_yuv_buffer yuv_buffer;
    133   };
    134 } mm_lib2d_buffer;
    135 
    136 /** lib2d_client_cb
    137  * @userdata: App userdata
    138  * @jobid: job id
    139 **/
    140 typedef lib2d_error (*lib2d_client_cb) (void *userdata, int jobid);
    141 
    142 /**
    143  * Function: mm_lib2d_init
    144  *
    145  * Description: Initialization function for Lib2D. src_format, dst_format
    146  *     are hints to the underlying component to initialize.
    147  *
    148  * Input parameters:
    149  *   mode - Mode (sync/async) in which App wants lib2d to run.
    150  *   src_format - source surface format
    151  *   dst_format - Destination surface format
    152  *   my_obj - handle that will be returned on succesful Init. App has to
    153  *       call other lib2d functions by passing this handle.
    154  *
    155  * Return values:
    156  *   MM_LIB2D_SUCCESS
    157  *   MM_LIB2D_ERR_MEMORY
    158  *   MM_LIB2D_ERR_BAD_PARAM
    159  *   MM_LIB2D_ERR_GENERAL
    160  *
    161  * Notes: none
    162  **/
    163 lib2d_error mm_lib2d_init(lib2d_mode mode, cam_format_t src_format,
    164   cam_format_t dst_format, void **lib2d_obj_handle);
    165 
    166 /**
    167  * Function: mm_lib2d_deinit
    168  *
    169  * Description: De-Initialization function for Lib2D
    170  *
    171  * Input parameters:
    172  *   lib2d_obj_handle - handle tto the lib2d object
    173  *
    174  * Return values:
    175  *   MM_LIB2D_SUCCESS
    176  *   MM_LIB2D_ERR_GENERAL
    177  *
    178  * Notes: none
    179  **/
    180 lib2d_error mm_lib2d_deinit(void *lib2d_obj_handle);
    181 
    182 /**
    183  * Function: mm_lib2d_start_job
    184  *
    185  * Description: Start executing the job
    186  *
    187  * Input parameters:
    188  *   lib2d_obj_handle - handle tto the lib2d object
    189  *   src_buffer - pointer to the source buffer
    190  *   dst_buffer - pointer to the destination buffer
    191  *   jobid - job id of this request
    192  *   userdata - userdata that will be pass through callback function
    193  *   cb - callback function that will be called on completion of this job
    194  *   rotation - rotation to be applied
    195  *
    196  * Return values:
    197  *   MM_LIB2D_SUCCESS
    198  *   MM_LIB2D_ERR_MEMORY
    199  *   MM_LIB2D_ERR_GENERAL
    200  *
    201  * Notes: none
    202  **/
    203 lib2d_error mm_lib2d_start_job(void *lib2d_obj_handle,
    204     mm_lib2d_buffer* src_buffer, mm_lib2d_buffer* dst_buffer,
    205     int jobid, void *userdata, lib2d_client_cb cb, uint32_t rotation);
    206 
    207 #endif /* MM_LIB2D_H_ */
    208 
    209 
    210