QCamera2: Port HAL for 64 bit platforms
- Added -Wextra compiler warning level.
- Avoiding implicit datatype conversions
and also pointer to integer conversions,
including literals.
- Avoiding pointer conversions between different types
other than (void*).
- Using 'size_t' to store memory size and indexes.
- Removed some unused variables.
- Changed datatype of some iterators to match their
corresponding limiter types.
- Using double instead of float where possible.
- Changed bitmasks to unsigned types.
- Updated printf/scanf format string specifiers to match
actual type of arguments.
- Using 'String8' instead of 'char[]' where possible
at QCameraParameters.
- Checking result of QCameraMemory::getSize().
- Fixes build errors and warnings.
CRs-Fixed: 641033
Change-Id: Ief2157b32e447af422456165552ee170a82d2652
diff --git a/QCamera2/HAL/Android.mk b/QCamera2/HAL/Android.mk
index 087d1eb..9122855 100644
--- a/QCamera2/HAL/Android.mk
+++ b/QCamera2/HAL/Android.mk
@@ -17,7 +17,8 @@
QCameraThermalAdapter.cpp \
wrapper/QualcommCamera.cpp
-LOCAL_CFLAGS = -Wall -Werror
+LOCAL_CFLAGS = -Wall -Wextra -Werror
+
#Debug logs are enabled
#LOCAL_CFLAGS += -DDISABLE_DEBUG_LOG
diff --git a/QCamera2/HAL/QCamera2Factory.cpp b/QCamera2/HAL/QCamera2Factory.cpp
index 36d44ee..0227868 100644
--- a/QCamera2/HAL/QCamera2Factory.cpp
+++ b/QCamera2/HAL/QCamera2Factory.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundataion. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundataion. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -135,7 +135,7 @@
return INVALID_OPERATION;
}
- rc = QCamera2HardwareInterface::getCapabilities(camera_id, info);
+ rc = QCamera2HardwareInterface::getCapabilities((uint32_t)camera_id, info);
ALOGV("%s: X", __func__);
return rc;
}
@@ -160,7 +160,7 @@
if (camera_id < 0 || camera_id >= mNumOfCameras)
return BAD_VALUE;
- QCamera2HardwareInterface *hw = new QCamera2HardwareInterface(camera_id);
+ QCamera2HardwareInterface *hw = new QCamera2HardwareInterface((uint32_t)camera_id);
if (!hw) {
ALOGE("Allocation of hardware interface failed");
return NO_MEMORY;
diff --git a/QCamera2/HAL/QCamera2HWI.cpp b/QCamera2/HAL/QCamera2HWI.cpp
index 4ecc20b..2b620fd 100644
--- a/QCamera2/HAL/QCamera2HWI.cpp
+++ b/QCamera2/HAL/QCamera2HWI.cpp
@@ -30,6 +30,7 @@
#define LOG_TAG "QCamera2HWI"
#define ATRACE_TAG ATRACE_TAG_CAMERA
+#include <utils/Log.h>
#include <cutils/properties.h>
#include <hardware/camera.h>
#include <stdlib.h>
@@ -41,7 +42,8 @@
#include "QCamera2HWI.h"
#include "QCameraMem.h"
-#define MAP_TO_DRIVER_COORDINATE(val, base, scale, offset) (val * scale / base + offset)
+#define MAP_TO_DRIVER_COORDINATE(val, base, scale, offset) \
+ ((int32_t)val * (int32_t)scale / (int32_t)base + (int32_t)offset)
#define CAMERA_MIN_STREAMING_BUFFERS 3
#define EXTRA_ZSL_PREVIEW_STREAM_BUF 2
#define CAMERA_MIN_JPEG_ENCODING_BUFFERS 2
@@ -90,18 +92,6 @@
dump: QCamera2HardwareInterface::dump,
};
-
-int32_t QCamera2HardwareInterface::getEffectValue(const char *effect)
-{
- uint32_t cnt = 0;
- while(NULL != QCameraParameters::EFFECT_MODES_MAP[cnt].desc) {
- if(!strcmp(QCameraParameters::EFFECT_MODES_MAP[cnt].desc, effect)) {
- return QCameraParameters::EFFECT_MODES_MAP[cnt].val;
- }
- cnt++;
- }
- return 0;
-}
/*===========================================================================
* FUNCTION : set_preview_window
*
@@ -207,7 +197,7 @@
}
hw->lockAPI();
qcamera_api_result_t apiResult;
- int32_t rc = hw->processAPI(QCAMERA_SM_EVT_ENABLE_MSG_TYPE, (void *)msg_type);
+ int32_t rc = hw->processAPI(QCAMERA_SM_EVT_ENABLE_MSG_TYPE, (void *)&msg_type);
if (rc == NO_ERROR) {
hw->waitAPIResult(QCAMERA_SM_EVT_ENABLE_MSG_TYPE, &apiResult);
}
@@ -236,7 +226,7 @@
}
hw->lockAPI();
qcamera_api_result_t apiResult;
- int32_t rc = hw->processAPI(QCAMERA_SM_EVT_DISABLE_MSG_TYPE, (void *)msg_type);
+ int32_t rc = hw->processAPI(QCAMERA_SM_EVT_DISABLE_MSG_TYPE, (void *)&msg_type);
if (rc == NO_ERROR) {
hw->waitAPIResult(QCAMERA_SM_EVT_DISABLE_MSG_TYPE, &apiResult);
}
@@ -267,7 +257,7 @@
}
hw->lockAPI();
qcamera_api_result_t apiResult;
- ret = hw->processAPI(QCAMERA_SM_EVT_MSG_TYPE_ENABLED, (void *)msg_type);
+ ret = hw->processAPI(QCAMERA_SM_EVT_MSG_TYPE_ENABLED, (void *)&msg_type);
if (ret == NO_ERROR) {
hw->waitAPIResult(QCAMERA_SM_EVT_MSG_TYPE_ENABLED, &apiResult);
ret = apiResult.enabled;
@@ -407,7 +397,7 @@
hw->lockAPI();
qcamera_api_result_t apiResult;
- ret = hw->processAPI(QCAMERA_SM_EVT_STORE_METADATA_IN_BUFS, (void *)enable);
+ ret = hw->processAPI(QCAMERA_SM_EVT_STORE_METADATA_IN_BUFS, (void *)&enable);
if (ret == NO_ERROR) {
hw->waitAPIResult(QCAMERA_SM_EVT_STORE_METADATA_IN_BUFS, &apiResult);
ret = apiResult.status;
@@ -646,7 +636,7 @@
qcamera_api_result_t apiResult;
/* Prepare snapshot in case LED needs to be flashed */
- if (hw->mFlashNeeded == 1 || hw->mParameters.isChromaFlashEnabled()) {
+ if (hw->mFlashNeeded == true || hw->mParameters.isChromaFlashEnabled()) {
ret = hw->processAPI(QCAMERA_SM_EVT_PREPARE_SNAPSHOT, NULL);
if (ret == NO_ERROR) {
hw->waitAPIResult(QCAMERA_SM_EVT_PREPARE_SNAPSHOT, &apiResult);
@@ -907,7 +897,7 @@
}
hw->lockAPI();
qcamera_api_result_t apiResult;
- ret = hw->processAPI(QCAMERA_SM_EVT_DUMP, (void *)fd);
+ ret = hw->processAPI(QCAMERA_SM_EVT_DUMP, (void *)&fd);
if (ret == NO_ERROR) {
hw->waitAPIResult(QCAMERA_SM_EVT_DUMP, &apiResult);
ret = apiResult.status;
@@ -998,7 +988,7 @@
*
* RETURN : none
*==========================================================================*/
-QCamera2HardwareInterface::QCamera2HardwareInterface(int cameraId)
+QCamera2HardwareInterface::QCamera2HardwareInterface(uint32_t cameraId)
: mCameraId(cameraId),
mCameraHandle(NULL),
mCameraOpened(false),
@@ -1014,8 +1004,8 @@
m_bRecordStarted(false),
m_currentFocusState(CAM_AF_SCANNING),
m_pPowerModule(NULL),
- mDumpFrmCnt(0),
- mDumpSkipCnt(0),
+ mDumpFrmCnt(0U),
+ mDumpSkipCnt(0U),
mThermalLevel(QCAMERA_THERMAL_NO_ADJUSTMENT),
mCancelAutoFocus(false),
mActiveAF(false),
@@ -1026,7 +1016,7 @@
mLiveSnapshotThread(0),
mIntPicThread(0),
mFlashNeeded(false),
- mCaptureRotation(0),
+ mCaptureRotation(0U),
mIs3ALocked(false),
mPrepSnapRun(false),
mZoomLevel(0),
@@ -1163,7 +1153,7 @@
ALOGE("Failure: Camera already opened");
return ALREADY_EXISTS;
}
- mCameraHandle = camera_open(mCameraId);
+ mCameraHandle = camera_open((uint8_t)mCameraId);
if (!mCameraHandle) {
ALOGE("camera_open failed.");
return UNKNOWN_ERROR;
@@ -1347,7 +1337,8 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCamera2HardwareInterface::initCapabilities(int cameraId,mm_camera_vtbl_t *cameraHandle)
+int QCamera2HardwareInterface::initCapabilities(uint32_t cameraId,
+ mm_camera_vtbl_t *cameraHandle)
{
ATRACE_CALL();
int rc = NO_ERROR;
@@ -1416,12 +1407,12 @@
* @cameraId : camera Id
* @info : camera info struct to be filled in with camera capabilities
*
- * RETURN : int32_t type of status
+ * RETURN : int type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCamera2HardwareInterface::getCapabilities(int cameraId,
- struct camera_info *info)
+int QCamera2HardwareInterface::getCapabilities(uint32_t cameraId,
+ struct camera_info *info)
{
ATRACE_CALL();
int rc = NO_ERROR;
@@ -1651,7 +1642,7 @@
}
ALOGD("%s: Allocating %d buffers for streamtype %d",__func__,bufferCnt,stream_type);
- return bufferCnt;
+ return (uint8_t)bufferCnt;
}
/*===========================================================================
@@ -1670,11 +1661,9 @@
* RETURN : ptr to a memory obj that holds stream buffers.
* NULL if failed
*==========================================================================*/
-QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf(cam_stream_type_t stream_type,
- int size,
- int stride,
- int scanline,
- uint8_t &bufferCnt)
+QCameraMemory *QCamera2HardwareInterface::allocateStreamBuf(
+ cam_stream_type_t stream_type, size_t size, int stride, int scanline,
+ uint8_t &bufferCnt)
{
int rc = NO_ERROR;
QCameraMemory *mem = NULL;
@@ -1789,9 +1778,8 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int32_t QCamera2HardwareInterface::allocateMoreStreamBuf(QCameraMemory *mem_obj,
- int size,
- uint8_t &bufferCnt)
+int32_t QCamera2HardwareInterface::allocateMoreStreamBuf(
+ QCameraMemory *mem_obj, size_t size, uint8_t &bufferCnt)
{
int rc = NO_ERROR;
@@ -1849,10 +1837,11 @@
streamInfo->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS;
} else {
streamInfo->streaming_mode = CAM_STREAMING_MODE_BURST;
- streamInfo->num_of_burst = mParameters.getNumOfSnapshots()
- + mParameters.getNumOfExtraHDRInBufsIfNeeded()
- - mParameters.getNumOfExtraHDROutBufsIfNeeded()
- + mParameters.getNumOfExtraBuffersForImageProc();
+ streamInfo->num_of_burst = (uint8_t)
+ (mParameters.getNumOfSnapshots()
+ + mParameters.getNumOfExtraHDRInBufsIfNeeded()
+ - mParameters.getNumOfExtraHDROutBufsIfNeeded()
+ + mParameters.getNumOfExtraBuffersForImageProc());
}
break;
case CAM_STREAM_TYPE_POSTVIEW:
@@ -1860,10 +1849,10 @@
streamInfo->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS;
} else {
streamInfo->streaming_mode = CAM_STREAMING_MODE_BURST;
- streamInfo->num_of_burst = mParameters.getNumOfSnapshots()
+ streamInfo->num_of_burst = (uint8_t)(mParameters.getNumOfSnapshots()
+ mParameters.getNumOfExtraHDRInBufsIfNeeded()
- mParameters.getNumOfExtraHDROutBufsIfNeeded()
- + mParameters.getNumOfExtraBuffersForImageProc();
+ + mParameters.getNumOfExtraBuffersForImageProc());
}
break;
case CAM_STREAM_TYPE_VIDEO:
@@ -1901,7 +1890,7 @@
int flipMode = mParameters.getFlipMode(stream_type);
if (flipMode > 0) {
streamInfo->pp_config.feature_mask |= CAM_QCOM_FEATURE_FLIP;
- streamInfo->pp_config.flip = flipMode;
+ streamInfo->pp_config.flip = (uint32_t)flipMode;
}
}
@@ -2303,13 +2292,13 @@
{
bool ret = true;
if (mParameters.isUbiRefocus()) {
- int index = getOutputImageCount();
+ int index = (int)getOutputImageCount();
bool allFocusImage = (index == ((int)mParameters.UfOutputCount()-1));
char name[CAM_FN_CNT];
camera_memory_t *jpeg_mem = NULL;
omx_jpeg_ouput_buf_t *jpeg_out = NULL;
- uint32_t dataLen;
+ size_t dataLen;
uint8_t *dataPtr;
if (!m_postprocessor.getJpegMemOpt()) {
dataLen = evt->out_data.buf_filled_len;
@@ -2322,10 +2311,10 @@
}
if (allFocusImage) {
- strncpy(name, "AllFocusImage", CAM_FN_CNT - 1);
+ snprintf(name, CAM_FN_CNT, "AllFocusImage");
index = -1;
} else {
- strncpy(name, "0", CAM_FN_CNT - 1);
+ snprintf(name, CAM_FN_CNT, "%d", 0);
}
CAM_DUMP_TO_FILE("/data/local/ubifocus", name, index, "jpg",
dataPtr, dataLen);
@@ -2358,13 +2347,13 @@
{
bool ret = true;
if (mParameters.isMTFRefocus()) {
- int index = getOutputImageCount();
+ int index = (int) getOutputImageCount();
bool allFocusImage = (index == ((int)mParameters.MTFOutputCount()-1));
char name[CAM_FN_CNT];
camera_memory_t *jpeg_mem = NULL;
omx_jpeg_ouput_buf_t *jpeg_out = NULL;
- uint32_t dataLen;
+ size_t dataLen;
uint8_t *dataPtr;
if (!m_postprocessor.getJpegMemOpt()) {
dataLen = evt->out_data.buf_filled_len;
@@ -2628,11 +2617,11 @@
int32_t rc = NO_ERROR;
// 'values' should be in "idx1,idx2,idx3,..." format
- uint8_t hdrFrameCount = gCamCapability[mCameraId]->hdr_bracketing_setting.num_frames;
- CDBG_HIGH("%s : HDR values %d, %d frame count: %d",
+ uint32_t hdrFrameCount = gCamCapability[mCameraId]->hdr_bracketing_setting.num_frames;
+ CDBG_HIGH("%s : HDR values %d, %d frame count: %u",
__func__,
- (int8_t) gCamCapability[mCameraId]->hdr_bracketing_setting.exp_val.values[0],
- (int8_t) gCamCapability[mCameraId]->hdr_bracketing_setting.exp_val.values[1],
+ (int) gCamCapability[mCameraId]->hdr_bracketing_setting.exp_val.values[0],
+ (int) gCamCapability[mCameraId]->hdr_bracketing_setting.exp_val.values[1],
hdrFrameCount);
// Enable AE Bracketing for HDR
@@ -2641,7 +2630,7 @@
aeBracket.mode =
gCamCapability[mCameraId]->hdr_bracketing_setting.exp_val.mode;
String8 tmp;
- for ( unsigned int i = 0; i < hdrFrameCount ; i++ ) {
+ for (uint32_t i = 0; i < hdrFrameCount; i++) {
tmp.appendFormat("%d",
(int8_t) gCamCapability[mCameraId]->hdr_bracketing_setting.exp_val.values[i]);
tmp.append(",");
@@ -3482,7 +3471,7 @@
pChannel = m_channels[QCAMERA_CH_TYPE_ZSL];
if (NULL != pChannel) {
QCameraStream *pStream = NULL;
- for(int i = 0; i < pChannel->getNumOfStreams(); i++) {
+ for (uint32_t i = 0; i < pChannel->getNumOfStreams(); i++) {
pStream = pChannel->getStreamByIndex(i);
if (pStream != NULL) {
if (pStream->isTypeOf(CAM_STREAM_TYPE_SNAPSHOT)) {
@@ -3618,7 +3607,13 @@
return rc;
}
- rc = pChannel->doReprocess(imgBuf->getFd(0), imgBuf->getSize(0), faceID);
+ ssize_t bufSize = imgBuf->getSize(0);
+ if (BAD_INDEX != bufSize) {
+ rc = pChannel->doReprocess(imgBuf->getFd(0), (size_t)bufSize, faceID);
+ } else {
+ ALOGE("Failed to retrieve buffer size (bad index)");
+ return UNKNOWN_ERROR;
+ }
// done with register face image, free imgbuf and delete reprocess channel
imgBuf->deallocate();
@@ -3848,7 +3843,7 @@
//We don't need to lockAPI, waitAPI here. QCAMERA_SM_EVT_THERMAL_NOTIFY
// becomes an aync call. This also means we can only pass payload
// by value, not by address.
- return processAPI(QCAMERA_SM_EVT_THERMAL_NOTIFY, (void *)level);
+ return processAPI(QCAMERA_SM_EVT_THERMAL_NOTIFY, (void *)&level);
}
/*===========================================================================
@@ -4058,7 +4053,7 @@
}
pHDRData[0] = CAMERA_META_DATA_HDR;
- pHDRData[1] = data_len;
+ pHDRData[1] = (int)data_len;
pHDRData[2] = m_HDRSceneEnabled;
qcamera_callback_argm_t cbArg;
@@ -4167,7 +4162,7 @@
#ifndef VANILLA_HAL
pASDData[0] = CAMERA_META_DATA_ASD;
- pASDData[1] = data_len;
+ pASDData[1] = (int)data_len;
pASDData[2] = scene;
qcamera_callback_argm_t cbArg;
@@ -4357,7 +4352,7 @@
for (int j = 0; j < QCAMERA_CH_TYPE_MAX; j++) {
if (m_channels[j] != NULL) {
pChannel = m_channels[j];
- for (int i = 0; i < pChannel->getNumOfStreams();i++) {
+ for (uint8_t i = 0; i < pChannel->getNumOfStreams(); i++) {
QCameraStream *pStream = pChannel->getStreamByIndex(i);
if (pStream != NULL) {
if (pStream->isTypeOf(CAM_STREAM_TYPE_METADATA)) {
@@ -4375,7 +4370,7 @@
}
}
- for (int i = 0; i < curChannel->getNumOfStreams();i++) {
+ for (uint8_t i = 0; i < curChannel->getNumOfStreams(); i++) {
QCameraStream *pStream = curChannel->getStreamByIndex(i);
if (pStream != NULL) {
if (pStream->isTypeOf(CAM_STREAM_TYPE_METADATA)) {
@@ -4430,12 +4425,12 @@
}
if ( ( streamType == CAM_STREAM_TYPE_SNAPSHOT ||
- streamType == CAM_STREAM_TYPE_POSTVIEW ||
- streamType == CAM_STREAM_TYPE_METADATA ||
- streamType == CAM_STREAM_TYPE_RAW) &&
- !isZSLMode() &&
- !isLongshotEnabled() &&
- !mParameters.getRecordingHintValue()) {
+ streamType == CAM_STREAM_TYPE_POSTVIEW ||
+ streamType == CAM_STREAM_TYPE_METADATA ||
+ streamType == CAM_STREAM_TYPE_RAW) &&
+ !isZSLMode() &&
+ !isLongshotEnabled() &&
+ !mParameters.getRecordingHintValue()) {
rc = pChannel->addStream(*this,
pStreamInfo,
minStreamBufNum,
@@ -5005,7 +5000,6 @@
{
int32_t rc = NO_ERROR;
QCameraReprocessChannel *pChannel = NULL;
- const char *effect;
if (pInputChannel == NULL) {
ALOGE("%s: input channel obj is NULL", __func__);
@@ -5042,9 +5036,7 @@
if (mParameters.isZSLMode() || (required_mask & CAM_QCOM_FEATURE_CPP)) {
if (gCamCapability[mCameraId]->min_required_pp_mask & CAM_QCOM_FEATURE_EFFECT) {
pp_config.feature_mask |= CAM_QCOM_FEATURE_EFFECT;
- effect = mParameters.get(CameraParameters::KEY_EFFECT);
- if (effect != NULL)
- pp_config.effect = getEffectValue(effect);
+ pp_config.effect = mParameters.getEffectValue();
}
if ((gCamCapability[mCameraId]->min_required_pp_mask & CAM_QCOM_FEATURE_SHARPNESS) &&
!mParameters.isOptiZoomEnabled()) {
@@ -5074,7 +5066,7 @@
if (needRotationReprocess()) {
pp_config.feature_mask |= CAM_QCOM_FEATURE_CPP;
- int rotation = getJpegRotation();
+ uint32_t rotation = getJpegRotation();
if (rotation == 0) {
pp_config.rotation = ROTATE_0;
} else if (rotation == 90) {
@@ -5148,7 +5140,7 @@
temp_feature_mask &= ~CAM_QCOM_FEATURE_DENOISE2D;
temp_feature_mask &= ~CAM_QCOM_FEATURE_HDR;
if (temp_feature_mask && mParameters.isHDREnabled()) {
- minStreamBufNum = 1 + mParameters.getNumOfExtraHDRInBufsIfNeeded();
+ minStreamBufNum = (uint8_t)(1 + mParameters.getNumOfExtraHDRInBufsIfNeeded());
}
// Add non inplace image lib buffers only when ppproc is present,
@@ -5159,7 +5151,7 @@
if (temp_feature_mask && imglib_extra_bufs) {
// 1 is added because getNumOfExtraBuffersForImageProc returns extra
// buffers assuming number of capture is already added
- minStreamBufNum += imglib_extra_bufs + 1;
+ minStreamBufNum = (uint8_t)(minStreamBufNum + imglib_extra_bufs + 1);
}
CDBG_HIGH("%s: Allocating %d reproc buffers",__func__,minStreamBufNum);
@@ -5653,7 +5645,7 @@
//need fill meta type and meta data len first
int *data_header = (int* )pFaceResult;
data_header[0] = CAMERA_META_DATA_FD;
- data_header[1] = data_len;
+ data_header[1] = (int)data_len;
if(data_len <= 0){
//if face is not valid or do not have face, return
@@ -5808,9 +5800,11 @@
int32_t /*cbStatus*/)
{
QCameraStream *stream = ( QCameraStream * ) cookie;
- int idx = ( int ) data;
- if ( ( NULL != stream )) {
- stream->bufDone(idx);
+ int idx = *((int *)data);
+ if ((NULL != stream) && (0 <= idx)) {
+ stream->bufDone((uint32_t)idx);
+ } else {
+ ALOGE("%s: Cannot return buffer %d %p", __func__, idx, cookie);
}
}
@@ -5895,13 +5889,16 @@
*==========================================================================*/
int QCamera2HardwareInterface::calcThermalLevel(
qcamera_thermal_level_enum_t level,
- const int minFPS,
- const int maxFPS,
+ const int minFPSi,
+ const int maxFPSi,
cam_fps_range_t &adjustedRange,
enum msm_vfe_frame_skip_pattern &skipPattern)
{
+ const float minFPS = (float)minFPSi;
+ const float maxFPS = (float)maxFPSi;
+
// Initialize video fps to preview fps
- int minVideoFps = minFPS, maxVideoFps = maxFPS;
+ float minVideoFps = minFPS, maxVideoFps = maxFPS;
cam_fps_range_t videoFps;
// If HFR mode, update video fps accordingly
if(isHFRMode()) {
@@ -5910,9 +5907,9 @@
maxVideoFps = videoFps.video_max_fps;
}
- CDBG_HIGH("%s: level: %d, preview minfps %d, preview maxfpS %d"
- "video minfps %d, video maxfpS %d",
- __func__, level, minFPS, maxFPS, minVideoFps, maxVideoFps);
+ CDBG_HIGH("%s: level: %d, preview minfps %f, preview maxfpS %f, "
+ "video minfps %f, video maxfpS %f",
+ __func__, level, minFPS, maxFPS, minVideoFps, maxVideoFps);
switch(level) {
case QCAMERA_THERMAL_NO_ADJUSTMENT:
@@ -5972,8 +5969,8 @@
// Set lowest min FPS for now
adjustedRange.min_fps = minFPS/1000.0f;
adjustedRange.max_fps = minFPS/1000.0f;
- for ( size_t i = 0 ; i < gCamCapability[mCameraId]->fps_ranges_tbl_cnt ; i++ ) {
- if ( gCamCapability[mCameraId]->fps_ranges_tbl[i].min_fps < adjustedRange.min_fps ) {
+ for (size_t i = 0 ; i < gCamCapability[mCameraId]->fps_ranges_tbl_cnt ; i++) {
+ if (gCamCapability[mCameraId]->fps_ranges_tbl[i].min_fps < adjustedRange.min_fps) {
adjustedRange.min_fps = gCamCapability[mCameraId]->fps_ranges_tbl[i].min_fps;
adjustedRange.max_fps = adjustedRange.min_fps;
}
@@ -6432,9 +6429,9 @@
*
* RETURN : jpeg quality setting
*==========================================================================*/
-int QCamera2HardwareInterface::getJpegQuality()
+uint32_t QCamera2HardwareInterface::getJpegQuality()
{
- int quality = 0;
+ uint32_t quality = 0;
pthread_mutex_lock(&m_parm_lock);
quality = mParameters.getJpegQuality();
pthread_mutex_unlock(&m_parm_lock);
@@ -6450,7 +6447,7 @@
*
* RETURN : rotation information
*==========================================================================*/
-int QCamera2HardwareInterface::getJpegRotation() {
+uint32_t QCamera2HardwareInterface::getJpegRotation() {
return mCaptureRotation;
}
@@ -6487,7 +6484,6 @@
}
int32_t rc = NO_ERROR;
- uint32_t count = 0;
pthread_mutex_lock(&m_parm_lock);
@@ -6497,15 +6493,11 @@
mFlashPresence = mParameters.getSupportedFlashModes();
// add exif entries
- char dateTime[20];
- memset(dateTime, 0, sizeof(dateTime));
- count = 20;
- rc = mParameters.getExifDateTime(dateTime, count);
+ String8 dateTime;
+ rc = mParameters.getExifDateTime(dateTime);
if(rc == NO_ERROR) {
- exif->addEntry(EXIFTAGID_EXIF_DATE_TIME_ORIGINAL,
- EXIF_ASCII,
- count,
- (void *)dateTime);
+ exif->addEntry(EXIFTAGID_EXIF_DATE_TIME_ORIGINAL, EXIF_ASCII,
+ (uint32_t)(dateTime.length() + 1), (void *)dateTime.string());
} else {
ALOGE("%s: getExifDateTime failed", __func__);
}
@@ -6530,7 +6522,7 @@
}
char gpsProcessingMethod[EXIF_ASCII_PREFIX_SIZE + GPS_PROCESSING_METHOD_SIZE];
- count = 0;
+ uint32_t count = 0;
rc = mParameters.getExifGpsProcessingMethod(gpsProcessingMethod, count);
if(rc == NO_ERROR) {
exif->addEntry(EXIFTAGID_GPS_PROCESSINGMETHOD,
@@ -6597,7 +6589,7 @@
if(rc == NO_ERROR) {
exif->addEntry(EXIFTAGID_GPS_DATESTAMP,
EXIF_ASCII,
- strlen(gpsDateStamp) + 1,
+ (uint32_t)(strlen(gpsDateStamp) + 1),
(void *)gpsDateStamp);
exif->addEntry(EXIFTAGID_GPS_TIMESTAMP,
@@ -6712,12 +6704,11 @@
}
bool QCamera2HardwareInterface::removeSizeFromList(cam_dimension_t* size_list,
- uint8_t length,
- cam_dimension_t size)
+ size_t length, cam_dimension_t size)
{
bool found = false;
- int index = 0;
- for (int i = 0; i < length; i++) {
+ size_t index = 0;
+ for (size_t i = 0; i < length; i++) {
if ((size_list[i].width == size.width
&& size_list[i].height == size.height)) {
found = true;
@@ -6727,18 +6718,18 @@
}
if (found) {
- for (int i = index; i < length; i++) {
+ for (size_t i = index; i < length; i++) {
size_list[i] = size_list[i+1];
}
}
return found;
}
-void QCamera2HardwareInterface::copyList(cam_dimension_t* src_list,
- cam_dimension_t* dst_list, uint8_t len){
- for (int i = 0; i < len; i++) {
- dst_list[i] = src_list[i];
- }
+void QCamera2HardwareInterface::copyList(cam_dimension_t *src_list,
+ cam_dimension_t *dst_list, size_t len) {
+ for (size_t i = 0; i < len; i++) {
+ dst_list[i] = src_list[i];
+ }
}
/*===========================================================================
@@ -6906,14 +6897,14 @@
DefferWorkArgs args)
{
Mutex::Autolock l(mDeffLock);
- for (int i = 0; i < MAX_ONGOING_JOBS; ++i) {
+ for (uint32_t i = 0; i < MAX_ONGOING_JOBS; ++i) {
if (!mDeffOngoingJobs[i]) {
mCmdQueue.enqueue(new DeffWork(cmd, i, args));
mDeffOngoingJobs[i] = true;
mDefferedWorkThread.sendCmd(CAMERA_CMD_TYPE_DO_NEXT_JOB,
- FALSE,
- FALSE);
- return i;
+ FALSE,
+ FALSE);
+ return (int32_t)i;
}
}
return -1;
@@ -6984,9 +6975,6 @@
void QCamera2HardwareInterface::getLogLevel()
{
char prop[PROPERTY_VALUE_MAX];
- uint32_t temp;
- uint32_t log_level;
- uint32_t debug_mask;
memset(prop, 0, sizeof(prop));
/* Higher 4 bits : Value of Debug log level (Default level is 1 to print all CDBG_HIGH)
@@ -6995,9 +6983,9 @@
0x10 for mm-camera-interface
0x100 for mm-jpeg-interface */
property_get("persist.camera.hal.debug.mask", prop, "268435463"); // 0x10000007=268435463
- temp = atoi(prop);
- log_level = ((temp >> 28) & 0xF);
- debug_mask = (temp & HAL_DEBUG_MASK_HAL);
+ uint32_t temp = (uint32_t) atoi(prop);
+ uint32_t log_level = ((temp >> 28) & 0xF);
+ uint32_t debug_mask = (temp & HAL_DEBUG_MASK_HAL);
if (debug_mask > 0)
gCamHalLogLevel = log_level;
else
diff --git a/QCamera2/HAL/QCamera2HWI.h b/QCamera2/HAL/QCamera2HWI.h
index 4dd562a..36b9dd1 100644
--- a/QCamera2/HAL/QCamera2HWI.h
+++ b/QCamera2/HAL/QCamera2HWI.h
@@ -164,9 +164,9 @@
typedef struct {
cam_dimension_t all_preview_sizes[MAX_SIZES_CNT];
- uint8_t all_preview_sizes_cnt;
+ size_t all_preview_sizes_cnt;
cam_dimension_t all_video_sizes[MAX_SIZES_CNT];
- uint8_t all_video_sizes_cnt;
+ size_t all_video_sizes_cnt;
} qcamera_saved_sizes_list;
class QCameraCbNotifier {
@@ -256,22 +256,18 @@
void *img_ptr,
cam_pp_offline_src_config_t *config);
public:
- QCamera2HardwareInterface(int cameraId);
+ QCamera2HardwareInterface(uint32_t cameraId);
virtual ~QCamera2HardwareInterface();
int openCamera(struct hw_device_t **hw_device);
- static int getCapabilities(int cameraId, struct camera_info *info);
- static int initCapabilities(int cameraId,mm_camera_vtbl_t *cameraHandle);
+ static int getCapabilities(uint32_t cameraId, struct camera_info *info);
+ static int initCapabilities(uint32_t cameraId, mm_camera_vtbl_t *cameraHandle);
// Implementation of QCameraAllocator
virtual QCameraMemory *allocateStreamBuf(cam_stream_type_t stream_type,
- int size,
- int stride,
- int scanline,
- uint8_t &bufferCnt);
+ size_t size, int stride, int scanline, uint8_t &bufferCnt);
virtual int32_t allocateMoreStreamBuf(QCameraMemory *mem_obj,
- int size,
- uint8_t &bufferCnt);
+ size_t size, uint8_t &bufferCnt);
virtual QCameraHeapMemory *allocateStreamInfoBuf(cam_stream_type_t stream_type);
@@ -339,12 +335,9 @@
void signalAPIResult(qcamera_api_result_t *result);
void signalEvtResult(qcamera_api_result_t *result);
- int calcThermalLevel(
- qcamera_thermal_level_enum_t level,
- const int minFPS,
- const int maxFPS,
- cam_fps_range_t &adjustedRange,
- enum msm_vfe_frame_skip_pattern &skipPattern);
+ int calcThermalLevel(qcamera_thermal_level_enum_t level,
+ const int minFPSi, const int maxFPSi, cam_fps_range_t &adjustedRange,
+ enum msm_vfe_frame_skip_pattern &skipPattern);
int updateThermalLevel(qcamera_thermal_level_enum_t level);
// update entris to set parameters and check if restart is needed
@@ -365,17 +358,16 @@
bool needScaleReprocess();
void debugShowVideoFPS();
void debugShowPreviewFPS();
- void dumpJpegToFile(const void *data, uint32_t size, int index);
+ void dumpJpegToFile(const void *data, size_t size, uint32_t index);
void dumpFrameToFile(QCameraStream *stream,
- mm_camera_buf_def_t *frame,
- int dump_type);
+ mm_camera_buf_def_t *frame, uint32_t dump_type);
void dumpMetadataToFile(QCameraStream *stream,
mm_camera_buf_def_t *frame,char *type);
void releaseSuperBuf(mm_camera_super_buf_t *super_buf);
void playShutter();
void getThumbnailSize(cam_dimension_t &dim);
- int getJpegQuality();
- int getJpegRotation();
+ uint32_t getJpegQuality();
+ uint32_t getJpegRotation();
void getOrientation();
inline int getFlash(){ return mFlash; }
inline int getFlashPresence(){ return mFlashPresence; }
@@ -437,14 +429,15 @@
bool isZSLMode() {return mParameters.isZSLMode();};
bool isHFRMode() {return mParameters.isHfrMode();};
uint8_t numOfSnapshotsExpected() {
- return ((mParameters.isUbiRefocus() || mParameters.isMTFRefocus()) ?
- 1 : mParameters.getNumOfSnapshots());};
+ return (uint8_t) ((mParameters.isUbiRefocus() ||
+ mParameters.isMTFRefocus()) ?
+ 1 : mParameters.getNumOfSnapshots());
+ }
bool isLongshotEnabled() { return mLongshotEnabled; };
uint8_t getBufNumRequired(cam_stream_type_t stream_type);
bool needFDMetadata(qcamera_ch_type_enum_t channel_type);
- bool removeSizeFromList(cam_dimension_t* size_list,
- uint8_t length,
- cam_dimension_t size);
+ bool removeSizeFromList(cam_dimension_t *size_list, size_t length,
+ cam_dimension_t size);
int32_t unconfigureAdvancedCapture();
int32_t configureAdvancedCapture();
int32_t configureAFBracketing(bool enable = true);
@@ -461,9 +454,8 @@
bool processUFDumps(qcamera_jpeg_evt_payload_t *evt);
bool processMTFDumps(qcamera_jpeg_evt_payload_t *evt);
void captureDone();
-
- static void copyList(cam_dimension_t* src_list,
- cam_dimension_t* dst_list, uint8_t len);
+ static void copyList(cam_dimension_t *src_list, cam_dimension_t *dst_list,
+ size_t len);
static void camEvtHandle(uint32_t camera_handle,
mm_camera_event_t *evt,
void *user_data);
@@ -519,12 +511,11 @@
static void returnStreamBuffer(void *data,
void *cookie,
int32_t cbStatus);
- static int32_t getEffectValue(const char *effect);
static void getLogLevel();
private:
camera_device_t mCameraDevice;
- uint8_t mCameraId;
+ uint32_t mCameraId;
mm_camera_vtbl_t *mCameraHandle;
bool mCameraOpened;
@@ -569,8 +560,8 @@
power_module_t *m_pPowerModule; // power module
- int mDumpFrmCnt; // frame dump count
- int mDumpSkipCnt; // frame skip count
+ uint32_t mDumpFrmCnt; // frame dump count
+ uint32_t mDumpSkipCnt; // frame skip count
mm_jpeg_exif_params_t mExifParams;
qcamera_thermal_level_enum_t mThermalLevel;
bool mCancelAutoFocus;
@@ -581,8 +572,8 @@
int32_t m_max_pic_height;
pthread_t mLiveSnapshotThread;
pthread_t mIntPicThread;
- uint8_t mFlashNeeded;
- int mCaptureRotation;
+ bool mFlashNeeded;
+ uint32_t mCaptureRotation;
int32_t mFlash;
int32_t mRedEye;
int32_t mFlashPresence;
@@ -593,7 +584,7 @@
//eztune variables for communication with eztune server at backend
bool m_bIntEvtPending;
char m_BackendFileName[QCAMERA_MAX_FILEPATH_LENGTH];
- int32_t mBackendFileSize;
+ size_t mBackendFileSize;
pthread_mutex_t m_int_lock;
pthread_cond_t m_int_cond;
@@ -645,7 +636,7 @@
int32_t mMetadataJob;
int32_t mReprocJob;
int32_t mRawdataJob;
- int32_t mOutputCount;
+ uint32_t mOutputCount;
bool mPreviewFrameSkipValid;
cam_frame_idx_range_t mPreviewFrameSkipIdxRange;
bool mAdvancedCaptureConfigured;
diff --git a/QCamera2/HAL/QCamera2HWICallbacks.cpp b/QCamera2/HAL/QCamera2HWICallbacks.cpp
index a3b4e92..c535688 100644
--- a/QCamera2/HAL/QCamera2HWICallbacks.cpp
+++ b/QCamera2/HAL/QCamera2HWICallbacks.cpp
@@ -317,7 +317,7 @@
// find snapshot frame
QCameraStream *main_stream = NULL;
mm_camera_buf_def_t *main_frame = NULL;
- for (int i = 0; i < recvd_frame->num_bufs; i++) {
+ for (uint32_t i = 0; i < recvd_frame->num_bufs; i++) {
QCameraStream *pStream =
pChannel->getStreamByHandle(recvd_frame->bufs[i]->stream_id);
if (pStream != NULL) {
@@ -500,7 +500,7 @@
pme->debugShowPreviewFPS();
}
- int idx = frame->buf_idx;
+ uint32_t idx = frame->buf_idx;
pme->dumpFrameToFile(stream, frame, QCAMERA_DUMP_FRM_PREVIEW);
if (pme->mPreviewFrameSkipValid) {
@@ -534,7 +534,7 @@
__func__, dequeuedIdx);
} else {
// Return dequeued buffer back to driver
- err = stream->bufDone(dequeuedIdx);
+ err = stream->bufDone((uint32_t)dequeuedIdx);
if ( err < 0) {
ALOGE("stream bufDone failed %d", err);
}
@@ -544,7 +544,7 @@
if (pme->mDataCb != NULL && pme->msgTypeEnabledWithLock(CAMERA_MSG_PREVIEW_FRAME) > 0) {
camera_memory_t *previewMem = NULL;
camera_memory_t *data = NULL;
- int previewBufSize;
+ size_t previewBufSize;
cam_dimension_t preview_dim;
cam_format_t previewFmt;
stream->getFrameDimension(preview_dim);
@@ -557,21 +557,26 @@
(previewFmt == CAM_FORMAT_YUV_420_NV12) ||
(previewFmt == CAM_FORMAT_YUV_420_YV12)) {
if(previewFmt == CAM_FORMAT_YUV_420_YV12) {
- previewBufSize = ((preview_dim.width+15)/16) * 16 * preview_dim.height +
- ((preview_dim.width/2+15)/16) * 16* preview_dim.height;
- } else {
- previewBufSize = preview_dim.width * preview_dim.height * 3/2;
- }
- if(previewBufSize != memory->getSize(idx)) {
+ previewBufSize = (((size_t)preview_dim.width + 15) / 16) * 16 *
+ (size_t)preview_dim.height +
+ (((size_t)preview_dim.width / 2 + 15) / 16) * 16 *
+ (size_t)preview_dim.height;
+ } else {
+ previewBufSize = (size_t)preview_dim.width *
+ (size_t)preview_dim.height * 3 / 2;
+ }
+ ssize_t bufSize = memory->getSize(idx);
+ if((BAD_INDEX != bufSize) && (previewBufSize != (size_t)bufSize)) {
previewMem = pme->mGetMemory(memory->getFd(idx),
- previewBufSize, 1, pme->mCallbackCookie);
+ previewBufSize, 1, pme->mCallbackCookie);
if (!previewMem || !previewMem->data) {
ALOGE("%s: mGetMemory failed.\n", __func__);
} else {
data = previewMem;
}
- } else
+ } else {
data = memory->getMemory(idx, false);
+ }
} else {
data = memory->getMemory(idx, false);
ALOGE("%s: Invalid preview format, buffer size in preview callback may be wrong.",
@@ -685,8 +690,7 @@
cbArg.cb_type = QCAMERA_DATA_CALLBACK;
cbArg.msg_type = CAMERA_MSG_PREVIEW_FRAME;
cbArg.data = preview_mem;
- int user_data = frame->buf_idx;
- cbArg.user_data = ( void * ) user_data;
+ cbArg.user_data = (void *) &frame->buf_idx;
cbArg.cookie = stream;
cbArg.release_cb = returnStreamBuffer;
int32_t rc = pme->m_cbNotifier.notifyCallback(cbArg);
@@ -1257,7 +1261,7 @@
/* Update 3a info */
if(pMetaData->is_ae_params_valid) {
pme->mExifParams.ae_params = pMetaData->ae_params;
- pme->mFlashNeeded = pMetaData->ae_params.flash_needed;
+ pme->mFlashNeeded = pMetaData->ae_params.flash_needed ? true : false;
}
if(pMetaData->is_awb_params_valid) {
pme->mExifParams.awb_params = pMetaData->awb_params;
@@ -1397,13 +1401,12 @@
* RETURN : None
*==========================================================================*/
void QCamera2HardwareInterface::dumpJpegToFile(const void *data,
- uint32_t size,
- int index)
+ size_t size, uint32_t index)
{
char value[PROPERTY_VALUE_MAX];
property_get("persist.camera.dumpimg", value, "0");
- int32_t enabled = atoi(value);
- int frm_num = 0;
+ uint32_t enabled = (uint32_t) atoi(value);
+ uint32_t frm_num = 0;
uint32_t skip_mode = 0;
char buf[32];
@@ -1430,7 +1433,7 @@
// reset frame count if cycling
mDumpFrmCnt = 0;
}
- if (mDumpFrmCnt >= 0 && mDumpFrmCnt <= frm_num) {
+ if (mDumpFrmCnt <= frm_num) {
snprintf(buf, sizeof(buf), "/data/%d_%d.jpg", mDumpFrmCnt, index);
if (true == m_bIntEvtPending) {
strncpy(m_BackendFileName, buf, sizeof(buf));
@@ -1439,7 +1442,7 @@
int file_fd = open(buf, O_RDWR | O_CREAT, 0777);
if (file_fd >= 0) {
- int written_len = write(file_fd, data, size);
+ ssize_t written_len = write(file_fd, data, size);
fchmod(file_fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
CDBG_HIGH("%s: written number of bytes %d\n", __func__, written_len);
close(file_fd);
@@ -1460,30 +1463,30 @@
mm_camera_buf_def_t *frame,char *type)
{
char value[PROPERTY_VALUE_MAX];
- int frm_num = 0;
+ uint32_t frm_num = 0;
cam_metadata_info_t *metadata = (cam_metadata_info_t *)frame->buffer;
property_get("persist.camera.dumpmetadata", value, "0");
- int32_t enabled = atoi(value);
+ uint32_t enabled = (uint32_t) atoi(value);
if (stream == NULL) {
ALOGE("No op");
return;
}
- int mDumpFrmCnt = stream->mDumpMetaFrame;
+ uint32_t dumpFrmCnt = stream->mDumpMetaFrame;
if(enabled){
frm_num = ((enabled & 0xffff0000) >> 16);
- if(frm_num == 0) {
+ if (frm_num == 0) {
frm_num = 10; //default 10 frames
}
- if(frm_num > 256) {
+ if (frm_num > 256) {
frm_num = 256; //256 buffers cycle around
}
- if((frm_num == 256) && (mDumpFrmCnt >= frm_num)) {
+ if ((frm_num == 256) && (dumpFrmCnt >= frm_num)) {
// reset frame count if cycling
- mDumpFrmCnt = 0;
+ dumpFrmCnt = 0;
}
- CDBG_HIGH("mDumpFrmCnt= %d, frm_num = %d",mDumpFrmCnt,frm_num);
- if (mDumpFrmCnt >= 0 && mDumpFrmCnt < frm_num) {
+ CDBG_HIGH("dumpFrmCnt= %u, frm_num = %u", dumpFrmCnt, frm_num);
+ if (dumpFrmCnt < frm_num) {
char timeBuf[128];
char buf[32];
memset(buf, 0, sizeof(buf));
@@ -1495,12 +1498,11 @@
if (timeinfo != NULL)
strftime (timeBuf, sizeof(timeBuf),"/data/%Y%m%d%H%M%S", timeinfo);
String8 filePath(timeBuf);
- snprintf(buf, sizeof(buf), "%dm_%s_%d.bin",
- mDumpFrmCnt,type,frame->frame_idx);
+ snprintf(buf, sizeof(buf), "%um_%s_%d.bin", dumpFrmCnt, type, frame->frame_idx);
filePath.append(buf);
int file_fd = open(filePath.string(), O_RDWR | O_CREAT, 0777);
if (file_fd > 0) {
- int written_len = 0;
+ ssize_t written_len = 0;
metadata->tuning_params.tuning_data_version = TUNING_DATA_VERSION;
void *data = (void *)((uint8_t *)&metadata->tuning_params.tuning_data_version);
written_len += write(file_fd, data, sizeof(uint32_t));
@@ -1516,7 +1518,7 @@
data = (void *)((uint8_t *)&metadata->tuning_params.tuning_cac_data_size);
CDBG_HIGH("tuning_cac_data_size %d",(int)(*(int *)data));
written_len += write(file_fd, data, sizeof(uint32_t));
- int total_size = metadata->tuning_params.tuning_sensor_data_size;
+ size_t total_size = metadata->tuning_params.tuning_sensor_data_size;
data = (void *)((uint8_t *)&metadata->tuning_params.data);
written_len += write(file_fd, data, total_size);
total_size = metadata->tuning_params.tuning_vfe_data_size;
@@ -1532,10 +1534,10 @@
}else {
ALOGE("%s: fail t open file for image dumping", __func__);
}
- mDumpFrmCnt++;
+ dumpFrmCnt++;
}
}
- stream->mDumpMetaFrame = mDumpFrmCnt;
+ stream->mDumpMetaFrame = dumpFrmCnt;
}
/*===========================================================================
* FUNCTION : dumpFrameToFile
@@ -1553,15 +1555,13 @@
* RETURN : None
*==========================================================================*/
void QCamera2HardwareInterface::dumpFrameToFile(QCameraStream *stream,
- mm_camera_buf_def_t *frame,
- int dump_type)
+ mm_camera_buf_def_t *frame, uint32_t dump_type)
{
char value[PROPERTY_VALUE_MAX];
property_get("persist.camera.dumpimg", value, "0");
- int32_t enabled = atoi(value);
- int frm_num = 0;
+ uint32_t enabled = (uint32_t) atoi(value);
+ uint32_t frm_num = 0;
uint32_t skip_mode = 0;
- int mDumpFrmCnt = 0;
if (stream)
mDumpFrmCnt = stream->mDumpFrame;
@@ -1587,7 +1587,7 @@
// reset frame count if cycling
mDumpFrmCnt = 0;
}
- if (mDumpFrmCnt >= 0 && mDumpFrmCnt <= frm_num) {
+ if (mDumpFrmCnt <= frm_num) {
char buf[32];
char timeBuf[128];
time_t current_time;
@@ -1651,7 +1651,7 @@
int file_fd = open(filePath.string(), O_RDWR | O_CREAT, 0777);
if (file_fd > 0) {
void *data = NULL;
- int written_len = 0;
+ ssize_t written_len = 0;
for (uint32_t i = 0; i < offset.num_planes; i++) {
uint32_t index = offset.mp[i].offset;
@@ -1660,8 +1660,9 @@
}
for (int j = 0; j < offset.mp[i].height; j++) {
data = (void *)((uint8_t *)frame->buffer + index);
- written_len += write(file_fd, data, offset.mp[i].width);
- index += offset.mp[i].stride;
+ written_len += write(file_fd, data,
+ (size_t)offset.mp[i].width);
+ index += (uint32_t)offset.mp[i].stride;
}
}
@@ -1696,12 +1697,13 @@
static int n_vFrameCount = 0;
static int n_vLastFrameCount = 0;
static nsecs_t n_vLastFpsTime = 0;
- static float n_vFps = 0;
+ static double n_vFps = 0;
n_vFrameCount++;
nsecs_t now = systemTime();
nsecs_t diff = now - n_vLastFpsTime;
if (diff > ms2ns(250)) {
- n_vFps = ((n_vFrameCount - n_vLastFrameCount) * float(s2ns(1))) / diff;
+ n_vFps = (((double)(n_vFrameCount - n_vLastFrameCount)) *
+ (double)(s2ns(1))) / (double)diff;
ALOGE("Video Frames Per Second: %.4f", n_vFps);
n_vLastFpsTime = now;
n_vLastFrameCount = n_vFrameCount;
@@ -1722,12 +1724,13 @@
static int n_pFrameCount = 0;
static int n_pLastFrameCount = 0;
static nsecs_t n_pLastFpsTime = 0;
- static float n_pFps = 0;
+ static double n_pFps = 0;
n_pFrameCount++;
nsecs_t now = systemTime();
nsecs_t diff = now - n_pLastFpsTime;
if (diff > ms2ns(250)) {
- n_pFps = ((n_pFrameCount - n_pLastFrameCount) * float(s2ns(1))) / diff;
+ n_pFps = (((double)(n_pFrameCount - n_pLastFrameCount)) *
+ (double)(s2ns(1))) / (double)diff;
CDBG_HIGH("[KPI Perf] %s: PROFILE_PREVIEW_FRAMES_PER_SECOND : %.4f", __func__, n_pFps);
n_pLastFpsTime = now;
n_pLastFrameCount = n_pFrameCount;
diff --git a/QCamera2/HAL/QCameraAllocator.h b/QCamera2/HAL/QCameraAllocator.h
index 114aca5..13672d2 100644
--- a/QCamera2/HAL/QCameraAllocator.h
+++ b/QCamera2/HAL/QCameraAllocator.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundataion. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundataion. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -42,13 +42,9 @@
class QCameraAllocator {
public:
virtual QCameraMemory *allocateStreamBuf(cam_stream_type_t stream_type,
- int size,
- int stride,
- int scanline,
- uint8_t &bufferCnt) = 0;
+ size_t size, int stride, int scanline, uint8_t &bufferCnt) = 0;
virtual int32_t allocateMoreStreamBuf(QCameraMemory *mem_obj,
- int size,
- uint8_t &bufferCnt) = 0;
+ size_t size, uint8_t &bufferCnt) = 0;
virtual QCameraHeapMemory *allocateStreamInfoBuf(cam_stream_type_t stream_type) = 0;
virtual ~QCameraAllocator() {}
};
diff --git a/QCamera2/HAL/QCameraChannel.cpp b/QCamera2/HAL/QCameraChannel.cpp
index 160c5a4..5e9f9de 100644
--- a/QCamera2/HAL/QCameraChannel.cpp
+++ b/QCamera2/HAL/QCameraChannel.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The Linux Foundataion. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundataion. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -366,7 +366,7 @@
int32_t QCameraChannel::stop()
{
int32_t rc = NO_ERROR;
- int linkedIdx = -1;
+ ssize_t linkedIdx = -1;
for (size_t i = 0; i < mStreams.size(); i++) {
if (mStreams[i] != NULL) {
@@ -374,12 +374,12 @@
mStreams[i]->stop();
} else {
// Remove linked stream from stream list
- linkedIdx = i;
+ linkedIdx = (ssize_t)i;
}
}
}
if (linkedIdx > 0) {
- mStreams.removeAt(linkedIdx);
+ mStreams.removeAt((size_t)linkedIdx);
}
rc = m_camOps->stop_channel(m_camHandle, m_handle);
@@ -495,7 +495,7 @@
*
* RETURN : stream object. NULL if not found
*==========================================================================*/
-QCameraStream *QCameraChannel::getStreamByIndex(uint8_t index)
+QCameraStream *QCameraChannel::getStreamByIndex(uint32_t index)
{
if (index >= MAX_STREAM_NUM_IN_BUNDLE) {
return NULL;
@@ -532,7 +532,8 @@
cam_stream_parm_buffer_t param_buf;
memset(¶m_buf, 0, sizeof(cam_stream_parm_buffer_t));
param_buf.type = CAM_STREAM_PARAM_TYPE_SET_FLIP;
- param_buf.flipInfo.flip_mask = param.getFlipMode(CAM_STREAM_TYPE_PREVIEW);
+ param_buf.flipInfo.flip_mask =
+ (uint32_t)param.getFlipMode(CAM_STREAM_TYPE_PREVIEW);
rc = mStreams[i]->setParameter(param_buf);
if (rc != NO_ERROR) {
ALOGE("%s: set preview stream flip failed", __func__);
@@ -550,7 +551,8 @@
cam_stream_parm_buffer_t param_buf;
memset(¶m_buf, 0, sizeof(cam_stream_parm_buffer_t));
param_buf.type = CAM_STREAM_PARAM_TYPE_SET_FLIP;
- param_buf.flipInfo.flip_mask = param.getFlipMode(CAM_STREAM_TYPE_VIDEO);
+ param_buf.flipInfo.flip_mask =
+ (uint32_t)param.getFlipMode(CAM_STREAM_TYPE_VIDEO);
rc = mStreams[i]->setParameter(param_buf);
if (rc != NO_ERROR) {
ALOGE("%s: set video stream flip failed", __func__);
@@ -570,7 +572,8 @@
cam_stream_parm_buffer_t param_buf;
memset(¶m_buf, 0, sizeof(cam_stream_parm_buffer_t));
param_buf.type = CAM_STREAM_PARAM_TYPE_SET_FLIP;
- param_buf.flipInfo.flip_mask = param.getFlipMode(CAM_STREAM_TYPE_SNAPSHOT);
+ param_buf.flipInfo.flip_mask =
+ (uint32_t)param.getFlipMode(CAM_STREAM_TYPE_SNAPSHOT);
rc = mStreams[i]->setParameter(param_buf);
if (rc != NO_ERROR) {
ALOGE("%s: set snapshot stream flip failed", __func__);
@@ -824,15 +827,11 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int32_t QCameraReprocessChannel::addReprocStreamsFromSource(QCameraAllocator& allocator,
- cam_pp_feature_config_t &config,
- QCameraChannel *pSrcChannel,
- uint8_t minStreamBufNum,
- uint32_t burstNum,
- cam_padding_info_t *paddingInfo,
- QCameraParameters ¶m,
- bool contStream,
- bool offline)
+int32_t QCameraReprocessChannel::addReprocStreamsFromSource(
+ QCameraAllocator& allocator, cam_pp_feature_config_t &config,
+ QCameraChannel *pSrcChannel, uint8_t minStreamBufNum, uint8_t burstNum,
+ cam_padding_info_t *paddingInfo, QCameraParameters ¶m, bool contStream,
+ bool offline)
{
int32_t rc = 0;
QCameraStream *pStream = NULL;
@@ -841,7 +840,7 @@
memset(mSrcStreamHandles, 0, sizeof(mSrcStreamHandles));
- for (int i = 0; i < pSrcChannel->getNumOfStreams(); i++) {
+ for (uint32_t i = 0; i < pSrcChannel->getNumOfStreams(); i++) {
pStream = pSrcChannel->getStreamByIndex(i);
if (pStream != NULL) {
if (pStream->isTypeOf(CAM_STREAM_TYPE_METADATA) ||
@@ -859,33 +858,33 @@
continue;
}
- if(pStream->isTypeOf(CAM_STREAM_TYPE_PREVIEW) ||
- pStream->isTypeOf(CAM_STREAM_TYPE_POSTVIEW) ||
- pStream->isOrignalTypeOf(CAM_STREAM_TYPE_PREVIEW) ||
- pStream->isOrignalTypeOf(CAM_STREAM_TYPE_POSTVIEW)) {
- uint32_t feature_mask = config.feature_mask;
+ if (pStream->isTypeOf(CAM_STREAM_TYPE_PREVIEW) ||
+ pStream->isTypeOf(CAM_STREAM_TYPE_POSTVIEW) ||
+ pStream->isOrignalTypeOf(CAM_STREAM_TYPE_PREVIEW) ||
+ pStream->isOrignalTypeOf(CAM_STREAM_TYPE_POSTVIEW)) {
+ uint32_t feature_mask = config.feature_mask;
- if ((feature_mask & ~CAM_QCOM_FEATURE_HDR) == 0
- && param.isHDREnabled()
- && !param.isHDRThumbnailProcessNeeded()) {
+ if ((feature_mask & ~CAM_QCOM_FEATURE_HDR) == 0
+ && param.isHDREnabled()
+ && !param.isHDRThumbnailProcessNeeded()) {
- // Skip thumbnail stream reprocessing in HDR
- // if only hdr is enabled
- continue;
- }
+ // Skip thumbnail stream reprocessing in HDR
+ // if only hdr is enabled
+ continue;
+ }
- // skip thumbnail reprocessing if not needed
- if (!param.needThumbnailReprocess(&feature_mask)) {
- continue;
- }
+ // skip thumbnail reprocessing if not needed
+ if (!param.needThumbnailReprocess(&feature_mask)) {
+ continue;
+ }
- //Don't do WNR for thumbnail
- feature_mask &= ~CAM_QCOM_FEATURE_DENOISE2D;
- if(!feature_mask) {
+ //Don't do WNR for thumbnail
+ feature_mask &= ~CAM_QCOM_FEATURE_DENOISE2D;
+ if (!feature_mask) {
// Skip thumbnail stream reprocessing since no other
//reprocessing is enabled.
- continue;
- }
+ continue;
+ }
}
pStreamInfoBuf = allocator.allocateStreamInfoBuf(CAM_STREAM_TYPE_OFFLINE_PROC);
@@ -976,7 +975,7 @@
int flipMode = param.getFlipMode(type);
if (flipMode > 0) {
streamInfo->reprocess_config.pp_feature_config.feature_mask |= CAM_QCOM_FEATURE_FLIP;
- streamInfo->reprocess_config.pp_feature_config.flip = flipMode;
+ streamInfo->reprocess_config.pp_feature_config.flip = (uint32_t)flipMode;
}
}
@@ -1112,7 +1111,6 @@
}
// find meta data stream and index of meta data frame in the superbuf
- int32_t meta_buf_index = -1;
mm_camera_buf_def_t *meta_buf = NULL;
QCameraStream *pStream = NULL;
for (uint32_t i = 0; i < frame->num_bufs; i++) {
@@ -1133,7 +1131,7 @@
continue;
}
- meta_buf_index = 0;
+ uint32_t meta_buf_index = 0;
if (NULL != meta_buf) {
rc = pStream->mapBuf(CAM_MAPPING_BUF_TYPE_OFFLINE_META_BUF,
meta_buf_index,
@@ -1151,7 +1149,7 @@
mappedBuffer.type = CAM_MAPPING_BUF_TYPE_OFFLINE_META_BUF;
mOfflineBuffers.push_back(mappedBuffer);
- int buf_index = 1;
+ uint32_t buf_index = 1;
rc = pStream->mapBuf(CAM_MAPPING_BUF_TYPE_OFFLINE_INPUT_BUF,
buf_index,
-1,
@@ -1232,7 +1230,7 @@
// find meta data stream and index of meta data frame in the superbuf
QCameraStream *pMetaStream = NULL;
- uint8_t meta_buf_index = 0;
+ uint32_t meta_buf_index = 0;
for (uint32_t i = 0; i < frame->num_bufs; i++) {
QCameraStream *pStream = m_pSrcChannel->getStreamByHandle(frame->bufs[i]->stream_id);
if (pStream != NULL) {
@@ -1300,8 +1298,7 @@
* none-zero failure code
*==========================================================================*/
int32_t QCameraReprocessChannel::doReprocess(int buf_fd,
- uint32_t buf_length,
- int32_t &ret_val)
+ size_t buf_length, int32_t &ret_val)
{
int32_t rc = 0;
if (mStreams.size() < 1) {
diff --git a/QCamera2/HAL/QCameraChannel.h b/QCamera2/HAL/QCameraChannel.h
index 104b607..6ba101f 100644
--- a/QCamera2/HAL/QCameraChannel.h
+++ b/QCamera2/HAL/QCameraChannel.h
@@ -68,8 +68,10 @@
int32_t config();
QCameraStream *getStreamByHandle(uint32_t streamHandle);
uint32_t getMyHandle() const {return m_handle;};
- uint8_t getNumOfStreams() const {return mStreams.size();};
- QCameraStream *getStreamByIndex(uint8_t index);
+ uint32_t getNumOfStreams() const {
+ return (uint32_t) mStreams.size();
+ }
+ QCameraStream *getStreamByIndex(uint32_t index);
QCameraStream *getStreamByServerID(uint32_t serverID);
int32_t UpdateStreamBasedParameters(QCameraParameters ¶m);
void deleteChannel();
@@ -122,7 +124,7 @@
cam_pp_feature_config_t &config,
QCameraChannel *pSrcChannel,
uint8_t minStreamBufNum,
- uint32_t burstNum,
+ uint8_t burstNum,
cam_padding_info_t *paddingInfo,
QCameraParameters ¶m,
bool contStream,
@@ -130,7 +132,7 @@
// online reprocess
int32_t doReprocess(mm_camera_super_buf_t *frame);
// offline reprocess
- int32_t doReprocess(int buf_fd, uint32_t buf_length, int32_t &ret_val);
+ int32_t doReprocess(int buf_fd, size_t buf_length, int32_t &ret_val);
int32_t doReprocessOffline(mm_camera_super_buf_t *frame);
int32_t stop();
QCameraChannel *getSourceChannel() { return m_pSrcChannel; }
@@ -141,7 +143,7 @@
typedef struct {
QCameraStream *stream;
cam_mapping_buf_type type;
- int index;
+ uint32_t index;
} OfflineBuffer;
uint32_t mSrcStreamHandles[MAX_STREAM_NUM_IN_BUNDLE];
diff --git a/QCamera2/HAL/QCameraMem.cpp b/QCamera2/HAL/QCameraMem.cpp
index 2d797f8..b37c7f1 100644
--- a/QCamera2/HAL/QCameraMem.cpp
+++ b/QCamera2/HAL/QCameraMem.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundataion. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundataion. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -99,7 +99,7 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraMemory::cacheOpsInternal(int index, unsigned int cmd, void *vaddr)
+int QCameraMemory::cacheOpsInternal(uint32_t index, unsigned int cmd, void *vaddr)
{
if (!m_bCached) {
// Memory is not cached, no need for cache ops
@@ -121,7 +121,9 @@
cache_inv_data.vaddr = vaddr;
cache_inv_data.fd = mMemInfo[index].fd;
cache_inv_data.handle = mMemInfo[index].handle;
- cache_inv_data.length = mMemInfo[index].size;
+ cache_inv_data.length =
+ ( /* FIXME: Should remove this after ION interface changes */ unsigned int)
+ mMemInfo[index].size;
custom_data.cmd = cmd;
custom_data.arg = (unsigned long)&cache_inv_data;
@@ -146,7 +148,7 @@
*
* RETURN : file descriptor
*==========================================================================*/
-int QCameraMemory::getFd(int index) const
+int QCameraMemory::getFd(uint32_t index) const
{
if (index >= mBufferCount)
return BAD_INDEX;
@@ -164,12 +166,12 @@
*
* RETURN : buffer size
*==========================================================================*/
-int QCameraMemory::getSize(int index) const
+ssize_t QCameraMemory::getSize(uint32_t index) const
{
if (index >= mBufferCount)
return BAD_INDEX;
- return (int)mMemInfo[index].size;
+ return (ssize_t)mMemInfo[index].size;
}
/*===========================================================================
@@ -181,7 +183,7 @@
*
* RETURN : number of buffers allocated
*==========================================================================*/
-int QCameraMemory::getCnt() const
+uint8_t QCameraMemory::getCnt() const
{
return mBufferCount;
}
@@ -199,7 +201,7 @@
* RETURN : none
*==========================================================================*/
void QCameraMemory::getBufDef(const cam_frame_len_offset_t &offset,
- mm_camera_buf_def_t &bufDef, int index) const
+ mm_camera_buf_def_t &bufDef, uint32_t index) const
{
if (!mBufferCount) {
ALOGE("Memory not allocated");
@@ -208,18 +210,18 @@
bufDef.fd = mMemInfo[index].fd;
bufDef.frame_len = mMemInfo[index].size;
bufDef.mem_info = (void *)this;
- bufDef.num_planes = offset.num_planes;
- bufDef.buffer = getPtr(index);
+ bufDef.num_planes = (int8_t)offset.num_planes;
+ bufDef.buffer = getPtr(index);
bufDef.buf_idx = index;
/* Plane 0 needs to be set separately. Set other planes in a loop */
bufDef.planes[0].length = offset.mp[0].len;
- bufDef.planes[0].m.userptr = mMemInfo[index].fd;
+ bufDef.planes[0].m.userptr = (long unsigned int)mMemInfo[index].fd;
bufDef.planes[0].data_offset = offset.mp[0].offset;
bufDef.planes[0].reserved[0] = 0;
for (int i = 1; i < bufDef.num_planes; i++) {
bufDef.planes[i].length = offset.mp[i].len;
- bufDef.planes[i].m.userptr = mMemInfo[i].fd;
+ bufDef.planes[i].m.userptr = (long unsigned int)mMemInfo[i].fd;
bufDef.planes[i].data_offset = offset.mp[i].offset;
bufDef.planes[i].reserved[0] =
bufDef.planes[i-1].reserved[0] +
@@ -239,13 +241,13 @@
*
* RETURN : none
*==========================================================================*/
-inline void QCameraMemory::traceLogAllocStart(int size, int count, const char *allocName)
+inline void QCameraMemory::traceLogAllocStart(size_t size, int count, const char *allocName)
{
- ALOGD("%s : alloc E count=%d size=%d", __func__, count, size);
+ ALOGD("%s : alloc E count=%d size=%zu", __func__, count, size);
#ifdef ATRACE_TAG_CAMERA
char atracer[30];
- if ((size * count) > MEMLOG_THRESH) {
- snprintf(atracer,sizeof(atracer), "%s %d",allocName, size);
+ if ((size * (size_t)count) > MEMLOG_THRESH) {
+ snprintf(atracer,sizeof(atracer), "%s %zu",allocName, size);
ATRACE_BEGIN(atracer);
ALOGE("%s:%s", __func__, atracer);
} else {
@@ -265,13 +267,13 @@
*
* RETURN : none
*==========================================================================*/
-inline void QCameraMemory::traceLogAllocEnd(int size)
+inline void QCameraMemory::traceLogAllocEnd(size_t size)
{
ALOGD(" %s : X", __func__);
#ifdef ATRACE_TAG_CAMERA
if (size > MEMLOG_THRESH) {
ATRACE_END();
- ALOGE("%s %d", __func__, size);
+ ALOGE("%s %zu", __func__, size);
}
#endif
}
@@ -290,12 +292,13 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraMemory::alloc(int count, int size, int heap_id)
+int QCameraMemory::alloc(int count, size_t size, unsigned int heap_id)
{
int rc = OK;
- if (mBufferCount < 0) {
- mBufferCount = 0;
+ if (0 > count) {
+ ALOGE("%s: Negative count %d", __func__, count);
+ return BAD_INDEX;
}
int new_bufCnt = mBufferCount + count;
@@ -333,7 +336,7 @@
}
}
- traceLogAllocEnd((size * count));
+ traceLogAllocEnd (size * (size_t)count);
return rc;
}
@@ -373,9 +376,7 @@
* none-zero failure code
*==========================================================================*/
int QCameraMemory::allocOneBuffer(QCameraMemInfo &memInfo,
- int heap_id,
- int size,
- bool cached)
+ unsigned int heap_id, size_t size, bool cached)
{
int rc = OK;
struct ion_handle_data handle_data;
@@ -392,7 +393,7 @@
memset(&alloc, 0, sizeof(alloc));
alloc.len = size;
/* to make it page size aligned */
- alloc.len = (alloc.len + 4095) & (~4095);
+ alloc.len = (alloc.len + 4095U) & (~4095U);
alloc.align = 4096;
if (cached) {
alloc.flags = ION_FLAG_CACHED;
@@ -557,11 +558,8 @@
* none-zero failure code
*==========================================================================*/
int QCameraMemoryPool::findBufferLocked(
- struct QCameraMemory::QCameraMemInfo &memInfo,
- int heap_id,
- uint32_t size,
- bool cached,
- cam_stream_type_t streamType)
+ struct QCameraMemory::QCameraMemInfo &memInfo, unsigned int heap_id,
+ size_t size, bool cached, cam_stream_type_t streamType)
{
int rc = NAME_NOT_FOUND;
@@ -604,11 +602,8 @@
* none-zero failure code
*==========================================================================*/
int QCameraMemoryPool::allocateBuffer(
- struct QCameraMemory::QCameraMemInfo &memInfo,
- int heap_id,
- int size,
- bool cached,
- cam_stream_type_t streamType)
+ struct QCameraMemory::QCameraMemInfo &memInfo, unsigned int heap_id,
+ size_t size, bool cached, cam_stream_type_t streamType)
{
int rc = NO_ERROR;
@@ -665,7 +660,7 @@
*
* RETURN : buffer ptr
*==========================================================================*/
-void *QCameraHeapMemory::getPtr(int index) const
+void *QCameraHeapMemory::getPtr(uint32_t index) const
{
if (index >= mBufferCount) {
ALOGE("index out of bound");
@@ -687,10 +682,10 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraHeapMemory::allocate(int count, int size)
+int QCameraHeapMemory::allocate(uint8_t count, size_t size)
{
traceLogAllocStart(size, count, "HeapMemsize");
- int heap_mask = 0x1 << ION_IOMMU_HEAP_ID;
+ unsigned int heap_mask = 0x1 << ION_IOMMU_HEAP_ID;
int rc = alloc(count, size, heap_mask);
if (rc < 0)
return rc;
@@ -730,10 +725,10 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraHeapMemory::allocateMore(int count, int size)
+int QCameraHeapMemory::allocateMore(uint8_t count, size_t size)
{
traceLogAllocStart(size, count, "HeapMemsize");
- int heap_mask = 0x1 << ION_IOMMU_HEAP_ID;
+ unsigned int heap_mask = 0x1 << ION_IOMMU_HEAP_ID;
int rc = alloc(count, size, heap_mask);
if (rc < 0)
return rc;
@@ -755,7 +750,7 @@
mPtr[i] = vaddr;
}
}
- mBufferCount += count;
+ mBufferCount = (uint8_t)(mBufferCount + count);
traceLogAllocEnd((size * count));
return OK;
}
@@ -792,7 +787,7 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraHeapMemory::cacheOps(int index, unsigned int cmd)
+int QCameraHeapMemory::cacheOps(uint32_t index, unsigned int cmd)
{
if (index >= mBufferCount)
return BAD_INDEX;
@@ -828,8 +823,7 @@
* RETURN : camera memory ptr
* NULL if not supported or failed
*==========================================================================*/
-camera_memory_t *QCameraHeapMemory::getMemory(
- int /*index*/, bool /*metadata*/) const
+camera_memory_t *QCameraHeapMemory::getMemory(uint32_t /*index*/, bool /*metadata*/) const
{
return NULL;
}
@@ -911,10 +905,10 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraStreamMemory::allocate(int count, int size)
+int QCameraStreamMemory::allocate(uint8_t count, size_t size)
{
traceLogAllocStart(size, count, "StreamMemsize");
- int heap_mask = 0x1 << ION_IOMMU_HEAP_ID;
+ unsigned int heap_mask = 0x1 << ION_IOMMU_HEAP_ID;
int rc = alloc(count, size, heap_mask);
if (rc < 0)
return rc;
@@ -940,10 +934,10 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraStreamMemory::allocateMore(int count, int size)
+int QCameraStreamMemory::allocateMore(uint8_t count, size_t size)
{
traceLogAllocStart(size, count, "StreamMemsize");
- int heap_mask = 0x1 << ION_IOMMU_HEAP_ID;
+ unsigned int heap_mask = 0x1 << ION_IOMMU_HEAP_ID;
int rc = alloc(count, size, heap_mask);
if (rc < 0)
return rc;
@@ -951,7 +945,7 @@
for (int i = mBufferCount; i < mBufferCount + count; i++) {
mCameraMemory[i] = mGetMemory(mMemInfo[i].fd, mMemInfo[i].size, 1, this);
}
- mBufferCount += count;
+ mBufferCount = (uint8_t)(mBufferCount + count);
traceLogAllocEnd((size * count));
return NO_ERROR;
}
@@ -988,7 +982,7 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraStreamMemory::cacheOps(int index, unsigned int cmd)
+int QCameraStreamMemory::cacheOps(uint32_t index, unsigned int cmd)
{
if (index >= mBufferCount)
return BAD_INDEX;
@@ -1026,7 +1020,8 @@
* RETURN : camera memory ptr
* NULL if not supported or failed
*==========================================================================*/
-camera_memory_t *QCameraStreamMemory::getMemory(int index, bool metadata) const
+camera_memory_t *QCameraStreamMemory::getMemory(uint32_t index,
+ bool metadata) const
{
if (index >= mBufferCount || metadata)
return NULL;
@@ -1071,7 +1066,7 @@
*
* RETURN : buffer ptr
*==========================================================================*/
-void *QCameraStreamMemory::getPtr(int index) const
+void *QCameraStreamMemory::getPtr(uint32_t index) const
{
if (index >= mBufferCount) {
ALOGE("index out of bound");
@@ -1125,7 +1120,7 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraVideoMemory::allocate(int count, int size)
+int QCameraVideoMemory::allocate(uint8_t count, size_t size)
{
traceLogAllocStart(size, count, "VideoMemsize");
int rc = QCameraStreamMemory::allocate(count, size);
@@ -1149,7 +1144,7 @@
native_handle_t * nh = const_cast<native_handle_t *>(packet->meta_handle);
nh->data[0] = mMemInfo[i].fd;
nh->data[1] = 0;
- nh->data[2] = mMemInfo[i].size;
+ nh->data[2] = (int)mMemInfo[i].size;
}
mBufferCount = count;
traceLogAllocEnd((size * count));
@@ -1169,7 +1164,7 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraVideoMemory::allocateMore(int count, int size)
+int QCameraVideoMemory::allocateMore(uint8_t count, size_t size)
{
traceLogAllocStart(size, count, "VideoMemsize");
int rc = QCameraStreamMemory::allocateMore(count, size);
@@ -1196,9 +1191,9 @@
native_handle_t * nh = const_cast<native_handle_t *>(packet->meta_handle);
nh->data[0] = mMemInfo[i].fd;
nh->data[1] = 0;
- nh->data[2] = mMemInfo[i].size;
+ nh->data[2] = (int)mMemInfo[i].size;
}
- mBufferCount += count;
+ mBufferCount = (uint8_t)(mBufferCount + count);
traceLogAllocEnd((size * count));
return NO_ERROR;
}
@@ -1250,7 +1245,8 @@
* RETURN : camera memory ptr
* NULL if not supported or failed
*==========================================================================*/
-camera_memory_t *QCameraVideoMemory::getMemory(int index, bool metadata) const
+camera_memory_t *QCameraVideoMemory::getMemory(uint32_t index,
+ bool metadata) const
{
if (index >= mBufferCount)
return NULL;
@@ -1369,7 +1365,7 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraGrallocMemory::displayBuffer(int index)
+int QCameraGrallocMemory::displayBuffer(uint32_t index)
{
int err = NO_ERROR;
int dequeuedIdx = BAD_INDEX;
@@ -1420,7 +1416,7 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraGrallocMemory::allocate(int count, int /*size*/)
+int QCameraGrallocMemory::allocate(uint8_t count, size_t /*size*/)
{
traceLogAllocStart(0,count, "Grallocbufcnt");
int err = 0;
@@ -1569,17 +1565,15 @@
}
mCameraMemory[cnt] =
mGetMemory(mPrivateHandle[cnt]->fd,
- mPrivateHandle[cnt]->size,
+ (size_t)mPrivateHandle[cnt]->size,
1,
(void *)this);
CDBG("%s: idx = %d, fd = %d, size = %d, offset = %d",
__func__, cnt, mPrivateHandle[cnt]->fd,
mPrivateHandle[cnt]->size,
mPrivateHandle[cnt]->offset);
- mMemInfo[cnt].fd =
- mPrivateHandle[cnt]->fd;
- mMemInfo[cnt].size =
- mPrivateHandle[cnt]->size;
+ mMemInfo[cnt].fd = mPrivateHandle[cnt]->fd;
+ mMemInfo[cnt].size = (size_t)mPrivateHandle[cnt]->size;
mMemInfo[cnt].handle = ion_info_fd.handle;
}
mBufferCount = count;
@@ -1609,7 +1603,7 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraGrallocMemory::allocateMore(int /*count*/, int /*size*/)
+int QCameraGrallocMemory::allocateMore(uint8_t /*count*/, size_t /*size*/)
{
ALOGE("%s: Not implenmented yet", __func__);
return UNKNOWN_ERROR;
@@ -1666,7 +1660,7 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int QCameraGrallocMemory::cacheOps(int index, unsigned int cmd)
+int QCameraGrallocMemory::cacheOps(uint32_t index, unsigned int cmd)
{
if (index >= mBufferCount)
return BAD_INDEX;
@@ -1707,7 +1701,8 @@
* RETURN : camera memory ptr
* NULL if not supported or failed
*==========================================================================*/
-camera_memory_t *QCameraGrallocMemory::getMemory(int index, bool metadata) const
+camera_memory_t *QCameraGrallocMemory::getMemory(uint32_t index,
+ bool metadata) const
{
if (index >= mBufferCount || metadata)
return NULL;
@@ -1752,7 +1747,7 @@
*
* RETURN : buffer ptr
*==========================================================================*/
-void *QCameraGrallocMemory::getPtr(int index) const
+void *QCameraGrallocMemory::getPtr(uint32_t index) const
{
if (index >= mBufferCount) {
ALOGE("index out of bound");
diff --git a/QCamera2/HAL/QCameraMem.h b/QCamera2/HAL/QCameraMem.h
index a755a4d..43e7133 100644
--- a/QCamera2/HAL/QCameraMem.h
+++ b/QCamera2/HAL/QCameraMem.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundataion. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundataion. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -48,21 +48,31 @@
class QCameraMemory {
public:
- int cleanCache(int index) {return cacheOps(index, ION_IOC_CLEAN_CACHES);}
- int invalidateCache(int index) {return cacheOps(index, ION_IOC_INV_CACHES);}
- int cleanInvalidateCache(int index) {return cacheOps(index, ION_IOC_CLEAN_INV_CACHES);}
- int getFd(int index) const;
- int getSize(int index) const;
- int getCnt() const;
+ int cleanCache(uint32_t index)
+ {
+ return cacheOps(index, ION_IOC_CLEAN_CACHES);
+ }
+ int invalidateCache(uint32_t index)
+ {
+ return cacheOps(index, ION_IOC_INV_CACHES);
+ }
+ int cleanInvalidateCache(uint32_t index)
+ {
+ return cacheOps(index, ION_IOC_CLEAN_INV_CACHES);
+ }
+ int getFd(uint32_t index) const;
+ ssize_t getSize(uint32_t index) const;
+ uint8_t getCnt() const;
- virtual int allocate(int count, int size) = 0;
+ virtual int allocate(uint8_t count, size_t size) = 0;
virtual void deallocate() = 0;
- virtual int allocateMore(int count, int size) = 0;
- virtual int cacheOps(int index, unsigned int cmd) = 0;
+ virtual int allocateMore(uint8_t count, size_t size) = 0;
+ virtual int cacheOps(uint32_t index, unsigned int cmd) = 0;
virtual int getRegFlags(uint8_t *regFlags) const = 0;
- virtual camera_memory_t *getMemory(int index, bool metadata) const = 0;
+ virtual camera_memory_t *getMemory(uint32_t index,
+ bool metadata) const = 0;
virtual int getMatchBufIndex(const void *opaque, bool metadata) const = 0;
- virtual void *getPtr(int index) const= 0;
+ virtual void *getPtr(uint32_t index) const= 0;
QCameraMemory(bool cached,
QCameraMemoryPool *pool = NULL,
@@ -70,10 +80,10 @@
virtual ~QCameraMemory();
void getBufDef(const cam_frame_len_offset_t &offset,
- mm_camera_buf_def_t &bufDef, int index) const;
+ mm_camera_buf_def_t &bufDef, uint32_t index) const;
- void traceLogAllocStart(int size, int count, const char *allocName);
- void traceLogAllocEnd(int size);
+ void traceLogAllocStart(size_t size, int count, const char *allocName);
+ void traceLogAllocEnd(size_t size);
protected:
@@ -83,22 +93,20 @@
int fd;
int main_ion_fd;
ion_user_handle_t handle;
- uint32_t size;
+ size_t size;
bool cached;
- int heap_id;
+ unsigned int heap_id;
};
- int alloc(int count, int size, int heap_id);
+ int alloc(int count, size_t size, unsigned int heap_id);
void dealloc();
static int allocOneBuffer(struct QCameraMemInfo &memInfo,
- int heap_id,
- int size,
- bool cached);
+ unsigned int heap_id, size_t size, bool cached);
static void deallocOneBuffer(struct QCameraMemInfo &memInfo);
- int cacheOpsInternal(int index, unsigned int cmd, void *vaddr);
+ int cacheOpsInternal(uint32_t index, unsigned int cmd, void *vaddr);
bool m_bCached;
- int mBufferCount;
+ uint8_t mBufferCount;
struct QCameraMemInfo mMemInfo[MM_CAMERA_MAX_NUM_FRAMES];
QCameraMemoryPool *mMemoryPool;
cam_stream_type_t mStreamType;
@@ -112,21 +120,17 @@
virtual ~QCameraMemoryPool();
int allocateBuffer(struct QCameraMemory::QCameraMemInfo &memInfo,
- int heap_id,
- int size,
- bool cached,
- cam_stream_type_t streamType);
+ unsigned int heap_id, size_t size, bool cached,
+ cam_stream_type_t streamType);
void releaseBuffer(struct QCameraMemory::QCameraMemInfo &memInfo,
- cam_stream_type_t streamType);
+ cam_stream_type_t streamType);
void clear();
protected:
int findBufferLocked(struct QCameraMemory::QCameraMemInfo &memInfo,
- int heap_id,
- uint32_t size,
- bool cached,
- cam_stream_type_t streamType);
+ unsigned int heap_id, size_t size, bool cached,
+ cam_stream_type_t streamType);
android::List<QCameraMemory::QCameraMemInfo> mPools[CAM_STREAM_TYPE_MAX];
pthread_mutex_t mLock;
@@ -139,14 +143,14 @@
QCameraHeapMemory(bool cached);
virtual ~QCameraHeapMemory();
- virtual int allocate(int count, int size);
- virtual int allocateMore(int count, int size);
+ virtual int allocate(uint8_t count, size_t size);
+ virtual int allocateMore(uint8_t count, size_t size);
virtual void deallocate();
- virtual int cacheOps(int index, unsigned int cmd);
+ virtual int cacheOps(uint32_t index, unsigned int cmd);
virtual int getRegFlags(uint8_t *regFlags) const;
- virtual camera_memory_t *getMemory(int index, bool metadata) const;
+ virtual camera_memory_t *getMemory(uint32_t index, bool metadata) const;
virtual int getMatchBufIndex(const void *opaque, bool metadata) const;
- virtual void *getPtr(int index) const;
+ virtual void *getPtr(uint32_t index) const;
private:
void *mPtr[MM_CAMERA_MAX_NUM_FRAMES];
@@ -162,14 +166,14 @@
cam_stream_type_t streamType = CAM_STREAM_TYPE_DEFAULT);
virtual ~QCameraStreamMemory();
- virtual int allocate(int count, int size);
- virtual int allocateMore(int count, int size);
+ virtual int allocate(uint8_t count, size_t size);
+ virtual int allocateMore(uint8_t count, size_t size);
virtual void deallocate();
- virtual int cacheOps(int index, unsigned int cmd);
+ virtual int cacheOps(uint32_t index, unsigned int cmd);
virtual int getRegFlags(uint8_t *regFlags) const;
- virtual camera_memory_t *getMemory(int index, bool metadata) const;
+ virtual camera_memory_t *getMemory(uint32_t index, bool metadata) const;
virtual int getMatchBufIndex(const void *opaque, bool metadata) const;
- virtual void *getPtr(int index) const;
+ virtual void *getPtr(uint32_t index) const;
protected:
camera_request_memory mGetMemory;
@@ -183,10 +187,10 @@
QCameraVideoMemory(camera_request_memory getMemory, bool cached);
virtual ~QCameraVideoMemory();
- virtual int allocate(int count, int size);
- virtual int allocateMore(int count, int size);
+ virtual int allocate(uint8_t count, size_t size);
+ virtual int allocateMore(uint8_t count, size_t size);
virtual void deallocate();
- virtual camera_memory_t *getMemory(int index, bool metadata) const;
+ virtual camera_memory_t *getMemory(uint32_t index, bool metadata) const;
virtual int getMatchBufIndex(const void *opaque, bool metadata) const;
private:
@@ -205,21 +209,21 @@
void setNativeWindow(preview_stream_ops_t *anw);
virtual ~QCameraGrallocMemory();
- virtual int allocate(int count, int size);
- virtual int allocateMore(int count, int size);
+ virtual int allocate(uint8_t count, size_t size);
+ virtual int allocateMore(uint8_t count, size_t size);
virtual void deallocate();
- virtual int cacheOps(int index, unsigned int cmd);
+ virtual int cacheOps(uint32_t index, unsigned int cmd);
virtual int getRegFlags(uint8_t *regFlags) const;
- virtual camera_memory_t *getMemory(int index, bool metadata) const;
+ virtual camera_memory_t *getMemory(uint32_t index, bool metadata) const;
virtual int getMatchBufIndex(const void *opaque, bool metadata) const;
- virtual void *getPtr(int index) const;
+ virtual void *getPtr(uint32_t index) const;
void setWindowInfo(preview_stream_ops_t *window, int width, int height,
int stride, int scanline, int format);
// Enqueue/display buffer[index] onto the native window,
// and dequeue one buffer from it.
// Returns the buffer index of the dequeued buffer.
- int displayBuffer(int index);
+ int displayBuffer(uint32_t index);
private:
buffer_handle_t *mBufferHandle[MM_CAMERA_MAX_NUM_FRAMES];
diff --git a/QCamera2/HAL/QCameraParameters.cpp b/QCamera2/HAL/QCameraParameters.cpp
index 59f8ebb..0fac6f3 100644
--- a/QCamera2/HAL/QCameraParameters.cpp
+++ b/QCamera2/HAL/QCameraParameters.cpp
@@ -32,6 +32,7 @@
#include <cutils/properties.h>
#include <math.h>
#include <utils/Errors.h>
+#include <utils/Log.h>
#include <string.h>
#include <stdlib.h>
#include <gralloc_priv.h>
@@ -367,7 +368,8 @@
{ 0, 0 } // required by Android SDK
};
-const QCameraParameters::QCameraMap QCameraParameters::AUTO_EXPOSURE_MAP[] = {
+const QCameraParameters::QCameraMap<cam_auto_exposure_mode_type>
+ QCameraParameters::AUTO_EXPOSURE_MAP[] = {
{ AUTO_EXPOSURE_FRAME_AVG, CAM_AEC_MODE_FRAME_AVERAGE },
{ AUTO_EXPOSURE_CENTER_WEIGHTED, CAM_AEC_MODE_CENTER_WEIGHTED },
{ AUTO_EXPOSURE_SPOT_METERING, CAM_AEC_MODE_SPOT_METERING },
@@ -377,7 +379,8 @@
{ AUTO_EXPOSURE_CENTER_WEIGHTED_ADV, CAM_AEC_MODE_CENTER_WEIGHTED_ADV },
};
-const QCameraParameters::QCameraMap QCameraParameters::PREVIEW_FORMATS_MAP[] = {
+const QCameraParameters::QCameraMap<cam_format_t>
+ QCameraParameters::PREVIEW_FORMATS_MAP[] = {
{PIXEL_FORMAT_YUV420SP, CAM_FORMAT_YUV_420_NV21},
{PIXEL_FORMAT_YUV420P, CAM_FORMAT_YUV_420_YV12},
{PIXEL_FORMAT_YUV420SP_ADRENO, CAM_FORMAT_YUV_420_NV21_ADRENO},
@@ -386,7 +389,8 @@
{QC_PIXEL_FORMAT_NV12_VENUS, CAM_FORMAT_YUV_420_NV12_VENUS}
};
-const QCameraParameters::QCameraMap QCameraParameters::PICTURE_TYPES_MAP[] = {
+const QCameraParameters::QCameraMap<cam_format_t>
+ QCameraParameters::PICTURE_TYPES_MAP[] = {
{PIXEL_FORMAT_JPEG, CAM_FORMAT_JPEG},
{PIXEL_FORMAT_YUV420SP, CAM_FORMAT_YUV_420_NV21},
{PIXEL_FORMAT_YUV422SP, CAM_FORMAT_YUV_422_NV16},
@@ -460,10 +464,8 @@
{QC_PIXEL_FORMAT_BAYER_IDEAL_PLAIN16_12BGGR, CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_12BPP_BGGR}
};
-const QCameraParameters::QCameraMap QCameraParameters::RAW_FORMATS_MAP[] = {
-};
-
-const QCameraParameters::QCameraMap QCameraParameters::FOCUS_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<cam_focus_mode_type>
+ QCameraParameters::FOCUS_MODES_MAP[] = {
{ FOCUS_MODE_AUTO, CAM_FOCUS_MODE_AUTO },
{ FOCUS_MODE_INFINITY, CAM_FOCUS_MODE_INFINITY },
{ FOCUS_MODE_MACRO, CAM_FOCUS_MODE_MACRO },
@@ -474,7 +476,8 @@
{ FOCUS_MODE_MANUAL_POSITION, CAM_FOCUS_MODE_MANUAL},
};
-const QCameraParameters::QCameraMap QCameraParameters::EFFECT_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<cam_effect_mode_type>
+ QCameraParameters::EFFECT_MODES_MAP[] = {
{ EFFECT_NONE, CAM_EFFECT_MODE_OFF },
{ EFFECT_MONO, CAM_EFFECT_MODE_MONO },
{ EFFECT_NEGATIVE, CAM_EFFECT_MODE_NEGATIVE },
@@ -489,7 +492,8 @@
{ EFFECT_NEON, CAM_EFFECT_MODE_NEON }
};
-const QCameraParameters::QCameraMap QCameraParameters::SCENE_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<cam_scene_mode_type>
+ QCameraParameters::SCENE_MODES_MAP[] = {
{ SCENE_MODE_AUTO, CAM_SCENE_MODE_OFF },
{ SCENE_MODE_ACTION, CAM_SCENE_MODE_ACTION },
{ SCENE_MODE_PORTRAIT, CAM_SCENE_MODE_PORTRAIT },
@@ -512,21 +516,24 @@
{ SCENE_MODE_HDR, CAM_SCENE_MODE_HDR },
};
-const QCameraParameters::QCameraMap QCameraParameters::FLASH_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<cam_flash_mode_t>
+ QCameraParameters::FLASH_MODES_MAP[] = {
{ FLASH_MODE_OFF, CAM_FLASH_MODE_OFF },
{ FLASH_MODE_AUTO, CAM_FLASH_MODE_AUTO },
{ FLASH_MODE_ON, CAM_FLASH_MODE_ON },
{ FLASH_MODE_TORCH, CAM_FLASH_MODE_TORCH }
};
-const QCameraParameters::QCameraMap QCameraParameters::FOCUS_ALGO_MAP[] = {
+const QCameraParameters::QCameraMap<cam_focus_algorithm_type>
+ QCameraParameters::FOCUS_ALGO_MAP[] = {
{ FOCUS_ALGO_AUTO, CAM_FOCUS_ALGO_AUTO },
{ FOCUS_ALGO_SPOT_METERING, CAM_FOCUS_ALGO_SPOT },
{ FOCUS_ALGO_CENTER_WEIGHTED, CAM_FOCUS_ALGO_CENTER_WEIGHTED },
{ FOCUS_ALGO_FRAME_AVERAGE, CAM_FOCUS_ALGO_AVERAGE }
};
-const QCameraParameters::QCameraMap QCameraParameters::WHITE_BALANCE_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<cam_wb_mode_type>
+ QCameraParameters::WHITE_BALANCE_MODES_MAP[] = {
{ WHITE_BALANCE_AUTO, CAM_WB_MODE_AUTO },
{ WHITE_BALANCE_INCANDESCENT, CAM_WB_MODE_INCANDESCENT },
{ WHITE_BALANCE_FLUORESCENT, CAM_WB_MODE_FLUORESCENT },
@@ -538,14 +545,16 @@
{ WHITE_BALANCE_MANUAL_CCT, CAM_WB_MODE_CCT},
};
-const QCameraParameters::QCameraMap QCameraParameters::ANTIBANDING_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<cam_antibanding_mode_type>
+ QCameraParameters::ANTIBANDING_MODES_MAP[] = {
{ ANTIBANDING_OFF, CAM_ANTIBANDING_MODE_OFF },
{ ANTIBANDING_50HZ, CAM_ANTIBANDING_MODE_50HZ },
{ ANTIBANDING_60HZ, CAM_ANTIBANDING_MODE_60HZ },
{ ANTIBANDING_AUTO, CAM_ANTIBANDING_MODE_AUTO }
};
-const QCameraParameters::QCameraMap QCameraParameters::ISO_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<cam_iso_mode_type>
+ QCameraParameters::ISO_MODES_MAP[] = {
{ ISO_AUTO, CAM_ISO_MODE_AUTO },
{ ISO_HJR, CAM_ISO_MODE_DEBLUR },
{ ISO_100, CAM_ISO_MODE_100 },
@@ -556,7 +565,8 @@
{ ISO_3200, CAM_ISO_MODE_3200 }
};
-const QCameraParameters::QCameraMap QCameraParameters::HFR_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<cam_hfr_mode_t>
+ QCameraParameters::HFR_MODES_MAP[] = {
{ VIDEO_HFR_OFF, CAM_HFR_MODE_OFF },
{ VIDEO_HFR_2X, CAM_HFR_MODE_60FPS },
{ VIDEO_HFR_3X, CAM_HFR_MODE_90FPS },
@@ -564,74 +574,88 @@
{ VIDEO_HFR_5X, CAM_HFR_MODE_150FPS }
};
-const QCameraParameters::QCameraMap QCameraParameters::BRACKETING_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<cam_bracket_mode>
+ QCameraParameters::BRACKETING_MODES_MAP[] = {
{ AE_BRACKET_OFF, CAM_EXP_BRACKETING_OFF },
{ AE_BRACKET, CAM_EXP_BRACKETING_ON }
};
-const QCameraParameters::QCameraMap QCameraParameters::ON_OFF_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<int>
+ QCameraParameters::ON_OFF_MODES_MAP[] = {
{ VALUE_OFF, 0 },
{ VALUE_ON, 1 }
};
-const QCameraParameters::QCameraMap QCameraParameters::TOUCH_AF_AEC_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<int>
+ QCameraParameters::TOUCH_AF_AEC_MODES_MAP[] = {
{ QCameraParameters::TOUCH_AF_AEC_OFF, 0 },
{ QCameraParameters::TOUCH_AF_AEC_ON, 1 }
};
-const QCameraParameters::QCameraMap QCameraParameters::ENABLE_DISABLE_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<int>
+ QCameraParameters::ENABLE_DISABLE_MODES_MAP[] = {
{ VALUE_ENABLE, 1 },
{ VALUE_DISABLE, 0 }
};
-const QCameraParameters::QCameraMap QCameraParameters::DENOISE_ON_OFF_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<int>
+ QCameraParameters::DENOISE_ON_OFF_MODES_MAP[] = {
{ DENOISE_OFF, 0 },
{ DENOISE_ON, 1 }
};
-const QCameraParameters::QCameraMap QCameraParameters::TRUE_FALSE_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<int>
+ QCameraParameters::TRUE_FALSE_MODES_MAP[] = {
{ VALUE_FALSE, 0},
{ VALUE_TRUE, 1}
};
-const QCameraParameters::QCameraMap QCameraParameters::FLIP_MODES_MAP[] = {
- {FLIP_MODE_OFF, 0},
+const QCameraParameters::QCameraMap<cam_flip_t>
+ QCameraParameters::FLIP_MODES_MAP[] = {
+ {FLIP_MODE_OFF, FLIP_NONE},
{FLIP_MODE_V, FLIP_V},
{FLIP_MODE_H, FLIP_H},
{FLIP_MODE_VH, FLIP_V_H}
};
-const QCameraParameters::QCameraMap QCameraParameters::AF_BRACKETING_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<int>
+ QCameraParameters::AF_BRACKETING_MODES_MAP[] = {
{ AF_BRACKET_OFF, 0 },
{ AF_BRACKET_ON, 1 }
};
-const QCameraParameters::QCameraMap QCameraParameters::CHROMA_FLASH_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<int>
+ QCameraParameters::CHROMA_FLASH_MODES_MAP[] = {
{ CHROMA_FLASH_OFF, 0 },
{ CHROMA_FLASH_ON, 1 }
};
-const QCameraParameters::QCameraMap QCameraParameters::OPTI_ZOOM_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<int>
+ QCameraParameters::OPTI_ZOOM_MODES_MAP[] = {
{ OPTI_ZOOM_OFF, 0 },
{ OPTI_ZOOM_ON, 1 }
};
-const QCameraParameters::QCameraMap QCameraParameters::TRUE_PORTRAIT_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<int>
+ QCameraParameters::TRUE_PORTRAIT_MODES_MAP[] = {
{ TRUE_PORTRAIT_OFF, 0 },
{ TRUE_PORTRAIT_ON, 1 }
};
-const QCameraParameters::QCameraMap QCameraParameters::FSSR_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<int>
+ QCameraParameters::FSSR_MODES_MAP[] = {
{ FSSR_OFF, 0 },
{ FSSR_ON, 1 }
};
-const QCameraParameters::QCameraMap QCameraParameters::MULTI_TOUCH_FOCUS_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<int>
+ QCameraParameters::MULTI_TOUCH_FOCUS_MODES_MAP[] = {
{ MULTI_TOUCH_FOCUS_OFF, 0 },
{ MULTI_TOUCH_FOCUS_ON, 1 }
};
-const QCameraParameters::QCameraMap QCameraParameters::CDS_MODES_MAP[] = {
+const QCameraParameters::QCameraMap<cam_cds_mode_type_t>
+ QCameraParameters::CDS_MODES_MAP[] = {
{ CDS_MODE_OFF, CAM_CDS_MODE_OFF },
{ CDS_MODE_ON, CAM_CDS_MODE_ON },
{ CDS_MODE_AUTO, CAM_CDS_MODE_AUTO}
@@ -641,6 +665,7 @@
#define DATA_PTR(MEM_OBJ,INDEX) MEM_OBJ->getPtr( INDEX )
#define MIN_PP_BUF_CNT 1
#define TOTAL_RAM_SIZE_512MB 536870912
+#define PARAM_MAP_SIZE(MAP) (sizeof(MAP)/sizeof(MAP[0]))
/*===========================================================================
@@ -840,7 +865,7 @@
*
* RETURN : string obj
*==========================================================================*/
-String8 QCameraParameters::createSizesString(const cam_dimension_t *sizes, int len)
+String8 QCameraParameters::createSizesString(const cam_dimension_t *sizes, size_t len)
{
String8 str;
char buffer[32];
@@ -849,8 +874,9 @@
snprintf(buffer, sizeof(buffer), "%dx%d", sizes[0].width, sizes[0].height);
str.append(buffer);
}
- for (int i = 1; i < len; i++) {
- snprintf(buffer, sizeof(buffer), ",%dx%d", sizes[i].width, sizes[i].height);
+ for (size_t i = 1; i < len; i++) {
+ snprintf(buffer, sizeof(buffer), ",%dx%d",
+ sizes[i].width, sizes[i].height);
str.append(buffer);
}
return str;
@@ -870,16 +896,14 @@
*
* RETURN : string obj
*==========================================================================*/
-String8 QCameraParameters::createValuesString(const int *values,
- int len,
- const QCameraMap* map,
- int map_len)
+template <typename valuesType, class mapType> String8 createValuesString(
+ const valuesType *values, size_t len, const mapType *map, size_t map_len)
{
String8 str;
int count = 0;
- for (int i = 0; i < len; i++ ) {
- for (int j = 0; j < map_len; j ++)
+ for (size_t i = 0; i < len; i++ ) {
+ for (size_t j = 0; j < map_len; j ++)
if (map[j].val == values[i]) {
if (NULL != map[j].desc) {
if (count > 0) {
@@ -905,12 +929,12 @@
*
* RETURN : string obj
*==========================================================================*/
-String8 QCameraParameters::createValuesStringFromMap(const QCameraMap* map,
- int map_len)
+template <class mapType> String8 createValuesStringFromMap(
+ const mapType *map, size_t map_len)
{
String8 str;
- for (int i = 0; i < map_len; i++) {
+ for (size_t i = 0; i < map_len; i++) {
if (NULL != map[i].desc) {
if (i > 0) {
str.append(",");
@@ -933,7 +957,7 @@
* RETURN : string obj
*==========================================================================*/
String8 QCameraParameters::createZoomRatioValuesString(uint32_t *zoomRatios,
- size_t length)
+ size_t length)
{
String8 str;
char buffer[32] = {0};
@@ -965,17 +989,14 @@
*
* RETURN : string obj
*==========================================================================*/
-String8 QCameraParameters::createHfrValuesString(
- const cam_hfr_info_t *values,
- int len,
- const QCameraMap* map,
- int map_len)
+String8 QCameraParameters::createHfrValuesString(const cam_hfr_info_t *values,
+ size_t len, const QCameraMap<cam_hfr_mode_t> *map, size_t map_len)
{
String8 str;
int count = 0;
- for (int i = 0; i < len; i++ ) {
- for (int j = 0; j < map_len; j ++)
+ for (size_t i = 0; i < len; i++ ) {
+ for (size_t j = 0; j < map_len; j ++)
if (map[j].val == (int)values[i].mode) {
if (NULL != map[j].desc) {
if (count > 0) {
@@ -1005,9 +1026,7 @@
*
* RETURN : string obj
*==========================================================================*/
-String8 QCameraParameters::createHfrSizesString(
- const cam_hfr_info_t *values,
- int len)
+String8 QCameraParameters::createHfrSizesString(const cam_hfr_info_t *values, size_t len)
{
String8 str;
char buffer[32];
@@ -1017,7 +1036,7 @@
values[0].dim.width, values[0].dim.height);
str.append(buffer);
}
- for (int i = 1; i < len; i++) {
+ for (size_t i = 1; i < len; i++) {
snprintf(buffer, sizeof(buffer), ",%dx%d",
values[i].dim.width, values[i].dim.height);
str.append(buffer);
@@ -1075,8 +1094,7 @@
* RETURN : string obj
*==========================================================================*/
String8 QCameraParameters::createFpsRangeString(const cam_fps_range_t* fps,
- int len,
- int &default_fps_index)
+ size_t len, int &default_fps_index)
{
String8 str;
char buffer[32];
@@ -1091,12 +1109,12 @@
snprintf(buffer, sizeof(buffer), "(%d,%d)", min_fps, max_fps);
str.append(buffer);
}
- for (int i = 1; i < len; i++) {
+ for (size_t i = 1; i < len; i++) {
min_fps = int(fps[i].min_fps * 1000);
max_fps = int(fps[i].max_fps * 1000);
if (max_range < (max_fps - min_fps)) {
max_range = max_fps - min_fps;
- default_fps_index = i;
+ default_fps_index = (int)i;
}
snprintf(buffer, sizeof(buffer), ",(%d,%d)", min_fps, max_fps);
str.append(buffer);
@@ -1117,10 +1135,11 @@
* RETURN : valid value if found
* NAME_NOT_FOUND if not found
*==========================================================================*/
-int QCameraParameters::lookupAttr(const QCameraMap arr[], int len, const char *name)
+template <class mapType> int lookupAttr(const mapType *arr,
+ size_t len, const char *name)
{
if (name) {
- for (int i = 0; i < len; i++) {
+ for (size_t i = 0; i < len; i++) {
if (!strcmp(arr[i].desc, name))
return arr[i].val;
}
@@ -1140,9 +1159,10 @@
*
* RETURN : name str or NULL if not found
*==========================================================================*/
-const char *QCameraParameters::lookupNameByValue(const QCameraMap arr[], int len, int value)
+template <class mapType> const char *lookupNameByValue(const mapType *arr,
+ size_t len, int value)
{
- for (int i = 0; i < len; i++) {
+ for (size_t i = 0; i < len; i++) {
if (arr[i].val == value) {
return arr[i].desc;
}
@@ -1318,45 +1338,43 @@
// use picture size from user setting
params.getPictureSize(&m_LiveSnapshotSize.width, &m_LiveSnapshotSize.height);
- uint8_t livesnapshot_sizes_tbl_cnt = m_pCapability->livesnapshot_sizes_tbl_cnt;
- cam_dimension_t *livesnapshot_sizes_tbl = &m_pCapability->livesnapshot_sizes_tbl[0];
+ size_t livesnapshot_sizes_tbl_cnt =
+ m_pCapability->livesnapshot_sizes_tbl_cnt;
+ cam_dimension_t *livesnapshot_sizes_tbl =
+ &m_pCapability->livesnapshot_sizes_tbl[0];
// check if HFR is enabled
const char *hfrStr = params.get(KEY_QC_VIDEO_HIGH_FRAME_RATE);
cam_hfr_mode_t hfrMode = CAM_HFR_MODE_OFF;
const char *hsrStr = params.get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING);
- if (hsrStr != NULL && strcmp(hsrStr, "off")) {
- int32_t value = lookupAttr(HFR_MODES_MAP,
- sizeof(HFR_MODES_MAP)/sizeof(QCameraMap),
- hsrStr);
- for (size_t i = 0; i < m_pCapability->hfr_tbl_cnt; i++) {
- if (m_pCapability->hfr_tbl[i].mode == value) {
- livesnapshot_sizes_tbl_cnt =
- m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl_cnt;
- livesnapshot_sizes_tbl =
- &m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl[0];
- hfrMode = m_pCapability->hfr_tbl[i].mode;
- break;
+ if ((hsrStr != NULL) && strcmp(hsrStr, "off")) {
+ int32_t value = lookupAttr(HFR_MODES_MAP, PARAM_MAP_SIZE(HFR_MODES_MAP), hsrStr);
+ if ((value != NAME_NOT_FOUND) && (value > CAM_HFR_MODE_OFF)) {
+ // if HSR is enabled, change live snapshot size
+ for (size_t i = 0; i < m_pCapability->hfr_tbl_cnt; i++) {
+ if (m_pCapability->hfr_tbl[i].mode == value) {
+ livesnapshot_sizes_tbl_cnt =
+ m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl_cnt;
+ livesnapshot_sizes_tbl =
+ &m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl[0];
+ hfrMode = m_pCapability->hfr_tbl[i].mode;
+ break;
+ }
}
}
- }
- else if (hfrStr != NULL && strcmp(hfrStr, "off")) {
- int32_t value = lookupAttr(HFR_MODES_MAP,
- sizeof(HFR_MODES_MAP)/sizeof(QCameraMap),
- hfrStr);
- if (value != NAME_NOT_FOUND) {
+ } else if ((hfrStr != NULL) && strcmp(hfrStr, "off")) {
+ int32_t value = lookupAttr(HFR_MODES_MAP, PARAM_MAP_SIZE(HFR_MODES_MAP), hfrStr);
+ if ((value != NAME_NOT_FOUND) && (value > CAM_HFR_MODE_OFF)) {
// if HFR is enabled, change live snapshot size
- if (value > CAM_HFR_MODE_OFF) {
- for (size_t i = 0; i < m_pCapability->hfr_tbl_cnt; i++) {
- if (m_pCapability->hfr_tbl[i].mode == value) {
- livesnapshot_sizes_tbl_cnt =
+ for (size_t i = 0; i < m_pCapability->hfr_tbl_cnt; i++) {
+ if (m_pCapability->hfr_tbl[i].mode == value) {
+ livesnapshot_sizes_tbl_cnt =
m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl_cnt;
- livesnapshot_sizes_tbl =
+ livesnapshot_sizes_tbl =
&m_pCapability->hfr_tbl[i].livesnapshot_sizes_tbl[0];
- hfrMode = m_pCapability->hfr_tbl[i].mode;
- break;
- }
+ hfrMode = m_pCapability->hfr_tbl[i].mode;
+ break;
}
}
}
@@ -1366,7 +1384,7 @@
bool found = false;
// first check if picture size is within the list of supported sizes
- for (int i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) {
+ for (size_t i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) {
if (m_LiveSnapshotSize.width == livesnapshot_sizes_tbl[i].width &&
m_LiveSnapshotSize.height == livesnapshot_sizes_tbl[i].height) {
found = true;
@@ -1381,7 +1399,7 @@
params.getPreviewSize(&width, &height);
double previewAspectRatio = (double)width / height;
- for (int i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) {
+ for (size_t i = 0; i < livesnapshot_sizes_tbl_cnt; ++i) {
double ratio = (double)livesnapshot_sizes_tbl[i].width /
livesnapshot_sizes_tbl[i].height;
if (fabs(previewAspectRatio - ratio) <= ASPECT_TOLERANCE) {
@@ -1409,7 +1427,6 @@
return NO_ERROR;
}
-
/*===========================================================================
* FUNCTION : setRawSize
*
@@ -1442,10 +1459,8 @@
int32_t QCameraParameters::setPreviewFormat(const QCameraParameters& params)
{
const char *str = params.getPreviewFormat();
- int32_t previewFormat =
- lookupAttr(PREVIEW_FORMATS_MAP,
- sizeof(PREVIEW_FORMATS_MAP) / sizeof(QCameraMap),
- str);
+ int32_t previewFormat = lookupAttr(PREVIEW_FORMATS_MAP,
+ PARAM_MAP_SIZE(PREVIEW_FORMATS_MAP), str);
if (previewFormat != NAME_NOT_FOUND) {
mPreviewFormat = (cam_format_t)previewFormat;
@@ -1472,10 +1487,7 @@
int32_t QCameraParameters::setPictureFormat(const QCameraParameters& params)
{
const char *str = params.getPictureFormat();
- int32_t pictureFormat =
- lookupAttr(PICTURE_TYPES_MAP,
- sizeof(PICTURE_TYPES_MAP) / sizeof(QCameraMap),
- str);
+ int32_t pictureFormat = lookupAttr(PICTURE_TYPES_MAP, PARAM_MAP_SIZE(PICTURE_TYPES_MAP), str);
if (pictureFormat != NAME_NOT_FOUND) {
mPictureFormat = pictureFormat;
@@ -1506,7 +1518,7 @@
CDBG("requested jpeg thumbnail size %d x %d", width, height);
- int sizes_cnt = sizeof(THUMBNAIL_SIZES_MAP) / sizeof(cam_dimension_t);
+ size_t sizes_cnt = PARAM_MAP_SIZE(THUMBNAIL_SIZES_MAP);
cam_dimension_t dim;
@@ -1535,7 +1547,7 @@
// just honor setting supplied by application.
// Try to find a size matches aspect ratio and has the largest width
- for (int i = 0; i < sizes_cnt; i++) {
+ for (size_t i = 0; i < sizes_cnt; i++) {
if (THUMBNAIL_SIZES_MAP[i].height == 0) {
// No thumbnail case, just skip
continue;
@@ -1554,7 +1566,7 @@
if ((0 == optimalWidth) || (0 == optimalHeight)) {
// Optimal size not found
// Validate thumbnail size
- for (int i = 0; i < sizes_cnt; i++) {
+ for (size_t i = 0; i < sizes_cnt; i++) {
if (width == THUMBNAIL_SIZES_MAP[i].width &&
height == THUMBNAIL_SIZES_MAP[i].height) {
optimalWidth = width;
@@ -1691,12 +1703,12 @@
if(updateNeeded) {
m_bNeedRestart = true;
rc = setHighFrameRate(mHfrMode);
- if(rc != NO_ERROR) goto end;
+ if (rc != NO_ERROR) goto end;
}
CDBG("%s: UpdateHFRFrameRate %d", __func__, updateNeeded);
- vidMinFps = m_hfrFpsRange.video_min_fps;
- vidMaxFps = m_hfrFpsRange.video_max_fps;
+ vidMinFps = (int)m_hfrFpsRange.video_min_fps;
+ vidMaxFps = (int)m_hfrFpsRange.video_max_fps;
if(minFps == prevMinFps && maxFps == prevMaxFps) {
if ( m_bFixedFrameRateSet ) {
@@ -1712,22 +1724,22 @@
for(size_t i = 0; i < m_pCapability->fps_ranges_tbl_cnt; i++) {
// if the value is in the supported list
- if(minFps >= m_pCapability->fps_ranges_tbl[i].min_fps * 1000 &&
- maxFps <= m_pCapability->fps_ranges_tbl[i].max_fps * 1000) {
+ if (minFps >= m_pCapability->fps_ranges_tbl[i].min_fps * 1000 &&
+ maxFps <= m_pCapability->fps_ranges_tbl[i].max_fps * 1000) {
found = true;
CDBG_HIGH("%s: FPS i=%d : minFps = %d, maxFps = %d"
" vidMinFps = %d, vidMaxFps = %d",
__func__, i, minFps, maxFps,
(int)m_hfrFpsRange.video_min_fps,
(int)m_hfrFpsRange.video_max_fps);
- if ((m_hfrFpsRange.video_min_fps == 0) ||
- (m_hfrFpsRange.video_max_fps == 0)) {
+ if ((0.0f >= m_hfrFpsRange.video_min_fps) ||
+ (0.0f >= m_hfrFpsRange.video_max_fps)) {
vidMinFps = minFps;
vidMaxFps = maxFps;
}
else {
- vidMinFps = m_hfrFpsRange.video_min_fps;
- vidMaxFps = m_hfrFpsRange.video_max_fps;
+ vidMinFps = (int)m_hfrFpsRange.video_min_fps;
+ vidMaxFps = (int)m_hfrFpsRange.video_max_fps;
}
setPreviewFpsRange(minFps, maxFps, vidMinFps, vidMaxFps);
@@ -1776,9 +1788,9 @@
const char *prev_hfrStr = CameraParameters::get(KEY_QC_VIDEO_HIGH_FRAME_RATE);
const char *prev_hsrStr = CameraParameters::get(KEY_QC_VIDEO_HIGH_SPEED_RECORDING);
- if ((hfrStr != NULL) && (prev_hfrStr != NULL) && strcmp(hfrStr, prev_hfrStr)) {
- updateParamEntry(KEY_QC_VIDEO_HIGH_FRAME_RATE, hfrStr);
- }
+ if ((hfrStr != NULL) && (prev_hfrStr != NULL) && strcmp(hfrStr, prev_hfrStr)) {
+ updateParamEntry(KEY_QC_VIDEO_HIGH_FRAME_RATE, hfrStr);
+ }
if ((hsrStr != NULL) && (prev_hsrStr != NULL) && strcmp(hsrStr, prev_hsrStr)) {
updateParamEntry(KEY_QC_VIDEO_HIGH_SPEED_RECORDING, hsrStr);
@@ -1786,17 +1798,13 @@
}
// check if HFR is enabled
- if(hfrStr != NULL && strcmp(hfrStr, "off")){
- hfrMode = lookupAttr(HFR_MODES_MAP,
- sizeof(HFR_MODES_MAP)/sizeof(QCameraMap),
- hfrStr);
+ if ((hfrStr != NULL) && strcmp(hfrStr, "off")) {
+ hfrMode = lookupAttr(HFR_MODES_MAP, PARAM_MAP_SIZE(HFR_MODES_MAP), hfrStr);
if(NAME_NOT_FOUND != hfrMode) newHfrMode = hfrMode;
}
// check if HSR is enabled
- else if(hsrStr != NULL && strcmp(hsrStr, "off")){
- hfrMode = lookupAttr(HFR_MODES_MAP,
- sizeof(HFR_MODES_MAP)/sizeof(QCameraMap),
- hsrStr);
+ else if ((hsrStr != NULL) && strcmp(hsrStr, "off")) {
+ hfrMode = lookupAttr(HFR_MODES_MAP, PARAM_MAP_SIZE(HFR_MODES_MAP), hsrStr);
if(NAME_NOT_FOUND != hfrMode) newHfrMode = hfrMode;
}
CDBG("%s: prevHfrMode - %d, currentHfrMode = %d ",
@@ -1829,8 +1837,8 @@
max_fps = 0;
break;
}
- m_hfrFpsRange.video_min_fps = min_fps;
- m_hfrFpsRange.video_max_fps = max_fps;
+ m_hfrFpsRange.video_min_fps = (float)min_fps;
+ m_hfrFpsRange.video_max_fps = (float)max_fps;
CDBG_HIGH("%s: HFR mode (%d) Set video FPS : minFps = %d, maxFps = %d ",
__func__, mHfrMode, min_fps, max_fps);
@@ -2584,7 +2592,7 @@
if (str != NULL) {
if (prev_str == NULL ||
strcmp(str, prev_str) != 0) {
- int maxFaces = params.getInt(KEY_QC_MAX_NUM_REQUESTED_FACES);
+ uint32_t maxFaces = (uint32_t)params.getInt(KEY_QC_MAX_NUM_REQUESTED_FACES);
return setFaceRecognition(str, maxFaces);
}
}
@@ -2612,8 +2620,7 @@
}
int zoomLevel = params.getInt(KEY_ZOOM);
- if((zoomLevel < 0) ||
- (zoomLevel >= (int)m_pCapability->zoom_ratio_tbl_cnt)) {
+ if ((zoomLevel < 0) || (zoomLevel >= (int)m_pCapability->zoom_ratio_tbl_cnt)) {
ALOGE("%s: invalid value %d out of (%d, %d)",
__func__, zoomLevel,
0, m_pCapability->zoom_ratio_tbl_cnt-1);
@@ -2860,8 +2867,7 @@
const char *str = get(KEY_QC_AUTO_HDR_ENABLE);
if (str != NULL) {
int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
- sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
- str);
+ PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), str);
if (value == NAME_NOT_FOUND) {
ALOGE("%s: Invalid Auto HDR value %s", __func__, str);
return false;
@@ -3221,8 +3227,7 @@
{
if(multiTouchFocusStr != NULL) {
int value = lookupAttr(MULTI_TOUCH_FOCUS_MODES_MAP,
- sizeof(MULTI_TOUCH_FOCUS_MODES_MAP)/sizeof(QCameraMap),
- multiTouchFocusStr);
+ PARAM_MAP_SIZE(MULTI_TOUCH_FOCUS_MODES_MAP), multiTouchFocusStr);
if(value != NAME_NOT_FOUND) {
m_bMultiTouchFocusOn = (value != 0);
if (!m_bMultiTouchFocusOn) {
@@ -3284,8 +3289,7 @@
{
if (touchAfAecStr != NULL) {
int value = lookupAttr(TOUCH_AF_AEC_MODES_MAP,
- sizeof(TOUCH_AF_AEC_MODES_MAP)/sizeof(QCameraMap),
- touchAfAecStr);
+ PARAM_MAP_SIZE(TOUCH_AF_AEC_MODES_MAP), touchAfAecStr);
if (value != NAME_NOT_FOUND) {
m_bTouchFocusOn = (value != 0);
updateParamEntry(KEY_QC_TOUCH_AF_AEC, touchAfAecStr);
@@ -3642,13 +3646,12 @@
int32_t QCameraParameters::setNumOfSnapshot()
{
int nBurstNum = getBurstNum();
- uint8_t nExpnum = 0;
+ int nExpnum = 0;
const char *bracket_str = get(KEY_QC_AE_BRACKET_HDR);
if (bracket_str != NULL && strlen(bracket_str) > 0) {
- int value = lookupAttr(BRACKETING_MODES_MAP,
- sizeof(BRACKETING_MODES_MAP)/sizeof(QCameraMap),
- bracket_str);
+ int value = lookupAttr(BRACKETING_MODES_MAP, PARAM_MAP_SIZE(BRACKETING_MODES_MAP),
+ bracket_str);
switch (value) {
case CAM_EXP_BRACKETING_ON:
{
@@ -3699,9 +3702,8 @@
const char *prev_str = get(KEY_RECORDING_HINT);
if (str != NULL) {
if (prev_str == NULL || strcmp(str, prev_str) != 0) {
- int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP,
- sizeof(TRUE_FALSE_MODES_MAP)/sizeof(QCameraMap),
- str);
+ int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP),
+ str);
if(value != NAME_NOT_FOUND){
updateParamEntry(KEY_RECORDING_HINT, str);
setRecordingHintValue(value);
@@ -3763,9 +3765,8 @@
if (str_val != NULL) {
if (prev_val == NULL || strcmp(str_val, prev_val) != 0) {
- int32_t value = lookupAttr(ON_OFF_MODES_MAP,
- sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap),
- str_val);
+ int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP),
+ str_val);
if (value != NAME_NOT_FOUND) {
set(KEY_QC_ZSL, str_val);
m_bZslMode_new = (value > 0)? true : false;
@@ -3802,10 +3803,8 @@
int32_t QCameraParameters::setWaveletDenoise(const QCameraParameters& params)
{
const char *str_pf = params.getPictureFormat();
- int32_t pictureFormat =
- lookupAttr(PICTURE_TYPES_MAP,
- sizeof(PICTURE_TYPES_MAP) / sizeof(QCameraMap),
- str_pf);
+ int32_t pictureFormat = lookupAttr(PICTURE_TYPES_MAP, PARAM_MAP_SIZE(PICTURE_TYPES_MAP),
+ str_pf);
if (pictureFormat != NAME_NOT_FOUND) {
if (CAM_FORMAT_YUV_422_NV16 == pictureFormat) {
ALOGE("NV16 format isn't supported in denoise lib!");
@@ -3917,9 +3916,7 @@
const char *prev_val = get(KEY_QC_PREVIEW_FLIP);
if(str != NULL){
if (prev_val == NULL || strcmp(str, prev_val) != 0) {
- int32_t value = lookupAttr(FLIP_MODES_MAP,
- sizeof(FLIP_MODES_MAP)/sizeof(QCameraMap),
- str);
+ int32_t value = lookupAttr(FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP), str);
if(value != NAME_NOT_FOUND){
set(KEY_QC_PREVIEW_FLIP, str);
m_bPreviewFlipChanged = true;
@@ -3932,9 +3929,7 @@
prev_val = get(KEY_QC_VIDEO_FLIP);
if(str != NULL){
if (prev_val == NULL || strcmp(str, prev_val) != 0) {
- int32_t value = lookupAttr(FLIP_MODES_MAP,
- sizeof(FLIP_MODES_MAP)/sizeof(QCameraMap),
- str);
+ int32_t value = lookupAttr(FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP), str);
if(value != NAME_NOT_FOUND){
set(KEY_QC_VIDEO_FLIP, str);
m_bVideoFlipChanged = true;
@@ -3947,9 +3942,7 @@
prev_val = get(KEY_QC_SNAPSHOT_PICTURE_FLIP);
if(str != NULL){
if (prev_val == NULL || strcmp(str, prev_val) != 0) {
- int32_t value = lookupAttr(FLIP_MODES_MAP,
- sizeof(FLIP_MODES_MAP)/sizeof(QCameraMap),
- str);
+ int32_t value = lookupAttr(FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP), str);
if(value != NAME_NOT_FOUND){
set(KEY_QC_SNAPSHOT_PICTURE_FLIP, str);
m_bSnapshotFlipChanged = true;
@@ -3992,7 +3985,7 @@
} else {
set(KEY_QC_SNAPSHOT_BURST_NUM, nBurstNum);
}
- m_nBurstNum = nBurstNum;
+ m_nBurstNum = (uint8_t)nBurstNum;
return NO_ERROR;
}
@@ -4039,7 +4032,7 @@
{
char value [PROPERTY_VALUE_MAX];
property_get("persist.camera.mobicat", value, "0");
- uint32_t enableMobi = atoi(value);
+ uint32_t enableMobi = (uint32_t) atoi(value);
int32_t ret = NO_ERROR;;
if (enableMobi) {
@@ -4069,7 +4062,7 @@
CAM_INTF_PARM_AF_MOBICAT_CMD,
sizeof(enableMobi),
&enableMobi);
- m_bMobiMask = enableMobi;
+ m_bMobiMask = (uint8_t)enableMobi;
return ret;
}
@@ -4121,7 +4114,7 @@
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::updateParameters(QCameraParameters& params,
- bool &needRestart)
+ bool &needRestart)
{
int32_t final_rc = NO_ERROR;
int32_t rc;
@@ -4268,7 +4261,7 @@
set(KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED,
m_pCapability->auto_wb_lock_supported? VALUE_TRUE : VALUE_FALSE);
set(KEY_QC_SUPPORTED_CAMERA_FEATURES,
- m_pCapability->qcom_supported_feature_mask);
+ (int)m_pCapability->qcom_supported_feature_mask);
set(KEY_MAX_NUM_DETECTED_FACES_HW, m_pCapability->max_num_roi);
set(KEY_MAX_NUM_DETECTED_FACES_SW, m_pCapability->max_num_roi);
set(KEY_QC_MAX_NUM_REQUESTED_FACES, m_pCapability->max_num_roi);
@@ -4350,7 +4343,7 @@
// Set supported thumbnail sizes
String8 thumbnailSizeValues = createSizesString(
THUMBNAIL_SIZES_MAP,
- sizeof(THUMBNAIL_SIZES_MAP)/sizeof(cam_dimension_t));
+ PARAM_MAP_SIZE(THUMBNAIL_SIZES_MAP));
set(KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, thumbnailSizeValues.string());
// Set default thumnail size
set(KEY_JPEG_THUMBNAIL_WIDTH, THUMBNAIL_SIZES_MAP[0].width);
@@ -4370,10 +4363,10 @@
// Set supported preview formats
String8 previewFormatValues = createValuesString(
- (int *)m_pCapability->supported_preview_fmts,
+ m_pCapability->supported_preview_fmts,
m_pCapability->supported_preview_fmt_cnt,
PREVIEW_FORMATS_MAP,
- sizeof(PREVIEW_FORMATS_MAP)/sizeof(QCameraMap));
+ PARAM_MAP_SIZE(PREVIEW_FORMATS_MAP));
set(KEY_SUPPORTED_PREVIEW_FORMATS, previewFormatValues.string());
// Set default preview format
CameraParameters::setPreviewFormat(PIXEL_FORMAT_YUV420SP);
@@ -4384,10 +4377,10 @@
// Set supported picture formats
String8 pictureTypeValues(PIXEL_FORMAT_JPEG);
String8 str = createValuesString(
- (int *)m_pCapability->supported_raw_fmts,
+ m_pCapability->supported_raw_fmts,
m_pCapability->supported_raw_fmt_cnt,
PICTURE_TYPES_MAP,
- sizeof(PICTURE_TYPES_MAP)/sizeof(QCameraMap));
+ PARAM_MAP_SIZE(PICTURE_TYPES_MAP));
if (str.string() != NULL) {
pictureTypeValues.append(",");
pictureTypeValues.append(str);
@@ -4436,16 +4429,16 @@
// Set supported focus modes
if (m_pCapability->supported_focus_modes_cnt > 0) {
String8 focusModeValues = createValuesString(
- (int *)m_pCapability->supported_focus_modes,
+ m_pCapability->supported_focus_modes,
m_pCapability->supported_focus_modes_cnt,
FOCUS_MODES_MAP,
- sizeof(FOCUS_MODES_MAP)/sizeof(QCameraMap));
+ PARAM_MAP_SIZE(FOCUS_MODES_MAP));
set(KEY_SUPPORTED_FOCUS_MODES, focusModeValues);
// Set default focus mode and update corresponding parameter buf
const char *focusMode = lookupNameByValue(FOCUS_MODES_MAP,
- sizeof(FOCUS_MODES_MAP)/sizeof(QCameraMap),
- m_pCapability->supported_focus_modes[0]);
+ PARAM_MAP_SIZE(FOCUS_MODES_MAP),
+ m_pCapability->supported_focus_modes[0]);
if (focusMode != NULL) {
setFocusMode(focusMode);
} else {
@@ -4516,10 +4509,10 @@
// Set Auto exposure
String8 autoExposureValues = createValuesString(
- (int *)m_pCapability->supported_aec_modes,
+ m_pCapability->supported_aec_modes,
m_pCapability->supported_aec_modes_cnt,
AUTO_EXPOSURE_MAP,
- sizeof(AUTO_EXPOSURE_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(AUTO_EXPOSURE_MAP));
set(KEY_QC_SUPPORTED_AUTO_EXPOSURE, autoExposureValues.string());
setAutoExposure(AUTO_EXPOSURE_FRAME_AVG);
@@ -4531,28 +4524,28 @@
// Set Antibanding
String8 antibandingValues = createValuesString(
- (int *)m_pCapability->supported_antibandings,
+ m_pCapability->supported_antibandings,
m_pCapability->supported_antibandings_cnt,
ANTIBANDING_MODES_MAP,
- sizeof(ANTIBANDING_MODES_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(ANTIBANDING_MODES_MAP));
set(KEY_SUPPORTED_ANTIBANDING, antibandingValues);
setAntibanding(ANTIBANDING_OFF);
// Set Effect
String8 effectValues = createValuesString(
- (int *)m_pCapability->supported_effects,
+ m_pCapability->supported_effects,
m_pCapability->supported_effects_cnt,
EFFECT_MODES_MAP,
- sizeof(EFFECT_MODES_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(EFFECT_MODES_MAP));
set(KEY_SUPPORTED_EFFECTS, effectValues);
setEffect(EFFECT_NONE);
// Set WhiteBalance
String8 whitebalanceValues = createValuesString(
- (int *)m_pCapability->supported_white_balances,
+ m_pCapability->supported_white_balances,
m_pCapability->supported_white_balances_cnt,
WHITE_BALANCE_MODES_MAP,
- sizeof(WHITE_BALANCE_MODES_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(WHITE_BALANCE_MODES_MAP));
set(KEY_SUPPORTED_WHITE_BALANCE, whitebalanceValues);
setWhiteBalance(WHITE_BALANCE_AUTO);
@@ -4565,10 +4558,10 @@
// Set Flash mode
if(m_pCapability->supported_flash_modes_cnt > 0) {
String8 flashValues = createValuesString(
- (int *)m_pCapability->supported_flash_modes,
+ m_pCapability->supported_flash_modes,
m_pCapability->supported_flash_modes_cnt,
FLASH_MODES_MAP,
- sizeof(FLASH_MODES_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(FLASH_MODES_MAP));
set(KEY_SUPPORTED_FLASH_MODES, flashValues);
setFlash(FLASH_MODE_OFF);
} else {
@@ -4577,19 +4570,19 @@
// Set Scene Mode
String8 sceneModeValues = createValuesString(
- (int *)m_pCapability->supported_scene_modes,
+ m_pCapability->supported_scene_modes,
m_pCapability->supported_scene_modes_cnt,
SCENE_MODES_MAP,
- sizeof(SCENE_MODES_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(SCENE_MODES_MAP));
set(KEY_SUPPORTED_SCENE_MODES, sceneModeValues);
setSceneMode(SCENE_MODE_AUTO);
// Set ISO Mode
String8 isoValues = createValuesString(
- (int *)m_pCapability->supported_iso_modes,
+ m_pCapability->supported_iso_modes,
m_pCapability->supported_iso_modes_cnt,
ISO_MODES_MAP,
- sizeof(ISO_MODES_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(ISO_MODES_MAP));
set(KEY_QC_SUPPORTED_ISO_MODES, isoValues);
setISOValue(ISO_AUTO);
@@ -4605,7 +4598,7 @@
m_pCapability->hfr_tbl,
m_pCapability->hfr_tbl_cnt,
HFR_MODES_MAP,
- sizeof(HFR_MODES_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(HFR_MODES_MAP));
set(KEY_QC_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES, hfrValues.string());
set(KEY_QC_VIDEO_HIGH_SPEED_RECORDING, "off");
set(KEY_QC_VIDEO_HIGH_FRAME_RATE, "off");
@@ -4617,10 +4610,10 @@
// Set Focus algorithms
String8 focusAlgoValues = createValuesString(
- (int *)m_pCapability->supported_focus_algos,
+ m_pCapability->supported_focus_algos,
m_pCapability->supported_focus_algos_cnt,
FOCUS_ALGO_MAP,
- sizeof(FOCUS_ALGO_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(FOCUS_ALGO_MAP));
set(KEY_QC_SUPPORTED_FOCUS_ALGOS, focusAlgoValues);
setSelectableZoneAf(FOCUS_ALGO_AUTO);
@@ -4630,7 +4623,7 @@
m_pCapability->zoom_ratio_tbl,
m_pCapability->zoom_ratio_tbl_cnt);
set(KEY_ZOOM_RATIOS, zoomRatioValues);
- set(KEY_MAX_ZOOM, m_pCapability->zoom_ratio_tbl_cnt - 1);
+ set(KEY_MAX_ZOOM, (int)(m_pCapability->zoom_ratio_tbl_cnt - 1));
setZoom(0);
}
@@ -4643,18 +4636,18 @@
}
String8 bracketingValues = createValuesStringFromMap(
BRACKETING_MODES_MAP,
- sizeof(BRACKETING_MODES_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(BRACKETING_MODES_MAP));
set(KEY_QC_SUPPORTED_AE_BRACKET_MODES, bracketingValues);
setAEBracket(AE_BRACKET_OFF);
//Set AF Bracketing.
- for(size_t i = 0; i < m_pCapability->supported_focus_modes_cnt; i++) {
+ for (size_t i = 0; i < m_pCapability->supported_focus_modes_cnt; i++) {
if ((CAM_FOCUS_MODE_AUTO == m_pCapability->supported_focus_modes[i]) &&
((m_pCapability->qcom_supported_feature_mask &
CAM_QCOM_FEATURE_UBIFOCUS) > 0)) {
String8 afBracketingValues = createValuesStringFromMap(
AF_BRACKETING_MODES_MAP,
- sizeof(AF_BRACKETING_MODES_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(AF_BRACKETING_MODES_MAP));
set(KEY_QC_SUPPORTED_AF_BRACKET_MODES, afBracketingValues);
setAFBracket(AF_BRACKET_OFF);
}
@@ -4666,7 +4659,7 @@
CAM_QCOM_FEATURE_CHROMA_FLASH) > 0) {
String8 chromaFlashValues = createValuesStringFromMap(
CHROMA_FLASH_MODES_MAP,
- sizeof(CHROMA_FLASH_MODES_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(CHROMA_FLASH_MODES_MAP));
set(KEY_QC_SUPPORTED_CHROMA_FLASH_MODES, chromaFlashValues);
setChromaFlash(CHROMA_FLASH_OFF);
}
@@ -4677,7 +4670,7 @@
CAM_QCOM_FEATURE_OPTIZOOM) > 0){
String8 optiZoomValues = createValuesStringFromMap(
OPTI_ZOOM_MODES_MAP,
- sizeof(OPTI_ZOOM_MODES_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(OPTI_ZOOM_MODES_MAP));
set(KEY_QC_SUPPORTED_OPTI_ZOOM_MODES, optiZoomValues);
setOptiZoom(OPTI_ZOOM_OFF);
}
@@ -4686,16 +4679,15 @@
if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_TRUEPORTRAIT) > 0) {
String8 truePortraitValues = createValuesStringFromMap(
TRUE_PORTRAIT_MODES_MAP,
- sizeof(TRUE_PORTRAIT_MODES_MAP) / sizeof(QCameraMap));
+ PARAM_MAP_SIZE(TRUE_PORTRAIT_MODES_MAP));
set(KEY_QC_SUPPORTED_TRUE_PORTRAIT_MODES, truePortraitValues);
}
//Set FSSR.
if ((m_pCapability->qcom_supported_feature_mask &
CAM_QCOM_FEATURE_FSSR) > 0) {
- String8 fssrValues = createValuesStringFromMap(
- FSSR_MODES_MAP,
- sizeof(FSSR_MODES_MAP) / sizeof(QCameraMap));
+ String8 fssrValues = createValuesStringFromMap(FSSR_MODES_MAP,
+ PARAM_MAP_SIZE(FSSR_MODES_MAP));
set(KEY_QC_SUPPORTED_FSSR_MODES, fssrValues);
setFssr(FSSR_OFF);
}
@@ -4703,9 +4695,8 @@
//Set Multi-touch Focus.
if ((m_pCapability->qcom_supported_feature_mask &
CAM_QCOM_FEATURE_MULTI_TOUCH_FOCUS) > 0){
- String8 multiTouchFocusValues = createValuesStringFromMap(
- MULTI_TOUCH_FOCUS_MODES_MAP,
- sizeof(MULTI_TOUCH_FOCUS_MODES_MAP) / sizeof(QCameraMap));
+ String8 multiTouchFocusValues = createValuesStringFromMap(MULTI_TOUCH_FOCUS_MODES_MAP,
+ PARAM_MAP_SIZE(MULTI_TOUCH_FOCUS_MODES_MAP));
set(KEY_QC_SUPPORTED_MULTI_TOUCH_FOCUS_MODES, multiTouchFocusValues);
setMultiTouchFocus(MULTI_TOUCH_FOCUS_OFF);
}
@@ -4713,7 +4704,7 @@
// Set Denoise
if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_DENOISE2D) > 0){
String8 denoiseValues = createValuesStringFromMap(
- DENOISE_ON_OFF_MODES_MAP, sizeof(DENOISE_ON_OFF_MODES_MAP) / sizeof(QCameraMap));
+ DENOISE_ON_OFF_MODES_MAP, PARAM_MAP_SIZE(DENOISE_ON_OFF_MODES_MAP));
set(KEY_QC_SUPPORTED_DENOISE, denoiseValues.string());
#ifdef DEFAULT_DENOISE_MODE_ON
setWaveletDenoise(DENOISE_ON);
@@ -4724,7 +4715,7 @@
// Set feature enable/disable
String8 enableDisableValues = createValuesStringFromMap(
- ENABLE_DISABLE_MODES_MAP, sizeof(ENABLE_DISABLE_MODES_MAP) / sizeof(QCameraMap));
+ ENABLE_DISABLE_MODES_MAP, PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP));
// Set Lens Shading
set(KEY_QC_SUPPORTED_LENSSHADE_MODES, enableDisableValues);
@@ -4752,7 +4743,7 @@
// Set feature on/off
String8 onOffValues = createValuesStringFromMap(
- ON_OFF_MODES_MAP, sizeof(ON_OFF_MODES_MAP) / sizeof(QCameraMap));
+ ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP));
//Set See more (LLVD)
if (m_pCapability->qcom_supported_feature_mask &
@@ -4822,7 +4813,7 @@
set(KEY_QC_VT_ENABLE, VALUE_DISABLE);
//Set Touch AF/AEC
String8 touchValues = createValuesStringFromMap(
- TOUCH_AF_AEC_MODES_MAP, sizeof(TOUCH_AF_AEC_MODES_MAP) / sizeof(QCameraMap));
+ TOUCH_AF_AEC_MODES_MAP, PARAM_MAP_SIZE(TOUCH_AF_AEC_MODES_MAP));
set(KEY_QC_SUPPORTED_TOUCH_AF_AEC, touchValues);
set(KEY_QC_TOUCH_AF_AEC, TOUCH_AF_AEC_OFF);
@@ -4830,7 +4821,7 @@
//set flip mode
if ((m_pCapability->qcom_supported_feature_mask & CAM_QCOM_FEATURE_FLIP) > 0) {
String8 flipModes = createValuesStringFromMap(
- FLIP_MODES_MAP, sizeof(FLIP_MODES_MAP) / sizeof(QCameraMap));
+ FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP));
set(KEY_QC_SUPPORTED_FLIP_MODES, flipModes);
set(KEY_QC_PREVIEW_FLIP, FLIP_MODE_OFF);
set(KEY_QC_VIDEO_FLIP, FLIP_MODE_OFF);
@@ -5157,11 +5148,10 @@
updateParamEntry(KEY_PREVIEW_FPS_RANGE, str);
cam_fps_range_t fps_range;
memset(&fps_range, 0x00, sizeof(cam_fps_range_t));
- fps_range.min_fps = min_fps / float (1000.0);
- fps_range.max_fps = max_fps / float (1000.0);
- fps_range.video_min_fps = vid_min_fps / float (1000.0);
- fps_range.video_max_fps = vid_max_fps / float (1000.0);
-
+ fps_range.min_fps = (float)min_fps / 1000.0f;
+ fps_range.max_fps = (float)max_fps / 1000.0f;
+ fps_range.video_min_fps = (float)vid_min_fps / 1000.0f;
+ fps_range.video_max_fps = (float)vid_max_fps / 1000.0f;
CDBG_HIGH("%s: Updated: minFps = %d, maxFps = %d ,"
" vid minFps = %d, vid maxFps = %d",
@@ -5197,9 +5187,7 @@
int32_t QCameraParameters::setAutoExposure(const char *autoExp)
{
if (autoExp != NULL) {
- int32_t value = lookupAttr(AUTO_EXPOSURE_MAP,
- sizeof(AUTO_EXPOSURE_MAP)/sizeof(AUTO_EXPOSURE_MAP[0]),
- autoExp);
+ int32_t value = lookupAttr(AUTO_EXPOSURE_MAP, PARAM_MAP_SIZE(AUTO_EXPOSURE_MAP), autoExp);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting auto exposure %s", __func__, autoExp);
updateParamEntry(KEY_QC_AUTO_EXPOSURE, autoExp);
@@ -5228,9 +5216,7 @@
int32_t QCameraParameters::setEffect(const char *effect)
{
if (effect != NULL) {
- int32_t value = lookupAttr(EFFECT_MODES_MAP,
- sizeof(EFFECT_MODES_MAP)/sizeof(QCameraMap),
- effect);
+ int32_t value = lookupAttr(EFFECT_MODES_MAP, PARAM_MAP_SIZE(EFFECT_MODES_MAP), effect);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting effect %s", __func__, effect);
updateParamEntry(KEY_EFFECT, effect);
@@ -5286,9 +5272,7 @@
{
int32_t rc;
if (focusMode != NULL) {
- int32_t value = lookupAttr(FOCUS_MODES_MAP,
- sizeof(FOCUS_MODES_MAP)/sizeof(QCameraMap),
- focusMode);
+ int32_t value = lookupAttr(FOCUS_MODES_MAP, PARAM_MAP_SIZE(FOCUS_MODES_MAP), focusMode);
if (value != NAME_NOT_FOUND) {
CDBG_HIGH("%s: Setting focus mode %s", __func__, focusMode);
mFocusMode = (cam_focus_mode_type)value;
@@ -5497,9 +5481,8 @@
int32_t QCameraParameters::setSceneDetect(const char *sceneDetect)
{
if (sceneDetect != NULL) {
- int32_t value = lookupAttr(ON_OFF_MODES_MAP,
- sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap),
- sceneDetect);
+ int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP),
+ sceneDetect);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting Scene Detect %s", __func__, sceneDetect);
updateParamEntry(KEY_QC_SCENE_DETECT, sceneDetect);
@@ -5529,9 +5512,8 @@
int32_t QCameraParameters::setSensorSnapshotHDR(const char *snapshotHDR)
{
if (snapshotHDR != NULL) {
- int32_t value = lookupAttr(ON_OFF_MODES_MAP,
- sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap),
- snapshotHDR);
+ int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP),
+ snapshotHDR);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting Sensor Snapshot HDR %s", __func__, snapshotHDR);
updateParamEntry(KEY_QC_SENSOR_HDR, snapshotHDR);
@@ -5563,9 +5545,7 @@
int32_t QCameraParameters::setVideoHDR(const char *videoHDR)
{
if (videoHDR != NULL) {
- int32_t value = lookupAttr(ON_OFF_MODES_MAP,
- sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap),
- videoHDR);
+ int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP), videoHDR);
if (value != NAME_NOT_FOUND) {
CDBG_HIGH("%s: Setting Video HDR %s", __func__, videoHDR);
updateParamEntry(KEY_QC_VIDEO_HDR, videoHDR);
@@ -5596,8 +5576,7 @@
{
if (vtEnable != NULL) {
int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
- sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
- vtEnable);
+ PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), vtEnable);
if (value != NAME_NOT_FOUND) {
CDBG_HIGH("%s: Setting Vt Enable %s", __func__, vtEnable);
m_bAVTimerEnabled = true;
@@ -5627,21 +5606,20 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int32_t QCameraParameters::setFaceRecognition(const char *faceRecog, int maxFaces)
+int32_t QCameraParameters::setFaceRecognition(const char *faceRecog,
+ uint32_t maxFaces)
{
if (faceRecog != NULL) {
- int32_t value = lookupAttr(ON_OFF_MODES_MAP,
- sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap),
- faceRecog);
+ int32_t value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP), faceRecog);
if (value != NAME_NOT_FOUND) {
CDBG_HIGH("%s: Setting face recognition %s", __func__, faceRecog);
updateParamEntry(KEY_QC_FACE_RECOGNITION, faceRecog);
- int faceProcMask = m_nFaceProcMask;
+ uint32_t faceProcMask = m_nFaceProcMask;
if (value > 0) {
faceProcMask |= CAM_FACE_PROCESS_MASK_RECOGNITION;
} else {
- faceProcMask &= ~CAM_FACE_PROCESS_MASK_RECOGNITION;
+ faceProcMask &= (uint32_t)(~CAM_FACE_PROCESS_MASK_RECOGNITION);
}
if(m_nFaceProcMask == faceProcMask) {
@@ -5718,9 +5696,7 @@
sizeof(continous_iso),
&continous_iso);
} else if (isoValue != NULL) {
- int32_t value = lookupAttr(ISO_MODES_MAP,
- sizeof(ISO_MODES_MAP)/sizeof(QCameraMap),
- isoValue);
+ int32_t value = lookupAttr(ISO_MODES_MAP, PARAM_MAP_SIZE(ISO_MODES_MAP), isoValue);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting ISO value %s", __func__, isoValue);
updateParamEntry(KEY_QC_ISO_MODE, isoValue);
@@ -5784,9 +5760,9 @@
*==========================================================================*/
int32_t QCameraParameters::getFlashValue()
{
- const char *flash_str = get(QCameraParameters::KEY_FLASH_MODE);
- int flash_index = lookupAttr(FLASH_MODES_MAP,
- sizeof(ISO_MODES_MAP)/sizeof(FLASH_MODES_MAP[0]), flash_str);
+ const char *flash_str = get(QCameraParameters::KEY_FLASH_MODE);
+ int32_t flash_index = lookupAttr(FLASH_MODES_MAP, PARAM_MAP_SIZE(FLASH_MODES_MAP),
+ flash_str);
return flash_index;
}
@@ -5830,8 +5806,8 @@
int32_t QCameraParameters::getRedEyeValue()
{
const char *redEye_str = get(QCameraParameters::KEY_QC_REDEYE_REDUCTION);
- int redEye = lookupAttr(ENABLE_DISABLE_MODES_MAP,
- sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap), redEye_str);
+ int32_t redEye = lookupAttr(ENABLE_DISABLE_MODES_MAP, PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP),
+ redEye_str);
return redEye;
}
@@ -5890,9 +5866,7 @@
int32_t QCameraParameters::setFlash(const char *flashStr)
{
if (flashStr != NULL) {
- int32_t value = lookupAttr(FLASH_MODES_MAP,
- sizeof(FLASH_MODES_MAP)/sizeof(QCameraMap),
- flashStr);
+ int32_t value = lookupAttr(FLASH_MODES_MAP, PARAM_MAP_SIZE(FLASH_MODES_MAP), flashStr);
if (value != NAME_NOT_FOUND) {
CDBG_HIGH("%s: Setting Flash value %s", __func__, flashStr);
@@ -5928,10 +5902,8 @@
int32_t QCameraParameters::setAecLock(const char *aecLockStr)
{
if (aecLockStr != NULL) {
- int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP,
- sizeof(TRUE_FALSE_MODES_MAP)/
- sizeof(QCameraMap),
- aecLockStr);
+ int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP),
+ aecLockStr);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting AECLock value %s", __func__, aecLockStr);
updateParamEntry(KEY_AUTO_EXPOSURE_LOCK, aecLockStr);
@@ -5961,9 +5933,8 @@
int32_t QCameraParameters::setAwbLock(const char *awbLockStr)
{
if (awbLockStr != NULL) {
- int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP,
- sizeof(TRUE_FALSE_MODES_MAP)/sizeof(QCameraMap),
- awbLockStr);
+ int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP),
+ awbLockStr);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting AWBLock value %s", __func__, awbLockStr);
updateParamEntry(KEY_AUTO_WHITEBALANCE_LOCK, awbLockStr);
@@ -5993,8 +5964,7 @@
{
if (mceStr != NULL) {
int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
- sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
- mceStr);
+ PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), mceStr);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting AWBLock value %s", __func__, mceStr);
updateParamEntry(KEY_QC_MEMORY_COLOR_ENHANCEMENT, mceStr);
@@ -6059,8 +6029,7 @@
{
if (tintStr != NULL) {
int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
- sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
- tintStr);
+ PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), tintStr);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting Tintless value %s", __func__, tintStr);
updateParamEntry(KEY_QC_TINTLESS_ENABLE, tintStr);
@@ -6092,31 +6061,30 @@
const char *prev_str = get(KEY_QC_CDS_MODE);
char *cds_mode_str = NULL;
int32_t rc = NO_ERROR;
+ char prop[PROPERTY_VALUE_MAX];
if (str) {
if (!prev_str || !strcmp(str, prev_str)) {
cds_mode_str = (char *)str;
}
} else {
- char prop[PROPERTY_VALUE_MAX];
memset(prop, 0, sizeof(prop));
- property_get("persist.camera.CDS", prop, VALUE_OFF);
+ property_get("persist.camera.CDS", prop, CDS_MODE_AUTO);
cds_mode_str = prop;
}
if (cds_mode_str) {
CDBG("%s: Set CDS mode = %s", __func__, cds_mode_str);
-
- int cds_mode = lookupAttr(CDS_MODES_MAP,
- sizeof(CDS_MODES_MAP) / sizeof(QCameraMap),
- cds_mode_str);
-
- rc = AddSetParmEntryToBatch(m_pParamBuf,
- CAM_INTF_PARM_CDS_MODE,
- sizeof(cds_mode),
- &cds_mode);
- if (rc != NO_ERROR) {
- ALOGE("%s:Failed CDS MODE to update table", __func__);
+ int32_t cds_mode = lookupAttr(CDS_MODES_MAP, PARAM_MAP_SIZE(CDS_MODES_MAP), cds_mode_str);
+ if (NAME_NOT_FOUND != cds_mode) {
+ rc = AddSetParmEntryToBatch(m_pParamBuf, CAM_INTF_PARM_CDS_MODE,
+ sizeof(cds_mode), &cds_mode);
+ if (rc != NO_ERROR) {
+ ALOGE("%s:Failed CDS MODE to update table", __func__);
+ }
+ } else {
+ ALOGE("%s: Invalid argument for CDS MODE %s", __func__, cds_mode_str);
+ rc = BAD_VALUE;
}
}
return rc;
@@ -6138,8 +6106,7 @@
{
if (disStr != NULL) {
int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
- sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
- disStr);
+ PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), disStr);
if (value != NAME_NOT_FOUND) {
//For some IS types (like EIS 2.0), when DIS value is changed, we need to restart
//preview because of topology change in backend. But, for now, restart preview
@@ -6200,8 +6167,7 @@
{
if (lensShadeStr != NULL) {
int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
- sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
- lensShadeStr);
+ PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), lensShadeStr);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting LensShade value %s", __func__, lensShadeStr);
updateParamEntry(KEY_QC_LENSSHADE, lensShadeStr);
@@ -6258,8 +6224,7 @@
{
if (wbStr != NULL) {
int32_t value = lookupAttr(WHITE_BALANCE_MODES_MAP,
- sizeof(WHITE_BALANCE_MODES_MAP)/sizeof(QCameraMap),
- wbStr);
+ PARAM_MAP_SIZE(WHITE_BALANCE_MODES_MAP), wbStr);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting WhiteBalance value %s", __func__, wbStr);
updateParamEntry(KEY_WHITE_BALANCE, wbStr);
@@ -6348,9 +6313,8 @@
int32_t QCameraParameters::setAntibanding(const char *antiBandingStr)
{
if (antiBandingStr != NULL) {
- int32_t value = lookupAttr(ANTIBANDING_MODES_MAP,
- sizeof(ANTIBANDING_MODES_MAP)/sizeof(QCameraMap),
- antiBandingStr);
+ int32_t value = lookupAttr(ANTIBANDING_MODES_MAP, PARAM_MAP_SIZE(ANTIBANDING_MODES_MAP),
+ antiBandingStr);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting AntiBanding value %s", __func__, antiBandingStr);
updateParamEntry(KEY_ANTIBANDING, antiBandingStr);
@@ -6427,17 +6391,26 @@
getPreviewSize(&previewWidth, &previewHeight);
cam_roi_info_t af_roi_value;
memset(&af_roi_value, 0, sizeof(cam_roi_info_t));
- af_roi_value.num_roi = num_areas_found;
+ af_roi_value.num_roi = (uint8_t)num_areas_found;
for (int i = 0; i < num_areas_found; i++) {
CDBG_HIGH("%s: FocusArea[%d] = (%d, %d, %d, %d)",
__func__, i, (areas[i].rect.top), (areas[i].rect.left),
(areas[i].rect.width), (areas[i].rect.height));
- //transform the coords from (-1000, 1000) to (0, previewWidth or previewHeight)
- af_roi_value.roi[i].left = (int32_t)((areas[i].rect.left + 1000.0f) * (previewWidth / 2000.0f));
- af_roi_value.roi[i].top = (int32_t)((areas[i].rect.top + 1000.0f) * (previewHeight / 2000.0f));
- af_roi_value.roi[i].width = (int32_t)(areas[i].rect.width * previewWidth / 2000.0f);
- af_roi_value.roi[i].height = (int32_t)(areas[i].rect.height * previewHeight / 2000.0f);
+ // Transform the coords from (-1000, 1000)
+ // to (0, previewWidth or previewHeight).
+ af_roi_value.roi[i].left =
+ (int32_t)(((double)areas[i].rect.left + 1000.0) *
+ ((double)previewWidth / 2000.0));
+ af_roi_value.roi[i].top =
+ (int32_t)(((double)areas[i].rect.top + 1000.0) *
+ ((double)previewHeight / 2000.0));
+ af_roi_value.roi[i].width =
+ (int32_t)((double)areas[i].rect.width *
+ (double)previewWidth / 2000.0);
+ af_roi_value.roi[i].height =
+ (int32_t)((double)areas[i].rect.height *
+ (double)previewHeight / 2000.0);
af_roi_value.weight[i] = areas[i].weight;
}
free(areas);
@@ -6515,11 +6488,16 @@
__func__, i, (areas[i].rect.top), (areas[i].rect.left),
(areas[i].rect.width), (areas[i].rect.height));
- //transform the coords from (-1000, 1000) to (0, previewWidth or previewHeight)
+ // Transform the coords from (-1000, 1000) to
+ // (0, previewWidth or previewHeight).
aec_roi_value.cam_aec_roi_position.coordinate[i].x =
- (uint32_t)(((areas[i].rect.left + areas[i].rect.width / 2) + 1000.0f) * previewWidth / 2000.0f) ;
+ (uint32_t)((((double)areas[i].rect.left +
+ (double)areas[i].rect.width / 2.0) + 1000.0) *
+ (double)previewWidth / 2000.0);
aec_roi_value.cam_aec_roi_position.coordinate[i].y =
- (uint32_t)(((areas[i].rect.top + areas[i].rect.height / 2) + 1000.0f) * previewHeight / 2000.0f) ;
+ (uint32_t)((((double)areas[i].rect.top +
+ (double)areas[i].rect.height / 2.0) + 1000.0) *
+ (double)previewHeight / 2000.0);
}
} else {
aec_roi_value.aec_roi_enable = CAM_AEC_ROI_OFF;
@@ -6546,9 +6524,7 @@
int32_t QCameraParameters::setSceneMode(const char *sceneModeStr)
{
if (sceneModeStr != NULL) {
- int32_t value = lookupAttr(SCENE_MODES_MAP,
- sizeof(SCENE_MODES_MAP)/sizeof(QCameraMap),
- sceneModeStr);
+ int32_t value = lookupAttr(SCENE_MODES_MAP, PARAM_MAP_SIZE(SCENE_MODES_MAP), sceneModeStr);
if (value != NAME_NOT_FOUND) {
CDBG_HIGH("%s: Setting SceneMode %s", __func__, sceneModeStr);
updateParamEntry(KEY_SCENE_MODE, sceneModeStr);
@@ -6584,9 +6560,7 @@
int32_t QCameraParameters::setSelectableZoneAf(const char *selZoneAFStr)
{
if (selZoneAFStr != NULL) {
- int32_t value = lookupAttr(FOCUS_ALGO_MAP,
- sizeof(FOCUS_ALGO_MAP)/sizeof(QCameraMap),
- selZoneAFStr);
+ int32_t value = lookupAttr(FOCUS_ALGO_MAP, PARAM_MAP_SIZE(FOCUS_ALGO_MAP), selZoneAFStr);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting Selectable Zone AF value %s", __func__, selZoneAFStr);
updateParamEntry(KEY_QC_SELECTABLE_ZONE_AF, selZoneAFStr);
@@ -6643,9 +6617,8 @@
cam_exp_bracketing_t expBracket;
memset(&expBracket, 0, sizeof(expBracket));
- int value = lookupAttr(BRACKETING_MODES_MAP,
- sizeof(BRACKETING_MODES_MAP)/sizeof(QCameraMap),
- aecBracketStr);
+ int value = lookupAttr(BRACKETING_MODES_MAP, PARAM_MAP_SIZE(BRACKETING_MODES_MAP),
+ aecBracketStr);
switch (value) {
case CAM_EXP_BRACKETING_ON:
{
@@ -6699,9 +6672,8 @@
{
int32_t rc = NO_ERROR;
if (lockStr != NULL) {
- int32_t value = lookupAttr(TRUE_FALSE_MODES_MAP,
- sizeof(TRUE_FALSE_MODES_MAP)/sizeof(QCameraMap),
- lockStr);
+ int value = lookupAttr(TRUE_FALSE_MODES_MAP, PARAM_MAP_SIZE(TRUE_FALSE_MODES_MAP),
+ lockStr);
if (value != NAME_NOT_FOUND) {
CDBG_HIGH("%s: Setting Lock lockStr =%s", __func__, lockStr);
if(initBatchUpdate(m_pParamBuf) < 0 ) {
@@ -6718,12 +6690,13 @@
focus_mode = CAM_FOCUS_MODE_FIXED;
}
} else {
- // retrieve previous focus value.
- const char *focus = get(KEY_FOCUS_MODE);
- focus_mode = lookupAttr(FOCUS_MODES_MAP,
- sizeof(FOCUS_MODES_MAP)/sizeof(QCameraMap),
- focus);
- CDBG("%s: focus mode %s", __func__, focus);
+ // retrieve previous focus value.
+ const char *focus = get(KEY_FOCUS_MODE);
+ int val = lookupAttr(FOCUS_MODES_MAP, PARAM_MAP_SIZE(FOCUS_MODES_MAP), focus);
+ if (val != NAME_NOT_FOUND) {
+ focus_mode = (int32_t) val;
+ CDBG("%s: focus mode %s", __func__, focus);
+ }
}
//Lock AWB
rc = AddSetParmEntryToBatch(m_pParamBuf,
@@ -6963,8 +6936,7 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int32_t QCameraParameters::commitFlashBracket(
- cam_flash_bracketing_t flashBracket)
+int32_t QCameraParameters::commitFlashBracket(cam_flash_bracketing_t flashBracket)
{
CDBG_HIGH("%s: E",__func__);
int32_t rc = NO_ERROR;
@@ -7008,10 +6980,8 @@
CDBG_HIGH("%s: afBracketStr =%s",__func__,afBracketStr);
if(afBracketStr != NULL) {
- int value = lookupAttr(AF_BRACKETING_MODES_MAP,
- sizeof(AF_BRACKETING_MODES_MAP)/
- sizeof(QCameraMap),
- afBracketStr);
+ int value = lookupAttr(AF_BRACKETING_MODES_MAP, PARAM_MAP_SIZE(AF_BRACKETING_MODES_MAP),
+ afBracketStr);
if (value != NAME_NOT_FOUND) {
m_bAFBracketingOn = (value != 0);
updateParamEntry(KEY_QC_AF_BRACKET, afBracketStr);
@@ -7041,9 +7011,8 @@
{
CDBG_HIGH("%s: chromaFlashStr =%s",__func__,chromaFlashStr);
if(chromaFlashStr != NULL) {
- int value = lookupAttr(CHROMA_FLASH_MODES_MAP,
- sizeof(CHROMA_FLASH_MODES_MAP)/sizeof(QCameraMap),
- chromaFlashStr);
+ int value = lookupAttr(CHROMA_FLASH_MODES_MAP, PARAM_MAP_SIZE(CHROMA_FLASH_MODES_MAP),
+ chromaFlashStr);
if(value != NAME_NOT_FOUND) {
m_bChromaFlashOn = (value != 0);
updateParamEntry(KEY_QC_CHROMA_FLASH, chromaFlashStr);
@@ -7073,9 +7042,8 @@
{
CDBG_HIGH("%s: optiZoomStr =%s",__func__,optiZoomStr);
if(optiZoomStr != NULL) {
- int value = lookupAttr(OPTI_ZOOM_MODES_MAP,
- sizeof(OPTI_ZOOM_MODES_MAP)/sizeof(QCameraMap),
- optiZoomStr);
+ int value = lookupAttr(OPTI_ZOOM_MODES_MAP, PARAM_MAP_SIZE(OPTI_ZOOM_MODES_MAP),
+ optiZoomStr);
if(value != NAME_NOT_FOUND) {
m_bOptiZoomOn = (value != 0);
updateParamEntry(KEY_QC_OPTI_ZOOM, optiZoomStr);
@@ -7102,19 +7070,17 @@
*==========================================================================*/
int32_t QCameraParameters::setFssr(const char *fssrStr)
{
- CDBG_HIGH("%s: fssrStr =%s",__func__,fssrStr);
- if(fssrStr != NULL) {
- int value = lookupAttr(FSSR_MODES_MAP,
- sizeof(FSSR_MODES_MAP)/sizeof(QCameraMap),
- fssrStr);
- if(value != NAME_NOT_FOUND) {
- m_bFssrOn = (value != 0);
- updateParamEntry(KEY_QC_FSSR, fssrStr);
- return NO_ERROR;
- }
+ if (fssrStr != NULL) {
+ CDBG_HIGH("%s: fssrStr = %s", __func__, fssrStr);
+ int value = lookupAttr(FSSR_MODES_MAP, PARAM_MAP_SIZE(FSSR_MODES_MAP), fssrStr);
+ if(value != NAME_NOT_FOUND) {
+ m_bFssrOn = (value != 0);
+ updateParamEntry(KEY_QC_FSSR, fssrStr);
+ return NO_ERROR;
+ }
}
- CDBG_HIGH("Invalid fssr value: %s",
- (fssrStr == NULL) ? "NULL" : fssrStr);
+
+ CDBG_HIGH("Invalid fssr value: %s", (fssrStr == NULL) ? "NULL" : fssrStr);
return BAD_VALUE;
}
@@ -7134,8 +7100,7 @@
{
CDBG_HIGH("%s: truePortraitStr =%s",__func__,truePortraitStr);
if(truePortraitStr != NULL) {
- int value = lookupAttr(TRUE_PORTRAIT_MODES_MAP,
- sizeof(TRUE_PORTRAIT_MODES_MAP)/sizeof(QCameraMap),
+ int value = lookupAttr(TRUE_PORTRAIT_MODES_MAP, PARAM_MAP_SIZE(TRUE_PORTRAIT_MODES_MAP),
truePortraitStr);
if(value != NAME_NOT_FOUND) {
m_bTruePortraitOn = (value != 0);
@@ -7164,9 +7129,7 @@
{
CDBG_HIGH("%s: seeMoreStr =%s",__func__,seeMoreStr);
if(seeMoreStr != NULL) {
- int value = lookupAttr(ON_OFF_MODES_MAP,
- sizeof(ON_OFF_MODES_MAP)/sizeof(QCameraMap),
- seeMoreStr);
+ int value = lookupAttr(ON_OFF_MODES_MAP, PARAM_MAP_SIZE(ON_OFF_MODES_MAP), seeMoreStr);
if(value != NAME_NOT_FOUND) {
m_bSeeMoreOn = (value != 0);
updateParamEntry(KEY_QC_SEE_MORE, seeMoreStr);
@@ -7352,8 +7315,7 @@
{
if (redeyeStr != NULL) {
int32_t value = lookupAttr(ENABLE_DISABLE_MODES_MAP,
- sizeof(ENABLE_DISABLE_MODES_MAP)/sizeof(QCameraMap),
- redeyeStr);
+ PARAM_MAP_SIZE(ENABLE_DISABLE_MODES_MAP), redeyeStr);
if (value != NAME_NOT_FOUND) {
CDBG("%s: Setting RedEye Reduce value %s", __func__, redeyeStr);
updateParamEntry(KEY_QC_REDEYE_REDUCTION, redeyeStr);
@@ -7425,15 +7387,14 @@
}
if (wnrStr != NULL) {
- int value = lookupAttr(DENOISE_ON_OFF_MODES_MAP,
- sizeof(DENOISE_ON_OFF_MODES_MAP)/sizeof(QCameraMap),
- wnrStr);
+ int value = lookupAttr(DENOISE_ON_OFF_MODES_MAP, PARAM_MAP_SIZE(DENOISE_ON_OFF_MODES_MAP),
+ wnrStr);
if (value != NAME_NOT_FOUND) {
updateParamEntry(KEY_QC_DENOISE, wnrStr);
cam_denoise_param_t temp;
memset(&temp, 0, sizeof(temp));
- temp.denoise_enable = value;
+ temp.denoise_enable = (uint8_t) value;
m_bWNROn = (value != 0);
if (m_bWNROn) {
temp.process_plates = getWaveletDenoiseProcessPlate();
@@ -7734,8 +7695,7 @@
if(str != NULL){
//Need give corresponding filp value based on flip mode strings
- int value = lookupAttr(FLIP_MODES_MAP,
- sizeof(FLIP_MODES_MAP)/sizeof(QCameraMap), str);
+ int value = lookupAttr(FLIP_MODES_MAP, PARAM_MAP_SIZE(FLIP_MODES_MAP), str);
if(value != NAME_NOT_FOUND)
flipMode = value;
}
@@ -7827,7 +7787,7 @@
getRawSize(dim);
break;
case CAM_STREAM_TYPE_METADATA:
- dim.width = sizeof(cam_metadata_info_t);
+ dim.width = (int32_t)sizeof(cam_metadata_info_t);
dim.height = 1;
break;
case CAM_STREAM_TYPE_OFFLINE_PROC:
@@ -7906,13 +7866,13 @@
*
* RETURN : ZSL burst interval value
*==========================================================================*/
-int QCameraParameters::getZSLBurstInterval()
+uint8_t QCameraParameters::getZSLBurstInterval()
{
int interval = getInt(KEY_QC_ZSL_BURST_INTERVAL);
if (interval < 0) {
interval = 1;
}
- return interval;
+ return (uint8_t)interval;
}
/*===========================================================================
@@ -7924,13 +7884,13 @@
*
* RETURN : ZSL queue depth value
*==========================================================================*/
-int QCameraParameters::getZSLQueueDepth()
+uint8_t QCameraParameters::getZSLQueueDepth()
{
int qdepth = getInt(KEY_QC_ZSL_QUEUE_DEPTH);
if (qdepth < 0) {
qdepth = 2;
}
- return qdepth;
+ return (uint8_t)qdepth;
}
/*===========================================================================
@@ -7942,13 +7902,13 @@
*
* RETURN : ZSL backlook count value
*==========================================================================*/
-int QCameraParameters::getZSLBackLookCount()
+uint8_t QCameraParameters::getZSLBackLookCount()
{
int look_back = getInt(KEY_QC_ZSL_BURST_LOOKBACK);
if (look_back < 0) {
look_back = 2;
}
- return look_back;
+ return (uint8_t)look_back;
}
/*===========================================================================
@@ -7960,9 +7920,9 @@
*
* RETURN : ZSL backlook count value
*==========================================================================*/
-int QCameraParameters::getMaxUnmatchedFramesInQueue()
+uint8_t QCameraParameters::getMaxUnmatchedFramesInQueue()
{
- return m_pCapability->min_num_pp_bufs + (m_nBurstNum / 10);
+ return (uint8_t)(m_pCapability->min_num_pp_bufs + (m_nBurstNum / 10));
}
/**
@@ -8039,17 +7999,18 @@
*==========================================================================*/
uint8_t QCameraParameters::getNumOfSnapshots()
{
- int numOfSnapshot = getInt(KEY_QC_NUM_SNAPSHOT_PER_SHUTTER);
- if (numOfSnapshot <= 0) {
- numOfSnapshot = 1; // set to default value
+ uint8_t numOfSnapshot = 1;
+ int val = getInt(KEY_QC_NUM_SNAPSHOT_PER_SHUTTER);
+ if (0 < val) {
+ numOfSnapshot = (uint8_t)val;
}
/* update the count for refocus */
if (isUbiRefocus()) {
- numOfSnapshot += UfOutputCount();
+ numOfSnapshot = (uint8_t) (numOfSnapshot + UfOutputCount());
}
- return (uint8_t)numOfSnapshot;
+ return numOfSnapshot;
}
/*===========================================================================
@@ -8063,7 +8024,7 @@
*==========================================================================*/
uint32_t QCameraParameters::MTFOutputCount()
{
- return m_currNumBufMTF+1;
+ return (uint32_t) (m_currNumBufMTF + 1);
}
/*===========================================================================
@@ -8077,7 +8038,7 @@
*==========================================================================*/
uint8_t QCameraParameters::getBurstCountForAdvancedCapture()
{
- int burstCount = 0;
+ uint32_t burstCount = 0;
if (isUbiFocusEnabled()) {
//number of snapshots required for Ubi Focus.
burstCount = m_pCapability->ubifocus_af_bracketing_need.burst_count;
@@ -8130,7 +8091,7 @@
*==========================================================================*/
uint8_t QCameraParameters::getNumOfExtraHDRInBufsIfNeeded()
{
- uint8_t numOfBufs = 0;
+ unsigned int numOfBufs = 0;
if (isHDREnabled()) {
numOfBufs += m_pCapability->hdr_bracketing_setting.num_frames;
@@ -8140,7 +8101,7 @@
numOfBufs--; // Only additional buffers need to be returned
}
- return numOfBufs * getBurstNum();
+ return (uint8_t)(numOfBufs * getBurstNum());
}
/*===========================================================================
@@ -8154,13 +8115,13 @@
*==========================================================================*/
uint8_t QCameraParameters::getNumOfExtraHDROutBufsIfNeeded()
{
- uint8_t numOfBufs = 0;
+ int numOfBufs = 0;
if (isHDREnabled() && isHDR1xFrameEnabled()) {
numOfBufs++;
}
- return numOfBufs * getBurstNum();
+ return (uint8_t)(numOfBufs * getBurstNum());
}
/*===========================================================================
@@ -8172,7 +8133,7 @@
*
* RETURN : number of burst
*==========================================================================*/
-int QCameraParameters::getBurstNum()
+uint8_t QCameraParameters::getBurstNum()
{
return m_nBurstNum;
}
@@ -8186,13 +8147,13 @@
*
* RETURN : jpeg encoding quality
*==========================================================================*/
-int QCameraParameters::getJpegQuality()
+uint32_t QCameraParameters::getJpegQuality()
{
int quality = getInt(KEY_JPEG_QUALITY);
if (quality < 0) {
quality = 85; // set to default quality value
}
- return quality;
+ return (uint32_t)quality;
}
@@ -8205,12 +8166,38 @@
*
* RETURN : rotation value
*==========================================================================*/
-int QCameraParameters::getJpegRotation() {
+uint32_t QCameraParameters::getJpegRotation() {
int rotation = getInt(KEY_ROTATION);
if (rotation < 0) {
rotation = 0;
}
- return rotation;
+ return (uint32_t)rotation;
+}
+
+/*===========================================================================
+ * FUNCTION : getEffectValue
+ *
+ * DESCRIPTION: get effect value
+ *
+ * PARAMETERS : none
+ *
+ * RETURN : effect value
+ *==========================================================================*/
+int32_t QCameraParameters::getEffectValue()
+{
+ uint32_t cnt = 0;
+ const char *effect = get(KEY_EFFECT);
+ if (effect) {
+ while (NULL != EFFECT_MODES_MAP[cnt].desc) {
+ if (!strcmp(EFFECT_MODES_MAP[cnt].desc, effect)) {
+ return EFFECT_MODES_MAP[cnt].val;
+ }
+ cnt++;
+ }
+ } else {
+ ALOGE("%s: Missing effect value", __func__);
+ }
+ return CAM_EFFECT_MODE_OFF;
}
/*===========================================================================
@@ -8232,16 +8219,16 @@
ALOGE("%s: error, invalid argument coord == NULL", __func__);
return BAD_VALUE;
}
- float degF = atof(coord_str);
+ double degF = atof(coord_str);
if (degF < 0) {
degF = -degF;
}
- float minF = (degF - (int) degF) * 60;
- float secF = (minF - (int) minF) * 60;
+ double minF = (degF - (double)(int) degF) * 60.0;
+ double secF = (minF - (double)(int) minF) * 60.0;
getRational(&coord[0], (int)degF, 1);
getRational(&coord[1], (int)minF, 1);
- getRational(&coord[2], (int)(secF * 10000), 10000);
+ getRational(&coord[2], (int)(secF * 10000.0), 10000);
return NO_ERROR;
}
@@ -8251,32 +8238,36 @@
* DESCRIPTION: query exif date time
*
* PARAMETERS :
- * @dateTime : string to store exif date time
- * @count : lenght of the dateTime string
+ * @dateTime : String to store exif date time.
+ * Should be leaved unchanged in case of error.
*
* RETURN : int32_t type of status
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int32_t QCameraParameters::getExifDateTime(char *dateTime, uint32_t &count)
+int32_t QCameraParameters::getExifDateTime(String8 &dateTime)
{
+ int32_t ret = NO_ERROR;
//get time and date from system
- time_t rawtime;
- struct tm * timeinfo = NULL;
- memset(&rawtime, 0, sizeof(rawtime));
- time(&rawtime);
- timeinfo = localtime (&rawtime);
- if (timeinfo != NULL && count >= 20) {
- //Write datetime according to EXIF Spec
- //"YYYY:MM:DD HH:MM:SS" (20 chars including \0)
- snprintf(dateTime, 20, "%04d:%02d:%02d %02d:%02d:%02d",
- timeinfo->tm_year + 1900, timeinfo->tm_mon + 1,
- timeinfo->tm_mday, timeinfo->tm_hour,
- timeinfo->tm_min, timeinfo->tm_sec);
- count = 20;
- return NO_ERROR;
+ time_t rawtime = time(NULL);
+ if (((time_t) 0) <= rawtime) {
+ struct tm *timeinfo = localtime (&rawtime);
+ if (NULL != timeinfo) {
+ //Write datetime according to EXIF Spec
+ //"YYYY:MM:DD HH:MM:SS" (20 chars including \0)
+ dateTime = String8::format("%04d:%02d:%02d %02d:%02d:%02d",
+ timeinfo->tm_year + 1900, timeinfo->tm_mon + 1,
+ timeinfo->tm_mday, timeinfo->tm_hour,
+ timeinfo->tm_min, timeinfo->tm_sec);
+ } else {
+ ALOGE("%s: localtime() error: %s", __func__, strerror(errno));
+ ret = UNKNOWN_ERROR;
+ }
+ } else {
+ ALOGE("%s: rawtime() error: %s", __func__, strerror(errno));
+ ret = UNKNOWN_ERROR;
}
- return UNKNOWN_ERROR;
+ return ret;
}
/*===========================================================================
@@ -8295,12 +8286,16 @@
*==========================================================================*/
int32_t QCameraParameters::getRational(rat_t *rat, int num, int denom)
{
+ if ((0 > num) || (0 > denom)) {
+ ALOGE("%s: Negative values", __func__);
+ return BAD_VALUE;
+ }
if (NULL == rat) {
ALOGE("%s: NULL rat input", __func__);
return BAD_VALUE;
}
- rat->num = num;
- rat->denom = denom;
+ rat->num = (uint32_t)num;
+ rat->denom = (uint32_t)denom;
return NO_ERROR;
}
@@ -8336,8 +8331,7 @@
{
uint16_t isoSpeed = 0;
const char *iso_str = get(QCameraParameters::KEY_QC_ISO_MODE);
- int iso_index = lookupAttr(ISO_MODES_MAP,
- sizeof(ISO_MODES_MAP)/sizeof(ISO_MODES_MAP[0]), iso_str);
+ int iso_index = lookupAttr(ISO_MODES_MAP, PARAM_MAP_SIZE(ISO_MODES_MAP), iso_str);
switch (iso_index) {
case CAM_ISO_MODE_AUTO:
isoSpeed = 0;
@@ -8388,7 +8382,7 @@
memcpy(gpsProcessingMethod, ExifAsciiPrefix, EXIF_ASCII_PREFIX_SIZE);
count = EXIF_ASCII_PREFIX_SIZE;
strncpy(gpsProcessingMethod + EXIF_ASCII_PREFIX_SIZE, str, strlen(str));
- count += strlen(str);
+ count += (uint32_t)strlen(str);
gpsProcessingMethod[count++] = '\0'; // increase 1 for the last NULL char
return NO_ERROR;
} else {
@@ -8488,7 +8482,7 @@
*altRef = 1;
value = -value;
}
- return getRational(altitude, value*1000, 1000);
+ return getRational(altitude, (int)(value*1000), 1000);
}else{
return BAD_VALUE;
}
@@ -8702,7 +8696,7 @@
*==========================================================================*/
int32_t QCameraParameters::setFaceDetection(bool enabled)
{
- int faceProcMask = m_nFaceProcMask;
+ uint32_t faceProcMask = m_nFaceProcMask;
// set face detection mask
if (enabled) {
faceProcMask |= CAM_FACE_PROCESS_MASK_DETECTION;
@@ -8718,7 +8712,7 @@
m_nFaceProcMask = faceProcMask;
// set parm for face detection
- int requested_faces = getInt(KEY_QC_MAX_NUM_REQUESTED_FACES);
+ uint32_t requested_faces = (uint32_t)getInt(KEY_QC_MAX_NUM_REQUESTED_FACES);
cam_fd_set_parm_t fd_set_parm;
memset(&fd_set_parm, 0, sizeof(cam_fd_set_parm_t));
fd_set_parm.fd_mode = faceProcMask;
@@ -9092,9 +9086,8 @@
}
const char *aecBracketStr = get(KEY_QC_AE_BRACKET_HDR);
- int value = lookupAttr(BRACKETING_MODES_MAP,
- sizeof(BRACKETING_MODES_MAP)/sizeof(QCameraMap),
- aecBracketStr);
+ int value = lookupAttr(BRACKETING_MODES_MAP, PARAM_MAP_SIZE(BRACKETING_MODES_MAP),
+ aecBracketStr);
CDBG_HIGH("%s: aecBracketStr=%s, value=%d.", __func__, aecBracketStr, value);
return (value == CAM_EXP_BRACKETING_ON);
}
@@ -9111,9 +9104,7 @@
*==========================================================================*/
const char *QCameraParameters::getFrameFmtString(cam_format_t fmt)
{
- return lookupNameByValue(PICTURE_TYPES_MAP,
- sizeof(PICTURE_TYPES_MAP)/sizeof(QCameraMap),
- fmt);
+ return lookupNameByValue(PICTURE_TYPES_MAP, PARAM_MAP_SIZE(PICTURE_TYPES_MAP), fmt);
}
/*===========================================================================
@@ -9158,16 +9149,15 @@
* none-zero failure code
*==========================================================================*/
int32_t QCameraParameters::AddSetParmEntryToBatch(void *p_table,
- cam_intf_parm_type_t paramType,
- uint32_t paramLength,
- void *paramValue)
+ cam_intf_parm_type_t paramType, size_t paramLength, void *paramValue)
{
- uint32_t j = 0;
+ size_t j = 0;
parm_buffer_new_t *param_buf = (parm_buffer_new_t *)p_table;
- uint32_t num_entry = param_buf->num_entry;
- uint32_t size_req = paramLength + sizeof(parm_entry_type_new_t);
- uint32_t aligned_size_req = (size_req + 3) & (~3);
- parm_entry_type_new_t *curr_param = (parm_entry_type_new_t *)¶m_buf->entry[0];
+ size_t num_entry = param_buf->num_entry;
+ size_t size_req = paramLength + sizeof(parm_entry_type_new_t);
+ size_t aligned_size_req = (size_req + 3U) & (~3U);
+ parm_entry_type_new_t *curr_param = (parm_entry_type_new_t *)
+ (void *) ¶m_buf->entry[0];
/* first search if the key is already present in the batch list
* this is a search penalty but as the batch list is never more
@@ -9194,15 +9184,15 @@
initBatchUpdate(p_table);
}
- curr_param = (parm_entry_type_new_t *)(¶m_buf->entry[0] +
- param_buf->curr_size);
+ curr_param = (parm_entry_type_new_t *)
+ (void *) (¶m_buf->entry[0] + param_buf->curr_size);
param_buf->curr_size += aligned_size_req;
param_buf->tot_rem_size -= aligned_size_req;
param_buf->num_entry++;
}
curr_param->entry_type = paramType;
- curr_param->size = (int32_t)paramLength;
+ curr_param->size = paramLength;
curr_param->aligned_size = aligned_size_req;
memcpy(&curr_param->data[0], paramValue, paramLength);
CDBG("%s: num_entry: %d, paramType: %d, paramLength: %d, aligned_size_req: %d",
@@ -9229,13 +9219,14 @@
{
///in get params, we have no information on the size of the param requested
//for, hence we assume the largest size and reserve space for the same
- uint32_t j = 0;
- uint32_t paramLength = sizeof(parm_type_t);
+ size_t j = 0;
+ size_t paramLength = sizeof(parm_type_t);
parm_buffer_new_t *param_buf = (parm_buffer_new_t *)p_table;
- uint32_t num_entry = param_buf->num_entry;
- uint32_t size_req = paramLength + sizeof(parm_entry_type_new_t) - sizeof(char);
- uint32_t aligned_size_req = (size_req + 3) & (~3);
- parm_entry_type_new_t *curr_param = (parm_entry_type_new_t *)¶m_buf->entry[0];
+ size_t num_entry = param_buf->num_entry;
+ size_t size_req = paramLength + sizeof(parm_entry_type_new_t) - sizeof(char);
+ size_t aligned_size_req = (size_req + 3U) & (~3U);
+ parm_entry_type_new_t *curr_param = (parm_entry_type_new_t *)
+ (void *) ¶m_buf->entry[0];
/* first search if the key is already present in the batch list
* this is a search penalty but as the batch list is never more
@@ -9246,34 +9237,34 @@
* direct indexing
*/
for (j = 0; j < num_entry; j++) {
- if (paramType == curr_param->entry_type) {
- CDBG_HIGH("%s:Batch parameter overwrite for param: %d",
- __func__, paramType);
+ if (paramType == curr_param->entry_type) {
+ CDBG_HIGH("%s:Batch parameter overwrite for param: %d",
+ __func__, paramType);
break;
- }
- curr_param = GET_NEXT_PARAM(curr_param, parm_entry_type_new_t);
+ }
+ curr_param = GET_NEXT_PARAM(curr_param, parm_entry_type_new_t);
}
//new param, search not found
if (j == num_entry) {
- if (aligned_size_req > param_buf->tot_rem_size) {
- ALOGE("%s:Batch buffer running out of size, commit and resend",__func__);
- //this is an extreme corner case
- //if the size of the batch set is full, we return error
- //the caller is expected to commit the get batch, use the params
- //returned, initialize the batch again and continue
- return NO_MEMORY;
- }
+ if (aligned_size_req > param_buf->tot_rem_size) {
+ ALOGE("%s:Batch buffer running out of size, commit and resend", __func__);
+ // This is an extreme corner case
+ // if the size of the batch set is full, we return error
+ // the caller is expected to commit the get batch, use the params
+ // returned, initialize the batch again and continue.
+ return NO_MEMORY;
+ }
- curr_param = (parm_entry_type_new_t *)(¶m_buf->entry[0] +
- param_buf->curr_size);
- param_buf->curr_size += aligned_size_req;
- param_buf->tot_rem_size -= aligned_size_req;
- param_buf->num_entry++;
+ curr_param = (parm_entry_type_new_t *) (void *)
+ (¶m_buf->entry[0] + param_buf->curr_size);
+ param_buf->curr_size += aligned_size_req;
+ param_buf->tot_rem_size -= aligned_size_req;
+ param_buf->num_entry++;
}
curr_param->entry_type = paramType;
- curr_param->size = (int32_t)paramLength;
+ curr_param->size = paramLength;
curr_param->aligned_size = aligned_size_req;
CDBG_HIGH("%s:num_entry: %d, paramType: %d ",__func__, param_buf->num_entry, paramType);
@@ -9446,10 +9437,11 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int32_t QCameraReprocScaleParam::setScaleSizeTbl(uint8_t scale_cnt, cam_dimension_t *scale_tbl, uint8_t org_cnt, cam_dimension_t *org_tbl)
+int32_t QCameraReprocScaleParam::setScaleSizeTbl(size_t scale_cnt,
+ cam_dimension_t *scale_tbl, size_t org_cnt, cam_dimension_t *org_tbl)
{
int32_t rc = NO_ERROR;
- int i;
+ size_t i;
mNeedScaleCnt = 0;
if(!mScaleEnabled || scale_cnt <=0 || scale_tbl == NULL || org_cnt <=0 || org_tbl == NULL){
@@ -9495,7 +9487,7 @@
*
* RETURN : uint8_t type of picture size count
*==========================================================================*/
-uint8_t QCameraReprocScaleParam::getScaleSizeTblCnt()
+size_t QCameraReprocScaleParam::getScaleSizeTblCnt()
{
return mNeedScaleCnt;
}
@@ -9563,9 +9555,8 @@
if(mNeedScaleCnt <= 0)
return FALSE;
- for(int i = 0; i < mNeedScaleCnt; i++){
- if(mNeedScaledSizeTbl[i].width == width
- && mNeedScaledSizeTbl[i].height == height){
+ for (size_t i = 0; i < mNeedScaleCnt; i++) {
+ if ((mNeedScaledSizeTbl[i].width == width) && (mNeedScaledSizeTbl[i].height == height)) {
//found match
return TRUE;
}
@@ -9588,7 +9579,7 @@
*==========================================================================*/
bool QCameraReprocScaleParam::isValidatePicSize(int width, int height)
{
- int i = 0;
+ size_t i = 0;
for(i = 0; i < mSensorSizeTblCnt; i++){
if(mSensorSizeTbl[i].width == width
@@ -9756,11 +9747,12 @@
*
* RETURN : bool type of status
*==========================================================================*/
-uint8_t QCameraReprocScaleParam::checkScaleSizeTable(uint8_t scale_cnt, cam_dimension_t *scale_tbl, uint8_t org_cnt, cam_dimension_t *org_tbl)
+size_t QCameraReprocScaleParam::checkScaleSizeTable(size_t scale_cnt,
+ cam_dimension_t *scale_tbl, size_t org_cnt, cam_dimension_t *org_tbl)
{
- uint8_t stbl_cnt = 0;
- uint8_t temp_cnt = 0;
- int i = 0;
+ size_t stbl_cnt = 0;
+ size_t temp_cnt = 0;
+ ssize_t i = 0;
if(scale_cnt <=0 || scale_tbl == NULL || org_tbl == NULL || org_cnt <= 0)
return stbl_cnt;
@@ -9768,10 +9760,10 @@
// 1. upscale. The scale size must larger than max sensor supported size
// 2. Scale dimension ratio must be same as the max sensor supported size.
temp_cnt = scale_cnt;
- for(i = scale_cnt-1; i >= 0; i--){
- if(scale_tbl[i].width > org_tbl[0].width ||
- (scale_tbl[i].width == org_tbl[0].width &&
- scale_tbl[i].height > org_tbl[0].height)){
+ for (i = (ssize_t)(scale_cnt - 1); i >= 0; i--) {
+ if (scale_tbl[i].width > org_tbl[0].width ||
+ (scale_tbl[i].width == org_tbl[0].width &&
+ scale_tbl[i].height > org_tbl[0].height)) {
//get the smallest scale size
break;
}
@@ -9779,10 +9771,10 @@
}
//check dimension ratio
- double supported_ratio = (double)org_tbl[0].width/ (double)org_tbl[0].height;
- for(i = 0; i < temp_cnt; i++){
- double cur_ratio = (double)scale_tbl[i].width/ (double)scale_tbl[i].height;
- if(fabs(supported_ratio - cur_ratio) > ASPECT_TOLERANCE){
+ double supported_ratio = (double)org_tbl[0].width / (double)org_tbl[0].height;
+ for (i = 0; i < (ssize_t)temp_cnt; i++) {
+ double cur_ratio = (double)scale_tbl[i].width / (double)scale_tbl[i].height;
+ if (fabs(supported_ratio - cur_ratio) > ASPECT_TOLERANCE) {
continue;
}
mNeedScaledSizeTbl[stbl_cnt].width = scale_tbl[i].width;
@@ -9802,7 +9794,7 @@
*
* RETURN : uint8_t type of picture size count
*==========================================================================*/
-uint8_t QCameraReprocScaleParam::getTotalSizeTblCnt()
+size_t QCameraReprocScaleParam::getTotalSizeTblCnt()
{
return mTotalSizeTblCnt;
}
@@ -9921,7 +9913,7 @@
*==========================================================================*/
uint8_t QCameraParameters::getNumOfExtraBuffersForImageProc()
{
- uint8_t numOfBufs = 0;
+ int numOfBufs = 0;
if (isUbiFocusEnabled()) {
numOfBufs += m_pCapability->ubifocus_af_bracketing_need.burst_count - 1;
@@ -9942,7 +9934,8 @@
numOfBufs += m_pCapability->fssr_settings_need.burst_count - 1;
//One output buffer of 4X size excluded
}
- return numOfBufs * getBurstNum();
+
+ return (uint8_t)(numOfBufs * getBurstNum());
}
/*===========================================================================
diff --git a/QCamera2/HAL/QCameraParameters.h b/QCamera2/HAL/QCameraParameters.h
index 513a60a..c474b93 100644
--- a/QCamera2/HAL/QCameraParameters.h
+++ b/QCamera2/HAL/QCameraParameters.h
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <utils/Errors.h>
#include "cam_intf.h"
+#include "cam_types.h"
#include "QCameraMem.h"
#include "QCameraThermalAdapter.h"
@@ -69,16 +70,18 @@
virtual ~QCameraReprocScaleParam();
virtual void setScaleEnable(bool enabled);
- virtual int32_t setScaleSizeTbl(uint8_t scale_cnt, cam_dimension_t *scale_tbl, uint8_t org_cnt, cam_dimension_t *org_tbl);
+ virtual int32_t setScaleSizeTbl(size_t scale_cnt,
+ cam_dimension_t *scale_tbl, size_t org_cnt,
+ cam_dimension_t *org_tbl);
virtual int32_t setValidatePicSize(int &width, int &height);
virtual bool isScaleEnabled();
virtual bool isUnderScaling();
- virtual uint8_t getScaleSizeTblCnt();
+ virtual size_t getScaleSizeTblCnt();
virtual cam_dimension_t *getScaledSizeTbl();
- virtual uint8_t getTotalSizeTblCnt();
+ virtual size_t getTotalSizeTblCnt();
virtual cam_dimension_t *getTotalSizeTbl();
virtual int32_t getPicSizeFromAPK(int &width, int &height);
virtual int32_t getPicSizeSetted(int &width, int &height);
@@ -87,7 +90,8 @@
bool isScalePicSize(int width, int height);
bool isValidatePicSize(int width, int height);
int32_t setSensorSupportedPicSize();
- uint8_t checkScaleSizeTable(uint8_t scale_cnt, cam_dimension_t *scale_tbl, uint8_t org_cnt, cam_dimension_t *org_tbl);
+ size_t checkScaleSizeTable(size_t scale_cnt, cam_dimension_t *scale_tbl,
+ size_t org_cnt, cam_dimension_t *org_tbl);
QCameraParameters *mParent;
bool mScaleEnabled;
@@ -95,15 +99,15 @@
bool mScaleDirection; // 0: Upscaling; 1: Downscaling
// picture size cnt that need scale operation
- uint8_t mNeedScaleCnt;
+ size_t mNeedScaleCnt;
cam_dimension_t mNeedScaledSizeTbl[MAX_SCALE_SIZES_CNT];
// sensor supported size cnt and table
- uint8_t mSensorSizeTblCnt;
+ size_t mSensorSizeTblCnt;
cam_dimension_t *mSensorSizeTbl;
// Total size cnt (sensor supported + need scale cnt)
- uint8_t mTotalSizeTblCnt;
+ size_t mTotalSizeTblCnt;
cam_dimension_t mTotalSizeTbl[MAX_SIZES_CNT];
cam_dimension_t mPicSizeFromAPK; // dimension that APK is expected
@@ -252,8 +256,7 @@
// video rotation
static const char KEY_QC_VIDEO_ROTATION[];
- // Auto HDR supported
- static const char KEY_QC_AUTO_HDR_SUPPORTED[];
+
//Redeye Reduction
static const char KEY_QC_REDEYE_REDUCTION[];
static const char KEY_QC_SUPPORTED_REDEYE_REDUCTION[];
@@ -291,6 +294,9 @@
//ZSL+HDR
static const char KEY_QC_ZSL_HDR_SUPPORTED[];
+ // Auto HDR supported
+ static const char KEY_QC_AUTO_HDR_SUPPORTED[];
+
//Multi-touch Focus
static const char KEY_QC_MULTI_TOUCH_FOCUS[];
static const char KEY_QC_SUPPORTED_MULTI_TOUCH_FOCUS_MODES[];
@@ -512,14 +518,14 @@
CAMERA_ORIENTATION_PORTRAIT = 1,
CAMERA_ORIENTATION_LANDSCAPE = 2,
};
- typedef struct {
+
+ template <typename valueType> struct QCameraMap {
const char *const desc;
- int val;
- } QCameraMap;
+ valueType val;
+ };
friend class QCameraReprocScaleParam;
QCameraReprocScaleParam m_reprocScaleParam;
- static const QCameraMap EFFECT_MODES_MAP[];
void getSupportedHfrSizes(Vector<Size> &sizes);
void setPreviewFrameRateMode(const char *mode);
@@ -549,10 +555,10 @@
cam_dimension_t &dim);
void getThumbnailSize(int *width, int *height) const;
- int getZSLBurstInterval();
- int getZSLQueueDepth();
- int getZSLBackLookCount();
- int getMaxUnmatchedFramesInQueue();
+ uint8_t getZSLBurstInterval();
+ uint8_t getZSLQueueDepth();
+ uint8_t getZSLBackLookCount();
+ uint8_t getMaxUnmatchedFramesInQueue();
int getMinPPBufs();
bool isZSLMode() {return m_bZslMode;};
bool isNoDisplayMode() {return m_bNoDisplayMode;};
@@ -562,16 +568,17 @@
uint8_t getNumOfSnapshots();
uint8_t getNumOfExtraHDRInBufsIfNeeded();
uint8_t getNumOfExtraHDROutBufsIfNeeded();
- int getBurstNum();
+ uint8_t getBurstNum();
bool getRecordingHintValue() {return m_bRecordingHint;}; // return local copy of video hint
int setRecordingHintValue(int32_t value); // set local copy of video hint and send to server
// no change in parameters value
- int getJpegQuality();
- int getJpegRotation();
+ uint32_t getJpegQuality();
+ uint32_t getJpegRotation();
+ int32_t getEffectValue();
int32_t getFlashValue();
int32_t getSupportedFlashModes();
int32_t getRedEyeValue();
- int32_t getExifDateTime(char *dateTime, uint32_t &count);
+ int32_t getExifDateTime(String8 &dateTime);
int32_t getExifFocalLength(rat_t *focalLenght);
uint16_t getExifIsoSpeed();
int32_t getExifGpsProcessingMethod(char *gpsProcessingMethod, uint32_t &count);
@@ -661,7 +668,7 @@
int32_t setLongshotEnable(bool enable);
inline bool isUbiRefocus() {return isUbiFocusEnabled() &&
(m_pCapability->ubifocus_af_bracketing_need.output_count > 1);};
- inline uint32_t UfOutputCount() {
+ inline uint8_t UfOutputCount() {
return m_pCapability->ubifocus_af_bracketing_need.output_count;};
inline bool isMTFRefocus() {return (isMultiTouchFocusEnabled() &&
(m_pCapability->mtf_af_bracketing_parm.output_count > 1));};
@@ -801,7 +808,7 @@
int32_t setSeeMore(const char *optiZoomStr);
int32_t setRedeyeReduction(const char *redeyeStr);
int32_t setWaveletDenoise(const char *wnrStr);
- int32_t setFaceRecognition(const char *faceRecog, int maxFaces);
+ int32_t setFaceRecognition(const char *faceRecog, uint32_t maxFaces);
int32_t setTintlessValue(const char *tintStr);
@@ -814,28 +821,20 @@
bool validateCameraAreas(cam_area_t *areas, int num_areas);
int parseGPSCoordinate(const char *coord_str, rat_t *coord);
int32_t getRational(rat_t *rat, int num, int denom);
- String8 createSizesString(const cam_dimension_t *sizes, int len);
- String8 createValuesString(const int *values, int len,
- const QCameraMap *map, int map_len);
- String8 createValuesStringFromMap(const QCameraMap *map,
- int map_len);
- String8 createHfrValuesString(const cam_hfr_info_t *values, int len,
- const QCameraMap *map, int map_len);
- String8 createHfrSizesString(const cam_hfr_info_t *values, int len);
+ String8 createSizesString(const cam_dimension_t *sizes, size_t len);
+ String8 createHfrValuesString(const cam_hfr_info_t *values, size_t len,
+ const QCameraMap<cam_hfr_mode_t> *map, size_t map_len);
+ String8 createHfrSizesString(const cam_hfr_info_t *values, size_t len);
String8 createFpsRangeString(const cam_fps_range_t *fps,
- int len,
- int &default_fps_index);
+ size_t len, int &default_fps_index);
String8 createFpsString(cam_fps_range_t &fps);
String8 createZoomRatioValuesString(uint32_t *zoomRatios, size_t length);
- int lookupAttr(const QCameraMap arr[], int len, const char *name);
- const char *lookupNameByValue(const QCameraMap arr[], int len, int value);
// ops for batch set/get params with server
int32_t initBatchUpdate(void *p_table);
int32_t AddSetParmEntryToBatch(void *p_table,
- cam_intf_parm_type_t paramType,
- uint32_t paramLength,
- void *paramValue);
+ cam_intf_parm_type_t paramType,
+ size_t paramLength, void *paramValue);
int32_t commitSetBatch();
int32_t AddGetParmEntryToBatch(void *p_table,
cam_intf_parm_type_t paramType);
@@ -847,33 +846,32 @@
// Map from strings to values
static const cam_dimension_t THUMBNAIL_SIZES_MAP[];
- static const QCameraMap AUTO_EXPOSURE_MAP[];
- static const QCameraMap PREVIEW_FORMATS_MAP[];
- static const QCameraMap PICTURE_TYPES_MAP[];
- static const QCameraMap RAW_FORMATS_MAP[];
- static const QCameraMap FOCUS_MODES_MAP[];
- static const QCameraMap SCENE_MODES_MAP[];
- static const QCameraMap FLASH_MODES_MAP[];
- static const QCameraMap FOCUS_ALGO_MAP[];
- static const QCameraMap WHITE_BALANCE_MODES_MAP[];
- static const QCameraMap ANTIBANDING_MODES_MAP[];
- static const QCameraMap ISO_MODES_MAP[];
- static const QCameraMap HFR_MODES_MAP[];
- static const QCameraMap BRACKETING_MODES_MAP[];
- static const QCameraMap ON_OFF_MODES_MAP[];
- static const QCameraMap ENABLE_DISABLE_MODES_MAP[];
- static const QCameraMap DENOISE_ON_OFF_MODES_MAP[];
- static const QCameraMap TRUE_FALSE_MODES_MAP[];
- static const QCameraMap TOUCH_AF_AEC_MODES_MAP[];
- static const QCameraMap FLIP_MODES_MAP[];
- static const QCameraMap AF_BRACKETING_MODES_MAP[];
- static const QCameraMap CHROMA_FLASH_MODES_MAP[];
- static const QCameraMap OPTI_ZOOM_MODES_MAP[];
- static const QCameraMap TRUE_PORTRAIT_MODES_MAP[];
- static const QCameraMap FSSR_MODES_MAP[];
- static const QCameraMap MULTI_TOUCH_FOCUS_MODES_MAP[];
- static const QCameraMap CDS_MODES_MAP[];
- static const QCameraMap SEE_MORE_MODES_MAP[];
+ static const QCameraMap<cam_auto_exposure_mode_type> AUTO_EXPOSURE_MAP[];
+ static const QCameraMap<cam_format_t> PREVIEW_FORMATS_MAP[];
+ static const QCameraMap<cam_format_t> PICTURE_TYPES_MAP[];
+ static const QCameraMap<cam_focus_mode_type> FOCUS_MODES_MAP[];
+ static const QCameraMap<cam_effect_mode_type> EFFECT_MODES_MAP[];
+ static const QCameraMap<cam_scene_mode_type> SCENE_MODES_MAP[];
+ static const QCameraMap<cam_flash_mode_t> FLASH_MODES_MAP[];
+ static const QCameraMap<cam_focus_algorithm_type> FOCUS_ALGO_MAP[];
+ static const QCameraMap<cam_wb_mode_type> WHITE_BALANCE_MODES_MAP[];
+ static const QCameraMap<cam_antibanding_mode_type> ANTIBANDING_MODES_MAP[];
+ static const QCameraMap<cam_iso_mode_type> ISO_MODES_MAP[];
+ static const QCameraMap<cam_hfr_mode_t> HFR_MODES_MAP[];
+ static const QCameraMap<cam_bracket_mode> BRACKETING_MODES_MAP[];
+ static const QCameraMap<int> ON_OFF_MODES_MAP[];
+ static const QCameraMap<int> ENABLE_DISABLE_MODES_MAP[];
+ static const QCameraMap<int> DENOISE_ON_OFF_MODES_MAP[];
+ static const QCameraMap<int> TRUE_FALSE_MODES_MAP[];
+ static const QCameraMap<int> TOUCH_AF_AEC_MODES_MAP[];
+ static const QCameraMap<cam_flip_t> FLIP_MODES_MAP[];
+ static const QCameraMap<int> AF_BRACKETING_MODES_MAP[];
+ static const QCameraMap<int> CHROMA_FLASH_MODES_MAP[];
+ static const QCameraMap<int> OPTI_ZOOM_MODES_MAP[];
+ static const QCameraMap<int> TRUE_PORTRAIT_MODES_MAP[];
+ static const QCameraMap<int> FSSR_MODES_MAP[];
+ static const QCameraMap<int> MULTI_TOUCH_FOCUS_MODES_MAP[];
+ static const QCameraMap<cam_cds_mode_type_t> CDS_MODES_MAP[];
QCamera2HardwareInterface *m_parent;
cam_capability_t *m_pCapability;
@@ -886,8 +884,8 @@
bool m_bRecordingHint; // local copy of recording hint
bool m_bRecordingHint_new;
bool m_bHistogramEnabled; // if histogram is enabled
- bool m_bLongshotEnabled; // if longshot is enabled
- int m_nFaceProcMask; // face process mask
+ bool m_bLongshotEnabled; // if longshot is enabled
+ uint32_t m_nFaceProcMask; // face process mask
bool m_bDebugFps; // if FPS need to be logged
cam_focus_mode_type mFocusMode;
cam_format_t mPreviewFormat;
@@ -896,7 +894,7 @@
bool m_bNoDisplayMode;
bool m_bWNROn;
bool m_bInited;
- int m_nBurstNum;
+ uint8_t m_nBurstNum;
cam_exp_bracketing_t m_AEBracketingClient;
bool m_bUpdateEffects; // Cause reapplying of effects
bool m_bSceneTransitionAuto; // Indicate that scene has changed to Auto
diff --git a/QCamera2/HAL/QCameraPostProc.cpp b/QCamera2/HAL/QCameraPostProc.cpp
index 9c78172..71126c3 100644
--- a/QCamera2/HAL/QCameraPostProc.cpp
+++ b/QCamera2/HAL/QCameraPostProc.cpp
@@ -136,10 +136,16 @@
mJpegUserData = user_data;
mm_dimension max_size;
+ if ((0 > m_parent->m_max_pic_width) || (0 > m_parent->m_max_pic_height)) {
+ ALOGE("%s : Negative dimension %dx%d", __func__,
+ m_parent->m_max_pic_width, m_parent->m_max_pic_height);
+ return BAD_VALUE;
+ }
+
//set max pic size
memset(&max_size, 0, sizeof(mm_dimension));
- max_size.w = m_parent->m_max_pic_width;
- max_size.h = m_parent->m_max_pic_height;
+ max_size.w = (uint32_t)m_parent->m_max_pic_width;
+ max_size.h = (uint32_t)m_parent->m_max_pic_height;
mJpegClientHandle = jpeg_open(&mJpegHandle, max_size);
if(!mJpegClientHandle) {
@@ -268,7 +274,7 @@
QCameraStream *pSnapshotStream = NULL;
QCameraStream *pThumbStream = NULL;
- for (int i = 0; i < pChannel->getNumOfStreams(); ++i) {
+ for (uint32_t i = 0; i < pChannel->getNumOfStreams(); ++i) {
QCameraStream *pStream = pChannel->getStreamByIndex(i);
if ( NULL == pStream ) {
@@ -289,7 +295,7 @@
// If thumbnail is not part of the reprocess channel, then
// try to get it from the source channel
if ((NULL == pThumbStream) && (pChannel == m_pReprocChannel)) {
- for (int i = 0; i < pSrcChannel->getNumOfStreams(); ++i) {
+ for (uint32_t i = 0; i < pSrcChannel->getNumOfStreams(); ++i) {
QCameraStream *pStream = pSrcChannel->getStreamByIndex(i);
if ( NULL == pStream ) {
@@ -369,7 +375,7 @@
{
CDBG("%s : E", __func__);
int32_t ret = NO_ERROR;
- uint32_t out_size;
+ size_t out_size;
char prop[PROPERTY_VALUE_MAX];
property_get("persist.camera.jpeg_burst", prop, "0");
@@ -435,8 +441,11 @@
encode_parm.color_format = getColorfmtFromImgFmt(img_fmt);
// get jpeg quality
- encode_parm.quality = m_parent->getJpegQuality();
- if (encode_parm.quality <= 0) {
+ uint32_t val = m_parent->getJpegQuality();
+ if (0U < val) {
+ encode_parm.quality = val;
+ } else {
+ ALOGI("%s: Using default JPEG quality", __func__);
encode_parm.quality = 85;
}
cam_frame_len_offset_t main_offset;
@@ -484,7 +493,7 @@
memset(&thumb_offset, 0, sizeof(cam_frame_len_offset_t));
thumb_stream->getFrameOffset(thumb_offset);
encode_parm.num_tmb_bufs = pStreamMem->getCnt();
- for (int i = 0; i < pStreamMem->getCnt(); i++) {
+ for (uint32_t i = 0; i < pStreamMem->getCnt(); i++) {
camera_memory_t *stream_mem = pStreamMem->getMemory(i, false);
if (stream_mem != NULL) {
encode_parm.src_thumb_buf[i].index = i;
@@ -528,8 +537,8 @@
out_size = sizeof(omx_jpeg_ouput_buf_t);
encode_parm.num_dst_bufs = encode_parm.num_src_bufs;
}
- m_JpegOutputMemCount = encode_parm.num_dst_bufs;
- for (int i = 0; i < (int)m_JpegOutputMemCount; i++) {
+ m_JpegOutputMemCount = (uint32_t)encode_parm.num_dst_bufs;
+ for (uint32_t i = 0; i < m_JpegOutputMemCount; i++) {
if (m_pJpegOutputMem[i] != NULL)
free(m_pJpegOutputMem[i]);
omx_jpeg_ouput_buf_t omx_out_buf;
@@ -1621,7 +1630,7 @@
memset(&jpg_job, 0, sizeof(mm_jpeg_job_t));
jpg_job.job_type = JPEG_JOB_TYPE_ENCODE;
jpg_job.encode_job.session_id = mJpegSessionId;
- jpg_job.encode_job.src_index = main_frame->buf_idx;
+ jpg_job.encode_job.src_index = (int32_t)main_frame->buf_idx;
jpg_job.encode_job.dst_index = 0;
if (mJpegMemOpt) {
@@ -1696,17 +1705,17 @@
offset.mp[1].len);
uint8_t *tp_meta = (uint8_t *)mem->data + meta_offset;
- uint32_t tp_bodymask_height, tp_meta_size;
- float aspect_ratio;
+ double aspect_ratio;
if (src_dim.width < src_dim.height) {
- aspect_ratio = (float)src_dim.width/src_dim.height;
+ aspect_ratio = (double)src_dim.width / (double)src_dim.height;
} else {
- aspect_ratio = (float)src_dim.height/src_dim.width;
+ aspect_ratio = (double)src_dim.height / (double)src_dim.width;
}
- tp_bodymask_height = m_parent->mParameters.TPBodyMaskWidth() * aspect_ratio;
- tp_meta_size = m_parent->mParameters.TpHeaderSize() +
+ uint32_t tp_bodymask_height = (uint32_t)
+ ((double)m_parent->mParameters.TPBodyMaskWidth() * aspect_ratio);
+ uint32_t tp_meta_size = m_parent->mParameters.TpHeaderSize() +
(m_parent->mParameters.TPBodyMaskWidth() * tp_bodymask_height);
CDBG_HIGH("%s:%d] %d x %d, %f, %d, %d", __func__, __LINE__,
@@ -2074,16 +2083,16 @@
int file_fd = open(saveName, O_RDWR | O_CREAT, 0655);
if (file_fd > 0) {
- size_t written_len = write(file_fd,
- job_data->out_data.buf_vaddr,
- job_data->out_data.buf_filled_len);
- if ( job_data->out_data.buf_filled_len != written_len ) {
- ALOGE("%s: Failed save complete data %d bytes written instead of %d bytes!",
- __func__,
- written_len,
+ ssize_t written_len = write(file_fd, job_data->out_data.buf_vaddr,
+ job_data->out_data.buf_filled_len);
+ if ((ssize_t)job_data->out_data.buf_filled_len != written_len) {
+ ALOGE("%s: Failed save complete data %d bytes "
+ "written instead of %d bytes!",
+ __func__, written_len,
job_data->out_data.buf_filled_len);
} else {
- CDBG_HIGH("%s: written number of bytes %d\n", __func__, written_len);
+ CDBG_HIGH("%s: written number of bytes %d\n",
+ __func__, written_len);
}
close(file_fd);
@@ -2521,13 +2530,14 @@
pStream->getFormat(frame_fmt);
fmt_string = m_parent->mParameters.getFrameFmtString(frame_fmt);
- int cbcr_offset = frame_offset.mp[0].len - frame_dim.width * frame_dim.height;
- m_parent->mParameters.set("snapshot-framelen", frame_offset.frame_len);
- m_parent->mParameters.set("snapshot-yoff", frame_offset.mp[0].offset);
+ int cbcr_offset = (int32_t)frame_offset.mp[0].len -
+ frame_dim.width * frame_dim.height;
+ m_parent->mParameters.set("snapshot-framelen", (int)frame_offset.frame_len);
+ m_parent->mParameters.set("snapshot-yoff", (int)frame_offset.mp[0].offset);
m_parent->mParameters.set("snapshot-cbcroff", cbcr_offset);
- if(fmt_string != NULL){
+ if (fmt_string != NULL) {
m_parent->mParameters.set("snapshot-format", fmt_string);
- }else{
+ } else {
m_parent->mParameters.set("snapshot-format", "");
}
@@ -2566,8 +2576,8 @@
{
CDBG_HIGH("%s: Allocating jpeg out buffer of size: %d", __func__, out_buf->size);
QCameraPostProcessor *procInst = (QCameraPostProcessor *) out_buf->handle;
- camera_memory_t *cam_mem = procInst->m_parent->mGetMemory(-1, out_buf->size,
- 1, procInst->m_parent->mCallbackCookie);
+ camera_memory_t *cam_mem = procInst->m_parent->mGetMemory(-1, out_buf->size, 1U,
+ procInst->m_parent->mCallbackCookie);
out_buf->mem_hdl = cam_mem;
out_buf->vaddr = cam_mem->data;
diff --git a/QCamera2/HAL/QCameraPostProc.h b/QCamera2/HAL/QCameraPostProc.h
index 554225e..340a769 100644
--- a/QCamera2/HAL/QCameraPostProc.h
+++ b/QCamera2/HAL/QCameraPostProc.h
@@ -180,7 +180,7 @@
void * m_pJpegOutputMem[MM_JPEG_MAX_BUF];
QCameraExif * m_pJpegExifObj;
- int8_t m_bThumbnailNeeded;
+ uint32_t m_bThumbnailNeeded;
QCameraReprocessChannel * m_pReprocChannel;
QCameraReprocessChannel * m_pDualReprocChannel;
diff --git a/QCamera2/HAL/QCameraStateMachine.cpp b/QCamera2/HAL/QCameraStateMachine.cpp
index 1765197..1936527 100644
--- a/QCamera2/HAL/QCameraStateMachine.cpp
+++ b/QCamera2/HAL/QCameraStateMachine.cpp
@@ -323,7 +323,7 @@
break;
case QCAMERA_SM_EVT_ENABLE_MSG_TYPE:
{
- rc = m_parent->enableMsgType(int32_t(payload));
+ rc = m_parent->enableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -332,7 +332,7 @@
break;
case QCAMERA_SM_EVT_DISABLE_MSG_TYPE:
{
- rc = m_parent->disableMsgType(int32_t(payload));
+ rc = m_parent->disableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -341,7 +341,7 @@
break;
case QCAMERA_SM_EVT_MSG_TYPE_ENABLED:
{
- int enabled = m_parent->msgTypeEnabled(int32_t(payload));
+ int enabled = m_parent->msgTypeEnabled(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_ENABLE_FLAG;
@@ -461,7 +461,7 @@
break;
case QCAMERA_SM_EVT_STORE_METADATA_IN_BUFS:
{
- rc = m_parent->storeMetaDataInBuffers(int(payload));
+ rc = m_parent->storeMetaDataInBuffers(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -470,7 +470,7 @@
break;
case QCAMERA_SM_EVT_DUMP:
{
- rc = m_parent->dump((int)payload);
+ rc = m_parent->dump(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -542,7 +542,7 @@
case QCAMERA_SM_EVT_THERMAL_NOTIFY:
{
rc = m_parent->updateThermalLevel(
- *(qcamera_thermal_level_enum_t *)&payload);
+ *((qcamera_thermal_level_enum_t *)payload));
}
break;
case QCAMERA_SM_EVT_EVT_NOTIFY:
@@ -641,7 +641,7 @@
break;
case QCAMERA_SM_EVT_ENABLE_MSG_TYPE:
{
- rc = m_parent->enableMsgType(int32_t(payload));
+ rc = m_parent->enableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -650,7 +650,7 @@
break;
case QCAMERA_SM_EVT_DISABLE_MSG_TYPE:
{
- rc = m_parent->disableMsgType(int32_t(payload));
+ rc = m_parent->disableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -659,7 +659,7 @@
break;
case QCAMERA_SM_EVT_MSG_TYPE_ENABLED:
{
- int enabled = m_parent->msgTypeEnabled(int32_t(payload));
+ int enabled = m_parent->msgTypeEnabled(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_ENABLE_FLAG;
@@ -757,7 +757,7 @@
break;
case QCAMERA_SM_EVT_STORE_METADATA_IN_BUFS:
{
- rc = m_parent->storeMetaDataInBuffers(int(payload));
+ rc = m_parent->storeMetaDataInBuffers(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -766,7 +766,7 @@
break;
case QCAMERA_SM_EVT_DUMP:
{
- rc = m_parent->dump((int)payload);
+ rc = m_parent->dump(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -925,7 +925,7 @@
break;
case QCAMERA_SM_EVT_ENABLE_MSG_TYPE:
{
- rc = m_parent->enableMsgType(int32_t(payload));
+ rc = m_parent->enableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -934,7 +934,7 @@
break;
case QCAMERA_SM_EVT_DISABLE_MSG_TYPE:
{
- rc = m_parent->disableMsgType(int32_t(payload));
+ rc = m_parent->disableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -943,7 +943,7 @@
break;
case QCAMERA_SM_EVT_MSG_TYPE_ENABLED:
{
- int enabled = m_parent->msgTypeEnabled(int32_t(payload));
+ int enabled = m_parent->msgTypeEnabled(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_ENABLE_FLAG;
@@ -1048,7 +1048,7 @@
break;
case QCAMERA_SM_EVT_STORE_METADATA_IN_BUFS:
{
- rc = m_parent->storeMetaDataInBuffers(int(payload));
+ rc = m_parent->storeMetaDataInBuffers(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -1057,7 +1057,7 @@
break;
case QCAMERA_SM_EVT_DUMP:
{
- rc = m_parent->dump((int)payload);
+ rc = m_parent->dump(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -1259,7 +1259,7 @@
case QCAMERA_SM_EVT_THERMAL_NOTIFY:
{
rc = m_parent->updateThermalLevel(
- *(qcamera_thermal_level_enum_t *)&payload);
+ *((qcamera_thermal_level_enum_t *)payload));
}
break;
case QCAMERA_SM_EVT_SNAPSHOT_DONE:
@@ -1467,7 +1467,7 @@
break;
case QCAMERA_SM_EVT_ENABLE_MSG_TYPE:
{
- rc = m_parent->enableMsgType(int32_t(payload));
+ rc = m_parent->enableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -1476,7 +1476,7 @@
break;
case QCAMERA_SM_EVT_DISABLE_MSG_TYPE:
{
- rc = m_parent->disableMsgType(int32_t(payload));
+ rc = m_parent->disableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -1485,7 +1485,7 @@
break;
case QCAMERA_SM_EVT_MSG_TYPE_ENABLED:
{
- int enabled = m_parent->msgTypeEnabled(int32_t(payload));
+ int enabled = m_parent->msgTypeEnabled(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_ENABLE_FLAG;
@@ -1559,7 +1559,7 @@
break;
case QCAMERA_SM_EVT_STORE_METADATA_IN_BUFS:
{
- rc = m_parent->storeMetaDataInBuffers(int(payload));
+ rc = m_parent->storeMetaDataInBuffers(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -1568,7 +1568,7 @@
break;
case QCAMERA_SM_EVT_DUMP:
{
- rc = m_parent->dump((int)payload);
+ rc = m_parent->dump(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -1766,7 +1766,7 @@
case QCAMERA_SM_EVT_THERMAL_NOTIFY:
{
rc = m_parent->updateThermalLevel(
- *(qcamera_thermal_level_enum_t *)&payload);
+ *((qcamera_thermal_level_enum_t *)payload));
}
break;
default:
@@ -1829,7 +1829,7 @@
break;
case QCAMERA_SM_EVT_ENABLE_MSG_TYPE:
{
- rc = m_parent->enableMsgType(int32_t(payload));
+ rc = m_parent->enableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -1838,7 +1838,7 @@
break;
case QCAMERA_SM_EVT_DISABLE_MSG_TYPE:
{
- rc = m_parent->disableMsgType(int32_t(payload));
+ rc = m_parent->disableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -1847,7 +1847,7 @@
break;
case QCAMERA_SM_EVT_MSG_TYPE_ENABLED:
{
- int enabled = m_parent->msgTypeEnabled(int32_t(payload));
+ int enabled = m_parent->msgTypeEnabled(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_ENABLE_FLAG;
@@ -1916,7 +1916,7 @@
break;
case QCAMERA_SM_EVT_STORE_METADATA_IN_BUFS:
{
- rc = m_parent->storeMetaDataInBuffers(int(payload));
+ rc = m_parent->storeMetaDataInBuffers(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -1925,7 +1925,7 @@
break;
case QCAMERA_SM_EVT_DUMP:
{
- rc = m_parent->dump((int)payload);
+ rc = m_parent->dump(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -2107,7 +2107,7 @@
case QCAMERA_SM_EVT_THERMAL_NOTIFY:
{
rc = m_parent->updateThermalLevel(
- *(qcamera_thermal_level_enum_t *)&payload);
+ *((qcamera_thermal_level_enum_t *)payload));
}
break;
case QCAMERA_SM_EVT_SNAPSHOT_DONE:
@@ -2179,7 +2179,7 @@
break;
case QCAMERA_SM_EVT_ENABLE_MSG_TYPE:
{
- rc = m_parent->enableMsgType(int32_t(payload));
+ rc = m_parent->enableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -2188,7 +2188,7 @@
break;
case QCAMERA_SM_EVT_DISABLE_MSG_TYPE:
{
- rc = m_parent->disableMsgType(int32_t(payload));
+ rc = m_parent->disableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -2197,7 +2197,7 @@
break;
case QCAMERA_SM_EVT_MSG_TYPE_ENABLED:
{
- int enabled = m_parent->msgTypeEnabled(int32_t(payload));
+ int enabled = m_parent->msgTypeEnabled(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_ENABLE_FLAG;
@@ -2266,7 +2266,7 @@
break;
case QCAMERA_SM_EVT_STORE_METADATA_IN_BUFS:
{
- rc = m_parent->storeMetaDataInBuffers(int(payload));
+ rc = m_parent->storeMetaDataInBuffers(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -2275,7 +2275,7 @@
break;
case QCAMERA_SM_EVT_DUMP:
{
- rc = m_parent->dump((int)payload);
+ rc = m_parent->dump(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -2461,7 +2461,7 @@
case QCAMERA_SM_EVT_THERMAL_NOTIFY:
{
rc = m_parent->updateThermalLevel(
- *(qcamera_thermal_level_enum_t *)&payload);
+ *((qcamera_thermal_level_enum_t *)payload));
}
break;
default:
@@ -2511,7 +2511,7 @@
break;
case QCAMERA_SM_EVT_ENABLE_MSG_TYPE:
{
- rc = m_parent->enableMsgType(int32_t(payload));
+ rc = m_parent->enableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -2520,7 +2520,7 @@
break;
case QCAMERA_SM_EVT_DISABLE_MSG_TYPE:
{
- rc = m_parent->disableMsgType(int32_t(payload));
+ rc = m_parent->disableMsgType(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -2529,7 +2529,7 @@
break;
case QCAMERA_SM_EVT_MSG_TYPE_ENABLED:
{
- int enabled = m_parent->msgTypeEnabled(int32_t(payload));
+ int enabled = m_parent->msgTypeEnabled(*((int32_t *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_ENABLE_FLAG;
@@ -2612,7 +2612,7 @@
break;
case QCAMERA_SM_EVT_STORE_METADATA_IN_BUFS:
{
- rc = m_parent->storeMetaDataInBuffers(int(payload));
+ rc = m_parent->storeMetaDataInBuffers(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -2621,7 +2621,7 @@
break;
case QCAMERA_SM_EVT_DUMP:
{
- rc = m_parent->dump((int)payload);
+ rc = m_parent->dump(*((int *)payload));
result.status = rc;
result.request_api = evt;
result.result_type = QCAMERA_API_RESULT_TYPE_DEF;
@@ -2859,7 +2859,7 @@
case QCAMERA_SM_EVT_THERMAL_NOTIFY:
{
rc = m_parent->updateThermalLevel(
- *(qcamera_thermal_level_enum_t *)&payload);
+ *((qcamera_thermal_level_enum_t *)payload));
}
break;
default:
diff --git a/QCamera2/HAL/QCameraStream.cpp b/QCamera2/HAL/QCameraStream.cpp
index 2cc61da..8a669aa 100644
--- a/QCamera2/HAL/QCameraStream.cpp
+++ b/QCamera2/HAL/QCameraStream.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014 The Linux Foundataion. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundataion. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -391,6 +391,7 @@
bool bDynallocBuf)
{
int32_t rc = OK;
+ ssize_t bufSize = BAD_INDEX;
mHandle = mCamOps->add_stream(mCamHandle, mChannelHandle);
if (!mHandle) {
@@ -404,11 +405,17 @@
mStreamInfo = reinterpret_cast<cam_stream_info_t *>(mStreamInfoBuf->getPtr(0));
mNumBufs = minNumBuffers;
- rc = mCamOps->map_stream_buf(mCamHandle,
+ bufSize = mStreamInfoBuf->getSize(0);
+ if (BAD_INDEX != bufSize) {
+ rc = mCamOps->map_stream_buf(mCamHandle,
mChannelHandle, mHandle, CAM_MAPPING_BUF_TYPE_STREAM_INFO,
- 0, -1, mStreamInfoBuf->getFd(0), mStreamInfoBuf->getSize(0));
- if (rc < 0) {
- ALOGE("Failed to map stream info buffer");
+ 0, -1, mStreamInfoBuf->getFd(0), (uint32_t)bufSize);
+ if (rc < 0) {
+ ALOGE("Failed to map stream info buffer");
+ goto err1;
+ }
+ } else {
+ ALOGE("Failed to retrieve buffer size (bad index)");
goto err1;
}
@@ -778,7 +785,7 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int32_t QCameraStream::bufDone(int index)
+int32_t QCameraStream::bufDone(uint32_t index)
{
int32_t rc = NO_ERROR;
@@ -814,8 +821,9 @@
ALOGE("%s: Cannot find buf for opaque data = %p", __func__, opaque);
return BAD_INDEX;
}
- CDBG_HIGH("%s: Buffer Index = %d, Frame Idx = %d", __func__, index, mBufDefs[index].frame_idx);
- rc = bufDone(index);
+ CDBG_HIGH("%s: Buffer Index = %d, Frame Idx = %d", __func__, index,
+ mBufDefs[index].frame_idx);
+ rc = bufDone((uint32_t)index);
return rc;
}
@@ -860,7 +868,7 @@
mDynBufAlloc = false;
numBufAlloc = mNumBufs;
} else {
- mNumBufsNeedAlloc = mNumBufs - numBufAlloc;
+ mNumBufsNeedAlloc = (uint8_t)(mNumBufs - numBufAlloc);
}
}
@@ -870,24 +878,30 @@
mFrameLenOffset.mp[0].stride,
mFrameLenOffset.mp[0].scanline,
numBufAlloc);
- mNumBufs = numBufAlloc + mNumBufsNeedAlloc;
+ mNumBufs = (uint8_t)(numBufAlloc + mNumBufsNeedAlloc);
if (!mStreamBufs) {
ALOGE("%s: Failed to allocate stream buffers", __func__);
return NO_MEMORY;
}
- for (int i = 0; i < numBufAlloc; i++) {
- rc = ops_tbl->map_ops(i, -1, mStreamBufs->getFd(i),
- mStreamBufs->getSize(i), ops_tbl->userdata);
- if (rc < 0) {
- ALOGE("%s: map_stream_buf failed: %d", __func__, rc);
- for (int j = 0; j < i; j++) {
- ops_tbl->unmap_ops(j, -1, ops_tbl->userdata);
+ for (uint32_t i = 0; i < numBufAlloc; i++) {
+ ssize_t bufSize = mStreamBufs->getSize(i);
+ if (BAD_INDEX != bufSize) {
+ rc = ops_tbl->map_ops(i, -1, mStreamBufs->getFd(i),
+ (uint32_t)bufSize, ops_tbl->userdata);
+ if (rc < 0) {
+ ALOGE("%s: map_stream_buf failed: %d", __func__, rc);
+ for (uint32_t j = 0; j < i; j++) {
+ ops_tbl->unmap_ops(j, -1, ops_tbl->userdata);
+ }
+ mStreamBufs->deallocate();
+ delete mStreamBufs;
+ mStreamBufs = NULL;
+ return INVALID_OPERATION;
}
- mStreamBufs->deallocate();
- delete mStreamBufs;
- mStreamBufs = NULL;
+ } else {
+ ALOGE("Failed to retrieve buffer size (bad index)");
return INVALID_OPERATION;
}
}
@@ -896,7 +910,7 @@
regFlags = (uint8_t *)malloc(sizeof(uint8_t) * mNumBufs);
if (!regFlags) {
ALOGE("%s: Out of memory", __func__);
- for (int i = 0; i < numBufAlloc; i++) {
+ for (uint32_t i = 0; i < numBufAlloc; i++) {
ops_tbl->unmap_ops(i, -1, ops_tbl->userdata);
}
mStreamBufs->deallocate();
@@ -909,7 +923,7 @@
mBufDefs = (mm_camera_buf_def_t *)malloc(mNumBufs * sizeof(mm_camera_buf_def_t));
if (mBufDefs == NULL) {
ALOGE("%s: getRegFlags failed %d", __func__, rc);
- for (int i = 0; i < numBufAlloc; i++) {
+ for (uint32_t i = 0; i < numBufAlloc; i++) {
ops_tbl->unmap_ops(i, -1, ops_tbl->userdata);
}
mStreamBufs->deallocate();
@@ -920,14 +934,14 @@
return INVALID_OPERATION;
}
memset(mBufDefs, 0, mNumBufs * sizeof(mm_camera_buf_def_t));
- for (int i = 0; i < numBufAlloc; i++) {
+ for (uint32_t i = 0; i < numBufAlloc; i++) {
mStreamBufs->getBufDef(mFrameLenOffset, mBufDefs[i], i);
}
rc = mStreamBufs->getRegFlags(regFlags);
if (rc < 0) {
ALOGE("%s: getRegFlags failed %d", __func__, rc);
- for (int i = 0; i < numBufAlloc; i++) {
+ for (uint32_t i = 0; i < numBufAlloc; i++) {
ops_tbl->unmap_ops(i, -1, ops_tbl->userdata);
}
mStreamBufs->deallocate();
@@ -992,14 +1006,19 @@
return NO_MEMORY;
}
- for (int i = 0; i < mNumBufs; i++) {
- rc = mapBuf(CAM_MAPPING_BUF_TYPE_STREAM_BUF,
- i, -1,
- mStreamBufs->getFd(i),
- mStreamBufs->getSize(i));
+ for (uint32_t i = 0; i < mNumBufs; i++) {
+ ssize_t bufSize = mStreamBufs->getSize(i);
+ if (BAD_INDEX != bufSize) {
+ rc = mapBuf(CAM_MAPPING_BUF_TYPE_STREAM_BUF, i, -1,
+ mStreamBufs->getFd(i), (size_t)bufSize);
+ ALOGE_IF((rc < 0), "%s: map_stream_buf failed: %d", __func__, rc);
+ } else {
+ ALOGE("%s: Bad index %u", __func__, i);
+ rc = BAD_INDEX;
+ }
if (rc < 0) {
- ALOGE("%s: map_stream_buf failed: %d", __func__, rc);
- for (int j = 0; j < i; j++) {
+ ALOGE("%s: Cleanup after error: %d", __func__, rc);
+ for (uint32_t j = 0; j < i; j++) {
unmapBuf(CAM_MAPPING_BUF_TYPE_STREAM_BUF, i, -1);
}
mStreamBufs->deallocate();
@@ -1014,7 +1033,7 @@
mRegFlags = (uint8_t *)malloc(sizeof(uint8_t) * mNumBufs);
if (!mRegFlags) {
ALOGE("%s: Out of memory", __func__);
- for (int i = 0; i < mNumBufs; i++) {
+ for (uint32_t i = 0; i < mNumBufs; i++) {
unmapBuf(CAM_MAPPING_BUF_TYPE_STREAM_BUF, i, -1);
}
mStreamBufs->deallocate();
@@ -1028,7 +1047,7 @@
mBufDefs = (mm_camera_buf_def_t *)malloc(bufDefsSize);
if (mBufDefs == NULL) {
ALOGE("%s: getRegFlags failed %d", __func__, rc);
- for (int i = 0; i < mNumBufs; i++) {
+ for (uint32_t i = 0; i < mNumBufs; i++) {
unmapBuf(CAM_MAPPING_BUF_TYPE_STREAM_BUF, i, -1);
}
mStreamBufs->deallocate();
@@ -1039,14 +1058,14 @@
return INVALID_OPERATION;
}
memset(mBufDefs, 0, bufDefsSize);
- for (int i = 0; i < mNumBufs; i++) {
+ for (uint32_t i = 0; i < mNumBufs; i++) {
mStreamBufs->getBufDef(mFrameLenOffset, mBufDefs[i], i);
}
rc = mStreamBufs->getRegFlags(mRegFlags);
if (rc < 0) {
ALOGE("%s: getRegFlags failed %d", __func__, rc);
- for (int i = 0; i < mNumBufs; i++) {
+ for (uint32_t i = 0; i < mNumBufs; i++) {
unmapBuf(CAM_MAPPING_BUF_TYPE_STREAM_BUF, i, -1);
}
mStreamBufs->deallocate();
@@ -1079,7 +1098,7 @@
int rc = NO_ERROR;
if (NULL != mBufDefs) {
- for (int i = 0; i < mNumBufs; i++) {
+ for (uint32_t i = 0; i < mNumBufs; i++) {
rc = unmapBuf(CAM_MAPPING_BUF_TYPE_STREAM_BUF, i, -1);
if (rc < 0) {
ALOGE("%s: map_stream_buf failed: %d", __func__, rc);
@@ -1118,24 +1137,25 @@
CDBG_HIGH("%s: E", __func__);
pme->cond_wait();
if (pme->mNumBufsNeedAlloc > 0) {
- uint8_t numBufAlloc = pme->mNumBufs - pme->mNumBufsNeedAlloc;
+ uint8_t numBufAlloc = (uint8_t)(pme->mNumBufs - pme->mNumBufsNeedAlloc);
rc = pme->mAllocator.allocateMoreStreamBuf(pme->mStreamBufs,
pme->mFrameLenOffset.frame_len,
pme->mNumBufsNeedAlloc);
if (rc == NO_ERROR){
- for (int i = numBufAlloc; i < pme->mNumBufs; i++) {
- rc = pme->m_MemOpsTbl.map_ops(i, -1,
- pme->mStreamBufs->getFd(i),
- pme->mStreamBufs->getSize(i),
- pme->m_MemOpsTbl.userdata);
- if (rc == 0) {
- pme->mStreamBufs->getBufDef(pme->mFrameLenOffset,
- pme->mBufDefs[i], i);
- pme->mCamOps->qbuf(pme->mCamHandle,
- pme->mChannelHandle,
- &pme->mBufDefs[i]);
+ for (uint32_t i = numBufAlloc; i < pme->mNumBufs; i++) {
+ ssize_t bufSize = pme->mStreamBufs->getSize(i);
+ if (BAD_INDEX != bufSize) {
+ rc = pme->m_MemOpsTbl.map_ops(i, -1, pme->mStreamBufs->getFd(i),
+ (uint32_t)bufSize, pme->m_MemOpsTbl.userdata);
+ if (rc == 0) {
+ pme->mStreamBufs->getBufDef(pme->mFrameLenOffset, pme->mBufDefs[i], i);
+ pme->mCamOps->qbuf(pme->mCamHandle, pme->mChannelHandle,
+ &pme->mBufDefs[i]);
+ } else {
+ ALOGE("%s: map_stream_buf %d failed: %d", __func__, rc, i);
+ }
} else {
- ALOGE("%s: map_stream_buf %d failed: %d", __func__, rc, i);
+ ALOGE("Failed to retrieve buffer size (bad index)");
}
}
@@ -1201,7 +1221,7 @@
CDBG_HIGH("%s: return from buf allocation thread", __func__);
}
- for (int i = 0; i < mNumBufs; i++) {
+ for (uint32_t i = 0; i < mNumBufs; i++) {
rc = ops_tbl->unmap_ops(i, -1, ops_tbl->userdata);
if (rc < 0) {
ALOGE("%s: map_stream_buf failed: %d", __func__, rc);
@@ -1230,7 +1250,7 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int32_t QCameraStream::invalidateBuf(int index)
+int32_t QCameraStream::invalidateBuf(uint32_t index)
{
return mStreamBufs->invalidateCache(index);
}
@@ -1247,7 +1267,7 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int32_t QCameraStream::cleanInvalidateBuf(int index)
+int32_t QCameraStream::cleanInvalidateBuf(uint32_t index)
{
return mStreamBufs->cleanInvalidateCache(index);
}
@@ -1487,11 +1507,8 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-int32_t QCameraStream::mapBuf(uint8_t buf_type,
- uint32_t buf_idx,
- int32_t plane_idx,
- int fd,
- uint32_t size)
+int32_t QCameraStream::mapBuf(uint8_t buf_type, uint32_t buf_idx,
+ int32_t plane_idx, int fd, size_t size)
{
return mCamOps->map_stream_buf(mCamHandle, mChannelHandle,
mHandle, buf_type,
diff --git a/QCamera2/HAL/QCameraStream.h b/QCamera2/HAL/QCameraStream.h
index c9dfe92..4732056 100644
--- a/QCamera2/HAL/QCameraStream.h
+++ b/QCamera2/HAL/QCameraStream.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012,2014 The Linux Foundataion. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundataion. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -63,7 +63,7 @@
bool bDynallocBuf);
virtual int32_t processZoomDone(preview_stream_ops_t *previewWindow,
cam_crop_data_t &crop_info);
- virtual int32_t bufDone(int index);
+ virtual int32_t bufDone(uint32_t index);
virtual int32_t bufDone(const void *opaque, bool isMetaData);
virtual int32_t processDataNotify(mm_camera_super_buf_t *bufs);
virtual int32_t start();
@@ -91,7 +91,7 @@
int32_t acquireStreamBufs();
int32_t mapBuf(uint8_t buf_type, uint32_t buf_idx,
- int32_t plane_idx, int fd, uint32_t size);
+ int32_t plane_idx, int fd, size_t size);
int32_t unmapBuf(uint8_t buf_type, uint32_t buf_idx, int32_t plane_idx);
int32_t setParameter(cam_stream_parm_buffer_t ¶m);
int32_t getParameter(cam_stream_parm_buffer_t ¶m);
@@ -107,9 +107,9 @@
uint8_t getBufferCount() { return mNumBufs; }
uint32_t getChannelHandle() { return mChannelHandle; }
- int mDumpFrame;
- int mDumpMetaFrame;
- int mDumpSkipCnt;
+ uint32_t mDumpFrame;
+ uint32_t mDumpMetaFrame;
+ uint32_t mDumpSkipCnt;
void cond_wait();
void cond_signal();
@@ -180,8 +180,8 @@
mm_camera_buf_def_t **bufs,
mm_camera_map_unmap_ops_tbl_t *ops_tbl);
int32_t putBufs(mm_camera_map_unmap_ops_tbl_t *ops_tbl);
- int32_t invalidateBuf(int index);
- int32_t cleanInvalidateBuf(int index);
+ int32_t invalidateBuf(uint32_t index);
+ int32_t cleanInvalidateBuf(uint32_t index);
int32_t calcOffset(cam_stream_info_t *streamInfo);
int32_t unmapStreamInfoBuf();
int32_t releaseStreamInfoBuf();
diff --git a/QCamera2/HAL/test/Android.mk b/QCamera2/HAL/test/Android.mk
index 00162bc..d850489 100644
--- a/QCamera2/HAL/test/Android.mk
+++ b/QCamera2/HAL/test/Android.mk
@@ -46,7 +46,11 @@
LOCAL_MODULE:= camera_test
LOCAL_MODULE_TAGS:= tests
-LOCAL_CFLAGS += -Wall -fno-short-enums -O0
+LOCAL_CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter
+ifeq ($(call is-platform-sdk-version-at-least,20),true)
+LOCAL_CFLAGS += -Wno-error=deprecated-declarations -Wno-error=deprecated
+endif
+LOCAL_CFLAGS += -O0
include $(BUILD_EXECUTABLE)
diff --git a/QCamera2/HAL/test/qcamera_test.cpp b/QCamera2/HAL/test/qcamera_test.cpp
index b57a13a..aa1ef7e 100644
--- a/QCamera2/HAL/test/qcamera_test.cpp
+++ b/QCamera2/HAL/test/qcamera_test.cpp
@@ -73,7 +73,8 @@
#define ERROR(format, ...) printf( \
"%s[%d] : ERROR: "format"\n", __func__, __LINE__, ##__VA_ARGS__)
-#define VIDEO_BUF_ALLIGN(size, allign) (((size) + (allign-1)) & (~(allign-1)))
+#define VIDEO_BUF_ALLIGN(size, allign) \
+ (((size) + (allign-1)) & (typeof(size))(~(allign-1)))
namespace qcamera {
@@ -95,7 +96,7 @@
*==========================================================================*/
void CameraContext::previewCallback(const sp<IMemory>& mem)
{
- printf("PREVIEW Callback 0x%x", ( unsigned int ) mem->pointer());
+ printf("PREVIEW Callback %p", mem->pointer());
uint8_t *ptr = (uint8_t*) mem->pointer();
printf("PRV_CB: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x",
ptr[0],
@@ -161,7 +162,7 @@
status_t CameraContext::saveFile(const sp<IMemory>& mem, String8 path)
{
unsigned char *buff = NULL;
- int size;
+ ssize_t size;
int fd = -1;
if (mem == NULL) {
@@ -174,7 +175,7 @@
return -errno;
}
- size = mem->size();
+ size = (ssize_t)mem->size();
if (size <= 0) {
printf("IMemory object is of zero size\n");
close(fd);
@@ -188,16 +189,14 @@
return BAD_VALUE;
}
- if ( size != write(fd, buff, size) ) {
- printf("Bad Write error (%d)%s\n",
- errno,
- strerror(errno));
+ if (size != write(fd, buff, (size_t)size)) {
+ printf("Bad Write error (%d)%s\n", errno, strerror(errno));
close(fd);
return INVALID_OPERATION;
}
- printf("%s: buffer=%08X, size=%d stored at %s\n",
- __FUNCTION__, (int)buff, size, path.string());
+ printf("%s: buffer=%p, size=%lld stored at %s\n",
+ __FUNCTION__, buff, (long long int) size, path.string());
if (fd >= 0)
close(fd);
@@ -219,8 +218,8 @@
SkBitmap * CameraContext::PiPCopyToOneFile(
SkBitmap *bitmap0, SkBitmap *bitmap1)
{
- int size0;
- int size1;
+ size_t size0;
+ size_t size1;
SkBitmap *src;
SkBitmap *dst;
unsigned int dstOffset;
@@ -253,12 +252,12 @@
return NULL;
}
- for(int i=0; i<src->height(); i++) {
- dstOffset = i*(dst->width())*mfmtMultiplier;
- srcOffset = i*(src->width())*mfmtMultiplier;
- memcpy(((unsigned char *) dst->getPixels())+dstOffset,
- ((unsigned char *) src->getPixels())+srcOffset,
- src->width()*mfmtMultiplier);
+ for (unsigned int i = 0; i < (unsigned int)src->height(); i++) {
+ dstOffset = i * (unsigned int)dst->width() * mfmtMultiplier;
+ srcOffset = i * (unsigned int)src->width() * mfmtMultiplier;
+ memcpy(((unsigned char *)dst->getPixels()) + dstOffset,
+ ((unsigned char *)src->getPixels()) + srcOffset,
+ (unsigned int)src->width() * mfmtMultiplier);
}
return dst;
@@ -282,7 +281,7 @@
{
SkBitmap::Config prefConfig = SkBitmap::kARGB_8888_Config;
const void *buff = NULL;
- int size;
+ size_t size;
buff = (const void *)mem->pointer();
size= mem->size();
@@ -358,10 +357,6 @@
const SkBitmap *bitmap, String8 path)
{
int qFactor = 100;
- long len;
- status_t ret;
- unsigned char *buff;
- unsigned char temp;
skJpegEnc = SkImageEncoder::Create(SkImageEncoder::kJPEG_Type);
@@ -376,7 +371,7 @@
}
fseek(fh, 0, SEEK_END);
- len = ftell(fh);
+ size_t len = (size_t)ftell(fh);
rewind(fh);
if( !len ) {
@@ -385,19 +380,19 @@
return BAD_VALUE;
}
- buff = (unsigned char*)malloc(len);
+ unsigned char *buff = (unsigned char*)malloc(len);
if (!buff) {
printf("Cannot allocate memory for buffer reading!\n");
return BAD_VALUE;
}
- ret = fread(buff, 1, len, fh);
- if (ret != len) {
+ size_t readSize = fread(buff, 1, len, fh);
+ if (readSize != len) {
printf("Reading error\n");
return BAD_VALUE;
}
- ret = ReadSectionsFromBuffer(buff, len, READ_ALL);
+ status_t ret = ReadSectionsFromBuffer(buff, len, READ_ALL);
if (ret != NO_ERROR) {
printf("Cannot read sections from buffer\n");
DiscardData();
@@ -407,15 +402,15 @@
free(buff);
rewind(fh);
- temp = 0xff;
- ret = fwrite(&temp, sizeof(unsigned char), 1, fh);
- if (ret != 1) {
+ unsigned char temp = 0xff;
+ size_t writeSize = fwrite(&temp, sizeof(unsigned char), 1, fh);
+ if (1 != writeSize) {
printf("Writing error\n");
}
temp = 0xd8;
fwrite(&temp, sizeof(unsigned char), 1, fh);
- for (int i=0; i<mSectionsRead; i++) {
+ for (size_t i = 0; i < mSectionsRead; i++) {
switch((mSections[i].Type)) {
case 0x123:
@@ -442,11 +437,10 @@
}
}
fseek(fh, 0, SEEK_END);
- len = ftell(fh);
+ len = (size_t)ftell(fh);
rewind(fh);
- printf("%s: buffer=%p, size=%ld stored at %s\n",
- __FUNCTION__, bitmap->getPixels(),
- len, path.string());
+ printf("%s: buffer=%p, size=%zu stored at %s\n",
+ __FUNCTION__, bitmap->getPixels(), len, path.string());
free(mJEXIFSection.Data);
DiscardData();
@@ -472,10 +466,10 @@
* none-zero failure code
*==========================================================================*/
status_t CameraContext::ReadSectionsFromBuffer (unsigned char *buffer,
- unsigned int buffer_size, ReadMode_t ReadMode)
+ size_t buffer_size, ReadMode_t ReadMode)
{
int a;
- unsigned int pos = 0;
+ size_t pos = 0;
int HaveCom = 0;
mSectionsAllocated = 10;
@@ -499,9 +493,9 @@
}
for(;;){
- int itemlen;
+ size_t itemlen;
int marker = 0;
- int ll,lh;
+ size_t ll,lh;
unsigned char * Data;
CheckSectionsAllocated();
@@ -558,7 +552,7 @@
// If reading entire image is requested, read the rest of the
// data.
if (ReadMode & READ_IMAGE){
- int size;
+ size_t size;
// Determine how much file is left.
size = buffer_size - pos;
@@ -696,9 +690,7 @@
*==========================================================================*/
CameraContext::Sections_t *CameraContext::FindSection(int SectionType)
{
- int a;
-
- for (a=0;a<mSectionsRead;a++){
+ for (unsigned int a = 0; a < mSectionsRead; a++) {
if (mSections[a].Type == SectionType){
return &mSections[a];
}
@@ -720,9 +712,7 @@
*==========================================================================*/
void CameraContext::DiscardData()
{
- int a;
-
- for (a=0;a<mSectionsRead;a++){
+ for (unsigned int a = 0; a < mSectionsRead; a++) {
free(mSections[a].Data);
}
@@ -799,7 +789,7 @@
Size currentPictureSize = mSupportedPictureSizes.itemAt(
mCurrentPictureSizeIdx);
unsigned char *buff = NULL;
- int size;
+ size_t size;
status_t ret = 0;
memset(&mJEXIFSection, 0, sizeof(Sections_t)),
@@ -844,16 +834,12 @@
// Find the the capture with higher width and height and read
// its jpeg sections
- if ((mInterpr->camera[0]->mWidthTmp *
- mInterpr->camera[0]->mHeightTmp) >
- (mInterpr->camera[1]->mWidthTmp *
- mInterpr->camera[1]->mHeightTmp)) {
+ if ((mInterpr->camera[0]->mWidthTmp * mInterpr->camera[0]->mHeightTmp) >
+ (mInterpr->camera[1]->mWidthTmp * mInterpr->camera[1]->mHeightTmp)) {
buff = (unsigned char *)PiPPtrTmp->pointer();
size= PiPPtrTmp->size();
- } else if ((mInterpr->camera[0]->mWidthTmp *
- mInterpr->camera[0]->mHeightTmp) <
- (mInterpr->camera[1]->mWidthTmp *
- mInterpr->camera[1]->mHeightTmp)) {
+ } else if ((mInterpr->camera[0]->mWidthTmp * mInterpr->camera[0]->mHeightTmp) <
+ (mInterpr->camera[1]->mWidthTmp * mInterpr->camera[1]->mHeightTmp)) {
buff = (unsigned char *)PiPPtrTmp->pointer();
size= PiPPtrTmp->size();
} else {
@@ -873,8 +859,7 @@
mJEXIFTmp = FindSection(M_EXIF);
mJEXIFSection = *mJEXIFTmp;
- mJEXIFSection.Data =
- (unsigned char*)malloc(mJEXIFTmp->Size);
+ mJEXIFSection.Data = (unsigned char*)malloc(mJEXIFTmp->Size);
memcpy(mJEXIFSection.Data,
mJEXIFTmp->Data, mJEXIFTmp->Size);
DiscardData();
@@ -882,10 +867,10 @@
wStream = new SkFILEWStream(jpegPath.string());
skBMDec = PiPCopyToOneFile(&mInterpr->camera[0]->skBMtmp,
- &mInterpr->camera[1]->skBMtmp);
+ &mInterpr->camera[1]->skBMtmp);
if (encodeJPEG(wStream, skBMDec, jpegPath) != false) {
printf("%s():%d:: Failed during jpeg encode\n",
- __FUNCTION__,__LINE__);
+ __FUNCTION__, __LINE__);
return;
}
mPiPIdx = 0;
@@ -899,8 +884,7 @@
}
}
- if ( ( msgType & CAMERA_MSG_PREVIEW_METADATA ) &&
- ( NULL != metadata ) ) {
+ if ((msgType & CAMERA_MSG_PREVIEW_METADATA) && (NULL != metadata)) {
printf("Face detected %d \n", metadata->number_of_faces);
}
mInterpr->PiPUnlock();
@@ -923,7 +907,8 @@
int32_t msgType,
const sp<IMemory>& dataPtr)
{
- printf("Recording cb: %d %lld %p\n", msgType, timestamp, dataPtr.get());
+ printf("Recording cb: %d %lld %p\n",
+ msgType, (long long int)timestamp, dataPtr.get());
}
/*===========================================================================
@@ -949,7 +934,7 @@
// Not needed check. Just avoiding warnings of not used variables.
if (msgType > 0)
msgType = 0;
- int i = 0;
+ size_t i = 0;
void * srcBuff = NULL;
void * dstBuff = NULL;
@@ -971,8 +956,8 @@
srcUVStride = calcStride(currentVideoSize.width);
srcYScanLines = calcYScanLines(currentVideoSize.height);
srcUVScanLines = calcUVScanLines(currentVideoSize.height);
- mInterpr->mViVBuff.srcWidth = currentVideoSize.width;
- mInterpr->mViVBuff.srcHeight = currentVideoSize.height;
+ mInterpr->mViVBuff.srcWidth = (size_t)currentVideoSize.width;
+ mInterpr->mViVBuff.srcHeight = (size_t)currentVideoSize.height;
mInterpr->mViVBuff.YStride = srcYStride;
@@ -997,7 +982,7 @@
srcUVScanLines = mInterpr->mViVBuff.UVScanLines;
- for (i=0; i<(int) mInterpr->mViVBuff.srcHeight; i++) {
+ for (i = 0; i < mInterpr->mViVBuff.srcHeight; i++) {
srcOffset = i*srcYStride;
dstOffset = i*dstYStride;
memcpy((unsigned char *) dstBuff + dstOffset,
@@ -1006,7 +991,7 @@
}
srcBaseOffset = srcYStride * srcYScanLines;
dstBaseOffset = dstYStride * dstYScanLines;
- for (i=0;i<(int) mInterpr->mViVBuff.srcHeight/2;i++) {
+ for (i = 0; i < mInterpr->mViVBuff.srcHeight / 2; i++) {
srcOffset = i*srcUVStride + srcBaseOffset;
dstOffset = i*dstUVStride + dstBaseOffset;
memcpy((unsigned char *) dstBuff + dstOffset,
@@ -1039,23 +1024,23 @@
srcUVScanLines = dstUVScanLines;
srcBuff = dstBuff;
- for (i=0; i<(int) currentVideoSize.height; i++) {
+ for (i = 0; i < (size_t)currentVideoSize.height; i++) {
srcOffset = i*srcYStride;
dstOffset = i*dstYStride;
memcpy((unsigned char *) mInterpr->mViVVid.mappedBuff +
dstOffset, (unsigned char *) srcBuff +
- srcOffset, currentVideoSize.width);
+ srcOffset, (size_t)currentVideoSize.width);
}
srcBaseOffset = srcYStride * srcYScanLines;
- dstBaseOffset = dstUVStride * currentVideoSize.height;
+ dstBaseOffset = dstUVStride * (size_t)currentVideoSize.height;
- for (i=0;i<(int) currentVideoSize.height/2;i++) {
+ for (i = 0; i < (size_t)currentVideoSize.height / 2; i++) {
srcOffset = i*srcUVStride + srcBaseOffset;
dstOffset = i*dstUVStride + dstBaseOffset;
memcpy((unsigned char *) mInterpr->mViVVid.mappedBuff +
dstOffset, (unsigned char *) srcBuff +
- srcOffset, currentVideoSize.width);
+ srcOffset, (size_t)currentVideoSize.width);
}
@@ -1272,7 +1257,7 @@
return stride;
}
alignment = 128;
- stride = VIDEO_BUF_ALLIGN(width, alignment);
+ stride = VIDEO_BUF_ALLIGN((size_t)width, alignment);
return stride;
}
@@ -1294,7 +1279,7 @@
return scanlines;
}
alignment = 32;
- scanlines = VIDEO_BUF_ALLIGN(height, alignment);
+ scanlines = VIDEO_BUF_ALLIGN((size_t)height, alignment);
return scanlines;
}
@@ -1316,7 +1301,7 @@
return scanlines;
}
alignment = 16;
- scanlines = VIDEO_BUF_ALLIGN(((height + 1) >> 1), alignment);
+ scanlines = VIDEO_BUF_ALLIGN((size_t)((height + 1) >> 1), alignment);
return scanlines;
}
@@ -1407,27 +1392,30 @@
* NO_ERROR -- success
* none-zero failure code
*==========================================================================*/
-status_t CameraContext::createPreviewSurface(unsigned int width,
- unsigned int height,
- int32_t pixFormat)
+status_t CameraContext::createPreviewSurface(int width, int height, int32_t pixFormat)
{
int ret = NO_ERROR;
DisplayInfo dinfo;
sp<IBinder> display(SurfaceComposerClient::getBuiltInDisplay(
ISurfaceComposer::eDisplayIdMain));
SurfaceComposerClient::getDisplayInfo(display, &dinfo);
- unsigned int previewWidth, previewHeight;
+ uint32_t previewWidth, previewHeight;
- if ( dinfo.w < width ) {
- previewWidth = dinfo.w;
- } else {
- previewWidth = width;
+ if ((0 >= width) || (0 >= height)) {
+ printf("Bad preview surface size %dx%d\n", width, height);
+ return BAD_VALUE;
}
- if ( dinfo.h < height ) {
+ if ((int)dinfo.w < width) {
+ previewWidth = dinfo.w;
+ } else {
+ previewWidth = (unsigned int)width;
+ }
+
+ if ((int)dinfo.h < height) {
previewHeight = dinfo.h;
} else {
- previewHeight = height;
+ previewHeight = (unsigned int)height;
}
mClient = new SurfaceComposerClient();
@@ -1454,8 +1442,8 @@
if ( mCameraIndex == 0 )
ret |= mSurfaceControl->setPosition(0, 0);
else
- ret |= mSurfaceControl->setPosition(
- dinfo.w - previewWidth, dinfo.h - previewHeight);
+ ret |= mSurfaceControl->setPosition((float)(dinfo.w - previewWidth),
+ (float)(dinfo.h - previewHeight));
ret |= mSurfaceControl->setSize(previewWidth, previewHeight);
ret |= mSurfaceControl->show();
@@ -1523,7 +1511,7 @@
mPiPCapture(false),
mfmtMultiplier(1),
mSectionsRead(false),
- mSectionsAllocated(false),
+ mSectionsAllocated(0),
mSections(NULL),
mJEXIFTmp(NULL),
mHaveAll(false),
@@ -1959,7 +1947,7 @@
char fileName[100];
- sprintf(fileName, "/sdcard/vid_cam%d_%dx%d_%d.mpeg", mCameraIndex,
+ snprintf(fileName, 100, "/sdcard/vid_cam%d_%dx%d_%d.mpeg", mCameraIndex,
videoSize.width, videoSize.height, mVideoIdx++);
mVideoFd = open(fileName, O_CREAT | O_RDWR );
@@ -2590,9 +2578,9 @@
printf(" %c. Stop Preview\n",
Interpreter::STOP_PREVIEW_CMD);
printf(" %c. Preview size: %dx%d\n",
- Interpreter::CHANGE_PREVIEW_SIZE_CMD,
- currentPreviewSize.width,
- currentPreviewSize.height);
+ Interpreter::CHANGE_PREVIEW_SIZE_CMD,
+ currentPreviewSize.width,
+ currentPreviewSize.height);
printf(" %c. Video size: %dx%d\n",
Interpreter::CHANGE_VIDEO_SIZE_CMD,
currentVideoSize.width,
@@ -2617,15 +2605,13 @@
printf(" %c. Take picture in picture\n",
Interpreter::TAKEPICTURE_IN_PICTURE_CMD);
printf(" %c. Picture size: %dx%d\n",
- Interpreter::CHANGE_PICTURE_SIZE_CMD,
- currentPictureSize.width,
- currentPictureSize.height);
- printf(" %c. zsl: %s\n",
- Interpreter::ZSL_CMD, mParams.get(CameraContext::KEY_ZSL)?
- mParams.get(CameraContext::KEY_ZSL) : "NULL" );
+ Interpreter::CHANGE_PICTURE_SIZE_CMD,
+ currentPictureSize.width,
+ currentPictureSize.height);
+ printf(" %c. zsl: %s\n", Interpreter::ZSL_CMD, mParams.get(CameraContext::KEY_ZSL) ?
+ mParams.get(CameraContext::KEY_ZSL) : "NULL");
- printf("\n");
- printf(" Choice: ");
+ printf("\n Choice: ");
}
/*===========================================================================
@@ -2735,14 +2721,14 @@
mTestContext->mViVVid.VideoSizes[0].height >=
mTestContext->mViVVid.VideoSizes[1].width *
mTestContext->mViVVid.VideoSizes[1].height) {
- sprintf(fileName, "/sdcard/ViV_vid_%dx%d_%d.mp4",
+ snprintf(fileName, 100, "/sdcard/ViV_vid_%dx%d_%d.mp4",
mTestContext->mViVVid.VideoSizes[0].width,
mTestContext->mViVVid.VideoSizes[0].height,
mTestContext->mViVVid.ViVIdx++);
format->setInt32("width", mTestContext->mViVVid.VideoSizes[0].width);
format->setInt32("height", mTestContext->mViVVid.VideoSizes[0].height);
} else {
- sprintf(fileName, "/sdcard/ViV_vid_%dx%d_%d.mp4",
+ snprintf(fileName, 100, "/sdcard/ViV_vid_%dx%d_%d.mp4",
mTestContext->mViVVid.VideoSizes[1].width,
mTestContext->mViVVid.VideoSizes[1].height,
mTestContext->mViVVid.ViVIdx++);
@@ -2884,7 +2870,7 @@
}
fseek(fh, 0, SEEK_END);
- int len = ftell(fh);
+ size_t len = (size_t)ftell(fh);
rewind(fh);
if( !len ) {
@@ -3041,7 +3027,7 @@
} while ( i < camera[0]->getNumberOfCameras() ) ;
if (i < camera[0]->getNumberOfCameras() ) {
- for ( size_t j = 0 ; j < mAvailableCameras.size() ; j++ ) {
+ for (size_t j = 0; j < mAvailableCameras.size(); j++) {
camera[j] = mAvailableCameras.itemAt(j);
camera[j]->closeCamera();
camera[j].clear();
@@ -3064,7 +3050,7 @@
{
delete mInterpreter;
- for ( size_t j = 0 ; j < mAvailableCameras.size() ; j++ ) {
+ for (size_t j = 0; j < mAvailableCameras.size(); j++) {
camera[j] = mAvailableCameras.itemAt(j);
camera[j]->closeCamera();
camera[j].clear();
@@ -3082,7 +3068,7 @@
*
* RETURN : Number of cameras
*==========================================================================*/
-int32_t TestContext::GetCamerasNum()
+size_t TestContext::GetCamerasNum()
{
return mAvailableCameras.size();
}
@@ -3234,8 +3220,7 @@
mSaveCurrentCameraIndex = mCurrentCameraIndex;
for ( size_t i = 0; i < mAvailableCameras.size(); i++ ) {
mCurrentCameraIndex = i;
- currentCamera = mAvailableCameras.itemAt(
- mCurrentCameraIndex);
+ currentCamera = mAvailableCameras.itemAt(mCurrentCameraIndex);
currentCamera->enablePiPCapture();
stat = currentCamera->takePicture();
}
@@ -3327,7 +3312,7 @@
case Interpreter::DELAY:
{
if ( command.arg )
- usleep(1000 * atoi(command.arg));
+ usleep(1000LU * (long unsigned int)atoi(command.arg));
}
break;
diff --git a/QCamera2/HAL/test/qcamera_test.h b/QCamera2/HAL/test/qcamera_test.h
index 3832d5b..3de57c9 100644
--- a/QCamera2/HAL/test/qcamera_test.h
+++ b/QCamera2/HAL/test/qcamera_test.h
@@ -55,7 +55,7 @@
typedef struct {
unsigned char * Data;
int Type;
- unsigned Size;
+ size_t Size;
} Sections_t;
public:
@@ -96,7 +96,7 @@
status_t unconfigureRecorder();
Sections_t *FindSection(int SectionType);
status_t ReadSectionsFromBuffer (unsigned char *buffer,
- unsigned int buffer_size, ReadMode_t ReadMode);
+ size_t buffer_size, ReadMode_t ReadMode);
virtual IBinder* onAsBinder();
void setTestCtxInstance(TestContext *instance);
@@ -134,9 +134,7 @@
private:
- status_t createPreviewSurface(unsigned int width,
- unsigned int height,
- int32_t pixFormat);
+ status_t createPreviewSurface(int width, int height, int32_t pixFormat);
status_t destroyPreviewSurface();
status_t saveFile(const sp<IMemory>& mem, String8 path);
@@ -158,11 +156,11 @@
bool mDoPrintMenu;
bool mPiPCapture;
static int mPiPIdx;
- int mfmtMultiplier;
+ unsigned int mfmtMultiplier;
int mWidthTmp;
int mHeightTmp;
- int mSectionsRead;
- int mSectionsAllocated;
+ size_t mSectionsRead;
+ size_t mSectionsAllocated;
Sections_t * mSections;
Sections_t * mJEXIFTmp;
Sections_t mJEXIFSection;
@@ -180,9 +178,9 @@
SkBitmap skBMtmp;
sp<IMemory> PiPPtrTmp;
- int mCurrentPreviewSizeIdx;
- int mCurrentPictureSizeIdx;
- int mCurrentVideoSizeIdx;
+ size_t mCurrentPreviewSizeIdx;
+ size_t mCurrentPictureSizeIdx;
+ size_t mCurrentVideoSizeIdx;
Vector<Size> mSupportedPreviewSizes;
Vector<Size> mSupportedPictureSizes;
Vector<Size> mSupportedVideoSizes;
@@ -285,7 +283,7 @@
static const int numberOfCommands;
bool mUseScript;
- int mCmdIndex;
+ size_t mCmdIndex;
char *mScript;
Vector<Command> mCommands;
TestContext *mTestContext;
@@ -300,7 +298,7 @@
TestContext();
~TestContext();
- int32_t GetCamerasNum();
+ size_t GetCamerasNum();
status_t FunctionalTest();
status_t AddScriptFromFile(const char *scriptFile);
void setViVSize(Size VideoSize, int camIndex);
@@ -312,8 +310,8 @@
private:
sp<CameraContext> camera[MAX_CAM_INSTANCES];
char GetNextCmd(sp<qcamera::CameraContext> currentCamera);
- int mCurrentCameraIndex;
- int mSaveCurrentCameraIndex;
+ size_t mCurrentCameraIndex;
+ size_t mSaveCurrentCameraIndex;
Vector< sp<qcamera::CameraContext> > mAvailableCameras;
bool mTestRunning;
Interpreter *mInterpreter;
diff --git a/QCamera2/HAL/wrapper/QualcommCamera.cpp b/QCamera2/HAL/wrapper/QualcommCamera.cpp
index e0bee36..a2a02bc 100644
--- a/QCamera2/HAL/wrapper/QualcommCamera.cpp
+++ b/QCamera2/HAL/wrapper/QualcommCamera.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -131,9 +131,9 @@
camera_device *device = NULL;
if(module && id && hw_device) {
- int cameraId = atoi(id);
-
if (!strcmp(module->name, camera_common.name)) {
+ int cameraId = atoi(id);
+
camera_hardware_t *camHal =
(camera_hardware_t *) malloc(sizeof (camera_hardware_t));
if(!camHal) {
@@ -143,7 +143,7 @@
}
/* we have the camera_hardware obj malloced */
memset(camHal, 0, sizeof (camera_hardware_t));
- camHal->hardware = new QCamera2HardwareInterface(cameraId);
+ camHal->hardware = new QCamera2HardwareInterface((uint32_t)cameraId);
if (camHal->hardware) {
camHal->cameraId = cameraId;
device = &camHal->hw_dev;
diff --git a/QCamera2/stack/mm-camera-interface/Android.mk b/QCamera2/stack/mm-camera-interface/Android.mk
index f677cfb..f28f347 100755
--- a/QCamera2/stack/mm-camera-interface/Android.mk
+++ b/QCamera2/stack/mm-camera-interface/Android.mk
@@ -43,7 +43,7 @@
LOCAL_CFLAGS += -include bionic/libc/kernel/common/linux/socket.h
LOCAL_CFLAGS += -include bionic/libc/kernel/common/linux/un.h
endif
-LOCAL_CFLAGS += -Wall -Werror
+LOCAL_CFLAGS += -Wall -Wextra -Werror
LOCAL_SRC_FILES := $(MM_CAM_FILES)
diff --git a/QCamera2/stack/mm-camera-interface/inc/mm_camera.h b/QCamera2/stack/mm-camera-interface/inc/mm_camera.h
index 5a8988d..3828a6b 100644
--- a/QCamera2/stack/mm-camera-interface/inc/mm_camera.h
+++ b/QCamera2/stack/mm-camera-interface/inc/mm_camera.h
@@ -316,7 +316,7 @@
uint32_t buf_idx;
int32_t plane_idx;
int fd;
- uint32_t size;
+ size_t size;
} mm_evt_paylod_map_stream_buf_t;
typedef struct {
@@ -469,7 +469,7 @@
/* send msg throught domain socket for fd mapping */
extern int32_t mm_camera_util_sendmsg(mm_camera_obj_t *my_obj,
void *msg,
- uint32_t buf_size,
+ size_t buf_size,
int sendfd);
/* Check if hardware target is A family */
uint8_t mm_camera_util_chip_is_a_family(void);
@@ -491,7 +491,7 @@
extern int32_t mm_camera_map_buf(mm_camera_obj_t *my_obj,
uint8_t buf_type,
int fd,
- uint32_t size);
+ size_t size);
extern int32_t mm_camera_unmap_buf(mm_camera_obj_t *my_obj,
uint8_t buf_type);
extern int32_t mm_camera_do_auto_focus(mm_camera_obj_t *my_obj);
@@ -559,7 +559,7 @@
uint32_t buf_idx,
int32_t plane_idx,
int fd,
- uint32_t size);
+ size_t size);
extern int32_t mm_camera_unmap_stream_buf(mm_camera_obj_t *my_obj,
uint32_t ch_id,
uint32_t stream_id,
@@ -603,7 +603,7 @@
uint32_t frame_idx,
int32_t plane_idx,
int fd,
- uint32_t size);
+ size_t size);
extern int32_t mm_stream_unmap_buf(mm_stream_t *my_obj,
uint8_t buf_type,
uint32_t frame_idx,
@@ -644,5 +644,5 @@
extern int32_t mm_camera_channel_advanced_capture(mm_camera_obj_t *my_obj,
mm_camera_advanced_capture_t advanced_capturetype,
uint32_t ch_id,
- int32_t start_flag);
+ uint32_t start_flag);
#endif /* __MM_CAMERA_H__ */
diff --git a/QCamera2/stack/mm-camera-interface/inc/mm_camera_sock.h b/QCamera2/stack/mm-camera-interface/inc/mm_camera_sock.h
index 8889e3c..e6f42be 100755
--- a/QCamera2/stack/mm-camera-interface/inc/mm_camera_sock.h
+++ b/QCamera2/stack/mm-camera-interface/inc/mm_camera_sock.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,18 +31,26 @@
#define __MM_CAMERA_SOCKET_H__
#include <inttypes.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <sys/un.h>
typedef enum {
MM_CAMERA_SOCK_TYPE_UDP,
MM_CAMERA_SOCK_TYPE_TCP,
} mm_camera_sock_type_t;
+typedef union {
+ struct sockaddr addr;
+ struct sockaddr_un addr_un;
+} mm_camera_sock_addr_t;
+
int mm_camera_socket_create(int cam_id, mm_camera_sock_type_t sock_type);
int mm_camera_socket_sendmsg(
int fd,
void *msg,
- uint32_t buf_size,
+ size_t buf_size,
int sendfd);
int mm_camera_socket_recvmsg(
diff --git a/QCamera2/stack/mm-camera-interface/src/cam_intf.c b/QCamera2/stack/mm-camera-interface/src/cam_intf.c
index 1e08dc2..1349ea6 100644
--- a/QCamera2/stack/mm-camera-interface/src/cam_intf.c
+++ b/QCamera2/stack/mm-camera-interface/src/cam_intf.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -33,9 +33,10 @@
void *table_ptr)
{
parm_buffer_new_t *TABLE_PTR = (parm_buffer_new_t *)table_ptr;
- int32_t j = 0, i = TABLE_PTR->num_entry;
- parm_entry_type_new_t *curr_param =
- (parm_entry_type_new_t *)&TABLE_PTR->entry[0];
+ void *tmp_p;
+ size_t j = 0, i = TABLE_PTR->num_entry;
+ tmp_p = (void *) &TABLE_PTR->entry[0];
+ parm_entry_type_new_t *curr_param = (parm_entry_type_new_t *) tmp_p;
for (j = 0; j < i; j++) {
if (PARAM_ID == curr_param->entry_type) {
@@ -43,7 +44,8 @@
}
curr_param = GET_NEXT_PARAM(curr_param, parm_entry_type_new_t);
}
- curr_param = (parm_entry_type_new_t *)&TABLE_PTR->entry[0];
+ tmp_p = (void *) &TABLE_PTR->entry[0];
+ curr_param = (parm_entry_type_new_t *) tmp_p;
return (void *)&curr_param->data[0]; //should not be coming here
//this is just to prevent a crash
//for the caller
diff --git a/QCamera2/stack/mm-camera-interface/src/mm_camera.c b/QCamera2/stack/mm-camera-interface/src/mm_camera.c
index 915fed3..8f268fd 100644
--- a/QCamera2/stack/mm-camera-interface/src/mm_camera.c
+++ b/QCamera2/stack/mm-camera-interface/src/mm_camera.c
@@ -249,13 +249,13 @@
int32_t rc = 0;
int8_t n_try=MM_CAMERA_DEV_OPEN_TRIES;
uint8_t sleep_msec=MM_CAMERA_DEV_OPEN_RETRY_SLEEP;
- unsigned int cam_idx = 0;
+ int cam_idx = 0;
CDBG("%s: begin\n", __func__);
snprintf(dev_name, sizeof(dev_name), "/dev/%s",
mm_camera_util_get_dev_name(my_obj->my_hdl));
- sscanf(dev_name, "/dev/video%u", &cam_idx);
+ sscanf(dev_name, "/dev/video%d", &cam_idx);
CDBG_ERROR("%s: dev name = %s, cam_idx = %d", __func__, dev_name, cam_idx);
do{
@@ -268,7 +268,7 @@
}
CDBG("%s:failed with I/O error retrying after %d milli-seconds",
__func__, sleep_msec);
- usleep(sleep_msec * 1000);
+ usleep(sleep_msec * 1000U);
}while (n_try > 0);
if (my_obj->ctrl_fd <= 0) {
@@ -290,7 +290,7 @@
}
CDBG("%s:failed with I/O error retrying after %d milli-seconds",
__func__, sleep_msec);
- usleep(sleep_msec * 1000);
+ usleep(sleep_msec * 1000U);
} while (n_try > 0);
if (my_obj->ds_fd <= 0) {
@@ -891,7 +891,7 @@
mm_channel_fsm_fn(ch_obj,
MM_CHANNEL_EVT_ADD_STREAM,
NULL,
- (void*)&s_hdl);
+ (void *)&s_hdl);
} else {
pthread_mutex_unlock(&my_obj->cam_lock);
}
@@ -928,7 +928,7 @@
rc = mm_channel_fsm_fn(ch_obj,
MM_CHANNEL_EVT_DEL_STREAM,
- (void*)stream_id,
+ (void *)&stream_id,
NULL);
} else {
pthread_mutex_unlock(&my_obj->cam_lock);
@@ -1041,7 +1041,7 @@
payload.config = config;
rc = mm_channel_fsm_fn(ch_obj,
MM_CHANNEL_EVT_CONFIG_STREAM,
- (void*)&payload,
+ (void *)&payload,
NULL);
} else {
pthread_mutex_unlock(&my_obj->cam_lock);
@@ -1148,7 +1148,7 @@
rc = mm_channel_fsm_fn(ch_obj,
MM_CHANNEL_EVT_REQUEST_SUPER_BUF,
- (void*)num_buf_requested,
+ (void *)&num_buf_requested,
NULL);
} else {
pthread_mutex_unlock(&my_obj->cam_lock);
@@ -1218,7 +1218,7 @@
rc = mm_channel_fsm_fn(ch_obj,
MM_CHANNEL_EVT_FLUSH_SUPER_BUF_QUEUE,
- (void *)frame_idx,
+ (void *)&frame_idx,
NULL);
} else {
pthread_mutex_unlock(&my_obj->cam_lock);
@@ -1255,7 +1255,7 @@
rc = mm_channel_fsm_fn(ch_obj,
MM_CHANNEL_EVT_CONFIG_NOTIFY_MODE,
- (void *)notify_mode,
+ (void *)¬ify_mode,
NULL);
} else {
pthread_mutex_unlock(&my_obj->cam_lock);
@@ -1441,7 +1441,7 @@
uint32_t buf_idx,
int32_t plane_idx,
int fd,
- uint32_t size)
+ size_t size)
{
int32_t rc = -1;
mm_evt_paylod_map_stream_buf_t payload;
@@ -1591,7 +1591,7 @@
*==========================================================================*/
void mm_camera_util_wait_for_event(mm_camera_obj_t *my_obj,
uint32_t evt_mask,
- int32_t *status)
+ uint32_t *status)
{
pthread_mutex_lock(&my_obj->evt_lock);
while (!(my_obj->evt_rcvd.server_event_type & evt_mask)) {
@@ -1620,11 +1620,11 @@
*==========================================================================*/
int32_t mm_camera_util_sendmsg(mm_camera_obj_t *my_obj,
void *msg,
- uint32_t buf_size,
+ size_t buf_size,
int sendfd)
{
int32_t rc = -1;
- int32_t status;
+ uint32_t status;
/* need to lock msg_lock, since sendmsg until reposonse back is deemed as one operation*/
pthread_mutex_lock(&my_obj->msg_lock);
@@ -1660,7 +1660,7 @@
int32_t mm_camera_map_buf(mm_camera_obj_t *my_obj,
uint8_t buf_type,
int fd,
- uint32_t size)
+ size_t size)
{
int32_t rc = 0;
cam_sock_packet_t packet;
@@ -1735,8 +1735,8 @@
}
rc = ioctl(fd, VIDIOC_S_CTRL, &control);
- CDBG("%s: fd=%d, S_CTRL, id=0x%x, value = 0x%x, rc = %d\n",
- __func__, fd, id, (uint32_t)value, rc);
+ CDBG("%s: fd=%d, S_CTRL, id=0x%x, value = %p, rc = %d\n",
+ __func__, fd, id, value, rc);
if (value != NULL) {
*value = control.value;
}
@@ -1793,7 +1793,7 @@
int32_t mm_camera_channel_advanced_capture(mm_camera_obj_t *my_obj,
mm_camera_advanced_capture_t advanced_capture_type,
uint32_t ch_id,
- int32_t start_flag)
+ uint32_t start_flag)
{
CDBG("%s: E",__func__);
int32_t rc = -1;
@@ -1807,31 +1807,31 @@
case MM_CAMERA_AF_BRACKETING:
rc = mm_channel_fsm_fn(ch_obj,
MM_CHANNEL_EVT_AF_BRACKETING,
- (void *)start_flag,
+ (void *)&start_flag,
NULL);
break;
case MM_CAMERA_AE_BRACKETING:
rc = mm_channel_fsm_fn(ch_obj,
MM_CHANNEL_EVT_AE_BRACKETING,
- (void *)start_flag,
+ (void *)&start_flag,
NULL);
break;
case MM_CAMERA_FLASH_BRACKETING:
rc = mm_channel_fsm_fn(ch_obj,
MM_CHANNEL_EVT_FLASH_BRACKETING,
- (void *)start_flag,
+ (void *)&start_flag,
NULL);
break;
case MM_CAMERA_MTF_BRACKETING:
rc = mm_channel_fsm_fn(ch_obj,
MM_CHANNEL_EVT_MTF_BRACKETING,
- (void *)start_flag,
+ (void *)&start_flag,
NULL);
break;
case MM_CAMERA_ZOOM_1X:
rc = mm_channel_fsm_fn(ch_obj,
MM_CHANNEL_EVT_ZOOM_1X,
- (void *)start_flag,
+ (void *)&start_flag,
NULL);
break;
default:
diff --git a/QCamera2/stack/mm-camera-interface/src/mm_camera_channel.c b/QCamera2/stack/mm-camera-interface/src/mm_camera_channel.c
index 933e32c..131d0e6 100644
--- a/QCamera2/stack/mm-camera-interface/src/mm_camera_channel.c
+++ b/QCamera2/stack/mm-camera-interface/src/mm_camera_channel.c
@@ -252,8 +252,8 @@
case MM_CAMERA_GENERIC_CMD_TYPE_AE_BRACKETING:
case MM_CAMERA_GENERIC_CMD_TYPE_AF_BRACKETING:
case MM_CAMERA_GENERIC_CMD_TYPE_MTF_BRACKETING: {
- int8_t start = cmd_cb->u.gen_cmd.payload[0];
- CDBG_HIGH("%s:%d] MM_CAMERA_GENERIC_CMDTYPE_AF_BRACKETING %d",
+ uint32_t start = cmd_cb->u.gen_cmd.payload[0];
+ CDBG_HIGH("%s:%d] MM_CAMERA_GENERIC_CMDTYPE_AF_BRACKETING %u",
__func__, __LINE__, start);
mm_channel_superbuf_flush(ch_obj,
&ch_obj->bundle.superbuf_queue, CAM_STREAM_TYPE_DEFAULT);
@@ -268,8 +268,8 @@
}
break;
case MM_CAMERA_GENERIC_CMD_TYPE_FLASH_BRACKETING: {
- int8_t start = cmd_cb->u.gen_cmd.payload[0];
- CDBG_HIGH("%s:%d] MM_CAMERA_GENERIC_CMDTYPE_FLASH_BRACKETING %d",
+ uint32_t start = cmd_cb->u.gen_cmd.payload[0];
+ CDBG_HIGH("%s:%d] MM_CAMERA_GENERIC_CMDTYPE_FLASH_BRACKETING %u",
__func__, __LINE__, start);
mm_channel_superbuf_flush(ch_obj,
&ch_obj->bundle.superbuf_queue, CAM_STREAM_TYPE_DEFAULT);
@@ -284,8 +284,8 @@
}
break;
case MM_CAMERA_GENERIC_CMD_TYPE_ZOOM_1X: {
- int8_t start = cmd_cb->u.gen_cmd.payload[0];
- CDBG_HIGH("%s:%d] MM_CAMERA_GENERIC_CMD_TYPE_ZOOM_1X %d",
+ uint32_t start = cmd_cb->u.gen_cmd.payload[0];
+ CDBG_HIGH("%s:%d] MM_CAMERA_GENERIC_CMD_TYPE_ZOOM_1X %u",
__func__, __LINE__, start);
mm_channel_superbuf_flush(ch_obj,
&ch_obj->bundle.superbuf_queue, CAM_STREAM_TYPE_DEFAULT);
@@ -503,7 +503,7 @@
break;
case MM_CHANNEL_EVT_DEL_STREAM:
{
- uint32_t s_id = (uint32_t)in_val;
+ uint32_t s_id = *((uint32_t *)in_val);
rc = mm_channel_del_stream(my_obj, s_id);
}
break;
@@ -616,7 +616,7 @@
break;
case MM_CHANNEL_EVT_REQUEST_SUPER_BUF:
{
- uint32_t num_buf_requested = (uint32_t)in_val;
+ uint32_t num_buf_requested = *((uint32_t *)in_val);
rc = mm_channel_request_super_buf(my_obj, num_buf_requested);
}
break;
@@ -627,7 +627,7 @@
break;
case MM_CHANNEL_EVT_FLUSH_SUPER_BUF_QUEUE:
{
- uint32_t frame_idx = (uint32_t)in_val;
+ uint32_t frame_idx = *((uint32_t *)in_val);
rc = mm_channel_flush_super_buf_queue(my_obj, frame_idx);
}
break;
@@ -643,7 +643,8 @@
break;
case MM_CHANNEL_EVT_CONFIG_NOTIFY_MODE:
{
- mm_camera_super_buf_notify_mode_t notify_mode = ( mm_camera_super_buf_notify_mode_t ) in_val;
+ mm_camera_super_buf_notify_mode_t notify_mode =
+ *((mm_camera_super_buf_notify_mode_t *)in_val);
rc = mm_channel_config_notify_mode(my_obj, notify_mode);
}
break;
@@ -701,7 +702,7 @@
case MM_CHANNEL_EVT_AF_BRACKETING:
{
CDBG_HIGH("MM_CHANNEL_EVT_AF_BRACKETING");
- int32_t start_flag = ( int32_t ) in_val;
+ uint32_t start_flag = *((uint32_t *)in_val);
mm_camera_generic_cmd_t gen_cmd;
gen_cmd.type = MM_CAMERA_GENERIC_CMD_TYPE_AF_BRACKETING;
gen_cmd.payload[0] = start_flag;
@@ -711,7 +712,7 @@
case MM_CHANNEL_EVT_MTF_BRACKETING:
{
CDBG_HIGH("MM_CHANNEL_EVT_MTF_BRACKETING");
- int32_t start_flag = ( int32_t ) in_val;
+ uint32_t start_flag = *((uint32_t *)in_val);
mm_camera_generic_cmd_t gen_cmd;
gen_cmd.type = MM_CAMERA_GENERIC_CMD_TYPE_MTF_BRACKETING;
gen_cmd.payload[0] = start_flag;
@@ -721,7 +722,7 @@
case MM_CHANNEL_EVT_AE_BRACKETING:
{
CDBG_HIGH("MM_CHANNEL_EVT_AE_BRACKETING");
- int32_t start_flag = ( int32_t ) in_val;
+ uint32_t start_flag = *((uint32_t *)in_val);
mm_camera_generic_cmd_t gen_cmd;
gen_cmd.type = MM_CAMERA_GENERIC_CMD_TYPE_AE_BRACKETING;
gen_cmd.payload[0] = start_flag;
@@ -731,7 +732,7 @@
case MM_CHANNEL_EVT_FLASH_BRACKETING:
{
CDBG_HIGH("MM_CHANNEL_EVT_FLASH_BRACKETING");
- int32_t start_flag = ( int32_t ) in_val;
+ uint32_t start_flag = *((uint32_t *)in_val);
mm_camera_generic_cmd_t gen_cmd;
gen_cmd.type = MM_CAMERA_GENERIC_CMD_TYPE_FLASH_BRACKETING;
gen_cmd.payload[0] = start_flag;
@@ -741,7 +742,7 @@
case MM_CHANNEL_EVT_ZOOM_1X:
{
CDBG_HIGH("MM_CHANNEL_EVT_ZOOM_1X");
- int32_t start_flag = ( int32_t ) in_val;
+ uint32_t start_flag = *((uint32_t *)in_val);
mm_camera_generic_cmd_t gen_cmd;
gen_cmd.type = MM_CAMERA_GENERIC_CMD_TYPE_ZOOM_1X;
gen_cmd.payload[0] = start_flag;
@@ -1900,7 +1901,7 @@
uint32_t i;
/* Set expected frame id to a future frame idx, large enough to wait
* for good_frame_idx_range, and small enough to still capture an image */
- const int max_future_frame_offset = 100;
+ const uint32_t max_future_frame_offset = 100U;
stream_obj = mm_channel_util_get_stream_by_handler(ch_obj,
buf_info->stream_id);
diff --git a/QCamera2/stack/mm-camera-interface/src/mm_camera_interface.c b/QCamera2/stack/mm-camera-interface/src/mm_camera_interface.c
index 56b0602..03ad57b 100644
--- a/QCamera2/stack/mm-camera-interface/src/mm_camera_interface.c
+++ b/QCamera2/stack/mm-camera-interface/src/mm_camera_interface.c
@@ -592,7 +592,7 @@
uint32_t stream_id,
uint32_t linked_ch_id)
{
- uint32_t id = 0;
+ int32_t id = 0;
mm_camera_obj_t * my_obj = NULL;
CDBG("%s : E handle = %d ch_id = %d",
@@ -604,7 +604,7 @@
if(my_obj) {
pthread_mutex_lock(&my_obj->cam_lock);
pthread_mutex_unlock(&g_intf_lock);
- id = mm_camera_link_stream(my_obj, ch_id, stream_id, linked_ch_id);
+ id = (int32_t)mm_camera_link_stream(my_obj, ch_id, stream_id, linked_ch_id);
} else {
pthread_mutex_unlock(&g_intf_lock);
}
@@ -1034,7 +1034,7 @@
static int32_t mm_camera_intf_map_buf(uint32_t camera_handle,
uint8_t buf_type,
int fd,
- uint32_t size)
+ size_t size)
{
int32_t rc = -1;
mm_camera_obj_t * my_obj = NULL;
@@ -1209,7 +1209,7 @@
uint32_t buf_idx,
int32_t plane_idx,
int fd,
- uint32_t size)
+ size_t size)
{
int32_t rc = -1;
mm_camera_obj_t * my_obj = NULL;
@@ -1302,13 +1302,12 @@
int dev_fd = 0;
struct media_device_info mdev_info;
int num_media_devices = 0;
- uint8_t num_cameras = 0;
+ size_t num_cameras = 0;
CDBG("%s : E", __func__);
/* lock the mutex */
while (1) {
char dev_name[32];
- int num_entities;
snprintf(dev_name, sizeof(dev_name), "/dev/media%d", num_media_devices);
dev_fd = open(dev_name, O_RDWR | O_NONBLOCK);
if (dev_fd <= 0) {
@@ -1332,12 +1331,12 @@
continue;
}
- num_entities = 1;
+ unsigned int num_entities = 1;
while (1) {
struct media_entity_desc entity;
- unsigned long temp;
- unsigned int mount_angle;
- unsigned int facing;
+ uint32_t temp;
+ uint32_t mount_angle;
+ uint32_t facing;
memset(&entity, 0, sizeof(entity));
entity.id = num_entities++;
@@ -1352,17 +1351,17 @@
temp = entity.flags >> 8;
mount_angle = (temp & 0xFF) * 90;
facing = (temp >> 8);
- ALOGD("index = %d flag = %x mount_angle = %d facing = %d\n"
- , num_cameras, (unsigned int)temp, (unsigned int)mount_angle,
- (unsigned int)facing);
- g_cam_ctrl.info[num_cameras].facing = facing;
- g_cam_ctrl.info[num_cameras].orientation = mount_angle;
+ ALOGD("index = %u flag = %x mount_angle = %u facing = %u\n",
+ (unsigned int)num_cameras, (unsigned int)temp,
+ (unsigned int)mount_angle, (unsigned int)facing);
+ g_cam_ctrl.info[num_cameras].facing = (int)facing;
+ g_cam_ctrl.info[num_cameras].orientation = (int)mount_angle;
num_cameras++;
continue;
}
}
- CDBG("%s: dev_info[id=%d,name='%s']\n",
+ CDBG("%s: dev_info[id=%zu,name='%s']\n",
__func__, num_cameras, g_cam_ctrl.video_dev_name[num_cameras]);
close(dev_fd);
@@ -1389,7 +1388,7 @@
int dev_fd = 0;
struct media_device_info mdev_info;
int num_media_devices = 0;
- uint8_t num_cameras = 0;
+ int8_t num_cameras = 0;
char subdev_name[32];
int32_t sd_fd = 0;
struct sensor_init_cfg_data cfg;
@@ -1404,7 +1403,7 @@
0x10 for mm-camera-interface
0x100 for mm-jpeg-interface */
property_get("persist.camera.hal.debug.mask", prop, "268435463"); // 0x10000007=268435463
- temp = atoi(prop);
+ temp = (uint32_t) atoi(prop);
log_level = ((temp >> 28) & 0xF);
debug_mask = (temp & HAL_DEBUG_MASK_MM_CAMERA_INTERFACE);
if (debug_mask > 0)
@@ -1423,7 +1422,7 @@
pthread_mutex_lock(&g_intf_lock);
while (1) {
- int32_t num_entities = 1;
+ uint32_t num_entities = 1U;
char dev_name[32];
snprintf(dev_name, sizeof(dev_name), "/dev/media%d", num_media_devices);
@@ -1488,8 +1487,9 @@
num_media_devices = 0;
while (1) {
+ uint32_t num_entities = 1U;
char dev_name[32];
- int num_entities;
+
snprintf(dev_name, sizeof(dev_name), "/dev/media%d", num_media_devices);
dev_fd = open(dev_name, O_RDWR | O_NONBLOCK);
if (dev_fd <= 0) {
@@ -1513,7 +1513,6 @@
continue;
}
- num_entities = 1;
while (1) {
struct media_entity_desc entity;
memset(&entity, 0, sizeof(entity));
@@ -1532,7 +1531,7 @@
}
CDBG("%s: dev_info[id=%d,name='%s']\n",
- __func__, num_cameras, g_cam_ctrl.video_dev_name[num_cameras]);
+ __func__, (int)num_cameras, g_cam_ctrl.video_dev_name[num_cameras]);
num_cameras++;
close(dev_fd);
@@ -1543,8 +1542,8 @@
get_sensor_info();
/* unlock the mutex */
pthread_mutex_unlock(&g_intf_lock);
- CDBG("%s: num_cameras=%d\n", __func__, g_cam_ctrl.num_cam);
- return g_cam_ctrl.num_cam;
+ CDBG("%s: num_cameras=%d\n", __func__, (int)g_cam_ctrl.num_cam);
+ return(uint8_t)g_cam_ctrl.num_cam;
}
struct camera_info *get_cam_info(uint32_t camera_id)
@@ -1583,7 +1582,8 @@
if(my_obj) {
pthread_mutex_lock(&my_obj->cam_lock);
pthread_mutex_unlock(&g_intf_lock);
- rc = mm_camera_channel_advanced_capture(my_obj, advanced_capture_type, ch_id, start_flag);
+ rc = mm_camera_channel_advanced_capture(my_obj, advanced_capture_type,
+ ch_id, (uint32_t)start_flag);
} else {
pthread_mutex_unlock(&g_intf_lock);
}
diff --git a/QCamera2/stack/mm-camera-interface/src/mm_camera_sock.c b/QCamera2/stack/mm-camera-interface/src/mm_camera_sock.c
index 58953d1..4daba33 100755
--- a/QCamera2/stack/mm-camera-interface/src/mm_camera_sock.c
+++ b/QCamera2/stack/mm-camera-interface/src/mm_camera_sock.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,9 +32,6 @@
#include <stdlib.h>
#include <errno.h>
#include <string.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <sys/un.h>
#include "mm_camera_dbg.h"
#include "mm_camera_sock.h"
@@ -51,7 +48,7 @@
int mm_camera_socket_create(int cam_id, mm_camera_sock_type_t sock_type)
{
int socket_fd;
- struct sockaddr_un sock_addr;
+ mm_camera_sock_addr_t sock_addr;
int sktype;
int rc;
@@ -74,16 +71,18 @@
}
memset(&sock_addr, 0, sizeof(sock_addr));
- sock_addr.sun_family = AF_UNIX;
- snprintf(sock_addr.sun_path, UNIX_PATH_MAX, "/data/cam_socket%d", cam_id);
- if((rc = connect(socket_fd, (struct sockaddr *) &sock_addr,
- sizeof(sock_addr))) != 0) {
+ sock_addr.addr_un.sun_family = AF_UNIX;
+ snprintf(sock_addr.addr_un.sun_path, UNIX_PATH_MAX, "/data/cam_socket%d",
+ cam_id);
+ rc = connect(socket_fd, &sock_addr.addr, sizeof(sock_addr.addr_un));
+ if (0 != rc) {
close(socket_fd);
socket_fd = -1;
CDBG_ERROR("%s: socket_fd=%d %s ", __func__, socket_fd, strerror(errno));
}
- CDBG("%s: socket_fd=%d %s", __func__, socket_fd, sock_addr.sun_path);
+ CDBG("%s: socket_fd=%d %s", __func__, socket_fd,
+ sock_addr.addr_un.sun_path);
return socket_fd;
}
@@ -115,7 +114,7 @@
int mm_camera_socket_sendmsg(
int fd,
void *msg,
- uint32_t buf_size,
+ size_t buf_size,
int sendfd)
{
struct msghdr msgh;
@@ -135,7 +134,8 @@
iov[0].iov_len = buf_size;
msgh.msg_iov = iov;
msgh.msg_iovlen = 1;
- CDBG("%s: iov_len=%d", __func__, iov[0].iov_len);
+ CDBG("%s: iov_len=%llu", __func__,
+ (unsigned long long int)iov[0].iov_len);
msgh.msg_control = NULL;
msgh.msg_controllen = 0;
@@ -207,7 +207,8 @@
return rcvd_len;
}
- CDBG("%s: msg_ctrl %p len %d", __func__, msgh.msg_control, msgh.msg_controllen);
+ CDBG("%s: msg_ctrl %p len %zu", __func__, msgh.msg_control,
+ msgh.msg_controllen);
if( ((cmsghp = CMSG_FIRSTHDR(&msgh)) != NULL) &&
(cmsghp->cmsg_len == CMSG_LEN(sizeof(int))) ) {
diff --git a/QCamera2/stack/mm-camera-interface/src/mm_camera_stream.c b/QCamera2/stack/mm-camera-interface/src/mm_camera_stream.c
index 7428802..e286c79 100644
--- a/QCamera2/stack/mm-camera-interface/src/mm_camera_stream.c
+++ b/QCamera2/stack/mm-camera-interface/src/mm_camera_stream.c
@@ -252,7 +252,7 @@
static void mm_stream_data_notify(void* user_data)
{
mm_stream_t *my_obj = (mm_stream_t*)user_data;
- int32_t idx = -1, i, rc;
+ int32_t i, rc;
uint8_t has_cb = 0;
mm_camera_buf_info_t buf_info;
@@ -271,11 +271,12 @@
}
memset(&buf_info, 0, sizeof(mm_camera_buf_info_t));
- rc = mm_stream_read_msm_frame(my_obj, &buf_info, my_obj->frame_offset.num_planes);
+ rc = mm_stream_read_msm_frame(my_obj, &buf_info,
+ (uint8_t)my_obj->frame_offset.num_planes);
if (rc != 0) {
return;
}
- idx = buf_info.buf->buf_idx;
+ uint32_t idx = buf_info.buf->buf_idx;
pthread_mutex_lock(&my_obj->cb_lock);
for (i = 0; i < MM_CAMERA_STREAM_BUF_CB_MAX; i++) {
@@ -296,7 +297,8 @@
/* need to add into super buf since bundled, add ref count */
my_obj->buf_status[idx].buf_refcnt++;
}
- my_obj->buf_status[idx].buf_refcnt += has_cb;
+ my_obj->buf_status[idx].buf_refcnt =
+ (uint8_t)(my_obj->buf_status[idx].buf_refcnt + has_cb);
pthread_mutex_unlock(&my_obj->buf_lock);
mm_stream_handle_rcvd_buf(my_obj, &buf_info, has_cb);
@@ -868,7 +870,7 @@
CDBG("%s: E, my_handle = 0x%x, fd = %d, state = %d",
__func__, my_obj->my_hdl, my_obj->fd, my_obj->state);
my_obj->stream_info = config->stream_info;
- my_obj->buf_num = config->stream_info->num_bufs;
+ my_obj->buf_num = (uint8_t) config->stream_info->num_bufs;
my_obj->mem_vtbl = config->mem_vtbl;
my_obj->padding_info = config->padding_info;
/* cd through intf always palced at idx 0 of buf_cb */
@@ -1036,7 +1038,7 @@
my_obj, my_obj->stream_info->stream_type);
}
pthread_mutex_unlock(&my_obj->buf_lock);
- int8_t idx = vb.index;
+ uint32_t idx = vb.index;
buf_info->buf = &my_obj->buf[idx];
buf_info->frame_idx = vb.sequence;
buf_info->stream_id = my_obj->my_hdl;
@@ -1225,14 +1227,18 @@
memset(&buffer, 0, sizeof(buffer));
buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
buffer.memory = V4L2_MEMORY_USERPTR;
- buffer.index = buf->buf_idx;
+ buffer.index = (__u32)buf->buf_idx;
buffer.m.planes = &planes[0];
- buffer.length = buf->num_planes;
+ buffer.length = (__u32)buf->num_planes;
- CDBG("%s:plane 0: stream_hdl=%d,fd=%d,frame idx=%d,num_planes = %d, offset = %d, data_offset = %d\n", __func__,
- buf->stream_id, buf->fd, buffer.index, buffer.length, buf->planes[0].reserved[0], buf->planes[0].data_offset);
- CDBG("%s:plane 1: stream_hdl=%d,fd=%d,frame idx=%d,num_planes = %d, offset = %d, data_offset = %d\n", __func__,
- buf->stream_id, buf->fd, buffer.index, buffer.length, buf->planes[1].reserved[0], buf->planes[1].data_offset);
+ CDBG("%s:plane 0: stream_hdl=%u,fd=%d,frame idx=%d,num_planes = %u, "
+ "offset = %d, data_offset = %d\n", __func__,
+ buf->stream_id, buf->fd, buffer.index, buffer.length,
+ buf->planes[0].reserved[0], buf->planes[0].data_offset);
+ CDBG("%s:plane 1: stream_hdl=%u,fd=%d,frame idx=%d,num_planes = %u, "
+ "offset = %d, data_offset = %d\n", __func__,
+ buf->stream_id, buf->fd, buffer.index, buffer.length,
+ buf->planes[1].reserved[0], buf->planes[1].data_offset);
if ( NULL != my_obj->mem_vtbl.invalidate_buf ) {
rc = my_obj->mem_vtbl.invalidate_buf(buffer.index,
@@ -1365,7 +1371,7 @@
uint32_t frame_idx,
int32_t plane_idx,
int fd,
- uint32_t size)
+ size_t size)
{
if (NULL == my_obj || NULL == my_obj->ch_obj || NULL == my_obj->ch_obj->cam_obj) {
CDBG_ERROR("%s: NULL obj of stream/channel/camera", __func__);
@@ -1458,7 +1464,7 @@
static int32_t mm_stream_map_buf_ops(uint32_t frame_idx,
int32_t plane_idx,
int fd,
- uint32_t size,
+ size_t size,
void *userdata)
{
mm_stream_t *my_obj = (mm_stream_t *)userdata;
@@ -1791,7 +1797,7 @@
scanline = PAD_TO_SIZE(dim->height, CAM_PAD_TO_2);
buf_planes->plane_info.mp[0].offset = 0;
- buf_planes->plane_info.mp[0].len = stride * scanline;
+ buf_planes->plane_info.mp[0].len = (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[0].offset_x = 0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
@@ -1803,7 +1809,7 @@
scanline = PAD_TO_SIZE(dim->height / 2, CAM_PAD_TO_2);
buf_planes->plane_info.mp[1].offset = 0;
buf_planes->plane_info.mp[1].len =
- stride * scanline;
+ (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[1].offset_x = 0;
buf_planes->plane_info.mp[1].offset_y = 0;
buf_planes->plane_info.mp[1].stride = stride;
@@ -1812,7 +1818,7 @@
buf_planes->plane_info.mp[1].height = dim->height / 2;
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
buf_planes->plane_info.mp[1].len,
CAM_PAD_TO_4K);
break;
@@ -1824,8 +1830,7 @@
scanline = PAD_TO_SIZE(dim->height, CAM_PAD_TO_32);
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(stride * scanline,
- CAM_PAD_TO_4K);
+ PAD_TO_SIZE((uint32_t)(stride * scanline), CAM_PAD_TO_4K);
buf_planes->plane_info.mp[0].offset_x = 0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
@@ -1837,8 +1842,7 @@
scanline = PAD_TO_SIZE(dim->height / 2, CAM_PAD_TO_32);
buf_planes->plane_info.mp[1].offset = 0;
buf_planes->plane_info.mp[1].len =
- PAD_TO_SIZE(stride * scanline,
- CAM_PAD_TO_4K);
+ PAD_TO_SIZE((uint32_t)(stride * scanline), CAM_PAD_TO_4K);
buf_planes->plane_info.mp[1].offset_x = 0;
buf_planes->plane_info.mp[1].offset_y = 0;
buf_planes->plane_info.mp[1].stride = stride;
@@ -1847,7 +1851,7 @@
buf_planes->plane_info.mp[1].height = dim->height / 2;
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
buf_planes->plane_info.mp[1].len,
CAM_PAD_TO_4K);
break;
@@ -1858,7 +1862,7 @@
stride = PAD_TO_SIZE(dim->width, CAM_PAD_TO_16);
scanline = PAD_TO_SIZE(dim->height, CAM_PAD_TO_2);
buf_planes->plane_info.mp[0].offset = 0;
- buf_planes->plane_info.mp[0].len = stride * scanline;
+ buf_planes->plane_info.mp[0].len = (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[0].offset_x = 0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
@@ -1870,7 +1874,7 @@
scanline = scanline / 2;
buf_planes->plane_info.mp[1].offset = 0;
buf_planes->plane_info.mp[1].len =
- stride * scanline;
+ (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[1].offset_x = 0;
buf_planes->plane_info.mp[1].offset_y = 0;
buf_planes->plane_info.mp[1].stride = stride;
@@ -1880,7 +1884,7 @@
buf_planes->plane_info.mp[2].offset = 0;
buf_planes->plane_info.mp[2].len =
- stride * scanline;
+ (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[2].offset_x = 0;
buf_planes->plane_info.mp[2].offset_y = 0;
buf_planes->plane_info.mp[2].stride = stride;
@@ -1889,7 +1893,7 @@
buf_planes->plane_info.mp[2].height = dim->height / 2;
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
buf_planes->plane_info.mp[1].len +
buf_planes->plane_info.mp[2].len,
CAM_PAD_TO_4K);
@@ -1902,7 +1906,7 @@
stride = PAD_TO_SIZE(dim->width, CAM_PAD_TO_16);
scanline = dim->height;
buf_planes->plane_info.mp[0].offset = 0;
- buf_planes->plane_info.mp[0].len = stride * scanline;
+ buf_planes->plane_info.mp[0].len = (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[0].offset_x = 0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
@@ -1911,7 +1915,7 @@
buf_planes->plane_info.mp[0].height = dim->height;
buf_planes->plane_info.mp[1].offset = 0;
- buf_planes->plane_info.mp[1].len = stride * scanline;
+ buf_planes->plane_info.mp[1].len = (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[1].offset_x = 0;
buf_planes->plane_info.mp[1].offset_y = 0;
buf_planes->plane_info.mp[1].stride = stride;
@@ -1920,7 +1924,7 @@
buf_planes->plane_info.mp[1].height = dim->height;
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
buf_planes->plane_info.mp[1].len,
CAM_PAD_TO_4K);
break;
@@ -1933,7 +1937,7 @@
buf_planes->plane_info.frame_len =
VENUS_BUFFER_SIZE(COLOR_FMT_NV12, dim->width, dim->height);
buf_planes->plane_info.num_planes = 2;
- buf_planes->plane_info.mp[0].len = stride * scanline;
+ buf_planes->plane_info.mp[0].len = (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].offset_x =0;
buf_planes->plane_info.mp[0].offset_y = 0;
@@ -1997,7 +2001,7 @@
stride = PAD_TO_SIZE(dim->width, CAM_PAD_TO_64);
scanline = PAD_TO_SIZE(dim->height, CAM_PAD_TO_64);
buf_planes->plane_info.mp[0].offset = 0;
- buf_planes->plane_info.mp[0].len = stride * scanline;
+ buf_planes->plane_info.mp[0].len = (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[0].offset_x = 0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
@@ -2009,7 +2013,7 @@
scanline = PAD_TO_SIZE(dim->height / 2, CAM_PAD_TO_64);
buf_planes->plane_info.mp[1].offset = 0;
buf_planes->plane_info.mp[1].len =
- stride * scanline;
+ (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[1].offset_x = 0;
buf_planes->plane_info.mp[1].offset_y = 0;
buf_planes->plane_info.mp[1].stride = stride;
@@ -2018,7 +2022,7 @@
buf_planes->plane_info.mp[1].height = dim->height / 2;
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
buf_planes->plane_info.mp[1].len,
CAM_PAD_TO_4K);
break;
@@ -2030,8 +2034,7 @@
scanline = PAD_TO_SIZE(dim->height, CAM_PAD_TO_32);
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(stride * scanline,
- CAM_PAD_TO_4K);
+ PAD_TO_SIZE((uint32_t)(stride * scanline), CAM_PAD_TO_4K);
buf_planes->plane_info.mp[0].offset_x = 0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
@@ -2043,8 +2046,7 @@
scanline = PAD_TO_SIZE(dim->height / 2, CAM_PAD_TO_32);
buf_planes->plane_info.mp[1].offset = 0;
buf_planes->plane_info.mp[1].len =
- PAD_TO_SIZE(stride * scanline,
- CAM_PAD_TO_4K);
+ PAD_TO_SIZE((uint32_t)(stride * scanline), CAM_PAD_TO_4K);
buf_planes->plane_info.mp[1].offset_x = 0;
buf_planes->plane_info.mp[1].offset_y = 0;
buf_planes->plane_info.mp[1].stride = stride;
@@ -2053,7 +2055,7 @@
buf_planes->plane_info.mp[1].height = dim->height / 2;
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
buf_planes->plane_info.mp[1].len,
CAM_PAD_TO_4K);
break;
@@ -2064,7 +2066,7 @@
stride = PAD_TO_SIZE(dim->width, CAM_PAD_TO_16);
scanline = PAD_TO_SIZE(dim->height, CAM_PAD_TO_2);
buf_planes->plane_info.mp[0].offset = 0;
- buf_planes->plane_info.mp[0].len = stride * scanline;
+ buf_planes->plane_info.mp[0].len = (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[0].offset_x = 0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
@@ -2076,7 +2078,7 @@
scanline = scanline / 2;
buf_planes->plane_info.mp[1].offset = 0;
buf_planes->plane_info.mp[1].len =
- stride * scanline;
+ (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[1].offset_x = 0;
buf_planes->plane_info.mp[1].offset_y = 0;
buf_planes->plane_info.mp[1].stride = stride;
@@ -2086,7 +2088,7 @@
buf_planes->plane_info.mp[2].offset = 0;
buf_planes->plane_info.mp[2].len =
- stride * scanline;
+ (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[2].offset_x = 0;
buf_planes->plane_info.mp[2].offset_y = 0;
buf_planes->plane_info.mp[2].stride = stride;
@@ -2095,7 +2097,7 @@
buf_planes->plane_info.mp[2].height = dim->height / 2;
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
buf_planes->plane_info.mp[1].len +
buf_planes->plane_info.mp[2].len,
CAM_PAD_TO_4K);
@@ -2108,7 +2110,7 @@
stride = PAD_TO_SIZE(dim->width, CAM_PAD_TO_16);
scanline = dim->height;
buf_planes->plane_info.mp[0].offset = 0;
- buf_planes->plane_info.mp[0].len = stride * scanline;
+ buf_planes->plane_info.mp[0].len = (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[0].offset_x = 0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
@@ -2117,7 +2119,7 @@
buf_planes->plane_info.mp[0].height = dim->height;
buf_planes->plane_info.mp[1].offset = 0;
- buf_planes->plane_info.mp[1].len = stride * scanline;
+ buf_planes->plane_info.mp[1].len = (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[1].offset_x = 0;
buf_planes->plane_info.mp[1].offset_y = 0;
buf_planes->plane_info.mp[1].stride = stride;
@@ -2126,7 +2128,7 @@
buf_planes->plane_info.mp[1].height = dim->height;
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
buf_planes->plane_info.mp[1].len,
CAM_PAD_TO_4K);
break;
@@ -2139,7 +2141,7 @@
buf_planes->plane_info.frame_len =
VENUS_BUFFER_SIZE(COLOR_FMT_NV12, dim->width, dim->height);
buf_planes->plane_info.num_planes = 2;
- buf_planes->plane_info.mp[0].len = stride * scanline;
+ buf_planes->plane_info.mp[0].len = (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].offset_x =0;
buf_planes->plane_info.mp[0].offset_y = 0;
@@ -2222,10 +2224,10 @@
buf_planes->plane_info.num_planes = 2;
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(stride * scanline,
+ PAD_TO_SIZE((uint32_t)(stride * scanline),
padding->plane_padding);
buf_planes->plane_info.mp[0].offset =
- PAD_TO_SIZE(offset_x + stride * offset_y,
+ PAD_TO_SIZE((uint32_t)(offset_x + stride * offset_y),
padding->plane_padding);
buf_planes->plane_info.mp[0].offset_x = offset_x;
buf_planes->plane_info.mp[0].offset_y = offset_y;
@@ -2236,10 +2238,10 @@
scanline = scanline / 2;
buf_planes->plane_info.mp[1].len =
- PAD_TO_SIZE(stride * scanline,
+ PAD_TO_SIZE((uint32_t)(stride * scanline),
padding->plane_padding);
buf_planes->plane_info.mp[1].offset =
- PAD_TO_SIZE(offset_x + stride * offset_y,
+ PAD_TO_SIZE((uint32_t)(offset_x + stride * offset_y),
padding->plane_padding);
buf_planes->plane_info.mp[1].offset_x = offset_x;
buf_planes->plane_info.mp[1].offset_y = offset_y;
@@ -2250,8 +2252,8 @@
buf_planes->plane_info.frame_len =
PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
- buf_planes->plane_info.mp[1].len,
- CAM_PAD_TO_4K);
+ buf_planes->plane_info.mp[1].len,
+ CAM_PAD_TO_4K);
if (stream_info->reprocess_config.pp_feature_config.feature_mask &
CAM_QCOM_FEATURE_TRUEPORTRAIT) {
@@ -2270,10 +2272,11 @@
buf_planes->plane_info.num_planes = 3;
buf_planes->plane_info.mp[0].offset =
- PAD_TO_SIZE(offset_x + stride * offset_y,
+ PAD_TO_SIZE((uint32_t)(offset_x + stride * offset_y),
padding->plane_padding);
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(stride * scanline, padding->plane_padding);
+ PAD_TO_SIZE((uint32_t)(stride * scanline),
+ padding->plane_padding);
buf_planes->plane_info.mp[0].offset_x = offset_x;
buf_planes->plane_info.mp[0].offset_y = offset_y;
buf_planes->plane_info.mp[0].stride = stride;
@@ -2284,10 +2287,11 @@
stride = PAD_TO_SIZE(stride / 2, CAM_PAD_TO_16);
scanline = scanline / 2;
buf_planes->plane_info.mp[1].offset =
- PAD_TO_SIZE(offset_x + stride * offset_y,
+ PAD_TO_SIZE((uint32_t)(offset_x + stride * offset_y),
padding->plane_padding);
buf_planes->plane_info.mp[1].len =
- PAD_TO_SIZE(stride * scanline, padding->plane_padding);
+ PAD_TO_SIZE((uint32_t)(stride * scanline),
+ padding->plane_padding);
buf_planes->plane_info.mp[1].offset_x = offset_x;
buf_planes->plane_info.mp[1].offset_y = offset_y;
buf_planes->plane_info.mp[1].stride = stride;
@@ -2296,10 +2300,11 @@
buf_planes->plane_info.mp[1].height = dim->height / 2;
buf_planes->plane_info.mp[2].offset =
- PAD_TO_SIZE(offset_x + stride * offset_y,
+ PAD_TO_SIZE((uint32_t)(offset_x + stride * offset_y),
padding->plane_padding);
buf_planes->plane_info.mp[2].len =
- PAD_TO_SIZE(stride * scanline, padding->plane_padding);
+ PAD_TO_SIZE((uint32_t)(stride * scanline),
+ padding->plane_padding);
buf_planes->plane_info.mp[2].offset_x = offset_x;
buf_planes->plane_info.mp[2].offset_y = offset_y;
buf_planes->plane_info.mp[2].stride = stride;
@@ -2308,7 +2313,7 @@
buf_planes->plane_info.mp[2].height = dim->height / 2;
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
buf_planes->plane_info.mp[1].len +
buf_planes->plane_info.mp[2].len,
CAM_PAD_TO_4K);
@@ -2318,9 +2323,10 @@
/* 2 planes: Y + CbCr */
buf_planes->plane_info.num_planes = 2;
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(stride * scanline, padding->plane_padding);
+ PAD_TO_SIZE((uint32_t)(stride * scanline),
+ padding->plane_padding);
buf_planes->plane_info.mp[0].offset =
- PAD_TO_SIZE(offset_x + stride * offset_y,
+ PAD_TO_SIZE((uint32_t)(offset_x + stride * offset_y),
padding->plane_padding);
buf_planes->plane_info.mp[0].offset_x = offset_x;
buf_planes->plane_info.mp[0].offset_y = offset_y;
@@ -2330,9 +2336,10 @@
buf_planes->plane_info.mp[0].height = dim->height;
buf_planes->plane_info.mp[1].len =
- PAD_TO_SIZE(stride * scanline, padding->plane_padding);
+ PAD_TO_SIZE((uint32_t)(stride * scanline),
+ padding->plane_padding);
buf_planes->plane_info.mp[1].offset =
- PAD_TO_SIZE(offset_x + stride * offset_y,
+ PAD_TO_SIZE((uint32_t)(offset_x + stride * offset_y),
padding->plane_padding);
buf_planes->plane_info.mp[1].offset_x = offset_x;
buf_planes->plane_info.mp[1].offset_y = offset_y;
@@ -2376,8 +2383,8 @@
cam_stream_buf_plane_info_t *buf_planes)
{
int32_t rc = 0;
- int stride = 0;
- int scanline = dim->height;
+ int32_t stride = 0;
+ int32_t scanline = dim->height;
switch (fmt) {
case CAM_FORMAT_YUV_RAW_8BIT_YUYV:
@@ -2392,14 +2399,16 @@
buf_planes->plane_info.num_planes = 1;
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(stride * scanline * 2, padding->plane_padding);
+ PAD_TO_SIZE((uint32_t)(stride * scanline * 2),
+ padding->plane_padding);
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
buf_planes->plane_info.mp[0].offset_x =0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
buf_planes->plane_info.mp[0].scanline = scanline;
- buf_planes->plane_info.mp[0].width = buf_planes->plane_info.mp[0].len;
+ buf_planes->plane_info.mp[0].width =
+ (int32_t)buf_planes->plane_info.mp[0].len;
buf_planes->plane_info.mp[0].height = 1;
break;
case CAM_FORMAT_BAYER_QCOM_RAW_8BPP_GBRG:
@@ -2428,14 +2437,15 @@
buf_planes->plane_info.num_planes = 1;
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(stride * scanline, padding->plane_padding);
+ PAD_TO_SIZE((uint32_t)(stride * scanline),
+ padding->plane_padding);
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
buf_planes->plane_info.mp[0].offset_x =0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
buf_planes->plane_info.mp[0].scanline = scanline;
- buf_planes->plane_info.mp[0].width = buf_planes->plane_info.mp[0].len;
+ buf_planes->plane_info.mp[0].width = (int32_t)buf_planes->plane_info.mp[0].len;
buf_planes->plane_info.mp[0].height = 1;
break;
case CAM_FORMAT_BAYER_QCOM_RAW_10BPP_GBRG:
@@ -2451,14 +2461,15 @@
buf_planes->plane_info.num_planes = 1;
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(stride * scanline * 8 / 6, padding->plane_padding);
+ PAD_TO_SIZE((uint32_t)(stride * scanline * 8 / 6),
+ padding->plane_padding);
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
buf_planes->plane_info.mp[0].offset_x =0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
buf_planes->plane_info.mp[0].scanline = scanline;
- buf_planes->plane_info.mp[0].width = buf_planes->plane_info.mp[0].len;
+ buf_planes->plane_info.mp[0].width = (int32_t)buf_planes->plane_info.mp[0].len;
buf_planes->plane_info.mp[0].height = 1;
break;
case CAM_FORMAT_BAYER_QCOM_RAW_12BPP_GBRG:
@@ -2474,14 +2485,15 @@
buf_planes->plane_info.num_planes = 1;
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(stride * scanline * 8 / 5, padding->plane_padding);
+ PAD_TO_SIZE((uint32_t)(stride * scanline * 8 / 5),
+ padding->plane_padding);
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
buf_planes->plane_info.mp[0].offset_x =0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
buf_planes->plane_info.mp[0].scanline = scanline;
- buf_planes->plane_info.mp[0].width = buf_planes->plane_info.mp[0].len;
+ buf_planes->plane_info.mp[0].width = (int32_t)buf_planes->plane_info.mp[0].len;
buf_planes->plane_info.mp[0].height = 1;
break;
case CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GBRG:
@@ -2497,14 +2509,15 @@
buf_planes->plane_info.num_planes = 1;
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(stride * scanline, padding->plane_padding);
+ PAD_TO_SIZE((uint32_t)(stride * scanline),
+ padding->plane_padding);
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
buf_planes->plane_info.mp[0].offset_x =0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
buf_planes->plane_info.mp[0].scanline = scanline;
- buf_planes->plane_info.mp[0].width = buf_planes->plane_info.mp[0].len;
+ buf_planes->plane_info.mp[0].width = (int32_t)buf_planes->plane_info.mp[0].len;
buf_planes->plane_info.mp[0].height = 1;
break;
case CAM_FORMAT_BAYER_MIPI_RAW_12BPP_GBRG:
@@ -2520,14 +2533,15 @@
buf_planes->plane_info.num_planes = 1;
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(stride * scanline * 3 / 2, padding->plane_padding);
+ PAD_TO_SIZE((uint32_t)(stride * scanline * 3 / 2),
+ padding->plane_padding);
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
buf_planes->plane_info.mp[0].offset_x =0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
buf_planes->plane_info.mp[0].scanline = scanline;
- buf_planes->plane_info.mp[0].width = buf_planes->plane_info.mp[0].len;
+ buf_planes->plane_info.mp[0].width = (int32_t)buf_planes->plane_info.mp[0].len;
buf_planes->plane_info.mp[0].height = 1;
break;
case CAM_FORMAT_BAYER_IDEAL_RAW_PLAIN16_8BPP_GBRG:
@@ -2547,14 +2561,15 @@
buf_planes->plane_info.num_planes = 1;
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(stride * scanline * 2, padding->plane_padding);
+ PAD_TO_SIZE((uint32_t)(stride * scanline * 2),
+ padding->plane_padding);
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len, CAM_PAD_TO_4K);
buf_planes->plane_info.mp[0].offset_x =0;
buf_planes->plane_info.mp[0].offset_y = 0;
buf_planes->plane_info.mp[0].stride = stride;
buf_planes->plane_info.mp[0].scanline = scanline;
- buf_planes->plane_info.mp[0].width = buf_planes->plane_info.mp[0].len;
+ buf_planes->plane_info.mp[0].width = (int32_t)buf_planes->plane_info.mp[0].len;
buf_planes->plane_info.mp[0].height = 1;
break;
default:
@@ -2594,7 +2609,7 @@
buf_planes->plane_info.frame_len =
VENUS_BUFFER_SIZE(COLOR_FMT_NV12, dim->width, dim->height);
buf_planes->plane_info.num_planes = 2;
- buf_planes->plane_info.mp[0].len = stride * scanline;
+ buf_planes->plane_info.mp[0].len = (uint32_t)(stride * scanline);
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].offset_x =0;
buf_planes->plane_info.mp[0].offset_y = 0;
@@ -2627,7 +2642,7 @@
stride = dim->width;
scanline = dim->height;
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(stride * scanline, CAM_PAD_TO_2K);
+ PAD_TO_SIZE((uint32_t)(stride * scanline), CAM_PAD_TO_2K);
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].offset_x =0;
buf_planes->plane_info.mp[0].offset_y = 0;
@@ -2639,7 +2654,7 @@
stride = dim->width;
scanline = dim->height / 2;
buf_planes->plane_info.mp[1].len =
- PAD_TO_SIZE(stride * scanline, CAM_PAD_TO_2K);
+ PAD_TO_SIZE((uint32_t)(stride * scanline), CAM_PAD_TO_2K);
buf_planes->plane_info.mp[1].offset = 0;
buf_planes->plane_info.mp[1].offset_x =0;
buf_planes->plane_info.mp[1].offset_y = 0;
@@ -2649,7 +2664,7 @@
buf_planes->plane_info.mp[0].height = dim->height / 2;
buf_planes->plane_info.frame_len =
- PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
+ PAD_TO_SIZE(buf_planes->plane_info.mp[0].len +
buf_planes->plane_info.mp[1].len,
CAM_PAD_TO_4K);
@@ -2680,7 +2695,8 @@
buf_planes->plane_info.num_planes = 1;
buf_planes->plane_info.mp[0].offset = 0;
buf_planes->plane_info.mp[0].len =
- PAD_TO_SIZE(dim->width * dim->height, padding->plane_padding);
+ PAD_TO_SIZE((uint32_t)(dim->width * dim->height),
+ padding->plane_padding);
buf_planes->plane_info.frame_len =
buf_planes->plane_info.mp[0].len;
@@ -2911,10 +2927,10 @@
memset(&msm_fmt, 0, sizeof(msm_fmt));
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
msm_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
- msm_fmt.width = my_obj->stream_info->dim.width;
- msm_fmt.height = my_obj->stream_info->dim.height;
+ msm_fmt.width = (unsigned int)my_obj->stream_info->dim.width;
+ msm_fmt.height = (unsigned int)my_obj->stream_info->dim.height;
msm_fmt.pixelformat = mm_stream_get_v4l2_fmt(my_obj->stream_info->fmt);
- msm_fmt.num_planes = my_obj->frame_offset.num_planes;
+ msm_fmt.num_planes = (unsigned char)my_obj->frame_offset.num_planes;
for (i = 0; i < msm_fmt.num_planes; i++) {
msm_fmt.plane_sizes[i] = my_obj->frame_offset.mp[i].len;
}
diff --git a/QCamera2/stack/mm-camera-interface/src/mm_camera_thread.c b/QCamera2/stack/mm-camera-interface/src/mm_camera_thread.c
index 5754a31..758fd14 100644
--- a/QCamera2/stack/mm-camera-interface/src/mm_camera_thread.c
+++ b/QCamera2/stack/mm-camera-interface/src/mm_camera_thread.c
@@ -61,7 +61,7 @@
} mm_camera_poll_task_state_type_t;
typedef struct {
- uint8_t cmd;
+ uint32_t cmd;
mm_camera_event_t event;
} mm_camera_sig_evt_t;
@@ -85,7 +85,6 @@
/* send through pipe */
/* get the mutex */
mm_camera_sig_evt_t cmd_evt;
- int len;
CDBG("%s: E cmd = %d", __func__,cmd);
memset(&cmd_evt, 0, sizeof(cmd_evt));
@@ -95,14 +94,16 @@
poll_cb->status = FALSE;
/* send cmd to worker */
- len = write(poll_cb->pfds[1], &cmd_evt, sizeof(cmd_evt));
+ ssize_t len = write(poll_cb->pfds[1], &cmd_evt, sizeof(cmd_evt));
if (len < 1) {
- CDBG_ERROR("%s: len = %d, errno = %d", __func__, len, errno);
+ CDBG_ERROR("%s: len = %lld, errno = %d", __func__,
+ (long long int)len, errno);
/* Avoid waiting for the signal */
pthread_mutex_unlock(&poll_cb->mutex);
return 0;
}
- CDBG("%s: begin IN mutex write done, len = %d", __func__, len);
+ CDBG("%s: begin IN mutex write done, len = %lld", __func__,
+ (long long int)len);
pthread_mutex_unlock(&poll_cb->mutex);
CDBG("%s: X", __func__);
return 0;
@@ -130,7 +131,6 @@
/* send through pipe */
/* get the mutex */
mm_camera_sig_evt_t cmd_evt;
- int len;
CDBG("%s: E cmd = %d", __func__,cmd);
memset(&cmd_evt, 0, sizeof(cmd_evt));
@@ -140,14 +140,16 @@
poll_cb->status = FALSE;
/* send cmd to worker */
- len = write(poll_cb->pfds[1], &cmd_evt, sizeof(cmd_evt));
+ ssize_t len = write(poll_cb->pfds[1], &cmd_evt, sizeof(cmd_evt));
if(len < 1) {
- CDBG_ERROR("%s: len = %d, errno = %d", __func__, len, errno);
+ CDBG_ERROR("%s: len = %lld, errno = %d", __func__,
+ (long long int)len, errno);
/* Avoid waiting for the signal */
pthread_mutex_unlock(&poll_cb->mutex);
return 0;
}
- CDBG("%s: begin IN mutex write done, len = %d", __func__, len);
+ CDBG("%s: begin IN mutex write done, len = %lld", __func__,
+ (long long int)len);
/* wait till worker task gives positive signal */
if (FALSE == poll_cb->status) {
CDBG("%s: wait", __func__);
diff --git a/QCamera2/stack/mm-camera-test/Android.mk b/QCamera2/stack/mm-camera-test/Android.mk
index 8b3ab5c..7e2789f 100644
--- a/QCamera2/stack/mm-camera-test/Android.mk
+++ b/QCamera2/stack/mm-camera-test/Android.mk
@@ -86,7 +86,7 @@
LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_CAMERA_HEAP_ID
LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5
endif
-LOCAL_CFLAGS += -Wall -Werror
+LOCAL_CFLAGS += -Wall -Wextra -Werror
LOCAL_SHARED_LIBRARIES:= \
libcutils libdl libmmcamera_interface
@@ -182,7 +182,7 @@
LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_CAMERA_HEAP_ID
LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5
endif
-LOCAL_CFLAGS += -Wall -Werror
+LOCAL_CFLAGS += -Wall -Wextra -Werror
LOCAL_SHARED_LIBRARIES:= \
libcutils libdl libmmcamera_interface
diff --git a/QCamera2/stack/mm-camera-test/inc/mm_qcamera_app.h b/QCamera2/stack/mm-camera-test/inc/mm_qcamera_app.h
index 6ea6200..952b431 100644
--- a/QCamera2/stack/mm-camera-test/inc/mm_qcamera_app.h
+++ b/QCamera2/stack/mm-camera-test/inc/mm_qcamera_app.h
@@ -161,7 +161,7 @@
int fd;
int main_ion_fd;
ion_user_handle_t handle;
- uint32_t size;
+ size_t size;
void * data;
} mm_camera_app_meminfo_t;
@@ -351,12 +351,12 @@
extern void mm_app_dump_frame(mm_camera_buf_def_t *frame,
char *name,
char *ext,
- int frame_idx);
+ uint32_t frame_idx);
extern void mm_app_dump_jpeg_frame(const void * data,
- uint32_t size,
+ size_t size,
char* name,
char* ext,
- int index);
+ uint32_t index);
extern int mm_camera_app_timedwait(uint8_t seconds);
extern int mm_camera_app_wait();
extern void mm_camera_app_done();
@@ -375,12 +375,11 @@
void *user_data);
extern int32_t mm_app_stream_deinitbuf(mm_camera_map_unmap_ops_tbl_t *ops_tbl,
void *user_data);
-extern int mm_app_cache_ops(mm_camera_app_meminfo_t *mem_info,
- unsigned int cmd);
+extern int mm_app_cache_ops(mm_camera_app_meminfo_t *mem_info, int cmd);
extern int32_t mm_app_stream_clean_invalidate_buf(uint32_t index, void *user_data);
extern int32_t mm_app_stream_invalidate_buf(uint32_t index, void *user_data);
extern int mm_app_open(mm_camera_app_t *cam_app,
- uint8_t cam_id,
+ int cam_id,
mm_camera_test_obj_t *test_obj);
extern int mm_app_close(mm_camera_test_obj_t *test_obj);
extern mm_camera_channel_t * mm_app_add_channel(
@@ -445,7 +444,8 @@
extern int mm_app_start_capture(mm_camera_test_obj_t *test_obj,
uint8_t num_snapshots);
extern int mm_app_stop_capture(mm_camera_test_obj_t *test_obj);
-extern int mm_app_start_capture_raw(mm_camera_test_obj_t *test_obj, uint8_t num_snapshots);
+extern int mm_app_start_capture_raw(mm_camera_test_obj_t *test_obj,
+ uint8_t num_snapshots);
extern int mm_app_stop_capture_raw(mm_camera_test_obj_t *test_obj);
extern int mm_app_start_rdi(mm_camera_test_obj_t *test_obj, uint8_t num_burst);
extern int mm_app_stop_rdi(mm_camera_test_obj_t *test_obj);
@@ -453,7 +453,7 @@
extern int mm_app_close_fb(mm_camera_test_obj_t *test_obj);
extern int mm_app_fb_write(mm_camera_test_obj_t *test_obj, char *buffer);
extern int mm_app_overlay_display(mm_camera_test_obj_t *test_obj, int bufferFd);
-extern int mm_app_allocate_ion_memory(mm_camera_app_buf_t *buf, int ion_type);
+extern int mm_app_allocate_ion_memory(mm_camera_app_buf_t *buf, unsigned int ion_type);
extern int mm_app_deallocate_ion_memory(mm_camera_app_buf_t *buf);
extern int mm_app_set_params(mm_camera_test_obj_t *test_obj,
cam_intf_parm_type_t param_type,
@@ -494,7 +494,7 @@
extern int mm_app_stop_reprocess(mm_camera_test_obj_t *test_obj);
extern int mm_app_do_reprocess(mm_camera_test_obj_t *test_obj,
mm_camera_buf_def_t *frame,
- uint8_t meta_idx,
+ uint32_t meta_idx,
mm_camera_super_buf_t *super_buf,
mm_camera_stream_t *src_meta);
extern void mm_app_release_ppinput(void *data, void *user_data);
diff --git a/QCamera2/stack/mm-camera-test/inc/mm_qcamera_socket.h b/QCamera2/stack/mm-camera-test/inc/mm_qcamera_socket.h
index c054d63..d9bd71d 100644
--- a/QCamera2/stack/mm-camera-test/inc/mm_qcamera_socket.h
+++ b/QCamera2/stack/mm-camera-test/inc/mm_qcamera_socket.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -51,15 +51,15 @@
#undef __FD_SET
#define __FD_SET(fd, fdsetp) \
- (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] |= (1<<((fd) & 31)))
+ (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] |= (1LU<<((fd) & 31)))
#undef __FD_CLR
#define __FD_CLR(fd, fdsetp) \
- (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] &= ~(1<<((fd) & 31)))
+ (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] &= ~(1LU<<((fd) & 31)))
#undef __FD_ISSET
#define __FD_ISSET(fd, fdsetp) \
- ((((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] & (1<<((fd) & 31))) != 0)
+ ((((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] & (1LU<<((fd) & 31))) != 0)
#undef __FD_ZERO
#define __FD_ZERO(fdsetp) \
@@ -119,6 +119,10 @@
uint32_t new_cmd_available;
} prserver_protocol_t;
+typedef union {
+ struct sockaddr addr;
+ struct sockaddr_in addr_in;
+} mm_qcamera_sock_addr_t;
int eztune_server_start(void *lib_handle);
diff --git a/QCamera2/stack/mm-camera-test/src/mm_qcamera_app.c b/QCamera2/stack/mm-camera-test/src/mm_qcamera_app.c
index a8197a1..2eb760c 100644
--- a/QCamera2/stack/mm-camera-test/src/mm_qcamera_app.c
+++ b/QCamera2/stack/mm-camera-test/src/mm_qcamera_app.c
@@ -109,7 +109,7 @@
return MM_CAMERA_OK;
}
-int mm_app_allocate_ion_memory(mm_camera_app_buf_t *buf, int ion_type)
+int mm_app_allocate_ion_memory(mm_camera_app_buf_t *buf, unsigned int ion_type)
{
int rc = MM_CAMERA_OK;
struct ion_handle_data handle_data;
@@ -127,7 +127,7 @@
memset(&alloc, 0, sizeof(alloc));
alloc.len = buf->mem_info.size;
/* to make it page size aligned */
- alloc.len = (alloc.len + 4095) & (~4095);
+ alloc.len = (alloc.len + 4095U) & (~4095U);
alloc.align = 4096;
alloc.flags = ION_FLAG_CACHED;
alloc.heap_mask = ion_type;
@@ -197,7 +197,7 @@
/* cmd = ION_IOC_CLEAN_CACHES, ION_IOC_INV_CACHES, ION_IOC_CLEAN_INV_CACHES */
int mm_app_cache_ops(mm_camera_app_meminfo_t *mem_info,
- unsigned int cmd)
+ int cmd)
{
struct ion_flush_data cache_inv_data;
struct ion_custom_data custom_data;
@@ -214,13 +214,13 @@
cache_inv_data.vaddr = mem_info->data;
cache_inv_data.fd = mem_info->fd;
cache_inv_data.handle = mem_info->handle;
- cache_inv_data.length = mem_info->size;
- custom_data.cmd = cmd;
+ cache_inv_data.length = (unsigned int)mem_info->size;
+ custom_data.cmd = (unsigned int)cmd;
custom_data.arg = (unsigned long)&cache_inv_data;
- CDBG("addr = %p, fd = %d, handle = %p length = %d, ION Fd = %d",
+ CDBG("addr = %p, fd = %d, handle = %lx length = %d, ION Fd = %d",
cache_inv_data.vaddr, cache_inv_data.fd,
- cache_inv_data.handle, cache_inv_data.length,
+ (unsigned long)cache_inv_data.handle, cache_inv_data.length,
mem_info->main_ion_fd);
if(mem_info->main_ion_fd > 0) {
if(ioctl(mem_info->main_ion_fd, ION_IOC_CUSTOM, &custom_data) < 0) {
@@ -236,7 +236,7 @@
void mm_app_dump_frame(mm_camera_buf_def_t *frame,
char *name,
char *ext,
- int frame_idx)
+ uint32_t frame_idx)
{
char file_name[64];
int file_fd;
@@ -249,12 +249,13 @@
CDBG_ERROR("%s: cannot open file %s \n", __func__, file_name);
} else {
for (i = 0; i < frame->num_planes; i++) {
- CDBG("%s: saving file from address: 0x%x, data offset: %d, length: %d \n", __func__,
- (uint32_t )frame->buffer, frame->planes[i].data_offset, frame->planes[i].length);
+ CDBG("%s: saving file from address: %p, data offset: %d, "
+ "length: %d \n", __func__, frame->buffer,
+ frame->planes[i].data_offset, frame->planes[i].length);
write(file_fd,
(uint8_t *)frame->buffer + offset,
frame->planes[i].length);
- offset += frame->planes[i].length;
+ offset += (int)frame->planes[i].length;
}
close(file_fd);
@@ -263,13 +264,14 @@
}
}
-void mm_app_dump_jpeg_frame(const void * data, uint32_t size, char* name, char* ext, int index)
+void mm_app_dump_jpeg_frame(const void * data, size_t size, char* name,
+ char* ext, uint32_t index)
{
char buf[64];
int file_fd;
if ( data != NULL) {
- snprintf(buf, sizeof(buf), "/data/test/%s_%d.%s", name, index, ext);
- CDBG("%s: %s size =%d, jobId=%d", __func__, buf, size, index);
+ snprintf(buf, sizeof(buf), "/data/test/%s_%u.%s", name, index, ext);
+ CDBG("%s: %s size =%zu, jobId=%u", __func__, buf, size, index);
file_fd = open(buf, O_RDWR | O_CREAT, 0777);
write(file_fd, data, size);
close(file_fd);
@@ -283,7 +285,7 @@
size_t multipleOf)
{
uint32_t i, j;
- int ion_type = 0x1 << CAMERA_ION_FALLBACK_HEAP_ID;
+ unsigned int ion_type = 0x1 << CAMERA_ION_FALLBACK_HEAP_ID;
if (is_streambuf) {
ion_type |= 0x1 << CAMERA_ION_HEAP_ID;
@@ -302,7 +304,7 @@
mm_app_allocate_ion_memory(&app_bufs[i], ion_type);
app_bufs[i].buf.buf_idx = i;
- app_bufs[i].buf.num_planes = frame_offset_info->num_planes;
+ app_bufs[i].buf.num_planes = (int8_t)frame_offset_info->num_planes;
app_bufs[i].buf.fd = app_bufs[i].mem_info.fd;
app_bufs[i].buf.frame_len = app_bufs[i].mem_info.size;
app_bufs[i].buf.buffer = app_bufs[i].mem_info.data;
@@ -311,12 +313,14 @@
/* Plane 0 needs to be set seperately. Set other planes
* in a loop. */
app_bufs[i].buf.planes[0].length = frame_offset_info->mp[0].len;
- app_bufs[i].buf.planes[0].m.userptr = app_bufs[i].buf.fd;
+ app_bufs[i].buf.planes[0].m.userptr =
+ (long unsigned int)app_bufs[i].buf.fd;
app_bufs[i].buf.planes[0].data_offset = frame_offset_info->mp[0].offset;
app_bufs[i].buf.planes[0].reserved[0] = 0;
- for (j = 1; j < frame_offset_info->num_planes; j++) {
+ for (j = 1; j < (uint8_t)frame_offset_info->num_planes; j++) {
app_bufs[i].buf.planes[j].length = frame_offset_info->mp[j].len;
- app_bufs[i].buf.planes[j].m.userptr = app_bufs[i].buf.fd;
+ app_bufs[i].buf.planes[j].m.userptr =
+ (long unsigned int)app_bufs[i].buf.fd;
app_bufs[i].buf.planes[j].data_offset = frame_offset_info->mp[j].offset;
app_bufs[i].buf.planes[j].reserved[0] =
app_bufs[i].buf.planes[j-1].reserved[0] +
@@ -396,7 +400,7 @@
rc = ops_tbl->map_ops(pBufs[i].buf_idx,
-1,
pBufs[i].fd,
- pBufs[i].frame_len,
+ (uint32_t)pBufs[i].frame_len,
ops_tbl->userdata);
if (rc != MM_CAMERA_OK) {
CDBG_ERROR("%s: mapping buf[%d] err = %d", __func__, i, rc);
@@ -480,7 +484,7 @@
}
int mm_app_open(mm_camera_app_t *cam_app,
- uint8_t cam_id,
+ int cam_id,
mm_camera_test_obj_t *test_obj)
{
int32_t rc;
@@ -488,7 +492,7 @@
CDBG("%s:BEGIN\n", __func__);
- test_obj->cam = cam_app->hal_lib.mm_camera_open(cam_id);
+ test_obj->cam = cam_app->hal_lib.mm_camera_open((uint8_t)cam_id);
if(test_obj->cam == NULL) {
CDBG_ERROR("%s:dev open error\n", __func__);
return -MM_CAMERA_E_GENERAL;
@@ -592,7 +596,7 @@
int mm_app_close(mm_camera_test_obj_t *test_obj)
{
- uint32_t rc = MM_CAMERA_OK;
+ int32_t rc = MM_CAMERA_OK;
if (test_obj == NULL || test_obj->cam ==NULL) {
CDBG_ERROR("%s: cam not opened", __func__);
@@ -717,7 +721,7 @@
0,
-1,
stream->s_info_buf.mem_info.fd,
- stream->s_info_buf.mem_info.size);
+ (uint32_t)stream->s_info_buf.mem_info.size);
if (rc != MM_CAMERA_OK) {
CDBG_ERROR("%s:map setparm_buf error\n", __func__);
mm_app_deallocate_ion_memory(&stream->s_info_buf);
@@ -827,7 +831,7 @@
parm_buffer_new_t *param_buf = (parm_buffer_new_t *) test_obj->parm_buf.mem_info.data;
uint32_t num_entry = param_buf->num_entry;
uint32_t size_req = paramLength + sizeof(parm_entry_type_new_t);
- uint32_t aligned_size_req = (size_req + 3) & (~3);
+ uint32_t aligned_size_req = (size_req + 3U) & (~3U);
parm_entry_type_new_t *curr_param = (parm_entry_type_new_t *)¶m_buf->entry[0];
/* first search if the key is already present in the batch list
@@ -863,7 +867,7 @@
}
curr_param->entry_type = paramType;
- curr_param->size = (int32_t)paramLength;
+ curr_param->size = (size_t)paramLength;
curr_param->aligned_size = aligned_size_req;
memcpy(&curr_param->data[0], paramValue, paramLength);
ALOGD("%s: num_entry: %d, paramType: %d, paramLength: %d, aligned_size_req: %d",
@@ -1234,7 +1238,7 @@
goto ERROR;
}
- uint32_t value = ev;
+ uint32_t value = (uint32_t)ev;
rc = AddSetParmEntryToBatch(test_obj,
CAM_INTF_PARM_EXPOSURE_COMPENSATION,
@@ -1692,7 +1696,7 @@
return rc;
}
-int setWNR(mm_camera_test_obj_t *test_obj, int enable)
+int setWNR(mm_camera_test_obj_t *test_obj, uint8_t enable)
{
int rc = MM_CAMERA_OK;
@@ -1904,7 +1908,7 @@
handle->current_params.stream_width = DEFAULT_SNAPSHOT_WIDTH;
handle->current_params.stream_height = DEFAULT_SNAPSHOT_HEIGHT;
handle->current_params.af_mode = CAM_FOCUS_MODE_AUTO; // Default to auto focus mode
- rc = mm_app_open(&handle->app_ctx, cam_id, &handle->test_obj);
+ rc = mm_app_open(&handle->app_ctx, (uint8_t)cam_id, &handle->test_obj);
if (rc != MM_CAMERA_OK) {
CDBG_ERROR("%s:mm_app_open() cam_idx=%d, err=%d\n",
__func__, cam_id, rc);
@@ -2038,7 +2042,7 @@
mm_camera_lib_commands cmd,
void *in_data, void *out_data)
{
- int width, height;
+ uint32_t width, height;
int rc = MM_CAMERA_OK;
cam_capability_t *camera_cap = NULL;
mm_camera_lib_snapshot_params *dim = NULL;
@@ -2246,8 +2250,10 @@
width = handle->test_obj.buffer_width;
height = handle->test_obj.buffer_height;
- handle->test_obj.buffer_width = camera_cap->raw_dim.width;
- handle->test_obj.buffer_height = camera_cap->raw_dim.height;
+ handle->test_obj.buffer_width =
+ (uint32_t)camera_cap->raw_dim.width;
+ handle->test_obj.buffer_height =
+ (uint32_t)camera_cap->raw_dim.height;
handle->test_obj.buffer_format = DEFAULT_RAW_FORMAT;
CDBG_ERROR("%s: MM_CAMERA_LIB_RAW_CAPTURE %dx%d\n",
__func__,
@@ -2454,8 +2460,7 @@
}
case MM_CAMERA_LIB_WNR_ENABLE: {
- int wnr_enable = *((uint8_t *)in_data);
- rc = setWNR(&handle->test_obj, wnr_enable);
+ rc = setWNR(&handle->test_obj, *((uint8_t *)in_data));
if ( rc != MM_CAMERA_OK) {
CDBG_ERROR("%s: Set wnr enable failed\n", __func__);
goto EXIT;
diff --git a/QCamera2/stack/mm-camera-test/src/mm_qcamera_main_menu.c b/QCamera2/stack/mm-camera-test/src/mm_qcamera_main_menu.c
index 7296e4e..11af57f 100644
--- a/QCamera2/stack/mm-camera-test/src/mm_qcamera_main_menu.c
+++ b/QCamera2/stack/mm-camera-test/src/mm_qcamera_main_menu.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -272,7 +272,7 @@
*==========================================================================*/
int keypress_to_event(char keypress)
{
- char out_buf = INVALID_KEY_PRESS;
+ int out_buf = INVALID_KEY_PRESS;
if ((keypress >= 'A' && keypress <= 'Z') ||
(keypress >= 'a' && keypress <= 'z')) {
out_buf = tolower(keypress);
@@ -285,7 +285,7 @@
int next_menu(menu_id_change_t current_menu_id, char keypress, camera_action_t * action_id_ptr, int * action_param)
{
- char output_to_event;
+ int output_to_event;
menu_id_change_t next_menu_id = MENU_ID_INVALID;
* action_id_ptr = ACTION_NO_ACTION;
@@ -475,7 +475,7 @@
printf("MENU_ID_GET_CTRL_VALUE\n");
* action_id_ptr = ACTION_GET_CTRL_VALUE;
if (output_to_event > 0 &&
- output_to_event <= sizeof(get_ctrl_tbl)/sizeof(get_ctrl_tbl[0])) {
+ output_to_event <= (int)(sizeof(get_ctrl_tbl)/sizeof(get_ctrl_tbl[0]))) {
next_menu_id = MENU_ID_MAIN;
* action_param = output_to_event;
}
@@ -571,7 +571,7 @@
case MENU_ID_ZOOMCHANGE:
* action_id_ptr = ACTION_SET_ZOOM;
if (output_to_event > 0 &&
- output_to_event <= sizeof(zoom_tbl)/sizeof(zoom_tbl[0])) {
+ output_to_event <= (int)(sizeof(zoom_tbl)/sizeof(zoom_tbl[0]))) {
next_menu_id = MENU_ID_MAIN;
* action_param = output_to_event;
} else {
@@ -1090,8 +1090,8 @@
int take_jpeg_snapshot(mm_camera_test_obj_t *test_obj, int is_burst_mode)
{
CDBG_HIGH("\nEnter take_jpeg_snapshot!!\n");
- int rc = MM_CAMERA_OK;
- if(MM_CAMERA_OK != (rc = mm_app_take_picture(test_obj, is_burst_mode))) {
+ int rc = mm_app_take_picture (test_obj, (uint8_t)is_burst_mode);
+ if (MM_CAMERA_OK != rc) {
CDBG_ERROR("%s: mm_app_take_picture() err=%d\n", __func__, rc);
}
return rc;
@@ -1574,7 +1574,7 @@
if ( ( tbl[i].width == camera_cap.picture_sizes_tbl[j].width ) &&
( tbl[i].height == camera_cap.picture_sizes_tbl[j].height ) ) {
tbl[i].supported = 1;
- rc = i;
+ rc = (int)i;
break;
}
}
@@ -1651,8 +1651,10 @@
uint8_t wnr_enabled = 0;
mm_camera_lib_handle lib_handle;
int num_cameras;
- int available_sensors = sizeof(sensor_tbl) / sizeof(sensor_tbl[0]);
- int available_snap_sizes = sizeof(dimension_tbl)/sizeof(dimension_tbl[0]);
+ int available_sensors =
+ (int)(sizeof(sensor_tbl) / sizeof(sensor_tbl[0]));
+ int available_snap_sizes =
+ (int)(sizeof(dimension_tbl)/sizeof(dimension_tbl[0]));
int i,c;
mm_camera_lib_snapshot_params snap_dim;
snap_dim.width = DEFAULT_SNAPSHOT_WIDTH;
@@ -1683,7 +1685,7 @@
} else {
i = filter_resolutions(&lib_handle,
dimension_tbl,
- available_snap_sizes);
+ (size_t)available_snap_sizes);
if ( ( i < 0 ) || ( i >= available_snap_sizes ) ) {
CDBG_ERROR("%s:filter_resolutions()\n", __func__);
goto ERROR;
diff --git a/QCamera2/stack/mm-camera-test/src/mm_qcamera_preview.c b/QCamera2/stack/mm-camera-test/src/mm_qcamera_preview.c
index a68525f..b640024 100644
--- a/QCamera2/stack/mm-camera-test/src/mm_qcamera_preview.c
+++ b/QCamera2/stack/mm-camera-test/src/mm_qcamera_preview.c
@@ -109,8 +109,8 @@
mm_camera_buf_def_t *frame = bufs->bufs[0];
mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data;
- CDBG_ERROR("%s: BEGIN - length=%d, frame idx = %d\n",
- __func__, frame->frame_len, frame->frame_idx);
+ CDBG_ERROR("%s: BEGIN - length=%zu, frame idx = %d\n",
+ __func__, frame->frame_len, frame->frame_idx);
/* find channel */
for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) {
@@ -264,11 +264,11 @@
return;
}
- CDBG("%s: ZSL CB with fb_fd = %d, m_frame = 0x%x, p_frame = 0x%x \n",
+ CDBG("%s: ZSL CB with fb_fd = %d, m_frame = %p, p_frame = %p \n",
__func__,
pme->fb_fd,
- (uint32_t )m_frame,
- (uint32_t )p_frame);
+ m_frame,
+ p_frame);
if ( 0 < pme->fb_fd ) {
mm_app_overlay_display(pme, p_frame->fd);
@@ -476,8 +476,8 @@
stream->s_config.stream_info->dim.width = DEFAULT_SNAPSHOT_WIDTH;
stream->s_config.stream_info->dim.height = DEFAULT_SNAPSHOT_HEIGHT;
} else {
- stream->s_config.stream_info->dim.width = test_obj->buffer_width;
- stream->s_config.stream_info->dim.height = test_obj->buffer_height;
+ stream->s_config.stream_info->dim.width = (int32_t)test_obj->buffer_width;
+ stream->s_config.stream_info->dim.height = (int32_t)test_obj->buffer_height;
}
stream->s_config.padding_info = cam_cap->padding_info;
@@ -531,8 +531,8 @@
stream->s_config.stream_info->dim.width = DEFAULT_SNAPSHOT_WIDTH;
stream->s_config.stream_info->dim.height = DEFAULT_SNAPSHOT_HEIGHT;
} else {
- stream->s_config.stream_info->dim.width = test_obj->buffer_width;
- stream->s_config.stream_info->dim.height = test_obj->buffer_height;
+ stream->s_config.stream_info->dim.width = (int32_t)test_obj->buffer_width;
+ stream->s_config.stream_info->dim.height = (int32_t)test_obj->buffer_height;
}
stream->s_config.padding_info = cam_cap->padding_info;
@@ -871,7 +871,7 @@
}
munmap(fb_base, test_obj->slice_size);
- test_obj->data_overlay.id = MSMFB_NEW_REQUEST;
+ test_obj->data_overlay.id = (uint32_t)MSMFB_NEW_REQUEST;
rc = ioctl(test_obj->fb_fd, MSMFB_OVERLAY_SET, &test_obj->data_overlay);
if (rc < 0) {
CDBG_ERROR("%s : MSMFB_OVERLAY_SET failed! err=%d\n",
diff --git a/QCamera2/stack/mm-camera-test/src/mm_qcamera_rdi.c b/QCamera2/stack/mm-camera-test/src/mm_qcamera_rdi.c
index a79b8f2..4d3f3f8 100644
--- a/QCamera2/stack/mm-camera-test/src/mm_qcamera_rdi.c
+++ b/QCamera2/stack/mm-camera-test/src/mm_qcamera_rdi.c
@@ -35,13 +35,14 @@
static void mm_app_rdi_dump_frame(mm_camera_buf_def_t *frame,
char *name,
char *ext,
- int frame_idx)
+ uint32_t frame_idx)
{
char file_name[64];
int file_fd;
int i;
if (frame != NULL) {
- snprintf(file_name, sizeof(file_name), "/data/%s_%03d.%s", name, frame_idx, ext);
+ snprintf(file_name, sizeof(file_name), "/data/%s_%03u.%s", name,
+ frame_idx, ext);
file_fd = open(file_name, O_RDWR | O_CREAT, 0777);
if (file_fd < 0) {
CDBG_ERROR("%s: cannot open file %s \n", __func__, file_name);
@@ -65,7 +66,7 @@
mm_camera_buf_def_t *frame = bufs->bufs[0];
mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data;
- CDBG("%s: BEGIN - length=%d, frame idx = %d stream_id=%d\n",
+ CDBG("%s: BEGIN - length=%zu, frame idx = %d stream_id=%d\n",
__func__, frame->frame_len, frame->frame_idx, frame->stream_id);
snprintf(file_name, sizeof(file_name), "RDI_dump_%d", pme->cam->camera_handle);
mm_app_rdi_dump_frame(frame, file_name, "raw", frame->frame_idx);
@@ -101,9 +102,11 @@
return NULL;
}
- CDBG_ERROR("%s: raw_dim w:%d height:%d\n", __func__, cam_cap->raw_dim.width, cam_cap->raw_dim.height);
+ CDBG_ERROR("%s: raw_dim w:%d height:%d\n", __func__,
+ cam_cap->raw_dim.width, cam_cap->raw_dim.height);
for (i = 0;i < cam_cap->supported_raw_fmt_cnt;i++) {
- CDBG_ERROR("%s: supported_raw_fmts[%d]=%d\n", __func__, i, cam_cap->supported_raw_fmts[i]);
+ CDBG_ERROR("%s: supported_raw_fmts[%zu]=%d\n", __func__,
+ i, cam_cap->supported_raw_fmts[i]);
if (CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GBRG <= cam_cap->supported_raw_fmts[i] &&
CAM_FORMAT_BAYER_MIPI_RAW_12BPP_BGGR >= cam_cap->supported_raw_fmts[i])
{
diff --git a/QCamera2/stack/mm-camera-test/src/mm_qcamera_reprocess.c b/QCamera2/stack/mm-camera-test/src/mm_qcamera_reprocess.c
index 07f7226..6d7a758 100644
--- a/QCamera2/stack/mm-camera-test/src/mm_qcamera_reprocess.c
+++ b/QCamera2/stack/mm-camera-test/src/mm_qcamera_reprocess.c
@@ -47,7 +47,7 @@
return;
}
frame = bufs->bufs[0];
- CDBG_ERROR("%s: BEGIN - length=%d, frame idx = %d\n",
+ CDBG_ERROR("%s: BEGIN - length=%zu, frame idx = %d\n",
__func__, frame->frame_len, frame->frame_idx);
/* find channel */
for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) {
@@ -291,7 +291,7 @@
int mm_app_do_reprocess(mm_camera_test_obj_t *test_obj,
mm_camera_buf_def_t *frame,
- uint8_t meta_idx,
+ uint32_t meta_idx,
mm_camera_super_buf_t *super_buf,
mm_camera_stream_t *src_meta)
{
diff --git a/QCamera2/stack/mm-camera-test/src/mm_qcamera_snapshot.c b/QCamera2/stack/mm-camera-test/src/mm_qcamera_snapshot.c
index 4ddff8c..03278f7 100644
--- a/QCamera2/stack/mm-camera-test/src/mm_qcamera_snapshot.c
+++ b/QCamera2/stack/mm-camera-test/src/mm_qcamera_snapshot.c
@@ -670,7 +670,7 @@
{
CDBG_HIGH("\nEnter %s!!\n",__func__);
int rc = MM_CAMERA_OK;
- int num_snapshot = 1;
+ uint8_t num_snapshot = 1;
int num_rcvd_snapshot = 0;
if (is_burst_mode)
diff --git a/QCamera2/stack/mm-camera-test/src/mm_qcamera_socket.c b/QCamera2/stack/mm-camera-test/src/mm_qcamera_socket.c
index 6bbf748..e259a49 100644
--- a/QCamera2/stack/mm-camera-test/src/mm_qcamera_socket.c
+++ b/QCamera2/stack/mm-camera-test/src/mm_qcamera_socket.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -39,10 +39,10 @@
pthread_t eztune_thread_id;
-static int tuneserver_send_command_rsp(tuningserver_t *tsctrl,
+static ssize_t tuneserver_send_command_rsp(tuningserver_t *tsctrl,
char *send_buf, uint32_t send_len)
{
- int rc;
+ ssize_t rc;
/* send ack back to client upon req */
if (send_len <= 0) {
@@ -76,9 +76,9 @@
}
}
-static int tuneserver_ack(uint16_t a, uint32_t b, tuningserver_t *tsctrl)
+static ssize_t tuneserver_ack(uint16_t a, uint32_t b, tuningserver_t *tsctrl)
{
- int rc;
+ ssize_t rc;
char ack_1[6];
/*Ack the command here*/
memcpy(ack_1, &a, 2);
@@ -95,9 +95,10 @@
return 0;
}
-static int tuneserver_send_command_ack( uint8_t ack, tuningserver_t *tsctrl)
+static ssize_t tuneserver_send_command_ack( uint8_t ack,
+ tuningserver_t *tsctrl)
{
- int rc;
+ ssize_t rc;
/* send ack back to client upon req */
rc = send(tsctrl->clientsocket_id, &ack, sizeof(ack), 0);
if (rc < 0) {
@@ -284,9 +285,9 @@
*
* Return: >=0 on success, -1 on failure.
**/
-static int32_t tuneserver_ack_onaccept_initprotocol(tuningserver_t *tsctrl)
+static ssize_t tuneserver_ack_onaccept_initprotocol(tuningserver_t *tsctrl)
{
- int32_t rc = 0;
+ ssize_t rc = 0;
uint32_t ack_status;
ALOGE("%s starts\n", __func__);
@@ -338,10 +339,10 @@
}
#endif
-static int prevserver_send_command_rsp(tuningserver_t *tsctrl,
+static ssize_t prevserver_send_command_rsp(tuningserver_t *tsctrl,
char *send_buf, uint32_t send_len)
{
- int rc;
+ ssize_t rc;
/* send ack back to client upon req */
if (send_len <= 0) {
@@ -543,17 +544,17 @@
int tunning_server_socket_listen(const char* ip_addr, uint16_t port)
{
int sock_fd = -1;
- struct sockaddr_in server_addr;
+ mm_qcamera_sock_addr_t server_addr;
int result;
int option;
int socket_flag;
memset(&server_addr, 0, sizeof(server_addr));
- server_addr.sin_family = AF_INET;
- server_addr.sin_port= htons(port);
- server_addr.sin_addr.s_addr = inet_addr(ip_addr);
+ server_addr.addr_in.sin_family = AF_INET;
+ server_addr.addr_in.sin_port = (__be16) htons(port);
+ server_addr.addr_in.sin_addr.s_addr = inet_addr(ip_addr);
- if (server_addr.sin_addr.s_addr == INADDR_NONE) {
+ if (server_addr.addr_in.sin_addr.s_addr == INADDR_NONE) {
ALOGE("[ERR] %s invalid address.\n", __func__);
return -1;
}
@@ -581,7 +582,7 @@
return sock_fd;
}
- result = bind(sock_fd, (struct sockaddr*)&server_addr, sizeof(server_addr));
+ result = bind(sock_fd, &server_addr.addr, sizeof(server_addr.addr_in));
if (result < 0) {
ALOGE("eztune socket bind failed");
close(sock_fd);
@@ -614,12 +615,12 @@
int server_socket = -1, client_socket = -1;
int prev_server_socket = -1, prev_client_socket = -1;
- struct sockaddr_in addr_client_inet;
- socklen_t addr_client_len = sizeof(struct sockaddr_in);
+ mm_qcamera_sock_addr_t addr_client_inet;
+ socklen_t addr_client_len = sizeof(addr_client_inet.addr_in);
int result;
fd_set tsfds;
int num_fds = 0;
- int recv_bytes;
+ ssize_t recv_bytes;
char buf[TUNESERVER_MAX_RECV];
mm_camera_lib_handle *lib_handle = (mm_camera_lib_handle *)data;
@@ -665,7 +666,7 @@
CDBG("Receiving New client connection\n");
client_socket = accept(server_socket,
- (struct sockaddr *)&addr_client_inet, &addr_client_len);
+ &addr_client_inet.addr, &addr_client_len);
if (client_socket == -1) {
ALOGE("accept failed %s", strerror(errno));
continue;
@@ -710,7 +711,7 @@
/*Receive message and process it*/
recv_bytes = recv(client_socket, (void *)buf,
lib_handle->tsctrl.proto->next_recv_len, 0);
- CDBG("Receive %d bytes \n", recv_bytes);
+ CDBG("Receive %lld bytes \n", (long long int) recv_bytes);
if (recv_bytes == -1) {
ALOGE("%s: Receive failed with error %s\n", __func__, strerror(errno));
@@ -754,7 +755,7 @@
CDBG("Receiving New Preview client connection\n");
prev_client_socket = accept(prev_server_socket,
- (struct sockaddr *)&addr_client_inet, &addr_client_len);
+ &addr_client_inet.addr, &addr_client_len);
if (prev_client_socket == -1) {
ALOGE("accept failed %s", strerror(errno));
continue;
@@ -800,7 +801,7 @@
lib_handle->tsctrl.pr_proto->next_recv_len, 0);
CDBG("%s prev_client_socket=%d\n", __func__, prev_client_socket);
- CDBG("%s next_recv_len=%d\n", __func__, *(uint16_t *)buf);
+ CDBG("%s next_recv_len=%d\n", __func__, buf[0]+buf[1]*256);
if (recv_bytes <= 0) {
if (recv_bytes == 0) {
diff --git a/QCamera2/stack/mm-camera-test/src/mm_qcamera_video.c b/QCamera2/stack/mm-camera-test/src/mm_qcamera_video.c
index 136c8a8..338105e 100644
--- a/QCamera2/stack/mm-camera-test/src/mm_qcamera_video.c
+++ b/QCamera2/stack/mm-camera-test/src/mm_qcamera_video.c
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -37,7 +37,7 @@
mm_camera_buf_def_t *frame = bufs->bufs[0];
mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data;
- CDBG("%s: BEGIN - length=%d, frame idx = %d\n",
+ CDBG("%s: BEGIN - length=%zu, frame idx = %d\n",
__func__, frame->frame_len, frame->frame_idx);
snprintf(file_name, sizeof(file_name), "V_C%d", pme->cam->camera_handle);
mm_app_dump_frame(frame, file_name, "yuv", frame->frame_idx);
diff --git a/QCamera2/stack/mm-jpeg-interface/Android.mk b/QCamera2/stack/mm-jpeg-interface/Android.mk
index 902cff3..40cf778 100644
--- a/QCamera2/stack/mm-jpeg-interface/Android.mk
+++ b/QCamera2/stack/mm-jpeg-interface/Android.mk
@@ -3,6 +3,7 @@
include $(CLEAR_VARS)
LOCAL_CFLAGS+= -D_ANDROID_
+LOCAL_CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter
LOCAL_C_INCLUDES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include/media
diff --git a/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg.h b/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg.h
index a4c5fa7..e66aa0f 100644
--- a/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg.h
+++ b/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg.h
@@ -77,11 +77,11 @@
* dump the image to the file
**/
#define DUMP_TO_FILE(filename, p_addr, len) ({ \
- int rc = 0; \
+ size_t rc = 0; \
FILE *fp = fopen(filename, "w+"); \
if (fp) { \
rc = fwrite(p_addr, 1, len, fp); \
- CDBG_ERROR("%s:%d] written size %d", __func__, __LINE__, len); \
+ CDBG_ERROR("%s:%d] written size %zu", __func__, __LINE__, len); \
fclose(fp); \
} else { \
CDBG_ERROR("%s:%d] open %s failed", __func__, __LINE__, filename); \
@@ -96,12 +96,12 @@
* dump the image to the file if the memory is non-contiguous
**/
#define DUMP_TO_FILE2(filename, p_addr1, len1, paddr2, len2) ({ \
- int rc = 0; \
+ size_t rc = 0; \
FILE *fp = fopen(filename, "w+"); \
if (fp) { \
rc = fwrite(p_addr1, 1, len1, fp); \
rc = fwrite(p_addr2, 1, len2, fp); \
- CDBG_ERROR("%s:%d] written %d %d", __func__, __LINE__, len1, len2); \
+ CDBG_ERROR("%s:%d] written %zu %zu", __func__, __LINE__, len1, len2); \
fclose(fp); \
} else { \
CDBG_ERROR("%s:%d] open %s failed", __func__, __LINE__, filename); \
@@ -241,9 +241,14 @@
})
-typedef struct {
+typedef union {
+ uint32_t u32;
+ void* p;
+} mm_jpeg_q_data_t;
+
+ typedef struct {
struct cam_list list;
- void* data;
+ mm_jpeg_q_data_t data;
} mm_jpeg_q_node_t;
typedef struct {
@@ -307,7 +312,7 @@
OMX_BOOL config;
/* job history count to generate unique id */
- int job_hist;
+ unsigned int job_hist;
OMX_BOOL encoding;
@@ -317,7 +322,7 @@
int event_pending;
uint8_t *meta_enc_key;
- uint32_t meta_enc_keylen;
+ size_t meta_enc_keylen;
struct mm_jpeg_job_session *next_session;
@@ -377,9 +382,9 @@
/* Max pic dimension for work buf calc*/
- int32_t max_pic_w;
- int32_t max_pic_h;
- int work_buf_cnt;
+ uint32_t max_pic_w;
+ uint32_t max_pic_h;
+ uint32_t work_buf_cnt;
#ifdef LOAD_ADSP_RPC_LIB
void *adsprpc_lib_handle;
@@ -441,13 +446,15 @@
/* basic queue functions */
extern int32_t mm_jpeg_queue_init(mm_jpeg_queue_t* queue);
-extern int32_t mm_jpeg_queue_enq(mm_jpeg_queue_t* queue, void* node);
-extern int32_t mm_jpeg_queue_enq_head(mm_jpeg_queue_t* queue, void* node);
-extern void* mm_jpeg_queue_deq(mm_jpeg_queue_t* queue);
+extern int32_t mm_jpeg_queue_enq(mm_jpeg_queue_t* queue,
+ mm_jpeg_q_data_t data);
+extern int32_t mm_jpeg_queue_enq_head(mm_jpeg_queue_t* queue,
+ mm_jpeg_q_data_t data);
+extern mm_jpeg_q_data_t mm_jpeg_queue_deq(mm_jpeg_queue_t* queue);
extern int32_t mm_jpeg_queue_deinit(mm_jpeg_queue_t* queue);
extern int32_t mm_jpeg_queue_flush(mm_jpeg_queue_t* queue);
extern uint32_t mm_jpeg_queue_get_size(mm_jpeg_queue_t* queue);
-extern void* mm_jpeg_queue_peek(mm_jpeg_queue_t* queue);
+extern mm_jpeg_q_data_t mm_jpeg_queue_peek(mm_jpeg_queue_t* queue);
extern int32_t addExifEntry(QOMX_EXIF_INFO *p_exif_info, exif_tag_id_t tagid,
exif_tag_type_t type, uint32_t count, void *data);
extern int32_t releaseExifEntry(QEXIF_INFO_DATA *p_exif_data);
diff --git a/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_dbg.h b/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_dbg.h
index 0e805e9..4e55296 100644
--- a/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_dbg.h
+++ b/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_dbg.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -32,7 +32,6 @@
#include "cam_types.h"
-#define LOG_DEBUG
/* Choose debug log level. This will not affect the error logs
0: turns off CDBG and CDBG_HIGH logs
1: turns-on CDBG_HIGH logs
diff --git a/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_ionbuf.h b/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_ionbuf.h
index 5968013..0a1b0ae 100644
--- a/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_ionbuf.h
+++ b/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_ionbuf.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -44,7 +44,7 @@
struct ion_fd_data ion_info_fd;
struct ion_allocation_data alloc;
int p_pmem_fd;
- long size;
+ size_t size;
int ion_fd;
uint8_t *addr;
} buffer_t;
diff --git a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg.c b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg.c
index 190781a..9ab39d5 100644
--- a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg.c
+++ b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg.c
@@ -90,12 +90,11 @@
OMX_ERRORTYPE ret = OMX_ErrorNone;
QOMX_BUFFER_INFO lbuffer_info;
mm_jpeg_encode_params_t *p_params = &p_session->params;
- mm_jpeg_encode_job_t *p_jobparams = &p_session->encode_job;
memset(&lbuffer_info, 0x0, sizeof(QOMX_BUFFER_INFO));
for (i = 0; i < p_params->num_src_bufs; i++) {
CDBG("%s:%d] Source buffer %d", __func__, __LINE__, i);
- lbuffer_info.fd = p_params->src_main_buf[i].fd;
+ lbuffer_info.fd = (OMX_U32)p_params->src_main_buf[i].fd;
ret = OMX_UseBuffer(p_session->omx_handle, &(p_session->p_in_omx_buf[i]), 0,
&lbuffer_info, p_params->src_main_buf[i].buf_size,
p_params->src_main_buf[i].buf_vaddr);
@@ -107,7 +106,7 @@
for (i = 0; i < p_params->num_tmb_bufs; i++) {
CDBG("%s:%d] Source buffer %d", __func__, __LINE__, i);
- lbuffer_info.fd = p_params->src_thumb_buf[i].fd;
+ lbuffer_info.fd = (OMX_U32)p_params->src_thumb_buf[i].fd;
ret = OMX_UseBuffer(p_session->omx_handle,
&(p_session->p_in_omx_thumb_buf[i]), 2,
&lbuffer_info, p_params->src_thumb_buf[i].buf_size,
@@ -151,7 +150,6 @@
uint32_t i = 0;
mm_jpeg_job_session_t* p_session = (mm_jpeg_job_session_t *)data;
mm_jpeg_encode_params_t *p_params = &p_session->params;
- mm_jpeg_encode_job_t *p_jobparams = &p_session->encode_job;
for (i = 0; i < p_params->num_src_bufs; i++) {
CDBG("%s:%d] Source buffer %d", __func__, __LINE__, i);
@@ -275,9 +273,7 @@
OMX_ERRORTYPE mm_jpeg_session_create(mm_jpeg_job_session_t* p_session)
{
OMX_ERRORTYPE rc = OMX_ErrorNone;
- mm_jpeg_cirq_t *p_cirq = NULL;
mm_jpeg_obj *my_obj = (mm_jpeg_obj *) p_session->jpeg_obj;
- int i = 0;
pthread_mutex_init(&p_session->lock, NULL);
pthread_cond_init(&p_session->cond, NULL);
@@ -399,10 +395,9 @@
mm_jpeg_job_session_t* p_session)
{
OMX_ERRORTYPE rc = 0;
- int32_t i = 0;
OMX_INDEXTYPE buffer_index;
QOMX_YUV_FRAME_INFO frame_info;
- int32_t totalSize = 0;
+ size_t totalSize = 0;
mm_jpeg_encode_params_t *p_params = &p_session->params;
mm_jpeg_buf_t *p_src_buf =
@@ -424,7 +419,7 @@
return rc;
}
- CDBG_HIGH("%s:%d] yOffset = %d, cbcrOffset = (%d %d), totalSize = %d,"
+ CDBG_HIGH("%s:%d] yOffset = %d, cbcrOffset = (%d %d), totalSize = %zu,"
"cbcrStartOffset = (%d %d)", __func__, __LINE__,
(int)frame_info.yOffset,
(int)frame_info.cbcrOffset[0],
@@ -458,12 +453,8 @@
mm_jpeg_job_session_t* p_session)
{
OMX_ERRORTYPE rc = 0;
- int32_t i = 0;
OMX_INDEXTYPE indextype;
QOMX_ENCODING_MODE encoding_mode;
- int32_t totalSize = 0;
- mm_jpeg_encode_params_t *p_params = &p_session->params;
- mm_jpeg_encode_job_t *p_jobparams = &p_session->encode_job;
rc = OMX_GetExtensionIndex(p_session->omx_handle,
QOMX_IMAGE_EXT_ENCODING_MODE_NAME, &indextype);
@@ -503,12 +494,8 @@
mm_jpeg_job_session_t* p_session)
{
OMX_ERRORTYPE rc = 0;
- int32_t i = 0;
OMX_INDEXTYPE indextype;
QOMX_JPEG_SPEED jpeg_speed;
- int32_t totalSize = 0;
- mm_jpeg_encode_params_t *p_params = &p_session->params;
- mm_jpeg_encode_job_t *p_jobparams = &p_session->encode_job;
rc = OMX_GetExtensionIndex(p_session->omx_handle,
QOMX_IMAGE_EXT_JPEG_SPEED_NAME, &indextype);
@@ -549,12 +536,9 @@
mm_jpeg_job_session_t* p_session)
{
OMX_ERRORTYPE rc = 0;
- int32_t i = 0;
OMX_INDEXTYPE indextype;
QOMX_MEM_OPS mem_ops;
- int32_t totalSize = 0;
mm_jpeg_encode_params_t *p_params = &p_session->params;
- mm_jpeg_encode_job_t *p_jobparams = &p_session->encode_job;
mem_ops.get_memory = p_params->get_memory;
@@ -589,9 +573,7 @@
mm_jpeg_job_session_t* p_session)
{
OMX_ERRORTYPE rc = OMX_ErrorNone;
- int32_t i = 0;
OMX_INDEXTYPE indexType;
- mm_jpeg_encode_params_t *p_params = &p_session->params;
mm_jpeg_encode_job_t *p_jobparams = &p_session->encode_job;
QOMX_METADATA lMeta;
@@ -632,8 +614,6 @@
{
OMX_ERRORTYPE rc = OMX_ErrorNone;
OMX_INDEXTYPE indexType;
- mm_jpeg_encode_params_t *p_params = &p_session->params;
- mm_jpeg_encode_job_t *p_jobparams = &p_session->encode_job;
QOMX_META_ENC_KEY lKey;
lKey.metaKey = p_session->meta_enc_key;
@@ -746,18 +726,18 @@
}
p_session->inputPort.format.image.nFrameWidth =
- p_params->main_dim.src_dim.width;
+ (OMX_U32)p_params->main_dim.src_dim.width;
p_session->inputPort.format.image.nFrameHeight =
- p_params->main_dim.src_dim.height;
+ (OMX_U32)p_params->main_dim.src_dim.height;
p_session->inputPort.format.image.nStride =
p_src_buf->offset.mp[0].stride;
p_session->inputPort.format.image.nSliceHeight =
- p_src_buf->offset.mp[0].scanline;
+ (OMX_U32)p_src_buf->offset.mp[0].scanline;
p_session->inputPort.format.image.eColorFormat =
map_jpeg_format(p_params->color_format);
p_session->inputPort.nBufferSize =
p_params->src_main_buf[0/*p_jobparams->src_index*/].buf_size;
- p_session->inputPort.nBufferCountActual = p_params->num_src_bufs;
+ p_session->inputPort.nBufferCountActual = (OMX_U32)p_params->num_src_bufs;
ret = OMX_SetParameter(p_session->omx_handle, OMX_IndexParamPortDefinition,
&p_session->inputPort);
if (ret) {
@@ -769,18 +749,18 @@
mm_jpeg_buf_t *p_tmb_buf =
&p_params->src_thumb_buf[0];
p_session->inputTmbPort.format.image.nFrameWidth =
- p_params->thumb_dim.src_dim.width;
+ (OMX_U32)p_params->thumb_dim.src_dim.width;
p_session->inputTmbPort.format.image.nFrameHeight =
- p_params->thumb_dim.src_dim.height;
+ (OMX_U32)p_params->thumb_dim.src_dim.height;
p_session->inputTmbPort.format.image.nStride =
p_tmb_buf->offset.mp[0].stride;
p_session->inputTmbPort.format.image.nSliceHeight =
- p_tmb_buf->offset.mp[0].scanline;
+ (OMX_U32)p_tmb_buf->offset.mp[0].scanline;
p_session->inputTmbPort.format.image.eColorFormat =
map_jpeg_format(p_params->thumb_color_format);
p_session->inputTmbPort.nBufferSize =
p_params->src_thumb_buf[0].buf_size;
- p_session->inputTmbPort.nBufferCountActual = p_params->num_tmb_bufs;
+ p_session->inputTmbPort.nBufferCountActual = (OMX_U32)p_params->num_tmb_bufs;
ret = OMX_SetParameter(p_session->omx_handle, OMX_IndexParamPortDefinition,
&p_session->inputTmbPort);
@@ -810,7 +790,7 @@
p_session->outputPort.nBufferSize =
p_params->dest_buf[0].buf_size;
- p_session->outputPort.nBufferCountActual = p_params->num_dst_bufs;
+ p_session->outputPort.nBufferCountActual = (OMX_U32)p_params->num_dst_bufs;
ret = OMX_SetParameter(p_session->omx_handle, OMX_IndexParamPortDefinition,
&p_session->outputPort);
if (ret) {
@@ -821,7 +801,7 @@
/* set rotation */
memset(&rotate, 0, sizeof(rotate));
rotate.nPortIndex = 1;
- rotate.nRotation = p_params->rotation;
+ rotate.nRotation = (OMX_S32)p_params->rotation;
ret = OMX_SetConfig(p_session->omx_handle, OMX_IndexConfigCommonRotate,
&rotate);
if (OMX_ErrorNone != ret) {
@@ -851,15 +831,13 @@
OMX_ERRORTYPE ret = OMX_ErrorNone;
QOMX_THUMBNAIL_INFO thumbnail_info;
OMX_INDEXTYPE thumb_indextype;
- OMX_BOOL encode_thumbnail = OMX_FALSE;
mm_jpeg_encode_params_t *p_params = &p_session->params;
mm_jpeg_encode_job_t *p_jobparams = &p_session->encode_job;
mm_jpeg_dim_t *p_thumb_dim = &p_jobparams->thumb_dim;
- mm_jpeg_dim_t *p_main_dim = &p_jobparams->main_dim;
QOMX_YUV_FRAME_INFO *p_frame_info = &thumbnail_info.tmbOffset;
mm_jpeg_buf_t *p_tmb_buf = &p_params->src_thumb_buf[p_jobparams->thumb_index];
- CDBG_HIGH("%s:%d] encode_thumbnail %d", __func__, __LINE__,
+ CDBG_HIGH("%s:%d] encode_thumbnail %u", __func__, __LINE__,
p_params->encode_thumbnail);
if (OMX_FALSE == p_params->encode_thumbnail) {
return ret;
@@ -907,13 +885,13 @@
/* fill thumbnail info */
thumbnail_info.scaling_enabled = 1;
- thumbnail_info.input_width = p_thumb_dim->src_dim.width;
- thumbnail_info.input_height = p_thumb_dim->src_dim.height;
- thumbnail_info.crop_info.nWidth = p_thumb_dim->crop.width;
- thumbnail_info.crop_info.nHeight = p_thumb_dim->crop.height;
+ thumbnail_info.input_width = (OMX_U32)p_thumb_dim->src_dim.width;
+ thumbnail_info.input_height = (OMX_U32)p_thumb_dim->src_dim.height;
+ thumbnail_info.crop_info.nWidth = (OMX_U32)p_thumb_dim->crop.width;
+ thumbnail_info.crop_info.nHeight = (OMX_U32)p_thumb_dim->crop.height;
thumbnail_info.crop_info.nLeft = p_thumb_dim->crop.left;
thumbnail_info.crop_info.nTop = p_thumb_dim->crop.top;
- thumbnail_info.rotation = p_params->thumb_rotation;
+ thumbnail_info.rotation = (OMX_U32)p_params->thumb_rotation;
if ((p_thumb_dim->dst_dim.width > p_thumb_dim->src_dim.width)
|| (p_thumb_dim->dst_dim.height > p_thumb_dim->src_dim.height)) {
@@ -923,11 +901,11 @@
p_thumb_dim->dst_dim.height,
p_thumb_dim->src_dim.width,
p_thumb_dim->src_dim.height);
- thumbnail_info.output_width = p_thumb_dim->src_dim.width;
- thumbnail_info.output_height = p_thumb_dim->src_dim.height;
+ thumbnail_info.output_width = (OMX_U32)p_thumb_dim->src_dim.width;
+ thumbnail_info.output_height = (OMX_U32)p_thumb_dim->src_dim.height;
} else {
- thumbnail_info.output_width = p_thumb_dim->dst_dim.width;
- thumbnail_info.output_height = p_thumb_dim->dst_dim.height;
+ thumbnail_info.output_width = (OMX_U32)p_thumb_dim->dst_dim.width;
+ thumbnail_info.output_height = (OMX_U32)p_thumb_dim->dst_dim.height;
}
memset(p_frame_info, 0x0, sizeof(*p_frame_info));
@@ -964,7 +942,6 @@
{
OMX_CONFIG_RECTTYPE rect_type_in, rect_type_out;
OMX_ERRORTYPE ret = OMX_ErrorNone;
- mm_jpeg_encode_params_t *p_params = &p_session->params;
mm_jpeg_encode_job_t *p_jobparams = &p_session->encode_job;
mm_jpeg_dim_t *dim = &p_jobparams->main_dim;
@@ -1000,8 +977,8 @@
rect_type_in.nTop = dim->crop.top;
if (dim->dst_dim.width && dim->dst_dim.height) {
- rect_type_out.nWidth = dim->dst_dim.width;
- rect_type_out.nHeight = dim->dst_dim.height;
+ rect_type_out.nWidth = (OMX_U32)dim->dst_dim.width;
+ rect_type_out.nHeight = (OMX_U32)dim->dst_dim.height;
}
}
@@ -1109,17 +1086,15 @@
OMX_ERRORTYPE mm_jpeg_session_config_common(mm_jpeg_job_session_t *p_session)
{
OMX_ERRORTYPE rc = OMX_ErrorNone;
- int i;
OMX_INDEXTYPE exif_idx;
OMX_CONFIG_ROTATIONTYPE rotate;
- mm_jpeg_encode_params_t *p_params = &p_session->params;
mm_jpeg_encode_job_t *p_jobparams = &p_session->encode_job;
QOMX_EXIF_INFO exif_info;
/* set rotation */
memset(&rotate, 0, sizeof(rotate));
rotate.nPortIndex = 1;
- rotate.nRotation = p_jobparams->rotation;
+ rotate.nRotation = (OMX_S32)p_jobparams->rotation;
rc = OMX_SetConfig(p_session->omx_handle, OMX_IndexConfigCommonRotate,
&rotate);
if (OMX_ErrorNone != rc) {
@@ -1154,7 +1129,7 @@
exif_info.exif_data = &p_session->exif_info_local[0];
process_meta_data(p_jobparams->p_metadata, &exif_info, &p_jobparams->cam_exif_params);
/* After Parse metadata */
- p_session->exif_count_local = exif_info.numOfEntries;
+ p_session->exif_count_local = (int)exif_info.numOfEntries;
if (exif_info.numOfEntries > 0) {
/* set exif tags */
@@ -1260,9 +1235,8 @@
QOMX_WORK_BUFFER work_buffer;
OMX_INDEXTYPE work_buffer_index;
mm_jpeg_encode_params_t *p_params = &p_session->params;
- mm_jpeg_encode_job_t *p_jobparams = &p_session->encode_job;
- /* common config */
+ /* common config */
ret = mm_jpeg_session_config_common(p_session);
if (OMX_ErrorNone != ret) {
CDBG_ERROR("%s:%d] config common failed", __func__, __LINE__);
@@ -1307,7 +1281,7 @@
}
work_buffer.fd = p_session->work_buffer.p_pmem_fd;
work_buffer.vaddr = p_session->work_buffer.addr;
- work_buffer.length = p_session->work_buffer.size;
+ work_buffer.length = (uint32_t)p_session->work_buffer.size;
CDBG_ERROR("%s:%d] Work buffer %d %p WorkBufSize: %d", __func__, __LINE__,
work_buffer.fd, work_buffer.vaddr, work_buffer.length);
@@ -1345,8 +1319,6 @@
static OMX_ERRORTYPE mm_jpeg_session_configure(mm_jpeg_job_session_t *p_session)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
- mm_jpeg_encode_params_t *p_params = &p_session->params;
- mm_jpeg_obj *my_obj = (mm_jpeg_obj *)p_session->jpeg_obj;
CDBG("%s:%d] E ", __func__, __LINE__);
@@ -1399,10 +1371,7 @@
static OMX_ERRORTYPE mm_jpeg_session_encode(mm_jpeg_job_session_t *p_session)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
- mm_jpeg_encode_params_t *p_params = &p_session->params;
mm_jpeg_encode_job_t *p_jobparams = &p_session->encode_job;
- int dest_idx = 0;
- mm_jpeg_obj *my_obj = (mm_jpeg_obj *)p_session->jpeg_obj;
pthread_mutex_lock(&p_session->lock);
p_session->abort_state = MM_JPEG_ABORT_NONE;
@@ -1434,7 +1403,7 @@
snprintf(filename, 255, "/data/jpeg/mm_jpeg_int%d.yuv", p_session->ebd_count);
DUMP_TO_FILE(filename,
p_session->p_in_omx_buf[p_jobparams->src_index]->pBuffer,
- (int)p_session->p_in_omx_buf[p_jobparams->src_index]->nAllocLen);
+ (size_t)p_session->p_in_omx_buf[p_jobparams->src_index]->nAllocLen);
#endif
ret = OMX_EmptyThisBuffer(p_session->omx_handle,
@@ -1451,7 +1420,7 @@
p_session->ebd_count);
DUMP_TO_FILE(filename,
p_session->p_in_omx_thumb_buf[p_jobparams->thumb_index]->pBuffer,
- (int)p_session->p_in_omx_thumb_buf[p_jobparams->thumb_index]->nAllocLen);
+ (size_t)p_session->p_in_omx_thumb_buf[p_jobparams->thumb_index]->nAllocLen);
#endif
ret = OMX_EmptyThisBuffer(p_session->omx_handle,
p_session->p_in_omx_thumb_buf[p_jobparams->thumb_index]);
@@ -1491,11 +1460,10 @@
**/
int32_t mm_jpeg_process_encoding_job(mm_jpeg_obj *my_obj, mm_jpeg_job_q_node_t* job_node)
{
+ mm_jpeg_q_data_t qdata;
int32_t rc = 0;
OMX_ERRORTYPE ret = OMX_ErrorNone;
mm_jpeg_job_session_t *p_session = NULL;
- mm_jpeg_job_q_node_t *node = NULL;
- OMX_HANDLETYPE omx_handle = NULL;
uint32_t buf_idx;
/* check if valid session */
@@ -1510,13 +1478,15 @@
__func__, __LINE__, ret);
/* dequeue available omx handle */
- p_session = mm_jpeg_queue_deq(p_session->session_handle_q);
+ qdata = mm_jpeg_queue_deq(p_session->session_handle_q);
+ p_session = qdata.p;
if (NULL == p_session) {
CDBG_HIGH("%s:%d] No available sessions %d",
__func__, __LINE__, ret);
/* No available handles */
- mm_jpeg_queue_enq_head(&my_obj->job_mgr.job_queue, job_node);
+ qdata.p = job_node;
+ mm_jpeg_queue_enq_head(&my_obj->job_mgr.job_queue, qdata);
CDBG_HIGH("%s:%d]end enqueue %d",
__func__, __LINE__, ret);
@@ -1527,9 +1497,10 @@
p_session->auto_out_buf = OMX_FALSE;
if (job_node->enc_info.encode_job.dst_index < 0) {
/* dequeue available output buffer idx */
- buf_idx = (uint32_t)mm_jpeg_queue_deq(p_session->out_buf_q);
+ qdata = mm_jpeg_queue_deq(p_session->out_buf_q);
+ buf_idx = qdata.u32;
- if (NULL == (void*)buf_idx) {
+ if (0U == buf_idx) {
CDBG_ERROR("%s:%d] No available output buffers %d",
__func__, __LINE__, ret);
return OMX_ErrorUndefined;
@@ -1537,12 +1508,13 @@
buf_idx--;
- job_node->enc_info.encode_job.dst_index = buf_idx;
+ job_node->enc_info.encode_job.dst_index = (int32_t)buf_idx;
p_session->auto_out_buf = OMX_TRUE;
}
/* sent encode cmd to OMX, queue job into ongoing queue */
- rc = mm_jpeg_queue_enq(&my_obj->ongoing_job_q, job_node);
+ qdata.p = job_node;
+ rc = mm_jpeg_queue_enq(&my_obj->ongoing_job_q, qdata);
if (rc) {
CDBG_ERROR("%s:%d] jpeg enqueue failed %d",
__func__, __LINE__, ret);
@@ -1597,6 +1569,7 @@
**/
static void *mm_jpeg_jobmgr_thread(void *data)
{
+ mm_jpeg_q_data_t qdata;
int rc = 0;
int running = 1;
uint32_t num_ongoing_jobs = 0;
@@ -1625,7 +1598,8 @@
pthread_mutex_lock(&my_obj->job_lock);
/* can go ahead with new work */
- node = (mm_jpeg_job_q_node_t*)mm_jpeg_queue_deq(&cmd_thread->job_queue);
+ qdata = mm_jpeg_queue_deq(&cmd_thread->job_queue);
+ node = (mm_jpeg_job_q_node_t*)qdata.p;
if (node != NULL) {
switch (node->type) {
case MM_JPEG_CMD_TYPE_JOB:
@@ -1691,6 +1665,7 @@
**/
int32_t mm_jpeg_jobmgr_thread_release(mm_jpeg_obj * my_obj)
{
+ mm_jpeg_q_data_t qdata;
int32_t rc = 0;
mm_jpeg_job_cmd_thread_t * cmd_thread = &my_obj->job_mgr;
mm_jpeg_job_q_node_t* node =
@@ -1703,7 +1678,8 @@
memset(node, 0, sizeof(mm_jpeg_job_q_node_t));
node->type = MM_JPEG_CMD_TYPE_EXIT;
- mm_jpeg_queue_enq(&cmd_thread->job_queue, node);
+ qdata.p = node;
+ mm_jpeg_queue_enq(&cmd_thread->job_queue, qdata);
cam_sem_post(&cmd_thread->job_sem);
/* wait until cmd thread exits */
@@ -1733,8 +1709,8 @@
{
int32_t rc = 0;
uint32_t work_buf_size;
- int i = 0;
- int initial_workbufs_cnt = 1;
+ unsigned int i = 0;
+ unsigned int initial_workbufs_cnt = 1;
/* init locks */
pthread_mutex_init(&my_obj->job_lock, NULL);
@@ -1767,11 +1743,11 @@
pthread_mutex_destroy(&my_obj->job_lock);
return -1;
}
- work_buf_size = CEILING64(my_obj->max_pic_w) *
- CEILING64(my_obj->max_pic_h) * 1.5;
+ work_buf_size = CEILING64((uint32_t)my_obj->max_pic_w) *
+ CEILING64((uint32_t)my_obj->max_pic_h) * 3U / 2U;
for (i = 0; i < initial_workbufs_cnt; i++) {
my_obj->ionBuffer[i].size = CEILING32(work_buf_size);
- CDBG_HIGH("Max picture size %d x %d, WorkBufSize = %ld",
+ CDBG_HIGH("Max picture size %d x %d, WorkBufSize = %zu",
my_obj->max_pic_w, my_obj->max_pic_h, my_obj->ionBuffer[i].size);
my_obj->ionBuffer[i].addr = (uint8_t *)buffer_allocate(&my_obj->ionBuffer[i], 1);
@@ -1828,7 +1804,7 @@
int32_t mm_jpeg_deinit(mm_jpeg_obj *my_obj)
{
int32_t rc = 0;
- int i = 0;
+ uint32_t i = 0;
/* release jobmgr thread */
rc = mm_jpeg_jobmgr_thread_release(my_obj);
@@ -1928,13 +1904,13 @@
mm_jpeg_job_t *job,
uint32_t *job_id)
{
+ mm_jpeg_q_data_t qdata;
int32_t rc = -1;
uint8_t session_idx = 0;
uint8_t client_idx = 0;
mm_jpeg_job_q_node_t* node = NULL;
mm_jpeg_job_session_t *p_session = NULL;
mm_jpeg_encode_job_t *p_jobparams = &job->encode_job;
- uint32_t q_size;
*job_id = 0;
@@ -1972,7 +1948,7 @@
}
*job_id = job->encode_job.session_id |
- ((p_session->job_hist++ % JOB_HIST_MAX) << 16);
+ (((uint32_t)p_session->job_hist++ % JOB_HIST_MAX) << 16);
memset(node, 0, sizeof(mm_jpeg_job_q_node_t));
node->enc_info.encode_job = job->encode_job;
@@ -1982,7 +1958,8 @@
- rc = mm_jpeg_queue_enq(&my_obj->job_mgr.job_queue, node);
+ qdata.p = node;
+ rc = mm_jpeg_queue_enq(&my_obj->job_mgr.job_queue, qdata);
if (0 == rc) {
cam_sem_post(&my_obj->job_mgr.job_sem);
}
@@ -2012,9 +1989,7 @@
uint32_t jobId)
{
int32_t rc = -1;
- uint8_t clnt_idx = 0;
mm_jpeg_job_q_node_t *node = NULL;
- OMX_BOOL ret = OMX_FALSE;
mm_jpeg_job_session_t *p_session = NULL;
CDBG("%s:%d] ", __func__, __LINE__);
@@ -2049,18 +2024,20 @@
}
-static int32_t mm_jpeg_read_meta_keyfile(mm_jpeg_job_session_t *p_session, const char *filename)
+#ifdef MM_JPEG_READ_META_KEYFILE
+static int32_t mm_jpeg_read_meta_keyfile(mm_jpeg_job_session_t *p_session,
+ const char *filename)
{
int rc = 0;
FILE *fp = NULL;
- int file_size = 0;
+ size_t file_size = 0;
fp = fopen(filename, "r");
if (!fp) {
CDBG_ERROR("%s:%d] Key not present", __func__, __LINE__);
return -1;
}
fseek(fp, 0, SEEK_END);
- file_size = ftell(fp);
+ file_size = (size_t)ftell(fp);
fseek(fp, 0, SEEK_SET);
p_session->meta_enc_key = (uint8_t *) malloc((file_size + 1) * sizeof(uint8_t));
@@ -2077,6 +2054,7 @@
return rc;
}
+#endif // MM_JPEG_READ_META_KEYFILE
/** mm_jpeg_create_session:
*
@@ -2098,6 +2076,7 @@
mm_jpeg_encode_params_t *p_params,
uint32_t* p_session_id)
{
+ mm_jpeg_q_data_t qdata;
int32_t rc = 0;
OMX_ERRORTYPE ret = OMX_ErrorNone;
uint8_t clnt_idx = 0;
@@ -2109,7 +2088,7 @@
uint32_t num_omx_sessions;
uint32_t work_buf_size;
mm_jpeg_queue_t *p_session_handle_q, *p_out_buf_q;
- unsigned int work_bufs_need;
+ uint32_t work_bufs_need;
/* validate the parameters */
if ((p_params->num_src_bufs > MM_JPEG_MAX_BUF)
@@ -2134,11 +2113,11 @@
work_bufs_need = MM_JPEG_CONCURRENT_SESSIONS_COUNT;
}
CDBG_ERROR("%s:%d] >>>> Work bufs need %d", __func__, __LINE__, work_bufs_need);
- work_buf_size = CEILING64(p_params->main_dim.dst_dim.width) *
- CEILING64(p_params->main_dim.dst_dim.height) * 1.5;
+ work_buf_size = CEILING64((uint32_t)p_params->main_dim.dst_dim.width) *
+ CEILING64((uint32_t)p_params->main_dim.dst_dim.height) * 3U / 2U;
for (i = my_obj->work_buf_cnt; i < work_bufs_need; i++) {
my_obj->ionBuffer[i].size = CEILING32(work_buf_size);
- CDBG_HIGH("Max picture size %d x %d, WorkBufSize = %ld",
+ CDBG_HIGH("Max picture size %d x %d, WorkBufSize = %zu",
my_obj->max_pic_w, my_obj->max_pic_h, my_obj->ionBuffer[i].size);
my_obj->ionBuffer[i].addr = (uint8_t *)buffer_allocate(&my_obj->ionBuffer[i], 1);
@@ -2175,7 +2154,7 @@
}
for (i = 0; i < num_omx_sessions; i++) {
- int buf_idx = 0;
+ uint32_t buf_idx = 0U;
session_idx = mm_jpeg_get_new_session_idx(my_obj, clnt_idx, &p_session);
if (session_idx < 0) {
CDBG_ERROR("%s:%d] invalid session id (%d)", __func__, __LINE__, session_idx);
@@ -2207,7 +2186,8 @@
return rc;
}
- uint32_t session_id = (JOB_ID_MAGICVAL << 24) | (session_idx << 8) | clnt_idx;
+ uint32_t session_id = (JOB_ID_MAGICVAL << 24) |
+ ((uint32_t)session_idx << 8) | clnt_idx;
if (!*p_session_id) {
*p_session_id = session_id;
@@ -2220,7 +2200,8 @@
p_session->session_handle_q = p_session_handle_q;
p_session->out_buf_q = p_out_buf_q;
- mm_jpeg_queue_enq(p_session_handle_q, p_session);
+ qdata.p = p_session;
+ mm_jpeg_queue_enq(p_session_handle_q, qdata);
if (OMX_FALSE == p_session->config) {
rc = mm_jpeg_session_configure(p_session);
@@ -2237,7 +2218,8 @@
// Queue the output buf indexes
for (i = 0; i < p_params->num_dst_bufs; i++) {
- mm_jpeg_queue_enq(p_out_buf_q, (void *)(i+1));
+ qdata.u32 = i + 1;
+ mm_jpeg_queue_enq(p_out_buf_q, qdata);
}
p_session->meta_enc_key = NULL;
@@ -2295,6 +2277,7 @@
**/
static void mm_jpegenc_job_done(mm_jpeg_job_session_t *p_session)
{
+ mm_jpeg_q_data_t qdata;
mm_jpeg_obj *my_obj = (mm_jpeg_obj *)p_session->jpeg_obj;
mm_jpeg_job_q_node_t *node = NULL;
@@ -2310,11 +2293,13 @@
p_session->encoding = OMX_FALSE;
// Queue to available sessions
- mm_jpeg_queue_enq(p_session->session_handle_q, p_session);
+ qdata.p = p_session;
+ mm_jpeg_queue_enq(p_session->session_handle_q, qdata);
if (p_session->auto_out_buf) {
//Queue out buf index
- mm_jpeg_queue_enq(p_session->out_buf_q, (void*)(p_session->encode_job.dst_index +1));
+ qdata.u32 = (uint32_t)(p_session->encode_job.dst_index + 1);
+ mm_jpeg_queue_enq(p_session->out_buf_q, qdata);
}
/* wake up jobMgr thread to work on new job if there is any */
@@ -2337,10 +2322,9 @@
int32_t mm_jpeg_destroy_session(mm_jpeg_obj *my_obj,
mm_jpeg_job_session_t *p_session)
{
+ mm_jpeg_q_data_t qdata;
int32_t rc = 0;
- uint8_t clnt_idx = 0;
mm_jpeg_job_q_node_t *node = NULL;
- OMX_BOOL ret = OMX_FALSE;
uint32_t session_id = 0;
mm_jpeg_job_session_t *p_cur_sess;
@@ -2382,14 +2366,20 @@
pthread_mutex_unlock(&my_obj->job_lock);
- while (NULL != mm_jpeg_queue_deq(p_session->session_handle_q))
- ;
+ while (1) {
+ qdata = mm_jpeg_queue_deq(p_session->session_handle_q);
+ if (NULL == qdata.p)
+ break;
+ }
mm_jpeg_queue_deinit(p_session->session_handle_q);
free(p_session->session_handle_q);
p_session->session_handle_q = NULL;
- while (NULL != mm_jpeg_queue_deq(p_session->out_buf_q))
- ;
+ while (1) {
+ qdata = mm_jpeg_queue_deq(p_session->out_buf_q);
+ if (0U == qdata.u32)
+ break;
+ }
mm_jpeg_queue_deinit(p_session->out_buf_q);
free(p_session->out_buf_q);
p_session->out_buf_q = NULL;
@@ -2424,9 +2414,7 @@
mm_jpeg_job_session_t *p_session)
{
int32_t rc = -1;
- uint8_t clnt_idx = 0;
mm_jpeg_job_q_node_t *node = NULL;
- OMX_BOOL ret = OMX_FALSE;
uint32_t session_id = 0;
if (NULL == p_session) {
CDBG_ERROR("%s:%d] invalid session", __func__, __LINE__);
@@ -2497,8 +2485,6 @@
{
int32_t rc = -1;
uint8_t clnt_idx = 0;
- mm_jpeg_job_q_node_t *node = NULL;
- OMX_BOOL ret = OMX_FALSE;
int i = 0;
/* check if valid client */
@@ -2546,7 +2532,6 @@
OMX_PTR pAppData,
OMX_BUFFERHEADERTYPE *pBuffer)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
mm_jpeg_job_session_t *p_session = (mm_jpeg_job_session_t *) pAppData;
CDBG("%s:%d] count %d ", __func__, __LINE__, p_session->ebd_count);
@@ -2562,8 +2547,6 @@
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
mm_jpeg_job_session_t *p_session = (mm_jpeg_job_session_t *) pAppData;
- uint32_t i = 0;
- int rc = 0;
mm_jpeg_output_t output_buf;
CDBG("%s:%d] count %d ", __func__, __LINE__, p_session->fbd_count);
CDBG_HIGH("[KPI Perf] : PROFILE_JPEG_FBD");
@@ -2582,8 +2565,10 @@
output_buf.buf_filled_len = (uint32_t)pBuffer->nFilledLen;
output_buf.buf_vaddr = pBuffer->pBuffer;
output_buf.fd = 0;
- CDBG("%s:%d] send jpeg callback %d buf 0x%p len %u JobID %u", __func__, __LINE__,
- p_session->job_status, pBuffer->pBuffer, pBuffer->nFilledLen, p_session->jobId);
+ CDBG("%s:%d] send jpeg callback %d buf 0x%p len %u JobID %u",
+ __func__, __LINE__,
+ p_session->job_status, pBuffer->pBuffer,
+ (unsigned int)pBuffer->nFilledLen, p_session->jobId);
p_session->params.jpeg_cb(p_session->job_status,
p_session->client_hdl,
p_session->jobId,
@@ -2672,7 +2657,7 @@
pos = head->next;
while(pos != head) {
node = member_of(pos, mm_jpeg_q_node_t, list);
- data = (mm_jpeg_job_q_node_t *)node->data;
+ data = (mm_jpeg_job_q_node_t *)node->data.p;
if (data && (data->enc_info.client_handle == client_hdl)) {
CDBG_ERROR("%s:%d] found matching client handle", __func__, __LINE__);
@@ -2706,7 +2691,7 @@
pos = head->next;
while(pos != head) {
node = member_of(pos, mm_jpeg_q_node_t, list);
- data = (mm_jpeg_job_q_node_t *)node->data;
+ data = (mm_jpeg_job_q_node_t *)node->data.p;
if (data && (data->enc_info.encode_job.session_id == session_id)) {
CDBG_ERROR("%s:%d] found matching session id", __func__, __LINE__);
@@ -2741,7 +2726,7 @@
pos = head->next;
while(pos != head) {
node = member_of(pos, mm_jpeg_q_node_t, list);
- data = (mm_jpeg_job_q_node_t *)node->data;
+ data = (mm_jpeg_job_q_node_t *)node->data.p;
if (data != NULL) {
if (data->type == MM_JPEG_CMD_TYPE_DECODE_JOB) {
@@ -2781,7 +2766,7 @@
pos = head->next;
while(pos != head) {
node = member_of(pos, mm_jpeg_q_node_t, list);
- data = (mm_jpeg_job_q_node_t *)node->data;
+ data = (mm_jpeg_job_q_node_t *)node->data.p;
if (data && (data->enc_info.job_id == job_id)) {
job_node = data;
diff --git a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_exif.c b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_exif.c
index ae8741a..3c17068 100644
--- a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_exif.c
+++ b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_exif.c
@@ -35,8 +35,10 @@
#define LOWER(a) ((a) & 0xFFFF)
#define UPPER(a) (((a)>>16) & 0xFFFF)
-#define CHANGE_ENDIAN_16(a) ((0x00FF & ((a)>>8)) | (0xFF00 & ((a)<<8)))
-#define ROUND(a)((a >= 0) ? (long)(a + 0.5) : (long)(a - 0.5))
+#define CHANGE_ENDIAN_16(a) \
+ ((uint16_t)((0x00FF & ((a)>>8)) | (0xFF00 & ((a)<<8))))
+#define ROUND(a) \
+ ((a >= 0) ? (uint32_t)(a + 0.5) : (uint32_t)(a - 0.5))
#define AAA_EXIF_BUF_SIZE 10
#define AE_EXIF_SIZE 2
@@ -65,7 +67,7 @@
exif_tag_type_t type, uint32_t count, void *data)
{
int32_t rc = 0;
- int32_t numOfEntries = p_exif_info->numOfEntries;
+ uint32_t numOfEntries = (uint32_t)p_exif_info->numOfEntries;
QEXIF_INFO_DATA *p_info_data = p_exif_info->exif_data;
if(numOfEntries >= MAX_EXIF_TABLE_ENTRIES) {
ALOGE("%s: Number of entries exceeded limit", __func__);
@@ -411,7 +413,7 @@
p_ae_params->line_count, p_ae_params->real_gain);
/* Exposure time */
- if (p_ae_params->exp_time == 0) {
+ if (0.0f >= p_ae_params->exp_time) {
val_rat.num = 0;
val_rat.denom = 0;
} else {
@@ -430,7 +432,7 @@
/* Shutter Speed*/
if (p_ae_params->exp_time > 0) {
shutter_speed_value = log10(1/p_ae_params->exp_time)/log10(2);
- val_srat.num = shutter_speed_value * 1000;
+ val_srat.num = (int32_t)(shutter_speed_value * 1000.0f);
val_srat.denom = 1000;
} else {
val_srat.num = 0;
@@ -444,7 +446,7 @@
/* ISO */
short val_short;
- val_short = p_ae_params->iso_value;
+ val_short = (short) p_ae_params->iso_value;
rc = addExifEntry(exif_info, EXIFTAGID_ISO_SPEED_RATING, EXIF_SHORT,
sizeof(val_short)/2, &val_short);
if (rc) {
@@ -452,7 +454,7 @@
}
/* Gain */
- val_short = p_ae_params->real_gain;
+ val_short = (short) p_ae_params->real_gain;
rc = addExifEntry(exif_info, EXIFTAGID_GAIN_CONTROL, EXIF_SHORT,
sizeof(val_short)/2, &val_short);
if (rc) {
diff --git a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_interface.c b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_interface.c
index fbc294d..59227c3 100644
--- a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_interface.c
+++ b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_interface.c
@@ -296,7 +296,7 @@
uint32_t alloc)
{
int32_t rc = 0;
- int i = 0;
+ size_t i = 0;
CDBG_HIGH("%s:%d] alloc=%d", __func__, __LINE__, alloc);
@@ -310,13 +310,13 @@
}
g_jpeg_obj->work_buf_cnt = 0;
} else {
- int initial_workbufs_cnt = 1;
+ size_t initial_workbufs_cnt = 1;
uint32_t work_buf_size;
work_buf_size = CEILING64(g_jpeg_obj->max_pic_w) *
- CEILING64(g_jpeg_obj->max_pic_h) * 1.5;
+ CEILING64(g_jpeg_obj->max_pic_h) * 3U / 2U;
for (i = 0; i < initial_workbufs_cnt; i++) {
g_jpeg_obj->ionBuffer[i].size = CEILING32(work_buf_size);
- CDBG_HIGH("Max picture size %d x %d, WorkBufSize = %ld",
+ CDBG_HIGH("Max picture size %d x %d, WorkBufSize = %zu",
g_jpeg_obj->max_pic_w, g_jpeg_obj->max_pic_h, g_jpeg_obj->ionBuffer[i].size);
g_jpeg_obj->ionBuffer[i].addr = (uint8_t *)buffer_allocate(&g_jpeg_obj->ionBuffer[i], 1);
@@ -328,7 +328,7 @@
return -1;
}
}
- g_jpeg_obj->work_buf_cnt = i;
+ g_jpeg_obj->work_buf_cnt = (uint32_t) i;
}
return rc;
}
@@ -362,7 +362,7 @@
0x10 for mm-camera-interface
0x100 for mm-jpeg-interface */
property_get("persist.camera.hal.debug.mask", prop, "268435463"); // 0x10000007=268435463
- temp = atoi(prop);
+ temp = (uint32_t)atoi(prop);
log_level = ((temp >> 28) & 0xF);
debug_mask = (temp & HAL_DEBUG_MASK_MM_JPEG_INTERFACE);
if (debug_mask > 0)
diff --git a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_ionbuf.c b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_ionbuf.c
index a9fc4a4..7db5823 100644
--- a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_ionbuf.c
+++ b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_ionbuf.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -61,10 +61,10 @@
}
/* Make it page size aligned */
- p_buffer->alloc.len = (p_buffer->alloc.len + 4095) & (~4095);
+ p_buffer->alloc.len = (p_buffer->alloc.len + 4095U) & (~4095U);
lrc = ioctl(p_buffer->ion_fd, ION_IOC_ALLOC, &p_buffer->alloc);
if (lrc < 0) {
- CDBG_ERROR("%s :ION allocation failed len %d", __func__,
+ CDBG_ERROR("%s :ION allocation failed len %zu", __func__,
p_buffer->alloc.len);
goto ION_ALLOC_FAILED;
}
@@ -114,7 +114,7 @@
int buffer_deallocate(buffer_t *p_buffer)
{
int lrc = 0;
- int lsize = (p_buffer->size + 4095) & (~4095);
+ size_t lsize = (p_buffer->size + 4095U) & (~4095U);
struct ion_handle_data lhandle_data;
lrc = munmap(p_buffer->addr, lsize);
@@ -155,8 +155,8 @@
cache_inv_data.vaddr = p_buffer->addr;
cache_inv_data.fd = p_buffer->ion_info_fd.fd;
cache_inv_data.handle = p_buffer->ion_info_fd.handle;
- cache_inv_data.length = p_buffer->size;
- custom_data.cmd = ION_IOC_INV_CACHES;
+ cache_inv_data.length = (unsigned int)p_buffer->size;
+ custom_data.cmd = (unsigned int)ION_IOC_INV_CACHES;
custom_data.arg = (unsigned long)&cache_inv_data;
lrc = ioctl(p_buffer->ion_fd, ION_IOC_CUSTOM, &custom_data);
diff --git a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_queue.c b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_queue.c
index d721aab..03c8f3c 100644
--- a/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_queue.c
+++ b/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_queue.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -39,7 +39,7 @@
return 0;
}
-int32_t mm_jpeg_queue_enq(mm_jpeg_queue_t* queue, void* data)
+int32_t mm_jpeg_queue_enq(mm_jpeg_queue_t* queue, mm_jpeg_q_data_t data)
{
mm_jpeg_q_node_t* node =
(mm_jpeg_q_node_t *)malloc(sizeof(mm_jpeg_q_node_t));
@@ -60,7 +60,7 @@
}
-int32_t mm_jpeg_queue_enq_head(mm_jpeg_queue_t* queue, void* data)
+int32_t mm_jpeg_queue_enq_head(mm_jpeg_queue_t* queue, mm_jpeg_q_data_t data)
{
struct cam_list *head = NULL;
struct cam_list *pos = NULL;
@@ -84,13 +84,15 @@
return 0;
}
-void* mm_jpeg_queue_deq(mm_jpeg_queue_t* queue)
+mm_jpeg_q_data_t mm_jpeg_queue_deq(mm_jpeg_queue_t* queue)
{
+ mm_jpeg_q_data_t data;
mm_jpeg_q_node_t* node = NULL;
- void* data = NULL;
struct cam_list *head = NULL;
struct cam_list *pos = NULL;
+ memset(&data, 0, sizeof(data));
+
pthread_mutex_lock(&queue->lock);
head = &queue->head.list;
pos = head->next;
@@ -131,7 +133,6 @@
int32_t mm_jpeg_queue_flush(mm_jpeg_queue_t* queue)
{
mm_jpeg_q_node_t* node = NULL;
- void* data = NULL;
struct cam_list *head = NULL;
struct cam_list *pos = NULL;
@@ -146,8 +147,8 @@
/* for now we only assume there is no ptr inside data
* so we free data directly */
- if (NULL != node->data) {
- free(node->data);
+ if (NULL != node->data.p) {
+ free(node->data.p);
}
free(node);
pos = pos->next;
@@ -157,13 +158,15 @@
return 0;
}
-void* mm_jpeg_queue_peek(mm_jpeg_queue_t* queue)
+mm_jpeg_q_data_t mm_jpeg_queue_peek(mm_jpeg_queue_t* queue)
{
+ mm_jpeg_q_data_t data;
mm_jpeg_q_node_t* node = NULL;
- void* data = NULL;
struct cam_list *head = NULL;
struct cam_list *pos = NULL;
+ memset(&data, 0, sizeof(data));
+
pthread_mutex_lock(&queue->lock);
head = &queue->head.list;
pos = head->next;
diff --git a/QCamera2/stack/mm-jpeg-interface/src/mm_jpegdec.c b/QCamera2/stack/mm-jpeg-interface/src/mm_jpegdec.c
index 600099c..2e12b2b 100644
--- a/QCamera2/stack/mm-jpeg-interface/src/mm_jpegdec.c
+++ b/QCamera2/stack/mm-jpeg-interface/src/mm_jpegdec.c
@@ -68,7 +68,6 @@
**/
static int32_t mm_jpegdec_destroy_job(mm_jpeg_job_session_t *p_session)
{
- mm_jpeg_decode_job_t *p_jobparams = &p_session->decode_job;
int32_t rc = 0;
return rc;
@@ -126,12 +125,11 @@
OMX_ERRORTYPE ret = OMX_ErrorNone;
QOMX_BUFFER_INFO lbuffer_info;
mm_jpeg_decode_params_t *p_params = &p_session->dec_params;
- mm_jpeg_decode_job_t *p_jobparams = &p_session->decode_job;
memset(&lbuffer_info, 0x0, sizeof(QOMX_BUFFER_INFO));
for (i = 0; i < p_params->num_src_bufs; i++) {
CDBG("%s:%d] Source buffer %d", __func__, __LINE__, i);
- lbuffer_info.fd = p_params->src_main_buf[i].fd;
+ lbuffer_info.fd = (OMX_U32)p_params->src_main_buf[i].fd;
ret = OMX_UseBuffer(p_session->omx_handle, &(p_session->p_in_omx_buf[i]), 0,
&lbuffer_info, p_params->src_main_buf[i].buf_size,
p_params->src_main_buf[i].buf_vaddr);
@@ -163,7 +161,6 @@
uint32_t i = 0;
mm_jpeg_job_session_t* p_session = (mm_jpeg_job_session_t *)data;
mm_jpeg_decode_params_t *p_params = &p_session->dec_params;
- mm_jpeg_decode_job_t *p_jobparams = &p_session->decode_job;
for (i = 0; i < p_params->num_src_bufs; i++) {
CDBG("%s:%d] Source buffer %d", __func__, __LINE__, i);
@@ -201,7 +198,6 @@
OMX_ERRORTYPE mm_jpegdec_session_create(mm_jpeg_job_session_t* p_session)
{
OMX_ERRORTYPE rc = OMX_ErrorNone;
- mm_jpeg_cirq_t *p_cirq = NULL;
pthread_mutex_init(&p_session->lock, NULL);
pthread_cond_init(&p_session->cond, NULL);
@@ -316,18 +312,18 @@
}
p_session->inputPort.format.image.nFrameWidth =
- p_jobparams->main_dim.src_dim.width;
+ (OMX_U32)p_jobparams->main_dim.src_dim.width;
p_session->inputPort.format.image.nFrameHeight =
- p_jobparams->main_dim.src_dim.height;
+ (OMX_U32)p_jobparams->main_dim.src_dim.height;
p_session->inputPort.format.image.nStride =
p_src_buf->offset.mp[0].stride;
p_session->inputPort.format.image.nSliceHeight =
- p_src_buf->offset.mp[0].scanline;
+ (OMX_U32)p_src_buf->offset.mp[0].scanline;
p_session->inputPort.format.image.eColorFormat =
map_jpeg_format(p_params->color_format);
p_session->inputPort.nBufferSize =
p_params->src_main_buf[p_jobparams->src_index].buf_size;
- p_session->inputPort.nBufferCountActual = p_params->num_src_bufs;
+ p_session->inputPort.nBufferCountActual = (OMX_U32)p_params->num_src_bufs;
ret = OMX_SetParameter(p_session->omx_handle, OMX_IndexParamPortDefinition,
&p_session->inputPort);
if (ret) {
@@ -354,9 +350,6 @@
OMX_ERRORTYPE mm_jpegdec_session_config_main(mm_jpeg_job_session_t *p_session)
{
OMX_ERRORTYPE rc = OMX_ErrorNone;
- OMX_IMAGE_PARAM_QFACTORTYPE q_factor;
- mm_jpeg_decode_params_t *p_params = &p_session->dec_params;
- mm_jpeg_decode_job_t *p_jobparams = &p_session->decode_job;
/* config port */
CDBG("%s:%d] config port", __func__, __LINE__);
@@ -387,9 +380,6 @@
static OMX_ERRORTYPE mm_jpegdec_session_configure(mm_jpeg_job_session_t *p_session)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
- mm_jpeg_decode_params_t *p_params = &p_session->dec_params;
- mm_jpeg_decode_job_t *p_jobparams = &p_session->decode_job;
- mm_jpeg_obj *my_obj = (mm_jpeg_obj *)p_session->jpeg_obj;
CDBG("%s:%d] E ", __func__, __LINE__);
@@ -522,8 +512,6 @@
OMX_ERRORTYPE ret = OMX_ErrorNone;
mm_jpeg_decode_params_t *p_params = &p_session->dec_params;
mm_jpeg_decode_job_t *p_jobparams = &p_session->decode_job;
- int dest_idx = 0;
- mm_jpeg_obj *my_obj = (mm_jpeg_obj *)p_session->jpeg_obj;
OMX_EVENTTYPE lEvent;
uint32_t i;
QOMX_BUFFER_INFO lbuffer_info;
@@ -587,17 +575,18 @@
// Set port definition
p_session->outputPort.format.image.nFrameWidth =
- p_jobparams->main_dim.dst_dim.width;
+ (OMX_U32)p_jobparams->main_dim.dst_dim.width;
p_session->outputPort.format.image.nFrameHeight =
- p_jobparams->main_dim.dst_dim.height;
+ (OMX_U32)p_jobparams->main_dim.dst_dim.height;
p_session->outputPort.format.image.eColorFormat =
map_jpeg_format(p_params->color_format);
p_session->outputPort.nBufferSize =
p_params->dest_buf[p_jobparams->dst_index].buf_size;
- p_session->outputPort.nBufferCountActual = p_params->num_dst_bufs;
+ p_session->outputPort.nBufferCountActual = (OMX_U32)p_params->num_dst_bufs;
p_session->outputPort.format.image.nSliceHeight =
+ (OMX_U32)
p_params->dest_buf[p_jobparams->dst_index].offset.mp[0].scanline;
p_session->outputPort.format.image.nStride =
p_params->dest_buf[p_jobparams->dst_index].offset.mp[0].stride;
@@ -617,8 +606,8 @@
memset(&lbuffer_info, 0x0, sizeof(QOMX_BUFFER_INFO));
// Use buffers
for (i = 0; i < p_params->num_dst_bufs; i++) {
- lbuffer_info.fd = p_params->dest_buf[i].fd;
- CDBG("%s:%d] Dest buffer %d", __func__, __LINE__, i);
+ lbuffer_info.fd = (OMX_U32)p_params->dest_buf[i].fd;
+ CDBG("%s:%d] Dest buffer %d", __func__, __LINE__, (unsigned int)i);
ret = OMX_UseBuffer(p_session->omx_handle, &(p_session->p_out_omx_buf[i]),
1, &lbuffer_info, p_params->dest_buf[i].buf_size,
p_params->dest_buf[i].buf_vaddr);
@@ -674,10 +663,10 @@
**/
int32_t mm_jpegdec_process_decoding_job(mm_jpeg_obj *my_obj, mm_jpeg_job_q_node_t* job_node)
{
+ mm_jpeg_q_data_t qdata;
int32_t rc = 0;
OMX_ERRORTYPE ret = OMX_ErrorNone;
mm_jpeg_job_session_t *p_session = NULL;
- mm_jpeg_job_q_node_t *node = NULL;
/* check if valid session */
p_session = mm_jpeg_get_session(my_obj, job_node->dec_info.job_id);
@@ -688,7 +677,8 @@
}
/* sent encode cmd to OMX, queue job into ongoing queue */
- rc = mm_jpeg_queue_enq(&my_obj->ongoing_job_q, job_node);
+ qdata.p = job_node;
+ rc = mm_jpeg_queue_enq(&my_obj->ongoing_job_q, qdata);
if (rc) {
CDBG_ERROR("%s:%d] jpeg enqueue failed %d",
__func__, __LINE__, ret);
@@ -746,6 +736,7 @@
mm_jpeg_job_t *job,
uint32_t *job_id)
{
+ mm_jpeg_q_data_t qdata;
int32_t rc = -1;
uint8_t session_idx = 0;
uint8_t client_idx = 0;
@@ -797,7 +788,8 @@
node->dec_info.client_handle = p_session->client_hdl;
node->type = MM_JPEG_CMD_TYPE_DECODE_JOB;
- rc = mm_jpeg_queue_enq(&my_obj->job_mgr.job_queue, node);
+ qdata.p = node;
+ rc = mm_jpeg_queue_enq(&my_obj->job_mgr.job_queue, qdata);
if (0 == rc) {
cam_sem_post(&my_obj->job_mgr.job_sem);
}
@@ -859,7 +851,8 @@
return rc;
}
- *p_session_id = (JOB_ID_MAGICVAL << 24) | (session_idx << 8) | clnt_idx;
+ *p_session_id = (JOB_ID_MAGICVAL << 24) |
+ ((unsigned)session_idx << 8) | clnt_idx;
/*copy the params*/
p_session->dec_params = *p_params;
@@ -888,9 +881,7 @@
mm_jpeg_job_session_t *p_session)
{
int32_t rc = 0;
- uint8_t clnt_idx = 0;
mm_jpeg_job_q_node_t *node = NULL;
- OMX_BOOL ret = OMX_FALSE;
uint32_t session_id = p_session->sessionId;
if (NULL == p_session) {
@@ -958,7 +949,6 @@
OMX_PTR pAppData,
OMX_BUFFERHEADERTYPE *pBuffer)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
mm_jpeg_job_session_t *p_session = (mm_jpeg_job_session_t *) pAppData;
CDBG("%s:%d] count %d ", __func__, __LINE__, p_session->ebd_count);
@@ -974,8 +964,6 @@
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
mm_jpeg_job_session_t *p_session = (mm_jpeg_job_session_t *) pAppData;
- uint32_t i = 0;
- int rc = 0;
mm_jpeg_output_t output_buf;
CDBG("%s:%d] count %d ", __func__, __LINE__, p_session->fbd_count);
@@ -1085,9 +1073,7 @@
uint32_t jobId)
{
int32_t rc = -1;
- uint8_t clnt_idx = 0;
mm_jpeg_job_q_node_t *node = NULL;
- OMX_BOOL ret = OMX_FALSE;
mm_jpeg_job_session_t *p_session = NULL;
CDBG("%s:%d] ", __func__, __LINE__);
diff --git a/QCamera2/stack/mm-jpeg-interface/src/mm_jpegdec_interface.c b/QCamera2/stack/mm-jpeg-interface/src/mm_jpegdec_interface.c
index 5a1a1c3..08c7d1d 100644
--- a/QCamera2/stack/mm-jpeg-interface/src/mm_jpegdec_interface.c
+++ b/QCamera2/stack/mm-jpeg-interface/src/mm_jpegdec_interface.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -42,9 +42,6 @@
static mm_jpeg_obj* g_jpegdec_obj = NULL;
-static pthread_mutex_t g_dec_handler_lock = PTHREAD_MUTEX_INITIALIZER;
-
-
/** mm_jpeg_intf_start_job:
*
* Arguments:
diff --git a/QCamera2/stack/mm-jpeg-interface/test/Android.mk b/QCamera2/stack/mm-jpeg-interface/test/Android.mk
index a1955f3..0aef83d 100644
--- a/QCamera2/stack/mm-jpeg-interface/test/Android.mk
+++ b/QCamera2/stack/mm-jpeg-interface/test/Android.mk
@@ -7,8 +7,9 @@
LOCAL_MODULE_TAGS := optional
LOCAL_CFLAGS := -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID
-ifneq ($(call is-platform-sdk-version-at-least,20),true)
-LOCAL_CFLAGS += -Werror
+LOCAL_CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter
+ifeq ($(call is-platform-sdk-version-at-least,20),true)
+LOCAL_CFLAGS += -Wno-error=deprecated-declarations -Wno-error=deprecated
endif
LOCAL_CFLAGS += -D_ANDROID_
LOCAL_CFLAGS += -include mm_jpeg_dbg.h
@@ -51,8 +52,9 @@
LOCAL_MODULE_TAGS := optional
LOCAL_CFLAGS := -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID
-ifneq ($(call is-platform-sdk-version-at-least,20),true)
-LOCAL_CFLAGS += -Werror
+LOCAL_CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter
+ifeq ($(call is-platform-sdk-version-at-least,20),true)
+LOCAL_CFLAGS += -Wno-error=deprecated-declarations -Wno-error=deprecated
endif
LOCAL_CFLAGS += -D_ANDROID_
LOCAL_CFLAGS += -include mm_jpeg_dbg.h
diff --git a/QCamera2/stack/mm-jpeg-interface/test/mm_jpeg_test.c b/QCamera2/stack/mm-jpeg-interface/test/mm_jpeg_test.c
index 39f783b..35aa015 100644
--- a/QCamera2/stack/mm-jpeg-interface/test/mm_jpeg_test.c
+++ b/QCamera2/stack/mm-jpeg-interface/test/mm_jpeg_test.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -42,7 +42,7 @@
* dump the image to the file
**/
#define DUMP_TO_FILE(filename, p_addr, len) ({ \
- int rc = 0; \
+ size_t rc = 0; \
FILE *fp = fopen(filename, "w+"); \
if (fp) { \
rc = fwrite(p_addr, 1, len, fp); \
@@ -52,15 +52,15 @@
} \
})
-static int g_count = 1, g_i;
+static uint32_t g_count = 1U, g_i;
typedef struct {
char *filename;
int width;
int height;
char *out_filename;
- int burst_mode;
- int min_out_bufs;
+ uint32_t burst_mode;
+ uint32_t min_out_bufs;
} jpeg_test_input_t;
static jpeg_test_input_t jpeg_input[] = {
@@ -90,8 +90,8 @@
mm_jpeg_job_t job;
uint32_t session_id;
uint32_t num_bufs;
- int min_out_bufs;
- uint32_t buf_filled_len[MAX_NUM_BUFS];
+ uint32_t min_out_bufs;
+ size_t buf_filled_len[MAX_NUM_BUFS];
} mm_jpeg_intf_test_t;
static void mm_jpeg_encode_callback(jpeg_job_status_t status,
@@ -114,12 +114,12 @@
CDBG_ERROR("%s:%d] Cannot find job ID!!!", __func__, __LINE__);
goto error;
}
- CDBG_ERROR("%s:%d] Encode success addr %p len %d idx %d",
+ CDBG_ERROR("%s:%d] Encode success addr %p len %zu idx %d",
__func__, __LINE__, p_output->buf_vaddr, p_output->buf_filled_len, i);
p_obj->buf_filled_len[i] = p_output->buf_filled_len;
if (p_obj->min_out_bufs) {
- CDBG_ERROR("%s:%d] Saving file%s addr %p len %d",
+ CDBG_ERROR("%s:%d] Saving file%s addr %p len %zu",
__func__, __LINE__, p_obj->out_filename[i],
p_output->buf_vaddr, p_output->buf_filled_len);
@@ -171,20 +171,19 @@
memset(p_buffer, 0x0, sizeof(buffer_t));
}
-int mm_jpeg_test_read(mm_jpeg_intf_test_t *p_obj, int idx)
+int mm_jpeg_test_read(mm_jpeg_intf_test_t *p_obj, uint32_t idx)
{
- int rc = 0;
FILE *fp = NULL;
- int file_size = 0;
+ size_t file_size = 0;
fp = fopen(p_obj->filename[idx], "rb");
if (!fp) {
CDBG_ERROR("%s:%d] error", __func__, __LINE__);
return -1;
}
fseek(fp, 0, SEEK_END);
- file_size = ftell(fp);
+ file_size = (size_t)ftell(fp);
fseek(fp, 0, SEEK_SET);
- CDBG_ERROR("%s:%d] input file size is %d buf_size %ld",
+ CDBG_ERROR("%s:%d] input file size is %zu buf_size %zu",
__func__, __LINE__, file_size, p_obj->input[idx].size);
if (p_obj->input[idx].size > file_size) {
@@ -200,11 +199,11 @@
static int encode_init(jpeg_test_input_t *p_input, mm_jpeg_intf_test_t *p_obj)
{
int rc = -1;
- int size = p_input->width * p_input->height;
+ size_t size = (size_t)(p_input->width * p_input->height);
mm_jpeg_encode_params_t *p_params = &p_obj->params;
mm_jpeg_encode_job_t *p_job_params = &p_obj->job.encode_job;
- int i = 0;
- int burst_mode = p_input->burst_mode;
+ uint32_t i = 0;
+ uint32_t burst_mode = p_input->burst_mode;
do {
p_obj->filename[i] = p_input->filename;
@@ -235,10 +234,10 @@
p_params->src_main_buf[i].fd = p_obj->input[i].p_pmem_fd;
p_params->src_main_buf[i].index = i;
p_params->src_main_buf[i].format = MM_JPEG_FMT_YUV;
- p_params->src_main_buf[i].offset.mp[0].len = size;
+ p_params->src_main_buf[i].offset.mp[0].len = (uint32_t)size;
p_params->src_main_buf[i].offset.mp[0].stride = p_input->width;
p_params->src_main_buf[i].offset.mp[0].scanline = p_input->height;
- p_params->src_main_buf[i].offset.mp[1].len = size >> 1;
+ p_params->src_main_buf[i].offset.mp[1].len = (uint32_t)(size >> 1);
@@ -263,7 +262,7 @@
p_params->num_dst_bufs = p_obj->num_bufs;
}
- for (i = 0; i < (int)p_params->num_dst_bufs; i++) {
+ for (i = 0; i < (uint32_t)p_params->num_dst_bufs; i++) {
p_obj->output[i].size = size * 3/2;
rc = mm_jpeg_test_alloc(&p_obj->output[i], 0);
if (rc) {
@@ -322,7 +321,7 @@
{
int rc = 0;
mm_jpeg_intf_test_t jpeg_obj;
- unsigned int i = 0;
+ uint32_t i = 0;
memset(&jpeg_obj, 0x0, sizeof(jpeg_obj));
rc = encode_init(p_input, &jpeg_obj);
@@ -355,8 +354,9 @@
for (i = 0; i < jpeg_obj.num_bufs; i++) {
jpeg_obj.job.job_type = JPEG_JOB_TYPE_ENCODE;
- jpeg_obj.job.encode_job.src_index = i;
- jpeg_obj.job.encode_job.dst_index = i;
+ jpeg_obj.job.encode_job.src_index = (int32_t) i;
+ jpeg_obj.job.encode_job.dst_index = (int32_t) i;
+
if (jpeg_obj.params.burst_mode && jpeg_obj.min_out_bufs) {
jpeg_obj.job.encode_job.dst_index = -1;
}
@@ -386,7 +386,7 @@
for (i = 0; i < jpeg_obj.num_bufs; i++) {
if (!jpeg_obj.min_out_bufs) {
// Save output files
- CDBG_ERROR("%s:%d] Saving file%s addr %p len %d",
+ CDBG_ERROR("%s:%d] Saving file%s addr %p len %zu",
__func__, __LINE__,jpeg_obj.out_filename[i],
jpeg_obj.output[i].addr, jpeg_obj.buf_filled_len[i]);
@@ -416,7 +416,8 @@
static int mm_jpeg_test_get_input(int argc, char *argv[],
jpeg_test_input_t *p_test)
{
- int c, in_file_cnt = 0, out_file_cnt = 0, i;
+ int c;
+ size_t in_file_cnt = 0, out_file_cnt = 0, i;
int idx = 0;
jpeg_test_input_t *p_test_base = p_test;
@@ -464,7 +465,7 @@
default:;
}
}
- fprintf(stderr, "Infiles: %d Outfiles: %d\n", in_file_cnt, out_file_cnt);
+ fprintf(stderr, "Infiles: %zu Outfiles: %zu\n", in_file_cnt, out_file_cnt);
if (in_file_cnt > out_file_cnt) {
fprintf(stderr, "%-25s\n", "Insufficient number of output files!");
diff --git a/QCamera2/stack/mm-jpeg-interface/test/mm_jpegdec_test.c b/QCamera2/stack/mm-jpeg-interface/test/mm_jpegdec_test.c
index 92ec2e2..f83c1e3 100644
--- a/QCamera2/stack/mm-jpeg-interface/test/mm_jpegdec_test.c
+++ b/QCamera2/stack/mm-jpeg-interface/test/mm_jpegdec_test.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -36,7 +36,7 @@
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define CLAMP(x, min, max) MIN(MAX((x), (min)), (max))
-#define TIME_IN_US(r) ((uint64_t)r.tv_sec * 1000000LL + r.tv_usec)
+#define TIME_IN_US(r) ((uint64_t)r.tv_sec * 1000000LL + (uint64_t)r.tv_usec)
struct timeval dtime[2];
@@ -48,7 +48,7 @@
* dump the image to the file
**/
#define DUMP_TO_FILE(filename, p_addr, len) ({ \
- int rc = 0; \
+ size_t rc = 0; \
FILE *fp = fopen(filename, "w+"); \
if (fp) { \
rc = fwrite(p_addr, 1, len, fp); \
@@ -68,11 +68,6 @@
int format;
} jpeg_test_input_t;
-static jpeg_test_input_t jpeg_input[] = {
- {"/data/test.jpg", 5248, 3936, "/data/test.yuv",
- MM_JPEG_COLOR_FORMAT_YCBCRLP_H2V2}
-};
-
typedef struct {
char *filename;
int width;
@@ -125,7 +120,7 @@
CDBG_ERROR("%s:%d] Decode time %llu ms",
__func__, __LINE__, ((TIME_IN_US(dtime[1]) - TIME_IN_US(dtime[0]))/1000));
- CDBG_ERROR("%s:%d] Decode success file%s addr %p len %d",
+ CDBG_ERROR("%s:%d] Decode success file%s addr %p len %zu",
__func__, __LINE__, p_obj->out_filename,
p_output->buf_vaddr, p_output->buf_filled_len);
DUMP_TO_FILE(p_obj->out_filename, p_output->buf_vaddr, p_output->buf_filled_len);
@@ -177,17 +172,17 @@
{
int rc = 0;
FILE *fp = NULL;
- int file_size = 0;
+ size_t file_size = 0;
fp = fopen(p_obj->filename, "rb");
if (!fp) {
CDBG_ERROR("%s:%d] error", __func__, __LINE__);
return -1;
}
fseek(fp, 0, SEEK_END);
- file_size = ftell(fp);
+ file_size = (size_t)ftell(fp);
fseek(fp, 0, SEEK_SET);
- CDBG_ERROR("%s:%d] input file size is %d",
+ CDBG_ERROR("%s:%d] input file size is %zu",
__func__, __LINE__, file_size);
p_obj->input.size = file_size;
@@ -204,9 +199,9 @@
return 0;
}
-void chromaScale(mm_jpeg_color_format format, float *cScale)
+void chromaScale(mm_jpeg_color_format format, double *cScale)
{
- float scale;
+ double scale;
switch(format) {
case MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2:
@@ -237,8 +232,8 @@
static int decode_init(jpeg_test_input_t *p_input, mm_jpegdec_intf_test_t *p_obj)
{
int rc = -1;
- int size = CEILING16(p_input->width) * CEILING16(p_input->height);
- float cScale;
+ size_t size = (size_t)(CEILING16(p_input->width) * CEILING16(p_input->height));
+ double cScale;
mm_jpeg_decode_params_t *p_params = &p_obj->params;
mm_jpeg_decode_job_t *p_job_params = &p_obj->job.decode_job;
@@ -252,7 +247,7 @@
pthread_cond_init(&p_obj->cond, NULL);
chromaScale(p_input->format, &cScale);
- p_obj->output.size = size * cScale;
+ p_obj->output.size = (size_t)((double)size * cScale);
rc = mm_jpegdec_test_alloc(&p_obj->output, p_obj->use_ion);
if (rc) {
CDBG_ERROR("%s:%d] Error",__func__, __LINE__);
@@ -275,8 +270,9 @@
p_params->dest_buf[0].buf_vaddr = p_obj->output.addr;
p_params->dest_buf[0].fd = p_obj->output.p_pmem_fd;
p_params->dest_buf[0].format = MM_JPEG_FMT_YUV;
- p_params->dest_buf[0].offset.mp[0].len = size;
- p_params->dest_buf[0].offset.mp[1].len = size * (cScale-1.0);
+ p_params->dest_buf[0].offset.mp[0].len = (uint32_t)size;
+ p_params->dest_buf[0].offset.mp[1].len =
+ (uint32_t)((double)size * (cScale - 1.0));
p_params->dest_buf[0].offset.mp[0].stride = CEILING16(p_input->width);
p_params->dest_buf[0].offset.mp[0].scanline = CEILING16(p_input->height);
p_params->dest_buf[0].offset.mp[1].stride = CEILING16(p_input->width);
@@ -363,7 +359,7 @@
int format = 0;
format = atoi(optarg);
int num_formats = ARR_SZ(col_formats);
- CLAMP(format, 0, num_formats);
+ format = CLAMP(format, 0, num_formats);
p_test->format = col_formats[format].eColorFormat;
fprintf(stderr, "%-25s%s\n", "Default image format",
col_formats[format].format_str);