Property refactoring
[gstreamer-omap:gst-openmax.git] / omx / gstomx_camera_parameters.c
1 /* GStreamer
2  *
3  * Copyright (C) 2009 Texas Instruments, Inc - http://www.ti.com/
4  * Copyright (C) 2011 Collabora Ltda
5  *  @author: Luciana Fujii Pontello <luciana.fujii@collabora.co.uk>
6  *
7  * Description: OMX Camera element
8  *  Created on: Mar 22, 2011
9  *      Author: Joaquin Castellanos <jcastellanos@ti.com>
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation
14  * version 2.1 of the License.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
24  */
25
26 #include "gstomx_camera_parameters.h"
27 #include "gstomx.h"
28 #include "timer-32k.h"
29
30 #ifdef USE_OMXTICORE
31 #  include <OMX_TI_IVCommon.h>
32 #  include <OMX_TI_Index.h>
33 #endif
34
35 #define GST_USE_UNSTABLE_API TRUE
36
37 #include <stdint.h>
38 #include <fcntl.h>
39 #include <sys/ioctl.h>
40 #include <OMX_CoreExt.h>
41 #include <OMX_IndexExt.h>
42 #ifdef USE_OMXTICORE
43 #include "OMX_IVCommon.h"
44 #else
45 #include <omx/OMX_IVCommon.h>
46 #endif
47 #include <gst/interfaces/photography.h>
48
49 /*
50  * Enums:
51  */
52
53 GType
54 gst_omx_camera_mode_get_type (void)
55 {
56     static GType type = 0;
57
58     if (!type)
59     {
60         static GEnumValue vals[] =
61         {
62             {MODE_PREVIEW,        "Preview",                    "preview"},
63             {MODE_VIDEO,          "Video Capture",              "video"},
64             {MODE_VIDEO_IMAGE,    "Video+Image Capture",        "video-image"},
65             {MODE_IMAGE,          "Image Capture",              "image"},
66             {MODE_IMAGE_HS,       "Image Capture High Speed",   "image-hs"},
67             {0, NULL, NULL},
68         };
69
70         type = g_enum_register_static ("GstOmxCameraMode", vals);
71     }
72
73     return type;
74 }
75
76 /*
77  * OMX Structure wrappers
78  */
79 GType
80 gst_omx_camera_shutter_get_type (void)
81 {
82     static GType type = 0;
83
84     if (!type)
85     {
86         static GEnumValue vals[] =
87         {
88             {SHUTTER_OFF,         "Off",                        "off"},
89             {SHUTTER_HALF_PRESS,  "Half Press",                 "half-press"},
90             {SHUTTER_FULL_PRESS,  "Full Press",                 "full-press"},
91             {0, NULL, NULL},
92         };
93
94         type = g_enum_register_static ("GstOmxCameraShutter", vals);
95     }
96
97     return type;
98 }
99
100 GType
101 gst_omx_camera_focus_get_type (void)
102 {
103     static GType type = 0;
104
105     if (!type)
106     {
107         static GEnumValue vals[] =
108         {
109             {OMX_IMAGE_FocusControlOff,      "off",              "off"},
110             {OMX_IMAGE_FocusControlOn,       "on",               "on"},
111             {OMX_IMAGE_FocusControlAuto,     "auto",             "auto"},
112             {OMX_IMAGE_FocusControlAutoLock, "autolock",         "autolock"},
113 #ifdef USE_OMXTICORE
114             {OMX_IMAGE_FocusControlAutoMacro,         "AutoMacro",      "automacro"},
115             {OMX_IMAGE_FocusControlAutoInfinity,      "AutoInfinity",   "autoinfinity"},
116             {OMX_IMAGE_FocusControlHyperfocal,        "Hyperfocal",     "hyperfocal"},
117             {OMX_IMAGE_FocusControlPortrait,          "Portrait",       "portrait"},
118             {OMX_IMAGE_FocusControlExtended,          "Extended",       "extended"},
119             {OMX_IMAGE_FocusControlContinousNormal,   "Cont-Normal",    "cont-normal"},
120             {OMX_IMAGE_FocusControlContinousExtended, "Cont-Extended",  "cont-extended"},
121 #endif
122             {0, NULL, NULL},
123         };
124
125         type = g_enum_register_static ("GstOmxCameraFocus", vals);
126     }
127
128     return type;
129 }
130
131 GType
132 gst_omx_camera_awb_get_type (void)
133 {
134     static GType type = 0;
135
136     if (!type)
137     {
138         static const GEnumValue vals[] =
139         {
140             {OMX_WhiteBalControlOff,           "Balance off",    "off"},
141             {OMX_WhiteBalControlAuto,          "Auto balance",   "auto"},
142             {OMX_WhiteBalControlSunLight,      "Sun light",      "sunlight"},
143             {OMX_WhiteBalControlCloudy,        "Cloudy",         "cloudy"},
144             {OMX_WhiteBalControlShade,         "Shade",          "shade"},
145             {OMX_WhiteBalControlTungsten,      "Tungsten",       "tungsten"},
146             {OMX_WhiteBalControlFluorescent,   "Fluorescent",    "fluorescent"},
147             {OMX_WhiteBalControlIncandescent,  "Incandescent",   "incandescent"},
148             {OMX_WhiteBalControlFlash,         "Flash",          "flash" },
149             {OMX_WhiteBalControlHorizon,       "Horizon",        "horizon" },
150             {0, NULL, NULL },
151         };
152
153         type = g_enum_register_static ("GstOmxCameraWhiteBalance",vals);
154     }
155
156     return type;
157 }
158
159 GType
160 gst_omx_camera_exposure_get_type (void)
161 {
162     static GType type = 0;
163
164     if (!type)
165     {
166         static const GEnumValue vals[] =
167         {
168             {OMX_ExposureControlOff,             "Exposure control off",     "off"},
169             {OMX_ExposureControlAuto,            "Auto exposure",            "auto"},
170             {OMX_ExposureControlNight,           "Night exposure",           "night"},
171             {OMX_ExposureControlBackLight,       "Backlight exposure",       "backlight"},
172             {OMX_ExposureControlSpotLight,       "SportLight exposure",      "sportlight"},
173             {OMX_ExposureControlSports,          "Sports exposure",          "sports"},
174             {OMX_ExposureControlSnow,            "Snow exposure",            "snow"},
175             {OMX_ExposureControlBeach,           "Beach exposure",           "beach"},
176             {OMX_ExposureControlLargeAperture,   "Large aperture exposure",  "large-aperture"},
177             {OMX_ExposureControlSmallApperture,  "Small aperture exposure",  "small-aperture"},
178             {0, NULL, NULL },
179         };
180
181         type = g_enum_register_static ("GstOmxCameraExposureControl", vals);
182     }
183
184     return type;
185 }
186
187 GType
188 gst_omx_camera_mirror_get_type (void)
189 {
190     static GType type = 0;
191
192     if (!type)
193     {
194         static GEnumValue vals[] =
195         {
196             {OMX_MirrorNone,        "Off",              "off"},
197             {OMX_MirrorVertical,    "Vertical",         "vertical"},
198             {OMX_MirrorHorizontal,  "Horizontal",       "horizontal"},
199             {OMX_MirrorBoth,        "Both",             "both"},
200             {0, NULL, NULL},
201         };
202
203         type = g_enum_register_static ("GstOmxCameraMirror", vals);
204     }
205
206     return type;
207 }
208
209
210 #ifdef USE_OMXTICORE
211
212 GType
213 gst_omx_camera_flicker_get_type (void)
214 {
215     static GType type = 0;
216
217     if (!type)
218     {
219         static const GEnumValue vals[] =
220         {
221             {OMX_FlickerCancelOff,  "Flicker control off",       "off"},
222             {OMX_FlickerCancelAuto, "Auto flicker control",      "auto"},
223             {OMX_FlickerCancel50,   "Flicker control for 50Hz",  "flick-50hz"},
224             {OMX_FlickerCancel60,   "Flicker control for 60Hz",  "flick-60hz"},
225             {0, NULL, NULL },
226         };
227
228         type = g_enum_register_static ("GstOmxCameraFlickerCancel", vals);
229     }
230
231     return type;
232 }
233
234 GType
235 gst_omx_camera_scene_get_type (void)
236 {
237     static GType type = 0;
238
239     if (!type)
240     {
241         static const GEnumValue vals[] =
242         {
243             {OMX_Manual,         "Manual settings",         "manual"},
244             {OMX_Closeup,        "Closeup settings",        "closeup"},
245             {OMX_Portrait,       "Portrait settings",       "portrait"},
246             {OMX_Landscape,      "Landscape settings",      "landscape"},
247             {OMX_Underwater,     "Underwater settings",     "underwater"},
248             {OMX_Sport,          "Sport settings",          "sport"},
249             {OMX_SnowBeach,      "SnowBeach settings",      "snowbeach"},
250             {OMX_Mood,           "Mood settings",           "mood"},
251 #if 0       /* The following options are not yet enabled at OMX level */
252             {OMX_NightPortrait,  "NightPortrait settings",  "night-portrait"},
253             {OMX_NightIndoor,    "NightIndoor settings",    "night-indoor"},
254             {OMX_Fireworks,      "Fireworks settings",      "fireworks"},
255             /* for still image: */
256             {OMX_Document,       "Document settings",       "document"},
257             {OMX_Barcode,        "Barcode settings",        "barcode"},
258             /* for video: */
259             {OMX_SuperNight,     "SuperNight settings",     "supernight"},
260             {OMX_Cine,           "Cine settings",           "cine"},
261             {OMX_OldFilm,        "OldFilm settings",        "oldfilm"},
262 #endif
263             {0, NULL, NULL},
264         };
265
266         type = g_enum_register_static ("GstOmxCameraScene", vals);
267     }
268
269     return type;
270 }
271
272 GType
273 gst_omx_camera_vnf_get_type (void)
274 {
275     static GType type = 0;
276
277     if (!type)
278     {
279         static GEnumValue vals[] =
280         {
281             {OMX_VideoNoiseFilterModeOff,   "off",              "off"},
282             {OMX_VideoNoiseFilterModeOn,    "on",               "on"},
283             {OMX_VideoNoiseFilterModeAuto,  "auto",             "auto"},
284             {0, NULL, NULL},
285         };
286
287         type = g_enum_register_static ("GstOmxCameraVnf", vals);
288     }
289
290     return type;
291 }
292
293 GType
294 gst_omx_camera_yuv_range_get_type (void)
295 {
296     static GType type = 0;
297
298     if (!type)
299     {
300         static GEnumValue vals[] =
301         {
302             {OMX_ITURBT601,       "OMX_ITURBT601",              "OMX_ITURBT601"},
303             {OMX_Full8Bit,        "OMX_Full8Bit",               "OMX_Full8Bit"},
304             {0, NULL, NULL},
305         };
306
307         type = g_enum_register_static ("GstOmxCameraYuvRange", vals);
308     }
309
310     return type;
311 }
312
313 GType
314 gst_omx_camera_device_get_type (void)
315 {
316     static GType type = 0;
317
318     if (!type)
319     {
320         static GEnumValue vals[] =
321         {
322             {OMX_PrimarySensor,     "Primary",          "primary"},
323             {OMX_SecondarySensor,   "Secondary",        "secondary"},
324             {OMX_TI_StereoSensor,   "Stereo",           "stereo"},
325             {0, NULL, NULL},
326         };
327
328         type = g_enum_register_static ("GstOmxCameraDevice", vals);
329     }
330
331     return type;
332 }
333
334 GType
335 gst_omx_camera_nsf_get_type (void)
336 {
337     static GType type = 0;
338
339     if (!type)
340     {
341         static const GEnumValue vals[] =
342         {
343             {OMX_ISONoiseFilterModeOff,     "nsf control off",    "off"},
344             {OMX_ISONoiseFilterModeOn,      "nsf control on",     "on"},
345             {OMX_ISONoiseFilterModeAuto,    "nsf control auto",   "auto"},
346             {0, NULL, NULL },
347         };
348
349         type = g_enum_register_static ("GstOmxCameraISONoiseFilter", vals);
350     }
351
352     return type;
353 }
354
355 GType
356 gst_omx_camera_focusspot_weight_get_type (void)
357 {
358     static GType type = 0;
359
360     if (!type)
361     {
362         static const GEnumValue vals[] =
363         {
364             {OMX_FocusSpotDefault,        "Common focus region",  "default"},
365             {OMX_FocusSpotSinglecenter,   "Single center",        "center"},
366             {OMX_FocusSpotMultiNormal,    "Multi normal",         "multinormal"},
367             {OMX_FocusSpotMultiAverage,   "Multi average",        "multiaverage"},
368             {OMX_FocusSpotMultiCenter,    "Multi center",         "multicenter"},
369             {0, NULL, NULL },
370         };
371
372         type = g_enum_register_static ("GstOmxCameraFocusSpotWeight", vals);
373     }
374
375     return type;
376 }
377
378 GType
379 gst_omx_camera_bce_get_type (void)
380 {
381     static GType type = 0;
382
383     if (!type)
384     {
385         static const GEnumValue vals[] =
386         {
387             {OMX_TI_BceModeOff,     "bce control off",    "off"},
388             {OMX_TI_BceModeOn,      "bce control on",     "on"},
389             {OMX_TI_BceModeAuto,    "bce control auto",   "auto"},
390             {0, NULL, NULL },
391         };
392
393         type = g_enum_register_static ("GstOmxCameraBrightnessContrastEnhance", vals);
394     }
395
396     return type;
397 }
398
399 #endif
400
401
402 /*
403  *  Methods:
404  */
405
406 #define SET_PROP(fname,port,type,omxtype,idx,Api,set)        \
407 void                                                         \
408 gst_omx_camera_set_##fname (GstOmxCamera *self, gint value)  \
409 {                                                            \
410     omxtype var;                                             \
411     OMX_ERRORTYPE err;                                       \
412     GOmxCore *core = (GST_OMX_BASE_SRC (self))->gomx;        \
413     OMX_HANDLETYPE handle = g_omx_core_get_handle (core);    \
414                                                              \
415     GST_DEBUG_OBJECT (self, "[port %u] Setting " #fname      \
416         " to %d", port + 0, value);                          \
417                                                              \
418     _G_OMX_INIT_PARAM (&var);                                \
419     port;                                                    \
420     err = OMX_Get##Api (handle, idx, &var);                  \
421     if (err != OMX_ErrorNone) {                              \
422         GST_WARNING_OBJECT (self,                            \
423             "Error getting " #idx ": %x (%s)",               \
424             err, g_omx_error_to_str (err));                  \
425     } else {                                                 \
426         set;                                                 \
427         GST_DEBUG_OBJECT (self, #fname ": param=%d", value); \
428         err = OMX_Get##Api (handle, idx, &var);              \
429         if (err != OMX_ErrorNone) {                          \
430             GST_WARNING_OBJECT (self,                        \
431                 "Error setting " #idx ": %x (%s)",           \
432                 err, g_omx_error_to_str (err));              \
433         }                                                    \
434     }                                                        \
435 }
436
437 #define GET_PROP(fname,port,type,omxtype,idx,Api,get)        \
438 void                                                         \
439 gst_omx_camera_get_##fname (GstOmxCamera *self, type *value) \
440 {                                                            \
441     omxtype var;                                             \
442     OMX_ERRORTYPE err;                                       \
443     GOmxCore *core = (GST_OMX_BASE_SRC (self))->gomx;        \
444     OMX_HANDLETYPE handle = g_omx_core_get_handle (core);    \
445                                                              \
446     GST_DEBUG_OBJECT (self, "[port %u] Getting " #fname,     \
447         port + 0);                                           \
448                                                              \
449     _G_OMX_INIT_PARAM (&var);                                \
450     port;                                                    \
451     err = OMX_Get##Api (handle, idx, &var);                  \
452     if (err != OMX_ErrorNone) {                              \
453         GST_WARNING_OBJECT (self,                            \
454             "Error getting " #idx ": %x (%s)",               \
455             err, g_omx_error_to_str (err));                  \
456     } else {                                                 \
457       get;                                                   \
458       GST_DEBUG_OBJECT (self, #fname "=%d", *value);         \
459     }                                                        \
460 }
461
462 /* Keep the same behavior as to what port(s), if any, is/are used.
463  * Some of the routines did not set a port, using a 0 port index
464  * as set by the memset done by _G_OMX_INIT_PARAM. This is likely
465  * wrong (neither the video nor image ports have a 0 index, and
466  * OMX_ALL is 0xffffffff), but we still do the same here, as it
467  * will be trivial to replace NOPORT with whatever ends up being
468  * the correct port once we know. */
469 #define IMGPORT var.nPortIndex = self->img_port->port_index
470 #define OUTPORT var.nPortIndex = (GST_OMX_BASE_SRC (self))->out_port->port_index
471 #define NOPORT
472 #define ALL_PORTS var.nPortIndex = OMX_ALL
473
474 #define DEFAULT_SET(field) var.field = value
475 #define DEFAULT_GET(field) *value = var.field
476
477 #define SET_CONFIG(fname,port,type,omxtype,idx,set) SET_PROP(fname,port,type,omxtype,idx,Config,set)
478 #define GET_CONFIG(fname,port,type,omxtype,idx,get) GET_PROP(fname,port,type,omxtype,idx,Config,get)
479 #define DEF_CONFIG_GETSET(fname,port,type,omxtype,idx,get,set) \
480   GET_CONFIG(fname,port,type,omxtype,idx,get) \
481   SET_CONFIG(fname,port,type,omxtype,idx,set)
482 #define DEF_CONFIG(fname,port,type,omxtype,idx,field) \
483   DEF_CONFIG_GETSET(fname,port,type,omxtype,idx,DEFAULT_GET(field),DEFAULT_SET(field))
484
485 #define SET_PARAM(fname,port,type,omxtype,idx,set) SET_PROP(fname,port,type,omxtype,idx,Parameter,set)
486 #define GET_PARAM(fname,port,type,omxtype,idx,get) GET_PROP(fname,port,type,omxtype,idx,Parameter,get)
487 #define DEF_PARAM_GETSET(fname,port,type,omxtype,idx,get,set) \
488   GET_PARAM(fname,port,type,omxtype,idx,get) \
489   SET_PARAM(fname,port,type,omxtype,idx,set)
490 #define DEF_PARAM(fname,port,type,omxtype,idx,field) \
491   DEF_PARAM_GETSET(fname,port,type,omxtype,idx,DEFAULT_GET(field),DEFAULT_SET(field))
492
493 DEF_CONFIG(brightness,NOPORT,gint,OMX_CONFIG_BRIGHTNESSTYPE,OMX_IndexConfigCommonBrightness,nBrightness)
494 DEF_CONFIG(saturation,NOPORT,gint,OMX_CONFIG_SATURATIONTYPE,OMX_IndexConfigCommonSaturation,nSaturation)
495 DEF_CONFIG(contrast,NOPORT,gint,OMX_CONFIG_CONTRASTTYPE,OMX_IndexConfigCommonContrast,nContrast)
496 DEF_CONFIG(device,OUTPORT,gint,OMX_CONFIG_SENSORSELECTTYPE,OMX_TI_IndexConfigSensorSelect,eSensor)
497 DEF_CONFIG(white_balance_mode,OUTPORT,OMX_WHITEBALCONTROLTYPE,OMX_CONFIG_WHITEBALCONTROLTYPE,
498     OMX_IndexConfigCommonWhiteBalance,eWhiteBalControl)
499 DEF_CONFIG(rotation,IMGPORT,guint,OMX_CONFIG_ROTATIONTYPE,OMX_IndexConfigCommonRotate,nRotation)
500 DEF_CONFIG(mirror,IMGPORT,OMX_MIRRORTYPE,OMX_CONFIG_MIRRORTYPE,OMX_IndexConfigCommonMirror,eMirror)
501 DEF_PARAM(qfactor,IMGPORT,guint,OMX_IMAGE_PARAM_QFACTORTYPE,OMX_IndexParamQFactor,nQFactor)
502 DEF_CONFIG_GETSET(zoom,NOPORT,guint,OMX_CONFIG_SCALEFACTORTYPE,OMX_IndexConfigCommonDigitalZoom,
503     do { *value = var.xWidth * 100 / CAM_ZOOM_IN_STEP; } while(0),
504     do {OMX_U32 zf = (CAM_ZOOM_IN_STEP * value) / 100; var.xWidth = zf; var.xHeight = zf; } while(0))
505 DEF_CONFIG_GETSET(manual_focus,OUTPORT,guint,OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE,OMX_IndexConfigFocusControl,
506     DEFAULT_GET(nFocusSteps),
507     do { var.eFocusControl = OMX_IMAGE_FocusControlOn; var.nFocusSteps = value; } while(0))
508 #ifdef USE_OMXTICORE
509 DEF_PARAM(thumbnail_width,IMGPORT,gint,OMX_PARAM_THUMBNAILTYPE,OMX_IndexParamThumbnail,nWidth)
510 DEF_PARAM(thumbnail_height,IMGPORT,gint,OMX_PARAM_THUMBNAILTYPE,OMX_IndexParamThumbnail,nHeight)
511 DEF_CONFIG(flicker_mode,NOPORT,OMX_COMMONFLICKERCANCELTYPE,OMX_CONFIG_FLICKERCANCELTYPE,
512     OMX_IndexConfigFlickerCancel,eFlickerCancel)
513 DEF_CONFIG(scene_mode,NOPORT,OMX_SCENEMODETYPE,OMX_CONFIG_SCENEMODETYPE,OMX_TI_IndexConfigSceneMode,eSceneMode)
514 DEF_PARAM(vnf,OUTPORT,OMX_VIDEONOISEFILTERMODETYPE,OMX_PARAM_VIDEONOISEFILTERTYPE,
515     OMX_IndexParamVideoNoiseFilter,eMode)
516 DEF_PARAM(yuv_range,OUTPORT,OMX_VIDEOYUVRANGETYPE,OMX_PARAM_VIDEOYUVRANGETYPE,
517     OMX_IndexParamVideoCaptureYUVRange,eYUVRange)
518 DEF_PARAM(nsf,NOPORT,OMX_VIDEONOISEFILTERMODETYPE,OMX_PARAM_ISONOISEFILTERTYPE,OMX_IndexParamHighISONoiseFiler,eMode)
519 DEF_CONFIG(mtis,NOPORT,gboolean,OMX_CONFIG_BOOLEANTYPE,OMX_IndexConfigMotionTriggeredImageStabilisation,bEnabled)
520 DEF_PARAM(sensor_overclock,NOPORT,gboolean,OMX_CONFIG_BOOLEANTYPE,OMX_TI_IndexParamSensorOverClockMode,bEnabled)
521 DEF_CONFIG(white_balance_color_temperature,NOPORT,guint,OMX_TI_CONFIG_WHITEBALANCECOLORTEMPTYPE,
522     OMX_TI_IndexConfigWhiteBalanceManualColorTemp,nColorTemperature)
523 DEF_CONFIG(focus_spot_weighting,NOPORT,OMX_TI_CONFIG_FOCUSSPOTMODETYPE,
524     OMX_TI_CONFIG_FOCUSSPOTWEIGHTINGTYPE,OMX_TI_IndexConfigFocusSpotWeighting,eMode)
525 DEF_CONFIG(gbce,NOPORT,OMX_TI_BRIGHTNESSCONTRASTCRTLTYPE,OMX_TI_CONFIG_LOCAL_AND_GLOBAL_BRIGHTNESSCONTRASTTYPE,
526     OMX_TI_IndexConfigGlobalBrightnessContrastEnhance,eControl)
527 DEF_CONFIG(glbce,NOPORT,OMX_TI_BRIGHTNESSCONTRASTCRTLTYPE,OMX_TI_CONFIG_LOCAL_AND_GLOBAL_BRIGHTNESSCONTRASTTYPE,
528     OMX_TI_IndexConfigLocalBrightnessContrastEnhance,eControl)
529 DEF_CONFIG(cac,NOPORT,gboolean,OMX_CONFIG_BOOLEANTYPE,OMX_IndexConfigChromaticAberrationCorrection,bEnabled)
530 DEF_PARAM(ldc,NOPORT,gboolean,OMX_CONFIG_BOOLEANTYPE,OMX_IndexParamLensDistortionCorrection,bEnabled)
531 DEF_CONFIG_GETSET(sharpness,OUTPORT,gint,OMX_IMAGE_CONFIG_PROCESSINGLEVELTYPE,
532     OMX_IndexConfigSharpeningLevel,DEFAULT_GET(nLevel),
533     do {var.nLevel = value; if (var.nLevel == 0) var.bAuto = OMX_TRUE; else var.bAuto = OMX_FALSE; } while(0))
534 #endif
535
536 GstPhotoCaps
537 gst_omx_camera_photography_get_capabilities (GstPhotography *photo)
538 {
539   return GST_PHOTOGRAPHY_CAPS_EV_COMP |
540          GST_PHOTOGRAPHY_CAPS_ISO_SPEED |
541          GST_PHOTOGRAPHY_CAPS_WB_MODE |
542          GST_PHOTOGRAPHY_CAPS_SCENE |
543          GST_PHOTOGRAPHY_CAPS_ZOOM;
544 }
545
546 gboolean
547 gst_omx_camera_photography_get_ev_compensation (GstPhotography *photo,
548         gfloat *evcomp)
549 {
550     OMX_CONFIG_EXPOSUREVALUETYPE config;
551     GOmxCore *gomx;
552     OMX_ERRORTYPE error_val = OMX_ErrorNone;
553     GstOmxCamera *self = GST_OMX_CAMERA (photo);
554     GstOmxBaseSrc *omx_base = GST_OMX_BASE_SRC (self);
555
556     gomx = (GOmxCore *) omx_base->gomx;
557     _G_OMX_INIT_PARAM (&config);
558     error_val = OMX_GetConfig (gomx->omx_handle,
559             OMX_IndexConfigCommonExposureValue, &config);
560     g_assert (error_val == OMX_ErrorNone);
561     GST_DEBUG_OBJECT (self, "xEVCompensation: EVCompensation=%d",
562             config.xEVCompensation);
563
564     return TRUE;
565 }
566
567 gboolean
568 gst_omx_camera_photography_get_iso_speed (GstPhotography *photo, guint *iso_speed)
569 {
570     OMX_CONFIG_EXPOSUREVALUETYPE config;
571     GOmxCore *gomx;
572     GstOmxBaseSrc *omx_base = GST_OMX_BASE_SRC (photo);
573     OMX_ERRORTYPE error_val = OMX_ErrorNone;
574     GstOmxCamera *self = GST_OMX_CAMERA (photo);
575
576     gomx = (GOmxCore *) omx_base->gomx;
577
578     _G_OMX_INIT_PARAM (&config);
579     error_val = OMX_GetConfig (gomx->omx_handle,
580             OMX_IndexConfigCommonExposureValue, &config);
581     g_assert (error_val == OMX_ErrorNone);
582     GST_DEBUG_OBJECT (self, "ISO Speed: param=%d", config.nSensitivity);
583     *iso_speed = config.nSensitivity;
584
585     return TRUE;
586 }
587
588 gboolean
589 gst_omx_camera_photography_get_white_balance_mode (GstPhotography *photo,
590         GstWhiteBalanceMode *wb_mode)
591 {
592     OMX_WHITEBALCONTROLTYPE omx_wb;
593     gint convert_wb;
594
595     gst_omx_camera_get_white_balance_mode (GST_OMX_CAMERA (photo), &omx_wb);
596     convert_wb = omx_wb - 1;
597     if (convert_wb < 0 || convert_wb > 6)
598         return FALSE;
599
600     *wb_mode = convert_wb;
601     return TRUE;
602 }
603
604 gboolean
605 gst_omx_camera_photography_get_scene_mode (GstPhotography *photo,
606         GstSceneMode *scene_mode)
607 {
608     OMX_SCENEMODETYPE scene_omx_camera;
609
610     gst_omx_camera_get_scene_mode (GST_OMX_CAMERA (photo), &scene_omx_camera);
611     if (scene_omx_camera <= 3)
612         *scene_mode = scene_omx_camera;
613     else if (scene_omx_camera == 5)
614         *scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_SPORT;
615     else
616         /* scene does not exist in photography */
617         return FALSE;
618
619     return TRUE;
620 }
621
622 gboolean
623 gst_omx_camera_photography_get_zoom (GstPhotography *photo, gfloat *zoom)
624 {
625     guint zoom_int_value;
626
627     gst_omx_camera_get_zoom (GST_OMX_CAMERA (photo), &zoom_int_value);
628     *zoom = zoom_int_value /700.0 * 9.0;
629     return TRUE;
630 }
631
632 static gboolean
633 flicker_from_gst_photography (GstFlickerReductionMode flicker, OMX_COMMONFLICKERCANCELTYPE *res)
634 {
635   switch (flicker) {
636     case GST_PHOTOGRAPHY_FLICKER_REDUCTION_AUTO:
637       *res = OMX_FlickerCancelAuto;
638       return TRUE;
639     case GST_PHOTOGRAPHY_FLICKER_REDUCTION_OFF:
640       *res = OMX_FlickerCancelOff;
641       return TRUE;
642     case GST_PHOTOGRAPHY_FLICKER_REDUCTION_50HZ:
643       *res = OMX_FlickerCancel50;
644       return TRUE;
645     case GST_PHOTOGRAPHY_FLICKER_REDUCTION_60HZ:
646       *res = OMX_FlickerCancel60;
647       return TRUE;
648     default:
649       g_warning ("Unsupported flicker enum in gst->OMX conversion");
650       return FALSE;
651   }
652 }
653
654 static gboolean
655 flicker_to_gst_photography (OMX_COMMONFLICKERCANCELTYPE flicker, GstFlickerReductionMode *res)
656 {
657   switch (flicker) {
658     case OMX_FlickerCancelOff:
659       *res = GST_PHOTOGRAPHY_FLICKER_REDUCTION_OFF;
660        return TRUE;
661     case OMX_FlickerCancelAuto:
662       *res = GST_PHOTOGRAPHY_FLICKER_REDUCTION_AUTO;
663        return TRUE;
664     case OMX_FlickerCancel100:
665       GST_WARNING ("100 Hz flicker cancel unsupported by GstPhotography, using 50");
666     case OMX_FlickerCancel50:
667       *res = GST_PHOTOGRAPHY_FLICKER_REDUCTION_50HZ;
668        return TRUE;
669     case OMX_FlickerCancel120:
670       GST_WARNING ("120 Hz flicker cancel unsupported by GstPhotography, using 60");
671     case OMX_FlickerCancel60:
672       *res = GST_PHOTOGRAPHY_FLICKER_REDUCTION_60HZ;
673        return TRUE;
674     default:
675       g_warning ("Unsupported flicker enum in OMX->gst conversion");
676       return FALSE;
677   }
678 }
679
680 gboolean
681 gst_omx_camera_photography_get_flicker_mode (GstPhotography *photo,
682     GstFlickerReductionMode * flicker_mode)
683 {
684   OMX_COMMONFLICKERCANCELTYPE flicker;
685   gst_omx_camera_get_flicker_mode (GST_OMX_CAMERA (photo), &flicker);
686   return flicker_to_gst_photography (flicker, flicker_mode);
687 }
688
689 gboolean
690 gst_omx_camera_photography_set_ev_compensation (GstPhotography *photo,
691         gfloat evcomp)
692 {
693     OMX_CONFIG_EXPOSUREVALUETYPE config;
694     GOmxCore *gomx;
695     OMX_ERRORTYPE error_val = OMX_ErrorNone;
696     GstOmxCamera *self = GST_OMX_CAMERA (photo);
697     GstOmxBaseSrc *omx_base = GST_OMX_BASE_SRC (self);
698
699     gomx = (GOmxCore *) omx_base->gomx;
700     _G_OMX_INIT_PARAM (&config);
701     error_val = OMX_GetConfig (gomx->omx_handle,
702             OMX_IndexConfigCommonExposureValue, &config);
703     g_assert (error_val == OMX_ErrorNone);
704     /* Converting into Q16 ( X << 16  = X*65536 ) */
705     config.xEVCompensation = (OMX_S32) (evcomp * 65536);
706     GST_DEBUG_OBJECT (self, "xEVCompensation: value=%f EVCompensation=%d",
707             evcomp, config.xEVCompensation);
708
709     G_OMX_CORE_SET_CONFIG (gomx, OMX_IndexConfigCommonExposureValue, &config);
710
711     return TRUE;
712 }
713
714 gboolean
715 gst_omx_camera_photography_set_iso_speed (GstPhotography *photo, guint iso_speed)
716 {
717     OMX_CONFIG_EXPOSUREVALUETYPE config;
718     GOmxCore *gomx;
719     OMX_ERRORTYPE error_val = OMX_ErrorNone;
720     GstOmxCamera *self = GST_OMX_CAMERA (photo);
721     GstOmxBaseSrc *omx_base = GST_OMX_BASE_SRC (self);
722
723     gomx = (GOmxCore *) omx_base->gomx;
724     _G_OMX_INIT_PARAM (&config);
725     error_val = OMX_GetConfig (gomx->omx_handle,
726             OMX_IndexConfigCommonExposureValue, &config);
727     g_assert (error_val == OMX_ErrorNone);
728     if (iso_speed > 1600)
729       return FALSE;
730     config.bAutoSensitivity = (iso_speed < 100) ? OMX_TRUE : OMX_FALSE;
731     if (config.bAutoSensitivity == OMX_FALSE)
732     {
733         config.nSensitivity = iso_speed;
734     }
735     GST_DEBUG_OBJECT (self, "ISO Speed: Auto=%d Sensitivity=%d",
736             config.bAutoSensitivity, config.nSensitivity);
737
738     G_OMX_CORE_SET_CONFIG (gomx, OMX_IndexConfigCommonExposureValue, &config);
739
740     return TRUE;
741 }
742
743 gboolean
744 gst_omx_camera_photography_set_white_balance_mode (GstPhotography *photo,
745         GstWhiteBalanceMode wb_mode)
746 {
747     OMX_WHITEBALCONTROLTYPE wb_omx_camera;
748
749     wb_omx_camera = wb_mode + 1;
750     gst_omx_camera_set_white_balance_mode (GST_OMX_CAMERA (photo), wb_omx_camera);
751     return TRUE;
752 }
753
754 gboolean
755 gst_omx_camera_photography_set_scene_mode (GstPhotography *photo,
756         GstSceneMode scene_mode)
757 {
758     OMX_SCENEMODETYPE scene_omx_camera;
759
760     if (scene_mode <= 3)
761         scene_omx_camera = scene_mode;
762     else if (scene_mode == GST_PHOTOGRAPHY_SCENE_MODE_SPORT)
763         scene_omx_camera = 5;
764     else
765         /* scene does not exist in omx_camera */
766         return FALSE;
767
768     gst_omx_camera_set_scene_mode (GST_OMX_CAMERA (photo), scene_omx_camera);
769     return TRUE;
770 }
771
772 gboolean
773 gst_omx_camera_photography_set_zoom (GstPhotography *photo, gfloat zoom)
774 {
775     guint zoom_int_value;
776
777     zoom_int_value = abs (zoom * 900.0 / 7.0);
778     gst_omx_camera_set_zoom (GST_OMX_CAMERA (photo), zoom_int_value);
779     return TRUE;
780 }
781
782 gboolean
783 gst_omx_camera_photography_set_flicker_mode (GstPhotography *photo,
784     GstFlickerReductionMode flicker_mode)
785 {
786   OMX_COMMONFLICKERCANCELTYPE flicker;
787   if (!flicker_from_gst_photography (flicker_mode, &flicker))
788     return FALSE;
789   gst_omx_camera_set_flicker_mode (GST_OMX_CAMERA (photo), flicker);
790   return TRUE;
791 }
792
793 static void
794 gst_omx_camera_set_autofocus (GstPhotography *photo,
795     OMX_IMAGE_FOCUSCONTROLTYPE focus)
796 {
797     OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE config;
798     OMX_CONFIG_CALLBACKREQUESTTYPE focusreq_cb;
799     GOmxCore *gomx;
800     OMX_ERRORTYPE error_val = OMX_ErrorNone;
801     GstOmxCamera *self = GST_OMX_CAMERA (photo);
802     GstOmxBaseSrc *omx_base = GST_OMX_BASE_SRC (self);
803
804     gomx = (GOmxCore *) omx_base->gomx;
805     _G_OMX_INIT_PARAM (&config);
806     _G_OMX_INIT_PARAM (&focusreq_cb);
807     error_val = OMX_GetConfig(gomx->omx_handle,
808             OMX_IndexConfigFocusControl, &config);
809     g_assert (error_val == OMX_ErrorNone);
810     config.nPortIndex = omx_base->out_port->port_index;
811     config.eFocusControl = focus;
812     GST_DEBUG_OBJECT (self, "AF: param=%d port=%d", config.eFocusControl,
813             config.nPortIndex);
814
815     G_OMX_CORE_SET_CONFIG (gomx, OMX_IndexConfigFocusControl, &config);
816
817     if (config.eFocusControl == OMX_IMAGE_FocusControlAutoLock)
818         focusreq_cb.bEnable = OMX_TRUE;
819     else
820         focusreq_cb.bEnable = OMX_FALSE;
821
822     if (omx_base->gomx->omx_state == OMX_StateExecuting)
823     {
824         guint32 autofocus_start_time;
825
826         focusreq_cb.nPortIndex = OMX_ALL;
827         focusreq_cb.nIndex = OMX_IndexConfigCommonFocusStatus;
828
829         G_OMX_CORE_SET_CONFIG (gomx,
830                 OMX_IndexConfigCallbackRequest,
831                 &focusreq_cb);
832         GST_DEBUG_OBJECT (self, "AF_cb: enable=%d port=%d",
833                 focusreq_cb.bEnable, focusreq_cb.nPortIndex);
834
835         if (config.eFocusControl == OMX_IMAGE_FocusControlAutoLock)
836         {
837             GstStructure *structure = gst_structure_new ("omx_camera",
838                     "auto-focus", G_TYPE_BOOLEAN, FALSE, NULL);
839
840             GstMessage *message = gst_message_new_element (
841                     GST_OBJECT (self), structure);
842
843             gst_element_post_message (GST_ELEMENT (self), message);
844
845             autofocus_start_time = omap_32k_readraw ();
846             GST_CAT_INFO_OBJECT (gstomx_ppm, self,
847                     "%d Autofocus started", autofocus_start_time);
848         }
849     }
850 }
851
852 void
853 gst_omx_camera_photography_set_autofocus (GstPhotography *photo,
854     gboolean autofocus)
855 {
856     OMX_IMAGE_FOCUSCONTROLTYPE enum_focus;
857
858     enum_focus = autofocus ? 3 : 1;
859     gst_omx_camera_set_autofocus (photo, enum_focus);
860 }
861
862 void
863 set_camera_operating_mode (GstOmxCamera *self)
864 {
865     GstOmxBaseSrc *omx_base = GST_OMX_BASE_SRC (self);
866     OMX_CONFIG_CAMOPERATINGMODETYPE mode;
867     GOmxCore *gomx;
868
869     gomx = (GOmxCore *) omx_base->gomx;
870     _G_OMX_INIT_PARAM (&mode);
871
872     switch (self->next_mode)
873     {
874         case MODE_VIDEO:
875             if (self->device == OMX_TI_StereoSensor) {
876                 mode.eCamOperatingMode = OMX_CaptureStereoImageCapture;
877             } else {
878                 mode.eCamOperatingMode = OMX_CaptureVideo;
879             }
880             break;
881         case MODE_PREVIEW:
882             if (self->device == OMX_TI_StereoSensor) {
883                 mode.eCamOperatingMode = OMX_CaptureStereoImageCapture;
884             } else {
885                 mode.eCamOperatingMode = OMX_CaptureImageProfileBase;
886             }
887             break;
888         case MODE_IMAGE:
889             mode.eCamOperatingMode = OMX_CaptureImageProfileBase;
890             break;
891         case MODE_VIDEO_IMAGE:     /* @todo check this */
892         case MODE_IMAGE_HS:
893             mode.eCamOperatingMode =
894                 OMX_CaptureImageHighSpeedTemporalBracketing;
895             break;
896         default:
897             g_assert_not_reached ();
898     }
899     GST_DEBUG_OBJECT (self, "OMX_CaptureImageMode: set = %d",
900             mode.eCamOperatingMode);
901     G_OMX_CORE_SET_PARAM (gomx, OMX_IndexCameraOperatingMode, &mode);
902 }
903
904 void
905 set_property (GObject *obj,
906               guint prop_id,
907               const GValue *value,
908               GParamSpec *pspec)
909 {
910     GstOmxCamera *self = GST_OMX_CAMERA (obj);
911     GstOmxBaseSrc *omx_base = GST_OMX_BASE_SRC (self);
912     GstPhotography *photo = GST_PHOTOGRAPHY (self);
913
914     if (omx_base->gomx->omx_state != OMX_StateLoaded) {
915         GST_ERROR_OBJECT (self, "OMX core not initialized, cannot set property");
916         return;
917     }
918
919     switch (prop_id)
920     {
921         case ARG_NUM_IMAGE_OUTPUT_BUFFERS:
922         case ARG_NUM_VIDEO_OUTPUT_BUFFERS:
923         {
924             OMX_PARAM_PORTDEFINITIONTYPE param;
925             OMX_U32 nBufferCountActual = g_value_get_uint (value);
926             GOmxPort *port = (prop_id == ARG_NUM_IMAGE_OUTPUT_BUFFERS) ?
927                     self->img_port : self->vid_port;
928
929             G_OMX_PORT_GET_DEFINITION (port, &param);
930
931             g_return_if_fail (nBufferCountActual >= param.nBufferCountMin);
932             param.nBufferCountActual = nBufferCountActual;
933
934             G_OMX_PORT_SET_DEFINITION (port, &param);
935
936             break;
937         }
938         case ARG_MODE:
939         {
940             self->next_mode = g_value_get_enum (value);
941             GST_DEBUG_OBJECT (self, "mode: %d", self->next_mode);
942             break;
943         }
944         case ARG_SHUTTER:
945         {
946             self->shutter = g_value_get_enum (value);
947             GST_DEBUG_OBJECT (self, "shutter: %d", self->shutter);
948             break;
949         }
950         case ARG_ZOOM:
951         {
952             gfloat zoom_value;
953             zoom_value = g_value_get_float (value);
954             gst_omx_camera_photography_set_zoom (photo, zoom_value);
955             break;
956         }
957         case ARG_FOCUS:
958         {
959             OMX_IMAGE_FOCUSCONTROLTYPE focus_value;
960
961             focus_value = g_value_get_enum (value);
962             gst_omx_camera_set_autofocus (photo, focus_value);
963
964             break;
965         }
966         case ARG_AWB:
967         {
968             OMX_WHITEBALCONTROLTYPE wb_enum_value;
969
970             wb_enum_value = g_value_get_enum (value);
971             gst_omx_camera_set_white_balance_mode (self, wb_enum_value);
972             break;
973         }
974         case ARG_WHITE_BALANCE:
975         {
976             GstWhiteBalanceMode wb_enum_value;
977
978             wb_enum_value = g_value_get_enum (value);
979             gst_omx_camera_photography_set_white_balance_mode (photo,
980                                                                wb_enum_value);
981             break;
982         }
983         case ARG_CONTRAST:
984         {
985             gint contrast = g_value_get_int (value);
986
987             gst_omx_camera_set_contrast (self, contrast);
988             break;
989         }
990         case ARG_BRIGHTNESS:
991         {
992             gint brightness;
993
994             brightness = g_value_get_int (value);
995             gst_omx_camera_set_brightness (self, brightness);
996             break;
997         }
998         case ARG_EXPOSURE:
999         {
1000             OMX_CONFIG_EXPOSURECONTROLTYPE config;
1001             GOmxCore *gomx;
1002             OMX_ERRORTYPE error_val = OMX_ErrorNone;
1003
1004             gomx = (GOmxCore *) omx_base->gomx;
1005             _G_OMX_INIT_PARAM (&config);
1006             error_val = OMX_GetConfig (gomx->omx_handle,
1007                                        OMX_IndexConfigCommonExposure,
1008                                        &config);
1009             g_assert (error_val == OMX_ErrorNone);
1010             config.eExposureControl = g_value_get_enum (value);
1011             GST_DEBUG_OBJECT (self, "Exposure control = %d",
1012                               config.eExposureControl);
1013
1014             G_OMX_CORE_SET_CONFIG (gomx, OMX_IndexConfigCommonExposure, &config);
1015             break;
1016         }
1017         case ARG_ISO:
1018         {
1019             OMX_U32 iso_requested;
1020
1021             iso_requested = g_value_get_uint (value);
1022             gst_omx_camera_photography_set_iso_speed (photo, iso_requested);
1023             break;
1024         }
1025         case ARG_ROTATION:
1026         {
1027             gst_omx_camera_set_rotation (self, g_value_get_uint (value));
1028             break;
1029         }
1030         case ARG_MIRROR:
1031         {
1032             gst_omx_camera_set_mirror (self, g_value_get_enum (value));
1033             break;
1034         }
1035         case ARG_SATURATION:
1036         {
1037             gint saturation = g_value_get_int (value);
1038
1039             gst_omx_camera_set_saturation (self, saturation);
1040             break;
1041         }
1042         case ARG_EXPOSUREVALUE:
1043         {
1044             gfloat exposure_float_value;
1045             exposure_float_value = g_value_get_float (value);
1046
1047             gst_omx_camera_photography_set_ev_compensation (photo,
1048                 exposure_float_value);
1049
1050             break;
1051         }
1052         case ARG_EVCOMPENSATION:
1053         {
1054             gfloat exposure_float_value;
1055             exposure_float_value = g_value_get_float (value);
1056
1057             gst_omx_camera_photography_set_ev_compensation (photo,
1058                 exposure_float_value);
1059
1060             break;
1061         }
1062         case ARG_MANUALFOCUS:
1063         {
1064             gst_omx_camera_set_manual_focus (self, g_value_get_uint (value));
1065             break;
1066         }
1067         case ARG_QFACTORJPEG:
1068         {
1069             gst_omx_camera_set_qfactor (self, g_value_get_uint (value));
1070             break;
1071         }
1072
1073         /* Not implemented GstPhotography properties */
1074
1075         case ARG_APERTURE:
1076         case ARG_CAPABILITIES:
1077         case ARG_COLOUR_TONE:
1078         case ARG_FLASH_MODE:
1079         case ARG_FOCUS_MODE:
1080         case ARG_IMAGE_CAPTURE_SUPPORTED_CAPS:
1081         case ARG_IMAGE_PREVIEW_SUPPORTED_CAPS:
1082         case ARG_NOISE_REDUCTION:
1083             break;
1084 #ifdef USE_OMXTICORE
1085         case ARG_THUMBNAIL_WIDTH:
1086         {
1087             gst_omx_camera_set_thumbnail_width (self, g_value_get_int (value));
1088             break;
1089         }
1090         case ARG_THUMBNAIL_HEIGHT:
1091         {
1092             gst_omx_camera_set_thumbnail_height (self, g_value_get_int (value));
1093             break;
1094         }
1095         case ARG_FLICKER:
1096         {
1097             OMX_COMMONFLICKERCANCELTYPE flicker_enum_value;
1098
1099             flicker_enum_value = g_value_get_enum (value);
1100             gst_omx_camera_set_flicker_mode (GST_OMX_CAMERA (photo), flicker_enum_value);
1101             break;
1102         }
1103         case ARG_FLICKER_MODE:
1104         {
1105             GstFlickerReductionMode flicker_enum_value;
1106
1107             flicker_enum_value = g_value_get_enum (value);
1108             gst_omx_camera_photography_set_flicker_mode (photo,
1109                                                          flicker_enum_value);
1110             break;
1111         }
1112         case ARG_SCENE:
1113         {
1114             OMX_SCENEMODETYPE scene_enum;
1115
1116             scene_enum = g_value_get_enum (value);
1117             gst_omx_camera_set_scene_mode (self, scene_enum);
1118             break;
1119         }
1120         case ARG_SCENE_MODE:
1121         {
1122             GstSceneMode scene_enum;
1123
1124             scene_enum = g_value_get_enum (value);
1125             gst_omx_camera_photography_set_scene_mode (photo, scene_enum);
1126             break;
1127         }
1128         case ARG_VNF:
1129         {
1130             gst_omx_camera_set_vnf (self, g_value_get_enum (value));
1131             break;
1132         }
1133         case ARG_YUV_RANGE:
1134         {
1135             gst_omx_camera_set_yuv_range (self, g_value_get_enum (value));
1136             break;
1137         }
1138         case ARG_VSTAB:
1139         {
1140             OMX_CONFIG_BOOLEANTYPE param;
1141             OMX_CONFIG_FRAMESTABTYPE config;
1142
1143             G_OMX_CORE_GET_PARAM (omx_base->gomx, OMX_IndexParamFrameStabilisation, &param);
1144             G_OMX_CORE_GET_CONFIG (omx_base->gomx, OMX_IndexConfigCommonFrameStabilisation, &config);
1145
1146             param.bEnabled = config.bStab = g_value_get_boolean (value);
1147             GST_DEBUG_OBJECT (self, "vstab: param=%d, config=%d", param.bEnabled, config.bStab);
1148
1149             G_OMX_CORE_SET_PARAM (omx_base->gomx, OMX_IndexParamFrameStabilisation, &param);
1150             G_OMX_CORE_SET_CONFIG (omx_base->gomx, OMX_IndexConfigCommonFrameStabilisation, &config);
1151
1152             break;
1153         }
1154         case ARG_DEVICE:
1155         {
1156             gint device_enum;
1157
1158             device_enum = g_value_get_enum (value);
1159             gst_omx_camera_set_device (self, device_enum);
1160
1161             break;
1162         }
1163         case ARG_LDC:
1164         {
1165             gst_omx_camera_set_ldc (self, g_value_get_boolean (value));
1166             break;
1167         }
1168         case ARG_NSF:
1169         {
1170             gst_omx_camera_set_nsf (self, g_value_get_enum (value));
1171             break;
1172         }
1173         case ARG_MTIS:
1174         {
1175             gst_omx_camera_set_mtis (self, g_value_get_boolean (value));
1176             break;
1177         }
1178         case ARG_SENSOR_OVERCLOCK:
1179         {
1180             gst_omx_camera_set_sensor_overclock (self, g_value_get_boolean (value));
1181             break;
1182         }
1183         case ARG_WB_COLORTEMP:
1184         {
1185             gst_omx_camera_set_white_balance_color_temperature (self, g_value_get_uint (value));
1186             break;
1187         }
1188         case ARG_FOCUSSPOT_WEIGHT:
1189         {
1190             gst_omx_camera_set_focus_spot_weighting (self, g_value_get_enum (value));
1191             break;
1192         }
1193         case ARG_SHARPNESS:
1194         {
1195             gint sharpness = g_value_get_int (value);
1196
1197             gst_omx_camera_set_sharpness (self, sharpness);
1198             break;
1199         }
1200         case ARG_CAC:
1201         {
1202             gst_omx_camera_set_cac (self, g_value_get_boolean (value));
1203             break;
1204         }
1205         case ARG_GBCE:
1206         {
1207             gst_omx_camera_set_gbce (self, g_value_get_enum (value));
1208             break;
1209         }
1210         case ARG_GLBCE:
1211         {
1212             gst_omx_camera_set_glbce (self, g_value_get_enum (value));
1213             break;
1214         }
1215 #endif
1216         default:
1217         {
1218             G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
1219             break;
1220         }
1221     }
1222 }
1223
1224 void
1225 get_property (GObject *obj,
1226               guint prop_id,
1227               GValue *value,
1228               GParamSpec *pspec)
1229 {
1230     GstOmxCamera *self = GST_OMX_CAMERA (obj);
1231     GstOmxBaseSrc *omx_base = GST_OMX_BASE_SRC (self);
1232     GstPhotography *photo = GST_PHOTOGRAPHY (self);
1233
1234     if (omx_base->gomx->omx_state != OMX_StateLoaded) {
1235         GST_ERROR_OBJECT (self, "OMX core not initialized, cannot get property");
1236         return;
1237     }
1238
1239     switch (prop_id)
1240     {
1241         case ARG_NUM_IMAGE_OUTPUT_BUFFERS:
1242         case ARG_NUM_VIDEO_OUTPUT_BUFFERS:
1243         {
1244             OMX_PARAM_PORTDEFINITIONTYPE param;
1245             GOmxPort *port = (prop_id == ARG_NUM_IMAGE_OUTPUT_BUFFERS) ?
1246                     self->img_port : self->vid_port;
1247
1248             G_OMX_PORT_GET_DEFINITION (port, &param);
1249
1250             g_value_set_uint (value, param.nBufferCountActual);
1251
1252             break;
1253         }
1254         case ARG_MODE:
1255         {
1256             GST_DEBUG_OBJECT (self, "mode: %d", self->mode);
1257             g_value_set_enum (value, self->mode);
1258             break;
1259         }
1260         case ARG_SHUTTER:
1261         {
1262             GST_DEBUG_OBJECT (self, "shutter: %d", self->shutter);
1263             g_value_set_enum (value, self->shutter);
1264             break;
1265         }
1266         case ARG_ZOOM:
1267         {
1268             gfloat zoom_value;
1269             gst_omx_camera_photography_get_zoom (photo, &zoom_value);
1270             g_value_set_float (value, zoom_value);
1271             break;
1272         }
1273         case ARG_FOCUS:
1274         {
1275             OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE config;
1276             GOmxCore *gomx;
1277             OMX_ERRORTYPE error_val = OMX_ErrorNone;
1278             gomx = (GOmxCore *) omx_base->gomx;
1279
1280             _G_OMX_INIT_PARAM (&config);
1281             error_val = OMX_GetConfig (gomx->omx_handle,
1282                                         OMX_IndexConfigFocusControl, &config);
1283             g_assert (error_val == OMX_ErrorNone);
1284             config.nPortIndex = omx_base->out_port->port_index;
1285             GST_DEBUG_OBJECT (self, "AF: param=%d port=%d", config.eFocusControl,
1286                                                             config.nPortIndex);
1287             g_value_set_enum (value, config.eFocusControl);
1288
1289             break;
1290         }
1291         case ARG_AWB:
1292         {
1293             OMX_WHITEBALCONTROLTYPE wb_enum_value;
1294
1295             gst_omx_camera_get_white_balance_mode (self, &wb_enum_value);
1296             g_value_set_enum (value, wb_enum_value);
1297             break;
1298         }
1299         case ARG_WHITE_BALANCE:
1300         {
1301             GstWhiteBalanceMode wb_enum_value;
1302
1303             gst_omx_camera_photography_get_white_balance_mode (photo,
1304                                                                &wb_enum_value);
1305             g_value_set_enum (value, wb_enum_value);
1306             break;
1307         }
1308         case ARG_CONTRAST:
1309         {
1310             gint contrast;
1311             gst_omx_camera_get_contrast (self, &contrast);
1312             g_value_set_int (value, contrast);
1313
1314             break;
1315         }
1316         case ARG_BRIGHTNESS:
1317         {
1318             gint brightness;
1319
1320             gst_omx_camera_get_brightness (self, &brightness);
1321             g_value_set_int (value, brightness);
1322             break;
1323         }
1324         case ARG_EXPOSURE:
1325         {
1326             OMX_CONFIG_EXPOSURECONTROLTYPE config;
1327             GOmxCore *gomx;
1328             OMX_ERRORTYPE error_val = OMX_ErrorNone;
1329             gomx = (GOmxCore *) omx_base->gomx;
1330
1331             _G_OMX_INIT_PARAM (&config);
1332             error_val = OMX_GetConfig (gomx->omx_handle,
1333                                        OMX_IndexConfigCommonExposure,
1334                                        &config);
1335             g_assert (error_val == OMX_ErrorNone);
1336             GST_DEBUG_OBJECT (self, "Exposure control = %d",
1337                               config.eExposureControl);
1338             g_value_set_enum (value, config.eExposureControl);
1339
1340             break;
1341         }
1342         case ARG_ISO:
1343         {
1344             guint iso_uint_value;
1345
1346             gst_omx_camera_photography_get_iso_speed (photo, &iso_uint_value);
1347             g_value_set_uint (value, iso_uint_value);
1348             break;
1349         }
1350         case ARG_ROTATION:
1351         {
1352             guint rotation;
1353
1354             gst_omx_camera_get_rotation (self, &rotation);
1355             g_value_set_uint (value, rotation);
1356             break;
1357         }
1358         case ARG_MIRROR:
1359         {
1360             OMX_MIRRORTYPE mirror;
1361
1362             gst_omx_camera_get_mirror (self, &mirror);
1363             g_value_set_enum (value, mirror);
1364             break;
1365         }
1366         case ARG_SATURATION:
1367         {
1368             gint saturation;
1369
1370             gst_omx_camera_get_contrast (self, &saturation);
1371             g_value_set_int (value, saturation);
1372             break;
1373         }
1374         case ARG_EXPOSUREVALUE:
1375         {
1376             gfloat float_value = 0;
1377             gst_omx_camera_photography_get_ev_compensation (photo, &float_value);
1378             break;
1379         }
1380         case ARG_EVCOMPENSATION:
1381         {
1382             gfloat float_value = 0;
1383             gst_omx_camera_photography_get_ev_compensation (photo, &float_value);
1384             break;
1385         }
1386         case ARG_MANUALFOCUS:
1387         {
1388             guint manual_focus;
1389
1390             gst_omx_camera_get_manual_focus (self, &manual_focus);
1391             g_value_set_uint (value, manual_focus);
1392             break;
1393         }
1394         case ARG_QFACTORJPEG:
1395         {
1396             guint qfactor;
1397
1398             gst_omx_camera_get_qfactor (self, &qfactor);
1399             g_value_set_uint (value, qfactor);
1400             break;
1401         }
1402
1403         /* Not implemented GstPhotography properties */
1404
1405         case ARG_APERTURE:
1406         case ARG_CAPABILITIES:
1407         case ARG_COLOUR_TONE:
1408         case ARG_FLASH_MODE:
1409         case ARG_FOCUS_MODE:
1410         case ARG_IMAGE_CAPTURE_SUPPORTED_CAPS:
1411         case ARG_IMAGE_PREVIEW_SUPPORTED_CAPS:
1412         case ARG_NOISE_REDUCTION:
1413             break;
1414 #ifdef USE_OMXTICORE
1415         case ARG_THUMBNAIL_WIDTH:
1416         {
1417             gst_omx_camera_get_thumbnail_width (self, &self->img_thumbnail_width);
1418             g_value_set_int (value, self->img_thumbnail_width);
1419             break;
1420         }
1421         case ARG_THUMBNAIL_HEIGHT:
1422         {
1423             gst_omx_camera_get_thumbnail_height (self, &self->img_thumbnail_height);
1424             g_value_set_int (value, self->img_thumbnail_height);
1425             break;
1426         }
1427         case ARG_FLICKER:
1428         {
1429             OMX_COMMONFLICKERCANCELTYPE flicker_enum_value;
1430
1431             gst_omx_camera_get_flicker_mode (GST_OMX_CAMERA (photo), &flicker_enum_value);
1432             g_value_set_enum (value, flicker_enum_value);
1433             break;
1434         }
1435         case ARG_FLICKER_MODE:
1436         {
1437             GstFlickerReductionMode flicker_enum_value;
1438
1439             gst_omx_camera_photography_get_flicker_mode (photo, &flicker_enum_value);
1440             g_value_set_enum (value, flicker_enum_value);
1441             break;
1442         }
1443         case ARG_SCENE:
1444         {
1445             OMX_SCENEMODETYPE scene_enum;
1446
1447             gst_omx_camera_get_scene_mode (self, &scene_enum);
1448             g_value_set_enum (value, scene_enum);
1449             break;
1450         }
1451         case ARG_SCENE_MODE:
1452         {
1453             GstSceneMode scene_enum;
1454
1455             gst_omx_camera_photography_get_scene_mode (photo, &scene_enum);
1456             g_value_set_enum (value, scene_enum);
1457             break;
1458         }
1459         case ARG_VNF:
1460         {
1461             OMX_VIDEONOISEFILTERMODETYPE vnf;
1462
1463             gst_omx_camera_get_vnf (self, &vnf);
1464             g_value_set_enum (value, vnf);
1465             break;
1466         }
1467         case ARG_YUV_RANGE:
1468         {
1469             OMX_VIDEOYUVRANGETYPE range;
1470
1471             gst_omx_camera_get_yuv_range (self, &range);
1472             g_value_set_enum (value, range);
1473             break;
1474         }
1475         case ARG_VSTAB:
1476         {
1477             OMX_CONFIG_BOOLEANTYPE param;
1478             OMX_CONFIG_FRAMESTABTYPE config;
1479
1480             G_OMX_CORE_GET_PARAM (omx_base->gomx, OMX_IndexParamFrameStabilisation, &param);
1481             G_OMX_CORE_GET_CONFIG (omx_base->gomx, OMX_IndexConfigCommonFrameStabilisation, &config);
1482
1483             GST_DEBUG_OBJECT (self, "vstab: param=%d, config=%d", param.bEnabled, config.bStab);
1484             g_value_set_boolean (value, param.bEnabled && config.bStab);
1485
1486             break;
1487         }
1488         case ARG_DEVICE:
1489         {
1490             OMX_CONFIG_SENSORSELECTTYPE config;
1491             GOmxCore *gomx;
1492             OMX_ERRORTYPE error_val = OMX_ErrorNone;
1493
1494             g_value_set_enum (value, self->device);
1495             gomx = (GOmxCore *) omx_base->gomx;
1496             _G_OMX_INIT_PARAM (&config);
1497             error_val = OMX_GetConfig (gomx->omx_handle,
1498                                        OMX_TI_IndexConfigSensorSelect, &config);
1499             g_assert (error_val == OMX_ErrorNone);
1500             GST_DEBUG_OBJECT (self, "Device src=%d", config.eSensor);
1501
1502             break;
1503         }
1504         case ARG_LDC:
1505         {
1506             gboolean ldc;
1507
1508             gst_omx_camera_get_ldc (self, &ldc);
1509             g_value_set_boolean (value, ldc);
1510             break;
1511         }
1512         case ARG_NSF:
1513         {
1514             OMX_VIDEONOISEFILTERMODETYPE nsf;
1515
1516             gst_omx_camera_get_nsf (self, &nsf);
1517             g_value_set_enum (value, nsf);
1518             break;
1519         }
1520         case ARG_MTIS:
1521         {
1522             gboolean mtis;
1523
1524             gst_omx_camera_get_mtis (self, &mtis);
1525             g_value_set_boolean (value, mtis);
1526             break;
1527         }
1528         case ARG_SENSOR_OVERCLOCK:
1529         {
1530             gboolean sensor_overclock;
1531
1532             gst_omx_camera_get_sensor_overclock (self, &sensor_overclock);
1533             g_value_set_boolean (value, sensor_overclock);
1534             break;
1535         }
1536         case ARG_WB_COLORTEMP:
1537         {
1538             guint wbct;
1539
1540             gst_omx_camera_get_white_balance_color_temperature (self, &wbct);
1541             g_value_set_uint (value, wbct);
1542             break;
1543         }
1544         case ARG_FOCUSSPOT_WEIGHT:
1545         {
1546             OMX_TI_CONFIG_FOCUSSPOTMODETYPE focus;
1547
1548             gst_omx_camera_get_focus_spot_weighting (self, &focus);
1549             g_value_set_enum (value, focus);
1550             break;
1551         }
1552         case ARG_SHARPNESS:
1553         {
1554             gint sharpness;
1555
1556             gst_omx_camera_get_sharpness (self, &sharpness);
1557             g_value_set_int (value, sharpness);
1558             break;
1559         }
1560         case ARG_CAC:
1561         {
1562             gboolean cac;
1563
1564             gst_omx_camera_get_cac (self, &cac);
1565             g_value_set_boolean (value, cac);
1566             break;
1567         }
1568         case ARG_GBCE:
1569         {
1570             OMX_TI_BRIGHTNESSCONTRASTCRTLTYPE gbce;
1571
1572             gst_omx_camera_get_gbce (self, &gbce);
1573             g_value_set_enum (value, gbce);
1574             break;
1575         }
1576         case ARG_GLBCE:
1577         {
1578             OMX_TI_BRIGHTNESSCONTRASTCRTLTYPE gbce;
1579
1580             gst_omx_camera_get_glbce (self, &gbce);
1581             g_value_set_enum (value, gbce);
1582             break;
1583         }
1584 #endif
1585         default:
1586         {
1587             G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
1588             break;
1589         }
1590     }
1591 }
1592
1593
1594 void
1595 install_camera_properties(GObjectClass *gobject_class)
1596 {
1597     g_object_class_install_property (gobject_class, ARG_NUM_IMAGE_OUTPUT_BUFFERS,
1598             g_param_spec_uint ("image-output-buffers", "Image port output buffers",
1599                     "The number of OMX image port output buffers",
1600                     1, 10, 4, G_PARAM_READWRITE));
1601     g_object_class_install_property (gobject_class, ARG_NUM_VIDEO_OUTPUT_BUFFERS,
1602             g_param_spec_uint ("video-output-buffers", "Video port output buffers",
1603                     "The number of OMX video port output buffers",
1604                     1, 10, 4, G_PARAM_READWRITE));
1605     g_object_class_install_property (gobject_class, ARG_MODE,
1606             g_param_spec_enum ("mode", "Camera Mode",
1607                     "image capture, video capture, or both",
1608                     GST_TYPE_OMX_CAMERA_MODE,
1609                     MODE_PREVIEW,
1610                     G_PARAM_READWRITE));
1611     g_object_class_install_property (gobject_class, ARG_SHUTTER,
1612             g_param_spec_enum ("shutter", "Shutter State",
1613                     "shutter button state",
1614                     GST_TYPE_OMX_CAMERA_SHUTTER,
1615                     SHUTTER_OFF,
1616                     G_PARAM_READWRITE));
1617     g_object_class_install_property (gobject_class, ARG_ZOOM,
1618             g_param_spec_float ("zoom", "Digital Zoom",
1619                     "digital zoom factor/level",
1620                     MIN_ZOOM_LEVEL, MAX_ZOOM_LEVEL, DEFAULT_ZOOM_LEVEL,
1621                     G_PARAM_READWRITE));
1622     g_object_class_install_property (gobject_class, ARG_FOCUS,
1623             g_param_spec_enum ("focus", "Auto Focus",
1624                     "auto focus state",
1625                     GST_TYPE_OMX_CAMERA_FOCUS,
1626                     DEFAULT_FOCUS,
1627                     G_PARAM_READWRITE));
1628     g_object_class_install_property (gobject_class, ARG_AWB,
1629             g_param_spec_enum ("awb", "Auto White Balance",
1630                     "auto white balance state",
1631                     GST_TYPE_OMX_CAMERA_AWB,
1632                     DEFAULT_AWB,
1633                     G_PARAM_READWRITE));
1634     g_object_class_install_property (gobject_class, ARG_CONTRAST,
1635             g_param_spec_int ("contrast", "Contrast",
1636                     "contrast level", MIN_CONTRAST_LEVEL,
1637                     MAX_CONTRAST_LEVEL, DEFAULT_CONTRAST_LEVEL,
1638                     G_PARAM_READWRITE));
1639     g_object_class_install_property (gobject_class, ARG_BRIGHTNESS,
1640             g_param_spec_int ("brightness", "Brightness",
1641                     "brightness level", MIN_BRIGHTNESS_LEVEL,
1642                     MAX_BRIGHTNESS_LEVEL, DEFAULT_BRIGHTNESS_LEVEL,
1643                     G_PARAM_READWRITE));
1644     g_object_class_install_property (gobject_class, ARG_EXPOSURE,
1645             g_param_spec_enum ("exposure", "Exposure Control",
1646                     "exposure control mode",
1647                     GST_TYPE_OMX_CAMERA_EXPOSURE,
1648                     DEFAULT_EXPOSURE,
1649                     G_PARAM_READWRITE));
1650     g_object_class_install_property (gobject_class, ARG_ISO,
1651             g_param_spec_uint ("iso-speed", "ISO Speed",
1652                     "ISO speed level", MIN_ISO_LEVEL,
1653                     MAX_ISO_LEVEL, DEFAULT_ISO_LEVEL,
1654                     G_PARAM_READWRITE));
1655     g_object_class_install_property (gobject_class, ARG_ROTATION,
1656             g_param_spec_uint ("rotation", "Rotation",
1657                     "Image rotation",
1658                     0, 270, DEFAULT_ROTATION , G_PARAM_READWRITE));
1659     g_object_class_install_property (gobject_class, ARG_MIRROR,
1660             g_param_spec_enum ("mirror", "Mirror",
1661                     "Mirror image",
1662                     GST_TYPE_OMX_CAMERA_MIRROR,
1663                     DEFAULT_MIRROR,
1664                     G_PARAM_READWRITE));
1665     g_object_class_install_property (gobject_class, ARG_SATURATION,
1666             g_param_spec_int ("saturation", "Saturation",
1667                     "Saturation level", MIN_SATURATION_VALUE,
1668                     MAX_SATURATION_VALUE, DEFAULT_SATURATION_VALUE,
1669                     G_PARAM_READWRITE));
1670     g_object_class_install_property (gobject_class, ARG_EXPOSUREVALUE,
1671             g_param_spec_float ("exposure-value", "Exposure value",
1672                     "EVCompensation level", MIN_EXPOSURE_VALUE,
1673                     MAX_EXPOSURE_VALUE, DEFAULT_EXPOSURE_VALUE,
1674                     G_PARAM_READWRITE));
1675     g_object_class_install_property (gobject_class, ARG_MANUALFOCUS,
1676             g_param_spec_uint ("manual-focus", "Manual Focus",
1677                     "Manual focus level, 0:Infinity  100:Macro",
1678                     MIN_MANUALFOCUS, MAX_MANUALFOCUS, DEFAULT_MANUALFOCUS,
1679                     G_PARAM_READWRITE));
1680     g_object_class_install_property (gobject_class, ARG_QFACTORJPEG,
1681             g_param_spec_uint ("qfactor", "Q Factor JPEG",
1682                     "JPEG Q Factor level, 1:Highest compression  100:Best quality",
1683                     MIN_QFACTORJPEG, MAX_QFACTORJPEG, DEFAULT_QFACTORJPEG,
1684                     G_PARAM_READWRITE));
1685
1686     /* GstPhotography properties*/
1687
1688     g_object_class_install_property (gobject_class, ARG_WHITE_BALANCE,
1689             g_param_spec_enum ("white-balance-mode",
1690                     "GstPhotography White Balance",
1691                     "Auto white balance state as defined in GstPhotography",
1692                     GST_TYPE_WHITE_BALANCE_MODE,
1693                     GST_PHOTOGRAPHY_WB_MODE_AUTO,
1694                     G_PARAM_READWRITE));
1695     g_object_class_install_property (gobject_class, ARG_EVCOMPENSATION,
1696             g_param_spec_float ("ev-compensation", "Exposure compensation",
1697                     "Exposure Value Compensation level",
1698                     -2.5, 2.5, DEFAULT_EXPOSURE_VALUE,
1699                     G_PARAM_READWRITE));
1700     g_object_class_install_property (gobject_class, ARG_FLICKER_MODE,
1701             g_param_spec_enum ("flicker-mode", "Photography Flicker Control",
1702                     "flicker control state as described in GstPhotography",
1703                     GST_TYPE_FLICKER_REDUCTION_MODE,
1704                     GST_PHOTOGRAPHY_FLICKER_REDUCTION_OFF,
1705                     G_PARAM_READWRITE));
1706     g_object_class_install_property (gobject_class, ARG_SCENE_MODE,
1707             g_param_spec_enum ("scene-mode", "GstPhotography Scene Mode",
1708                     "Scene mode as in GstPhotography",
1709                     GST_TYPE_SCENE_MODE,
1710                     GST_PHOTOGRAPHY_SCENE_MODE_AUTO,
1711                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1712     g_object_class_install_property (gobject_class, ARG_APERTURE,
1713             g_param_spec_uint ("aperture", "GstPhotography Aperture",
1714                     "Aperture as in GstPhotography",
1715                     0, 255, 0,
1716                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1717     g_object_class_install_property (gobject_class, ARG_CAPABILITIES,
1718             g_param_spec_ulong ("capabilities",
1719                     "GstPhotography capabilities property",
1720                     "Capabilities as in GstPhotography",
1721                     0, G_MAXULONG, 0,
1722                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1723     g_object_class_install_property (gobject_class, ARG_COLOUR_TONE,
1724             g_param_spec_enum ("colour-tone-mode",
1725                     "GstPhotography colour tone mode",
1726                     "Mode of colour tone as in GstPhotography",
1727                     GST_TYPE_COLOUR_TONE_MODE,
1728                     GST_PHOTOGRAPHY_COLOUR_TONE_MODE_NORMAL,
1729                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1730     g_object_class_install_property (gobject_class, ARG_FLASH_MODE,
1731             g_param_spec_enum ("flash-mode",
1732                     "GstPhotography flash mode",
1733                     "Flash mode as in GstPhotography",
1734                     GST_TYPE_FLASH_MODE,
1735                     GST_PHOTOGRAPHY_FLASH_MODE_AUTO,
1736                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1737     g_object_class_install_property (gobject_class, ARG_FOCUS_MODE,
1738             g_param_spec_enum ("focus-mode",
1739                     "GstPhotography focus mode",
1740                     "Focus mode as in GstPhotography",
1741                     GST_TYPE_FOCUS_MODE,
1742                     GST_PHOTOGRAPHY_FOCUS_MODE_AUTO,
1743                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1744     g_object_class_install_property (gobject_class,
1745             ARG_IMAGE_CAPTURE_SUPPORTED_CAPS,
1746             g_param_spec_boxed ("image-capture-supported-caps",
1747                     "GstPhotography image capture supported caps",
1748                     "Caps describing supported image capture formats",
1749                     GST_TYPE_CAPS,
1750                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1751     g_object_class_install_property (gobject_class,
1752             ARG_IMAGE_PREVIEW_SUPPORTED_CAPS,
1753             g_param_spec_boxed ("image-preview-supported-caps",
1754                     "GstPhotography image preview supported caps",
1755                     "Caps describing supported image preview formats",
1756                     GST_TYPE_CAPS,
1757                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1758     g_object_class_install_property (gobject_class, ARG_NOISE_REDUCTION,
1759             g_param_spec_flags ("noise-reduction",
1760                     "GstPhotography noise reduction",
1761                     "Which noise reduction modes are enabled (0 = disabled)",
1762                     GST_TYPE_PHOTOGRAPHY_NOISE_REDUCTION,
1763                     0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1764
1765 #ifdef USE_OMXTICORE
1766     g_object_class_install_property (gobject_class, ARG_THUMBNAIL_WIDTH,
1767             g_param_spec_int ("thumb-width", "Thumbnail width",
1768                     "Thumbnail width in pixels", MIN_THUMBNAIL_LEVEL,
1769                     MAX_THUMBNAIL_LEVEL, DEFAULT_THUMBNAIL_WIDTH,
1770                     G_PARAM_READWRITE));
1771     g_object_class_install_property (gobject_class, ARG_THUMBNAIL_HEIGHT,
1772             g_param_spec_int ("thumb-height", "Thumbnail height",
1773                     "Thumbnail height in pixels", MIN_THUMBNAIL_LEVEL,
1774                     MAX_THUMBNAIL_LEVEL, DEFAULT_THUMBNAIL_HEIGHT,
1775                     G_PARAM_READWRITE));
1776     g_object_class_install_property (gobject_class, ARG_FLICKER,
1777             g_param_spec_enum ("flicker", "Flicker Control",
1778                     "flicker control state",
1779                     GST_TYPE_OMX_CAMERA_FLICKER,
1780                     DEFAULT_FLICKER,
1781                     G_PARAM_READWRITE));
1782     g_object_class_install_property (gobject_class, ARG_SCENE,
1783             g_param_spec_enum ("scene", "Scene Mode",
1784                     "Scene mode",
1785                     GST_TYPE_OMX_CAMERA_SCENE,
1786                     DEFAULT_SCENE,
1787                     G_PARAM_READWRITE));
1788     g_object_class_install_property (gobject_class, ARG_VNF,
1789             g_param_spec_enum ("vnf", "Video Noise Filter",
1790                     "is video noise filter algorithm enabled?",
1791                     GST_TYPE_OMX_CAMERA_VNF,
1792                     DEFAULT_VNF,
1793                     G_PARAM_READWRITE));
1794     g_object_class_install_property (gobject_class, ARG_YUV_RANGE,
1795             g_param_spec_enum ("yuv-range", "YUV Range",
1796                     "YUV Range",
1797                     GST_TYPE_OMX_CAMERA_YUV_RANGE,
1798                     DEFAULT_YUV_RANGE,
1799                     G_PARAM_READWRITE));
1800     g_object_class_install_property (gobject_class, ARG_VSTAB,
1801             g_param_spec_boolean ("vstab", "Video Frame Stabilization",
1802                     "is video stabilization algorithm enabled?",
1803                     TRUE,
1804                     G_PARAM_READWRITE));
1805     g_object_class_install_property (gobject_class, ARG_DEVICE,
1806             g_param_spec_enum ("device", "Camera sensor",
1807                     "Image and video stream source",
1808                     GST_TYPE_OMX_CAMERA_DEVICE,
1809                     DEFAULT_DEVICE,
1810                     G_PARAM_READWRITE));
1811     g_object_class_install_property (gobject_class, ARG_LDC,
1812             g_param_spec_boolean ("ldc", "Lens Distortion Correction",
1813                     "Lens Distortion Correction state",
1814                     FALSE,
1815                     G_PARAM_READWRITE));
1816     g_object_class_install_property (gobject_class, ARG_NSF,
1817             g_param_spec_enum ("nsf", "ISO noise suppression filter",
1818                     "low light environment noise filter",
1819                     GST_TYPE_OMX_CAMERA_NSF,
1820                     DEFAULT_NSF,
1821                     G_PARAM_READWRITE));
1822     g_object_class_install_property (gobject_class, ARG_MTIS,
1823             g_param_spec_boolean ("mtis", "Motion triggered image stabilisation mode",
1824                     "Motion triggered image stabilisation mode",
1825                     FALSE,
1826                     G_PARAM_READWRITE));
1827     g_object_class_install_property (gobject_class, ARG_SENSOR_OVERCLOCK,
1828             g_param_spec_boolean ("overclock", "Sensor over-clock mode",
1829                     "Sensor over-clock mode",
1830                     FALSE,
1831                     G_PARAM_READWRITE));
1832     g_object_class_install_property (gobject_class, ARG_WB_COLORTEMP,
1833             g_param_spec_uint ("wb-colortemp",
1834                     "White Balance Color Temperature",
1835                     "White balance color temperature", MIN_WB_COLORTEMP_VALUE,
1836                     MAX_WB_COLORTEMP_VALUE, DEFAULT_WB_COLORTEMP_VALUE,
1837                     G_PARAM_READWRITE));
1838     g_object_class_install_property (gobject_class, ARG_FOCUSSPOT_WEIGHT,
1839             g_param_spec_enum ("focusweight", "Focus Spot Weight mode",
1840                     "Focus spot weight mode",
1841                     GST_TYPE_OMX_CAMERA_FOCUSSPOT_WEIGHT,
1842                     DEFAULT_FOCUSSPOT_WEIGHT,
1843                     G_PARAM_READWRITE));
1844     g_object_class_install_property (gobject_class, ARG_SHARPNESS,
1845             g_param_spec_int ("sharpness", "Sharpness value",
1846                     "Sharpness value, 0:automatic mode)", MIN_SHARPNESS_VALUE,
1847                     MAX_SHARPNESS_VALUE, DEFAULT_SHARPNESS_VALUE,
1848                     G_PARAM_READWRITE));
1849     g_object_class_install_property (gobject_class, ARG_CAC,
1850             g_param_spec_boolean ("cac", "Chromatic Aberration Correction",
1851                     "Chromatic Aberration Correction state",
1852                     FALSE,
1853                     G_PARAM_READWRITE));
1854     g_object_class_install_property (gobject_class, ARG_GBCE,
1855             g_param_spec_enum ("gbce", "Global Brightness Contrast Enhance",
1856                     "global brightness contrast enhance",
1857                     GST_TYPE_OMX_CAMERA_BCE,
1858                     DEFAULT_GBCE,
1859                     G_PARAM_READWRITE));
1860     g_object_class_install_property (gobject_class, ARG_GLBCE,
1861             g_param_spec_enum ("lbce", "Local Brightness Contrast Enhance",
1862                     "local brightness contrast enhance",
1863                     GST_TYPE_OMX_CAMERA_BCE,
1864                     DEFAULT_GLBCE,
1865                     G_PARAM_READWRITE));
1866 #endif
1867
1868 }
1869
1870 void
1871 gst_omx_camera_setup_stereo (GstOmxCamera * self)
1872 {
1873     GstOmxBaseSrc *omx_base;
1874     GOmxPort *port;
1875     OMX_TI_FRAMELAYOUTTYPE frameLayout;
1876     OMX_TI_CONFIG_CONVERGENCETYPE acParams;
1877
1878     omx_base = GST_OMX_BASE_SRC (self);
1879     port = omx_base->out_port;
1880
1881     _G_OMX_INIT_PARAM(&frameLayout);
1882     frameLayout.nPortIndex = port->port_index;
1883     frameLayout.eFrameLayout = OMX_TI_StereoFrameLayoutLeftRight;
1884     frameLayout.nSubsampleRatio = 1 << 7; /* in Q15.7 format */
1885     G_OMX_CORE_SET_PARAM (omx_base->gomx,
1886         OMX_TI_IndexParamStereoFrmLayout, &frameLayout);
1887
1888     _G_OMX_INIT_PARAM(&acParams);
1889     acParams.nPortIndex = port->port_index;
1890     acParams.nManualConverence = 0;
1891     acParams.eACMode = OMX_TI_AutoConvergenceModeDisable;
1892     G_OMX_CORE_SET_CONFIG (omx_base->gomx,
1893         OMX_TI_IndexConfigAutoConvergence, &acParams);
1894 }
1895
1896
1897
1898
1899