hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#ifndef _TOOL_RKAIQ_MEDIA_H_
#define _TOOL_RKAIQ_MEDIA_H_
 
#include <errno.h>
#include <linux/videodev2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
 
#include <string>
 
#include "logger/log.h"
#include "mediactl-priv.h"
#include "mediactl.h"
#include "v4l2subdev.h"
 
#define MAX_MEDIA_NUM 20
#define MAX_CAM_NUM 20
#define SENSOR_ATTACHED_FLASH_MAX_NUM 2
 
#define VICAP_COMPACT_TEST_ON "echo 1 > /sys/devices/platform/rkcif_mipi_lvds/compact_test"
#define VICAP2_COMPACT_TEST_ON "echo 1 > /sys/devices/platform/rkcif_lite_mipi_lvds/compact_test"
 
typedef struct {
    int model_idx;
    int linked_sensor;
    std::string sensor_name;
    std::string sensor_subdev_path;
    std::string media_dev_path;
    std::string isp_dev_path;
    std::string csi_dev_path;
    std::string mpfbc_dev_path;
    std::string main_path;
    std::string self_path;
    std::string fbc_path;
    std::string rawwr0_path;
    std::string rawwr1_path;
    std::string rawwr2_path;
    std::string rawwr3_path;
    std::string dma_path;
    std::string rawrd0_m_path;
    std::string rawrd1_l_path;
    std::string rawrd2_s_path;
    std::string stats_path;
    std::string input_params_path;
    std::string mipi_luma_path;
    std::string mipi_dphy_rx_path;
} isp_info_t;
 
typedef struct {
    int model_idx;
    std::string media_dev_path;
    std::string pp_input_image_path;
    std::string pp_m_bypass_path;
    std::string pp_scale0_path;
    std::string pp_scale1_path;
    std::string pp_scale2_path;
    std::string pp_input_params_path;
    std::string pp_stats_path;
    std::string pp_dev_path;
} ispp_info_t;
 
typedef struct {
    int model_idx;
    int linked_sensor;
    std::string sensor_name;
    std::string sensor_subdev_path;
    std::string media_dev_path;
    std::string mipi_id0;
    std::string mipi_id1;
    std::string mipi_id2;
    std::string mipi_id3;
    std::string mipi_dphy_rx_path;
    std::string mipi_csi2_sd_path;
    std::string lvds_sd_path;
    std::string mipi_luma_path;
} cif_info_t;
 
typedef struct {
    int model_idx;
    int linked_sensor;
    std::string sensor_name;
    std::string sensor_subdev_path;
    std::string media_dev_path;
    std::string dvp_id0;
    std::string dvp_id1;
    std::string dvp_id2;
    std::string dvp_id3;
} dvp_info_t;
 
typedef struct {
    int model_idx;
    std::string sensor_name;
    std::string sensor_subdev_path;
    std::string media_dev_path;
    std::string module_lens_dev_name;
    std::string module_ircut_dev_name;
    int flash_num;
    std::string module_flash_dev_name[SENSOR_ATTACHED_FLASH_MAX_NUM];
    bool fl_strth_adj_sup;
    int flash_ir_num;
    std::string module_flash_ir_dev_name[SENSOR_ATTACHED_FLASH_MAX_NUM];
    bool fl_ir_strth_adj_sup;
} lens_info_t;
 
typedef struct {
    isp_info_t isp;
    ispp_info_t ispp;
    cif_info_t cif;
    dvp_info_t dvp;
    lens_info_t lens;
} media_info_t;
 
class RKAiqMedia
{
  public:
    RKAiqMedia();
    virtual ~RKAiqMedia() = default;
    int IsLinkSensor(struct media_device* device, int cam_index);
    std::string GetLinkSensorSubDev(struct media_device* device, int cam_index);
    std::string GetSensorName(struct media_device* device, int cam_index);
    void GetIsppSubDevs(int id, struct media_device* device, const char* devpath);
    void GetIspSubDevs(int id, struct media_device* device, const char* devpath);
    void GetCifSubDevs(int id, struct media_device* device, const char* devpath);
    void GetDvpSubDevs(int id, struct media_device* device, const char* devpath);
    void GetLensSubDevs(int id, struct media_device* device, const char* devpath, int count);
    int GetMediaInfo();
    int GetIspVer();
    int DumpMediaInfo();
    int LinkToIsp(bool enable = false);
    int LinkToSensor(int cam_index);
 
  public:
    std::string GetSensorName(int id)
    {
        if (media_info[id].isp.linked_sensor) {
            return media_info[id].isp.sensor_name;
        } else if (media_info[id].cif.linked_sensor) {
            return media_info[id].cif.sensor_name;
        } else if (media_info[id].dvp.linked_sensor) {
            return media_info[id].dvp.sensor_name;
        }
        return "";
    }
 
    media_info_t GetMediaInfoT(int id)
    {
        return media_info[id];
    }
 
  private:
    media_info_t media_info[MAX_CAM_NUM];
};
 
#endif // _TOOL_RKAIQ_MEDIA_H_