1 /*
2  * Copyright (C) Texas Instruments - http://www.ti.com/
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /**
18 * @file General3A_Settings.h
19 *
20 * This file maps the Camera Hardware Interface to OMX.
21 *
22 */
23 
24 #include "OMX_TI_IVCommon.h"
25 #include "OMX_TI_Common.h"
26 #include "OMX_TI_Index.h"
27 #include "TICameraParameters.h"
28 
29 #ifndef GENERAL_3A_SETTINGS_H
30 #define GENERAL_3A_SETTINGS_H
31 
32 namespace Ti {
33 namespace Camera {
34 
35 struct userToOMX_LUT{
36     const char * userDefinition;
37     int         omxDefinition;
38 };
39 
40 struct LUTtype{
41     int size;
42     const userToOMX_LUT *Table;
43 };
44 
45 const userToOMX_LUT isoUserToOMX[] = {
46     { TICameraParameters::ISO_MODE_AUTO, 0 },
47     { TICameraParameters::ISO_MODE_100, 100 },
48     { TICameraParameters::ISO_MODE_200, 200 },
49     { TICameraParameters::ISO_MODE_400, 400 },
50     { TICameraParameters::ISO_MODE_800, 800 },
51     { TICameraParameters::ISO_MODE_1000, 1000 },
52     { TICameraParameters::ISO_MODE_1200, 1200 },
53     { TICameraParameters::ISO_MODE_1600, 1600 },
54 };
55 
56 const userToOMX_LUT effects_UserToOMX [] = {
57     { android::CameraParameters::EFFECT_NONE, OMX_ImageFilterNone },
58     { android::CameraParameters::EFFECT_NEGATIVE, OMX_ImageFilterNegative },
59     { android::CameraParameters::EFFECT_SOLARIZE,  OMX_ImageFilterSolarize },
60     { android::CameraParameters::EFFECT_SEPIA, OMX_ImageFilterSepia },
61     { android::CameraParameters::EFFECT_MONO, OMX_ImageFilterGrayScale },
62     { android::CameraParameters::EFFECT_BLACKBOARD, OMX_TI_ImageFilterBlackBoard },
63     { android::CameraParameters::EFFECT_WHITEBOARD, OMX_TI_ImageFilterWhiteBoard },
64     { android::CameraParameters::EFFECT_AQUA, OMX_TI_ImageFilterAqua },
65     { android::CameraParameters::EFFECT_POSTERIZE, OMX_TI_ImageFilterPosterize },
66 #ifdef OMAP_ENHANCEMENT
67     { TICameraParameters::EFFECT_NATURAL, OMX_ImageFilterNatural },
68     { TICameraParameters::EFFECT_VIVID, OMX_ImageFilterVivid },
69     { TICameraParameters::EFFECT_COLOR_SWAP, OMX_ImageFilterColourSwap   },
70     { TICameraParameters::EFFECT_BLACKWHITE, OMX_TI_ImageFilterBlackWhite }
71 #endif
72 };
73 
74 const userToOMX_LUT scene_UserToOMX [] = {
75     { android::CameraParameters::SCENE_MODE_AUTO, OMX_Manual },
76     { android::CameraParameters::SCENE_MODE_LANDSCAPE, OMX_Landscape },
77     { android::CameraParameters::SCENE_MODE_NIGHT_PORTRAIT, OMX_NightPortrait },
78     { android::CameraParameters::SCENE_MODE_FIREWORKS, OMX_Fireworks },
79     { android::CameraParameters::SCENE_MODE_ACTION, OMX_TI_Action },
80     { android::CameraParameters::SCENE_MODE_BEACH, OMX_TI_Beach },
81     { android::CameraParameters::SCENE_MODE_CANDLELIGHT, OMX_TI_Candlelight },
82     { android::CameraParameters::SCENE_MODE_NIGHT, OMX_TI_Night },
83     { android::CameraParameters::SCENE_MODE_PARTY, OMX_TI_Party },
84     { android::CameraParameters::SCENE_MODE_PORTRAIT, OMX_TI_Portrait },
85     { android::CameraParameters::SCENE_MODE_SNOW, OMX_TI_Snow },
86     { android::CameraParameters::SCENE_MODE_STEADYPHOTO, OMX_TI_Steadyphoto },
87     { android::CameraParameters::SCENE_MODE_SUNSET, OMX_TI_Sunset },
88     { android::CameraParameters::SCENE_MODE_THEATRE, OMX_TI_Theatre },
89     { android::CameraParameters::SCENE_MODE_SPORTS, OMX_Sport },
90 #ifdef OMAP_ENHANCEMENT
91     { TICameraParameters::SCENE_MODE_CLOSEUP, OMX_Closeup },
92     { TICameraParameters::SCENE_MODE_AQUA, OMX_Underwater },
93     { TICameraParameters::SCENE_MODE_MOOD, OMX_Mood },
94     { TICameraParameters::SCENE_MODE_NIGHT_INDOOR, OMX_NightIndoor },
95     { TICameraParameters::SCENE_MODE_DOCUMENT, OMX_Document },
96     { TICameraParameters::SCENE_MODE_BARCODE, OMX_Barcode },
97     { TICameraParameters::SCENE_MODE_VIDEO_SUPER_NIGHT, OMX_SuperNight },
98     { TICameraParameters::SCENE_MODE_VIDEO_CINE, OMX_Cine },
99     { TICameraParameters::SCENE_MODE_VIDEO_OLD_FILM, OMX_OldFilm },
100 #endif
101 };
102 
103 const userToOMX_LUT whiteBal_UserToOMX [] = {
104     { android::CameraParameters::WHITE_BALANCE_AUTO, OMX_WhiteBalControlAuto },
105     { android::CameraParameters::WHITE_BALANCE_DAYLIGHT, OMX_WhiteBalControlSunLight },
106     { android::CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT, OMX_WhiteBalControlCloudy },
107     { android::CameraParameters::WHITE_BALANCE_FLUORESCENT, OMX_WhiteBalControlFluorescent },
108     { android::CameraParameters::WHITE_BALANCE_INCANDESCENT, OMX_WhiteBalControlIncandescent },
109     { android::CameraParameters::WHITE_BALANCE_SHADE, OMX_TI_WhiteBalControlShade },
110     { android::CameraParameters::WHITE_BALANCE_TWILIGHT, OMX_TI_WhiteBalControlTwilight },
111     { android::CameraParameters::WHITE_BALANCE_WARM_FLUORESCENT, OMX_TI_WhiteBalControlWarmFluorescent },
112 #ifdef OMAP_ENHANCEMENT
113     { TICameraParameters::WHITE_BALANCE_TUNGSTEN, OMX_WhiteBalControlTungsten },
114     { TICameraParameters::WHITE_BALANCE_HORIZON, OMX_WhiteBalControlHorizon },
115     { TICameraParameters::WHITE_BALANCE_SUNSET, OMX_TI_WhiteBalControlSunset }
116 #endif
117 };
118 
119 const userToOMX_LUT antibanding_UserToOMX [] = {
120     { android::CameraParameters::ANTIBANDING_OFF, OMX_FlickerCancelOff },
121     { android::CameraParameters::ANTIBANDING_AUTO, OMX_FlickerCancelAuto },
122     { android::CameraParameters::ANTIBANDING_50HZ, OMX_FlickerCancel50 },
123     { android::CameraParameters::ANTIBANDING_60HZ, OMX_FlickerCancel60 }
124 };
125 
126 const userToOMX_LUT focus_UserToOMX [] = {
127     { android::CameraParameters::FOCUS_MODE_AUTO, OMX_IMAGE_FocusControlAutoLock },
128     { android::CameraParameters::FOCUS_MODE_INFINITY, OMX_IMAGE_FocusControlAutoInfinity },
129     { android::CameraParameters::FOCUS_MODE_INFINITY, OMX_IMAGE_FocusControlHyperfocal },
130     { android::CameraParameters::FOCUS_MODE_MACRO, OMX_IMAGE_FocusControlAutoMacro },
131     { android::CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO, OMX_IMAGE_FocusControlAuto },
132     { android::CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE, OMX_IMAGE_FocusControlAuto },
133 #ifdef OMAP_ENHANCEMENT
134     { TICameraParameters::FOCUS_MODE_FACE , OMX_IMAGE_FocusControlContinousFacePriority },
135     { TICameraParameters::FOCUS_MODE_PORTRAIT, OMX_IMAGE_FocusControlPortrait },
136     { TICameraParameters::FOCUS_MODE_EXTENDED, OMX_IMAGE_FocusControlExtended },
137 #endif
138     { TICameraParameters::FOCUS_MODE_OFF , OMX_IMAGE_FocusControlOff }
139 };
140 
141 const userToOMX_LUT exposure_UserToOMX [] = {
142     { TICameraParameters::EXPOSURE_MODE_MANUAL, OMX_ExposureControlOff },
143     { TICameraParameters::EXPOSURE_MODE_AUTO, OMX_ExposureControlAuto },
144     { TICameraParameters::EXPOSURE_MODE_NIGHT, OMX_ExposureControlNight },
145     { TICameraParameters::EXPOSURE_MODE_BACKLIGHT, OMX_ExposureControlBackLight },
146     { TICameraParameters::EXPOSURE_MODE_SPOTLIGHT, OMX_ExposureControlSpotLight},
147     { TICameraParameters::EXPOSURE_MODE_SPORTS, OMX_ExposureControlSports },
148     { TICameraParameters::EXPOSURE_MODE_SNOW, OMX_ExposureControlSnow },
149     { TICameraParameters::EXPOSURE_MODE_BEACH, OMX_ExposureControlBeach },
150     { TICameraParameters::EXPOSURE_MODE_APERTURE, OMX_ExposureControlLargeAperture },
151     { TICameraParameters::EXPOSURE_MODE_SMALL_APERTURE, OMX_ExposureControlSmallApperture },
152 };
153 
154 const userToOMX_LUT flash_UserToOMX [] = {
155     { android::CameraParameters::FLASH_MODE_OFF           ,OMX_IMAGE_FlashControlOff             },
156     { android::CameraParameters::FLASH_MODE_ON            ,OMX_IMAGE_FlashControlOn              },
157     { android::CameraParameters::FLASH_MODE_AUTO          ,OMX_IMAGE_FlashControlAuto            },
158     { android::CameraParameters::FLASH_MODE_TORCH         ,OMX_IMAGE_FlashControlTorch           },
159     { android::CameraParameters::FLASH_MODE_RED_EYE        ,OMX_IMAGE_FlashControlRedEyeReduction },
160 #ifdef OMAP_ENHANCEMENT
161     { TICameraParameters::FLASH_MODE_FILL_IN        ,OMX_IMAGE_FlashControlFillin          }
162 #endif
163 };
164 
165 const LUTtype ExpLUT =
166     {
167     sizeof(exposure_UserToOMX)/sizeof(exposure_UserToOMX[0]),
168     exposure_UserToOMX
169     };
170 
171 const LUTtype WBalLUT =
172     {
173     sizeof(whiteBal_UserToOMX)/sizeof(whiteBal_UserToOMX[0]),
174     whiteBal_UserToOMX
175     };
176 
177 const LUTtype FlickerLUT =
178     {
179     sizeof(antibanding_UserToOMX)/sizeof(antibanding_UserToOMX[0]),
180     antibanding_UserToOMX
181     };
182 
183 const LUTtype SceneLUT =
184     {
185     sizeof(scene_UserToOMX)/sizeof(scene_UserToOMX[0]),
186     scene_UserToOMX
187     };
188 
189 const LUTtype FlashLUT =
190     {
191     sizeof(flash_UserToOMX)/sizeof(flash_UserToOMX[0]),
192     flash_UserToOMX
193     };
194 
195 const LUTtype EffLUT =
196     {
197     sizeof(effects_UserToOMX)/sizeof(effects_UserToOMX[0]),
198     effects_UserToOMX
199     };
200 
201 const LUTtype FocusLUT =
202     {
203     sizeof(focus_UserToOMX)/sizeof(focus_UserToOMX[0]),
204     focus_UserToOMX
205     };
206 
207 const LUTtype IsoLUT =
208     {
209     sizeof(isoUserToOMX)/sizeof(isoUserToOMX[0]),
210     isoUserToOMX
211     };
212 
213 /*
214 *   class Gen3A_settings
215 *   stores the 3A settings
216 *   also defines the look up tables
217 *   for mapping settings from Hal to OMX
218 */
219 class Gen3A_settings{
220     public:
221 
222     int Exposure;
223     int WhiteBallance;
224     int Flicker;
225     int SceneMode;
226     int Effect;
227     int Focus;
228     int EVCompensation;
229     int Contrast;
230     int Saturation;
231     int Sharpness;
232     int ISO;
233     int FlashMode;
234     int ManualExposure;
235     int ManualExposureRight;
236     int ManualGain;
237     int ManualGainRight;
238 
239     unsigned int Brightness;
240     OMX_BOOL ExposureLock;
241     OMX_BOOL FocusLock;
242     OMX_BOOL WhiteBalanceLock;
243 
244     OMX_BOOL AlgoExternalGamma;
245     OMX_BOOL AlgoNSF1;
246     OMX_BOOL AlgoNSF2;
247     OMX_BOOL AlgoSharpening;
248     OMX_BOOL AlgoThreeLinColorMap;
249     OMX_BOOL AlgoGIC;
250 
251     OMX_TI_CONFIG_GAMMATABLE_TYPE mGammaTable;
252 
253 };
254 
255 /*
256 *   Flags raised when a setting is changed
257 */
258 enum E3ASettingsFlags
259 {
260     SetSceneMode            = 1 << 0,
261     SetEVCompensation       = 1 << 1,
262     SetWhiteBallance        = 1 << 2,
263     SetFlicker              = 1 << 3,
264     SetExposure             = 1 << 4,
265     SetSharpness            = 1 << 5,
266     SetBrightness           = 1 << 6,
267     SetContrast             = 1 << 7,
268     SetISO                  = 1 << 8,
269     SetSaturation           = 1 << 9,
270     SetEffect               = 1 << 10,
271     SetFocus                = 1 << 11,
272     SetExpMode              = 1 << 14,
273     SetFlash                = 1 << 15,
274     SetExpLock              = 1 << 16,
275     SetWBLock               = 1 << 17,
276     SetMeteringAreas        = 1 << 18,
277     SetManualExposure       = 1 << 19,
278 
279     SetAlgoExternalGamma    = 1 << 20,
280     SetAlgoNSF1             = 1 << 21,
281     SetAlgoNSF2             = 1 << 22,
282     SetAlgoSharpening       = 1 << 23,
283     SetAlgoThreeLinColorMap = 1 << 24,
284     SetAlgoGIC              = 1 << 25,
285     SetGammaTable           = 1 << 26,
286 
287 
288     E3aSettingMax,
289     E3AsettingsAll = ( ((E3aSettingMax -1 ) << 1) -1 ) /// all possible flags raised
290 };
291 
292 } // namespace Camera
293 } // namespace Ti
294 
295 #endif //GENERAL_3A_SETTINGS_H
296