author | Lawrence Mok <lawrence.mok@amlogic.com> | 2011-11-30 03:53:52 (GMT) |
---|---|---|
committer | Lawrence Mok <lawrence.mok@amlogic.com> | 2011-11-30 03:53:52 (GMT) |
commit | d6732b466fdb808cf3cdd00fdebb0ae54727318a (patch) | |
tree | ff4cb470b3403a0bc8d74e3e56ef355b1e0a98ba | |
parent | f9e38a19becf6274c0028ee2de4fc448a38451ca (diff) | |
download | camera-d6732b466fdb808cf3cdd00fdebb0ae54727318a.zip camera-d6732b466fdb808cf3cdd00fdebb0ae54727318a.tar.gz camera-d6732b466fdb808cf3cdd00fdebb0ae54727318a.tar.bz2 |
support 2 cameras
-rw-r--r-- | Android.mk | 29 | ||||
-rw-r--r-- | V4LCameraAdapter/V4LCameraAdapter.cpp | 43 | ||||
-rw-r--r-- | inc/CameraProperties.h | 7 | ||||
-rw-r--r-- | inc/V4LCameraAdapter/V4LCameraAdapter.h | 2 |
4 files changed, 51 insertions, 30 deletions
@@ -47,12 +47,6 @@ LOCAL_C_INCLUDES += \ external/jpeg/ \ hardware/libhardware/modules/gralloc/ - #$(LOCAL_PATH)/../include \ - #$(LOCAL_PATH)/../hwc \ - #hardware/ti/omap4xxx/tiler \ - #hardware/ti/omap4xxx/ion \ - #frameworks/base/include/media/stagefright/openmax - LOCAL_SHARED_LIBRARIES:= \ libui \ libbinder \ @@ -63,11 +57,28 @@ LOCAL_SHARED_LIBRARIES:= \ libjpeg \ libgui - #libtiutils \ - #libion \ - LOCAL_CFLAGS := -fno-short-enums -DCOPY_IMAGE_BUFFER +ifeq ($(BOARD_HAVE_FRONT_CAM),true) + LOCAL_CFLAGS += -DAMLOGIC_FRONT_CAMERA_SUPPORT +endif + +ifeq ($(BOARD_HAVE_BACK_CAM),true) + LOCAL_CFLAGS += -DAMLOGIC_BACK_CAMERA_SUPPORT +endif + +ifeq ($(BOARD_USE_USB_CAMERA),true) + LOCAL_CFLAGS += -DAMLOGIC_USB_CAMERA_SUPPORT + LOCAL_SRC_FILES += util.cpp +else + ifeq ($(BOARD_HAVE_MULTI_CAMERAS),true) + LOCAL_CFLAGS += -DAMLOGIC_MULTI_CAMERA_SUPPORT + endif + ifeq ($(BOARD_HAVE_FLASHLIGHT),true) + LOCAL_CFLAGS += -DAMLOGIC_FLASHLIGHT_SUPPORT + endif +endif + LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw LOCAL_MODULE:= camera.amlogic LOCAL_MODULE_TAGS:= optional diff --git a/V4LCameraAdapter/V4LCameraAdapter.cpp b/V4LCameraAdapter/V4LCameraAdapter.cpp index b2ab198..2d218e6 100644 --- a/V4LCameraAdapter/V4LCameraAdapter.cpp +++ b/V4LCameraAdapter/V4LCameraAdapter.cpp @@ -54,6 +54,8 @@ static int mDebugFps = 0; #define HERE(Msg) {CAMHAL_LOGEB("--===line %d, %s===--\n", __LINE__, Msg);} +#define DEVICE_PATH(_sensor_index) (_sensor_index == 0 ? "/dev/video0" : "/dev/video1") + namespace android { #undef LOG_TAG @@ -70,7 +72,6 @@ namespace android { #define FPS_PERIOD 30 Mutex gAdapterLock; -const char *device = DEVICE; /*--------------------junk STARTS here-----------------------------*/ #define SYSFILE_CAMERA_SET_PARA "/sys/class/vm/attr2" @@ -114,7 +115,7 @@ status_t V4LCameraAdapter::initialize(CameraProperties::Properties* caps) return NO_MEMORY; } - if ((mCameraHandle = open(device, O_RDWR)) == -1) + if ((mCameraHandle = open(DEVICE_PATH(mSensorIndex), O_RDWR)) == -1) { CAMHAL_LOGEB("Error while opening handle to V4L2 Camera: %s", strerror(errno)); return -EINVAL; @@ -632,7 +633,7 @@ V4LCameraAdapter::V4LCameraAdapter(size_t sensor_index) { LOG_FUNCTION_NAME; - // Nothing useful to do in the constructor + mSensorIndex = sensor_index; LOG_FUNCTION_NAME_EXIT; } @@ -831,16 +832,16 @@ int V4LCameraAdapter::pictureThread() // --------------------------------------------------------------------------- -extern "C" CameraAdapter* CameraAdapter_Factory() +extern "C" CameraAdapter* CameraAdapter_Factory(size_t sensor_index) { CameraAdapter *adapter = NULL; Mutex::Autolock lock(gAdapterLock); LOG_FUNCTION_NAME; - adapter = new V4LCameraAdapter(0/*sensor_index*/); + adapter = new V4LCameraAdapter(sensor_index); if ( adapter ) { - CAMHAL_LOGDB("New V4L Camera adapter instance created for sensor %d",0/*sensor_index*/); + CAMHAL_LOGDB("New V4L Camera adapter instance created for sensor %d", sensor_index); } else { CAMHAL_LOGEA("Camera adapter create failed!"); } @@ -863,19 +864,14 @@ extern "C" int CameraAdapter_Capabilities(CameraProperties::Properties* properti return -EINVAL; } - // TODO: Need to tell camera properties what other cameras we can support - if (starting_camera + num_cameras_supported < max_camera) { - num_cameras_supported++; - properties = properties_array + starting_camera; + while (starting_camera + num_cameras_supported < max_camera) { + properties = properties_array + starting_camera + num_cameras_supported; properties->set(CameraProperties::CAMERA_NAME, "Camera"); - //TODO move extern void loadCaps(int camera_id, CameraProperties::Properties* params); - loadCaps(0, properties); + loadCaps(starting_camera + num_cameras_supported, properties); + num_cameras_supported++; } - - //------------------------ - LOG_FUNCTION_NAME_EXIT; return num_cameras_supported; @@ -887,7 +883,7 @@ extern "C" int getValidFrameSize(int camera_id, int pixel_format, char *framesiz int fd, i=0; char tempsize[12]; framesize[0] = '\0'; - fd = open(device, O_RDWR); + fd = open(DEVICE_PATH(camera_id), O_RDWR); if (fd >= 0) { memset(&frmsize,0,sizeof(v4l2_frmsizeenum)); for(i=0;;i++){ @@ -963,7 +959,20 @@ extern "C" void loadCaps(int camera_id, CameraProperties::Properties* params) { const char DEFAULT_VIDEO_SIZE[] = "640x480"; const char DEFAULT_PREFERRED_PREVIEW_SIZE_FOR_VIDEO[] = "640x480"; - params->set(CameraProperties::FACING_INDEX, TICameraParameters::FACING_FRONT); + if (camera_id == 0) { +#ifdef AMLOGIC_BACK_CAMERA_SUPPORT + params->set(CameraProperties::FACING_INDEX, TICameraParameters::FACING_BACK); +#else + params->set(CameraProperties::FACING_INDEX, TICameraParameters::FACING_FRONT); +#endif + } else if (camera_id == 1) { +#if defined(AMLOGIC_BACK_CAMERA_SUPPORT) && defined(AMLOGIC_FRONT_CAMERA_SUPPORT) + params->set(CameraProperties::FACING_INDEX, TICameraParameters::FACING_FRONT); +#else + //if support front camera only do we need to add a fake back camera for cts? + //params->set(CameraProperties::FACING_INDEX, TICameraParameters::FACING_BACK); +#endif + } params->set(CameraProperties::ANTIBANDING, DEFAULT_ANTIBANDING); params->set(CameraProperties::BRIGHTNESS, DEFAULT_BRIGHTNESS); params->set(CameraProperties::CONTRAST, DEFAULT_CONTRAST); diff --git a/inc/CameraProperties.h b/inc/CameraProperties.h index ef3b459..1afebc0 100644 --- a/inc/CameraProperties.h +++ b/inc/CameraProperties.h @@ -32,8 +32,11 @@ namespace android {
-//TODO
-#define MAX_CAMERAS_SUPPORTED 1
+#if defined(AMLOGIC_FRONT_CAMERA_SUPPORT) && defined(AMLOGIC_BACK_CAMERA_SUPPORT)
+ #define MAX_CAMERAS_SUPPORTED 2
+#else
+ #define MAX_CAMERAS_SUPPORTED 1
+#endif
#define MAX_SIMUL_CAMERAS_SUPPORTED 1
#define MAX_PROP_NAME_LENGTH 50
#define MAX_PROP_VALUE_LENGTH 2048
diff --git a/inc/V4LCameraAdapter/V4LCameraAdapter.h b/inc/V4LCameraAdapter/V4LCameraAdapter.h index 6085547..e379a53 100644 --- a/inc/V4LCameraAdapter/V4LCameraAdapter.h +++ b/inc/V4LCameraAdapter/V4LCameraAdapter.h @@ -28,8 +28,6 @@ namespace android { #define DEFAULT_PREVIEW_PIXEL_FORMAT V4L2_PIX_FMT_NV21 #define DEFAULT_IMAGE_CAPTURE_PIXEL_FORMAT V4L2_PIX_FMT_RGB24 #define NB_BUFFER 6 -#define DEVICE "/dev/video0" - struct VideoInfo { struct v4l2_capability cap; |