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