• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * handler_interface.h - handler interface
3  *
4  *  Copyright (c) 2014-2015 Intel Corporation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Author: Wind Yuan <feng.yuan@intel.com>
19  */
20 
21 #ifndef XCAM_HANDLER_INTERFACE_H
22 #define XCAM_HANDLER_INTERFACE_H
23 
24 #include <base/xcam_common.h>
25 #include <base/xcam_3a_types.h>
26 #include <base/xcam_params.h>
27 
28 #include <xcam_std.h>
29 #include <xcam_mutex.h>
30 #include <x3a_result.h>
31 
32 namespace XCam {
33 
34 class AnalyzerHandler {
35     friend class HandlerLock;
36 public:
AnalyzerHandler()37     explicit AnalyzerHandler() {}
~AnalyzerHandler()38     virtual ~AnalyzerHandler () {}
39 
40     virtual XCamReturn analyze (X3aResultList &output) = 0;
41 
42 protected:
43     class HandlerLock
44         : public SmartLock
45     {
46     public:
HandlerLock(AnalyzerHandler * handler)47         HandlerLock(AnalyzerHandler *handler)
48             : SmartLock (handler->_mutex)
49         {}
~HandlerLock()50         ~HandlerLock() {}
51     };
52 
53     // members
54     Mutex _mutex;
55 };
56 
57 class AeHandler
58     : public AnalyzerHandler
59 {
60 public:
61     explicit AeHandler();
~AeHandler()62     virtual ~AeHandler() {}
63 
64     bool set_mode (XCamAeMode mode);
65     bool set_metering_mode (XCamAeMeteringMode mode);
66     bool set_window (XCam3AWindow *window);
67     bool set_window (XCam3AWindow *window, uint8_t count);
68     bool set_ev_shift (double ev_shift);
69     bool set_speed (double speed);
70     bool set_flicker_mode (XCamFlickerMode flicker);
71     bool set_manual_exposure_time (int64_t time_in_us);
72     bool set_manual_analog_gain (double gain);
73     bool set_aperture (double fn);
74     bool set_max_analog_gain (double max_gain);
75     bool set_exposure_time_range (int64_t min_time_in_us, int64_t max_time_in_us);
76 
77     bool update_parameters (const XCamAeParam &params);
78 
79     bool get_exposure_time_range (int64_t *min_time_in_us, int64_t *max_time_in_us);
80 
get_metering_mode()81     XCamAeMeteringMode get_metering_mode() const {
82         return _params.metering_mode;
83     }
84 
85     //virtual functions
86     virtual XCamFlickerMode get_flicker_mode ();
87     virtual int64_t get_current_exposure_time ();
88     virtual double get_current_analog_gain ();
89     virtual double get_max_analog_gain ();
90 
91 protected:
get_params_unlock()92     const XCamAeParam &get_params_unlock () const {
93         return _params;
94     }
95 
get_mode_unlock()96     XCamAeMode get_mode_unlock() const {
97         return _params.mode;
98     }
get_metering_mode_unlock()99     XCamAeMeteringMode get_metering_mode_unlock() const {
100         return _params.metering_mode;
101     }
get_window_unlock()102     const XCam3AWindow &get_window_unlock() const {
103         return _params.window;
104     }
get_flicker_mode_unlock()105     XCamFlickerMode get_flicker_mode_unlock() const {
106         return _params.flicker_mode;
107     }
get_speed_unlock()108     double get_speed_unlock() const {
109         return _params.speed;
110     }
get_ev_shift_unlock()111     double get_ev_shift_unlock() const {
112         return _params.ev_shift;
113     }
114 
get_manual_exposure_time_unlock()115     uint64_t get_manual_exposure_time_unlock () const {
116         return _params.manual_exposure_time;
117     }
get_manual_analog_gain_unlock()118     double get_manual_analog_gain_unlock () const {
119         return _params.manual_analog_gain;
120     }
121 
get_aperture_fn_unlock()122     double get_aperture_fn_unlock () const {
123         return _params.aperture_fn;
124     }
125 
get_exposure_time_range_unlock(uint64_t & min,uint64_t & max)126     void get_exposure_time_range_unlock (uint64_t &min, uint64_t &max) const {
127         min = _params.exposure_time_min;
128         max = _params.exposure_time_max;
129     }
130 
get_max_analog_gain_unlock()131     double get_max_analog_gain_unlock () const {
132         return _params.max_analog_gain;
133     }
134 
135 private:
136     void reset_parameters ();
137     XCAM_DEAD_COPY (AeHandler);
138 
139 protected:
140     XCamAeParam   _params;
141 };
142 
143 class AwbHandler
144     : public AnalyzerHandler
145 {
146 public:
147     explicit AwbHandler();
~AwbHandler()148     virtual ~AwbHandler() {}
149 
150     bool set_mode (XCamAwbMode mode);
151     bool set_speed (double speed);
152     bool set_color_temperature_range (uint32_t cct_min, uint32_t cct_max);
153     bool set_manual_gain (double gr, double r, double b, double gb);
154 
155     bool update_parameters (const XCamAwbParam &params);
156 
157     //virtual functions
158     virtual uint32_t get_current_estimate_cct ();
159 
160 protected:
get_params_unlock()161     const XCamAwbParam &get_params_unlock () const {
162         return _params;
163     }
164 
get_mode_unlock()165     XCamAwbMode get_mode_unlock() const {
166         return _params.mode;
167     }
get_speed_unlock()168     double get_speed_unlock () const {
169         return _params.speed;
170     }
171 
get_window_unlock()172     const XCam3AWindow &get_window_unlock () const {
173         return _params.window;
174     }
175 
get_cct_range_unlock(uint32_t & cct_min,uint32_t & cct_max)176     void get_cct_range_unlock (uint32_t &cct_min, uint32_t &cct_max) const {
177         cct_min = _params.cct_min;
178         cct_max = _params.cct_max;
179     }
180 
181 private:
182     void reset_parameters ();
183     XCAM_DEAD_COPY (AwbHandler);
184 
185 protected:
186     XCamAwbParam _params;
187 };
188 
189 class AfHandler
190     : public AnalyzerHandler
191 {
192 public:
AfHandler()193     explicit AfHandler() {}
~AfHandler()194     virtual ~AfHandler() {}
195 
196     bool update_parameters (const XCamAfParam &params);
197 
198 private:
199     XCAM_DEAD_COPY (AfHandler);
200 
201 protected:
get_params_unlock()202     const XCamAfParam &get_params_unlock () const {
203         return _params;
204     }
205 
206 protected:
207     XCamAfParam _params;
208 };
209 
210 class CommonHandler
211     : public AnalyzerHandler
212 {
213 public:
214     explicit CommonHandler();
~CommonHandler()215     virtual ~CommonHandler() {}
216 
217     bool set_dvs (bool enable);
218     bool set_gbce (bool enable);
219     bool set_night_mode (bool enable);
220 
221     /* Picture quality */
222     bool set_noise_reduction_level (double level);
223     bool set_temporal_noise_reduction_level (double level);
224     bool set_manual_brightness (double level);
225     bool set_manual_contrast (double level);
226     bool set_manual_hue (double level);
227     bool set_manual_saturation (double level);
228     bool set_manual_sharpness (double level);
229     bool set_gamma_table (double *r_table, double *g_table, double *b_table);
230     bool set_color_effect(XCamColorEffect effect);
231 
232     bool update_parameters (const XCamCommonParam &params);
233 
234 protected:
get_params_unlock()235     const XCamCommonParam &get_params_unlock () const {
236         return _params;
237     }
has_gbce_unlock()238     bool has_gbce_unlock () const {
239         return _params.enable_gbce;
240     }
has_dvs_unlock()241     bool has_dvs_unlock () const {
242         return _params.enable_dvs;
243     }
has_night_mode_unlock()244     bool has_night_mode_unlock () const {
245         return _params.enable_night_mode;
246     }
247 
get_nr_level_unlock()248     double get_nr_level_unlock () const {
249         return _params.nr_level;
250     }
get_tnr_level_unlock()251     double get_tnr_level_unlock () const {
252         return _params.tnr_level;
253     }
get_brightness_unlock()254     double get_brightness_unlock () const {
255         return _params.brightness;
256     }
get_contrast_unlock()257     double get_contrast_unlock () const {
258         return _params.contrast;
259     }
get_hue_unlock()260     double get_hue_unlock () const {
261         return _params.hue;
262     }
get_saturation_unlock()263     double get_saturation_unlock () const {
264         return _params.saturation;
265     }
get_sharpness_unlock()266     double get_sharpness_unlock () const {
267         return _params.sharpness;
268     }
269 
270 private:
271     void reset_parameters ();
272     XCAM_DEAD_COPY (CommonHandler);
273 
274 protected:
275     XCamCommonParam _params;
276 };
277 
278 };
279 
280 #endif // XCAM_HANDLER_INTERFACE_H
281