Home | History | Annotate | Download | only in src
      1 /* Copyright (c) 2012-2013, 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 // To remove
     31 #include <cutils/properties.h>
     32 
     33 // Camera dependencies
     34 #include "mm_qcamera_commands.h"
     35 #include "mm_qcamera_dbg.h"
     36 
     37 int tuneserver_initialize_prevtuningp(void * ctrl,
     38   int pr_client_socket_id, cam_dimension_t dimension,
     39   char **send_buf, uint32_t *send_len)
     40 {
     41   int result = 0;
     42   mm_camera_lib_handle *lib_handle = (mm_camera_lib_handle *) ctrl;
     43   tuningserver_t *tctrl = &lib_handle->tsctrl;
     44 
     45   LOGD("E");
     46   if (tctrl->tuning_params.func_tbl->prevcommand_process == NULL) {
     47       LOGE("prevcommand_process is NULL");
     48       return -1;
     49   }
     50 
     51   result = tctrl->tuning_params.func_tbl->prevcommand_process(
     52       NULL, TUNE_PREVCMD_INIT, (void *)&pr_client_socket_id,
     53       send_buf, send_len);
     54   result = tctrl->tuning_params.func_tbl->prevcommand_process(
     55       NULL, TUNE_PREVCMD_SETDIM, (void *)&dimension,
     56       send_buf, send_len);
     57 
     58   mm_camera_lib_set_preview_usercb(lib_handle,
     59       (tctrl->tuning_params.func_tbl->prevframe_callback));
     60 
     61   return result;
     62 }
     63 
     64 int tuneserver_deinitialize_prevtuningp(void * ctrl,
     65     char **send_buf, uint32_t *send_len)
     66 {
     67   int result = 0;
     68   tuningserver_t *tctrl = (tuningserver_t *) ctrl;
     69 
     70   LOGD("E");
     71 
     72   result = tctrl->tuning_params.func_tbl->prevcommand_process(
     73     &tctrl->pr_proto, TUNE_PREVCMD_DEINIT, NULL, send_buf, send_len);
     74 
     75   return result;
     76 }
     77 
     78 int tuneserver_preview_getinfo(void * ctrl, char **send_buf, uint32_t *send_len)
     79 {
     80   int result = 0;
     81   tuningserver_t *tctrl = (tuningserver_t *) ctrl;
     82 
     83   LOGD("E");
     84   result = tctrl->tuning_params.func_tbl->prevcommand_process(
     85     &tctrl->pr_proto, TUNE_PREVCMD_GETINFO, NULL, send_buf, send_len);
     86 
     87   return result;
     88 }
     89 
     90 int tuneserver_preview_getchunksize(void * ctrl,
     91   char **send_buf, uint32_t *send_len)
     92 {
     93   int result = 0;
     94   tuningserver_t *tctrl = (tuningserver_t *) ctrl;
     95 
     96   LOGD("E");
     97   result = tctrl->tuning_params.func_tbl->prevcommand_process(
     98     &tctrl->pr_proto, TUNE_PREVCMD_GETCHUNKSIZE,
     99     (void *)&tctrl->pr_proto->new_cnk_size, send_buf, send_len);
    100 
    101   return result;
    102 }
    103 
    104 int tuneserver_preview_getframe(void * ctrl,
    105   char **send_buf, uint32_t *send_len)
    106 {
    107   int result = 0;
    108   tuningserver_t *tctrl = (tuningserver_t *) ctrl;
    109 
    110   LOGD("E");
    111   result = tctrl->tuning_params.func_tbl->prevcommand_process(
    112     &tctrl->pr_proto, TUNE_PREVCMD_GETFRAME, NULL, send_buf, send_len);
    113 
    114   return result;
    115 }
    116 
    117 int tuneserver_preview_unsupported(void * ctrl,
    118   char **send_buf, uint32_t *send_len)
    119 {
    120   int result = 0;
    121   tuningserver_t *tctrl = (tuningserver_t *) ctrl;
    122 
    123   LOGD("E");
    124   result = tctrl->tuning_params.func_tbl->prevcommand_process(
    125     &tctrl->pr_proto, TUNE_PREVCMD_UNSUPPORTED, NULL, send_buf, send_len);
    126 
    127   return result;
    128 }
    129 
    130 int tuneserver_initialize_tuningp(void * ctrl, int client_socket_id,
    131   char *send_buf, uint32_t send_len)
    132 {
    133   int result = 0;
    134   mm_camera_lib_handle *lib_handle = (mm_camera_lib_handle *) ctrl;
    135   tuningserver_t *tctrl = &lib_handle->tsctrl;
    136 
    137   LOGD("E");
    138   result = tctrl->tuning_params.func_tbl->command_process(
    139     lib_handle, TUNE_CMD_INIT, &client_socket_id, send_buf, send_len);
    140 
    141   return result;
    142 }
    143 
    144 int tuneserver_deinitialize_tuningp(void * ctrl, int client_socket_id,
    145   char *send_buf, uint32_t send_len)
    146 {
    147   int result = 0;
    148   tuningserver_t *tctrl = (tuningserver_t *) ctrl;
    149 
    150   LOGD("E");
    151 
    152   result = tctrl->tuning_params.func_tbl->command_process(
    153     NULL, TUNE_CMD_DEINIT, &client_socket_id, send_buf, send_len);
    154 
    155   return result;
    156 }
    157 
    158 int tuneserver_process_get_list_cmd(void * ctrl, void *recv_cmd,
    159   char *send_buf, uint32_t send_len)
    160 {
    161   int result = 0;
    162   tuningserver_t *tctrl = (tuningserver_t *) ctrl;
    163 
    164   LOGD("E");
    165   result = tctrl->tuning_params.func_tbl->command_process(
    166      recv_cmd, TUNE_CMD_GET_LIST, NULL, send_buf, send_len);
    167 
    168   return result;
    169 }
    170 
    171 int tuneserver_process_get_params_cmd(void * ctrl, void *recv_cmd,
    172   char *send_buf, uint32_t send_len)
    173 {
    174   int result = 0;
    175   tuningserver_t *tctrl = (tuningserver_t *) ctrl;
    176 
    177   LOGD("E");
    178   result = tctrl->tuning_params.func_tbl->command_process
    179     (recv_cmd, TUNE_CMD_GET_PARAMS, NULL, send_buf, send_len);
    180 
    181   return result;
    182 }
    183 
    184 int tuneserver_process_set_params_cmd(void * ctrl, void *recv_cmd,
    185   char *send_buf, uint32_t send_len)
    186 {
    187   int result = 0;
    188   tuningserver_t *tctrl = (tuningserver_t *) ctrl;
    189 
    190   LOGD("E");
    191   result = tctrl->tuning_params.func_tbl->command_process(
    192      recv_cmd, TUNE_CMD_SET_PARAMS, NULL, send_buf, send_len);
    193 
    194   return result;
    195 }
    196 
    197 int tuneserver_process_misc_cmd(void * ctrl, void *recv_cmd,
    198   char *send_buf, uint32_t send_len)
    199 {
    200   int result = 0;
    201   tuningserver_t *tctrl = (tuningserver_t *) ctrl;
    202 
    203   LOGD("E");
    204   result = tctrl->tuning_params.func_tbl->command_process(
    205      recv_cmd, TUNE_CMD_MISC, NULL, send_buf, send_len);
    206 
    207   return result;
    208 }
    209 
    210 /** tuneserver_close_cam
    211  *    @lib_handle: the camera handle object
    212  *
    213  *  closes the camera
    214  *
    215  *  Return: >=0 on success, -1 on failure.
    216  **/
    217 int tuneserver_close_cam(mm_camera_lib_handle *lib_handle)
    218 {
    219   int result = 0;
    220 
    221   result = mm_camera_lib_close(lib_handle);
    222   if (result < 0) {
    223     printf(" Camera close failed\n");
    224   } else {
    225     printf("Camera is closed \n");
    226   }
    227   return result;
    228 }
    229 #if 0
    230 /** tuneserver_start_cam
    231  *    @lib_handle: the camera handle object
    232  *
    233  *  starts the camera
    234  *
    235  *  Return: >=0 on success, -1 on failure.
    236  **/
    237 static int tuneserver_start_cam(mm_camera_lib_handle *lib_handle)
    238 {
    239   int result = 0;
    240 
    241   result = mm_camera_lib_start_stream(lib_handle);
    242   if (result < 0) {
    243     printf(" Camera start failed\n");
    244     goto error1;
    245   }
    246   return result;
    247 error1:
    248   mm_camera_lib_close(lib_handle);
    249   return result;
    250 }
    251 #endif
    252 
    253 /** tuneserver_stop_cam
    254  *    @lib_handle: the camera handle object
    255  *
    256  *  stops the camera
    257  *
    258  *  Return: >=0 on success, -1 on failure.
    259  **/
    260 int tuneserver_stop_cam(mm_camera_lib_handle *lib_handle)
    261 {
    262   int result = 0;
    263 
    264   result = mm_camera_lib_stop_stream(lib_handle);
    265   if (result < 0) {
    266     printf(" Camera stop failed\n");
    267   }
    268 //  result = mm_camera_lib_close(lib_handle);
    269   return result;
    270 }
    271 
    272 /** tuneserver_open_cam
    273  *    @lib_handle: the camera handle object
    274  *
    275  *  opens the camera
    276  *
    277  *  Return: >=0 on success, -1 on failure.
    278  **/
    279 #if 1
    280 int tuneserver_open_cam(mm_camera_lib_handle *lib_handle)
    281 {
    282   int result = 0;
    283 
    284   LOGD("E");
    285   result = mm_camera_load_tuninglibrary(&lib_handle->tsctrl.tuning_params);
    286   if (result < 0) {
    287     LOGE(" tuning library open failed\n");
    288   }
    289   return result;
    290 }
    291 #endif
    292