1 /* Gstreamer MFLD camera source abstract Layer API
2 * Copyright (c) 2010 Intel Corporation
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
22 #include "mfld_cam_defs.h"
23 #include "mfld_driver.h"
24 #include "gstv4l2mfldadvci.h"
25 #include <linux/videodev2.h>
27 #define V4L2_COLORFX_BW 1
28 #define V4L2_COLORFX_SKY_BLUE 6
30 /* init: Initialize the driver. V4l2camerasrc calls this immediately after
31 * the camera device has been opened and registers the device file
32 * descriptor to the driver.
35 /* Support the photography configure
36 * Capture Correction has removed from the photography interface
37 * We also implement it here ane export it as the camsrc property
42 CAM_AWB_MODE, /* wb_mode */
43 CAM_GENERAL_EFFECT_TYPE, /* Tone Mode */
44 CAM_GENERAL_SCENE_MODE, /* Tone Mode */
45 CAM_LIGHT_FLASH_MODE, /* Flash Mode */
46 CAM_EXPOSURE_MANUAL_TIME, /* Exposure value */
47 CAM_EXPOSURE_MANUAL_APERTURE, /* Aperture Value */
48 CAM_EXPOSURE_COMPENSATION, /* ev_compensation */
49 CAM_EXPOSURE_ISO_VALUE, /* ISO Speed */
50 CAM_FOCUS_MODE, /* Focus Mode */
51 CAM_GENERAL_FLICKER_REDUCTION_MODE, /* flicker mode */
52 CAM_NOISE_REDUCTION_MODE, /* Noise reduction */
53 CAM_CAPTURE_CORRECTION, /* Capture Correction */
54 } cam_photo_feature_t;
58 CAM_GAMMA_VALUE, /* Gamma Setting */
59 CAM_CONTRAST_VALUE, /* Contrast Setting */
60 CAM_BRIGHTNESS_VALUE /* Brightness Setting */
63 /* Supported white balance mode by our 3A library */
67 CAM_AWB_MODE_DAYLIGHT,
70 CAM_AWB_MODE_TUNGSTEN,
71 CAM_AWB_MODE_FLUORESCENT
74 /* Color effect in the V4L2 */
77 CAM_GENERAL_EFFECT_TYPE_NORMAL = V4L2_COLORFX_NONE,
78 CAM_GENERAL_EFFECT_TYPE_GRAYSCALE = V4L2_COLORFX_BW,
79 CAM_GENERAL_EFFECT_TYPE_SEPIA ,
80 CAM_GENERAL_EFFECT_TYPE_NEGATIVE ,
81 CAM_GENERAL_EFFECT_TYPE_SKY_BLUE = V4L2_COLORFX_SKY_BLUE,
82 CAM_GENERAL_EFFECT_TYPE_GRASS_GREEN ,
83 CAM_GENERAL_EFFECT_TYPE_SKIN_WHITEN ,
84 CAM_GENERAL_EFFECT_TYPE_VIVID,
85 } cam_general_effect_t;
87 /* Scence Mode are not supported by MFLD camera currently */
90 CAM_GENERAL_SCENE_MODE_CLOSEUP = 1000,
91 CAM_GENERAL_SCENE_MODE_PORTRAIT,
92 CAM_GENERAL_SCENE_MODE_LANDSCAPE,
93 CAM_GENERAL_SCENE_MODE_SPORT,
94 CAM_GENERAL_SCENE_MODE_NIGHT,
95 CAM_GENERAL_SCENE_MODE_AUTO,
96 CAM_GENERAL_SCENE_MODE_FIREWORKS,
102 CAM_FOCUS_STATUS_IDLE,
103 CAM_FOCUS_STATUS_SUCCESS,
104 CAM_FOCUS_STATUS_RUNNING,
105 CAM_FOCUS_STATUS_FAIL
106 } cam_focus_status_t;
111 CAM_CAPTURE_MODE_VIEWFINDER,
112 CAM_CAPTURE_MODE_STILL_CAPTURE,
113 CAM_CAPTURE_MODE_VIDEO_RECORD
114 } cam_capture_mode_t;
118 CAM_LIGHT_FLASH_MODE_AUTO,
119 CAM_LIGHT_FLASH_MODE_OFF,
120 CAM_LIGHT_FLASH_MODE_ON,
121 CAM_LIGHT_FLASH_MODE_FILL_IN,
122 CAM_LIGHT_FLASH_MODE_RED_EYE
127 CAM_EXPOSURE_ISO_VALUE_1600,
128 CAM_EXPOSURE_ISO_VALUE_800,
129 CAM_EXPOSURE_ISO_VALUE_400,
130 CAM_EXPOSURE_ISO_VALUE_200,
131 CAM_EXPOSURE_ISO_VALUE_100,
132 CAM_EXPOSURE_ISO_VALUE_AUTO
133 } cam_exposure_iso_value_t;
138 CAM_FOCUS_MODE_AUTO, /* GST_PHOTOGRAPHY_FOCUS_MODE_AUTO = 0 */
139 CAM_FOCUS_MODE_MACRO,
142 CAM_FOCUS_MODE_CONTINUOUS,
143 CAM_FOCUS_MODE_TOUCH_AUTO,
148 CAM_VIEWFINDER_MODE_VIEWFINDER,
149 CAM_VIEWFINDER_MODE_STILL_CAPTURE,
150 CAM_VIEWFINDER_MODE_VIDEO_RECORD
151 } cam_viewfinder_mode_t;
153 /* Supported noise reduction mode
154 * These mode can be combiled together */
157 CAM_NOISE_REDUCTION_BAYER,
158 CAM_NOISE_REDUCTION_YCC,
159 CAM_NOISE_REDUCTION_TEMPORAL,
160 CAM_NOISE_REDUCTION_FIXED_PATTERN,
161 CAM_NOISE_REDUCTION_EXTRA,
162 } cam_noise_reduction_t;
164 /* Know as advanced mode before.
165 * RER, Image Stable and GDC are post processing.
166 * Others are on the fly processing
170 CAM_CAPTURE_CORRECTION_GDC, /* Geometry Distortion Correction */
171 CAM_CAPTURE_CORRECTION_CAC, /* Chromatic Aberration Correction */
172 CAM_CAPTURE_CORRECTION_EE, /* Edge Enhancement, increates the sharpness of the image */
173 CAM_CAPTURE_CORRECTION_SC, /* Shading Correction */
174 CAM_CAPTURE_CORRECTION_BLC, /* Black Level Compensation */
175 CAM_CAPTURE_CORRECTION_BPD, /* Bad Pixel Detection */
176 CAM_CAPTURE_CORRECTION_RER, /* Red Eye reduction */
177 CAM_CAPTURE_CORRECTION_DIS, /* Still Image Stabilization */
178 CAM_CAPTURE_CORRECTION_DVS /* Video Stabilization */
179 } cam_capture_correction_t;
181 /* Flicker mode supported on SH 3A library */
184 CAM_GENERAL_FLICKER_REDUCTION_MODE_OFF, /* GST_PHOTOGRAPHY_FLICKER_REDUCTION_OFF = 0 */
185 CAM_GENERAL_FLICKER_REDUCTION_MODE_50HZ, /* GST_PHOTOGRAPHY_FLICKER_REDUCTION_50HZ */
186 CAM_GENERAL_FLICKER_REDUCTION_MODE_60HZ, /* GST_PHOTOGRAPHY_FLICKER_REDUCTION_60HZ */
187 CAM_GENERAL_FLICKER_REDUCTION_MODE_AUTO, /* GST_PHOTOGRAPHY_FLICKER_REDUCTION_AUTO */
188 } cam_flicker_reduction_mode_t;
190 /* noise filter setting names */
191 #define EENF_LNF_STRENGTH "luma-noise-filter-strength"
192 #define EENF_CNF_STRENGTH "chroma-noise-filter-strength"
197 int contrast, brightness;
200 /* Camera Interal Status saved for upper layer */
201 struct mfld_cam_settings_t
207 int exposure, aperture;
210 struct tone_control tone;
211 int flicker_mode, focus_mode;
212 int noise_reduction, capture_correction;
216 struct cam_capture_settings
221 unsigned int raw_output_size;
225 cam_err_t cam_driver_init (int fd, const char *sensor_id);
227 cam_err_t cam_driver_deinit (int fd);
229 /* Known as read_settings before: mfldcamsrc tells the driver to retrieve settings from
230 * device and store them into #GstPhotoSettings structure.
232 cam_err_t cam_feature_get (int fd, cam_photo_feature_t feature, int *value);
234 /* Known as write_settings before: Called when some settings in mfldcamsrc's #GstPhotoSettings
235 * structure has changed. Driver needs to forward the settings to device.
237 cam_err_t cam_feature_set (int fd, cam_photo_feature_t feature, int value);
239 cam_err_t cam_set_capture_correction(int fd, cam_capture_correction_t mode, int on);
241 cam_err_t cam_set_tone_control(int fd, cam_tone_control_t tone, struct tone_control *value);
243 cam_err_t cam_set_autoexposure (int fd, int on);
245 cam_err_t cam_set_autofocus (int on);
247 cam_err_t cam_set_frame_rate( float frame_rate);
249 int cam_checkfocus_status (cam_focus_status_t * status, int force_update);
251 cam_err_t cam_get_shake_risk (int fd, int risk);
253 cam_err_t cam_set_flash (int fd, int on);
255 cam_err_t cam_get_flash_intensity (int fd, int on);
257 cam_err_t cam_set_flash_intensity (int fd, int on);
259 cam_err_t cam_set_capture_mode (int fd, cam_capture_mode_t mode);
261 cam_err_t cam_set_capture_fmt(int fd, unsigned int width,unsigned int height,
262 unsigned int fourcc);
264 cam_err_t cam_post_process(int fd);
266 cam_err_t cam_get_makernote (int fd, unsigned char *buf, unsigned size);
268 cam_err_t cam_start_capture(int fd);
270 cam_err_t cam_stop_capture(int fd);
272 cam_err_t cam_capture_frames(int fd, struct v4l2_buffer *buffer,
273 struct cam_capture_settings *capture_settings);
275 cam_err_t cam_set_zoom(int fd, float zoom);
277 void mfldcam_3a_start (void);
278 void mfldcam_3a_stop (void);
280 void libmfld_cam_init (GstV4l2MFLDAdvCI *advci);
281 void libmfld_cam_dispose (void);
284 cam_err_t get_ae_windows_num(int fd, int * num);
285 void get_awb_version(int fd, int * major, int * minor);
286 void get_ae_version(int fd, int * major, int * minor);
287 void get_rer_status(int fd, int * status);
288 void get_rer_version(int fd, int * major, int * minor);
289 void get_af_version(int fd, int * major, int * minor);
290 cam_err_t cam_get_focus_posi(int fd, unsigned * posi);
291 void get_af_result(int fd, unsigned * result);
292 cam_err_t get_af_status(int fd, unsigned * status);
293 void cam_set_af_ae_window(advci_window *window);
295 cam_err_t get_exp_mode(int fd, cam_scene_mode_t *expmode);
296 void get_ae_bias(int fd, int * bias);
297 cam_err_t get_ae_manual_shutter(int fd, float *time);
298 cam_err_t get_ae_manual_aperture(int fd, int *aperture);
299 cam_err_t get_ae_flash_mode(int fd, cam_flash_mode_t *mode);
300 cam_err_t set_ae_flash_mode(int fd, cam_flash_mode_t mode);
302 int cam_find_item_new (const int table[][2], const int item, int reverse);
304 cam_err_t get_awb_manual_color_temperature(int fd, int *ctemp);
305 cam_err_t get_wb_mode (int *wb_mode);
306 gboolean cam_is_flash_used(void);