1 /* 2 * gstxcaminterface.h - gst xcam 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 /*! \file gstxcaminterface.h 22 * \brief Gstreamer XCam 3A interface 23 * 24 */ 25 26 #ifndef GST_XCAM_INTERFACE_H 27 #define GST_XCAM_INTERFACE_H 28 29 #include <gst/gst.h> 30 #include <linux/videodev2.h> 31 #include <base/xcam_3a_types.h> 32 33 34 G_BEGIN_DECLS 35 36 /*! \brief Get GST interface type of XCam 3A interface 37 * 38 * \return GType returned by g_type_register_static() 39 */ 40 #define GST_TYPE_XCAM_3A_IF (gst_xcam_3a_interface_get_type ()) 41 42 /*! \brief Get GST XCam 3A handle. 43 * See usage of struct _GstXCam3AInterface. 44 * 45 * \return XCam 3A handle of _GstXCam3A * type 46 */ 47 #define GST_XCAM_3A(obj) \ 48 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XCAM_3A_IF, GstXCam3A)) 49 50 /*! \brief Get GST XCam 3A interface 51 * 52 * See usage of struct _GstXCam3AInterface. 53 * 54 * \param[in] Xcam 3A handle 55 * \return GstXCam3AInterface* 56 */ 57 #define GST_XCAM_3A_GET_INTERFACE(inst) \ 58 (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_XCAM_3A_IF, GstXCam3AInterface)) 59 60 typedef struct _GstXCam3A GstXCam3A; 61 typedef struct _GstXCam3AInterface GstXCam3AInterface; 62 63 /*! \brief XCam 3A Interface 64 * 65 * Usage: 66 * - GstXCam3A *xcam = GST_XCAM_3A (xcamsrc); 67 * - GstXCam3AInterface *xcam_interface = GST_XCAM_3A_GET_INTERFACE (xcam); 68 * - ret = xcam_interface->set_exposure_mode(xcam, XCAM_AE_MODE_AUTO); 69 */ 70 struct _GstXCam3AInterface { 71 GTypeInterface base; /*!< inherent from GTypeInterface */ 72 73 /*! \brief Set white balance mode. 74 * See xcam_3a_set_whitebalance_mode(). 75 * 76 * \param[in,out] xcam XCam handle 77 * \param[in] mode white balance mode 78 * return 0 on success; -1 on error (parameter error) 79 */ 80 gboolean (* set_white_balance_mode) (GstXCam3A *xcam, XCamAwbMode mode); 81 82 /*! \brief set AWB speed. 83 * see xcam_3a_set_awb_speed(). 84 * 85 * \param[in,out] xcam XCam handle 86 * \param[in,out] speed AWB speed; speed meaturement will consider later 87 * return 0 on success; -1 on error 88 */ 89 gboolean (* set_awb_speed) (GstXCam3A *xcam, double speed); 90 91 /*! \brief Set white balance temperature range. 92 * see xcam_3a_set_awb_color_temperature_range(). 93 * 94 * \param[in] cct_min 0 < cct_min <= cct_max <= 10000; if 0, disable cct range 95 * \param[in] cct_max 0 < cct_min <= cct_max <= 10000; if 0, disable cct range 96 * \return 0 on success; -1 on error 97 * 98 * Usage: 99 * 100 * - Enable: 101 * 1. set_white_balance_mode(%XCAM_AWB_MODE_MANUAL) 102 * 2. set_wb_color_temperature_range 103 * - Disable: 104 * set_white_balance_mode(%XCAM_AWB_MODE_AUTO) 105 * 106 */ 107 gboolean (* set_wb_color_temperature_range) (GstXCam3A *xcam, guint cct_min, guint cct_max); 108 109 /*! \brief Set manual white balance gain. 110 * see xcam_3a_set_wb_manual_gain(). 111 * 112 * \param[in,out] xcam XCam handle 113 * \param[in] gr GR channel 114 * \param[in] r R channel 115 * \param[in] b B channel 116 * \param[in] gb GB channel 117 * 118 * Usage: 119 * 120 * - Enable: 121 * 1. need gr, r, b, gb => gain value [0.1~4.0]; 122 * 2. set_white_balance_mode(xcam, XCAM_AWB_MODE_NOT_SET) 123 * - Disable: 124 * 1. need set gr=0, r=0, b=0, gb=0; 125 * 2. set_white_balance_mode(xcam, mode); mode != XCAM_AWB_MODE_NOT_SET 126 */ 127 gboolean (* set_manual_wb_gain) (GstXCam3A *xcam, double gr, double r, double b, double gb); 128 129 130 /*! \brief set exposure mode. 131 * see xcam_3a_set_exposure_mode(). 132 * 133 * \param[in,out] xcam XCam handle 134 * \param[in] mode choose from XCAM_AE_MODE_AUTO and XCAM_AE_MODE_MANUAL; others not supported 135 */ 136 gboolean (* set_exposure_mode) (GstXCam3A *xcam, XCamAeMode mode); 137 138 /*! \brief set AE metering mode. 139 * see xcam_3a_set_ae_metering_mode(). 140 * 141 * \param[in,out] xcam XCam handle 142 * \param[in] mode XCAM_AE_METERING_MODE_AUTO, default 143 * XCAM_AE_METERING_MODE_SPOT, need set spot window by set_exposure_window 144 * XCAM_AE_METERING_MODE_CENTER, more weight in center 145 * XCAM_AE_METERING_MODE_WEIGHTED_WINDOW, weighted multi metering window 146 */ 147 gboolean (* set_ae_metering_mode) (GstXCam3A *xcam, XCamAeMeteringMode mode); 148 149 /* \brief set exposure window. 150 * see xcam_3a_set_ae_window(). 151 * 152 * \param[in,out] xcam XCam handle 153 * \param[in] window the area to set exposure with. x_end > x_start AND y_end > y_start; only ONE window can be set 154 * \param[in] count the number of metering window 155 * 156 * Usage 157 * - Enable: 158 * set_ae_metering_mode(@xcam, %XCAM_AE_METERING_MODE_SPOT) 159 * - Disable: 160 * set_ae_metering_mode(@xcam, @mode); #mode != %XCAM_AE_METERING_MODE_SPOT 161 */ 162 gboolean (* set_exposure_window) (GstXCam3A *xcam, XCam3AWindow *window, guint8 count); 163 164 /*! \brief set exposure value offset. 165 * see xcam_3a_set_ae_value_shift(). 166 * 167 * \param[in,out] xcam XCam handle 168 * \param[in] ev_offset -4.0 <= ev_offset <= 4.0; default 0.0 169 */ 170 gboolean (* set_exposure_value_offset) (GstXCam3A *xcam, double ev_offset); 171 172 /*! \brief set AE speed. 173 * see xcam_3a_set_ae_speed(). 174 * 175 * \param[in,out] xcam XCam handle 176 * \param[in] speed AE speed 177 */ 178 gboolean (* set_ae_speed) (GstXCam3A *xcam, double speed); 179 180 /*! \brief set exposure flicker mode. 181 * see xcam_3a_set_ae_flicker_mode(). 182 * 183 * \param[in,out] xcam XCam handle 184 * \param[in] flicker XCAM_AE_FLICKER_MODE_AUTO, default 185 * XCAM_AE_FLICKER_MODE_50HZ 186 * XCAM_AE_FLICKER_MODE_60HZ 187 * XCAM_AE_FLICKER_MODE_OFF, outside 188 */ 189 gboolean (*set_exposure_flicker_mode) (GstXCam3A *xcam, XCamFlickerMode flicker); 190 191 /*! \brief get exposure flicker mode. 192 * see xcam_3a_get_ae_flicker_mode(). 193 * 194 * \param[in,out] xcam XCam handle 195 * \return XCamFlickerMode XCAM_AE_FLICKER_MODE_AUTO, default 196 * XCAM_AE_FLICKER_MODE_50HZ 197 * XCAM_AE_FLICKER_MODE_60HZ 198 * XCAM_AE_FLICKER_MODE_OFF, outside 199 */ 200 XCamFlickerMode (*get_exposure_flicker_mode) (GstXCam3A *xcam); 201 202 /*! \brief get current exposure time. 203 * see xcam_3a_get_current_exposure_time(). 204 * 205 * \param[in,out] xcam XCam handle 206 * \return current exposure time in microsecond, if return -1, means xcam is not started 207 */ 208 gint64 (* get_current_exposure_time) (GstXCam3A *xcam); 209 210 /*! \brief get current analog gain. 211 * see xcam_3a_get_current_analog_gain(). 212 * 213 * \param[in,out] xcam XCam handle 214 * \return current analog gain as multiplier. If return < 0.0 OR return < 1.0, xcam is not started. 215 */ 216 double (* get_current_analog_gain) (GstXCam3A *xcam); 217 218 /*! \brief set manual exposure time 219 * 220 * \param[in,out] xcam XCam handle 221 * \param[in] time_in_us exposure time 222 * 223 * Usage: 224 * - Enable: 225 * set time_in_us, 0 < time_in_us < 1/fps 226 * - Disable: 227 * time_in_us = 0 228 */ 229 gboolean (* set_manual_exposure_time) (GstXCam3A *xcam, gint64 time_in_us); 230 231 /*! \brief set manual analog gain. 232 * see xcam_3a_set_ae_manual_analog_gain(). 233 * 234 * \param[in,out] xcam XCam handle 235 * \param[in] gain analog gain 236 * 237 * Usage: 238 * - Enable: 239 * set @gain value, 1.0 < @gain 240 * - Disable: 241 * set @gain = 0.0 242 */ 243 gboolean (* set_manual_analog_gain) (GstXCam3A *xcam, double gain); 244 245 /*! \brief set aperture. 246 * see xcam_3a_set_ae_set_aperture(). 247 * 248 * \param[in,out] xcam XCam3A handle 249 * \param[in] fn AE aperture fn 250 * \return bool 0 on success 251 */ 252 gboolean (* set_aperture) (GstXCam3A *xcam, double fn); 253 254 /*! \brief set max analog gain. 255 * see xcam_3a_set_ae_max_analog_gain(). 256 * 257 * \param[in,out] xcam XCam3A handle 258 * \param[in] max_gain max analog gain 259 * \return gboolen 0 on success 260 */ 261 gboolean (* set_max_analog_gain) (GstXCam3A *xcam, double max_gain); 262 263 /*! \brief get max analog gain. 264 * see xcam_3a_get_ae_max_analog_gain(). 265 * 266 * \param[in,out] xcam XCam3A handle 267 * \return max_gain max analog gain 268 */ 269 double (* get_max_analog_gain) (GstXCam3A *xcam); 270 271 /*! 272 * \brief set AE time range 273 * 274 * \param[in,out] xcam XCam3A handle 275 * \param[in] min_time_in_us min time 276 * \param[in] max_time_in_us max time 277 * \return XCam3AStatus 0 on success 278 */ 279 gboolean (* set_exposure_time_range) (GstXCam3A *xcam, gint64 min_time_in_us, gint64 max_time_in_us); 280 281 /*! 282 * \brief XCam3A get AE time range. 283 * Range in [0 ~ 1000000/fps] micro-seconds. see xcam_3a_set_ae_time_range(). 284 * 285 * \param[in,out] xcam XCam3A handle 286 * \param[out] min_time_in_us min time 287 * \param[out] max_time_in_us max time 288 * \return bool 0 on success 289 */ 290 gboolean (* get_exposure_time_range) (GstXCam3A *xcam, gint64 *min_time_in_us, gint64 *max_time_in_us); 291 292 /*! \brief set DVS. 293 * digital video stabilization. see xcam_3a_enable_dvs(). 294 * 295 * \param[in,out] xcam XCam3A handle 296 * \param[in] enable enable/disable 297 * \return bool 0 on success 298 */ 299 gboolean (* set_dvs) (GstXCam3A *xcam, gboolean enable); 300 301 /*! \brief set noice reduction level to BNR and YNR. 302 * see xcam_3a_set_noise_reduction_level(). 303 * 304 * \param[in,out] xcam XCam3A handle 305 * \param[in] level control BNR/YNR gain. 0 <= level <= 255; default level: 128 306 * \return bool 0 on success 307 */ 308 gboolean (*set_noise_reduction_level) (GstXCam3A *xcam, guint8 level); 309 310 /*! \brief set temporal noice reduction level. 311 * see xcam_3a_set_temporal_noise_reduction_level(). 312 * 313 * \param[in,out] xcam XCam3A handle 314 * \param[in] level control TNR gain. 0 <= level <= 255; default level: 128 315 * \param[in] mode TNR filter mode 0: disable, 1: YUV mode, 2: RGB mode 316 * \return bool 0 on success 317 */ 318 gboolean (*set_temporal_noise_reduction_level) (GstXCam3A *xcam, guint8 level, gint8 mode); 319 320 /*! 321 * \brief set gamma table. 322 * see xcam_3a_set_set_gamma_table(). 323 * 324 * \param[in,out] xcam XCam3A handle 325 * \param[in] r_table red color gamma table 326 * \param[in] g_table green color gamma table 327 * \param[in] b_table blue color gamma table 328 * \return bool 0 on success 329 * 330 * Restriction: 331 * 1. can't co-work with manual brightness and contrast, 332 * 2. table size = 256, and values in [0.0~1.0], e.g 0.0, 1.0/256, 2.0/256 ... 255.0/256 333 * 334 * Usage: 335 * - to Disable: 336 * r_table = NULL && g_table = NULL && b_table=NULL 337 */ 338 gboolean (* set_gamma_table) (GstXCam3A *xcam, double *r_table, double *g_table, double *b_table); 339 340 /*! 341 * \brief enable/disable gbce. 342 * see xcam_3a_enable_gbce(). 343 * 344 * \param[in,out] xcam XCam3A handle 345 * \param[in] enable enable/disable, i.e. TRUE to enable GBCE and otherwise disable GBCE. 346 * \return bool 0 on success 347 */ 348 gboolean (* set_gbce) (GstXCam3A *xcam, gboolean enable); 349 350 /*! 351 * \brief set manual brightness. 352 * see xcam_3a_set_manual_brightness(). 353 * 354 * \param[in,out] xcam XCam3A handle 355 * \param[in] value manual brightness, 0 <= value <= 255; default:128 356 * \return bool 0 on success */ 357 gboolean (* set_manual_brightness) (GstXCam3A *xcam, guint8 value); 358 359 /*! 360 * \brief set manual contrast. 361 * see xcam_3a_set_manual_contrast(). 362 * 363 * \param[in,out] xcam XCam3A handle 364 * \param[in] value manual contrast, 0 <= value <= 255; default:128 365 * \return bool 0 on success */ 366 gboolean (* set_manual_contrast) (GstXCam3A *xcam, guint8 value); 367 368 /*! 369 * \brief set manual hue. 370 * see xcam_3a_set_manual_hue(). 371 * 372 * \param[in,out] xcam XCam3A handle 373 * \param[in] value manual hue, 0 <= value <= 255; default:128 374 * \return bool 0 on success */ 375 gboolean (* set_manual_hue) (GstXCam3A *xcam, guint8 value); 376 377 /*! 378 * \brief set manual saturation. 379 * see xcam_3a_set_manual_saturation(). 380 * 381 * \param[in,out] xcam XCam3A handle 382 * \param[in] value manual saturation, 0 <= value <= 255; default:128 383 * \return bool 0 on success */ 384 gboolean (* set_manual_saturation) (GstXCam3A *xcam, guint8 value); 385 386 /*! 387 * \brief set manual sharpness. 388 * see xcam_3a_set_manual_sharpness(). 389 * 390 * \param[in,out] xcam XCam3A handle 391 * \param[in] value manual sharpness, 0 <= value <= 255; default:128 392 * \return bool 0 on success */ 393 gboolean (* set_manual_sharpness) (GstXCam3A *xcam, guint8 value); 394 395 /* IR-cut */ 396 /*! 397 * \brief enable/disable night mode. 398 * see xcam_3a_enable_night_mode(). 399 * 400 * \param[in,out] xcam XCam3A handle 401 * \param[in] enable enable/disable, i.e. TRUE to enable night mode and otherwise disable night mode. 402 * \return bool 0 on success 403 */ 404 gboolean (* set_night_mode) (GstXCam3A *xcam, gboolean enable); 405 406 /*! 407 * \brief set HDR mode. 408 * 409 * \param[in,out] xcam XCam3A handle 410 * \param[in] mode 0: disable, 1: HDR in RGB color space, 2: HDR in LAB color space 411 * \return bool 0 on success 412 */ 413 gboolean (* set_hdr_mode) (GstXCam3A *xcam, guint8 mode); 414 415 /*! 416 * \brief set denoise mode. 417 * 418 * \param[in,out] xcam XCam3A handle 419 * \param[in] mode bit mask to enable/disable denoise functions 420 * each bit controls a specific denoise function, 0: disable, 1: enable 421 * bit 0: simple noise reduction 422 * bit 1: bilateral noise reduction 423 * bit 2: luminance noise reduction and edge enhancement 424 * bit 3: bayer noise reduction 425 * bit 4: advanced bayer noise reduction 426 * \return bool 0 on success 427 */ 428 gboolean (* set_denoise_mode) (GstXCam3A *xcam, guint32 mode); 429 430 /*! 431 * \brief set gamma mode. 432 * 433 * \param[in,out] xcam XCam3A handle 434 * \param[in] enable true: enable, false: disable 435 * \return bool 0 on success 436 */ 437 gboolean (* set_gamma_mode) (GstXCam3A *xcam, gboolean enable); 438 439 /*! 440 * \brief set dpc mode. 441 * 442 * \param[in,out] xcam XCam3A handle 443 * \param[in] enable true: enable, false: disable 444 * \return bool 0 on success 445 */ 446 gboolean (* set_dpc_mode) (GstXCam3A *xcam, gboolean enable); 447 448 /*! 449 * \brief set tone mapping mode. 450 * 451 * \param[in,out] xcam XCam3A handle 452 * \param[in] enable true: enable, false: disable 453 * \return bool 0 on success 454 */ 455 gboolean (* set_tonemapping_mode) (GstXCam3A *xcam, gboolean enable); 456 457 /*! 458 * \brief set retinex mode. 459 * 460 * \param[in,out] xcam XCam3A handle 461 * \param[in] enable true: enable, false: disable 462 * \return bool 0 on success 463 */ 464 gboolean (* set_retinex_mode) (GstXCam3A *xcam, gboolean enable); 465 466 467 }; 468 469 /*! \brief Get GST interface type of XCam 3A interface. 470 * will try to register GsXcam3AInterface with 471 * g_type_register_static() if not done so yet, and in turn return the 472 * interface type it returns. 473 * 474 * \return GType XCam 3A interface type returned by g_type_register_static() 475 */ 476 GType 477 gst_xcam_3a_interface_get_type (void); 478 479 G_END_DECLS 480 481 #endif /* GST_XCAM_INTERFACE_H */ 482