Home | History | Annotate | Download | only in inc
      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 
     19 
     20 #ifndef CAMERA_PROPERTIES_H
     21 #define CAMERA_PROPERTIES_H
     22 
     23 #include <utils/KeyedVector.h>
     24 #include <utils/String8.h>
     25 #include <stdio.h>
     26 #include <dirent.h>
     27 #include <errno.h>
     28 #include <stdio.h>
     29 #include <string.h>
     30 #include <ctype.h>
     31 #include "cutils/properties.h"
     32 
     33 #include "Common.h"
     34 
     35 namespace Ti {
     36 namespace Camera {
     37 
     38 #define MAX_CAMERAS_SUPPORTED 3
     39 #define MAX_SIMUL_CAMERAS_SUPPORTED 1
     40 #define MAX_PROP_NAME_LENGTH 50
     41 #define MAX_PROP_VALUE_LENGTH 2048
     42 
     43 #define REMAINING_BYTES(buff) ((((int)sizeof(buff) - 1 - (int)strlen(buff)) < 0) ? 0 : (sizeof(buff) - 1 - strlen(buff)))
     44 
     45 enum OperatingMode {
     46     MODE_HIGH_SPEED = 0,
     47     MODE_HIGH_QUALITY,
     48     MODE_ZEROSHUTTERLAG,
     49     MODE_VIDEO,
     50     MODE_STEREO,
     51     MODE_CPCAM,
     52     MODE_VIDEO_HIGH_QUALITY,
     53     MODE_MAX
     54 };
     55 
     56 // Class that handles the Camera Properties
     57 class CameraProperties
     58 {
     59 public:
     60     static const char INVALID[];
     61     static const char CAMERA_NAME[];
     62     static const char CAMERA_SENSOR_INDEX[];
     63     static const char CAMERA_SENSOR_ID[];
     64     static const char ORIENTATION_INDEX[];
     65     static const char FACING_INDEX[];
     66     static const char SUPPORTED_PREVIEW_SIZES[];
     67     static const char SUPPORTED_PREVIEW_SUBSAMPLED_SIZES[];
     68     static const char SUPPORTED_PREVIEW_TOPBOTTOM_SIZES[];
     69     static const char SUPPORTED_PREVIEW_SIDEBYSIDE_SIZES[];
     70     static const char SUPPORTED_PREVIEW_FORMATS[];
     71     static const char SUPPORTED_PREVIEW_FRAME_RATES[];
     72     static const char SUPPORTED_PREVIEW_FRAME_RATES_EXT[];
     73     static const char SUPPORTED_PICTURE_SIZES[];
     74     static const char SUPPORTED_PICTURE_SUBSAMPLED_SIZES[];
     75     static const char SUPPORTED_PICTURE_TOPBOTTOM_SIZES[];
     76     static const char SUPPORTED_PICTURE_SIDEBYSIDE_SIZES[];
     77     static const char SUPPORTED_PICTURE_FORMATS[];
     78     static const char SUPPORTED_THUMBNAIL_SIZES[];
     79     static const char SUPPORTED_WHITE_BALANCE[];
     80     static const char SUPPORTED_EFFECTS[];
     81     static const char SUPPORTED_ANTIBANDING[];
     82     static const char SUPPORTED_EXPOSURE_MODES[];
     83     static const char SUPPORTED_MANUAL_EXPOSURE_MIN[];
     84     static const char SUPPORTED_MANUAL_EXPOSURE_MAX[];
     85     static const char SUPPORTED_MANUAL_EXPOSURE_STEP[];
     86     static const char SUPPORTED_MANUAL_GAIN_ISO_MIN[];
     87     static const char SUPPORTED_MANUAL_GAIN_ISO_MAX[];
     88     static const char SUPPORTED_MANUAL_GAIN_ISO_STEP[];
     89     static const char SUPPORTED_EV_MIN[];
     90     static const char SUPPORTED_EV_MAX[];
     91     static const char SUPPORTED_EV_STEP[];
     92     static const char SUPPORTED_ISO_VALUES[];
     93     static const char SUPPORTED_SCENE_MODES[];
     94     static const char SUPPORTED_FLASH_MODES[];
     95     static const char SUPPORTED_FOCUS_MODES[];
     96     static const char REQUIRED_PREVIEW_BUFS[];
     97     static const char REQUIRED_IMAGE_BUFS[];
     98     static const char SUPPORTED_ZOOM_RATIOS[];
     99     static const char SUPPORTED_ZOOM_STAGES[];
    100     static const char SUPPORTED_IPP_MODES[];
    101     static const char SMOOTH_ZOOM_SUPPORTED[];
    102     static const char ZOOM_SUPPORTED[];
    103     static const char PREVIEW_SIZE[];
    104     static const char PREVIEW_FORMAT[];
    105     static const char PREVIEW_FRAME_RATE[];
    106     static const char ZOOM[];
    107     static const char PICTURE_SIZE[];
    108     static const char PICTURE_FORMAT[];
    109     static const char JPEG_THUMBNAIL_SIZE[];
    110     static const char WHITEBALANCE[];
    111     static const char EFFECT[];
    112     static const char ANTIBANDING[];
    113     static const char EXPOSURE_MODE[];
    114     static const char EV_COMPENSATION[];
    115     static const char ISO_MODE[];
    116     static const char FOCUS_MODE[];
    117     static const char SCENE_MODE[];
    118     static const char FLASH_MODE[];
    119     static const char JPEG_QUALITY[];
    120     static const char BRIGHTNESS[];
    121     static const char SATURATION[];
    122     static const char SHARPNESS[];
    123     static const char CONTRAST[];
    124     static const char IPP[];
    125     static const char GBCE[];
    126     static const char SUPPORTED_GBCE[];
    127     static const char GLBCE[];
    128     static const char SUPPORTED_GLBCE[];
    129     static const char AUTOCONVERGENCE_MODE[];
    130     static const char AUTOCONVERGENCE_MODE_VALUES[];
    131     static const char MANUAL_CONVERGENCE[];
    132     static const char SUPPORTED_MANUAL_CONVERGENCE_MIN[];
    133     static const char SUPPORTED_MANUAL_CONVERGENCE_MAX[];
    134     static const char SUPPORTED_MANUAL_CONVERGENCE_STEP[];
    135     static const char SENSOR_ORIENTATION[];
    136     static const char SENSOR_ORIENTATION_VALUES[];
    137     static const char REVISION[];
    138     static const char FOCAL_LENGTH[];
    139     static const char HOR_ANGLE[];
    140     static const char VER_ANGLE[];
    141     static const char EXIF_MAKE[];
    142     static const char EXIF_MODEL[];
    143     static const char JPEG_THUMBNAIL_QUALITY[];
    144     static const char MAX_FOCUS_AREAS[];
    145     static const char MAX_FD_HW_FACES[];
    146     static const char MAX_FD_SW_FACES[];
    147 
    148     static const char MAX_PICTURE_WIDTH[];
    149     static const char MAX_PICTURE_HEIGHT[];
    150 
    151     static const char PARAMS_DELIMITER [];
    152 
    153     static const char S3D_PRV_FRAME_LAYOUT[];
    154     static const char S3D_PRV_FRAME_LAYOUT_VALUES[];
    155     static const char S3D_CAP_FRAME_LAYOUT[];
    156     static const char S3D_CAP_FRAME_LAYOUT_VALUES[];
    157     static const char VSTAB[];
    158     static const char VSTAB_SUPPORTED[];
    159     static const char VNF[];
    160     static const char VNF_SUPPORTED[];
    161     static const char FRAMERATE_RANGE[];
    162     static const char FRAMERATE_RANGE_SUPPORTED[];
    163     static const char FRAMERATE_RANGE_EXT_SUPPORTED[];
    164 
    165     static const char DEFAULT_VALUE[];
    166 
    167     static const char AUTO_EXPOSURE_LOCK[];
    168     static const char AUTO_EXPOSURE_LOCK_SUPPORTED[];
    169     static const char AUTO_WHITEBALANCE_LOCK[];
    170     static const char AUTO_WHITEBALANCE_LOCK_SUPPORTED[];
    171     static const char MAX_NUM_METERING_AREAS[];
    172     static const char METERING_AREAS[];
    173     static const char MAX_NUM_FOCUS_AREAS[];
    174 
    175     static const char VIDEO_SNAPSHOT_SUPPORTED[];
    176 
    177     static const char VIDEO_SIZE[];
    178     static const char SUPPORTED_VIDEO_SIZES[];
    179 
    180     static const char MECHANICAL_MISALIGNMENT_CORRECTION_SUPPORTED[];
    181     static const char MECHANICAL_MISALIGNMENT_CORRECTION[];
    182 
    183     static const char RAW_WIDTH[];
    184     static const char RAW_HEIGHT[];
    185 
    186     static const char CAP_MODE_VALUES[];
    187 
    188     CameraProperties();
    189     ~CameraProperties();
    190 
    191     // container class passed around for accessing properties
    192     class Properties
    193     {
    194         public:
    195 
    196             Properties()
    197             {
    198             }
    199 
    200             ~Properties()
    201             {
    202             }
    203 
    204             void set(const char *prop, const char *value);
    205             void set(const char *prop, int value);
    206             const char* get(const char * prop) const;
    207             int getInt(const char * prop) const;
    208             void setSensorIndex(int idx);
    209             void setMode(OperatingMode mode);
    210             OperatingMode getMode() const;
    211             void dump();
    212 
    213         protected:
    214             const char* keyAt(const unsigned int) const;
    215             const char* valueAt(const unsigned int) const;
    216 
    217         private:
    218             OperatingMode mCurrentMode;
    219             android::DefaultKeyedVector<android::String8, android::String8> mProperties[MODE_MAX];
    220 
    221     };
    222 
    223     ///Initializes the CameraProperties class
    224     status_t initialize();
    225     status_t loadProperties();
    226     int camerasSupported();
    227     int getProperties(int cameraIndex, Properties** properties);
    228 
    229 private:
    230 
    231     int mCamerasSupported;
    232     int mInitialized;
    233     mutable android::Mutex mLock;
    234 
    235     Properties mCameraProps[MAX_CAMERAS_SUPPORTED];
    236 
    237 };
    238 
    239 } // namespace Camera
    240 } // namespace Ti
    241 
    242 #endif //CAMERA_PROPERTIES_H
    243