Home | History | Annotate | Download | only in camera
      1 /*
      2  * Copyright (C) Texas Instruments - http://www.ti.com/
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 /**
     18 * @file CameraProperties.cpp
     19 *
     20 * This file maps the CameraHardwareInterface to the Camera interfaces on OMAP4 (mainly OMX).
     21 *
     22 */
     23 
     24 //#include "CameraHal.h"
     25 #include <utils/threads.h>
     26 
     27 #include "DebugUtils.h"
     28 #include "CameraProperties.h"
     29 
     30 #define CAMERA_ROOT         "CameraRoot"
     31 #define CAMERA_INSTANCE     "CameraInstance"
     32 
     33 namespace android {
     34 
     35 // lower entries have higher priority
     36 static const char* g_camera_adapters[] = {
     37 #ifdef OMAP4_SUPPORT_OMX_CAMERA_ADAPTER
     38     "libomxcameraadapter.so",
     39 #endif
     40 #ifdef OMAP4_SUPPORT_USB_CAMERA_ADAPTER
     41     "libusbcameraadapter.so"
     42 #endif
     43 };
     44 
     45 /*********************************************************
     46  CameraProperties - public function implemetation
     47 **********************************************************/
     48 
     49 CameraProperties::CameraProperties() : mCamerasSupported(0)
     50 {
     51     LOG_FUNCTION_NAME;
     52 
     53     mCamerasSupported = 0;
     54     mInitialized = 0;
     55 
     56     LOG_FUNCTION_NAME_EXIT;
     57 }
     58 
     59 CameraProperties::~CameraProperties()
     60 {
     61     LOG_FUNCTION_NAME;
     62 
     63     LOG_FUNCTION_NAME_EXIT;
     64 }
     65 
     66 
     67 // Initializes the CameraProperties class
     68 status_t CameraProperties::initialize()
     69 {
     70     LOG_FUNCTION_NAME;
     71 
     72     status_t ret;
     73 
     74     Mutex::Autolock lock(mLock);
     75 
     76     if(mInitialized)
     77         return NO_ERROR;
     78 
     79     ret = loadProperties();
     80 
     81     mInitialized = 1;
     82 
     83     LOG_FUNCTION_NAME_EXIT;
     84 
     85     return ret;
     86 }
     87 
     88 extern "C" int CameraAdapter_Capabilities(CameraProperties::Properties* properties_array,
     89                                           const unsigned int starting_camera,
     90                                           const unsigned int max_camera);
     91 
     92 ///Loads all the Camera related properties
     93 status_t CameraProperties::loadProperties()
     94 {
     95     LOG_FUNCTION_NAME;
     96 
     97     status_t ret = NO_ERROR;
     98 
     99     // adapter updates capabilities and we update camera count
    100     mCamerasSupported = CameraAdapter_Capabilities(mCameraProps, mCamerasSupported, MAX_CAMERAS_SUPPORTED);
    101 
    102     if((int)mCamerasSupported < 0) {
    103         ALOGE("error while getting capabilities");
    104         ret = UNKNOWN_ERROR;
    105     } else if (mCamerasSupported > MAX_CAMERAS_SUPPORTED) {
    106         ALOGE("returned too many adapaters");
    107         ret = UNKNOWN_ERROR;
    108     } else {
    109         ALOGE("num_cameras = %d", mCamerasSupported);
    110 
    111         for (unsigned int i = 0; i < mCamerasSupported; i++) {
    112             mCameraProps[i].set(CAMERA_SENSOR_INDEX, i);
    113             mCameraProps[i].dump();
    114         }
    115     }
    116 
    117     ALOGV("mCamerasSupported = %d", mCamerasSupported);
    118     LOG_FUNCTION_NAME_EXIT;
    119     return ret;
    120 }
    121 
    122 // Returns the number of Cameras found
    123 int CameraProperties::camerasSupported()
    124 {
    125     LOG_FUNCTION_NAME;
    126     return mCamerasSupported;
    127 }
    128 
    129 };
    130