camera: Remove unused files

Change-Id: I0c717d165162469ba4b78ea07da6dd88b5cfc18a
This commit is contained in:
Michael Bestas 2017-11-14 17:10:06 +02:00 committed by Darshan Manjrekar
parent a018167757
commit 782b2a0c20
9 changed files with 0 additions and 6422 deletions

View file

@ -1,256 +0,0 @@
/*
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#ifndef ANDROID_HARDWARE_QCAMERA_PARAMETERS_H
#define ANDROID_HARDWARE_QCAMERA_PARAMETERS_H
// Camera dependencies
#include <camera/CameraParameters.h>
namespace android {
struct FPSRange{
int minFPS;
int maxFPS;
FPSRange(){
minFPS=0;
maxFPS=0;
};
FPSRange(int min,int max){
minFPS=min;
maxFPS=max;
};
};
class QCameraParameters: public CameraParameters
{
public:
#if 1
QCameraParameters() : CameraParameters() {};
QCameraParameters(const String8 &params): CameraParameters(params) {};
#else
QCameraParameters() : CameraParameters() {};
QCameraParameters(const String8 &params) { unflatten(params); }
#endif
~QCameraParameters();
// Supported PREVIEW/RECORDING SIZES IN HIGH FRAME RATE recording, sizes in pixels.
// Example value: "800x480,432x320". Read only.
static const char KEY_SUPPORTED_HFR_SIZES[];
// The mode of preview frame rate.
// Example value: "frame-rate-auto, frame-rate-fixed".
static const char KEY_PREVIEW_FRAME_RATE_MODE[];
static const char KEY_SUPPORTED_PREVIEW_FRAME_RATE_MODES[];
static const char KEY_PREVIEW_FRAME_RATE_AUTO_MODE[];
static const char KEY_PREVIEW_FRAME_RATE_FIXED_MODE[];
static const char KEY_SKIN_TONE_ENHANCEMENT[] ;
static const char KEY_SUPPORTED_SKIN_TONE_ENHANCEMENT_MODES[] ;
//Touch Af/AEC settings.
static const char KEY_TOUCH_AF_AEC[];
static const char KEY_SUPPORTED_TOUCH_AF_AEC[];
//Touch Index for AEC.
static const char KEY_TOUCH_INDEX_AEC[];
//Touch Index for AF.
static const char KEY_TOUCH_INDEX_AF[];
// Current auto scene detection mode.
// Example value: "off" or SCENE_DETECT_XXX constants. Read/write.
static const char KEY_SCENE_DETECT[];
// Supported auto scene detection settings.
// Example value: "off,backlight,snow/cloudy". Read only.
static const char KEY_SUPPORTED_SCENE_DETECT[];
// Returns true if video snapshot is supported. That is, applications
static const char KEY_FULL_VIDEO_SNAP_SUPPORTED[];
static const char KEY_POWER_MODE_SUPPORTED[];
static const char KEY_ISO_MODE[];
static const char KEY_SUPPORTED_ISO_MODES[];
static const char KEY_LENSSHADE[] ;
static const char KEY_SUPPORTED_LENSSHADE_MODES[] ;
static const char KEY_AUTO_EXPOSURE[];
static const char KEY_SUPPORTED_AUTO_EXPOSURE[];
static const char KEY_GPS_LATITUDE_REF[];
static const char KEY_GPS_LONGITUDE_REF[];
static const char KEY_GPS_ALTITUDE_REF[];
static const char KEY_GPS_STATUS[];
static const char KEY_EXIF_DATETIME[];
static const char KEY_MEMORY_COLOR_ENHANCEMENT[];
static const char KEY_SUPPORTED_MEM_COLOR_ENHANCE_MODES[];
static const char KEY_POWER_MODE[];
static const char KEY_ZSL[];
static const char KEY_SUPPORTED_ZSL_MODES[];
static const char KEY_CAMERA_MODE[];
static const char KEY_VIDEO_HIGH_FRAME_RATE[];
static const char KEY_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES[];
static const char KEY_HIGH_DYNAMIC_RANGE_IMAGING[];
static const char KEY_SUPPORTED_HDR_IMAGING_MODES[];
static const char KEY_AE_BRACKET_HDR[];
// DENOISE
static const char KEY_DENOISE[];
static const char KEY_SUPPORTED_DENOISE[];
//Selectable zone AF.
static const char KEY_SELECTABLE_ZONE_AF[];
static const char KEY_SUPPORTED_SELECTABLE_ZONE_AF[];
//Face Detection
static const char KEY_FACE_DETECTION[];
static const char KEY_SUPPORTED_FACE_DETECTION[];
//Redeye Reduction
static const char KEY_REDEYE_REDUCTION[];
static const char KEY_SUPPORTED_REDEYE_REDUCTION[];
static const char EFFECT_EMBOSS[];
static const char EFFECT_SKETCH[];
static const char EFFECT_NEON[];
// Values for Touch AF/AEC
static const char TOUCH_AF_AEC_OFF[] ;
static const char TOUCH_AF_AEC_ON[] ;
static const char SCENE_MODE_ASD[];
static const char SCENE_MODE_BACKLIGHT[];
static const char SCENE_MODE_FLOWERS[];
static const char SCENE_MODE_AR[];
static const char SCENE_MODE_HDR[];
static const char SCENE_DETECT_OFF[];
static const char SCENE_DETECT_ON[];
static const char PIXEL_FORMAT_YUV420SP_ADRENO[]; // ADRENO
static const char PIXEL_FORMAT_RAW[];
static const char PIXEL_FORMAT_YV12[]; // NV12
static const char PIXEL_FORMAT_NV12[]; //NV12
// Normal focus mode. Applications should call
// CameraHardwareInterface.autoFocus to start the focus in this mode.
static const char FOCUS_MODE_NORMAL[];
static const char ISO_AUTO[];
static const char ISO_HJR[] ;
static const char ISO_100[];
static const char ISO_200[] ;
static const char ISO_400[];
static const char ISO_800[];
static const char ISO_1600[];
// Values for Lens Shading
static const char LENSSHADE_ENABLE[] ;
static const char LENSSHADE_DISABLE[] ;
// Values for auto exposure settings.
static const char AUTO_EXPOSURE_FRAME_AVG[];
static const char AUTO_EXPOSURE_CENTER_WEIGHTED[];
static const char AUTO_EXPOSURE_SPOT_METERING[];
static const char KEY_SHARPNESS[];
static const char KEY_MAX_SHARPNESS[];
static const char KEY_CONTRAST[];
static const char KEY_MAX_CONTRAST[];
static const char KEY_SATURATION[];
static const char KEY_MAX_SATURATION[];
static const char KEY_HISTOGRAM[] ;
static const char KEY_SUPPORTED_HISTOGRAM_MODES[] ;
// Values for HISTOGRAM
static const char HISTOGRAM_ENABLE[] ;
static const char HISTOGRAM_DISABLE[] ;
// Values for SKIN TONE ENHANCEMENT
static const char SKIN_TONE_ENHANCEMENT_ENABLE[] ;
static const char SKIN_TONE_ENHANCEMENT_DISABLE[] ;
// Values for Denoise
static const char DENOISE_OFF[] ;
static const char DENOISE_ON[] ;
// Values for auto exposure settings.
static const char SELECTABLE_ZONE_AF_AUTO[];
static const char SELECTABLE_ZONE_AF_SPOT_METERING[];
static const char SELECTABLE_ZONE_AF_CENTER_WEIGHTED[];
static const char SELECTABLE_ZONE_AF_FRAME_AVERAGE[];
// Values for Face Detection settings.
static const char FACE_DETECTION_OFF[];
static const char FACE_DETECTION_ON[];
// Values for MCE settings.
static const char MCE_ENABLE[];
static const char MCE_DISABLE[];
// Values for ZSL settings.
static const char ZSL_OFF[];
static const char ZSL_ON[];
// Values for HDR Bracketing settings.
static const char AE_BRACKET_HDR_OFF[];
static const char AE_BRACKET_HDR[];
static const char AE_BRACKET[];
// Values for Power mode settings.
static const char LOW_POWER[];
static const char NORMAL_POWER[];
// Values for HFR settings.
static const char VIDEO_HFR_OFF[];
static const char VIDEO_HFR_2X[];
static const char VIDEO_HFR_3X[];
static const char VIDEO_HFR_4X[];
// Values for Redeye Reduction settings.
static const char REDEYE_REDUCTION_ENABLE[];
static const char REDEYE_REDUCTION_DISABLE[];
// Values for HDR settings.
static const char HDR_ENABLE[];
static const char HDR_DISABLE[];
// Values for Redeye Reduction settings.
// static const char REDEYE_REDUCTION_ENABLE[];
// static const char REDEYE_REDUCTION_DISABLE[];
// Values for HDR settings.
// static const char HDR_ENABLE[];
// static const char HDR_DISABLE[];
static const char KEY_SINGLE_ISP_OUTPUT_ENABLED[];
static const char KEY_SUPPORTED_CAMERA_FEATURES[];
static const char KEY_MAX_NUM_REQUESTED_FACES[];
enum {
CAMERA_ORIENTATION_UNKNOWN = 0,
CAMERA_ORIENTATION_PORTRAIT = 1,
CAMERA_ORIENTATION_LANDSCAPE = 2,
};
int getOrientation() const;
void setOrientation(int orientation);
void getSupportedHfrSizes(Vector<Size> &sizes) const;
void setPreviewFpsRange(int minFPS,int maxFPS);
void setPreviewFrameRateMode(const char *mode);
const char *getPreviewFrameRateMode() const;
void setTouchIndexAec(int x, int y);
void getTouchIndexAec(int *x, int *y) const;
void setTouchIndexAf(int x, int y);
void getTouchIndexAf(int *x, int *y) const;
void getMeteringAreaCenter(int * x, int *y) const;
};
}; // namespace android
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,49 +0,0 @@
/* Copyright (c) 2011-2012, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __QCAMERA_MJPEG_DECODE_H
#define __QCAMERA_MJPEG_DECODE_H
typedef int MJPEGD_ERR;
#define MJPEGD_NO_ERROR 0
#define MJPEGD_ERROR -1
#define MJPEGD_INSUFFICIENT_MEM -2
MJPEGD_ERR mjpegDecoderInit(void**);
MJPEGD_ERR mjpegDecoderDestroy(void* mjpegd);
MJPEGD_ERR mjpegDecode(
void* mjpegd,
char* mjpegBuffer,
int mjpegBufferSize,
char* outputYptr,
char* outputUVptr,
int outputFormat);
#endif /* __QCAMERA_MJPEG_DECODE_H */

View file

@ -1,178 +0,0 @@
/* Copyright (c) 2012, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ANDROID_HARDWARE_QCAMERA_USB_PARM_H
#define ANDROID_HARDWARE_QCAMERA_USB_PARM_H
#include <utils/threads.h>
#include <hardware/camera.h>
#include <binder/MemoryBase.h>
#include <binder/MemoryHeapBase.h>
#include <utils/threads.h>
#include <cutils/properties.h>
#include <camera/Camera.h>
#include <camera/QCameraParameters.h>
#include <system/window.h>
#include <system/camera.h>
#include <hardware/camera.h>
#include <gralloc_priv.h>
#include <hardware/power.h>
extern "C" {
#include <linux/android_pmem.h>
#include <linux/msm_ion.h>
#include <camera.h>
#include <camera_defs_i.h>
} //extern C
//Error codes
#define NOT_FOUND -1
/******************************************************************************
* Macro definitions
******************************************************************************/
/* enum definitions for picture formats */
static const int PICTURE_FORMAT_JPEG = 1;
static const int PICTURE_FORMAT_RAW = 2;
/* Default preview width in pixels */
#define DEFAULT_USBCAM_PRVW_WD 1280//640
/* Default preview height in pixels */
#define DEFAULT_USBCAM_PRVW_HT 720//480
/* Default picture format */
#define DEFAULT_USBCAM_PICT_FMT PICTURE_FORMAT_JPEG
/* Default picture width in pixels */
#define DEFAULT_USBCAM_PICT_WD 640
/* Default picture height in pixels */
#define DEFAULT_USBCAM_PICT_HT 480
/* Default picture JPEG quality 0-100 */
#define DEFAULT_USBCAM_PICT_QLTY 85
/* Default thumbnail width in pixels */
#define DEFAULT_USBCAM_THUMBNAIL_WD 432
/* Default thumbnail height in pixels */
#define DEFAULT_USBCAM_THUMBNAIL_HT 288
/* Default thumbnail JPEG quality 0-100 */
#define DEFAULT_USBCAM_THUMBNAIL_QLTY 85
/* Default preview format */
#define DEFAULT_USBCAM_PRVW_FMT HAL_PIXEL_FORMAT_YCrCb_420_SP
/* minimum of the default preview fps range in milli-Hz */
#define MIN_PREV_FPS 5000
/* maximum of the default preview fps range in milli-Hz */
#define MAX_PREV_FPS 121000
//for histogram stats
#define HISTOGRAM_STATS_SIZE 257
#define NUM_HISTOGRAM_BUFFERS 3
namespace android {
/******************************************************************************
* Structure definitions
******************************************************************************/
typedef struct {
uint32_t aspect_ratio;
uint32_t width;
uint32_t height;
} thumbnail_size_type;
/******************************************************************************
* Function: usbCamInitDefaultParameters
* Description: This function sets default parameters to camera HAL context
*
* Input parameters:
* camHal - camera HAL handle
*
* Return values:
* 0 No error
* -1 Error
*
* Notes: none
*****************************************************************************/
int usbCamInitDefaultParameters(camera_hardware_t *camHal);
/******************************************************************************
* Function: usbCamSetParameters
* Description: This function parses the parameter string and stores the
* parameters in the camera HAL handle
*
* Input parameters:
* camHal - camera HAL handle
* params - pointer to parameter string
*
* Return values:
* 0 Success
* -1 Error
* Notes: none
*****************************************************************************/
int usbCamSetParameters(camera_hardware_t *camHal, const char *params);
/******************************************************************************
* Function: usbCamGetParameters
* Description: This function allocates memory for parameter string,
* composes and returns the parameter string
*
* Input parameters:
* camHal - camera HAL handle
*
* Return values:
* Address to the parameter string
*
* Notes: none
*****************************************************************************/
char* usbCamGetParameters(camera_hardware_t *camHal);
/******************************************************************************
* Function: usbCamPutParameters
* Description: This function frees the memory allocated for parameter string
*
* Input parameters:
* camHal - camera HAL handle
* parms - Parameter string
*
* Return values:
* 0 Success
* -1 Error
* Notes: none
*****************************************************************************/
void usbCamPutParameters(camera_hardware_t *camHal, char *parms);
}; // namespace android
#endif /* ANDROID_HARDWARE_QCAMERA_USB_PARM_H */

View file

@ -1,202 +0,0 @@
/* Copyright (c) 2012, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ANDROID_HARDWARE_QCAMERA_USB_PRIV_H
#define ANDROID_HARDWARE_QCAMERA_USB_PRIV_H
namespace android {
/* File name length in number of characters */
#define FILENAME_LENGTH (256)
/* Number of display buffers (in addition to minimum number of undequed buffers */
#define PRVW_DISP_BUF_CNT 2
/* Number of V4L2 capture buffers. */
#define PRVW_CAP_BUF_CNT 4
/* Maximum buffer size for JPEG output in number of bytes */
#define MAX_JPEG_BUFFER_SIZE (1024 * 1024)
/* Preview loop commands */
#define USB_CAM_PREVIEW_EXIT (0x100)
#define USB_CAM_PREVIEW_PAUSE (0x101)
#define USB_CAM_PREVIEW_TAKEPIC (0x200)
/******************************************************************************
* Macro function to input validate device handle
*****************************************************************************/
#define VALIDATE_DEVICE_HDL(camHal, device, ret_err_code) {\
if(device && device->priv){\
camHal = (camera_hardware_t *)device->priv;\
}else{\
ALOGE("%s: Null device or device->priv", __func__);\
return ret_err_code;\
}\
}\
/******************************************************************************
* Macro function to check return status of a function, log and exit the thread
*****************************************************************************/
#define ERROR_CHECK_EXIT_THREAD(rc, string) {\
if(rc < 0) {\
ALOGE("%s: Error %s", __func__, string);\
return (void *)-1;\
}\
}
/******************************************************************************
* Macro function to check return status of a function, log and exit
*****************************************************************************/
#define ERROR_CHECK_EXIT(rc, string) {\
if(rc < 0) {\
ALOGE("%s: Error %s", __func__, string);\
return -1;\
}\
}
/******************************************************************************
* Macro function to Print the parameter string 1000 characters at a time
******************************************************************************/
#define PRINT_PARAM_STR(parms) {\
char temp[1001] = {0};\
int n=0;\
while(1) {\
strlcpy(temp,parms+n,1000);\
ALOGD("parms = %s", temp);\
if (strlen(temp) < 1000) break;\
n += 1000;\
}\
}\
/******************************************************************************
* Macro function to open camera
*****************************************************************************/
#define USB_CAM_OPEN(camHal) {\
camHal->fd = open(camHal->dev_name, O_RDWR | O_NONBLOCK, 0);\
if(!camHal->fd)\
ALOGE("%s: Error in open", __func__);\
else\
ALOGD("%s: Successfully opened", __func__);\
}\
/******************************************************************************
* Macro function to close camera
*****************************************************************************/
#define USB_CAM_CLOSE(camHal) {\
int rc;\
if(camHal->fd){\
rc = close(camHal->fd);\
if(0 > rc){\
ALOGE("%s: close failed ", __func__);\
}\
else{\
camHal->fd = 0;\
ALOGD("%s: close successful", __func__);\
}\
}\
}\
struct bufObj {
void *data;
int len;
};
typedef struct {
camera_device hw_dev;
Mutex lock;
int previewEnabledFlag;
int prvwStoppedForPicture;
int msgEnabledFlag;
volatile int prvwCmdPending;
volatile int prvwCmd;
pthread_t previewThread;
pthread_t takePictureThread;
camera_notify_callback notify_cb;
camera_data_callback data_cb;
camera_data_timestamp_callback data_cb_timestamp;
camera_request_memory get_memory;
void* cb_ctxt;
/* capture related members */
/* prevFormat is pixel format of preview buffers that are exported */
int prevFormat;
int prevFps;
int prevWidth;
int prevHeight;
/* captureFormat is internal setting for USB camera buffers */
int captureFormat;
char dev_name[FILENAME_LENGTH];
int fd;
unsigned int n_buffers;
struct v4l2_buffer curCaptureBuf;
struct bufObj *buffers;
/* Display related members */
preview_stream_ops* window;
QCameraHalMemory_t previewMem;
/* dispFormat is preview display format.Same as preview buffer format*/
int dispFormat;
int dispWidth;
int dispHeight;
/* MJPEG decoder related members */
/* MJPEG decoder object */
void* mjpegd;
/* JPEG picture and thumbnail related members */
int pictFormat;
int pictWidth;
int pictHeight;
int pictJpegQlty;
int thumbnailWidth;
int thumbnailHeight;
int thumbnailJpegQlty;
QCameraHalMemory_t pictMem;
int takePictInProgress;
int jpegEncInProgress;
pthread_mutex_t jpegEncMutex;
pthread_cond_t jpegEncCond;
/* */
QCameraParameters qCamParams;
String8 prevSizeValues;
String8 pictSizeValues;
String8 thumbnailSizeValues;
String8 vidSizeValues;
String8 pictFormatValues;
String8 prevFormatValues;
String8 prevFpsRangesValues;
} camera_hardware_t;
}; // namespace android
#endif /* ANDROID_HARDWARE_QCAMERA_USB_PRIV_H */

View file

@ -1,243 +0,0 @@
/* Copyright (c) 2011-2012, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ANDROID_HARDWARE_QUALCOMM_CAMERA_USBCAM_H
#define ANDROID_HARDWARE_QUALCOMM_CAMERA_USBCAM_H
extern "C" {
#include <sys/time.h>
}
#include "QCameraHWI.h"
extern "C" {
/*#include <hardware/camera.h>*/
int usbcam_get_number_of_cameras();
int usbcam_get_camera_info(int camera_id, struct camera_info *info);
int usbcam_camera_device_open(const struct hw_module_t* module, const char* id,
struct hw_device_t** device);
hw_device_t * usbcam_open_camera_device(int cameraId);
int usbcam_close_camera_device( hw_device_t *);
namespace android {
/** Set the ANativeWindow to which preview frames are sent */
int usbcam_set_preview_window(struct camera_device *,
struct preview_stream_ops *window);
/** Set the notification and data callbacks */
void usbcam_set_CallBacks(struct camera_device *,
camera_notify_callback notify_cb,
camera_data_callback data_cb,
camera_data_timestamp_callback data_cb_timestamp,
camera_request_memory get_memory,
void *user);
/**
* The following three functions all take a msg_type, which is a bitmask of
* the messages defined in include/ui/Camera.h
*/
/**
* Enable a message, or set of messages.
*/
void usbcam_enable_msg_type(struct camera_device *, int32_t msg_type);
/**
* Disable a message, or a set of messages.
*
* Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera
* HAL should not rely on its client to call releaseRecordingFrame() to
* release video recording frames sent out by the cameral HAL before and
* after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL
* clients must not modify/access any video recording frame after calling
* disableMsgType(CAMERA_MSG_VIDEO_FRAME).
*/
void usbcam_disable_msg_type(struct camera_device *, int32_t msg_type);
/**
* Query whether a message, or a set of messages, is enabled. Note that
* this is operates as an AND, if any of the messages queried are off, this
* will return false.
*/
int usbcam_msg_type_enabled(struct camera_device *, int32_t msg_type);
/**
* Start preview mode.
*/
int usbcam_start_preview(struct camera_device *);
/**
* Stop a previously started preview.
*/
void usbcam_stop_preview(struct camera_device *);
/**
* Returns true if preview is enabled.
*/
int usbcam_preview_enabled(struct camera_device *);
/**
* Request the camera HAL to store meta data or real YUV data in the video
* buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If
* it is not called, the default camera HAL behavior is to store real YUV
* data in the video buffers.
*
* This method should be called before startRecording() in order to be
* effective.
*
* If meta data is stored in the video buffers, it is up to the receiver of
* the video buffers to interpret the contents and to find the actual frame
* data with the help of the meta data in the buffer. How this is done is
* outside of the scope of this method.
*
* Some camera HALs may not support storing meta data in the video buffers,
* but all camera HALs should support storing real YUV data in the video
* buffers. If the camera HAL does not support storing the meta data in the
* video buffers when it is requested to do do, INVALID_OPERATION must be
* returned. It is very useful for the camera HAL to pass meta data rather
* than the actual frame data directly to the video encoder, since the
* amount of the uncompressed frame data can be very large if video size is
* large.
*
* @param enable if true to instruct the camera HAL to store
* meta data in the video buffers; false to instruct
* the camera HAL to store real YUV data in the video
* buffers.
*
* @return OK on success.
*/
int usbcam_store_meta_data_in_buffers(struct camera_device *, int enable);
/**
* Start record mode. When a record image is available, a
* CAMERA_MSG_VIDEO_FRAME message is sent with the corresponding
* frame. Every record frame must be released by a camera HAL client via
* releaseRecordingFrame() before the client calls
* disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls
* disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
* responsibility to manage the life-cycle of the video recording frames,
* and the client must not modify/access any video recording frames.
*/
int usbcam_start_recording(struct camera_device *);
/**
* Stop a previously started recording.
*/
void usbcam_stop_recording(struct camera_device *);
/**
* Returns true if recording is enabled.
*/
int usbcam_recording_enabled(struct camera_device *);
/**
* Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME.
*
* It is camera HAL client's responsibility to release video recording
* frames sent out by the camera HAL before the camera HAL receives a call
* to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to
* disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's
* responsibility to manage the life-cycle of the video recording frames.
*/
void usbcam_release_recording_frame(struct camera_device *,
const void *opaque);
/**
* Start auto focus, the notification callback routine is called with
* CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() will be
* called again if another auto focus is needed.
*/
int usbcam_auto_focus(struct camera_device *);
/**
* Cancels auto-focus function. If the auto-focus is still in progress,
* this function will cancel it. Whether the auto-focus is in progress or
* not, this function will return the focus position to the default. If
* the camera does not support auto-focus, this is a no-op.
*/
int usbcam_cancel_auto_focus(struct camera_device *);
/**
* Take a picture.
*/
int usbcam_take_picture(struct camera_device *);
/**
* Cancel a picture that was started with takePicture. Calling this method
* when no picture is being taken is a no-op.
*/
int usbcam_cancel_picture(struct camera_device *);
/**
* Set the camera parameters. This returns BAD_VALUE if any parameter is
* invalid or not supported.
*/
int usbcam_set_parameters(struct camera_device *, const char *parms);
//status_t setParameters(const QCameraParameters& params);
/** Retrieve the camera parameters. The buffer returned by the camera HAL
must be returned back to it with put_parameters, if put_parameters
is not NULL.
*/
char* usbcam_get_parameters(struct camera_device *);
/** The camera HAL uses its own memory to pass us the parameters when we
call get_parameters. Use this function to return the memory back to
the camera HAL, if put_parameters is not NULL. If put_parameters
is NULL, then you have to use free() to release the memory.
*/
void usbcam_put_parameters(struct camera_device *, char *);
/**
* Send command to camera driver.
*/
int usbcam_send_command(struct camera_device *,
int32_t cmd, int32_t arg1, int32_t arg2);
/**
* Release the hardware resources owned by this object. Note that this is
* *not* done in the destructor.
*/
void usbcam_release(struct camera_device *);
/**
* Dump state of the camera hardware
*/
int usbcam_dump(struct camera_device *, int fd);
}; // namespace android
} //extern "C"
#endif

View file

@ -1,701 +0,0 @@
/* Copyright (c) 2011-2012, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//#define ALOG_NDEBUG 0
#define ALOG_NIDEBUG 0
#define LOG_TAG "QCameraMjpegDecode"
#include <utils/Log.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
extern "C" {
#include "jpeg_buffer.h"
#include "jpeg_common.h"
#include "jpegd.h"
}
#include "QCameraMjpegDecode.h"
/* TBDJ: Can be removed */
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
// Abstract the return type of the function to be run as a thread
#define OS_THREAD_FUNC_RET_T void *
// Abstract the argument type to the thread function
#define OS_THREAD_FUNC_ARG_T void *
// Helpful constants for return values in the thread functions
#define OS_THREAD_FUNC_RET_SUCCEEDED (OS_THREAD_FUNC_RET_T)0
#define OS_THREAD_FUNC_RET_FAILED (OS_THREAD_FUNC_RET_T)1
// Abstract the function modifier placed in the beginning of the thread
// declaration (empty for Linux)
#define OS_THREAD_FUNC_MODIFIER
#define os_mutex_init(a) pthread_mutex_init(a, NULL)
#define os_cond_init(a) pthread_cond_init(a, NULL)
#define os_mutex_lock pthread_mutex_lock
#define os_mutex_unlock pthread_mutex_unlock
#define os_cond_wait pthread_cond_wait
#define os_cond_signal pthread_cond_signal
const char event_to_string[4][14] =
{
"EVENT_DONE",
"EVENT_WARNING",
"EVENT_ERROR",
};
typedef struct
{
uint32_t width;
uint32_t height;
uint32_t format;
uint32_t preference;
uint32_t abort_time;
uint16_t back_to_back_count;
/* TBDJ: Is this required */
int32_t rotation;
/* TBDJ: Is this required */
jpeg_rectangle_t region;
/* TBDJ: Is this required */
jpegd_scale_type_t scale_factor;
uint32_t hw_rotation;
char* inputMjpegBuffer;
int inputMjpegBufferSize;
char* outputYptr;
char* outputUVptr;
} test_args_t;
typedef struct
{
int tid;
pthread_t thread;
jpegd_obj_t decoder;
uint8_t decoding;
uint8_t decode_success;
pthread_mutex_t mutex;
pthread_cond_t cond;
test_args_t *p_args;
jpegd_output_buf_t *p_whole_output_buf;
} thread_ctrl_blk_t;
OS_THREAD_FUNC_RET_T OS_THREAD_FUNC_MODIFIER decoder_test(OS_THREAD_FUNC_ARG_T p_thread_args);
void decoder_event_handler(void *p_user_data,
jpeg_event_t event,
void *p_arg);
int decoder_output_handler(void *p_user_data,
jpegd_output_buf_t *p_output_buffer,
uint32_t first_row_id,
uint8_t is_last_buffer);
uint32_t decoder_input_req_handler(void *p_user_data,
jpeg_buffer_t buffer,
uint32_t start_offset,
uint32_t length);
static void* insertHuffmanTable(void *p, int size);
static int mjpegd_timer_start(timespec *p_timer);
static int mjpegd_timer_get_elapsed(timespec *p_timer, int *elapsed_in_ms, uint8_t reset_start);
static int mjpegd_cond_timedwait(pthread_cond_t *p_cond, pthread_mutex_t *p_mutex, uint32_t ms);
// Global variables
/* TBDJ: can be removed */
thread_ctrl_blk_t *thread_ctrl_blks = NULL;
/*
* This function initializes the mjpeg decoder and returns the object
*/
MJPEGD_ERR mjpegDecoderInit(void** mjpegd_obj)
{
test_args_t* mjpegd;
ALOGD("%s: E", __func__);
mjpegd = (test_args_t *)malloc(sizeof(test_args_t));
if(!mjpegd)
return MJPEGD_INSUFFICIENT_MEM;
memset(mjpegd, 0, sizeof(test_args_t));
/* Defaults */
/* Due to current limitation, s/w decoder is selected always */
mjpegd->preference = JPEG_DECODER_PREF_HW_ACCELERATED_PREFERRED;
mjpegd->back_to_back_count = 1;
mjpegd->rotation = 0;
mjpegd->hw_rotation = 0;
mjpegd->scale_factor = (jpegd_scale_type_t)1;
/* TBDJ: can be removed */
mjpegd->width = 640;
mjpegd->height = 480;
mjpegd->abort_time = 0;
*mjpegd_obj = (void *)mjpegd;
ALOGD("%s: X", __func__);
return MJPEGD_NO_ERROR;
}
MJPEGD_ERR mjpegDecode(
void* mjpegd_obj,
char* inputMjpegBuffer,
int inputMjpegBufferSize,
char* outputYptr,
char* outputUVptr,
int outputFormat)
{
int rc, c, i;
test_args_t* mjpegd;
test_args_t test_args;
ALOGD("%s: E", __func__);
/* store input arguments in the context */
mjpegd = (test_args_t*) mjpegd_obj;
mjpegd->inputMjpegBuffer = inputMjpegBuffer;
mjpegd->inputMjpegBufferSize = inputMjpegBufferSize;
mjpegd->outputYptr = outputYptr;
mjpegd->outputUVptr = outputUVptr;
mjpegd->format = outputFormat;
/* TBDJ: can be removed */
memcpy(&test_args, mjpegd, sizeof(test_args_t));
// check the formats
if (((test_args.format == YCRCBLP_H1V2) || (test_args.format == YCBCRLP_H1V2) ||
(test_args.format == YCRCBLP_H1V1) || (test_args.format == YCBCRLP_H1V1)) &&
!(test_args.preference == JPEG_DECODER_PREF_HW_ACCELERATED_ONLY)) {
ALOGE("%s:These formats are not supported by SW format %d", __func__, test_args.format);
return 1;
}
// Create thread control blocks
thread_ctrl_blks = (thread_ctrl_blk_t *)malloc( sizeof(thread_ctrl_blk_t));
if (!thread_ctrl_blks)
{
ALOGE("%s: decoder_test failed: insufficient memory in creating thread control blocks", __func__);
return 1;
}
memset(thread_ctrl_blks, 0, sizeof(thread_ctrl_blk_t));
// Initialize the blocks and kick off the threads
thread_ctrl_blks[i].tid = i;
thread_ctrl_blks[i].p_args = &test_args;
os_mutex_init(&thread_ctrl_blks[i].mutex);
os_cond_init(&thread_ctrl_blks[i].cond);
rc = (int)decoder_test(&thread_ctrl_blks[i]);
if (!rc)
ALOGD("%s: decoder_test finished successfully ", __func__);
else
ALOGE("%s: decoder_test failed",__func__);
ALOGD("%s: X rc: %d", __func__, rc);
return rc;
}
OS_THREAD_FUNC_RET_T OS_THREAD_FUNC_MODIFIER decoder_test(OS_THREAD_FUNC_ARG_T arg)
{
int rc, i;
jpegd_obj_t decoder;
jpegd_src_t source;
jpegd_dst_t dest;
jpegd_cfg_t config;
jpeg_hdr_t header;
jpegd_output_buf_t p_output_buffers;
uint32_t output_buffers_count = 1; // currently only 1 buffer a time is supported
uint8_t use_pmem = true;
timespec os_timer;
thread_ctrl_blk_t *p_thread_arg = (thread_ctrl_blk_t *)arg;
test_args_t *p_args = p_thread_arg->p_args;
uint32_t output_width;
uint32_t output_height;
uint32_t total_time = 0;
ALOGD("%s: E", __func__);
// Determine whether pmem should be used (useful for pc environment testing where
// pmem is not available)
if ((jpegd_preference_t)p_args->preference == JPEG_DECODER_PREF_SOFTWARE_PREFERRED ||
(jpegd_preference_t)p_args->preference == JPEG_DECODER_PREF_SOFTWARE_ONLY) {
use_pmem = false;
}
if (((jpegd_preference_t)p_args->preference !=
JPEG_DECODER_PREF_HW_ACCELERATED_ONLY) &&
((jpegd_preference_t)p_args->scale_factor > 0)) {
ALOGI("%s: Setting scale factor to 1x", __func__);
}
ALOGD("%s: before jpegd_init p_thread_arg: %p", __func__, p_thread_arg);
// Initialize decoder
rc = jpegd_init(&decoder,
&decoder_event_handler,
&decoder_output_handler,
p_thread_arg);
if (JPEG_FAILED(rc)) {
ALOGE("%s: decoder_test: jpegd_init failed", __func__);
goto fail;
}
p_thread_arg->decoder = decoder;
// Set source information
source.p_input_req_handler = &decoder_input_req_handler;
source.total_length = p_args->inputMjpegBufferSize & 0xffffffff;
rc = jpeg_buffer_init(&source.buffers[0]);
if (JPEG_SUCCEEDED(rc)) {
/* TBDJ: why buffer [1] */
rc = jpeg_buffer_init(&source.buffers[1]);
}
if (JPEG_SUCCEEDED(rc)) {
#if 1
rc = jpeg_buffer_allocate(source.buffers[0], 0xA000, use_pmem);
#else
rc = jpeg_buffer_use_external_buffer(source.buffers[0],
(uint8_t *)p_args->inputMjpegBuffer,
p_args->inputMjpegBufferSize,
0);
#endif
ALOGD("%s: source.buffers[0]:%p compressed buffer ptr = %p", __func__,
source.buffers[0], p_args->inputMjpegBuffer);
}
if (JPEG_SUCCEEDED(rc)) {
#if 1
rc = jpeg_buffer_allocate(source.buffers[1], 0xA000, use_pmem);
#else
rc = jpeg_buffer_use_external_buffer(source.buffers[1],
(uint8_t *)p_args->inputMjpegBuffer,
p_args->inputMjpegBufferSize,
0);
#endif
ALOGD("%s: source.buffers[1]:%p compressed buffer ptr = %p", __func__,
source.buffers[1], p_args->inputMjpegBuffer);
}
if (JPEG_FAILED(rc)) {
jpeg_buffer_destroy(&source.buffers[0]);
jpeg_buffer_destroy(&source.buffers[1]);
goto fail;
}
ALOGI("%s: *** Starting back-to-back decoding of %d frame(s)***\n",
__func__, p_args->back_to_back_count);
// Loop to perform n back-to-back decoding (to the same output file)
for(i = 0; i < p_args->back_to_back_count; i++) {
if(mjpegd_timer_start(&os_timer) < 0) {
ALOGE("%s: failed to get start time", __func__);
}
/* TBDJ: Every frame? */
ALOGD("%s: before jpegd_set_source source.p_arg:%p", __func__, source.p_arg);
rc = jpegd_set_source(decoder, &source);
if (JPEG_FAILED(rc))
{
ALOGE("%s: jpegd_set_source failed", __func__);
goto fail;
}
rc = jpegd_read_header(decoder, &header);
if (JPEG_FAILED(rc))
{
ALOGE("%s: jpegd_read_header failed", __func__);
goto fail;
}
p_args->width = header.main.width;
p_args->height = header.main.height;
ALOGD("%s: main dimension: (%dx%d) subsampling: (%d)", __func__,
header.main.width, header.main.height, (int)header.main.subsampling);
// main image decoding:
// Set destination information
dest.width = (p_args->width) ? (p_args->width) : header.main.width;
dest.height = (p_args->height) ? (p_args->height) : header.main.height;
dest.output_format = (jpeg_color_format_t) p_args->format;
dest.region = p_args->region;
// if region is defined, re-assign the output width/height
output_width = dest.width;
output_height = dest.height;
if (p_args->region.right || p_args->region.bottom)
{
if (0 == p_args->rotation || 180 == p_args->rotation)
{
output_width = MIN((dest.width),
(uint32_t)(dest.region.right - dest.region.left + 1));
output_height = MIN((dest.height),
(uint32_t)(dest.region.bottom - dest.region.top + 1));
}
// Swap output width/height for 90/270 rotation cases
else if (90 == p_args->rotation || 270 == p_args->rotation)
{
output_height = MIN((dest.height),
(uint32_t)(dest.region.right - dest.region.left + 1));
output_width = MIN((dest.width),
(uint32_t)(dest.region.bottom - dest.region.top + 1));
}
// Unsupported rotation cases
else
{
goto fail;
}
}
if (dest.output_format == YCRCBLP_H2V2 || dest.output_format == YCBCRLP_H2V2 ||
dest.output_format == YCRCBLP_H2V1 || dest.output_format == YCBCRLP_H2V1 ||
dest.output_format == YCRCBLP_H1V2 || dest.output_format == YCBCRLP_H1V2 ||
dest.output_format == YCRCBLP_H1V1 || dest.output_format == YCBCRLP_H1V1) {
jpeg_buffer_init(&p_output_buffers.data.yuv.luma_buf);
jpeg_buffer_init(&p_output_buffers.data.yuv.chroma_buf);
} else {
jpeg_buffer_init(&p_output_buffers.data.rgb.rgb_buf);
}
{
// Assign 0 to tile width and height
// to indicate that no tiling is requested.
p_output_buffers.tile_width = 0;
p_output_buffers.tile_height = 0;
}
p_output_buffers.is_in_q = 0;
switch (dest.output_format)
{
case YCRCBLP_H2V2:
case YCBCRLP_H2V2:
// case YCRCBLP_H2V1:
// case YCBCRLP_H2V1:
// case YCRCBLP_H1V2:
// case YCBCRLP_H1V2:
// case YCRCBLP_H1V1:
// case YCBCRLP_H1V1:
jpeg_buffer_use_external_buffer(
p_output_buffers.data.yuv.luma_buf,
(uint8_t*)p_args->outputYptr,
p_args->width * p_args->height * SQUARE(p_args->scale_factor),
0);
jpeg_buffer_use_external_buffer(
p_output_buffers.data.yuv.chroma_buf,
(uint8_t*)p_args->outputUVptr,
p_args->width * p_args->height / 2 * SQUARE(p_args->scale_factor),
0);
break;
default:
ALOGE("%s: decoder_test: unsupported output format", __func__);
goto fail;
}
// Set up configuration
memset(&config, 0, sizeof(jpegd_cfg_t));
config.preference = (jpegd_preference_t) p_args->preference;
config.decode_from = JPEGD_DECODE_FROM_AUTO;
config.rotation = p_args->rotation;
config.scale_factor = p_args->scale_factor;
config.hw_rotation = p_args->hw_rotation;
dest.back_to_back_count = p_args->back_to_back_count;
// Start decoding
p_thread_arg->decoding = true;
rc = jpegd_start(decoder, &config, &dest, &p_output_buffers, output_buffers_count);
dest.back_to_back_count--;
if(JPEG_FAILED(rc)) {
ALOGE("%s: decoder_test: jpegd_start failed (rc=%d)\n",
__func__, rc);
goto fail;
}
ALOGD("%s: decoder_test: jpegd_start succeeded", __func__);
// Do abort
if (p_args->abort_time) {
os_mutex_lock(&p_thread_arg->mutex);
while (p_thread_arg->decoding)
{
rc = mjpegd_cond_timedwait(&p_thread_arg->cond, &p_thread_arg->mutex, p_args->abort_time);
if (rc == JPEGERR_ETIMEDOUT)
{
// Do abort
os_mutex_unlock(&p_thread_arg->mutex);
rc = jpegd_abort(decoder);
if (rc)
{
ALOGE("%s: decoder_test: jpegd_abort failed: %d", __func__, rc);
goto fail;
}
break;
}
}
if (p_thread_arg->decoding)
os_mutex_unlock(&p_thread_arg->mutex);
} else {
// Wait until decoding is done or stopped due to error
os_mutex_lock(&p_thread_arg->mutex);
while (p_thread_arg->decoding)
{
os_cond_wait(&p_thread_arg->cond, &p_thread_arg->mutex);
}
os_mutex_unlock(&p_thread_arg->mutex);
}
int diff;
// Display the time elapsed
if (mjpegd_timer_get_elapsed(&os_timer, &diff, 0) < 0) {
ALOGE("%s: decoder_test: failed to get elapsed time", __func__);
} else {
if(p_args->abort_time) {
if(p_thread_arg->decoding) {
ALOGI("%s: decoder_test: decoding aborted successfully after %d ms", __func__, diff);
goto buffer_clean_up;
}
else
{
ALOGI("%s: decoder_test: decoding stopped before abort is issued. "
"decode time: %d ms", __func__, diff);
}
}
else {
if(p_thread_arg->decode_success) {
total_time += diff;
ALOGI("%s: decode time: %d ms (%d frame(s), total=%dms, avg=%dms/frame)",
__func__, diff, i+1, total_time, total_time/(i+1));
}
else
{
fprintf(stderr, "decoder_test: decode failed\n");
}
}
}
}
if(p_thread_arg->decode_success) {
ALOGD("%s: Frame(s) = %d, Total Time = %dms, Avg. decode time = %dms/frame)\n",
__func__, p_args->back_to_back_count, total_time, total_time/p_args->back_to_back_count);
}
buffer_clean_up:
// Clean up decoder and allocate buffers
jpeg_buffer_destroy(&source.buffers[0]);
jpeg_buffer_destroy(&source.buffers[1]);
switch (dest.output_format)
{
case YCRCBLP_H2V2:
case YCBCRLP_H2V2:
case YCRCBLP_H2V1:
case YCBCRLP_H2V1:
case YCRCBLP_H1V2:
case YCBCRLP_H1V2:
case YCRCBLP_H1V1:
case YCBCRLP_H1V1:
jpeg_buffer_destroy(&p_output_buffers.data.yuv.luma_buf);
jpeg_buffer_destroy(&p_output_buffers.data.yuv.chroma_buf);
break;
default:
break;
}
jpegd_destroy(&decoder);
if (!p_thread_arg->decode_success)
{
goto fail;
}
ALOGD("%s: X", __func__);
return OS_THREAD_FUNC_RET_SUCCEEDED;
fail:
ALOGD("%s: X", __func__);
return OS_THREAD_FUNC_RET_FAILED;
}
void decoder_event_handler(void *p_user_data,
jpeg_event_t event,
void *p_arg)
{
thread_ctrl_blk_t *p_thread_arg = (thread_ctrl_blk_t *)p_user_data;
ALOGD("%s: E", __func__);
ALOGD("%s: Event: %s\n", __func__, event_to_string[event]);
if (event == JPEG_EVENT_DONE)
{
p_thread_arg->decode_success = true;
ALOGD("%s: decode_success: %d\n", __func__, p_thread_arg->decode_success);
}
// If it is not a warning event, decoder has stopped; Signal
// main thread to clean up
if (event != JPEG_EVENT_WARNING)
{
os_mutex_lock(&p_thread_arg->mutex);
p_thread_arg->decoding = false;
os_cond_signal(&p_thread_arg->cond);
os_mutex_unlock(&p_thread_arg->mutex);
}
ALOGD("%s: X", __func__);
}
// consumes the output buffer.
/*TBDJ: Can be removed. Is this related to tiling */
int decoder_output_handler(void *p_user_data,
jpegd_output_buf_t *p_output_buffer,
uint32_t first_row_id,
uint8_t is_last_buffer)
{
uint8_t* whole_output_buf_ptr, *tiling_buf_ptr;
ALOGD("%s: E", __func__);
thread_ctrl_blk_t *p_thread_arg = (thread_ctrl_blk_t *)p_user_data;
jpeg_buffer_get_addr(p_thread_arg->p_whole_output_buf->data.rgb.rgb_buf, &whole_output_buf_ptr);
jpeg_buffer_get_addr(p_output_buffer->data.rgb.rgb_buf, &tiling_buf_ptr);
if (p_output_buffer->tile_height != 1)
return JPEGERR_EUNSUPPORTED;
// testing purpose only
// This is to simulate that the user needs to bail out when error happens
// in the middle of decoding
//if (first_row_id == 162)
// return JPEGERR_EFAILED;
// do not enqueue any buffer if it reaches the last buffer
if (!is_last_buffer)
{
jpegd_enqueue_output_buf(p_thread_arg->decoder, p_output_buffer, 1);
}
ALOGD("%s: X", __func__);
return JPEGERR_SUCCESS;
}
// p_reader->p_input_req_handler(p_reader->decoder,
// p_reader->p_input_buf,
// p_reader->next_byte_offset,
// MAX_BYTES_TO_FETCH);
uint32_t decoder_input_req_handler(void *p_user_data,
jpeg_buffer_t buffer,
uint32_t start_offset,
uint32_t length)
{
uint32_t buf_size;
uint8_t *buf_ptr;
int bytes_to_read, bytes_read, rc;
thread_ctrl_blk_t *p_thread_arg = (thread_ctrl_blk_t *)p_user_data;
thread_ctrl_blk_t *thread_ctrl_blk = (thread_ctrl_blk_t *)p_user_data;
test_args_t* mjpegd = (test_args_t*) thread_ctrl_blk->p_args;
ALOGD("%s: E", __func__);
jpeg_buffer_get_max_size(buffer, &buf_size);
jpeg_buffer_get_addr(buffer, &buf_ptr);
bytes_to_read = (length < buf_size) ? length : buf_size;
bytes_read = 0;
ALOGD("%s: buf_ptr = %p, start_offset = %d, length = %d buf_size = %d bytes_to_read = %d", __func__, buf_ptr, start_offset, length, buf_size, bytes_to_read);
if (bytes_to_read)
{
/* TBDJ: Should avoid this Mem copy */
#if 1
memcpy(buf_ptr, (char *)mjpegd->inputMjpegBuffer + start_offset, bytes_to_read);
#else
if(JPEGERR_SUCCESS != jpeg_buffer_set_start_offset(buffer, start_offset))
ALOGE("%s: jpeg_buffer_set_start_offset failed", __func__);
#endif
bytes_read = bytes_to_read;
}
ALOGD("%s: X", __func__);
return bytes_read;
}
static int mjpegd_timer_start(timespec *p_timer)
{
if (!p_timer)
return JPEGERR_ENULLPTR;
if (clock_gettime(CLOCK_REALTIME, p_timer))
return JPEGERR_EFAILED;
return JPEGERR_SUCCESS;
}
static int mjpegd_timer_get_elapsed(timespec *p_timer, int *elapsed_in_ms, uint8_t reset_start)
{
timespec now;
long diff;
int rc = mjpegd_timer_start(&now);
if (JPEG_FAILED(rc))
return rc;
diff = (long)(now.tv_sec - p_timer->tv_sec) * 1000;
diff += (long)(now.tv_nsec - p_timer->tv_nsec) / 1000000;
*elapsed_in_ms = (int)diff;
if (reset_start)
*p_timer = now;
return JPEGERR_SUCCESS;
}
int mjpegd_cond_timedwait(pthread_cond_t *p_cond, pthread_mutex_t *p_mutex, uint32_t ms)
{
struct timespec ts;
int rc = clock_gettime(CLOCK_REALTIME, &ts);
if (rc < 0) return rc;
if (ms >= 1000) {
ts.tv_sec += (ms/1000);
ts.tv_nsec += ((ms%1000) * 1000000);
} else {
ts.tv_nsec += (ms * 1000000);
}
rc = pthread_cond_timedwait(p_cond, p_mutex, &ts);
if (rc == ETIMEDOUT)
{
rc = JPEGERR_ETIMEDOUT;
}
return rc;
}

View file

@ -1,683 +0,0 @@
/* Copyright (c) 2012, 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
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//#define ALOG_NDEBUG 0
#define ALOG_NIDEBUG 0
#define LOG_TAG "QCameraUsbParm"
#include <utils/Log.h>
#include <utils/Errors.h>
#include <utils/threads.h>
#include <utils/String16.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <cutils/properties.h>
#include <math.h>
#if HAVE_ANDROID_OS
#include <linux/android_pmem.h>
#endif
#include <linux/ioctl.h>
#include <camera/QCameraParameters.h>
#include <media/mediarecorder.h>
#include <gralloc_priv.h>
#include "linux/msm_mdp.h"
#include <linux/fb.h>
#include <limits.h>
extern "C" {
#include <fcntl.h>
#include <time.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <termios.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <signal.h>
#include <errno.h>
#include <sys/mman.h>
#include <sys/system_properties.h>
#include <sys/time.h>
#include <stdlib.h>
#include <linux/msm_ion.h>
#include <camera.h>
#include <cam_fifo.h>
#include <jpege.h>
} // extern "C"
#include "QCameraHWI.h"
#include "QualcommUsbCamera.h"
#include "QCameraUsbPriv.h"
#include "QCameraUsbParm.h"
namespace android {
/********************************************************************/
static const str_map preview_formats[] = {
{QCameraParameters::PIXEL_FORMAT_YUV420SP, HAL_PIXEL_FORMAT_YCrCb_420_SP},
};
static const preview_format_info_t preview_format_info_list[] = {
{HAL_PIXEL_FORMAT_YV12, CAMERA_YUV_420_YV12, CAMERA_PAD_TO_WORD, 3}
};
static struct camera_size_type previewSizes[] = {
{ 1920, 1088}, //1080p
{ 1280, 720}, // 720P,
{ 640, 480}, // VGA
{ 512, 384},
{ 480, 320},
{ 320, 240}, // QVGA
};
// All fps ranges which can be supported. This list will be filtered according
// to the min and max fps supported by hardware
// this list must be sorted first by max_fps and then min_fps
// fps values are multiplied by 1000
static android::FPSRange prevFpsRanges[] = {
android::FPSRange(5000, 121000),
};
/* TBR: Is frame rate mode mandatory */
static const str_map frame_rate_modes[] = {
{QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_AUTO_MODE, FPS_MODE_AUTO},
{QCameraParameters::KEY_QC_PREVIEW_FRAME_RATE_FIXED_MODE, FPS_MODE_FIXED}
};
static const str_map picture_formats[] = {
{QCameraParameters::PIXEL_FORMAT_JPEG, PICTURE_FORMAT_JPEG},
//{QCameraParameters::PIXEL_FORMAT_RAW, PICTURE_FORMAT_RAW}
};
static camera_size_type picture_sizes[] = {
{ 1920, 1088}, //HD1080
{ 1280, 720}, //HD720
{ 640, 480}, // VGA
{ 320, 240}, // QVGA
};
/* aspect ratio removed */
static camera_size_type thumbnail_sizes[] = {
{ 512, 288 }, //1.777778
{ 480, 288 }, //1.666667
{ 256, 154 }, //1.66233
{ 432, 288 }, //1.5
{ 512, 384 }, //1.333333
{ 352, 288 }, //1.222222
{ 320, 240 }, //1.33333
{ 176, 144 }, //1.222222
};
static const str_map recording_Hints[] = {
{"false", FALSE},
{"true", TRUE}
};
/* Static functions list */
static String8 create_sizes_str(const camera_size_type *sizes, int len);
static String8 create_values_str(const str_map *values, int len);
static String8 create_fps_str(const android:: FPSRange* fps, int len);
static String8 create_values_range_str(int min, int max);
static int usbCamSetPrvwSize( camera_hardware_t *camHal,
const QCameraParameters& params);
static int usbCamSetPictSize( camera_hardware_t *camHal,
const QCameraParameters& params);
static int usbCamSetThumbnailSize( camera_hardware_t *camHal,
const QCameraParameters& params);
static int usbCamSetJpegQlty( camera_hardware_t *camHal,
const QCameraParameters& params);
/******************************************************************************
* Function: usbCamInitDefaultParameters
* Description: This function sets default parameters to camera HAL context
*
* Input parameters:
* camHal - camera HAL handle
*
* Return values:
* None
*
* Notes: none
*****************************************************************************/
int usbCamInitDefaultParameters(camera_hardware_t *camHal)
{
ALOGD("%s: E", __func__);
int rc = 0;
char tempStr[FILENAME_LENGTH];
/* Default initializations */
camHal->prevFormat = DEFAULT_USBCAM_PRVW_FMT;
camHal->prevWidth = DEFAULT_USBCAM_PRVW_WD;
camHal->prevHeight = DEFAULT_USBCAM_PRVW_HT;
camHal->dispFormat = camHal->prevFormat;
camHal->dispWidth = camHal->prevWidth;
camHal->dispHeight = camHal->prevHeight;
camHal->pictFormat = DEFAULT_USBCAM_PICT_FMT;
camHal->pictWidth = DEFAULT_USBCAM_PICT_WD;
camHal->pictHeight = DEFAULT_USBCAM_PICT_HT;
camHal->pictJpegQlty = DEFAULT_USBCAM_PICT_QLTY;
camHal->thumbnailWidth = DEFAULT_USBCAM_THUMBNAIL_WD;
camHal->thumbnailHeight = DEFAULT_USBCAM_THUMBNAIL_HT;
camHal->thumbnailJpegQlty = DEFAULT_USBCAM_THUMBNAIL_QLTY;
camHal->previewEnabledFlag = 0;
camHal->prvwStoppedForPicture = 0;
camHal->prvwCmdPending = 0;
camHal->takePictInProgress = 0;
//Set picture size values
camHal->pictSizeValues = create_sizes_str(
picture_sizes, sizeof(picture_sizes) / sizeof(camera_size_type));
camHal->qCamParams.set(QCameraParameters::KEY_SUPPORTED_PICTURE_SIZES,
camHal->pictSizeValues.string());
camHal->qCamParams.setPictureSize(camHal->pictWidth, camHal->pictHeight);
//Set picture format
camHal->pictFormatValues = create_values_str(
picture_formats, sizeof(picture_formats) / sizeof(str_map));
camHal->qCamParams.set(QCameraParameters::KEY_SUPPORTED_PICTURE_FORMATS,
camHal->pictFormatValues.string());
if(PICTURE_FORMAT_JPEG == camHal->pictFormat)
camHal->qCamParams.setPictureFormat(QCameraParameters::PIXEL_FORMAT_JPEG);
//Set picture quality
sprintf(tempStr, "%d", camHal->pictJpegQlty);
camHal->qCamParams.set(QCameraParameters::KEY_JPEG_QUALITY, tempStr);
//Set Thumbnail size
camHal->thumbnailSizeValues = create_sizes_str(
thumbnail_sizes, sizeof(thumbnail_sizes) /sizeof(camera_size_type));
camHal->qCamParams.set(QCameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES,
camHal->thumbnailSizeValues.string());
sprintf(tempStr, "%d", camHal->thumbnailWidth);
camHal->qCamParams.set(QCameraParameters::KEY_JPEG_THUMBNAIL_WIDTH,
tempStr);
sprintf(tempStr, "%d", camHal->thumbnailHeight);
camHal->qCamParams.set(QCameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT,
tempStr);
//Set Thumbnail quality
sprintf(tempStr, "%d", camHal->thumbnailJpegQlty);
camHal->qCamParams.set(QCameraParameters::KEY_JPEG_THUMBNAIL_QUALITY,
tempStr);
//Set Preview Format
camHal->prevFormatValues = create_values_str(
preview_formats, sizeof(preview_formats) / sizeof(str_map));
camHal->qCamParams.set(QCameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS,
camHal->prevFormatValues.string());
if(HAL_PIXEL_FORMAT_YCrCb_420_SP == camHal->prevFormat)
camHal->qCamParams.setPreviewFormat(QCameraParameters::PIXEL_FORMAT_YUV420SP);
//Set Preview size
camHal->prevSizeValues = create_sizes_str(
previewSizes, sizeof(previewSizes) / sizeof(camera_size_type));
camHal->qCamParams.set(QCameraParameters::KEY_SUPPORTED_PREVIEW_SIZES,
camHal->prevSizeValues.string());
camHal->qCamParams.setPreviewSize(camHal->prevWidth, camHal->prevHeight);
//Set Preivew fps range
camHal->prevFpsRangesValues = create_fps_str(
prevFpsRanges, sizeof(prevFpsRanges) / sizeof(android::FPSRange));
camHal->qCamParams.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE,
camHal->prevFpsRangesValues);
camHal->qCamParams.setPreviewFpsRange(MIN_PREV_FPS, MAX_PREV_FPS);
ALOGD("%s: X", __func__);
return rc;
} /* usbCamInitDefaultParameters */
/******************************************************************************
* Function: usbCamSetParameters
* Description: This function parses the parameter string and stores the
* parameters in the camera HAL handle
*
* Input parameters:
* camHal - camera HAL handle
* params - pointer to parameter string
*
* Return values:
* 0 Success
* -1 Error
* Notes: none
*****************************************************************************/
int usbCamSetParameters(camera_hardware_t *camHal, const char *params)
{
int rc = 0;
String8 str = String8(params);
QCameraParameters qParam;
ALOGD("%s: E", __func__);
if(params)
PRINT_PARAM_STR(params);
qParam.unflatten(str);
if(usbCamSetPrvwSize(camHal, qParam))
rc = -1;
if(usbCamSetPictSize(camHal, qParam))
rc = -1;
if(usbCamSetThumbnailSize(camHal, qParam))
rc = -1;
if(usbCamSetJpegQlty(camHal, qParam))
rc = -1;
ALOGD("%s: X", __func__);
return rc;
} /* usbCamSetParameters */
/******************************************************************************
* Function: usbCamGetParameters
* Description: This function allocates memory for parameter string,
* composes and returns the parameter string
*
* Input parameters:
* camHal - camera HAL handle
*
* Return values:
* Address to the parameter string
*
* Notes: none
*****************************************************************************/
char* usbCamGetParameters(camera_hardware_t *camHal)
{
ALOGD("%s: E", __func__);
char *parms = NULL;
char* rc = NULL;
String8 str;
QCameraParameters qParam = camHal->qCamParams;
//qParam.dump();
str = qParam.flatten( );
rc = (char *)malloc(sizeof(char)*(str.length()+1));
if(rc != NULL){
memset(rc, 0, sizeof(char)*(str.length()+1));
strncpy(rc, str.string(), str.length());
rc[str.length()] = 0;
parms = rc;
}
PRINT_PARAM_STR(parms);
ALOGD("%s: X", __func__);
return (parms);
} /* usbCamGetParameters */
/******************************************************************************
* Function: usbCamPutParameters
* Description: This function frees the memory allocated for parameter string
*
* Input parameters:
* camHal - camera HAL handle
* parms - Parameter string
*
* Return values:
* None
*
* Notes: none
*****************************************************************************/
void usbCamPutParameters(camera_hardware_t *camHal, char *parms)
{
ALOGD("%s: E", __func__);
if(parms)
free(parms);
parms = NULL;
ALOGD("%s: X", __func__);
} /* usbCamPutParameters */
/******************************************************************************
* Function: create_sizes_str
* Description: This function loops through /dev/video entries and probes with
* UVCIOC query. If the device responds to the query, then it is
* detected as UVC webcam
* Input parameters:
* devname - String pointer. The function return dev entry
* name in this string
* Return values:
* 0 Success
* -1 Error
* Notes: none
*****************************************************************************/
static String8 create_sizes_str(const camera_size_type *sizes, int len) {
String8 str;
char buffer[32];
if (len > 0) {
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);
str.append(buffer);
}
return str;
}
/******************************************************************************
* Function: create_values_str
* Description: This function loops through /dev/video entries and probes with
* UVCIOC query. If the device responds to the query, then it is
* detected as UVC webcam
* Input parameters:
* devname - String pointer. The function return dev entry
* name in this string
* Return values:
* 0 Success
* -1 Error
* Notes: none
*****************************************************************************/
static String8 create_values_str(const str_map *values, int len) {
String8 str;
if (len > 0) {
str.append(values[0].desc);
}
for (int i = 1; i < len; i++) {
str.append(",");
str.append(values[i].desc);
}
return str;
}
/******************************************************************************
* Function: create_fps_str
* Description: This function loops through /dev/video entries and probes with
* UVCIOC query. If the device responds to the query, then it is
* detected as UVC webcam
* Input parameters:
* devname - String pointer. The function return dev entry
* name in this string
* Return values:
* 0 Success
* -1 Error
* Notes: none
*****************************************************************************/
static String8 create_fps_str(const android:: FPSRange* fps, int len) {
String8 str;
char buffer[32];
if (len > 0) {
snprintf(buffer, sizeof(buffer), "(%d,%d)", fps[0].minFPS, fps[0].maxFPS);
str.append(buffer);
}
for (int i = 1; i < len; i++) {
snprintf(buffer, sizeof(buffer), ",(%d,%d)", fps[i].minFPS, fps[i].maxFPS);
str.append(buffer);
}
return str;
}
/******************************************************************************
* Function: create_values_range_str
* Description: This function loops through /dev/video entries and probes with
* UVCIOC query. If the device responds to the query, then it is
* detected as UVC webcam
* Input parameters:
* devname - String pointer. The function return dev entry
* name in this string
* Return values:
* 0 Success
* -1 Error
* Notes: none
*****************************************************************************/
static String8 create_values_range_str(int min, int max){
String8 str;
char buffer[32];
if(min <= max){
snprintf(buffer, sizeof(buffer), "%d", min);
str.append(buffer);
for (int i = min + 1; i <= max; i++) {
snprintf(buffer, sizeof(buffer), ",%d", i);
str.append(buffer);
}
}
return str;
}
/******************************************************************************
* Function: usbCamSetPrvwSize
* Description: This function parses preview width and height from the input
* parameters and stores into the context
*
* Input parameters:
* camHal - camera HAL handle
* params - QCameraParameters reference
*
* Return values:
* 0 If parameters are valid
* -1 If parameters are invalid
*
* Notes: none
*****************************************************************************/
static int usbCamSetPrvwSize( camera_hardware_t *camHal,
const QCameraParameters& params)
{
int rc = 0, width, height, i, numPrvwSizes, validSize;
ALOGD("%s: E", __func__);
params.getPreviewSize(&width, &height);
ALOGI("%s: Requested preview size %d x %d", __func__, width, height);
// Validate the preview size
numPrvwSizes = sizeof(previewSizes) / sizeof(camera_size_type);
for (i = 0, validSize = 0; i < numPrvwSizes; i++) {
if (width == previewSizes[i].width
&& height == previewSizes[i].height) {
validSize = 1;
camHal->qCamParams.setPreviewSize(width, height);
ALOGD("%s: setPreviewSize: width: %d height: %d",
__func__, width, height);
camHal->prevWidth = width;
camHal->prevHeight = height;
camHal->dispWidth = width;
camHal->dispHeight = height;
/* TBD: restrict pictures size and video to preview size */
}
}
if(!validSize)
ALOGE("%s: Invalid preview size %dx%d requested", __func__,
width, height);
rc = (validSize == 0)? -1:0;
ALOGD("%s: X", __func__);
return rc;
} /* usbCamSetPrvwSize */
/******************************************************************************
* Function: usbCamSetPictSize
* Description: This function parses picture width and height from the input
* parameters and stores into the context
*
* Input parameters:
* camHal - camera HAL handle
* params - QCameraParameters reference
*
* Return values:
* 0 If parameters are valid
* -1 If parameters are invalid
*
* Notes: none
*****************************************************************************/
static int usbCamSetPictSize( camera_hardware_t *camHal,
const QCameraParameters& params)
{
int rc = 0, width, height, i, numPictSizes, validSize;
ALOGD("%s: E", __func__);
/* parse for picture width and height */
params.getPictureSize(&width, &height);
ALOGI("%s: Requested picture size %d x %d", __func__, width, height);
// Validate the picture size
numPictSizes = sizeof(picture_sizes) / sizeof(camera_size_type);
for (i = 0, validSize = 0; i < numPictSizes; i++) {
if (width == picture_sizes[i].width
&& height == picture_sizes[i].height) {
validSize = 1;
camHal->qCamParams.setPictureSize(width, height);
ALOGD("%s: setPictureSize: width: %d height: %d",
__func__, width, height);
/* TBD: If new pictSize is different from old size, restart prvw */
camHal->pictWidth = width;
camHal->pictHeight = height;
}
}
if(!validSize)
ALOGE("%s: Invalid picture size %dx%d requested", __func__,
width, height);
rc = (validSize == 0)? -1:0;
ALOGD("%s: X", __func__);
return rc;
} /* usbCamSetPictSize */
/******************************************************************************
* Function: usbCamSetThumbnailSize
* Description: This function parses picture width and height from the input
* parameters and stores into the context
*
* Input parameters:
* camHal - camera HAL handle
* params - QCameraParameters reference
*
* Return values:
* 0 If parameters are valid
* -1 If parameters are invalid
*
* Notes: none
*****************************************************************************/
static int usbCamSetThumbnailSize( camera_hardware_t *camHal,
const QCameraParameters& params)
{
int rc = 0, width, height, i, numThumbnailSizes, validSize;
char tempStr[FILENAME_LENGTH];
ALOGD("%s: E", __func__);
/* parse for thumbnail width and height */
width = params.getInt(QCameraParameters::KEY_JPEG_THUMBNAIL_WIDTH);
height = params.getInt(QCameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT);
ALOGI("%s: Requested thumbnail size %d x %d", __func__, width, height);
// Validate the thumbnail size
numThumbnailSizes = sizeof(thumbnail_sizes) / sizeof(camera_size_type);
for (i = 0, validSize = 0; i < numThumbnailSizes; i++) {
if (width == thumbnail_sizes[i].width
&& height == thumbnail_sizes[i].height) {
validSize = 1;
camHal->thumbnailWidth = width;
camHal->thumbnailHeight = height;
sprintf(tempStr, "%d", camHal->thumbnailWidth);
camHal->qCamParams.set(QCameraParameters::KEY_JPEG_THUMBNAIL_WIDTH,
width);
sprintf(tempStr, "%d", camHal->thumbnailHeight);
camHal->qCamParams.set(QCameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT,
height);
}
}
if(!validSize)
ALOGE("%s: Invalid picture size %dx%d requested", __func__,
width, height);
rc = (validSize == 0)? -1:0;
ALOGD("%s: X", __func__);
return rc;
} /* usbCamSetThumbnailSize */
/******************************************************************************
* Function: usbCamSetJpegQlty
* Description: This function parses picture and thumbnail JPEG quality and
* validates before storing in the context
*
* Input parameters:
* camHal - camera HAL handle
* params - QCameraParameters reference
*
* Return values:
* 0 If parameters are valid
* -1 If parameters are invalid
*
* Notes: none
*****************************************************************************/
static int usbCamSetJpegQlty( camera_hardware_t *camHal,
const QCameraParameters& params)
{
int rc = 0, quality = 0;
char tempStr[FILENAME_LENGTH];
ALOGD("%s: E", __func__);
/**/
quality = params.getInt(QCameraParameters::KEY_JPEG_QUALITY);
ALOGI("%s: Requested picture qlty %d", __func__, quality);
if (quality >= 0 && quality <= 100) {
camHal->pictJpegQlty = quality;
sprintf(tempStr, "%d", camHal->pictJpegQlty);
camHal->qCamParams.set(QCameraParameters::KEY_JPEG_QUALITY, quality);
} else {
ALOGE("Invalid jpeg quality=%d", quality);
rc = -1;
}
quality = params.getInt(QCameraParameters::KEY_JPEG_THUMBNAIL_QUALITY);
ALOGI("%s: Requested thumbnail qlty %d", __func__, quality);
if (quality >= 0 && quality <= 100) {
camHal->thumbnailJpegQlty = quality;
sprintf(tempStr, "%d", camHal->thumbnailJpegQlty);
camHal->qCamParams.set(QCameraParameters::KEY_JPEG_THUMBNAIL_QUALITY,
tempStr);
} else {
ALOGE("Invalid jpeg thumbnail quality=%d", quality);
rc = -1;
}
ALOGD("%s: X rc:%d", __func__, rc);
return rc;
}
}; /*namespace android */

File diff suppressed because it is too large Load diff