Home | History | Annotate | Download | only in util
      1 /* Copyright (c) 2017, 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 #define LOG_TAG "QCameraExtZoomTranslator"
     31 
     32 #include <stdlib.h>
     33 #include <utils/Errors.h>
     34 #include "QCameraExtZoomTranslator.h"
     35 #include <dlfcn.h>
     36 
     37 extern "C" {
     38 #include "mm_camera_dbg.h"
     39 }
     40 
     41 namespace qcamera {
     42 
     43 /*===========================================================================
     44  * FUNCTION   : QCameraExtZoomTranslator constructor
     45  *
     46  * DESCRIPTION: class constructor
     47  *
     48  * PARAMETERS : none
     49  *
     50  * RETURN     : void
     51  *
     52  *==========================================================================*/
     53 QCameraExtZoomTranslator::QCameraExtZoomTranslator()
     54 {
     55     mLibHandle = NULL;
     56     mInitSuccess = false;
     57     memset(&mInitData, 0, sizeof(zoom_trans_init_data));
     58 }
     59 
     60 /*===========================================================================
     61  * FUNCTION   : QCameraExtZoomTranslator destructor
     62  *
     63  * DESCRIPTION: class destructor
     64  *
     65  * PARAMETERS : none
     66  *
     67  * RETURN     : void
     68  *
     69  *==========================================================================*/
     70 QCameraExtZoomTranslator::~QCameraExtZoomTranslator()
     71 {
     72     // dlclose the lib here and not in deinit
     73 }
     74 
     75 
     76 /*===========================================================================
     77  * FUNCTION   : create
     78  *
     79  * DESCRIPTION: This is a static method to create QCameraExtZoomTranslator object.
     80  *              It calls the private constructor of the class and only returns a
     81  *              valid object if the library loading succeeds.
     82  *
     83  * PARAMETERS : None
     84  *
     85  * RETURN     : Valid object pointer if succeeds
     86  *              NULL if fails
     87  *
     88  *==========================================================================*/
     89 QCameraExtZoomTranslator* QCameraExtZoomTranslator::create()
     90 {
     91     QCameraExtZoomTranslator *pZoomTranslator = NULL;
     92 
     93     // dlopen and dlsym here and if successful, create zoom translator object
     94     // if (success) {
     95     //     pZoomTranslator = new QCameraExtZoomTranslator();
     96     // }
     97 
     98     return pZoomTranslator;
     99 }
    100 
    101 
    102 /*===========================================================================
    103  * FUNCTION   : init
    104  *
    105  * DESCRIPTION: This function passes the initialization data to the zoom
    106  *              translation library.
    107  *
    108  *
    109  * PARAMETERS :
    110  *@initData   : Initialization data
    111  *
    112  * RETURN     :
    113  * NO_ERROR           : Success
    114  * INVALID_OPERATION  : Failure
    115  *
    116  *==========================================================================*/
    117 int32_t QCameraExtZoomTranslator::init(
    118         __unused zoom_trans_init_data initData)
    119 {
    120     int32_t rc = INVALID_OPERATION;
    121 
    122     // Pass the initData to the zoom translation lib and if the operation succeeds,
    123     // set rc to NO_ERROR. Set member variable mInitSuccess to true.
    124 
    125     return rc;
    126 }
    127 
    128 
    129 /*===========================================================================
    130  * FUNCTION   : getZoomValues
    131  *
    132  * DESCRIPTION: This function passes the user zoom to the zoom translation lib and
    133  *              gets back wide and tele zoom values corresponding to that user zoom.
    134  *
    135  *
    136  * PARAMETERS :
    137  *@userZoom   : User zoom (zoom index into the zoom table)
    138  *@wideZoom   : Zoom for wide camera (zoom index into the zoom table)
    139  *@teleZoom   : Zoom for tele camera (zoom index into the zoom table)
    140  *
    141  * RETURN     :
    142  * NO_ERROR           : Success
    143  * INVALID_OPERATION  : Failure
    144  *
    145  *==========================================================================*/
    146 int32_t QCameraExtZoomTranslator::getZoomValues(
    147         __unused uint32_t  userZoom,
    148         __unused uint32_t *wideZoom,
    149         __unused uint32_t *teleZoom)
    150 {
    151     int32_t rc = INVALID_OPERATION;
    152 
    153     // Pass the userzoom to the zoom translation lib to return wideZoom and teleZoom values.
    154     // If the operation succeeds, set rc to NO_ERROR.
    155 
    156     return rc;
    157 }
    158 
    159 
    160 /*===========================================================================
    161  * FUNCTION   : deInit
    162  *
    163  * DESCRIPTION: This function de-initializes zoom translation lib.
    164  *
    165  *
    166  * PARAMETERS : None
    167  *
    168  * RETURN     :
    169  * NO_ERROR           : Success
    170  * INVALID_OPERATION  : Failure
    171  *
    172  *==========================================================================*/
    173 int32_t QCameraExtZoomTranslator::deInit()
    174 {
    175     int32_t rc = INVALID_OPERATION;
    176 
    177     if (mInitSuccess) {
    178         // Deinit the zoom translation lib and if successful, set rc to NO_ERROR.
    179         // Do not dlclose here. dlclose in the destructor
    180     }
    181 
    182     return rc;
    183 }
    184 
    185 
    186 /*===========================================================================
    187  * FUNCTION   : isInitialized
    188  *
    189  * DESCRIPTION: Check if the zoom translator is initialized successfully
    190  *
    191  *
    192  * PARAMETERS : None
    193  *
    194  * RETURN     :
    195  * true       : Initialized successfully
    196  * false      : Not initialized
    197  *
    198  *==========================================================================*/
    199 bool QCameraExtZoomTranslator::isInitialized()
    200 {
    201     return mInitSuccess;
    202 }
    203 
    204 }; // namespace qcamera
    205