Skip to content

Commit

Permalink
Import libcamera from aries-common, and add flag for legacy camera su…
Browse files Browse the repository at this point in the history
…pport to BoardConfig.mk. Camcorder still broken.

Change-Id: Icaea86d2135b637f6b7ef7b418bd3dea9b19db27
  • Loading branch information
UberPinguin committed Jul 16, 2012
1 parent 3196fe0 commit c395d74
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 262 deletions.
1 change: 1 addition & 0 deletions BoardConfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ifeq ($(USE_CAMERA_STUB),false)
BOARD_SECOND_CAMERA_DEVICE := true
BOARD_CAMERA_LIBRARIES := libcamera
endif
ICS_CAMERA_BLOB := true

# OpenGL stuff
USE_OPENGL_RENDERER := true
Expand Down
2 changes: 1 addition & 1 deletion libcamera/Android.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ifeq ($(TARGET_DEVICE),epicmtd)
LOCAL_PATH:= $(call my-dir)
ifeq ($(TARGET_DEVICE),epicmtd)
include $(CLEAR_VARS)

# HAL module implemenation stored in
Expand Down
120 changes: 67 additions & 53 deletions libcamera/SecCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,26 @@ static int fimc_v4l2_s_ctrl(int fp, unsigned int id, unsigned int value)
return ctrl.value;
}

static int fimc_v4l2_s_ext_ctrl(int fp, unsigned int id, void *value)
{
struct v4l2_ext_controls ctrls;
struct v4l2_ext_control ctrl;
int ret;

ctrl.id = id;
ctrl.string = (char *) value;

ctrls.ctrl_class = V4L2_CTRL_CLASS_CAMERA;
ctrls.count = 1;
ctrls.controls = &ctrl;

ret = ioctl(fp, VIDIOC_S_EXT_CTRLS, &ctrls);
if (ret < 0)
ALOGE("ERR(%s):VIDIOC_S_EXT_CTRLS failed\n", __func__);

return ret;
}

static int fimc_v4l2_g_parm(int fp, struct v4l2_streamparm *streamparm)
{
int ret;
Expand Down Expand Up @@ -787,7 +807,6 @@ int SecCamera::startPreview(void)
// More parameters for CE147
ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FOCUS_MODE, m_params->focus_mode);
CHECK(ret);
// TODO
m_face_detect = 0;
ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FACE_DETECTION, m_face_detect);
CHECK(ret);
Expand All @@ -801,7 +820,6 @@ int SecCamera::startPreview(void)
m_beauty_shot = 0;
ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BEAUTY_SHOT, m_beauty_shot);
CHECK(ret);
// TODO
m_zoom_level = 0;
ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_ZOOM, m_zoom_level);
CHECK(ret);
Expand Down Expand Up @@ -1098,7 +1116,7 @@ int SecCamera::setPreviewSize(int width, int height, int pixel_format)

int v4lpixelformat = pixel_format;

#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0
#if defined(ALOG_NDEBUG) && ALOG_NDEBUG == 0
if (v4lpixelformat == V4L2_PIX_FMT_YUV420)
ALOGV("PreviewFormat:V4L2_PIX_FMT_YUV420");
else if (v4lpixelformat == V4L2_PIX_FMT_NV12)
Expand Down Expand Up @@ -1195,50 +1213,52 @@ int SecCamera::setSnapshotCmd(void)
ret = fimc_v4l2_streamon(m_cam_fd);
CHECK(ret);

// Additional calls needed for CE147

// GPS
//ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_LATITUDE, &gpsInfoLatitude);
//CHECK(ret);
//ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_LONGITUDE, &gpsInfoLongitude);
//CHECK(ret);
//ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_ALTITUDE, &gpsInfoAltitude);
//CHECK(ret);
//ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_PROCESSINGMETHOD, mExifInfo.gps_processing_method);
//CHECK(ret);
//unsigned long temp = m_gps_timestamp;
//ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_TIMESTAMP, &temp);
//CHECK(ret);

ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_LATITUDE, &gpsInfoLatitude);
CHECK(ret);
ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_LONGITUDE, &gpsInfoLongitude);
CHECK(ret);
ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_ALTITUDE, &gpsInfoAltitude);
CHECK(ret);
ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_PROCESSINGMETHOD,
mExifInfo.gps_processing_method);
CHECK(ret);
unsigned long temp = m_gps_timestamp;
ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_GPS_TIMESTAMP, &temp);
CHECK(ret);

// Time
//time_t rawtime;
//time(&rawtime);
//struct tm *timeinfo = localtime(&rawtime);
//ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_EXIF_TIME_INFO, timeinfo);
//CHECK(ret);
time_t rawtime;
time(&rawtime);
struct tm *timeinfo = localtime(&rawtime);
ret = fimc_v4l2_s_ext_ctrl(m_cam_fd, V4L2_CID_CAMERA_EXIF_TIME_INFO, timeinfo);
CHECK(ret);

// Orientation
//int orientation;
//switch (m_exif_orientation) {
//case 0:
// orientation = EXIF_ORIENTATION_UP;
// break;
//case 90:
// orientation = EXIF_ORIENTATION_90;
// break;
//case 180:
// orientation = EXIF_ORIENTATION_180;
// break;
//case 270:
// orientation = EXIF_ORIENTATION_270;
// break;
//default:
// orientation = EXIF_ORIENTATION_UP;
// break;
// }
// ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_EXIF_ORIENTATION, orientation);
// CHECK(ret);
// ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CAPTURE, 0);
// CHECK(ret);
int orientation;
switch (m_exif_orientation) {
case 0:
orientation = EXIF_ORIENTATION_UP;
break;
case 90:
orientation = EXIF_ORIENTATION_90;
break;
case 180:
orientation = EXIF_ORIENTATION_180;
break;
case 270:
orientation = EXIF_ORIENTATION_270;
break;
default:
orientation = EXIF_ORIENTATION_UP;
break;
}
ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_EXIF_ORIENTATION, orientation);
CHECK(ret);
ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_CAPTURE, 0);
CHECK(ret);

LOG_TIME_END(1)

Expand Down Expand Up @@ -1443,7 +1463,7 @@ int SecCamera::getSnapshotAndJpeg(unsigned char *yuv_buf, unsigned char *jpeg_bu
m_events_c.fd = m_cam_fd;
m_events_c.events = POLLIN | POLLERR;

#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0
#if defined(ALOG_NDEBUG) && ALOG_NDEBUG == 0
if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV420)
ALOGV("SnapshotFormat:V4L2_PIX_FMT_YUV420");
else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12)
Expand Down Expand Up @@ -1629,7 +1649,7 @@ int SecCamera::setSnapshotPixelFormat(int pixel_format)
m_snapshot_v4lformat = v4lpixelformat;
}

#if defined(LOG_NDEBUG) && LOG_NDEBUG == 0
#if defined(ALOG_NDEBUG) && ALOG_NDEBUG == 0
if (m_snapshot_v4lformat == V4L2_PIX_FMT_YUV420)
ALOGE("%s : SnapshotFormat:V4L2_PIX_FMT_YUV420", __func__);
else if (m_snapshot_v4lformat == V4L2_PIX_FMT_NV12)
Expand Down Expand Up @@ -2519,7 +2539,6 @@ int SecCamera::setGPSLatitude(const char *gps_latitude)
m_gps_latitude = lround(strtod(gps_latitude, NULL) * 10000000);
}


if (m_camera_id == CAMERA_ID_BACK) {
if (m_gps_enabled) {
long tmp = (m_gps_latitude >= 0) ? m_gps_latitude : -m_gps_latitude;
Expand All @@ -2536,7 +2555,7 @@ int SecCamera::setGPSLatitude(const char *gps_latitude)
gpsInfoLatitude.second = 0;
}
}

ALOGV("%s(m_gps_latitude(%ld))", __func__, m_gps_latitude);
return 0;
}
Expand All @@ -2551,7 +2570,6 @@ int SecCamera::setGPSLongitude(const char *gps_longitude)
m_gps_longitude = lround(strtod(gps_longitude, NULL) * 10000000);
}


if (m_camera_id == CAMERA_ID_BACK) {
if (m_gps_enabled) {
long tmp = (m_gps_longitude >= 0) ? m_gps_longitude : -m_gps_longitude;
Expand All @@ -2568,7 +2586,7 @@ int SecCamera::setGPSLongitude(const char *gps_longitude)
gpsInfoLongitude.second = 0;
}
}

ALOGV("%s(m_gps_longitude(%ld))", __func__, m_gps_longitude);
return 0;
}
Expand All @@ -2582,15 +2600,14 @@ int SecCamera::setGPSAltitude(const char *gps_altitude)
m_gps_altitude = lround(strtod(gps_altitude, NULL) * 100);
}


if (m_camera_id == CAMERA_ID_BACK) {
gpsInfoAltitude.plus_minus = (m_gps_altitude >= 0);
long tmp = gpsInfoAltitude.plus_minus ? m_gps_altitude : -m_gps_altitude;
gpsInfoAltitude.dgree = tmp / 100;
gpsInfoAltitude.minute = tmp % 100;
gpsInfoAltitude.second = 0;
}

ALOGV("%s(m_gps_altitude(%ld))", __func__, m_gps_altitude);
return 0;
}
Expand Down Expand Up @@ -2637,9 +2654,6 @@ int SecCamera::setObjectPosition(int x, int y)
{
ALOGV("%s(setObjectPosition(x=%d, y=%d))", __func__, x, y);

if (m_preview_width ==640)
x = x - 80;

if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJECT_POSITION_X, x) < 0) {
ALOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJECT_POSITION_X", __func__);
return -1;
Expand Down
Loading

0 comments on commit c395d74

Please sign in to comment.