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