1/*
2Copyright (c) 2012, Broadcom Europe Ltd
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the copyright holder nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#include "mmalomx.h"
29#include "mmalomx_util_params_common.h"
30#include "mmalomx_logging.h"
31
32static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_awb_mode[] = {
33 {MMAL_PARAM_AWBMODE_OFF, OMX_WhiteBalControlOff},
34 {MMAL_PARAM_AWBMODE_AUTO, OMX_WhiteBalControlAuto},
35 {MMAL_PARAM_AWBMODE_SUNLIGHT, OMX_WhiteBalControlSunLight},
36 {MMAL_PARAM_AWBMODE_CLOUDY, OMX_WhiteBalControlCloudy},
37 {MMAL_PARAM_AWBMODE_SHADE, OMX_WhiteBalControlShade},
38 {MMAL_PARAM_AWBMODE_TUNGSTEN, OMX_WhiteBalControlTungsten},
39 {MMAL_PARAM_AWBMODE_FLUORESCENT, OMX_WhiteBalControlFluorescent},
40 {MMAL_PARAM_AWBMODE_INCANDESCENT,OMX_WhiteBalControlIncandescent},
41 {MMAL_PARAM_AWBMODE_FLASH, OMX_WhiteBalControlFlash},
42 {MMAL_PARAM_AWBMODE_HORIZON, OMX_WhiteBalControlHorizon},
43 {MMAL_PARAM_AWBMODE_GREYWORLD, OMX_WhiteBalControlGreyWorld},
44};
45
46static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_image_effect[] = {
47 {MMAL_PARAM_IMAGEFX_NONE, OMX_ImageFilterNone},
48 {MMAL_PARAM_IMAGEFX_NEGATIVE, OMX_ImageFilterNegative},
49 {MMAL_PARAM_IMAGEFX_SOLARIZE, OMX_ImageFilterSolarize},
50 {MMAL_PARAM_IMAGEFX_SKETCH, OMX_ImageFilterSketch},
51 {MMAL_PARAM_IMAGEFX_DENOISE, OMX_ImageFilterNoise},
52 {MMAL_PARAM_IMAGEFX_EMBOSS, OMX_ImageFilterEmboss},
53 {MMAL_PARAM_IMAGEFX_OILPAINT, OMX_ImageFilterOilPaint},
54 {MMAL_PARAM_IMAGEFX_HATCH, OMX_ImageFilterHatch},
55 {MMAL_PARAM_IMAGEFX_GPEN, OMX_ImageFilterGpen},
56 {MMAL_PARAM_IMAGEFX_PASTEL, OMX_ImageFilterPastel},
57 {MMAL_PARAM_IMAGEFX_WATERCOLOUR, OMX_ImageFilterWatercolor},
58 {MMAL_PARAM_IMAGEFX_FILM, OMX_ImageFilterFilm},
59 {MMAL_PARAM_IMAGEFX_BLUR, OMX_ImageFilterBlur},
60 {MMAL_PARAM_IMAGEFX_SATURATION, OMX_ImageFilterSaturation},
61 {MMAL_PARAM_IMAGEFX_COLOURSWAP, OMX_ImageFilterColourSwap},
62 {MMAL_PARAM_IMAGEFX_WASHEDOUT, OMX_ImageFilterWashedOut},
63 {MMAL_PARAM_IMAGEFX_POSTERISE, OMX_ImageFilterPosterise},
64 {MMAL_PARAM_IMAGEFX_COLOURPOINT, OMX_ImageFilterColourPoint},
65 {MMAL_PARAM_IMAGEFX_COLOURBALANCE, OMX_ImageFilterColourBalance},
66 {MMAL_PARAM_IMAGEFX_CARTOON, OMX_ImageFilterCartoon},
67};
68
69static MMAL_STATUS_T mmalomx_param_mapping_colour_effect(MMALOMX_PARAM_MAPPING_DIRECTION dir,
70 MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param)
71{
72 OMX_CONFIG_COLORENHANCEMENTTYPE *omx = (OMX_CONFIG_COLORENHANCEMENTTYPE *)omx_param;
73 MMAL_PARAMETER_COLOURFX_T *mmal = (MMAL_PARAMETER_COLOURFX_T *)mmal_param;
74
75 if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL)
76 {
77 mmal->enable = omx->bColorEnhancement;
78 mmal->u = omx->nCustomizedU;
79 mmal->v = omx->nCustomizedV;
80 }
81 else
82 {
83 omx->bColorEnhancement = mmal->enable;
84 omx->nCustomizedU = mmal->u;
85 omx->nCustomizedV = mmal->v;
86 }
87
88 return MMAL_SUCCESS;
89}
90
91static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_flicker_avoid[] = {
92 {MMAL_PARAM_FLICKERAVOID_OFF, OMX_COMMONFLICKERCANCEL_OFF},
93 {MMAL_PARAM_FLICKERAVOID_AUTO, OMX_COMMONFLICKERCANCEL_AUTO},
94 {MMAL_PARAM_FLICKERAVOID_50HZ, OMX_COMMONFLICKERCANCEL_50},
95 {MMAL_PARAM_FLICKERAVOID_60HZ, OMX_COMMONFLICKERCANCEL_60},
96};
97
98static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_flash[] = {
99 {MMAL_PARAM_FLASH_OFF, OMX_IMAGE_FlashControlOff},
100 {MMAL_PARAM_FLASH_AUTO, OMX_IMAGE_FlashControlAuto},
101 {MMAL_PARAM_FLASH_ON, OMX_IMAGE_FlashControlOn},
102 {MMAL_PARAM_FLASH_REDEYE, OMX_IMAGE_FlashControlRedEyeReduction},
103 {MMAL_PARAM_FLASH_FILLIN, OMX_IMAGE_FlashControlFillin},
104 {MMAL_PARAM_FLASH_TORCH, OMX_IMAGE_FlashControlTorch},
105};
106
107static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_redeye[] = {
108 {MMAL_PARAM_REDEYE_OFF, OMX_RedEyeRemovalNone},
109 {MMAL_PARAM_REDEYE_ON, OMX_RedEyeRemovalOn},
110 {MMAL_PARAM_REDEYE_ON, OMX_RedEyeRemovalAuto},
111 {MMAL_PARAM_REDEYE_SIMPLE, OMX_RedEyeRemovalSimple}
112};
113
114static MMAL_STATUS_T mmalomx_param_mapping_focus(MMALOMX_PARAM_MAPPING_DIRECTION dir,
115 MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param)
116{
117 static const struct MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_focus[] = {
118 {MMAL_PARAM_FOCUS_AUTO, OMX_IMAGE_FocusControlAutoLock},
119 {MMAL_PARAM_FOCUS_CAF, OMX_IMAGE_FocusControlAuto},
120 {MMAL_PARAM_FOCUS_FIXED_INFINITY, OMX_IMAGE_FocusControlInfinityFixed},
121 {MMAL_PARAM_FOCUS_FIXED_HYPERFOCAL, OMX_IMAGE_FocusControlHyperfocal},
122 {MMAL_PARAM_FOCUS_FIXED_NEAR, OMX_IMAGE_FocusControlNearFixed},
123 {MMAL_PARAM_FOCUS_FIXED_MACRO, OMX_IMAGE_FocusControlMacroFixed},
124 {MMAL_PARAM_FOCUS_AUTO_MACRO, OMX_IMAGE_FocusControlAutoLockMacro},
125 {MMAL_PARAM_FOCUS_AUTO_NEAR, OMX_IMAGE_FocusControlAutoLock},
126 {MMAL_PARAM_FOCUS_CAF_NEAR, OMX_IMAGE_FocusControlAutoNear},
127 {MMAL_PARAM_FOCUS_CAF_MACRO, OMX_IMAGE_FocusControlAutoMacro},
128 {MMAL_PARAM_FOCUS_CAF_FAST, OMX_IMAGE_FocusControlAutoFast},
129 {MMAL_PARAM_FOCUS_CAF_MACRO_FAST, OMX_IMAGE_FocusControlAutoMacroFast},
130 {MMAL_PARAM_FOCUS_CAF_NEAR_FAST, OMX_IMAGE_FocusControlAutoNearFast},
131 /* {MMAL_PARAM_FOCUS_EDOF, ???}, */
132 };
133 OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE *omx = (OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE *)omx_param;
134 MMAL_PARAMETER_FOCUS_T *mmal = (MMAL_PARAMETER_FOCUS_T *)mmal_param;
135 MMALOMX_PARAM_ENUM_FIND(struct MMALOMX_PARAM_ENUM_TRANSLATE_T, xlat_enum, mmalomx_param_enum_focus,
136 dir, mmal->value, omx->eFocusControl);
137
138 if (!xlat_enum)
139 return MMAL_EINVAL;
140
141 if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL)
142 {
143 mmal->value = xlat_enum->mmal;
144 }
145 else
146 {
147 omx->eFocusControl = xlat_enum->omx;
148 omx->nFocusStepIndex = -1;
149 }
150
151 return MMAL_SUCCESS;
152}
153
154static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_mirror[] = {
155 {MMAL_PARAM_MIRROR_NONE, OMX_MirrorNone},
156 {MMAL_PARAM_MIRROR_VERTICAL, OMX_MirrorVertical},
157 {MMAL_PARAM_MIRROR_HORIZONTAL, OMX_MirrorHorizontal},
158 {MMAL_PARAM_MIRROR_BOTH, OMX_MirrorBoth}
159};
160
161static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_exposure_mode[] = {
162 {MMAL_PARAM_EXPOSUREMODE_OFF, OMX_ExposureControlOff},
163 {MMAL_PARAM_EXPOSUREMODE_AUTO, OMX_ExposureControlAuto},
164 {MMAL_PARAM_EXPOSUREMODE_NIGHT, OMX_ExposureControlNight},
165 {MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW, OMX_ExposureControlNightWithPreview},
166 {MMAL_PARAM_EXPOSUREMODE_BACKLIGHT, OMX_ExposureControlBackLight},
167 {MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT, OMX_ExposureControlSpotLight},
168 {MMAL_PARAM_EXPOSUREMODE_SPORTS, OMX_ExposureControlSports},
169 {MMAL_PARAM_EXPOSUREMODE_SNOW, OMX_ExposureControlSnow},
170 {MMAL_PARAM_EXPOSUREMODE_BEACH, OMX_ExposureControlBeach},
171 {MMAL_PARAM_EXPOSUREMODE_VERYLONG, OMX_ExposureControlVeryLong},
172 {MMAL_PARAM_EXPOSUREMODE_FIXEDFPS, OMX_ExposureControlFixedFps},
173 {MMAL_PARAM_EXPOSUREMODE_ANTISHAKE, OMX_ExposureControlAntishake},
174 {MMAL_PARAM_EXPOSUREMODE_FIREWORKS, OMX_ExposureControlFireworks},
175};
176
177static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_capture_status[] = {
178 {MMAL_PARAM_CAPTURE_STATUS_NOT_CAPTURING, OMX_NotCapturing},
179 {MMAL_PARAM_CAPTURE_STATUS_CAPTURE_STARTED, OMX_CaptureStarted},
180 {MMAL_PARAM_CAPTURE_STATUS_CAPTURE_ENDED, OMX_CaptureComplete},
181};
182
183static MMAL_STATUS_T mmalomx_param_mapping_face_track(MMALOMX_PARAM_MAPPING_DIRECTION dir,
184 MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param)
185{
186 static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_face_track[] = {
187 {MMAL_PARAM_FACE_DETECT_NONE, OMX_FaceDetectionControlNone},
188 {MMAL_PARAM_FACE_DETECT_ON, OMX_FaceDetectionControlOn},
189 };
190 OMX_CONFIG_FACEDETECTIONCONTROLTYPE *omx = (OMX_CONFIG_FACEDETECTIONCONTROLTYPE *)omx_param;
191 MMAL_PARAMETER_FACE_TRACK_T *mmal = (MMAL_PARAMETER_FACE_TRACK_T *)mmal_param;
192 MMALOMX_PARAM_ENUM_FIND(MMALOMX_PARAM_ENUM_TRANSLATE_T, xenum, mmalomx_param_enum_face_track,
193 dir, mmal->mode, omx->eMode);
194
195 if (!xenum)
196 return MMAL_EINVAL;
197
198 if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL)
199 {
200 mmal->mode = xenum->mmal;
201 mmal->maxRegions = omx->nMaxRegions;
202 mmal->frames = omx->nFrames;
203 mmal->quality = omx->nQuality;
204 }
205 else
206 {
207 omx->eMode = xenum->omx;
208 omx->nMaxRegions = mmal->maxRegions;
209 omx->nFrames = mmal->frames;
210 omx->nQuality = mmal->quality;
211 }
212
213 return MMAL_SUCCESS;
214}
215
216static MMAL_STATUS_T mmalomx_param_mapping_thumb_cfg(MMALOMX_PARAM_MAPPING_DIRECTION dir,
217 MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param)
218{
219 OMX_PARAM_BRCMTHUMBNAILTYPE *omx = (OMX_PARAM_BRCMTHUMBNAILTYPE *)omx_param;
220 MMAL_PARAMETER_THUMBNAIL_CONFIG_T *mmal = (MMAL_PARAMETER_THUMBNAIL_CONFIG_T *)mmal_param;
221
222 if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL)
223 {
224 mmal->enable = !!omx->bEnable;
225 mmal->width = omx->nWidth;
226 mmal->height = omx->nHeight;
227 mmal->quality = 0;
228 }
229 else
230 {
231 omx->bEnable = mmal->enable ? OMX_TRUE : OMX_FALSE;
232 omx->bUsePreview = OMX_FALSE;
233 omx->nWidth = mmal->width;
234 omx->nHeight = mmal->height;
235 /* We don't have an API for setting the thumbnail quality */
236 }
237
238 return MMAL_SUCCESS;
239}
240
241static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_stc[] = {
242 {MMAL_PARAM_STC_MODE_OFF, OMX_TimestampModeZero},
243 {MMAL_PARAM_STC_MODE_RAW, OMX_TimestampModeRawStc},
244 {MMAL_PARAM_STC_MODE_COOKED, OMX_TimestampModeResetStc},
245};
246
247static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_capture_mode[] = {
248 {MMAL_PARAM_CAPTUREMODE_WAIT_FOR_END, OMX_CameraCaptureModeWaitForCaptureEnd},
249 {MMAL_PARAM_CAPTUREMODE_RESUME_VF_IMMEDIATELY, OMX_CameraCaptureModeResumeViewfinderImmediately},
250 /*{MMAL_PARAM_CAPTUREMODE_WAIT_FOR_END_AND_HOLD, OMX_CameraCaptureModeWaitForCaptureEndAndUsePreviousInputImage}, Don't enable for now as not working */
251};
252
253static MMAL_STATUS_T mmalomx_param_mapping_sensor_info(MMALOMX_PARAM_MAPPING_DIRECTION dir,
254 MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param)
255{
256 OMX_CONFIG_CAMERAINFOTYPE *omx = (OMX_CONFIG_CAMERAINFOTYPE *)omx_param;
257 MMAL_PARAMETER_SENSOR_INFORMATION_T *mmal = (MMAL_PARAMETER_SENSOR_INFORMATION_T *)mmal_param;
258
259 if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL)
260 {
261 mmal->f_number = mmal_rational_from_fixed_16_16(omx->xFNumber);
262 mmal->focal_length = mmal_rational_from_fixed_16_16(omx->xFocalLength);
263 mmal->model_id = omx->nModelId;
264 mmal->manufacturer_id = omx->nManufacturerId;
265 mmal->revision = omx->nRevNum;
266 }
267 else
268 {
269 omx->xFNumber = mmal_rational_to_fixed_16_16(mmal->f_number);
270 omx->xFocalLength = mmal_rational_to_fixed_16_16(mmal->focal_length);
271 omx->nModelId = mmal->model_id;
272 omx->nManufacturerId = mmal->manufacturer_id;
273 omx->nRevNum = mmal->revision;
274 }
275
276 return MMAL_SUCCESS;
277}
278
279static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_flash_select[] = {
280 {MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_XENON, OMX_CameraFlashXenon},
281 {MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_LED, OMX_CameraFlashLED},
282 {MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_OTHER, OMX_CameraFlashNone},
283};
284
285static MMAL_STATUS_T mmalomx_param_mapping_fov(MMALOMX_PARAM_MAPPING_DIRECTION dir,
286 MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param)
287{
288 OMX_CONFIG_BRCMFOVTYPE *omx = (OMX_CONFIG_BRCMFOVTYPE *)omx_param;
289 MMAL_PARAMETER_FIELD_OF_VIEW_T *mmal = (MMAL_PARAMETER_FIELD_OF_VIEW_T *)mmal_param;
290
291 if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL)
292 {
293 mmal->fov_h = mmal_rational_from_fixed_16_16(omx->xFieldOfViewHorizontal);
294 mmal->fov_v = mmal_rational_from_fixed_16_16(omx->xFieldOfViewVertical);
295 }
296 else
297 {
298 omx->xFieldOfViewHorizontal = mmal_rational_to_fixed_16_16(mmal->fov_h);
299 omx->xFieldOfViewVertical = mmal_rational_to_fixed_16_16(mmal->fov_v);
300 }
301
302 return MMAL_SUCCESS;
303}
304
305static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_drc[] = {
306 {MMAL_PARAMETER_DRC_STRENGTH_OFF, OMX_DynRangeExpOff},
307 {MMAL_PARAMETER_DRC_STRENGTH_LOW, OMX_DynRangeExpLow},
308 {MMAL_PARAMETER_DRC_STRENGTH_MEDIUM, OMX_DynRangeExpMedium},
309 {MMAL_PARAMETER_DRC_STRENGTH_HIGH, OMX_DynRangeExpHigh},
310};
311
312static MMAL_STATUS_T mmalomx_param_mapping_algo_ctrl(MMALOMX_PARAM_MAPPING_DIRECTION dir,
313 MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param)
314{
315 static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_algo_ctrl[] = {
316 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_FACETRACKING, OMX_CameraDisableAlgorithmFacetracking},
317 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_REDEYE_REDUCTION, OMX_CameraDisableAlgorithmRedEyeReduction},
318 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_VIDEO_STABILISATION, OMX_CameraDisableAlgorithmVideoStabilisation},
319 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_WRITE_RAW, OMX_CameraDisableAlgorithmWriteRaw},
320 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_VIDEO_DENOISE, OMX_CameraDisableAlgorithmVideoDenoise},
321 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_STILLS_DENOISE, OMX_CameraDisableAlgorithmStillsDenoise},
322 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_TEMPORAL_DENOISE, OMX_CameraDisableAlgorithmMax},
323 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_ANTISHAKE, OMX_CameraDisableAlgorithmAntiShake},
324 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_IMAGE_EFFECTS, OMX_CameraDisableAlgorithmImageEffects},
325 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_DYNAMIC_RANGE_COMPRESSION,OMX_CameraDisableAlgorithmDynamicRangeExpansion},
326 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_FACE_RECOGNITION, OMX_CameraDisableAlgorithmFaceRecognition},
327 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_FACE_BEAUTIFICATION, OMX_CameraDisableAlgorithmFaceBeautification},
328 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_SCENE_DETECTION, OMX_CameraDisableAlgorithmSceneDetection},
329 { MMAL_PARAMETER_ALGORITHM_CONTROL_ALGORITHMS_HIGH_DYNAMIC_RANGE, OMX_CameraDisableAlgorithmHighDynamicRange},
330 };
331 OMX_PARAM_CAMERADISABLEALGORITHMTYPE *omx = (OMX_PARAM_CAMERADISABLEALGORITHMTYPE *)omx_param;
332 MMAL_PARAMETER_ALGORITHM_CONTROL_T *mmal = (MMAL_PARAMETER_ALGORITHM_CONTROL_T *)mmal_param;
333 MMALOMX_PARAM_ENUM_FIND(MMALOMX_PARAM_ENUM_TRANSLATE_T, xenum, mmalomx_param_enum_algo_ctrl,
334 dir, mmal->algorithm, omx->eAlgorithm);
335
336 if (!xenum)
337 return MMAL_EINVAL;
338
339 if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL)
340 {
341 mmal->algorithm = xenum->mmal;
342 mmal->enabled = !omx->bDisabled;
343 }
344 else
345 {
346 omx->eAlgorithm = xenum->omx;
347 omx->bDisabled = !mmal->enabled;
348 }
349
350 return MMAL_SUCCESS;
351}
352
353static MMAL_STATUS_T mmalomx_param_mapping_image_effect_params(MMALOMX_PARAM_MAPPING_DIRECTION dir,
354 MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param)
355{
356 OMX_CONFIG_IMAGEFILTERPARAMSTYPE *omx = (OMX_CONFIG_IMAGEFILTERPARAMSTYPE *)omx_param;
357 MMAL_PARAMETER_IMAGEFX_PARAMETERS_T *mmal = (MMAL_PARAMETER_IMAGEFX_PARAMETERS_T *)mmal_param;
358 MMALOMX_PARAM_ENUM_FIND(MMALOMX_PARAM_ENUM_TRANSLATE_T, xenum, mmalomx_param_enum_image_effect,
359 dir, mmal->effect, omx->eImageFilter);
360
361 if (!xenum)
362 return MMAL_EINVAL;
363
364 if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL)
365 {
366 if (omx->nNumParams > MMAL_COUNTOF(mmal->effect_parameter))
367 return MMAL_EINVAL;
368 mmal->effect = xenum->mmal;
369 mmal->num_effect_params = omx->nNumParams;
370 memcpy(mmal->effect_parameter, omx->nParams, sizeof(uint32_t) * omx->nNumParams);
371 }
372 else
373 {
374 if (mmal->num_effect_params > MMAL_COUNTOF(omx->nParams))
375 return MMAL_EINVAL;
376 omx->eImageFilter = xenum->omx;
377 omx->nNumParams = mmal->num_effect_params;
378 memcpy(omx->nParams, mmal->effect_parameter, sizeof(uint32_t) * omx->nNumParams);
379 }
380
381 return MMAL_SUCCESS;
382}
383
384static const MMALOMX_PARAM_ENUM_TRANSLATE_T mmalomx_param_enum_use_case[] = {
385 {MMAL_PARAM_CAMERA_USE_CASE_UNKNOWN, OMX_CameraUseCaseAuto},
386 {MMAL_PARAM_CAMERA_USE_CASE_STILLS_CAPTURE, OMX_CameraUseCaseStills},
387 {MMAL_PARAM_CAMERA_USE_CASE_VIDEO_CAPTURE, OMX_CameraUseCaseVideo},
388};
389
390static MMAL_STATUS_T mmalomx_param_mapping_fps_range(MMALOMX_PARAM_MAPPING_DIRECTION dir,
391 MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param)
392{
393 OMX_PARAM_BRCMFRAMERATERANGETYPE *omx = (OMX_PARAM_BRCMFRAMERATERANGETYPE *)omx_param;
394 MMAL_PARAMETER_FPS_RANGE_T *mmal = (MMAL_PARAMETER_FPS_RANGE_T *)mmal_param;
395
396 if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL)
397 {
398 mmal->fps_low = mmal_rational_from_fixed_16_16(omx->xFramerateLow);
399 mmal->fps_high = mmal_rational_from_fixed_16_16(omx->xFramerateHigh);
400 }
401 else
402 {
403 omx->xFramerateLow = mmal_rational_to_fixed_16_16(mmal->fps_low);
404 omx->xFramerateHigh = mmal_rational_to_fixed_16_16(mmal->fps_high);
405 }
406
407 return MMAL_SUCCESS;
408}
409
410static MMAL_STATUS_T mmalomx_param_mapping_ev_comp(MMALOMX_PARAM_MAPPING_DIRECTION dir,
411 MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param)
412{
413 OMX_PARAM_S32TYPE *omx = (OMX_PARAM_S32TYPE *)omx_param;
414 MMAL_PARAMETER_INT32_T *mmal = (MMAL_PARAMETER_INT32_T *)mmal_param;
415
416 if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL)
417 mmal->value = (omx->nS32 * 6) >> 16;
418 else
419 omx->nS32 = (mmal->value << 16) / 6;
420
421 return MMAL_SUCCESS;
422}
423
424const MMALOMX_PARAM_TRANSLATION_T mmalomx_param_xlator_camera[] = {
425 MMALOMX_PARAM_PASSTHROUGH(MMAL_PARAMETER_ROTATION, MMAL_PARAMETER_INT32_T,
426 OMX_IndexConfigCommonRotate, OMX_CONFIG_ROTATIONTYPE),
427 MMALOMX_PARAM_ENUM(MMAL_PARAMETER_AWB_MODE, MMAL_PARAM_AWBMODE_T,
428 OMX_IndexConfigCommonWhiteBalance, OMX_CONFIG_WHITEBALCONTROLTYPE, mmalomx_param_enum_awb_mode),
429 MMALOMX_PARAM_ENUM(MMAL_PARAMETER_IMAGE_EFFECT, MMAL_PARAMETER_IMAGEFX_T,
430 OMX_IndexConfigCommonImageFilter, OMX_CONFIG_IMAGEFILTERTYPE, mmalomx_param_enum_image_effect),
431 MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_COLOUR_EFFECT, MMAL_PARAMETER_COLOURFX_T,
432 OMX_IndexConfigCommonColorEnhancement, OMX_CONFIG_COLORENHANCEMENTTYPE, mmalomx_param_mapping_colour_effect),
433 MMALOMX_PARAM_ENUM(MMAL_PARAMETER_FLICKER_AVOID, MMAL_PARAMETER_FLICKERAVOID_T,
434 OMX_IndexConfigCommonFlickerCancellation, OMX_CONFIG_FLICKERCANCELTYPE, mmalomx_param_enum_flicker_avoid),
435 MMALOMX_PARAM_ENUM(MMAL_PARAMETER_FLASH, MMAL_PARAMETER_FLASH_T,
436 OMX_IndexParamFlashControl, OMX_IMAGE_PARAM_FLASHCONTROLTYPE, mmalomx_param_enum_flash),
437 MMALOMX_PARAM_ENUM(MMAL_PARAMETER_REDEYE, MMAL_PARAMETER_REDEYE_T,
438 OMX_IndexConfigCommonRedEyeRemoval, OMX_CONFIG_REDEYEREMOVALTYPE, mmalomx_param_enum_redeye),
439 MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_FOCUS, MMAL_PARAMETER_FOCUS_T,
440 OMX_IndexConfigFocusControl, OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE, mmalomx_param_mapping_focus),
441 MMALOMX_PARAM_ENUM(MMAL_PARAMETER_REDEYE, MMAL_PARAMETER_REDEYE_T,
442 OMX_IndexConfigCommonRedEyeRemoval, OMX_CONFIG_REDEYEREMOVALTYPE, mmalomx_param_enum_flash),
443 MMALOMX_PARAM_PASSTHROUGH(MMAL_PARAMETER_ZOOM, MMAL_PARAMETER_SCALEFACTOR_T,
444 OMX_IndexConfigCommonDigitalZoom, OMX_CONFIG_SCALEFACTORTYPE),
445 MMALOMX_PARAM_ENUM(MMAL_PARAMETER_MIRROR, MMAL_PARAMETER_MIRROR_T,
446 OMX_IndexConfigCommonMirror, OMX_CONFIG_MIRRORTYPE, mmalomx_param_enum_mirror),
447 MMALOMX_PARAM_PASSTHROUGH(MMAL_PARAMETER_CAMERA_NUM, MMAL_PARAMETER_UINT32_T,
448 OMX_IndexParamCameraDeviceNumber, OMX_PARAM_U32TYPE),
449 MMALOMX_PARAM_BOOLEAN(MMAL_PARAMETER_CAPTURE,
450 OMX_IndexConfigPortCapturing),
451 MMALOMX_PARAM_ENUM(MMAL_PARAMETER_EXPOSURE_MODE, MMAL_PARAMETER_EXPOSUREMODE_T,
452 OMX_IndexConfigCommonExposure, OMX_CONFIG_EXPOSURECONTROLTYPE, mmalomx_param_enum_exposure_mode),
453 MMALOMX_PARAM_ENUM_PORTLESS(MMAL_PARAMETER_CAPTURE_STATUS, MMAL_PARAMETER_CAPTURE_STATUS_T,
454 OMX_IndexParamCaptureStatus, OMX_PARAM_CAPTURESTATETYPE, mmalomx_param_enum_capture_status),
455 MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_FACE_TRACK, MMAL_PARAMETER_FACE_TRACK_T,
456 OMX_IndexConfigCommonFaceDetectionControl, OMX_CONFIG_FACEDETECTIONCONTROLTYPE, mmalomx_param_mapping_face_track),
457 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS,
458 OMX_IndexConfigDrawBoxAroundFaces),
459 MMALOMX_PARAM_PASSTHROUGH(MMAL_PARAMETER_JPEG_Q_FACTOR, MMAL_PARAMETER_UINT32_T,
460 OMX_IndexParamQFactor, OMX_IMAGE_PARAM_QFACTORTYPE),
461 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_EXIF_DISABLE,
462 OMX_IndexParamBrcmDisableEXIF),
463 MMALOMX_PARAM_STRAIGHT_MAPPING_PORTLESS(MMAL_PARAMETER_THUMBNAIL_CONFIGURATION, MMAL_PARAMETER_THUMBNAIL_CONFIG_T,
464 OMX_IndexParamBrcmThumbnail, OMX_PARAM_BRCMTHUMBNAILTYPE, mmalomx_param_mapping_thumb_cfg),
465 MMALOMX_PARAM_ENUM(MMAL_PARAMETER_USE_STC, MMAL_PARAMETER_CAMERA_STC_MODE_T,
466 OMX_IndexParamCommonUseStcTimestamps, OMX_PARAM_TIMESTAMPMODETYPE, mmalomx_param_enum_stc),
467 MMALOMX_PARAM_PASSTHROUGH(MMAL_PARAMETER_VIDEO_STABILISATION, MMAL_PARAMETER_BOOLEAN_T,
468 OMX_IndexConfigCommonFrameStabilisation, OMX_CONFIG_FRAMESTABTYPE),
469 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_ENABLE_DPF_FILE,
470 OMX_IndexParamUseDynamicParameterFile),
471 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_DPF_FAIL_IS_FATAL,
472 OMX_IndexParamDynamicParameterFileFailFatal),
473 MMALOMX_PARAM_ENUM(MMAL_PARAMETER_CAPTURE_MODE, MMAL_PARAMETER_CAPTUREMODE_T,
474 OMX_IndexParamCameraCaptureMode, OMX_PARAM_CAMERACAPTUREMODETYPE, mmalomx_param_enum_capture_mode),
475 MMALOMX_PARAM_PASSTHROUGH(MMAL_PARAMETER_INPUT_CROP, MMAL_PARAMETER_INPUT_CROP_T,
476 OMX_IndexConfigInputCropPercentages, OMX_CONFIG_INPUTCROPTYPE),
477 MMALOMX_PARAM_STRAIGHT_MAPPING_PORTLESS(MMAL_PARAMETER_SENSOR_INFORMATION, MMAL_PARAMETER_SENSOR_INFORMATION_T,
478 OMX_IndexConfigCameraInfo, OMX_CONFIG_CAMERAINFOTYPE, mmalomx_param_mapping_sensor_info),
479 MMALOMX_PARAM_ENUM(MMAL_PARAMETER_FLASH_SELECT, MMAL_PARAMETER_FLASH_SELECT_T,
480 OMX_IndexParamCameraFlashType, OMX_PARAM_CAMERAFLASHTYPE, mmalomx_param_enum_flash_select),
481 MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_FIELD_OF_VIEW, MMAL_PARAMETER_FIELD_OF_VIEW_T,
482 OMX_IndexConfigFieldOfView, OMX_CONFIG_BRCMFOVTYPE, mmalomx_param_mapping_fov),
483 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_HIGH_DYNAMIC_RANGE,
484 OMX_IndexConfigBrcmHighDynamicRange),
485 MMALOMX_PARAM_ENUM_PORTLESS(MMAL_PARAMETER_DYNAMIC_RANGE_COMPRESSION, MMAL_PARAMETER_DRC_T,
486 OMX_IndexConfigDynamicRangeExpansion, OMX_CONFIG_DYNAMICRANGEEXPANSIONTYPE, mmalomx_param_enum_drc),
487 MMALOMX_PARAM_STRAIGHT_MAPPING_PORTLESS(MMAL_PARAMETER_ALGORITHM_CONTROL, MMAL_PARAMETER_ALGORITHM_CONTROL_T,
488 OMX_IndexParamCameraDisableAlgorithm, OMX_PARAM_CAMERADISABLEALGORITHMTYPE, mmalomx_param_mapping_algo_ctrl),
489 MMALOMX_PARAM_RATIONAL(MMAL_PARAMETER_SHARPNESS, MMAL_PARAMETER_RATIONAL_T,
490 OMX_IndexConfigCommonSharpness, OMX_CONFIG_SHARPNESSTYPE, 100),
491 MMALOMX_PARAM_RATIONAL(MMAL_PARAMETER_CONTRAST, MMAL_PARAMETER_RATIONAL_T,
492 OMX_IndexConfigCommonContrast, OMX_CONFIG_CONTRASTTYPE, 100),
493 MMALOMX_PARAM_RATIONAL(MMAL_PARAMETER_BRIGHTNESS, MMAL_PARAMETER_RATIONAL_T,
494 OMX_IndexConfigCommonContrast, OMX_CONFIG_CONTRASTTYPE, 100),
495 MMALOMX_PARAM_RATIONAL(MMAL_PARAMETER_SATURATION, MMAL_PARAMETER_RATIONAL_T,
496 OMX_IndexConfigCommonSaturation, OMX_CONFIG_SATURATIONTYPE, 100),
497 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_ANTISHAKE,
498 OMX_IndexConfigStillsAntiShakeEnable),
499 MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_IMAGE_EFFECT_PARAMETERS, MMAL_PARAMETER_IMAGEFX_PARAMETERS_T,
500 OMX_IndexConfigCommonImageFilterParameters, OMX_CONFIG_IMAGEFILTERPARAMSTYPE, mmalomx_param_mapping_image_effect_params),
501 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_CAMERA_BURST_CAPTURE,
502 OMX_IndexConfigBurstCapture),
503 MMALOMX_PARAM_PASSTHROUGH(MMAL_PARAMETER_CAMERA_MIN_ISO, MMAL_PARAMETER_UINT32_T,
504 OMX_IndexConfigCameraIsoReferenceValue, OMX_PARAM_U32TYPE),
505 MMALOMX_PARAM_ENUM_PORTLESS(MMAL_PARAMETER_CAMERA_USE_CASE, MMAL_PARAMETER_CAMERA_USE_CASE_T,
506 OMX_IndexConfigCameraUseCase, OMX_CONFIG_CAMERAUSECASETYPE, mmalomx_param_enum_use_case),
507 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_CAPTURE_STATS_PASS,
508 OMX_IndexConfigCameraEnableStatsPass),
509 MMALOMX_PARAM_PASSTHROUGH(MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG, MMAL_PARAMETER_UINT32_T,
510 OMX_IndexParamCameraCustomSensorConfig, OMX_PARAM_U32TYPE),
511 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_ENABLE_REGISTER_FILE,
512 OMX_IndexConfigBrcmUseRegisterFile),
513 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_REGISTER_FAIL_IS_FATAL,
514 OMX_IndexConfigBrcmRegisterFileFailFatal),
515 MMALOMX_PARAM_PASSTHROUGH_PORTLESS(MMAL_PARAMETER_CONFIGFILE_REGISTERS, MMAL_PARAMETER_CONFIGFILE_T,
516 OMX_IndexParamBrcmConfigFileRegisters, OMX_PARAM_BRCMCONFIGFILETYPE),
517 MMALOMX_PARAM_PASSTHROUGH_PORTLESS(MMAL_PARAMETER_CONFIGFILE_CHUNK_REGISTERS, MMAL_PARAMETER_CONFIGFILE_CHUNK_T,
518 OMX_IndexParamBrcmConfigFileChunkRegisters, OMX_PARAM_BRCMCONFIGFILECHUNKTYPE),
519 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_JPEG_ATTACH_LOG,
520 OMX_IndexParamBrcmAttachLog),
521 MMALOMX_PARAM_PASSTHROUGH_PORTLESS(MMAL_PARAMETER_ZERO_SHUTTER_LAG, MMAL_PARAMETER_ZEROSHUTTERLAG_T,
522 OMX_IndexParamCameraZeroShutterLag, OMX_CONFIG_ZEROSHUTTERLAGTYPE),
523 MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_FPS_RANGE, MMAL_PARAMETER_FPS_RANGE_T,
524 OMX_IndexParamBrcmFpsRange, OMX_PARAM_BRCMFRAMERATERANGETYPE, mmalomx_param_mapping_fps_range),
525 MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_CAPTURE_EXPOSURE_COMP, MMAL_PARAMETER_INT32_T,
526 OMX_IndexParamCaptureExposureCompensation, OMX_PARAM_S32TYPE, mmalomx_param_mapping_ev_comp),
527 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_SW_SHARPEN_DISABLE,
528 OMX_IndexParamSWSharpenDisable),
529 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_FLASH_REQUIRED,
530 OMX_IndexConfigBrcmFlashRequired),
531 MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_SW_SATURATION_DISABLE,
532 OMX_IndexParamSWSaturationDisable),
533 MMALOMX_PARAM_TERMINATE()
534};
535
536#if 0 /* Conversions which are still left to implement */
537MMALOMX_PARAM_CUSTOM(MMAL_PARAMETER_CAMERA_CONFIG, MMAL_PARAMETER_CAMERA_CONFIG_T,
538 0, 0, mmal_ril_param_set_cam_config),
539MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_EXPOSURE_COMP, MMAL_PARAMETER_INT32_T,
540 OMX_IndexConfigCommonExposureValue, OMX_CONFIG_EXPOSUREVALUETYPE, 0),
541MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_EXP_METERING_MODE, MMAL_PARAMETER_EXPOSUREMETERINGMODE_T,
542 OMX_IndexConfigCommonExposureValue, OMX_CONFIG_EXPOSUREVALUETYPE, 0),
543MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_ISO, MMAL_PARAMETER_UINT32_T,
544 OMX_IndexConfigCommonExposureValue, OMX_CONFIG_EXPOSUREVALUETYPE, 0),
545MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_FOCUS_STATUS, MMAL_PARAMETER_FOCUS_STATUS_T,
546 OMX_IndexConfigCommonFocusStatus, OMX_PARAM_FOCUSSTATUSTYPE, mmalomx_param_mapping_focus_status),
547MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_EXIF, MMAL_PARAMETER_EXIF_T,
548 OMX_IndexConfigMetadataItem, OMX_CONFIG_METADATAITEMTYPE, 0),
549MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_FACE_TRACK_RESULTS, MMAL_PARAMETER_FACE_TRACK_RESULTS_T,
550 OMX_IndexConfigCommonFaceDetectionRegion, OMX_CONFIG_FACEDETECTIONREGIONTYPE, 0),
551MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_ENABLE_RAW_CAPTURE, MMAL_PARAMETER_BOOLEAN_T,
552 OMX_IndexConfigCaptureRawImageURI, OMX_PARAM_CONTENTURITYPE, 0),
553MMALOMX_PARAM_PASSTHROUGH_PORTLESS(MMAL_PARAMETER_DPF_FILE, MMAL_PARAMETER_URI_T,
554 OMX_IndexParamDynamicParameterFile, OMX_PARAM_CONTENTURITYPE),
555MMALOMX_PARAM_PASSTHROUGH_PORTLESS(MMAL_PARAMETER_FOCUS_REGIONS, ,
556 OMX_IndexConfigCommonFocusRegionXY, ),
557#endif
558