xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rk_stream/stream_cfg/MediaInfo.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  *  Copyright (c) 2021 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 #ifndef _MEDIA_INFO_H_
18 #define _MEDIA_INFO_H_
19 
20 #include <v4l2_device.h>
21 #include <map>
22 #include "mediactl/mediactl-priv.h"
23 #include <linux/v4l2-subdev.h>
24 #include "xcam_thread.h"
25 #include "xcam_log.h"
26 #include "Stream.h"
27 #include <time.h>
28 #include <unistd.h>
29 
30 using namespace XCam;
31 
32 namespace RkRawStream {
33 
34 //#define MAX_MEDIA_INDEX               16
35 //#define DEV_PATH_LEN                  64
36 //#define SENSOR_ATTACHED_FLASH_MAX_NUM 2
37 //#define MAX_CAM_NUM                   8
38 
39 //#define MAX_ISP_LINKED_VICAP_CNT      4
40 
41 #define STREAM_ISP_BUF_NUM 5
42 #define STREAM_VIPCAP_BUF_NUM 5
43 
44 /*
45 typedef struct {
46     int  model_idx;
47     int  logic_id;
48     int  phy_id; // physical isp id
49     int  linked_sensor;
50     bool is_multi_isp_mode; // isp-unit mode, 2 isp to 1
51     bool isMultiplex;      // muliplex mode, virtually sed by more than one sensor
52     bool linked_dvp;
53     bool valid;
54     char media_dev_path[DEV_PATH_LEN];
55     char isp_dev_path[DEV_PATH_LEN];
56     char csi_dev_path[DEV_PATH_LEN];
57     char mpfbc_dev_path[DEV_PATH_LEN];
58     char main_path[DEV_PATH_LEN];
59     char self_path[DEV_PATH_LEN];
60     char rawwr0_path[DEV_PATH_LEN];
61     char rawwr1_path[DEV_PATH_LEN];
62     char rawwr2_path[DEV_PATH_LEN];
63     char rawwr3_path[DEV_PATH_LEN];
64     char dma_path[DEV_PATH_LEN];
65     char rawrd0_m_path[DEV_PATH_LEN];
66     char rawrd1_l_path[DEV_PATH_LEN];
67     char rawrd2_s_path[DEV_PATH_LEN];
68     char stats_path[DEV_PATH_LEN];
69     char input_params_path[DEV_PATH_LEN];
70     char mipi_luma_path[DEV_PATH_LEN];
71     char mipi_dphy_rx_path[DEV_PATH_LEN];
72     char linked_vicap[MAX_ISP_LINKED_VICAP_CNT][DEV_PATH_LEN];
73 } rk_aiq_isp_t;
74 
75 typedef struct {
76     int  model_idx;
77     bool valid;
78     char media_dev_path[DEV_PATH_LEN];
79     char pp_input_image_path[DEV_PATH_LEN];
80     char pp_m_bypass_path[DEV_PATH_LEN];
81     char pp_scale0_path[DEV_PATH_LEN];
82     char pp_scale1_path[DEV_PATH_LEN];
83     char pp_scale2_path[DEV_PATH_LEN];
84     char pp_input_params_path[DEV_PATH_LEN];
85     char pp_stats_path[DEV_PATH_LEN];
86     char pp_tnr_params_path[DEV_PATH_LEN];
87     char pp_tnr_stats_path[DEV_PATH_LEN];
88     char pp_nr_params_path[DEV_PATH_LEN];
89     char pp_nr_stats_path[DEV_PATH_LEN];
90     char pp_fec_params_path[DEV_PATH_LEN];
91     char pp_dev_path[DEV_PATH_LEN];
92 } rk_aiq_ispp_t;
93 
94 typedef struct {
95     int isp_ver;
96     int awb_ver;
97     int aec_ver;
98     int afc_ver;
99     int ahdr_ver;
100     int blc_ver;
101     int dpcc_ver;
102     int anr_ver;
103     int debayer_ver;
104     int lsc_ver;
105     int ccm_ver;
106     int gamma_ver;
107     int gic_ver;
108     int sharp_ver;
109     int dehaze_ver;
110 } rk_aiq_hw_ver_t;
111 
112 typedef struct {
113     rk_aiq_isp_t isp_info[MAX_CAM_NUM];
114     rk_aiq_ispp_t ispp_info[MAX_CAM_NUM];
115     rk_aiq_hw_ver_t hw_ver_info;
116 } rk_aiq_isp_hw_info_t;
117 
118 typedef struct {
119     int  model_idx;
120     char media_dev_path[DEV_PATH_LEN];
121     char mipi_id0[DEV_PATH_LEN];
122     char mipi_id1[DEV_PATH_LEN];
123     char mipi_id2[DEV_PATH_LEN];
124     char mipi_id3[DEV_PATH_LEN];
125     char mipi_scl0[DEV_PATH_LEN];
126     char mipi_scl1[DEV_PATH_LEN];
127     char mipi_scl2[DEV_PATH_LEN];
128     char mipi_scl3[DEV_PATH_LEN];
129     char dvp_id0[DEV_PATH_LEN];
130     char dvp_id1[DEV_PATH_LEN];
131     char dvp_id2[DEV_PATH_LEN];
132     char dvp_id3[DEV_PATH_LEN];
133     char mipi_dphy_rx_path[DEV_PATH_LEN];
134     char mipi_csi2_sd_path[DEV_PATH_LEN];
135     char lvds_sd_path[DEV_PATH_LEN];
136     char mipi_luma_path[DEV_PATH_LEN];
137     char stream_cif_path[DEV_PATH_LEN];
138     char dvp_sof_sd_path[DEV_PATH_LEN];
139     char model_str[DEV_PATH_LEN];
140 } rk_aiq_cif_info_t;
141 
142 typedef struct {
143     rk_aiq_cif_info_t cif_info[MAX_CAM_NUM];
144     rk_aiq_hw_ver_t hw_ver_info;
145 } rk_aiq_cif_hw_info_t;
146 
147 typedef struct {
148     bool pdaf_support;
149     uint32_t pdaf_vc;
150     uint32_t pdaf_width;
151     uint32_t pdaf_height;
152     uint32_t pdaf_pixelformat;
153     uint32_t pdaf_code;
154     char pdaf_vdev[DEV_PATH_LEN];
155 } rk_sensor_pdaf_info_t;
156 
157 typedef struct {
158     std::string sensor_name;
159     std::string device_name;
160     std::string len_name;
161     std::string parent_media_dev;
162     int media_node_index;
163     int csi_port;
164     std::string module_lens_dev_name; // matched using mPhyModuleIndex
165     std::string module_ircut_dev_name;
166     int flash_num;
167     std::string module_flash_dev_name[SENSOR_ATTACHED_FLASH_MAX_NUM]; // matched using mPhyModuleIndex
168     bool fl_strth_adj_sup;
169     int flash_ir_num;
170     std::string module_flash_ir_dev_name[SENSOR_ATTACHED_FLASH_MAX_NUM];
171     bool fl_ir_strth_adj_sup;
172     std::string module_real_sensor_name; //parsed frome sensor entity name
173     std::string module_index_str; // parsed from sensor entity name
174     char phy_module_orient; // parsed from sensor entity name
175     std::vector<rk_frame_fmt_t>  frame_size;
176     rk_aiq_isp_t *isp_info;
177     rk_aiq_cif_info_t *cif_info;
178     rk_aiq_ispp_t *ispp_info;
179     bool linked_to_isp;
180     bool dvp_itf;
181     struct rkmodule_inf mod_info;
182 } rk_sensor_full_info_t;
183 */
184 
185 int8_t pixFmt2Bpp(uint32_t pixFmt);
186 
187 
188 class MediaInfo
189 {
190 public:
191     MediaInfo();
192     virtual ~MediaInfo();
193     rk_aiq_isp_hw_info_t mIspHwInfos;
194     rk_aiq_cif_hw_info_t mCifHwInfos;
195     std::map<std::string, SmartPtr<rk_aiq_static_info_t>> mCamHwInfos;
196     std::map<std::string, SmartPtr<rk_sensor_full_info_t>> mSensorHwInfos;
197     bool mIsMultiIspMode;
198     uint16_t mMultiIspExtendedPixel;
199     void findAttachedSubdevs(struct media_device *device, uint32_t count, rk_sensor_full_info_t *s_info);
200     XCamReturn initCamHwInfos();
201     rk_aiq_static_info_t* getStaticCamHwInfo(const char* sns_ent_name, uint16_t index = 0);
202     XCamReturn clearStaticCamHwInfo();
203     void getCamHwEntNames(char buf[12][32]);
204     rk_sensor_full_info_t* getSensorFullInfo(char* sns_ent_name, uint16_t index);
205     void offline(const char* isp_driver, const char* offline_sns_ent_name);
206 };
207 
208 }
209 #endif
210