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 "CameraProperties.h" 25 26#define CAMERA_ROOT "CameraRoot" 27#define CAMERA_INSTANCE "CameraInstance" 28 29namespace Ti { 30namespace Camera { 31 32// lower entries have higher priority 33static const char* g_camera_adapters[] = { 34#ifdef OMAP4_SUPPORT_OMX_CAMERA_ADAPTER 35 "libomxcameraadapter.so", 36#endif 37#ifdef OMAP4_SUPPORT_USB_CAMERA_ADAPTER 38 "libusbcameraadapter.so" 39#endif 40}; 41 42/********************************************************* 43 CameraProperties - public function implemetation 44**********************************************************/ 45 46CameraProperties::CameraProperties() : mCamerasSupported(0) 47{ 48 LOG_FUNCTION_NAME; 49 50 mCamerasSupported = 0; 51 mInitialized = 0; 52 53 LOG_FUNCTION_NAME_EXIT; 54} 55 56CameraProperties::~CameraProperties() 57{ 58 LOG_FUNCTION_NAME; 59 60 LOG_FUNCTION_NAME_EXIT; 61} 62 63 64// Initializes the CameraProperties class 65status_t CameraProperties::initialize() 66{ 67 LOG_FUNCTION_NAME; 68 69 status_t ret; 70 71 android::AutoMutex lock(mLock); 72 73 if(mInitialized) 74 return NO_ERROR; 75 76 ret = loadProperties(); 77 78 if (ret == NO_ERROR) { 79 mInitialized = 1; 80 } 81 82 LOG_FUNCTION_NAME_EXIT; 83 84 return ret; 85} 86 87extern "C" status_t CameraAdapter_Capabilities(CameraProperties::Properties* properties_array, 88 int starting_camera, int max_camera, int & supported_cameras); 89 90///Loads all the Camera related properties 91status_t CameraProperties::loadProperties() 92{ 93 LOG_FUNCTION_NAME; 94 95 status_t ret = NO_ERROR; 96 97 //Must be re-initialized here, since loadProperties() could potentially be called more than once. 98 mCamerasSupported = 0; 99 100 // adapter updates capabilities and we update camera count 101 const status_t err = CameraAdapter_Capabilities(mCameraProps, mCamerasSupported, 102 MAX_CAMERAS_SUPPORTED, mCamerasSupported); 103 104 if(err != NO_ERROR) { 105 CAMHAL_LOGE("error while getting capabilities"); 106 ret = UNKNOWN_ERROR; 107 } else if (mCamerasSupported == 0) { 108 CAMHAL_LOGE("camera busy. properties not loaded. num_cameras = %d", mCamerasSupported); 109 ret = UNKNOWN_ERROR; 110 } else if (mCamerasSupported > MAX_CAMERAS_SUPPORTED) { 111 CAMHAL_LOGE("returned too many adapaters"); 112 ret = UNKNOWN_ERROR; 113 } else { 114 CAMHAL_LOGI("num_cameras = %d", mCamerasSupported); 115 116 for (int i = 0; i < mCamerasSupported; i++) { 117 mCameraProps[i].setSensorIndex(i); 118 mCameraProps[i].dump(); 119 } 120 } 121 122 CAMHAL_LOGV("mCamerasSupported = %d", mCamerasSupported); 123 LOG_FUNCTION_NAME_EXIT; 124 return ret; 125} 126 127// Returns the number of Cameras found 128int CameraProperties::camerasSupported() 129{ 130 LOG_FUNCTION_NAME; 131 return mCamerasSupported; 132} 133 134} // namespace Camera 135} // namespace Ti 136