diff options
author | Jeongmo Yang <jm80.yang@samsung.com> | 2012-09-07 21:59:49 +0900 |
---|---|---|
committer | Jeongmo Yang <jm80.yang@samsung.com> | 2012-09-07 22:00:07 +0900 |
commit | 8665a5303d5fa3daaba53cff8f0758e0fc859636 (patch) | |
tree | 1f047a01969b70f244d6c0b4381a34e5b7b64355 /camerasrc/src/include | |
parent | 4e9e23ca3164c203a46c205da5af49e354dbbdd2 (diff) | |
download | gst-plugins-s5pc2xx-master.tar.gz gst-plugins-s5pc2xx-master.tar.bz2 gst-plugins-s5pc2xx-master.zip |
Initial releaseHEADsubmit/master/20120920.1509352.0_alphamaster2.0alpha
Change-Id: I0736f126be88ae94efb6698b91de356c16357e52
Diffstat (limited to 'camerasrc/src/include')
-rw-r--r-- | camerasrc/src/include/camerasrc-common.h | 408 | ||||
-rw-r--r-- | camerasrc/src/include/camerasrc-error.h | 140 | ||||
-rw-r--r-- | camerasrc/src/include/camerasrc-internal.h | 247 | ||||
-rw-r--r-- | camerasrc/src/include/camerasrc.h | 1488 | ||||
-rw-r--r-- | camerasrc/src/include/gstcamerasrc.h | 175 | ||||
-rw-r--r-- | camerasrc/src/include/gstcamerasrccolorbalance.h | 93 | ||||
-rw-r--r-- | camerasrc/src/include/gstcamerasrccontrol.h | 384 |
7 files changed, 2935 insertions, 0 deletions
diff --git a/camerasrc/src/include/camerasrc-common.h b/camerasrc/src/include/camerasrc-common.h new file mode 100644 index 0000000..207cdd3 --- /dev/null +++ b/camerasrc/src/include/camerasrc-common.h @@ -0,0 +1,408 @@ +/* + * camerasrc + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Jeongmo Yang <jm80.yang@samsung.com> + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __CAMERASRC_COMMON_H__ +#define __CAMERASRC_COMMON_H__ + +#include <stdio.h> +#include <malloc.h> +#include <pthread.h> +#include <errno.h> /*EXXX*/ +#include <sys/ioctl.h> /*ioctl*/ +#include <string.h> /*memcpy*/ + +#include <sys/types.h> /*open*/ +#include <sys/stat.h> +#include <fcntl.h> + +#include <unistd.h> /*mmap*/ +#include <sys/mman.h> /*alloc series, free..*/ +#include <sys/time.h> /*gettimeofday*/ +#include <math.h> /*log2*/ +#include <gst/gst.h> + +#undef __ASM_ARM_TYPES_H +#undef __ASSEMBLY_ +#undef _I386_TYPES_H + +#include <asm/types.h> +#include <linux/videodev2.h> /* V4L2 APIs */ +#include <linux/videodev2_exynos_camera.h> +#include <linux/videodev2_exynos_media.h> + +#include "camerasrc.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * Memory utility definitions + */ +#if !defined (PAGE_SHIFT) + #define PAGE_SHIFT sysconf(_SC_PAGESIZE) +#endif +#if !defined (PAGE_SIZE) + #define PAGE_SIZE (1UL << PAGE_SHIFT) +#endif +#if !defined (PAGE_MASK) + #define PAGE_MASK (~(PAGE_SIZE-1)) +#endif + +#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) +#define CLEAR(x) memset (&(x), 0, sizeof (x)) + +#define CAMERASRC_MAX_WIDTH 2560 +#define CAMERASRC_MAX_HEIGHT 1920 +#define CAMERASRC_CID_NOT_SUPPORT -1 +#define CAMERASRC_USRPTR_MAX_BUFFER_NUM 12 +#define CAMERASRC_MAX_FILENAME_LEN 255 +#define CAMERASRC_DEV_NODE_PREFIX "/dev/video" +#define CAMERASRC_DEV_FD_INIT -1 +#define CAMERASRC_DEV_ON_ACCESS_STR "ONACCESS" +#define CAMERASRC_DEV_RELEASED_STR "RELEASED" +#define CAMERASRC_OPENED_CHK_FILENAME "/tmp/.dev_chk" +#define CAMERASRC_THREAD_KILL -999 +#define CAMERASRC_DEV_FD_EMERGENCY_CLOSED -999 +#define CAMERASRC_ERRMSG_MAX_LEN 128 +#define CAMERASRC_FRAME_DUMP_PATH "/tmp/" +#define CAMERASRC_DBG_SCRIPT_PATH "/mnt/mmc/cam_dbg_script" +#define CAMERASRC_PRIMARY_BASIC_INFO_PATH "/tmp/.camprimarybasicinfo" +#define CAMERASRC_PRIMARY_MISC_INFO_PATH "/tmp/.camprimarymiscinfo" +#define CAMERASRC_PRIMARY_EXTRA_INFO_PATH "/tmp/.camprimaryextrainfo" +#define CAMERASRC_SECONDARY_BASIC_INFO_PATH "/tmp/.camsecondarybasicinfo" +#define CAMERASRC_SECONDARY_MISC_INFO_PATH "/tmp/.camsecondarymiscinfo" +#define CAMERASRC_SECONDARY_EXTRA_INFO_PATH "/tmp/.camsecondaryextrainfo" +#define CAMERASRC_MAX_IMAGE_BUFFER_PLANES 3 + +#define USE_OPEN_CHK /*< Using open check with temporary file */ +#define USE_SENSOR_MODE 1 +/*#define USE_SKIP_FRAME*/ /*< Skip frame toggle */ +/*#define USE_IOCTL_DEBUG*/ /*< For debugging ioctl name, argument, address, etc */ +/*#define USE_FRAME_COPY_BOUNDARY_CHECK*/ /*< Copy boundary checks occurs seg fault when overrun */ +/*#define USE_SKIP_FRAME_AT_RAW_FRAME*/ /*< In pumping raw frame, initial 2-3 frames are darker. so skip it */ +/*#define USE_CAMERASRC_FRAME_DUMP*/ /*< Debug system annoying me. Use printf!!!! */ +/*#define USE_USERPTR_DEBUG*/ +/*#define ENABLE_Q_ERROR*/ + +#ifndef GST_CAT_DEFAULT +GST_DEBUG_CATEGORY_EXTERN(camerasrc_debug); +#define GST_CAT_DEFAULT camerasrc_debug +#endif /* GST_CAT_DEFAULT */ + + +#define camsrc_info(msg, args...) GST_INFO(msg, ##args) +#define camsrc_warning(msg, args...) GST_WARNING(msg, ##args) +#define camsrc_error(msg, args...) GST_ERROR(msg, ##args) +#define camsrc_critical(msg, args...) GST_ERROR(msg, ##args) +#define camsrc_assert(condition) { \ + if (!(condition)) { \ + GST_ERROR("failed [%s]", #condition); \ + } \ +} + +/* + * Values for internal + */ +enum camerasrc_op_mode_t { + CAMERASRC_OP_PREVIEW = 0, + CAMERASRC_OP_CAPTURE, + CAMERASRC_OP_VIDEO, + CAMERASRC_OP_REGISTER_VALUE, + CAMERASRC_OP_NUM, +}; + +/* + * Values for internal + */ +enum camerasrc_ctrl_property_t{ + CAMERASRC_CTRL_SUPPORT = 0, + CAMERASRC_CTRL_MAX_VALUE, + CAMERASRC_CTRL_MIN_VALUE, + CAMERASRC_CTRL_CID_VALUE, + CAMERASRC_CTRL_CURRENT_VALUE, + CAMERASRC_CTRL_PROPERTY_NUM, +}; + +/* + * Values for internal + */ +enum camerasrc_quality_t{ + CAMERASRC_QUALITY_NORMAL = 0, + CAMERASRC_QUALITY_HIGH, + CAMERASRC_QUALITY_NUM, +}; + +enum camerasrc_dev_recog_t{ + CAMERASRC_DEV_RECOG_ID = 0, + CAMERASRC_DEV_RECOG_INDEX, + CAMERASRC_DEV_RECOG_NUM, +}; + +/** + * Phase, camerasrc consist of two phase, running and non-running. + */ +typedef enum { + CAMERASRC_PHASE_RUNNING = 0, + CAMERASRC_PHASE_NON_RUNNING, + CAMERASRC_PHASE_NUM, +} _camerasrc_phase_t; + +typedef enum { + CAMERASRC_MISC_STILL_SIGNAL = 0, + CAMERASRC_MISC_SKIP_FRAME, + CAMERASRC_MISC_FUNC_NUM, +} _camerasrc_misc_func_t; + +typedef enum{ + _CAMERASRC_CMD_AF_CONTROL = 0, + _CAMERASRC_CMD_AF_AREA, + _CAMERASRC_CMD_STROBE_MODE, + _CAMERASRC_CMD_FACEDETECTION, + _CAMERASRC_CMD_SHUTTER_SPEED, + _CAMERASRC_CMD_SUPPORT_EMBED_EXIF, + _CAMERASRC_CMD_SUPPORT_JPEG_ENCODING, + _CAMERASRC_CMD_CHECK_ESD, + _CAMERASRC_CMD_JPEG_COMPRESS_RATIO, + _CAMERASRC_CMD_JPEG_LENGTH, + _CAMERASRC_CMD_JPEG_THMBNL_LENGTH, + _CAMERASRC_CMD_JPEG_THMBNL_OFFSET, + _CAMERASRC_CMD_JPEG_SCRNL_LENGTH, + _CAMERASRC_CMD_JPEG_SCRNL_OFFSET, + _CAMERASRC_CMD_EXPOSURE_VALUE, + _CAMERASRC_CMD_ESD_CHECK, + _CAMERASRC_CMD_FRAME_DATA, + _CAMERASRC_CMD_EXIF_INFO, + _CAMERASRC_CMD_CTRL, + _CAMERASRC_CMD_ROTATION, + _CAMERASRC_CMD_SENSOR_MODE, + _CAMERASRC_CMD_VFLIP, + _CAMERASRC_CMD_HFLIP, + _CAMERASRC_CMD_NUM, +}_camsrc_cmd_t; + +typedef struct{ + int cid; + int value; +} _camerasrc_ctrl_t; + +enum { + _CAMERASRC_FACEDETECTION_START = 0, + _CAMERASRC_FACEDETECTION_STOP, + _CAMERASRC_FACEDETECTION_NUM, +}; + +enum { + _CAMERASRC_AF_START = 0, + _CAMERASRC_AF_STOP, + _CAMERASRC_AF_RELEASE, + _CAMERASRC_AF_INIT, + _CAMERASRC_AF_DESTROY, +}; + +// U T I L I T Y D E F I N I T I O N +/** + * Mapping device index - Device ID + */ +#define _CAMERASRC_GET_DEV_INDEX(dev_id) _camerasrc_dev_index[dev_id][CAMERASRC_DEV_RECOG_INDEX] +#define _CAMERASRC_GET_DEV_ID(dev_idx) _camerasrc_dev_index[dev_idx][CAMERASRC_DEV_RECOG_ID] + +/** + * For colorspace - pixel format combinability check + */ +#define _CAMERASRC_MATCH_COL_TO_PIX(dev_id, colorspace, pixel_fmt, quality) _camerasrc_match_col_to_pix[dev_id][colorspace][pixel_fmt][quality] + +/** + * For control capability check + */ +#define _CAMERASRC_CHK_SUPPORT_CONTROL(ctrl_id, dev_id) _camerasrc_ctrl_list[dev_id][ctrl_id][CAMERASRC_CTRL_SUPPORT] +#define _CAMERASRC_MAX_VALUE(ctrl_id, dev_id) _camerasrc_ctrl_list[dev_id][ctrl_id][CAMERASRC_CTRL_MAX_VALUE] +#define _CAMERASRC_MIN_VALUE(ctrl_id, dev_id) _camerasrc_ctrl_list[dev_id][ctrl_id][CAMERASRC_CTRL_MIN_VALUE] +#define _CAMERASRC_GET_CID(ctrl_id, dev_id) _camerasrc_ctrl_list[dev_id][ctrl_id][CAMERASRC_CTRL_CID_VALUE] +#define _CAMERASRC_GET_CURRENT_VALUE(ctrl_id, dev_id) _camerasrc_ctrl_list[dev_id][ctrl_id][CAMERASRC_CTRL_CURRENT_VALUE] +#define _CAMERASRC_SET_CURRENT_VALUE(ctrl_id, dev_id, value) _camerasrc_ctrl_list[dev_id][ctrl_id][CAMERASRC_CTRL_CURRENT_VALUE] = value + +/** + * Need miscellaneous function on operation? + */ +#define _CAMERASRC_NEED_MISC_FUNCTION(dev_id, operation, colorspace, misc_func) _camerasrc_misc_func_list[dev_id][operation][colorspace][misc_func] +#define _CAMERASRC_SUPPORT_AF(dev_id) _camerasrc_af_support[dev_id] + +/** + * Utility definitions + */ +#define CAMERASRC_SET_STATE(handle, state) { \ + handle->prev_state = handle->cur_state; \ + handle->cur_state = state; \ + camsrc_info("Set state [%d] -> [%d]", handle->prev_state, handle->cur_state); \ +} +#define CAMERASRC_SET_PHASE(handle, phase) handle->cur_phase = phase; +#define CAMERASRC_STATE(handle) (handle->cur_state) +#define CAMERASRC_PREV_STREAM_STATE(handle) -1 +#define CAMERASRC_PHASE(handle) (handle->cur_phase) +#define CAMERASRC_HANDLE(handle) ((camerasrc_handle_t*) handle) +#define CAMERASRC_CURRENT_DEV_ID(handle) (handle->dev_id) +#define CAMERASRC_IS_DEV_CLOSED(p) (p->dev_fd == -1 || p->dev_fd == CAMERASRC_DEV_FD_EMERGENCY_CLOSED) + +#define YUV422_SIZE(handle) ((handle->format.img_size.dim.height * handle->format.img_size.dim.width) << 1) +#define YUV420_SIZE(handle) ((handle->format.img_size.dim.height * handle->format.img_size.dim.width * 3) >> 1) +#define RGB565_SIZE(handle) ((handle->format.img_size.dim.height * handle->format.img_size.dim.width) << 1) + +#define ISO_APPROXIMATE_VALUE(iso_in, iso_approximated) { \ + if(iso_in > 8.909 && iso_in <= 11.22) iso_approximated = 10; \ + else if(iso_in > 11.22 && iso_in <= 14.14) iso_approximated = 12; \ + else if(iso_in > 14.14 && iso_in <= 17.82) iso_approximated = 16; \ + else if(iso_in > 17.82 && iso_in <= 22.45) iso_approximated = 20; \ + else if(iso_in > 22.45 && iso_in <= 28.28) iso_approximated = 25; \ + else if(iso_in > 28.28 && iso_in <= 35.64) iso_approximated = 32; \ + else if(iso_in > 35.64 && iso_in <= 44.90) iso_approximated = 40; \ + else if(iso_in > 44.90 && iso_in <= 56.57) iso_approximated = 50; \ + else if(iso_in > 56.57 && iso_in <= 71.27) iso_approximated = 64; \ + else if(iso_in > 71.27 && iso_in <= 89.09) iso_approximated = 80; \ + else if(iso_in > 89.09 && iso_in <= 112.2) iso_approximated = 100; \ + else if(iso_in > 112.2 && iso_in <= 141.4) iso_approximated = 125; \ + else if(iso_in > 141.4 && iso_in <= 178.2) iso_approximated = 160; \ + else if(iso_in > 178.2 && iso_in <= 224.5) iso_approximated = 200; \ + else if(iso_in > 224.5 && iso_in <= 282.8) iso_approximated = 250; \ + else if(iso_in > 282.8 && iso_in <= 356.4) iso_approximated = 320; \ + else if(iso_in > 356.4 && iso_in <= 449.0) iso_approximated = 400; \ + else if(iso_in > 449.0 && iso_in <= 565.7) iso_approximated = 500; \ + else if(iso_in > 565.7 && iso_in <= 712.7) iso_approximated = 640; \ + else if(iso_in > 712.7 && iso_in <= 890.9) iso_approximated = 800; \ + else if(iso_in > 890.9 && iso_in <= 1122) iso_approximated = 1000; \ + else if(iso_in > 1122 && iso_in <= 1414) iso_approximated = 1250; \ + else if(iso_in > 1414 && iso_in <= 1782) iso_approximated = 1600; \ + else if(iso_in > 1782 && iso_in <= 2245) iso_approximated = 2000; \ + else if(iso_in > 2245 && iso_in <= 2828) iso_approximated = 2500; \ + else if(iso_in > 2828 && iso_in <= 3564) iso_approximated = 3200; \ + else if(iso_in > 3564 && iso_in <= 4490) iso_approximated = 4000; \ + else if(iso_in > 4490 && iso_in <= 5657) iso_approximated = 5000; \ + else if(iso_in > 5657 && iso_in <= 7127) iso_approximated = 6400; \ + else if(iso_in > 7127 && iso_in <= 8909) iso_approximated = 8000; \ + else { \ + camsrc_warning("Invalid parameter(Maybe kernel failure).. give default value, 100");\ + iso_approximated = 100;\ + }\ +} + +#define PHOTOMETRY_MODE_TO_METERING_MODE(photometry_mode, metering_mode) { \ + if(photometry_mode == V4L2_PHOTOMETRY_MULTISEG) metering_mode = 1; \ + else if (photometry_mode == V4L2_PHOTOMETRY_CWA) metering_mode = 2; \ + else if (photometry_mode == V4L2_PHOTOMETRY_SPOT) metering_mode = 3; \ + else if (photometry_mode == V4L2_PHOTOMETRY_AFSPOT) metering_mode = 3; \ + else metering_mode = 1; \ +} + +#define CAMERASRC_EXIF_SHUTTERSPEED_VALUE_IN_APEX(NUM, DEN) (int)(-(log2((double)((double)NUM/(double)DEN)))) +#define CAMERASRC_EXIF_APERTURE_VALUE_IN_APEX(NUM, DEN) (int)(2 * (log2((double)((double)NUM/(double)DEN)))) + + +typedef void *(*camerasrc_signal_func_t) (camsrc_handle_t handle); +typedef int (*camerasrc_skip_frame_func_t) (camsrc_handle_t handle, long int timeout, int skip_frame); + +typedef struct _camerasrc_handle_t { + int is_async_open; + + /* device information */ + int dev_fd; + int cur_dev_id; + camerasrc_buffer_t alter_frame; + int check_esd; + int errnum; + int lens_rotation; /* physical rotation of lens */ + + /* state information */ + int prev_stream_state; + int prev_state; + int cur_state; + int cur_phase; + + /* image format information */ + int is_highquality; + int is_preset; + camerasrc_resol_name_t resolution; + camerasrc_format_t format; + + /* buffer information */ + camerasrc_io_method_t io_method; + camerasrc_usr_buf_t *present_buf; + int buffer_idx; + int num_buffers; + int queued_buffer_count; + int first_frame; + struct v4l2_buffer queued_buf_list[CAMERASRC_USRPTR_MAX_BUFFER_NUM]; + camerasrc_buffer_t *buffer; + camerasrc_buffer_t scrnl_buf; /* screennail buffer of captured JPEG image */ + + /* autofocusing information */ + camerasrc_af_mode_t cur_af_mode; + camerasrc_af_scan_range_t cur_af_range; + camerasrc_callback_t af_cb; + pthread_t focusing_thread; + pthread_cond_t af_wait_cond; + camerasrc_auto_focus_status_t af_status; + camerasrc_auto_focus_cmd_t af_cmd; + int af_dev_val; + void *af_usr_data; + int hold_af_after_capturing; + int af_init_called; /* whether af init was called after device open. */ + struct timeval set_af_area_time; /* for AF start delay after set AF area */ + + /* Jpg Still information */ + camerasrc_skip_frame_func_t skip_frame_func; + + /* Shutter & exposure value */ + int isAutoexposure; + + /* fps */ + camerasrc_frac_t timeperframe; + + /* sensor mode */ + camerasrc_sensor_mode_t sensor_mode; + + /* flip */ + int vflip; + int hflip; + + /* thread safe mechanism */ + pthread_mutex_t mutex; + pthread_mutex_t af_mutex; + pthread_cond_t cond; +} camerasrc_handle_t; + +typedef struct { + int (*_ioctl) (camerasrc_handle_t *handle, int request, void *arg); + int (*_ioctl_once) (camerasrc_handle_t *handle, int request, void *arg); + void *(*_run_autofocusing) (camerasrc_handle_t *handle); + int (*_skip_frame) (camerasrc_handle_t *handle, long int timeout, int skip_frame); + int (*_copy_frame) (camerasrc_handle_t *handle, camerasrc_buffer_t *src_buffer, camerasrc_buffer_t *dst_buffer, int isThumbnail); + int (*_set_cmd) (camerasrc_handle_t *handle, _camsrc_cmd_t cmd, void *value); + int (*_get_cmd) (camerasrc_handle_t *handle, _camsrc_cmd_t cmd, void *value); +} CAMERASRC_DEV_DEPENDENT_MISC_FUNC; + +#ifdef __cplusplus +} +#endif + +#endif /*__CAMERASRC_COMMON_H__*/ diff --git a/camerasrc/src/include/camerasrc-error.h b/camerasrc/src/include/camerasrc-error.h new file mode 100644 index 0000000..4ea8c7f --- /dev/null +++ b/camerasrc/src/include/camerasrc-error.h @@ -0,0 +1,140 @@ +/* + * camerasrc + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Jeongmo Yang <jm80.yang@samsung.com> + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __CAMERASRC_ERROR_H__ +#define __CAMERASRC_ERROR_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * CAMSRC CLASS + */ +#define CAMERASRC_SUCCESS (0x00000000) /**< No Error */ +#define CAMERASRC_ERROR (0x80000000) /**< Error Class */ +#define CAMERASRC_WARING (0x70000000) /**< Waring Class */ + +/* + * Detail enumeration + */ +enum { + CAMSRC_IN_UNKNOWN = 0, + CAMSRC_IN_PARAMETER, + CAMSRC_IN_HANDLE, + CAMSRC_IN_POINTER, + CAMSRC_IN_VALUE, + CAMSRC_IN_OVERRUN, + CAMSRC_IN_UNDERRUN, + CAMSRC_IN_RANGE_OVER, + CAMSRC_IN_RANGE_UNDER, + CAMSRC_IN_MODE, + CAMSRC_IN_FORMAT, + CAMSRC_IN_CHANNEL, + CAMSRC_IN_SAMPLERATE, + CAMSRC_IN_LAYER, + CAMSRC_IN_ROTATE, + CAMSRC_IN_ALLOC, + CAMSRC_IN_INTERNAL, + /*Extra state for camera*/ + CAMSRC_IN_IO_CONTROL, + CAMSRC_IN_DEVICE_OPEN, + CAMSRC_IN_DEVICE_BUSY, + CAMSRC_IN_DEVICE_NOT_FOUND, + CAMSRC_IN_DEVICE_REGISTER_TROUBLE, + CAMSRC_IN_WAIT_RES, + CAMSRC_IN_SUPPORT, + CAMSRC_IN_STATE, + CAMSRC_IN_PRIVILEGE, + CAMSRC_IN_SECURITY_SERVICE, +}; + +/* + * CAMERASRC_WARNING + */ +#define CAMERASRC_WAR_INVALID_PARAMETER (CAMERASRC_WARING | CAMSRC_IN_PARAMETER) +#define CAMERASRC_WAR_INVALID_HANDLE (CAMERASRC_WARING | CAMSRC_IN_HANDLE) +#define CAMERASRC_WAR_INVALID_VALUE (CAMERASRC_WARING | CAMSRC_IN_VALUE) +#define CAMERASRC_WAR_INVALID_MODE (CAMERASRC_WARING | CAMSRC_IN_MODE) +#define CAMERASRC_WAR_INVALID_FORMAT (CAMERASRC_WARING | CAMSRC_IN_FORMAT) +#define CAMERASRC_WAR_INVALID_CHANNEL (CAMERASRC_WARING | CAMSRC_IN_CHANNEL) +#define CAMERASRC_WAR_INVALID_SAMPLERATE (CAMERASRC_WARING | CAMSRC_IN_SAMPLERATE) +#define CAMERASRC_WAR_INVALID_LAYER (CAMERASRC_WARING | CAMSRC_IN_LAYER) +#define CAMERASRC_WAR_INVALID_ROTATE (CAMERASRC_WARING | CAMSRC_IN_ROTATE) +#define CAMERASRC_WAR_NULL_POINTER (CAMERASRC_WARING | CAMSRC_IN_POINTER) +#define CAMERASRC_WAR_UNDERRUN (CAMERASRC_WARING | CAMSRC_IN_UNDERRUN) +#define CAMERASRC_WAR_OVERRUN (CAMERASRC_WARING | CAMSRC_IN_OVERRUN) +#define CAMERASRC_WAR_RANGE_OVER (CAMERASRC_WARING | CAMSRC_IN_RANGE_OVER) +#define CAMERASRC_WAR_RANGE_UNDER (CAMERASRC_WARING | CAMSRC_IN_RANGE_UNDER) +#define CAMERASRC_WAR_ALLOCATION (CAMERASRC_WARING | CAMSRC_IN_ALLOC) +#define CAMERASRC_WAR_INTERNAL (CAMERASRC_WARING | CAMSRC_IN_INTERNAL) +/*Extra warning for camera*/ +#define CAMERASRC_WAR_IO_CONTROL (CAMERASRC_WARING | CAMSRC_IN_IO_CONTROL) +#define CAMERASRC_WAR_DEVICE_OPEN (CAMERASRC_WARING | CAMSRC_IN_DEVICE_OPEN) +#define CAMERASRC_WAR_DEVICE_BUSY (CAMERASRC_WARING | CAMSRC_IN_DEVICE_BUSY) +#define CAMERASRC_WAR_DEVICE_NOT_FOUND (CAMERASRC_WARING | CAMSRC_IN_DEVICE_NOT_FOUND) +#define CAMERASRC_WAR_DEVICE_UNAVAILABLE (CAMERASRC_WARING | CAMSRC_IN_DEVICE_REGISTER_TROUBLE) +#define CAMERASRC_WAR_DEVICE_WAIT_TIMEOUT (CAMERASRC_WARING | CAMSRC_IN_WAIT_RES) +#define CAMERASRC_WAR_DEVICE_NOT_SUPPORT (CAMERASRC_WARING | CAMSRC_IN_SUPPORT) +#define CAMERASRC_WAR_INVALID_STATE_TRANSITION (CAMERASRC_WARING | CAMSRC_IN_STATE) + +/** + * CAMERASRC_ERROR + */ +#define CAMERASRC_ERR_INVALID_PARAMETER (CAMERASRC_ERROR | CAMSRC_IN_PARAMETER) +#define CAMERASRC_ERR_INVALID_HANDLE (CAMERASRC_ERROR | CAMSRC_IN_HANDLE) +#define CAMERASRC_ERR_INVALID_VALUE (CAMERASRC_ERROR | CAMSRC_IN_VALUE) +#define CAMERASRC_ERR_INVALID_MODE (CAMERASRC_ERROR | CAMSRC_IN_MODE) +#define CAMERASRC_ERR_INVALID_FORMAT (CAMERASRC_ERROR | CAMSRC_IN_FORMAT) +#define CAMERASRC_ERR_INVALID_CHANNEL (CAMERASRC_ERROR | CAMSRC_IN_CHANNEL) +#define CAMERASRC_ERR_INVALID_SAMPLERATE (CAMERASRC_ERROR | CAMSRC_IN_SAMPLERATE) +#define CAMERASRC_ERR_INVALID_LAYER (CAMERASRC_ERROR | CAMSRC_IN_LAYER) +#define CAMERASRC_ERR_INVALID_ROTATE (CAMERASRC_ERROR | CAMSRC_IN_ROTATE) +#define CAMERASRC_ERR_NULL_POINTER (CAMERASRC_ERROR | CAMSRC_IN_POINTER) +#define CAMERASRC_ERR_UNDERRUN (CAMERASRC_ERROR | CAMSRC_IN_UNDERRUN) +#define CAMERASRC_ERR_OVERRUN (CAMERASRC_ERROR | CAMSRC_IN_OVERRUN) +#define CAMERASRC_ERR_RANGE_OVER (CAMERASRC_ERROR | CAMSRC_IN_RANGE_OVER) +#define CAMERASRC_ERR_RANGE_UNDER (CAMERASRC_ERROR | CAMSRC_IN_RANGE_UNDER) +#define CAMERASRC_ERR_ALLOCATION (CAMERASRC_ERROR | CAMSRC_IN_ALLOC) +#define CAMERASRC_ERR_INTERNAL (CAMERASRC_ERROR | CAMSRC_IN_INTERNAL) +#define CAMERASRC_ERR_UNKNOWN (CAMERASRC_ERROR | CAMSRC_IN_UNKNOWN) /**< unknown error */ +/*Extra warning for camera*/ +#define CAMERASRC_ERR_IO_CONTROL (CAMERASRC_ERROR | CAMSRC_IN_IO_CONTROL) +#define CAMERASRC_ERR_DEVICE_OPEN (CAMERASRC_ERROR | CAMSRC_IN_DEVICE_OPEN) +#define CAMERASRC_ERR_DEVICE_BUSY (CAMERASRC_ERROR | CAMSRC_IN_DEVICE_BUSY) +#define CAMERASRC_ERR_DEVICE_NOT_FOUND (CAMERASRC_ERROR | CAMSRC_IN_DEVICE_NOT_FOUND) +#define CAMERASRC_ERR_DEVICE_UNAVAILABLE (CAMERASRC_ERROR | CAMSRC_IN_DEVICE_REGISTER_TROUBLE) +#define CAMERASRC_ERR_DEVICE_WAIT_TIMEOUT (CAMERASRC_ERROR | CAMSRC_IN_WAIT_RES) +#define CAMERASRC_ERR_DEVICE_NOT_SUPPORT (CAMERASRC_ERROR | CAMSRC_IN_SUPPORT) +#define CAMERASRC_ERR_INVALID_STATE (CAMERASRC_ERROR | CAMSRC_IN_STATE) +#define CAMERASRC_ERR_PRIVILEGE (CAMERASRC_ERROR | CAMSRC_IN_PRIVILEGE) +#define CAMERASRC_ERR_SECURITY_SERVICE (CAMERASRC_ERROR | CAMSRC_IN_SECURITY_SERVICE) + + +#define CAMERASRC_IS_FAIL(_A_) (CAMERASRC_ERROR & (_A_)) + +#ifdef __cplusplus +} +#endif + +#endif /* __CAMERASRC_ERROR_H__ */ diff --git a/camerasrc/src/include/camerasrc-internal.h b/camerasrc/src/include/camerasrc-internal.h new file mode 100644 index 0000000..6b97589 --- /dev/null +++ b/camerasrc/src/include/camerasrc-internal.h @@ -0,0 +1,247 @@ +/* + * camerasrc + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Jeongmo Yang <jm80.yang@samsung.com> + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __CAMERASRC_INTERNAL_H__ +#define __CAMERASRC_INTERNAL_H__ + +#include "camerasrc-common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Video 4 linux control ID definitions (Extended by kernel team) + * extended pixel format for V4l2 + */ + + +/** + * Miscellaneous camera-dependent definitions + */ +#define CAMERASRC_DEV_INDEX_MAX 2 +#define CAMERASRC_AF_TOTALTIME 5000000 +#define CAMERASRC_AF_INTERVAL 20000 +#define CAMERASRC_AF_STOP_INTERVAL 10000 +#define CAMERASRC_MEGA_DEV_NAME "/dev/video0" +#define CAMERASRC_VGA_DEV_NAME "/dev/video0" +#define CAMERASRC_JPG_STILL_H_SYNC 2048 +#define CAMERASRC_JPG_STILL_V_SYNC 2048 +#define CAMERASRC_JPG_STILL_SKIP_FRAME 0 +#define CAMERASRC_RAW_STILL_THUMBNAIL_OFFSET 1689600 +#define CAMERASRC_JPG_STILL_THUMBNAIL_OFFSET 0x1bd000 +#define CAMERASRC_MAX_MAIN_JPEG_SIZE CAMERASRC_JPG_STILL_H_SYNC * CAMERASRC_JPG_STILL_V_SYNC /* 0x1bd000 */ +#define CAMERASRC_MAX_THM_JPEG_SIZE 0 +#define CAMERASRC_PREVIEW_BUFFER_NUM 6 +#define CAMERASRC_VIDEO_BUFFER_NUM 7 +#define CAMERASRC_STILL_BUFFER_NUM 1 +#define CAMERASRC_YUV_THMBNL_SIZE 320 * 240 * 2 +#define CAMERASRC_TIMEOUT_CRITICAL_VALUE 5000 +#define CAMERASRC_PRE_AF_INTERVAL 0 +#define CAMERASRC_REGISTER_SET_RETRY_NO 200 +#define CAMERASRC_V4L2_PREVIEW_PIX_FMT_DEFAULT V4L2_PIX_FMT_YUYV +#define CAMERASRC_V4L2_JPEG_CAPTURE_PIX_FMT_DEFAULT V4L2_PIX_FMT_JPEG +#define CAMERASRC_V4L2_JPG_YUV_CAPTURE_PIX_FMT_DEFAULT V4L2_PIX_FMT_MJPEG +#define CAMERASRC_V4L2_RGB_CAPTURE_PIX_FMT_DEFAULT V4L2_PIX_FMT_RGB565 + +#define CAMERASRC_SYNC_KEY_PATH "FUJITSU_M5MOLS" +#define CAMERASRC_SYNC_KEY_PREFIX 0x55 + +#define CAMERASRC_AF_DELAY_AFTER_SET_AF_AREA 350 /* msec */ + +#define _CAMERASRC_EXIF_COMP_CONF (0x00000000) | (0x00000001) | (0x00000002 << 8) | (0x00000003 << 16) /* Y Cb Cr - */ +#define _CAMERASRC_EXIF_COLORSPACE 0x00000001 +#define _CAMERASRC_EXIF_FOCAL_LEN_NUM 454 +#define _CAMERASRC_EXIF_FOCAL_LEN_DEN 100 +#define _CAMERASRC_EXIF_F_NUM_NUM 28 +#define _CAMERASRC_EXIF_F_NUM_DEN 10 +#define _CAMERASRC_EXIF_MAX_F_NUM_NUM_IN_APEX 3 + +#define _CAMERASRC_CMD_SUPPORT_EMBED_EXIF_DEF 0 + +/* + * |------------------------------------------------------------| + * | | Primary | Secondary | Extension| Unknown | + * |------------------------------------------------------------| + * | Index | 2 | 1 | 0 | -1 | + * |------------------------------------------------------------| + * + * |------------------------------------------------------------| + * | | 0 | 1 | 2 | 3 | + * |------------------------------------------------------------| + * | ID | Unknown | Secondary | Primary | Extension | + * |------------------------------------------------------------| + */ + +static int _camerasrc_dev_index[CAMERASRC_DEV_ID_NUM][CAMERASRC_DEV_RECOG_NUM] = +{ + {CAMERASRC_DEV_ID_SECONDARY, 0}, + {CAMERASRC_DEV_ID_PRIMARY, 1}, + {CAMERASRC_DEV_ID_EXTENSION, 2}, + {CAMERASRC_DEV_ID_UNKNOWN, -1}, +}; + + +/** + * preset size index + * |-------------------------------------------------------------------------| + * | | | YUV422P | YUV420P | SRGGB8 | SRGGB10 | + * |-------------------------------------------------------------------------| + * | | Highquality | O | X | X | X | + * | RAW |-----------------------------------------------------------| + * | | Normal | O | X | X | X | + * |-------------------------------------------------------------------------| + * | | Highquality | X | X | O | X | + * | JPEG |-----------------------------------------------------------| + * | | Normal | X | X | X | X | + * |-------------------------------------------------------------------------| + */ +static char _camerasrc_match_col_to_pix[CAMERASRC_DEV_ID_EXTENSION][CAMERASRC_COL_NUM][CAMERASRC_PIX_NUM][CAMERASRC_QUALITY_NUM] = +{ + {/*SECONDARY*/ + /*422P, 420P, SRGGB8, SRGGB10*/ + {{0x1,0x0}, {0x0,0x0}, {0x0,0x0}, {0x0,0x0}}, /**< RAW */ + {{0x0,0x0}, {0x0,0x0}, {0x0,0x0}, {0x0,0x0}}, /**< JPG */ + }, + {/*PRIMARY*/ + /*422P, 420P, SRGGB8, SRGGB10 */ + {{0x1,0x0}, {0x0,0x0}, {0x0,0x0}, {0x0,0x0}}, /**< RAW */ + {{0x0,0x0}, {0x0,0x0}, {0x0,0x1}, {0x0,0x1}}, /**< JPG */ + }, +}; /* {Normal quality, High quality} */ + +/* + * |--------------------------------------------------------------------------------| + * | | Support | MAX value | MIN value | CID | + * |--------------------------------------------------------------------------------| + * | Brightness | 1 | 8 | 0 | V4L2_CID_BRIGHTNESS | + * |--------------------------------------------------------------------------------| + * | Contrast | 1 | 9 | 0 | -1 | + * |--------------------------------------------------------------------------------| + * | Digital zoom | 1 | 100 | 0 | V4L2_CID_BASE+29 | + * |--------------------------------------------------------------------------------| + * | Optical zoom | 0 | -1 | -1 | -1 | + * |--------------------------------------------------------------------------------| + * | White balance | 1 | 9 | 0 | V4L2_CID_DO_WHITE_BALANCE | + * |--------------------------------------------------------------------------------| + * | Color tone | 1 | 14 | 0 | V4L2_CID_BASE+28 | + * |--------------------------------------------------------------------------------| + * | Program mode | 0 | -1 | -1 | -1 | + * |--------------------------------------------------------------------------------| + * | Flip | 1 | 1 | 0 | V4L2_CID_FLIP | + * |--------------------------------------------------------------------------------| + * | Flash | 1 | 2 | 0 | V4L2_CID_BASE+32 | + * |--------------------------------------------------------------------------------| + */ + +/* CUSTOM V4L2 CONTROL ID DEFINITIONS */ + +#define CAM_AF_STATUS_ONGOING 0 +#define CAM_AF_STATUS_FOCUSED 1 +#define CAM_AF_STATUS_FAILED 2 + +enum { + CAMERASRC_SENSOR_AF_STATUS_ONGOING = CAM_AF_STATUS_ONGOING, + CAMERASRC_SENSOR_AF_STATUS_FOCUSED = CAM_AF_STATUS_FOCUSED, + CAMERASRC_SENSOR_AF_STATUS_FAILED = CAM_AF_STATUS_FAILED +}; + +/* FACE_DETECTION CMD & STATUS */ +#define V4L2_CID_FACE_DETECTION (V4L2_CID_PRIVATE_BASE + 38) + +#define CAM_FACE_DETECTION_OFF 0 +#define CAM_FACE_DETECTION_ON 1 + +/* ESD INTERRUPT CHECK */ +/*To read interrupt status of "Data output stop from sensor"*/ +#define V4L2_CID_ESD_INT (V4L2_CID_PRIVATE_BASE + 40) + +#define CAM_ESD_INT_NORMAL 0 +#define CAM_ESD_INT_TROUBLE 1 + + +/* CUSTOM V4L2 CONTROL ID DEFINITIONS (END) */ +static int _camerasrc_ctrl_list[CAMERASRC_DEV_ID_EXTENSION][CAMERASRC_CTRL_NUM][CAMERASRC_CTRL_PROPERTY_NUM] = +{ /* { SUPPORT, MAX_VALUE, MIN_VALUE, CID, CURRENT_VALUE } */ + { /* Primary camera */ + {-1, 4, -4, V4L2_CID_EXPOSURE, 0}, /* Brightness */ + {-1, 3, -3, V4L2_CID_CONTRAST, 0}, /* Contrast */ + {-1, 30, 0, V4L2_CID_CAMERA_ZOOM, 0}, /* Digital zoom */ + {0, -1, -1, -1, -1}, /* Optical zoom */ + {-1, CAMERASRC_WHITEBALANCE_HORIZON, CAMERASRC_WHITEBALANCE_AUTO, V4L2_CID_WHITE_BALANCE_PRESET, CAMERASRC_WHITEBALANCE_AUTO}, /* White balance */ + {-1, CAMERASRC_COLORTONE_ANTIQUE, CAMERASRC_COLORTONE_NONE, V4L2_CID_COLORFX, CAMERASRC_COLORTONE_NONE}, /* Colortone */ + {-1, CAMERASRC_PROGRAM_MODE_BACK_LIGHT, CAMERASRC_PROGRAM_MODE_NORMAL, V4L2_CID_CAMERA_SCENE_MODE, CAMERASRC_PROGRAM_MODE_NORMAL}, /* program mode */ + {0, -1, -1, -1, -1}, /* Flip. V4L2_CID_VFLIP/HFLIP */ + {0, -1, -1, -1, -1}, /* PARTCOLOR_SRC */ + {0, -1, -1, -1, -1}, /* PARTCOLOR_DST */ + {0, -1, -1, -1, -1}, /* PARTCOLOR_MODE */ + {-1, 3, 0, V4L2_CID_CAM_STABILIZE, 0}, /* ANTI_HANDSHAKE */ + {-1, 2, 0, V4L2_CID_CAM_DR, 0}, /* WIDE_DYNAMIC_RANGE */ + {-1, 3, -3, V4L2_CID_SATURATION, 0}, /* SATURATION */ + {-1, 3, -3, V4L2_CID_SHARPNESS, 0}, /* SHARPNESS */ + {-1, -1, -1, V4L2_CID_CAMERA_ISO, -1}, /* ISO */ + {-1, -1, -1, V4L2_CID_CAMERA_METERING, -1}, /* PHOTOMETRY */ + }, + { /* Secondary camera */ + {0, -1, -1, V4L2_CID_CAMERA_BRIGHTNESS, -1}, /* Brightness */ + {0, -1, -1, V4L2_CID_CONTRAST, -1}, /* Contrast */ + {0, -1, -1, V4L2_CID_ZOOM_ABSOLUTE, -1}, /* Digital zoom */ + {0, -1, -1, -1, -1}, /* Optical zoom */ + {0, -1, -1, V4L2_CID_WHITE_BALANCE_PRESET, -1},/* White balance */ + {0, -1, -1, V4L2_CID_COLORFX, -1}, /* Colortone */ + {0, -1, -1, V4L2_CID_CAMERA_SCENE_MODE, -1}, /* program mode */ + {0, -1, -1, -1, -1}, /* Flip */ + {0, -1, -1, -1, -1}, /* PARTCOLOR_SRC */ + {0, -1, -1, -1, -1}, /* PARTCOLOR_DST */ + {0, -1, -1, -1, -1}, /* PARTCOLOR_MODE */ + {0, -1, -1, V4L2_CID_CAM_STABILIZE, -1}, /* ANTI_HANDSHAKE */ + {0, -1, -1, V4L2_CID_CAM_DR, -1}, /* WIDE_DYNAMIC_RANGE */ + {0, -1, -1, V4L2_CID_SATURATION, -1}, /* SATURATION */ + {0, -1, -1, V4L2_CID_SHARPNESS, -1}, /* SHARPNESS */ + {0, -1, -1, V4L2_CID_CAMERA_ISO, -1}, /* ISO */ + {0, -1, -1, V4L2_CID_CAMERA_METERING, -1}, /* PHOTOMETRY */ + }, +}; + +static char _camerasrc_misc_func_list[CAMERASRC_DEV_ID_EXTENSION][CAMERASRC_OP_REGISTER_VALUE][CAMERASRC_COL_NUM][CAMERASRC_MISC_FUNC_NUM] = +{ + {/*Primary*/ + /*Raw, JPG*/ + {{0x0,0x1}, {0x0,0x0}}, /*Preview*/ + {{0x0,0x1}, {0x0,0x0}}, /*Capture*/ + {{0x0,0x1}, {0x0,0x0}}, /*Video*/ + }, + {/*Secondary*/ + {{0x0,0x0}, {0x0,0x0}}, /*Preview*/ + {{0x0,0x0}, {0x0,0x0}}, /*Capture*/ + {{0x0,0x0}, {0x0,0x0}}, /*Video*/ + }/*{{Signal,Skip}, {Signal,Skip}}*/ +}; + +static int _camerasrc_af_support[CAMERASRC_DEV_ID_NUM] = {1, 0, 0, 0}; + +#ifdef __cplusplus +} +#endif + +#endif /*__CAMERASRC_INTERNAL_H__*/ diff --git a/camerasrc/src/include/camerasrc.h b/camerasrc/src/include/camerasrc.h new file mode 100644 index 0000000..2917f29 --- /dev/null +++ b/camerasrc/src/include/camerasrc.h @@ -0,0 +1,1488 @@ +/* + * camerasrc + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Jeongmo Yang <jm80.yang@samsung.com> + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __CAMERASRC_H__ +#define __CAMERASRC_H__ + +#include <stdint.h> /* to use uint64_t */ +#include <camerasrc-error.h> +#include <mm_ta.h> +#ifdef __cplusplus +extern "C" { +#endif + +/* GENERAL DEFINITIONS */ +/** + * Type definition of av camera src handle. + */ +typedef void *camsrc_handle_t; + + +/* ENUMERATION DEFINITIONS */ +/*! @enum camerasrc_state_t + * @brief Enumeration type for state transition + */ +typedef enum { + CAMERASRC_STATE_NONE = 0, + CAMERASRC_STATE_CREATED, + CAMERASRC_STATE_REALIZED, + CAMERASRC_STATE_READY, + CAMERASRC_STATE_PREVIEW, + CAMERASRC_STATE_STILL, + CAMERASRC_STATE_VIDEO, + CAMERASRC_STATE_UNREALIZED, + CAMERASRC_STATE_DESTROYED, + CAMERASRC_STATE_AF_IN_PROGRESS, +}camerasrc_state_t; + +/*! @enum camerasrc_dev_id_t + * @brief Enumeration type for camera device ID + * + * Devices will be managed by this IDs. (Independent with device index of V4L2) + */ +typedef enum { + CAMERASRC_DEV_ID_PRIMARY, /**< Higher resolution camera*/ + CAMERASRC_DEV_ID_SECONDARY, /**< Lower resolution camera*/ + CAMERASRC_DEV_ID_EXTENSION, /**< reserved for extension*/ + CAMERASRC_DEV_ID_UNKNOWN, /**< reserved for extension*/ + CAMERASRC_DEV_ID_NUM, /**< Number of IDs*/ +}camerasrc_dev_id_t; + +typedef enum { + CAMERASRC_COLOR_VIOLET = 0, + CAMERASRC_COLOR_PURPLE, + CAMERASRC_COLOR_MAGENTA_1, + CAMERASRC_COLOR_MAGENTA_2, + CAMERASRC_COLOR_RED_1, + CAMERASRC_COLOR_RED_2, + CAMERASRC_COLOR_BROWN, + CAMERASRC_COLOR_YELLOW, + CAMERASRC_COLOR_GREEN_1, + CAMERASRC_COLOR_GREEN_2, + CAMERASRC_COLOR_GREEN_3, + CAMERASRC_COLOR_GREEN_4, + CAMERASRC_COLOR_COBALT_BLUE, + CAMERASRC_COLOR_CYAN, + CAMERASRC_COLOR_BLUE_1, + CAMERASRC_COLOR_BLUE_2, + CAMERASRC_COLOR_GRAY, + CAMERASRC_COLOR_NUM, +}camerasrc_color_t; + +typedef enum { + CAMERASRC_PARTCOLOR_MODE_NONE = 0, + CAMERASRC_PARTCOLOR_MODE_SWAP, + CAMERASRC_PARTCOLOR_MODE_ACCENT, + CAMERASRC_PARTCOLOR_MODE_NUM, +}camerasrc_partcolor_mode_t; + +/*! @enum camerasrc_ctrl_t + * @brief Enumeration type for camera controls + * + * Special control entries for camera effects + * + * @remark Strobo can be controlled by this entry and ::camerasrc_set_strobo_status + */ +typedef enum { + CAMERASRC_CTRL_BRIGHTNESS = 0, /**< Brightness control entry*/ + CAMERASRC_CTRL_CONTRAST, /**< Contrast control entry*/ + CAMERASRC_CTRL_DIGITAL_ZOOM, /**< Digital zoom control entry*/ + CAMERASRC_CTRL_OPTICAL_ZOOM, /**< Optical zoom control entry*/ + CAMERASRC_CTRL_WHITE_BALANCE, /**< White balance control entry*/ + CAMERASRC_CTRL_COLOR_TONE, /**< Color tone control entry*/ + CAMERASRC_CTRL_PROGRAM_MODE, /**< Program mode control entry*/ + CAMERASRC_CTRL_FLIP, /**< Flip control entry*/ + CAMERASRC_CTRL_PARTCOLOR_SRC, /**< Partcolor effect source */ + CAMERASRC_CTRL_PARTCOLOR_DST, /**< Partcolor effect destination */ + CAMERASRC_CTRL_PARTCOLOR_MODE, /**< Partcolor effect mode */ + CAMERASRC_CTRL_ANTI_HANDSHAKE, /**< Anti-handshake control, 0:OFF / 1:ON / 2:AUTO / 3:MOVIE */ + CAMERASRC_CTRL_WIDE_DYNAMIC_RANGE, /**< wide dynamic control, 0:OFF / 1:ON / 2:AUTO */ + CAMERASRC_CTRL_SATURATION, /**< Saturation value control */ + CAMERASRC_CTRL_SHARPNESS, /**< Sharpness value control */ + CAMERASRC_CTRL_ISO, /**< Sensor sensitivity*/ + CAMERASRC_CTRL_PHOTOMETRY, /**< Exposure mode*/ + CAMERASRC_CTRL_NUM, /**< Number of Controls*/ +}camerasrc_ctrl_t; + +/*! @enum camerasrc_af_mode_t + * @brief AF operation mode + */ +typedef enum { + CAMERASRC_AF_MODE_AUTO = 0, /**< Auto Focus */ + CAMERASRC_AF_MODE_MANUAL, /**< Manual Focus */ + CAMERASRC_AF_MODE_PAN, /**< Pan Focus */ + CAMERASRC_AF_MODE_TOUCH_AUTO, /**< Touch Auto Focus */ + CAMERASRC_AF_MODE_CONTINUOUS, /**< Continuous Focus */ + CAMERASRC_AF_MODE_NUM, /**< Number of AF modes */ +}camerasrc_af_mode_t; + +/*! @enum camerasrc_af_scan_range_t + * @brief AF scan range + * AF scan range + */ +typedef enum { + CAMERASRC_AF_RANGE_NORMAL = 0, /**< Scan autofocus in normal range */ + CAMERASRC_AF_RANGE_MACRO, /**< Scan autofocus in macro range(close distance) */ + CAMERASRC_AF_RANGE_FULL, /**< Scan autofocus in full range(all range scan, limited by dev spec) */ + CAMERASRC_AF_RANGE_NUM, /**< Number of AF range types */ +}camerasrc_af_scan_range_t; + +/*! @enum camerasrc_resol_name_t + * @brief Enumeration type of resolution settings based on traditional resolution name + * Means pixel order of contents. + * @remark In the Grandprix, only YUV422P & RGGB8 is used + */ +typedef enum { + CAMERASRC_RESOL_QQCIF = 0, /**< 88 x 72 */ + CAMERASRC_RESOL_QQVGA, /**< 160 x 120 */ + CAMERASRC_RESOL_QCIF, /**< 176 x 144 */ + CAMERASRC_RESOL_QVGA, /**< 320 x 240 */ + CAMERASRC_RESOL_CIF, /**< 352 x 288 */ + CAMERASRC_RESOL_VGA, /**< 640 x 480 */ + CAMERASRC_RESOL_WVGA, /**< 800 x 480 */ + CAMERASRC_RESOL_SVGA, /**< 800 x 600 */ + CAMERASRC_RESOL_WSXGA, /**< 1280 x 960 (1M) */ + CAMERASRC_RESOL_UXGA, /**< 1600 x 1200 (2M) */ + CAMERASRC_RESOL_QXGA, /**< 2048 x 1536 (3M) */ + CAMERASRC_RESOL_WQSXGA, /**< 2560 x 1920 (5M) */ + CAMERASRC_RESOL_720P, /**< 1280 x 720 (720P) */ + CAMERASRC_RESOL_WQVGA, /**< 400 x 240 */ + CAMERASRC_RESOL_RQVGA, /**< 240 x 320 */ + CAMERASRC_RESOL_RWQVGA, /**< 240 x 400 */ + CAMERASRC_RESOL_QVGA_60FPS, /**< 320 x 240 60FPS(Slow motion I) */ + CAMERASRC_RESOL_QVGA_120FPS, /**< 320 x 240 60FPS(Slow motion II) */ + CAMERASRC_RESOL_NUM, +}camerasrc_resol_name_t; + +/*! @enum camerasrc_pix_format_t + * @brief Means order of pixel of contents + * Means pixel order of contents. + * @remark In the Grandprix, only YUV422P & RGGB8 is used + */ +typedef enum { + CAMERASRC_PIX_NONE = -1, /**< Default value or Not supported */ + CAMERASRC_PIX_YUV422P = 0, /**< Pixel format like YYYYYYYYUUUUVVVV*/ + CAMERASRC_PIX_YUV420P, /**< Pixel format like YYYYYYYYUUVV*/ + CAMERASRC_PIX_YUV420, /**< Pixel format like YYYYYYYYUVUV*/ + CAMERASRC_PIX_SN12, /**< YUV420 (interleaved, non-linear) */ + CAMERASRC_PIX_ST12, /**< YUV420 (interleaved, tiled, non-linear) */ + CAMERASRC_PIX_YUY2, /**< YUV 4:2:2 as for UYVY but with different component ordering within the u_int32 macropixel */ + CAMERASRC_PIX_RGGB8, /**< Raw RGB Pixel format like CCD order, a pixel consists of 8 bits, Actually means JPEG + JPEG image output */ + CAMERASRC_PIX_RGGB10, /**< Raw RGB Pixel format like CCD order, a pixel consists of 10 bits, Actually means JPEG + YUV image output */ + CAMERASRC_PIX_RGB565, /**< Raw RGB Pixel format like CCD order, a pixel consists of 10 bits, Actually means JPEG + YUV image output */ + CAMERASRC_PIX_UYVY, /**< YUV 4:2:2 */ + CAMERASRC_PIX_NV12, /**< YUV 4:2:0, 8-bit Y plane followed by an interleaved U/V plane with 2x2 subsampling */ + CAMERASRC_PIX_INTERLEAVED, /**< JPEG/YUYV interleaved data format for zero shutter lag */ + CAMERASRC_PIX_NUM, /**< Number of pixel formats*/ +}camerasrc_pix_format_t; + +/*! @enum camerasrc_colorspace_t + * @brief Means stored order or compressed status of image. + * Means stored order or compressed status of image. supplements of camerasrc_pix_format_t + * + * @note RAW means RGB/YUV pixel data, JPEG means compressed JPG file with marker information(header) + */ +typedef enum { + CAMERASRC_COL_NONE = -1, /**< Default value or Not supported */ + CAMERASRC_COL_RAW, /**< Non-compressed RGB/YUV pixel data*/ + CAMERASRC_COL_JPEG, /**< Compressed jpg data*/ + CAMERASRC_COL_NUM, /**< Number of colorspace data*/ +}camerasrc_colorspace_t; + +/*! @enum camerasrc_auto_focus_status_t + * @brief AF status + * AF status + */ +typedef enum { + CAMERASRC_AUTO_FOCUS_STATUS_RELEASED, /**< AF status released.*/ + CAMERASRC_AUTO_FOCUS_STATUS_ONGOING, /**< AF in progress*/ + CAMERASRC_AUTO_FOCUS_STATUS_NUM, /**< Number of AF status*/ +}camerasrc_auto_focus_status_t; + +/*! @enum camerasrc_auto_focus_cmd_t + * @brief AF status + * AF status + */ +typedef enum { + CAMERASRC_AUTO_FOCUS_CMD_NULL, /**< Null command.*/ + CAMERASRC_AUTO_FOCUS_CMD_START, /**< Start AF.*/ + CAMERASRC_AUTO_FOCUS_CMD_STOP, /**< Stop AF.*/ + CAMERASRC_AUTO_FOCUS_CMD_KILL, /**< Kill AF thread.*/ + CAMERASRC_AUTO_FOCUS_CMD_NUM, /**< Number of AF command*/ +}camerasrc_auto_focus_cmd_t; + +/*! @enum camerasrc_auto_focus_result_t + * @brief AF status + * AF status + */ +typedef enum { + CAMERASRC_AUTO_FOCUS_RESULT_FOCUSED = 2, /**< Focused.*/ + CAMERASRC_AUTO_FOCUS_RESULT_FAILED, /**< AF failed.*/ + CAMERASRC_AUTO_FOCUS_RESULT_NUM, /**< Number of AF result*/ +}camerasrc_auto_focus_result_t; + +/*! @enum camerasrc_ae_lock_t + * @brief + */ +typedef enum { + CAMERASRC_AE_LOCK = 0, + CAMERASRC_AE_UNLOCK, + CAMERASRC_AE_NUM, +}camerasrc_ae_lock_t; + +/*! @enum camerasrc_io_method_t + * @brief + */ +typedef enum { + CAMERASRC_IO_METHOD_READ= 0, + CAMERASRC_IO_METHOD_MMAP, + CAMERASRC_IO_METHOD_USRPTR, + CAMERASRC_IO_METHOD_NUM, +}camerasrc_io_method_t; + +/*! @enum camerasrc_buffer_queued_status + * @brief + */ +typedef enum { + CAMERASRC_BUFFER_QUEUED = 0, + CAMERASRC_BUFFER_DEQUEUED = 1, +}camerasrc_buffer_queued_status; + + +/* STRUCTURE DEFINITIONS */ + +typedef struct _camerasrc_rect_t { + int x; + int y; + int width; + int height; +} camerasrc_rect_t; + +/*! @struct camsrc_frac_t + * @brief Time per frame or frame per second will be expressed by this structure + * Time per frame or frame per second will be expressed by this structure + */ +typedef struct _camerasrc_frac_t { + int numerator; /**< Upper number of fraction*/ + int denominator; /**< Lower number of fraction*/ +} camerasrc_frac_t; + +/*! @struct camerasrc_buffer_t + * @brief data buffer + * Image data buffer + */ +typedef struct _camerasrc_buffer_t { + unsigned int length; /**< Size of stored data*/ + unsigned char* start; /**< Start address of data*/ + camerasrc_buffer_queued_status queued_status; /**< Queued or Dequeued status */ +} camerasrc_buffer_t; + +/*! @struct camerasrc_usr_buf_t + * @brief data buffer set to present usrptr buffer to camsrctem + * Image data buffer set + */ +typedef struct { + camerasrc_buffer_t* present_buffer; + unsigned int num_buffer; +} camerasrc_usr_buf_t; + +/*! @struct camerasrc_dimension_t + * @brief For non-regular size resolution + * width and height can be set independently + */ +typedef struct _camerasrc_dimension_t { + int width; + int height; +} camerasrc_dimension_t; + +/*! @union camerasrc_size_t + * @brief Size can be expressed by resolution name(predefined) and dimension(x, y) + */ +typedef union _camerasrc_size_t { + camerasrc_resol_name_t res; /**< Predefined resolution name */ + camerasrc_dimension_t dim; /**< Dimensional expression */ +} camerasrc_size_t; + +/*! @struct camerasrc_format_t + * @brief Format description structure + * in/output format description structure just like v4l2_format + */ +typedef struct _camerasrc_format_t { + camerasrc_size_t img_size; + camerasrc_size_t thumb_size; /**< Thumbnail size. Only effective with CAMERASRC_PIX_RGGB8 or CAMERASRC_PIX_RGGB10 */ + camerasrc_pix_format_t pix_format; /**< pixel order format*/ + int num_planes; /**< bytes per a line*/ + int bytesperline; /**< bytes per a line*/ + int sizeimage; /**< size of whole image*/ + camerasrc_colorspace_t colorspace; /**< stored status of image*/ + unsigned int quality; /**< jpeg compress ratio*/ + unsigned int is_highquality_mode; /**< picture quality is high or normal */ + int rotation; /**< Rotation angle of camera input */ +} camerasrc_format_t; + +typedef struct _camerasrc_ctrl_query_t { + int support; /**<1: support, 0: Not support, -1: extra support(Non v4l2)*/ + int max; /**<Integer max value(includes enums)*/ + int min; /**<Integer min value(includes enums)*/ +}camerasrc_ctrl_query_t; + +typedef struct _camerasrc_exif_t { + /* Dynamic value */ + unsigned int exposure_time_numerator; /**< Exposure time, given in seconds */ + unsigned int exposure_time_denominator; + int shutter_speed_numerator; /**< Shutter speed, given in APEX(Additive System Photographic Exposure) */ + int shutter_speed_denominator; + int brigtness_numerator; /**< Value of brightness, before firing flash, given in APEX value */ + int brightness_denominator; + unsigned short int iso; /**< Sensitivity value of sensor */ + unsigned short int flash; /**< Whether flash is fired(1) or not(0) */ + int metering_mode; /**< metering mode in EXIF 2.2 */ + int exif_image_width; /**< Size of image */ + int exif_image_height; + int exposure_bias_in_APEX; /**< Exposure bias in APEX standard */ + int software_used; /**< Firmware S/W version */ + int focal_len_numerator; /**< Lens focal length (f = 4.5mm) */ + int focal_len_denominator; + int aperture_f_num_numerator; /**< Aperture value (f_num = 2.8) */ + int aperture_f_num_denominator; + int aperture_in_APEX; /**< Aperture value in APEX standard */ + int max_lens_aperture_in_APEX; /**< Max aperture value in APEX standard */ + + /* Fixed value */ + int component_configuration; /**< color components arrangement (YCbCr = 1230) */ + int colorspace; /**< colorspace information (sRGB=1) */ +}camerasrc_exif_t; + +typedef struct _camerasrc_frame_data_t { + int index; + unsigned int phyAddrY; + unsigned int phyAddrCbCr; + unsigned int virAddrY; + unsigned int virAddrCbCr; +}camerasrc_frame_data_t; + +/* JPEG/YUV interleaved data */ +#define INTERLEAVED_JPEG_MAX_SIZE (1024*1024*6) /* 6 Mbyte */ + +/* Fixed focal length and aperture f-number */ +#define CAMERASRC_PRIMARY_FOCAL_LEGNTH_NUM 397 +#define CAMERASRC_PRIMARY_FOCAL_LEGNTH_DENOM 100 +#define CAMERASRC_PRIMARY_F_NUMBER_NUM 265 +#define CAMERASRC_PRIMARY_F_NUMBER_DENOM 100 +#define CAMERASRC_SECONDARY_FOCAL_LEGNTH_NUM 273 +#define CAMERASRC_SECONDARY_FOCAL_LEGNTH_DENOM 100 +#define CAMERASRC_SECONDARY_F_NUMBER_NUM 28 +#define CAMERASRC_SECONDARY_F_NUMBER_DENOM 10 + +/* For Query functionalities + For Querying capabilities */ +/*! Use static size of structures for querying because of performance + */ + +#define MAX_NUM_FMT_DESC 32 +#define MAX_NUM_RESOLUTION 32 +#define MAX_NUM_AVAILABLE_TPF 16 +#define MAX_NUM_AVAILABLE_FPS 16 +#define MAX_NUM_CTRL_LIST_INFO 64 +#define MAX_NUM_CTRL_MENU 64 +#define MAX_SZ_CTRL_NAME_STRING 32 +#define MAX_SZ_DEV_NAME_STRING 32 + +enum{ + CAMERASRC_FCC_USE_NONE = 0x00000001, + CAMERASRC_FCC_USE_REC_PREVIEW = 0x00000010, + CAMERASRC_FCC_USE_CAP_PREVIEW = 0x00000100, + CAMERASRC_FCC_USE_RECORDING = 0x00001000, + CAMERASRC_FCC_USE_NORMAL_CAPTURE = 0x00010000, + CAMERASRC_FCC_USE_CONT_CAPTURE = 0x00100000, + CAMERASRC_FCC_USE_NUM = 6, +}; + +/*! @struct camerasrc_tpf_frac_t + * @brief For timeperframe as fraction type + * Elapse time consumed by one frame, reverse of FPS + */ +typedef struct { + int num; + int den; +}camerasrc_tpf_frac_t; + +/*! @struct camerasrc_resolution_t + * @brief For querying supported resolutions + */ +typedef struct { + int w; + int h; + + /* Available time per frame(tpf) as each pixelformat */ + int num_avail_tpf; + camerasrc_tpf_frac_t tpf[MAX_NUM_AVAILABLE_TPF]; +} camerasrc_resolution_t; + +/*! @struct camerasrc_fmt_desc_t + * @brief For querying supported format type + */ +typedef struct { + /* fourcc name of each pixelformat */ + unsigned int fcc; + int fcc_use; + + /* Available resolutions as each pixelformat */ + int num_resolution; + camerasrc_resolution_t resolutions[MAX_NUM_RESOLUTION]; +} camerasrc_fmt_desc_t; + +/*! @struct camerasrc_caps_info_t + * @brief For querying image input capabilities + */ +typedef struct { + char dev_name[MAX_SZ_DEV_NAME_STRING]; + camerasrc_dev_id_t input_id; + int num_fmt_desc; + camerasrc_fmt_desc_t fmt_desc[MAX_NUM_FMT_DESC]; + + int num_preview_resolution; + int preview_resolution_width[MAX_NUM_RESOLUTION]; + int preview_resolution_height[MAX_NUM_RESOLUTION]; + + int num_capture_resolution; + int capture_resolution_width[MAX_NUM_RESOLUTION]; + int capture_resolution_height[MAX_NUM_RESOLUTION]; + + int num_preview_fmt; + unsigned int preview_fmt[MAX_NUM_FMT_DESC]; + + int num_capture_fmt; + unsigned int capture_fmt[MAX_NUM_FMT_DESC]; + + int num_fps; + camerasrc_frac_t fps[MAX_NUM_AVAILABLE_FPS]; +} camerasrc_caps_info_t; + +/* For Querying controls */ +enum { + CTRL_TYPE_RANGE = 0, /**< Integer, range type */ + CTRL_TYPE_BOOL, /**< Boolean type, 1 equals positive and 0 is negative */ + CTRL_TYPE_ARRAY, /**< Array type, also called menu type. each integer(enumeration) value can be set */ + CTRL_TYPE_UNKNOWN, /**< Unknown type, for error control */ + CTRL_TYPE_NUM, +}; + +/*! @struct camerasrc_ctrl_menu_t + * @brief For querying menu of specified controls + */ +typedef struct { + int menu_index; /**< What number is used for accessing this menu */ + char menu_name[MAX_SZ_CTRL_NAME_STRING]; /**< name of each menu */ +}camerasrc_ctrl_menu_t; + +/*! @struct camerasrc_ctrl_info_t + * @brief For querying controls detail + */ +typedef struct { + camerasrc_ctrl_t camsrc_ctrl_id; /**< camsrc camera control ID for controlling this */ + int v4l2_ctrl_id; /**< v4l2 ctrl id, user not need to use this. see @struct camerasrc_ctrl_t */ + int ctrl_type; /**< Type of this control */ + char ctrl_name[MAX_SZ_CTRL_NAME_STRING]; /**< Name of this control */ + int min; /**< minimum value */ + int max; /**< maximum value */ + int step; /**< unit of the values */ + int default_val; /**< Default value of the array or range */ + int num_ctrl_menu; /**< In the case of array type control, number of supported menu information */ + camerasrc_ctrl_menu_t ctrl_menu[MAX_NUM_CTRL_MENU]; /**< @struct camerasrc_ctrl_menu_t for detailed each menu information*/ +} camerasrc_ctrl_info_t; + +/*! @struct camerasrc_ctrl_list_info_t + * @brief For querying controls + */ +typedef struct { + int num_ctrl_list_info; /**< Number of supported controls */ + camerasrc_ctrl_info_t ctrl_info[MAX_NUM_CTRL_LIST_INFO]; /**< @struct camerasrc_ctrl_info_t for each control information */ +} camerasrc_ctrl_list_info_t; + + +/* capabilities field */ +#define CAMERASRC_STROBE_CAP_NONE 0x0000 /* No strobe supported */ +#define CAMERASRC_STROBE_CAP_OFF 0x0001 /* Always flash off mode */ +#define CAMERASRC_STROBE_CAP_ON 0x0002 /* Always use flash light mode */ +#define CAMERASRC_STROBE_CAP_AUTO 0x0004 /* Flashlight works automatic */ +#define CAMERASRC_STROBE_CAP_REDEYE 0x0008 /* Red-eye reduction */ +#define CAMERASRC_STROBE_CAP_SLOWSYNC 0x0010 /* Slow sync */ +#define CAMERASRC_STROBE_CAP_FRONT_CURTAIN 0x0020 /* Front curtain */ +#define CAMERASRC_STROBE_CAP_REAR_CURTAIN 0x0040 /* Rear curtain */ +#define CAMERASRC_STROBE_CAP_PERMANENT 0x0080 /* keep turned on until turning off */ +#define CAMERASRC_STROBE_CAP_EXTERNAL 0x0100 /* use external strobe */ + +typedef struct _camerasrc_extra_info_t{ + unsigned int strobe_caps; /**< Use above caps field */ + unsigned int detection_caps; /**< Just boolean */ + unsigned int reserved[4]; +} camerasrc_extra_info_t; +/* END For Query functionalities */ + +/*! @def CAMERASRC_SET_SIZE_BY_DIMENSION + * @brief Utility definitions for setting non-regular size + */ +#define CAMERASRC_SET_SIZE_BY_DIMENSION(format, img_width, img_height) { \ + format.img_size.dim.width = img_width; \ + format.img_size.dim.height = img_height; \ +} + + +/* CALLBACK DEFINITIONS */ +/*! @typedef camerasrc_callback_t + * @brief Called back when auto-focusing returns + * This callback will be called when the lens properly auto-focused + */ +typedef int (*camerasrc_callback_t) (camsrc_handle_t handle, int state, void* usr_data); + +/* Static variables */ +/** + * Label for camera control. This static variable has a label for each of camerasrc_ctrl_t enumeration. + * When enumeration of camerasrc_ctrl_t is increased, this variable should be increased, too. + * This string could be used as a key by user. + * Reference : camerasrc_ctrl_t, _camerasrc_ctrl_list + */ + +static char *camerasrc_ctrl_label[CAMERASRC_CTRL_NUM] = +{ + "brightness", /**< label for CAMERASRC_CTRL_BRIGHTNESS */ + "contrast", /**< label for CAMERASRC_CTRL_CONTRAST */ + "digital zoom", /**< label for CAMERASRC_CTRL_DIGITAL_ZOOM */ + "optical zoom", /**< label for CAMERASRC_CTRL_OPTICAL_ZOOM */ + "white balance", /**< label for CAMERASRC_CTRL_WHITE_BALANCE */ + "color tone", /**< label for CAMERASRC_CTRL_COLOR_TONE */ + "program mode", /**< label for CAMERASRC_CTRL_PROGRAM_MODE */ + "flip", /**< label for CAMERASRC_CTRL_FLIP */ + "partcolor src", /**< label for CAMERASRC_CTRL_PARTCOLOR_SRC */ + "partcolor dst", /**< label for CAMERASRC_CTRL_PARTCOLOR_DST */ + "partcolor mode", /**< label for CAMERASRC_CTRL_PARTCOLOR_MODE */ + "anti handshake", /**< label for CAMERASRC_CTRL_ANTI_HANDSHAKE */ + "wide dynamic range", /**< label for CAMERASRC_CTRL_WIDE_DYNAMIC_RANGE */ + "saturation", /**< label for CAMERASRC_CTRL_SATURATION */ + "sharpness", /**< label for CAMERASRC_CTRL_SHARPNESS */ + "iso", /**< label for CAMERASRC_CTRL_ISO */ + "photometry", /**< label for CAMERASRC_CTRL_PHOTOMETRY */ +}; + +/* FUNCTION DEFINITIONS */ + +/**** M A I N O P E R A T I O N ****/ + +/** + * allocate the handle, set initial state & settings + * + * @param[in] phandle ::camsrc_handle_t camerasrc context handle to be created + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t code + * @see camerasrc_destroy + * @note State transition : [CAMERASRC_STATE_NONE] => [CAMERASRC_STATE_CREATED] + * Phase description : Non-running phase + */ +int camerasrc_create(camsrc_handle_t *phandle); + +/** + * proceed fd close, other finalization routines + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t code + * + * @see <camerasrc_create> + * + * @note State transition : [CAMERASRC_STATE_UNREALIZED] => [CAMERASRC_STATE_DESTROYED] + * Phase description : Non-running phase + */ +int camerasrc_destroy(camsrc_handle_t handle); + +/** + * free device context handle, other finalization routines + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t code + * @see camerasrc_create + * @note State transition : [CAMERASRC_STATE_UNREALIZED] => [CAMERASRC_STATE_DESTROYED] + * Phase description : Non-running phase + */ +int camerasrc_close_device(camsrc_handle_t handle); + +/** + * Get the state of camerasrc context handle + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[out] state ::camerasrc_state_t camerasrc context current state + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t code + * + */ +int camerasrc_get_state(camsrc_handle_t handle, camerasrc_state_t* state); + +/** + * Allocate the device context handle, open device node and do the miscellaneous settings + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @return Success on ::camerasrc_handle_t or returns NULL code, and displays debug message + * @see camerasrc_unrealize + * @note State transition : [CAMERASRC_STATE_CREATED] => [CAMERASRC_STATE_REALIZED] + * Phase description : Non-running phase + * device name can be dependent on kernel module + */ +int camerasrc_realize(camsrc_handle_t handle); + +/** + * Deallocate the device structure of buffers, close device + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @return Success on ::camerasrc_handle_t or returns NULL code, and displays debug message + * @see camerasrc_realize + * @note State transition : [CAMERASRC_STATE_READY] => [CAMERASRC_STATE_UNREALIZED] + * Phase description : Transit to Non-running phase + */ +int camerasrc_unrealize(camsrc_handle_t handle); + +/** + * Prepare Handle to be ready to capture + * Can change settings like below at this state + * - camera device ID setting + * - color format setting + * - image size setting + * - image storing method + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @return Success on ::camerasrc_handle_t or returns NULL code, and displays debug message + * @see camerasrc_stop + * @note State transition : [CAMERASRC_STATE_REALIZED] => [CAMERASRC_STATE_READY] + * Phase description : Running phase + */ +int camerasrc_start(camsrc_handle_t handle); + +/** + * Present user buffer to camerasrc and force to use that buffer. + * After calling this API, all core routine of camerasrc camera will use + * User pointer method for managing buffers. + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[in] present_buf ::camerasrc_usr_buf_t Buffer set to present to camerasrc + * @param[in] io_method ::camerasrc_io_method_t Enum type represent to IO method + * @return Success on ::camsrc_handle_t or returns NULL code, and displays debug message + * @see camerasrc_io_method_t + * + */ +int camerasrc_present_usr_buffer(camsrc_handle_t handle, camerasrc_usr_buf_t* present_buf, camerasrc_io_method_t io_method); + +/** + * Get total number of buffer which managed in camerasrc currently. + * If this called, it will return default number of buffer in MMAP mode. + * but use this API after calling ::camerasrc_present_usr_buffer , It will + * return User specfied buffer number. + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[in] num_buffer Number of buffer that's managed in camerasrc currently + * @return Success on ::camsrc_handle_t or returns NULL code, and displays debug message + * @see camerasrc_io_method_t + * + */ +int camerasrc_get_num_buffer(camsrc_handle_t handle, unsigned int* num_buffer); + +/** + * Get Input/Output method which is used when access camera driver + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[in] io_method ::camerasrc_io_method_t method enum value + * @return Success on ::camsrc_handle_t or returns NULL code, and displays debug message + * @see camerasrc_io_method_t + * + */ +int camerasrc_get_io_method(camsrc_handle_t handle, camerasrc_io_method_t* io_method); + +/** + * Inner ring buffer start refreshing. refresh process occurs asynchronously, and + * ::camerasrc_wait_frame_available function can anounce when it is available. + * + * Camera is grabbing High quality, maybe low speed frame(dependent on device) + * - Cant approach the [AF] state + * - preview frames arent always automatically fed. If not, must request repeatedly + * - If device supports continuous focusing, it can be enabled at this state in case + * of multishot. + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note State transition : [CAMERASRC_STATE_READY] => [CAMERASRC_STATE_STILL] + * Phase description : Running phase + */ +int camerasrc_start_still_stream(camsrc_handle_t handle); + +/** + * Inner ring buffer start refreshing. refresh process occurs asynchronously, and + * ::camerasrc_wait_frame_available function can anounce when it is available. + * + * Camera is grabbing low quality, high speed frame + * - Can attempt the [AF] state only at this state + * - preview frames are always automatically fed + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note State transition : [CAMERASRC_STATE_READY] => [CAMERASRC_STATE_PREVIEW] + * Phase description : Running phase + */ +int camerasrc_start_preview_stream(camsrc_handle_t handle); + +/** + * Stop frame refreshing. Ring buffers don't be refreshed any more + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @return Success on ::camerasrc_handle_t or returns NULL code, and displays debug message + * @see camerasrc_stop + * @note State transition : [CAMERASRC_STATE_STILL/PREVIEW/VIDEO] => [CAMERASRC_STATE_READY] + * Phase description : Running phase + */ +int camerasrc_stop_stream(camsrc_handle_t handle); + +/** + * Query image buffer size. buffer allocation guide function. + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[out] main_img_size main image maximum size + * @param[out] thm_img_size thumb nail image maximum size + * @return Success on ::camsrc_handle_t or returns NULL code, and displays debug message + * + */ +int camerasrc_query_img_buf_size(camsrc_handle_t handle, unsigned int* main_img_size, unsigned int* thm_img_size); + +/** + * non-busy waiting function for image frame available + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[in] timeout main image maximum size + * @return Success on ::camsrc_handle_t or returns NULL code, and displays debug message + * + */ +int camerasrc_wait_frame_available(camsrc_handle_t handle, long int timeout); + +/** + * Check emp shock status + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[out] check_val + * @return Success on ::camsrc_handle_t or returns NULL code, and displays debug message + * + */ +int camerasrc_check_esd_shock(camsrc_handle_t *handle, int *check_val); + +/** + * Queue(in user space, almost same with free buffer) buffer to dev's ring buffer + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @param[in] buffer ::camerasrc_buffer_t buffer + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * + */ +int camerasrc_queue_buffer(camsrc_handle_t handle, int buf_index, camerasrc_buffer_t *buffer); + +/** + * Dequeue(Pop) buffer from v4l2 driver to usr space. + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[out] buf_index main buffer index number to be dequeued. + * @param[out] buffer main image buffer + * @param[out] thm_buffer thumbnail image buffer + * @return Success on ::camsrc_handle_t or returns NULL code, and displays debug message + * + */ +int camerasrc_dequeue_buffer(camsrc_handle_t handle, int *buf_index, camerasrc_buffer_t *buffer, camerasrc_buffer_t *thm_buffer); + +/** + * Read frame from camera device. + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[out] buffer ::camerasrc_buffer_t main image buffer to be get. + * @param[out] thm_buffer ::camerasrc_buffer_t thumbnail image buffer to be get. + * @param[out] buffer_index ::int v4l2 buffer index. + * @note if thm_buffer is NULL, thumbnail image will be discarded + * + */ +int camerasrc_read_frame(camsrc_handle_t handle, camerasrc_buffer_t *main_img_buffer, camerasrc_buffer_t *thm_img_buffer, int *buffer_index); + +/** + * Get screennail buffer + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[out] scrnl_buf ::camerasrc_buffer_t screennail buffer to be gotten + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + */ +int camerasrc_get_screennail_buffer(camsrc_handle_t handle, camerasrc_buffer_t *scrnl_buf); + +/** + * Set autofocus callback. ::camerasrc_callback_t type defined function can be set + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @param[in] cb ::camerasrc_callback_t callback after focusing over + * @param[in] use_data ::void * user data pointer that will be passed to callback + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note Callback function can be set on READY or REALIZED state + * + */ +int camerasrc_set_focused_callback(camsrc_handle_t handle, camerasrc_callback_t cb, void *usr_data); + +/** + * Set autofocusing area. autofocusing will be performed refer this rect of the preview + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[in] rect ::camerasrc_rect_t rectangle area for auto focusing + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + */ +int camerasrc_set_autofocusing_area(camsrc_handle_t handle, camerasrc_rect_t* rect); + +/** + * Get autofocusing area. + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[out] rect ::camerasrc_rect_t rectangle area for auto focusing + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + */ +int camerasrc_get_autofocusing_area(camsrc_handle_t handle, camerasrc_rect_t* rect); + +/** + * Start auto focusing with ::camerasrc_af_mode. After ::interval time, call the callback + * function with ::camerasrc_af_status value. + * Auto-focus is in progress. Cant return preview state + * before time-out, success, call camerasrc_autofocus_stop + * - If focused, focus status will be locked at preview state + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @param[in] af_mode Auto focusing operation mode see ::camerasrc_af_mode + * @param[in] interval interval time in millisecond + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note State transition : [CAMERASRC_STATE_PREVIEW] => [CAMERASRC_STATE_AF_IN_PROGRESS] + * Phase description : Running phase + */ +int camerasrc_start_autofocusing(camsrc_handle_t handle); + +/** + * Stop auto focusing + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note State transition : [CAMERASRC_STATE_AF_IN_PROGRESS] => [CAMERASRC_STATE_PREVIEW] + * Phase description : Running phase + */ +int camerasrc_stop_autofocusing(camsrc_handle_t handle); + +/** + * Release auto focusing + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note State transition : [CAMERASRC_STATE_AF_IN_PROGRESS] => [CAMERASRC_STATE_PREVIEW] + * Phase description : Running phase + */ +int camerasrc_release_autofocusing(camsrc_handle_t handle); + +/** + * Initialize auto focusing mode to specified focal length + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[in] af_mode ::camerasrc_af_mode_t Auto focusing mode + * @param[in] af_range ::camerasrc_af_scan_range_t Auto focusing range + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + */ +int camerasrc_init_autofocusing_mode(camsrc_handle_t handle, camerasrc_af_mode_t af_mode, camerasrc_af_scan_range_t af_range); + +/** + * Get current auto focusing mode + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[out] af_mode ::camerasrc_af_mode_t Auto focusing mode + * @param[out] af_range ::camerasrc_af_scan_range_t Auto focusing range + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + */ +int camerasrc_get_autofocusing_mode(camsrc_handle_t handle, camerasrc_af_mode_t* af_mode, camerasrc_af_scan_range_t* af_range); + +/** + * Get current auto focusing status + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[out] af_status ::camerasrc_auto_focus_status_t Auto focusing status + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * + */ +int camerasrc_get_autofocusing_status(camsrc_handle_t handle, camerasrc_auto_focus_status_t* af_status); +/**** M I S C E L L A N E O U S O P E R A T I O N ****/ + +/**** I N P U T ( C A M D E V I C E ) O P E R A T I O N ****/ + +/** + * Get input camera ID just like ioctl (fd, VIDIOC_G_INPUT, &index) + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @param[out] id Camera ID currently set + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note This function is only effective at CAMERASRC_PHASE_RUNNING + */ +int camerasrc_get_input(camsrc_handle_t handle, camerasrc_dev_id_t* camera_id); + +/** + * Set input camera ID just like ioctl (fd, VIDIOC_S_INPUT, &index) + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @param[out] camera_id Camera ID currently set + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note This function is only effective at CAMERASRC_STATE_READY + * If you use set_input(), handle will be initiated. + */ +int camerasrc_set_input(camsrc_handle_t handle, camerasrc_dev_id_t camera_id); + + +/**** E F F E C T C O N T R O L O P E R A T I O N ****/ + +/** + * Check support controls with ::camerasrc_ctrl_t ID + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[in] ctrl_id control ID to be checked + * @param[out] ctrl_info control information to be got + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + */ +int camerasrc_query_control(camsrc_handle_t handle, camerasrc_ctrl_t ctrl_id, camerasrc_ctrl_info_t* ctrl_info); + +/** + * Check support controls with ::camerasrc_ctrl_t ID + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[in] ctrl_id control ID to be checked + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + */ +int camerasrc_support_control(camsrc_handle_t handle, camerasrc_ctrl_t ctrl_id); + +/** + * Start facedetection + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note State transition : [CAMERASRC_STATE_AF_IN_PROGRESS] => [CAMERASRC_STATE_PREVIEW] + * Phase description : Running phase + */ +int camerasrc_start_facedetection(camsrc_handle_t handle); + +/** + * Stop face detection + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note State transition : [CAMERASRC_STATE_AF_IN_PROGRESS] => [CAMERASRC_STATE_PREVIEW] + * Phase description : Running phase + */ +int camerasrc_stop_facedetection(camsrc_handle_t handle); + +/** + * Get face detection status + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[out] is_detecting whether it is detecting or not + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note State transition : [CAMERASRC_STATE_AF_IN_PROGRESS] => [CAMERASRC_STATE_PREVIEW] + * Phase description : Running phase + */ +int camerasrc_get_facedetection(camsrc_handle_t handle, int* is_detecting); + +/** + * Control miscellaneous settings through ::camerasrc_ctrl_t IDs + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[in] ctrl_id control ID to be checked + * @param[in] value value to be set + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note This function is only effective at CAMERASRC_STATE_READY + */ +int camerasrc_set_control(camsrc_handle_t handle, camerasrc_ctrl_t ctrl_id, int value); + +/** + * Get the value of miscellaneous settings through ::camerasrc_ctrl_t IDs + * + * @param[in] handle ::camsrc_handle_t camerasrc context handle + * @param[in] ctrl_id control ID to be checked + * @param[out] value value to be stored + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note This function is only effective at CAMERASRC_STATE_READY + */ +int camerasrc_get_control(camsrc_handle_t handle, camerasrc_ctrl_t ctrl_id, int* value); + +/**** O U T P U T C O N T R O L O P E R A T I O N ****/ + +/** + * Control frame refresh rate setting + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @param[in] frac ::camsrc_frac_t time per frame + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note This function is only effective at CAMERASRC_STATE_READY + */ +int camerasrc_set_timeperframe(camsrc_handle_t handle, camerasrc_frac_t* frac); + +/** + * Set output format of camera device just like ioctl VIDIOC_S_FMT + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @param[in] fmt ::camerasrc_format_t output format description to be set + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note This function is only effective at CAMERASRC_STATE_READY. + * device dependent function. + */ +int camerasrc_set_format(camsrc_handle_t handle, camerasrc_format_t* fmt); + +/** + * Get output format of camera device just like ioctl VIDIOC_G_FMT + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @param[in] fmt ::camerasrc_format_t output format description to be set + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note This function is only effective at CAMERASRC_PHASE_RUNNING + */ +int camerasrc_get_format(camsrc_handle_t handle, camerasrc_format_t* fmt); + +/** + * Try output format of camera device just like ioctl VIDIOC_TRY_FMT + * In this function, it doesn't change any format, only just try. just test + * the combinations of format setting + * + * @param[in] handle ::camerasrc_handle_t camerasrc context handle + * @param[in] fmt ::camerasrc_format_t output format description to be set + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + * @note This function is only effective at CAMERASRC_STATE_READY. + * device dependent function. + */ +int camerasrc_try_format(camsrc_handle_t handle, camerasrc_format_t* fmt); + +/** + * Get virtual/physical address of data frame + * + * @param[in] handle ::camsrc_handle_t handle + * @param[in] ae_lock ::camerasrc_ae_lock_t Auto exposure lock/unlock + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_get_frame_data(camsrc_handle_t handle, camerasrc_frame_data_t * data); + +/**** S H U T T E R S P E E D & A P E R T U R E M O D U L A T I O N ****/ +/** + * Get exif string to be combined with jpg image from camerasrc + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] exif_string exif information string + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_get_exif_info(camsrc_handle_t handle, camerasrc_exif_t* exif_struct); + +/** + * Check whether camera device is opened + * + * @param[in] handle ::camsrc_handle_t handle + * @return 0 when camera is not opened else return non-zero value. + */ + int camerasrc_device_is_open(camsrc_handle_t handle); + +/** + * Set the camera device file decriptor + + * @param[in] handle ::camsrc_handle_t handle + * @param[in] videofd ::file descriptor of camera device + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + */ +int camerasrc_set_videofd(camsrc_handle_t handle,int videofd); + +/** + * Set AF behaviour after capturing + + * @param[in] handle ::camsrc_handle_t handle + * @param[in] hold_af ::whether holding af after capturing + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + */ +int camerasrc_set_af_hold_after_capture(camsrc_handle_t handle, int hold_af); + +/** + * Set Sensor mode to camera driver + + * @param[in] handle ::camsrc_handle_t handle + * @param[in] sensor_mode ::int mode + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + */ +int camerasrc_set_sensor_mode(camsrc_handle_t handle, int mode); + +/** + * Set vflip to camera driver + + * @param[in] handle ::camsrc_handle_t handle + * @param[in] vflip ::int vflip + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + */ +int camerasrc_set_vflip(camsrc_handle_t handle, int vflip); + +/** + * Set hflip to camera driver + + * @param[in] handle ::camsrc_handle_t handle + * @param[in] hflip ::int hflip + * @return Success on CAMERASRC_ERR_NONE or returns with ::camerasrc_error_t error code + */ +int camerasrc_set_hflip(camsrc_handle_t handle, int hflip); + +/* W I L L B E D E P R E C A T E D */ + +/*! @enum camerasrc_colortone_t + * @brief Enumeration type for camera colortone + * + * Colortone entries for camera effects. This can be used with CAMERASRC_CTRL_COLOR_TONE + * This values are defined for utility. It's dependent on the device/camera module. + */ +typedef enum { + CAMERASRC_COLORTONE_NONE = 0, + CAMERASRC_COLORTONE_NEGATIVE, + CAMERASRC_COLORTONE_SOLARIZATION_1, + CAMERASRC_COLORTONE_SOLARIZATION_2, + CAMERASRC_COLORTONE_SOLARIZATION_3, + CAMERASRC_COLORTONE_SOLARIZATION_4, + CAMERASRC_COLORTONE_EMBOSS, + CAMERASRC_COLORTONE_OUTLINE, + CAMERASRC_COLORTONE_AQUA, + CAMERASRC_COLORTONE_SEPHIA, + CAMERASRC_COLORTONE_GRAY, + CAMERASRC_COLORTONE_B_N_W, + CAMERASRC_COLORTONE_RED, + CAMERASRC_COLORTONE_GREEN, + CAMERASRC_COLORTONE_BLUE, + CAMERASRC_COLORTONE_ANTIQUE, + CAMERASRC_COLORTONE_SKETCH1, + CAMERASRC_COLORTONE_SKETCH2, + CAMERASRC_COLORTONE_SKETCH3, + CAMERASRC_COLORTONE_SKETCH4, + CAMERASRC_COLORTONE_NUM, +}camerasrc_colortone_t; + +/*! @enum camerasrc_program_mode_t + * @brief Enumeration type for preset program mode + * + * WRITEME + */ +typedef enum { + CAMERASRC_PROGRAM_MODE_NORMAL = 0, + CAMERASRC_PROGRAM_MODE_PORTRAIT, + CAMERASRC_PROGRAM_MODE_LANDSCAPE, + CAMERASRC_PROGRAM_MODE_SPORTS, + CAMERASRC_PROGRAM_MODE_PARTY_N_INDOOR, + CAMERASRC_PROGRAM_MODE_BEACH_N_INDOOR, + CAMERASRC_PROGRAM_MODE_SUNSET, + CAMERASRC_PROGRAM_MODE_DUSK_N_DAWN, + CAMERASRC_PROGRAM_MODE_FALL_COLOR, + CAMERASRC_PROGRAM_MODE_NIGHT_SCENE, + CAMERASRC_PROGRAM_MODE_FIREWORK, + CAMERASRC_PROGRAM_MODE_TEXT, + CAMERASRC_PROGRAM_MODE_SHOW_WINDOW, + CAMERASRC_PROGRAM_MODE_CANDLE_LIGHT, + CAMERASRC_PROGRAM_MODE_BACK_LIGHT, + CAMERASRC_PROGRAM_MODE_NUM, +}camerasrc_program_mode_t; + +/*! @enum camerasrc_whitebalance_t + * @brief Enumeration type for preset whitebalance + * + * WRITEME + */ +typedef enum { + CAMERASRC_WHITEBALANCE_AUTO = 0, + CAMERASRC_WHITEBALANCE_INCANDESCENT, + CAMERASRC_WHITEBALANCE_FLUORESCENT, + CAMERASRC_WHITEBALANCE_DAYLIGHT, + CAMERASRC_WHITEBALANCE_CLOUDY, + CAMERASRC_WHITEBALANCE_SHADE, + CAMERASRC_WHITEBALANCE_HORIZON, + CAMERASRC_WHITEBALANCE_FLASH, + CAMERASRC_WHITEBALANCE_CUSTOM, + CAMERASRC_WHITEBALANCE_NUM, +}camerasrc_whitebalance_t; + +/** + * Enumerations for flip. + */ +typedef enum { + CAMERASRC_FILP_NONE = 0, /**< Not flipped */ + CAMERASRC_FILP_VERTICAL, /**< Flip vertically */ + CAMERASRC_FILP_HORIZONTAL, /**< Flip horizontally */ + CAMERASRC_FILP_NUM, /**< Number of flip status */ +}camerasrc_flip_t; + +/*! @enum camerasrc_strobo_status_t + * @brief strobo status + * strobo status + */ +typedef enum { + CAMERASRC_STROBO_STATUS_BANNED = 0, /**< strobo off*/ + CAMERASRC_STROBO_STATUS_FORCE_ON, /**< strobo on.*/ + CAMERASRC_STROBO_STATUS_AUTO, /**< control strobo automatically*/ + CAMERASRC_STROBO_STATUS_MOVIE_ON, /**< control strobo automatically*/ + CAMERASRC_STROBO_STATUS_NUM, /**< Number of AF status*/ +}camerasrc_strobo_status_t; +/*! @enum camerasrc_strobe_mode_t + * @brief strobe mode + * strobe mode + */ +typedef enum { + CAMERASRC_STROBE_MODE_OFF = 1, /**< off */ + CAMERASRC_STROBE_MODE_AUTO, /**< auto */ + CAMERASRC_STROBE_MODE_ON, /**< on */ + CAMERASRC_STROBE_MODE_PERMANENT, /**< permanent */ + CAMERASRC_STROBE_MODE_NUM, /**< Number of strobe mode */ +}camerasrc_strobe_mode_t; + +/*! @enum camerasrc_ae_mode_t + * @brief Auto exposure mode + * Auto exposure operation mode + */ +typedef enum { + CAMERASRC_AE_MODE_OFF = 0, + CAMERASRC_AE_MODE_ALL, + CAMERASRC_AE_MODE_CENTER_WEIGHTED_AVR_1, + CAMERASRC_AE_MODE_CENTER_WEIGHTED_AVR_2, + CAMERASRC_AE_MODE_CENTER_WEIGHTED_AVR_3, + CAMERASRC_AE_MODE_SPOT_1, + CAMERASRC_AE_MODE_SPOT_2, + CAMERASRC_AE_MODE_CUSTOM_1, + CAMERASRC_AE_MODE_CUSTOM_2, +} camerasrc_ae_mode_t; + +/*! @enum camerasrc_iso_t + * @brief Reserved iso number in definition + * Traditionally predefined ISO values + */ +typedef enum { + CAMERASRC_ISO_AUTO = 0, + CAMERASRC_ISO_50, + CAMERASRC_ISO_100, + CAMERASRC_ISO_200, + CAMERASRC_ISO_400, + CAMERASRC_ISO_800, + CAMERASRC_ISO_1600, + CAMERASRC_ISO_3200, +} camerasrc_iso_t; + +/*! @enum camerasrc_sensor_mode_t + * @brief Sensor mode in driver + * Sensor mode + */ +typedef enum { + CAMERASRC_SENSOR_MODE_CAMERA = 0, + CAMERASRC_SENSOR_MODE_MOVIE, +} camerasrc_sensor_mode_t; + +/*! @def CAMERASRC_SET_SIZE_BY_PRESET_RESOLUTION + * @brief Utility definitions for setting regular size with ::camerasrc_resol_name_t + */ +#define CAMERASRC_SET_SIZE_BY_PRESET_RESOLUTION(format, resolution) { \ + memset(&(format.img_size), 0, sizeof(camerasrc_size_t)); \ + format.img_size.res = resolution; \ +} + +/** + * Set the mode of strobe + * + * @param[in] handle ::camsrc_handle_t handle + * @param[in] mode ::camerasrc_strobe_mode_t mode of strobe + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_set_strobe_mode(camsrc_handle_t handle, camerasrc_strobe_mode_t mode); + +/** + * Get the mode of strobe + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] mode ::camerasrc_strobe_mode_t mode of strobe + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_get_strobe_mode(camsrc_handle_t handle, camerasrc_strobe_mode_t* mode); + +/** + * Set the mode of auto-exposure processing + * + * @param[in] handle ::camsrc_handle_t handle + * @param[in] ae_mode ::camerasrc_ae_mode_t AE mode to be set + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_set_exposure_mode(camsrc_handle_t handle, camerasrc_ae_mode_t ae_mode); + +/** + * Get the mode of auto-exposure processing + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] ae_mode ::camerasrc_ae_mode_t AE mode to be got + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_get_exposure_mode(camsrc_handle_t handle, camerasrc_ae_mode_t* ae_mode); + +/** + * Set the shutter speed + * + * @param[in] handle ::camsrc_handle_t handle + * @param[in] frac ::camerasrc_frac_t shutter speed to be set + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_set_shutter_speed(camsrc_handle_t handle, camerasrc_frac_t frac); + +/** + * Get the shutter speed + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] frac ::camerasrc_frac_t shutter speed to be got + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_get_shutter_speed(camsrc_handle_t handle, camerasrc_frac_t* frac); + +/** + * Set the exposure value + * + * @param[in] handle ::camsrc_handle_t handle + * @param[in] frac ::camerasrc_frac_t exposure value to be set + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_set_exposure_value(camsrc_handle_t handle, camerasrc_frac_t frac); + +/** + * Get the exposure value + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] frac ::camerasrc_frac_t exposure value to be got + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_get_exposure_value(camsrc_handle_t handle, camerasrc_frac_t* frac); + +/** + * Check whether supports exif embed in jpg or not + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] support_exif ::if supports, returns 1 or 0 + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_support_embed_exif(camsrc_handle_t handle, int* support_exif); + +/** + * Check whether supports jpeg encoding inside camera driver + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] support_jpeg_encoding ::if supports, returns 1. If not, return 0 + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_support_jpeg_encoding(camsrc_handle_t handle, int* support_jpeg_encoding); + + + +/* For Query functionalities */ +/** + * Query basic device info of device + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] camerasrc_caps_info_t device information structure + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_read_basic_dev_info(camerasrc_dev_id_t dev_id, camerasrc_caps_info_t* caps_info); + +/** + * Query miscellaneous device info(effect, WB, preset values, etc.) of device + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] camerasrc_ctrl_list_info_t device capabilities structure + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_read_misc_dev_info(camerasrc_dev_id_t dev_id, camerasrc_ctrl_list_info_t* ctrl_info); + +/** + * Query extra device info(face detection, strobe, etc.) of device + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] camerasrc_extra_info_t device capabilities structure + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_read_extra_dev_info(camerasrc_dev_id_t dev_id, camerasrc_extra_info_t* extra_info); + +/** + * Record miscellaneous device info(effect, WB, preset values, etc.) of device + * + * @param[in] handle ::camsrc_handle_t handle + * @param[in] camerasrc_ctrl_list_info_t device capabilities structure + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_write_basic_dev_info(camsrc_handle_t handle, camerasrc_caps_info_t* caps_info); + +/** + * Record miscellaneous device info(effect, WB, preset values, etc.) of device + * + * @param[in] handle ::camsrc_handle_t handle + * @param[in] camerasrc_ctrl_list_info_t device capabilities structure + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_write_misc_dev_info(camsrc_handle_t handle, camerasrc_ctrl_list_info_t* ctrl_info); + +/** + * Record extra device info(face detection, strobe, etc.) of device + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] camerasrc_extra_info_t device capabilities structure + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_write_extra_dev_info(camsrc_handle_t handle, camerasrc_extra_info_t* extra_info); + +/** + * Query to device driver about basic device info + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] camerasrc_ctrl_list_info_t device capabilities structure + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_query_basic_dev_info(camsrc_handle_t handle, camerasrc_caps_info_t* caps_info); + +/** + * Query to device driver about miscellaneous device info(effect, WB, preset values, etc.) of device + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] camerasrc_ctrl_list_info_t device capabilities structure + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_query_misc_dev_info(camsrc_handle_t handle, camerasrc_ctrl_list_info_t* ctrl_list_info); +int camerasrc_query_misc_dev_ctrl_info(camsrc_handle_t handle, camerasrc_ctrl_t ctrl_id, camerasrc_ctrl_info_t* ctrl_info); + +/** + * Query to device driver about extra device info(face detection, strobe, etc.) of device + * + * @param[in] handle ::camsrc_handle_t handle + * @param[out] camerasrc_extra_info_t device capabilities structure + * @return Success(Support) on CAMERASRC_ERR_NONE or returns with ::camerasrc_error error code + */ +int camerasrc_query_extra_dev_info(camsrc_handle_t handle, camerasrc_extra_info_t* extra_info); + +/** + * Dump functions for debugging + */ +int camerasrc_dump_basic_dev_info(camsrc_handle_t handle, camerasrc_caps_info_t* caps_info); +int camerasrc_dump_misc_dev_info(camsrc_handle_t handle, camerasrc_ctrl_list_info_t* ctrl_list_info); +int camerasrc_dump_extra_dev_info(camsrc_handle_t handle, camerasrc_extra_info_t* extra_info); +/* END For Query functionalities */ + +#ifdef __cplusplus +} +#endif + +#endif /*__CAMERASRC_H__*/ diff --git a/camerasrc/src/include/gstcamerasrc.h b/camerasrc/src/include/gstcamerasrc.h new file mode 100644 index 0000000..61b3c28 --- /dev/null +++ b/camerasrc/src/include/gstcamerasrc.h @@ -0,0 +1,175 @@ +/* + * camerasrc + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Jeongmo Yang <jm80.yang@samsung.com> + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __GSTCAMERASRC_H__ +#define __GSTCAMERASRC_H__ + +#include <gst/gst.h> +#include <gst/base/gstpushsrc.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <gst/interfaces/colorbalance.h> +#include <gst/interfaces/cameracontrol.h> + +#include "camerasrc.h" + +#ifndef _SPEED_UP_RAW_CAPTURE +/* Disabled now +#define _SPEED_UP_RAW_CAPTURE +*/ +#endif /* _SPEED_UP_RAW_CAPTURE */ + +G_BEGIN_DECLS +#define GST_TYPE_CAMERA_SRC (gst_camerasrc_get_type()) +#define GST_CAMERA_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CAMERA_SRC,GstCameraSrc)) +#define GST_CAMERA_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CAMERA_SRC,GstCameraSrcClass)) +#define GST_IS_CAMERA_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CAMERA_SRC)) +#define GST_IS_CAMERA_SRC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CAMERA_SRC)) + + +/** + * Quality. + */ +typedef enum { + GST_CAMERASRC_QUALITY_LOW, /**< Low quality */ + GST_CAMERASRC_QUALITY_HIGH, /**< High quality */ +} GstCameraSrcQuality; + +#define MAX_USR_BUFFER_NUM 12 + +typedef struct _GstCameraSrc GstCameraSrc; +typedef struct _GstCameraSrcClass GstCameraSrcClass; +typedef struct _GstCameraBuffer GstCameraBuffer; + +/* global info */ +struct _GstCameraBuffer { + GstBuffer buffer; + int v4l2_buffer_index; + GstCameraSrc *camerasrc; + gboolean is_alloc_data; +}; + +struct _GstCameraSrc +{ + GstPushSrc element; + + /*private*/ + void *v4l2_handle; /**< video4linux2 handle */ + int mode; + int sensor_mode; /**< sensor mode - camera or movie(camcorder) */ + gboolean vflip; /**< flip camera input vertically */ + gboolean hflip; /**< flip camera input horizontally */ + gboolean firsttime; + + int main_buf_sz; + int cap_count_current; /**< current capture count */ + int cap_count_reverse; /**< current capture count (reverse counting) */ + unsigned long cap_next_time; /**< next shot time for capture */ + GQueue *command_list; /**< Command list(Start capture, Stop capture) queue */ + + GCond *cond; + GMutex *mutex; + + /*camera property*/ + int width; /**< Width */ + int height; /**< Height */ + int fps; /**< Video source fps */ + + guint32 fourcc; /**< Four CC */ + int pix_format; /**< Image format of video source */ + int colorspace; /**< Colorspace of video source */ + int high_speed_fps; /**< Video source fps for high speed recording */ + gboolean fps_auto; /**< Auto Video source fps */ + + gboolean req_negotiation; /**< Video source fps for high speed recording */ + int camera_id; + int rotate; /**< Video source rotate */ + gboolean use_rotate_caps; /**< Use or not rotate value in caps */ + int external_videofd; /**< video FD from external module */ + + GCond *buffer_cond; + GMutex *buffer_lock; + gboolean buffer_running; /* with lock */ + gint num_live_buffers; /* with lock */ + guint buffer_count; + gboolean bfirst; /* temp */ +#ifdef _SPEED_UP_RAW_CAPTURE + gboolean cap_stream_diff; /* whether preview and capture streams are different each other */ +#endif + GQueue *pad_alloc_list; + GMutex *pad_alloc_mutex; + gint current_buffer_data_index; + gboolean first_invokation; + + GstBuffer *usr_buffer[MAX_USR_BUFFER_NUM]; + gboolean use_pad_alloc; + guint num_alloc_buf; + + /* Colorbalance , CameraControl interface */ + GList *colors; + GList *camera_controls; + + + /*capture property*/ + guint32 cap_fourcc; /**< gstreamer fourcc value(GST_MAKE_FOURCC format) for raw capturing */ + GstCameraSrcQuality cap_quality; /**< Capture quality */ + int cap_width; /**< Capture width */ + int cap_height; /**< Capture height */ + int cap_interval; /**< Capture interval */ + int cap_count; /**< Capture count */ + int cap_jpg_quality; /**< Capture quality for jpg compress ratio */ + gboolean cap_provide_exif; /**< Is exif provided? */ + + /*etc property*/ + gboolean signal_still_capture; /**< enable still capture signal */ + gboolean hold_af_after_capturing; /**< Whether to hold af after capturing */ + gboolean create_jpeg; + GMutex *jpg_mutex; +}; + +struct _GstCameraSrcClass { + GstPushSrcClass parent_class; + /* signals */ + void (*still_capture) (GstElement *element, GstBuffer *main, GstBuffer *sub, GstBuffer *scrnl); + void (*nego_complete) (GstElement *element); + void (*register_trouble) (GstElement *element); +}; + +typedef enum { + INTERFACE_NONE, + INTERFACE_COLOR_BALANCE, + INTERFACE_CAMERA_CONTROL, +} GstInterfaceType; + + +void gst_camerasrc_set_capture_command(GstCameraSrc* camerasrc, GstCameraControlCaptureCommand cmd); + + +GType gst_camerasrc_get_type(void); + +G_END_DECLS + +#endif /* __GSTCAMERASRC_H__ */ diff --git a/camerasrc/src/include/gstcamerasrccolorbalance.h b/camerasrc/src/include/gstcamerasrccolorbalance.h new file mode 100644 index 0000000..0edeb46 --- /dev/null +++ b/camerasrc/src/include/gstcamerasrccolorbalance.h @@ -0,0 +1,93 @@ +/* + * camerasrc + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Jeongmo Yang <jm80.yang@samsung.com> + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __GST_CAMERASRC_COLOR_BALANCE_H__ +#define __GST_CAMERASRC_COLOR_BALANCE_H__ + +#include <gst/gst.h> +#include <gst/interfaces/colorbalance.h> +#include "gstcamerasrc.h" + +G_BEGIN_DECLS + +#define GST_TYPE_CAMERASRC_COLOR_BALANCE_CHANNEL (gst_camerasrc_color_balance_channel_get_type ()) +#define GST_CAMERASRC_COLOR_BALANCE_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CAMERASRC_COLOR_BALANCE_CHANNEL, GstCameraSrcColorBalanceChannel)) +#define GST_CAMERASRC_COLOR_BALANCE_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_CAMERASRC_COLOR_BALANCE_CHANNEL, GstCameraSrcColorBalanceChannelClass)) +#define GST_IS_CAMERASRC_COLOR_BALANCE_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CAMERASRC_COLOR_BALANCE_CHANNEL)) +#define GST_IS_CAMERASRC_COLOR_BALANCE_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CAMERASRC_COLOR_BALANCE_CHANNEL)) + +typedef struct _GstCameraSrcColorBalanceChannel { + GstColorBalanceChannel parent; + + guint32 id; +} GstCameraSrcColorBalanceChannel; + +typedef struct _GstCameraSrcColorBalanceChannelClass { + GstColorBalanceChannelClass parent; +} GstCameraSrcColorBalanceChannelClass; + +GType gst_camerasrc_color_balance_channel_get_type( void ); + +const GList *gst_camerasrc_color_balance_list_channels( GstCameraSrc* camerasrc ); +void gst_camerasrc_color_balance_set_value( GstCameraSrc* camerasrc, GstColorBalanceChannel* color_channel, gint value ); +gint gst_camerasrc_color_balance_get_value( GstCameraSrc* camerasrc, GstColorBalanceChannel* color_channel ); + +#define GST_IMPLEMENT_CAMERASRC_COLOR_BALANCE_METHODS( Type, interface_as_function ) \ + \ +static const GList* \ +interface_as_function ## _color_balance_list_channels( GstColorBalance* balance ) \ +{ \ + Type *this = (Type*) balance; \ + return gst_camerasrc_color_balance_list_channels( this ); \ +} \ + \ +static void \ +interface_as_function ## _color_balance_set_value( GstColorBalance* balance, \ + GstColorBalanceChannel* color_channel, \ + gint value ) \ +{ \ + Type *this = (Type*) balance; \ + return gst_camerasrc_color_balance_set_value( this, color_channel, value ); \ +} \ + \ +static gint \ +interface_as_function ## _color_balance_get_value( GstColorBalance* balance, \ + GstColorBalanceChannel* color_channel )\ +{ \ + Type *this = (Type*) balance; \ + return gst_camerasrc_color_balance_get_value( this, color_channel ); \ +} \ + \ +void \ +interface_as_function ## _color_balance_interface_init( GstColorBalanceClass* klass ) \ +{ \ + GST_COLOR_BALANCE_TYPE( klass ) = GST_COLOR_BALANCE_HARDWARE; \ + \ + /* default virtual functions */ \ + klass->list_channels = interface_as_function ## _color_balance_list_channels; \ + klass->set_value = interface_as_function ## _color_balance_set_value; \ + klass->get_value = interface_as_function ## _color_balance_get_value; \ +} + +#endif /* __GST_CAMERASRC_COLOR_BALANCE_H__ */ + diff --git a/camerasrc/src/include/gstcamerasrccontrol.h b/camerasrc/src/include/gstcamerasrccontrol.h new file mode 100644 index 0000000..c4ce913 --- /dev/null +++ b/camerasrc/src/include/gstcamerasrccontrol.h @@ -0,0 +1,384 @@ +/* + * camerasrc + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Jeongmo Yang <jm80.yang@samsung.com> + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __GST_CAMERASRC_CONTROL_H__ +#define __GST_CAMERASRC_CONTROL_H__ + +#include <gst/gst.h> +#include <gst/interfaces/cameracontrol.h> +#include "gstcamerasrc.h" + +G_BEGIN_DECLS + +#define GST_TYPE_CAMERASRC_CONTROL_CHANNEL (gst_camerasrc_control_channel_get_type ()) +#define GST_CAMERASRC_CONTROL_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CAMERASRC_CONTROL_CHANNEL, GstCamerasrcControlChannel)) +#define GST_CAMERASRC_CONTROL_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_CAMERASRC_CONTROL_CHANNEL, GstCamerasrcControlChannelClass)) +#define GST_IS_CAMERASRC_CONTROL_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CAMERASRC_CONTROL_CHANNEL)) +#define GST_IS_CAMERASRC_CONTROL_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CAMERASRC_CONTROL_CHANNEL)) + +typedef struct _GstCamerasrcControlChannel { +GstCameraControlChannel parent; +guint32 id; +} GstCamerasrcControlChannel; + +typedef struct _GstCamerasrcControlChannelClass { +GstCameraControlChannelClass parent; +} GstCamerasrcControlChannelClass; + +GType gst_camerasrc_control_channel_get_type( void ); + +const GList*gst_camerasrc_control_list_channels( GstCameraSrc* camera_src ); + +gboolean gst_camerasrc_control_set_value ( GstCameraSrc* camera_src, GstCameraControlChannel* control_channel, gint value ); +gboolean gst_camerasrc_control_get_value ( GstCameraSrc* camera_src, GstCameraControlChannel* control_channel, gint* value ); +gboolean gst_camerasrc_control_set_exposure ( GstCameraSrc* camera_src, gint type, gint value1, gint value2 ); +gboolean gst_camerasrc_control_get_exposure ( GstCameraSrc* camera_src, gint type, gint* value1, gint* value2 ); +gboolean gst_camerasrc_control_set_capture_mode ( GstCameraSrc* camera_src, gint type, gint value ); +gboolean gst_camerasrc_control_get_capture_mode ( GstCameraSrc* camera_src, gint type, gint* value ); +gboolean gst_camerasrc_control_set_strobe ( GstCameraSrc* camera_src, gint type, gint value ); +gboolean gst_camerasrc_control_get_strobe ( GstCameraSrc* camera_src, gint type, gint *value ); +gboolean gst_camerasrc_control_set_detect ( GstCameraSrc* camera_src, gint type, gint value ); +gboolean gst_camerasrc_control_get_detect ( GstCameraSrc* camera_src, gint type, gint* value ); +gboolean gst_camerasrc_control_set_zoom ( GstCameraSrc* camera_src, gint type, gint value ); +gboolean gst_camerasrc_control_get_zoom ( GstCameraSrc* camera_src, gint type, gint* value ); +gboolean gst_camerasrc_control_set_focus ( GstCameraSrc* camera_src, gint mode, gint range ); +gboolean gst_camerasrc_control_get_focus ( GstCameraSrc* camera_src, gint* mode, gint* range ); +gboolean gst_camerasrc_control_start_auto_focus ( GstCameraSrc* camera_src ); +gboolean gst_camerasrc_control_stop_auto_focus ( GstCameraSrc* camera_src ); +gboolean gst_camerasrc_control_set_focus_level ( GstCameraSrc* camera_src, gint manual_level ); +gboolean gst_camerasrc_control_get_focus_level ( GstCameraSrc* camera_src, gint* manual_level ); +gboolean gst_camerasrc_control_set_auto_focus_area( GstCameraSrc* camera_src, GstCameraControlRectType rect ); +gboolean gst_camerasrc_control_get_auto_focus_area( GstCameraSrc* camera_src, GstCameraControlRectType* rect ); +gboolean gst_camerasrc_control_set_wdr ( GstCameraSrc* camera_src, gint value ); +gboolean gst_camerasrc_control_get_wdr ( GstCameraSrc* camera_src, gint* value ); +gboolean gst_camerasrc_control_set_ahs ( GstCameraSrc* camera_src, gint value ); +gboolean gst_camerasrc_control_get_ahs ( GstCameraSrc* camera_src, gint* value ); +gboolean gst_camerasrc_control_set_part_color ( GstCameraSrc* camera_src, gint type, gint value ); +gboolean gst_camerasrc_control_get_part_color ( GstCameraSrc* camera_src, gint type, gint* value ); +gboolean gst_camerasrc_control_get_exif_info ( GstCameraSrc* camera_src, GstCameraControlExifInfo* info ); +gboolean gst_camerasrc_control_get_basic_dev_info ( GstCameraSrc* camera_src, gint dev_id, GstCameraControlCapsInfoType* info ); +gboolean gst_camerasrc_control_get_misc_dev_info ( GstCameraSrc* camera_src, gint dev_id, GstCameraControlCtrlListInfoType* info ); +gboolean gst_camerasrc_control_get_extra_dev_info ( GstCameraSrc* camera_src, gint dev_id, GstCameraControlExtraInfoType* info ); +void gst_camerasrc_control_set_capture_command( GstCameraSrc* camera_src, GstCameraControlCaptureCommand cmd ); + +#define GST_IMPLEMENT_CAMERASRC_CONTROL_METHODS(Type, interface_as_function) \ + \ +static const GList* \ +interface_as_function ## _control_list_channels( GstCameraControl* control ) \ +{ \ + Type* this = (Type*) control; \ + return gst_camerasrc_control_list_channels( this ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_set_value( GstCameraControl* control, \ + GstCameraControlChannel* control_channel, gint value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_set_value( this, control_channel, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_value( GstCameraControl* control, \ + GstCameraControlChannel* control_channel, gint* value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_value( this, control_channel, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_set_exposure( GstCameraControl* control, \ + gint type, gint value1, gint value2 ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_set_exposure( this, type, value1, value2 ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_exposure( GstCameraControl* control, \ + gint type, gint* value1, gint* value2 ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_exposure( this, type, value1, value2 ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_set_capture_mode( GstCameraControl* control, \ + gint type, gint value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_set_capture_mode( this, type, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_capture_mode( GstCameraControl* control, \ + gint type, gint* value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_capture_mode( this, type, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_set_strobe( GstCameraControl* control, \ + gint type, gint value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_set_strobe( this, type, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_strobe( GstCameraControl* control, \ + gint type, gint* value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_strobe( this, type, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_set_detect( GstCameraControl* control, \ + gint type, gint value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_set_detect( this, type, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_detect( GstCameraControl* control, \ + gint type, gint* value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_detect( this, type, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_set_zoom( GstCameraControl* control, \ + gint type, gint value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_set_zoom( this, type, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_zoom( GstCameraControl* control, \ + gint type, gint* value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_zoom( this, type, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_set_focus( GstCameraControl* control, \ + gint focus_mode, gint focus_range ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_set_focus( this, focus_mode, focus_range ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_focus( GstCameraControl* control, \ + gint* focus_mode, gint* focus_range ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_focus( this, focus_mode, focus_range ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_start_auto_focus( GstCameraControl* control) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_start_auto_focus( this ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_stop_auto_focus( GstCameraControl* control) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_stop_auto_focus( this ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_set_focus_level( GstCameraControl* control, \ + gint focus_level ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_set_focus_level( this, focus_level ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_focus_level( GstCameraControl* control, \ + gint* focus_level ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_focus_level( this, focus_level ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_set_auto_focus_area( GstCameraControl* control, \ + GstCameraControlRectType rect ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_set_auto_focus_area( this, rect ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_auto_focus_area( GstCameraControl* control, \ + GstCameraControlRectType* rect ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_auto_focus_area( this, rect ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_set_wdr( GstCameraControl* control, \ + gint value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_set_wdr( this, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_wdr( GstCameraControl* control, \ + gint* value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_wdr( this, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_set_ahs( GstCameraControl* control, \ + gint value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_set_ahs( this, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_ahs( GstCameraControl* control, \ + gint* value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_ahs( this, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_set_part_color( GstCameraControl* control, \ + gint type, gint value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_set_part_color( this, type, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_part_color( GstCameraControl* control, \ + gint type, gint* value ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_part_color( this, type, value ); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_exif_info( GstCameraControl* control, \ + GstCameraControlExifInfo* info ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_exif_info( this, info); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_basic_dev_info( GstCameraControl* control, \ + gint dev_id, \ + GstCameraControlCapsInfoType* info ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_basic_dev_info( this, dev_id, info); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_misc_dev_info( GstCameraControl* control, \ + gint dev_id, \ + GstCameraControlCtrlListInfoType* info ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_misc_dev_info( this, dev_id, info); \ +} \ + \ +static gboolean \ +interface_as_function ## _control_get_extra_dev_info( GstCameraControl* control, \ + gint dev_id, \ + GstCameraControlExtraInfoType* info ) \ +{ \ + Type* this = (Type*)control; \ + return gst_camerasrc_control_get_extra_dev_info( this, dev_id, info); \ +} \ + \ +static void \ +interface_as_function ## _control_set_capture_command( GstCameraControl* control, \ + GstCameraControlCaptureCommand cmd ) \ +{ \ + Type* this = (Type*)control; \ + gst_camerasrc_control_set_capture_command( this, cmd ); \ + return; \ +} \ + \ +void \ +interface_as_function ## _control_interface_init( GstCameraControlClass *klass ) \ +{ \ + GST_CAMERA_CONTROL_TYPE( klass ) = GST_CAMERA_CONTROL_HARDWARE; \ + \ + /* default virtual functions */ \ + klass->list_channels = interface_as_function ## _control_list_channels; \ + klass->set_value = interface_as_function ## _control_set_value; \ + klass->get_value = interface_as_function ## _control_get_value; \ + klass->set_exposure = interface_as_function ## _control_set_exposure; \ + klass->get_exposure = interface_as_function ## _control_get_exposure; \ + klass->set_capture_mode = interface_as_function ## _control_set_capture_mode; \ + klass->get_capture_mode = interface_as_function ## _control_get_capture_mode; \ + klass->set_strobe = interface_as_function ## _control_set_strobe; \ + klass->get_strobe = interface_as_function ## _control_get_strobe; \ + klass->set_detect = interface_as_function ## _control_set_detect; \ + klass->get_detect = interface_as_function ## _control_get_detect; \ + klass->set_zoom = interface_as_function ## _control_set_zoom; \ + klass->get_zoom = interface_as_function ## _control_get_zoom; \ + klass->set_focus = interface_as_function ## _control_set_focus; \ + klass->get_focus = interface_as_function ## _control_get_focus; \ + klass->start_auto_focus = interface_as_function ## _control_start_auto_focus; \ + klass->stop_auto_focus = interface_as_function ## _control_stop_auto_focus; \ + klass->set_focus_level = interface_as_function ## _control_set_focus_level; \ + klass->get_focus_level = interface_as_function ## _control_get_focus_level; \ + klass->set_auto_focus_area = interface_as_function ## _control_set_auto_focus_area; \ + klass->get_auto_focus_area = interface_as_function ## _control_get_auto_focus_area; \ + klass->set_wdr = interface_as_function ## _control_set_wdr; \ + klass->get_wdr = interface_as_function ## _control_get_wdr; \ + klass->set_ahs = interface_as_function ## _control_set_ahs; \ + klass->get_ahs = interface_as_function ## _control_get_ahs; \ + klass->set_part_color = interface_as_function ## _control_set_part_color; \ + klass->get_part_color = interface_as_function ## _control_get_part_color; \ + klass->get_exif_info = interface_as_function ## _control_get_exif_info; \ + klass->get_basic_dev_info = interface_as_function ## _control_get_basic_dev_info; \ + klass->get_misc_dev_info = interface_as_function ## _control_get_misc_dev_info; \ + klass->get_extra_dev_info = interface_as_function ## _control_get_extra_dev_info; \ + klass->set_capture_command = interface_as_function ## _control_set_capture_command; \ + \ +} + +#endif /* __GST_CAMERASRC_CONTROL_H__ */ |