Skip to content

Commit 2d38235

Browse files
committed
1 parent fe1b854 commit 2d38235

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+28487
-0
lines changed

camera/Android.mk

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
LOCAL_PATH := $(call my-dir)
2+
3+
ifneq ($(USE_CAMERA_STUB),true)
4+
ifneq ($(BUILD_TINY_ANDROID),true)
5+
ifeq ($(USE_DEVICE_SPECIFIC_CAMERA),true)
6+
7+
include $(CLEAR_VARS)
8+
9+
# When zero we link against libmmcamera; when 1, we dlopen libmmcamera.
10+
DLOPEN_LIBMMCAMERA := 1
11+
12+
LOCAL_CFLAGS:= -DDLOPEN_LIBMMCAMERA=$(DLOPEN_LIBMMCAMERA)
13+
14+
LOCAL_CFLAGS += -DUSE_ION
15+
16+
LOCAL_CFLAGS += -DCAMERA_ION_HEAP_ID=ION_CAMERA_HEAP_ID
17+
LOCAL_CFLAGS += -DCAMERA_ZSL_ION_HEAP_ID=ION_CAMERA_HEAP_ID
18+
LOCAL_CFLAGS += -DCAMERA_GRALLOC_HEAP_ID=GRALLOC_USAGE_PRIVATE_CAMERA_HEAP
19+
LOCAL_CFLAGS += -DCAMERA_GRALLOC_FALLBACK_HEAP_ID=GRALLOC_USAGE_PRIVATE_SYSTEM_HEAP
20+
LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=GRALLOC_USAGE_PRIVATE_UNCACHED #uncached
21+
LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_CAMERA_HEAP_ID
22+
LOCAL_CFLAGS += -DCAMERA_ZSL_ION_FALLBACK_HEAP_ID=ION_CAMERA_HEAP_ID
23+
24+
LOCAL_HAL_FILES := \
25+
QCameraHAL.cpp QCameraHWI_Parm.cpp\
26+
QCameraHWI.cpp QCameraHWI_Preview.cpp \
27+
QCameraHWI_Record_7x27A.cpp QCameraHWI_Still.cpp \
28+
QCameraHWI_Mem.cpp QCameraHWI_Display.cpp \
29+
QCameraStream.cpp QualcommCamera2.cpp QCameraHWI_Rdi.cpp QCameraParameters.cpp
30+
31+
LOCAL_CFLAGS+= -DHW_ENCODE
32+
33+
LOCAL_SRC_FILES := $(MM_CAM_FILES) $(LOCAL_HAL_FILES)
34+
35+
LOCAL_CFLAGS+= -DNUM_PREVIEW_BUFFERS=4 -D_ANDROID_
36+
37+
# Executed only on QCOM BSPs
38+
ifeq ($(TARGET_USES_QCOM_BSP),true)
39+
# This flag is used to compile out any features that depend on framework changes
40+
common_flags += -DQCOM_BSP
41+
endif
42+
43+
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
44+
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
45+
LOCAL_C_INCLUDES += \
46+
hardware/qcom/display-$(TARGET_QCOM_DISPLAY_VARIANT)/libgralloc \
47+
hardware/qcom/media-$(TARGET_QCOM_MEDIA_VARIANT)/libstagefrighthw \
48+
hardware/qcom/media-$(TARGET_QCOM_MEDIA_VARIANT)/mm-core/inc \
49+
frameworks/base/services/camera/libcameraservice \
50+
frameworks/native/include/media/hardware \
51+
$(LOCAL_PATH)/mm-camera-interface
52+
53+
54+
LOCAL_SHARED_LIBRARIES := \
55+
libcamera_client \
56+
libcutils \
57+
liblog \
58+
libui \
59+
libutils \
60+
libhardware \
61+
libbinder \
62+
libmmcamera_interface2
63+
64+
LOCAL_CFLAGS += -include bionic/libc/kernel/common/linux/socket.h
65+
66+
ifeq ($(DLOPEN_LIBMMCAMERA),1)
67+
LOCAL_SHARED_LIBRARIES += libdl
68+
LOCAL_CFLAGS += -DDLOPEN_LIBMMCAMERA
69+
else
70+
LOCAL_SHARED_LIBRARIES += liboemcamera
71+
endif
72+
73+
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
74+
LOCAL_MODULE := camera.$(TARGET_BOARD_PLATFORM)
75+
LOCAL_MODULE_TAGS := optional
76+
include $(BUILD_SHARED_LIBRARY)
77+
endif # BUILD_TINY_ANDROID
78+
endif # USE_CAMERA_STUB
79+
endif # USE_DEVICE_SPECIFIC_CAMERA
80+
81+
include $(LOCAL_PATH)/mm-camera-interface/Android.mk

camera/MODULE_LICENSE_BSD

Whitespace-only changes.

camera/QCameraHAL.cpp

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/*
2+
** Copyright (c) 2011 The Linux Foundation. All rights reserved.
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+
/*#error uncomment this for compiler test!*/
18+
//#define ALOG_NDEBUG 0
19+
#define ALOG_NIDEBUG 0
20+
#define LOG_TAG "QCameraHAL"
21+
#include <utils/Log.h>
22+
#include <utils/threads.h>
23+
#include <fcntl.h>
24+
#include <sys/mman.h>
25+
26+
27+
/* include QCamera Hardware Interface Header*/
28+
#include "QCameraHAL.h"
29+
30+
int HAL_numOfCameras = 0;
31+
qcamera_info_t HAL_cameraInfo[MSM_MAX_CAMERA_SENSORS];
32+
mm_camera_t * HAL_camerahandle[MSM_MAX_CAMERA_SENSORS];
33+
int HAL_currentCameraMode;
34+
35+
namespace android {
36+
/* HAL function implementation goes here*/
37+
38+
/**
39+
* The functions need to be provided by the camera HAL.
40+
*
41+
* If getNumberOfCameras() returns N, the valid cameraId for getCameraInfo()
42+
* and openCameraHardware() is 0 to N-1.
43+
*/
44+
extern "C" int HAL_getNumberOfCameras()
45+
{
46+
/* try to query every time we get the call!*/
47+
uint8_t num_camera = 0;
48+
mm_camera_t * handle_base = 0;
49+
ALOGV("%s: E", __func__);
50+
51+
handle_base= mm_camera_query(&num_camera);
52+
53+
if (!handle_base) {
54+
HAL_numOfCameras = 0;
55+
}
56+
else
57+
{
58+
qcamera_info_t* p_camera_info = 0;
59+
HAL_numOfCameras=num_camera;
60+
ALOGI("Handle base =0x%p",handle_base);
61+
ALOGI("getCameraInfo: numOfCameras = %d", HAL_numOfCameras);
62+
for(int i = 0; i < HAL_numOfCameras; i++) {
63+
ALOGI("Handle [%d]=0x%p",i,handle_base+i);
64+
HAL_camerahandle[i]=handle_base + i;
65+
p_camera_info = &(HAL_camerahandle[i]->camera_info);
66+
if (p_camera_info) {
67+
ALOGI("Camera sensor %d info:", i);
68+
ALOGI("camera_id: %d", p_camera_info->camera_id);
69+
ALOGI("modes_supported: %x", p_camera_info->modes_supported);
70+
ALOGI("position: %d", p_camera_info->position);
71+
ALOGI("sensor_mount_angle: %d", p_camera_info->sensor_mount_angle);
72+
}
73+
}
74+
}
75+
76+
ALOGV("%s: X", __func__);
77+
78+
return HAL_numOfCameras;
79+
}
80+
81+
extern "C" int HAL_isIn3DMode()
82+
{
83+
return HAL_currentCameraMode == CAMERA_MODE_3D;
84+
}
85+
86+
extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo* cameraInfo)
87+
{
88+
mm_camera_t *mm_camer_obj = 0;
89+
ALOGD("%s: E", __func__);
90+
91+
if (!HAL_numOfCameras || HAL_numOfCameras < cameraId || !cameraInfo)
92+
return;
93+
else
94+
mm_camer_obj = HAL_camerahandle[cameraId];
95+
96+
if (!mm_camer_obj)
97+
return;
98+
else {
99+
cameraInfo->facing =
100+
(FRONT_CAMERA == mm_camer_obj->camera_info.position)?
101+
CAMERA_FACING_FRONT : CAMERA_FACING_BACK;
102+
103+
cameraInfo->orientation = mm_camer_obj->camera_info.sensor_mount_angle;
104+
#if 0
105+
// TODO: fix me
106+
/* We always supprot ZSL in our stack*/
107+
cameraInfo->mode = CAMERA_SUPPORT_MODE_ZSL;
108+
if (mm_camer_obj->camera_info.modes_supported & CAMERA_MODE_2D) {
109+
cameraInfo->mode |= CAMERA_SUPPORT_MODE_2D;
110+
}
111+
if (mm_camer_obj->camera_info.modes_supported & CAMERA_MODE_3D) {
112+
cameraInfo->mode |= CAMERA_SUPPORT_MODE_3D;
113+
}
114+
#endif
115+
}
116+
ALOGV("%s: X", __func__);
117+
return;
118+
}
119+
120+
/* HAL should return NULL if it fails to open camera hardware. */
121+
extern "C" void * HAL_openCameraHardware(int cameraId, int mode)
122+
{
123+
ALOGV("%s: E", __func__);
124+
if (!HAL_numOfCameras || HAL_numOfCameras < cameraId ||cameraId < 0) {
125+
return NULL;
126+
}
127+
return QCameraHAL_openCameraHardware(cameraId, mode);
128+
}
129+
130+
131+
}; // namespace android

camera/QCameraHAL.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
** Copyright (c) 2011 The Linux Foundation. All rights reserved.
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+
#ifndef ANDROID_HARDWARE_QCAMERA_HAL_H
18+
#define ANDROID_HARDWARE_QCAMERA_HAL_H
19+
20+
21+
#include "QCameraHWI.h"
22+
23+
extern "C" {
24+
#include <mm_camera_interface2.h>
25+
}
26+
namespace android {
27+
28+
/* HAL should return NULL if it fails to open camera hardware. */
29+
extern "C" void *
30+
QCameraHAL_openCameraHardware(int cameraId, int mode);
31+
extern "C" int HAL_getNumberOfCameras();
32+
extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo* cameraInfo);
33+
34+
}; // namespace android
35+
36+
#endif
37+

0 commit comments

Comments
 (0)