xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/hwi/FlashLight.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  *  Copyright (c) 2019 Rockchip Corporation
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 #ifndef _FLASH_LIGHT_H_
19 #define _FLASH_LIGHT_H_
20 
21 #include "v4l2_device.h"
22 #include "rk_aiq_types.h"
23 #include <string>
24 
25 using namespace XCam;
26 
27 namespace RkCam {
28 
29 #define FLASH_MAX_NUM 2
30 #define FL_SUBM (0x8)
31 
32 class FlashLightHw {
33 public:
34     explicit FlashLightHw(std::string name[], int num);
35     virtual ~FlashLightHw();
36 
37     XCamReturn init(int active_num);
38     XCamReturn deinit();
39     XCamReturn start();
keep_status(bool ks)40     void keep_status(bool ks) {
41         _keep_status = ks;
42     };
43     XCamReturn stop();
isStrengthAdj()44     bool isStrengthAdj() {
45         return  _v4l_flash_info[0].fl_strth_adj_enable || _v4l_flash_info[0].tc_strth_adj_enable;}
46     XCamReturn set_params(rk_aiq_flash_setting_t& flash_settings);
47     XCamReturn get_status (rk_aiq_flash_setting_t& flash_settings, uint32_t frame_id = -1);
48 private:
49     int get_flash_info ();
50     XCamReturn v4l_set_params(int fl_mode, float fl_intensity[], int fl_timeout, int fl_on);
51 private:
52     XCAM_DEAD_COPY (FlashLightHw);
53     int _dev_num;
54     int _active_fl_num;
55     SmartPtr<V4l2SubDevice> _fl_device[FLASH_MAX_NUM];
56     rk_aiq_flash_setting_t _flash_settings;
57 
58     enum RK_AIQ_V4L_FLASH_QUERY_TYPE_E {
59        RK_AIQ_V4L_FLASH_QUERY_TYPE_E_MIN,
60        RK_AIQ_V4L_FLASH_QUERY_TYPE_E_MAX,
61        RK_AIQ_V4L_FLASH_QUERY_TYPE_E_DEFAULT,
62        RK_AIQ_V4L_FLASH_QUERY_TYPE_E_STEP,
63        RK_AIQ_V4L_FLASH_QUERY_TYPE_E_LAST,
64     };
65 
66     struct rk_aiq_v4l_flash_info_s {
67       // [min, max, default, step]
68       int torch_power_info[RK_AIQ_V4L_FLASH_QUERY_TYPE_E_LAST];
69       int flash_power_info[RK_AIQ_V4L_FLASH_QUERY_TYPE_E_LAST];
70       bool fl_strth_adj_enable;
71       bool tc_strth_adj_enable;
72     };
73 
74     struct rk_aiq_v4l_flash_info_s _v4l_flash_info[FLASH_MAX_NUM];
75     bool _keep_status;
76 };
77 
78 } //namespace RkCam
79 #endif // _FLASH_LIGHT_H_
80