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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
*/
#include <linux/module.h>
#include <linux/build_bug.h>
#include "cam_req_mgr_dev.h"
#include "cam_sync_api.h"
#include "cam_smmu_api.h"
#include "cam_cpas_hw_intf.h"
#include "cam_cdm_intf_api.h"
#include "cam_ife_csid_dev.h"
#include "cam_vfe.h"
#include "cam_sfe_dev.h"
#include "cam_isp_dev.h"
#include "cam_res_mgr_api.h"
#include "cam_cci_dev.h"
#include "cam_sensor_dev.h"
#include "cam_actuator_dev.h"
#include "cam_csiphy_dev.h"
#include "cam_eeprom_dev.h"
#include "cam_ois_dev.h"
#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) || \
IS_REACHABLE(CONFIG_LEDS_QTI_FLASH)
#include "cam_flash_dev.h"
#endif
#include "cam_sysfs_init.h"
#include "a5_core.h"
#include "ipe_core.h"
#include "bps_core.h"
#include "cam_icp_subdev.h"
#include "jpeg_dma_core.h"
#include "jpeg_enc_core.h"
#include "cam_jpeg_dev.h"
#include "cam_fd_hw_intf.h"
#include "cam_fd_dev.h"
#include "cam_lrme_hw_intf.h"
#include "cam_lrme_dev.h"
// #include "cam_custom_dev.h"
// #include "cam_custom_csid_dev.h"
// #include "cam_custom_sub_mod_dev.h"
#ifdef CONFIG_SAMSUNG_SBI
#include "cam_sbi_dev.h"
#include "cam_sbi_hw_dev.h"
#include "cam_sbi_csid_dev.h"
#endif
#include "cam_debug_util.h"
#include "ope_dev_intf.h"
#include "cam_top_tpg.h"
#include "cam_tfe_dev.h"
#include "cam_tfe_csid530.h"
#include "cam_csid_ppi100.h"
#include "camera_main.h"
struct camera_submodule_component {
int (*init)(void);
void (*exit)(void);
};
struct camera_submodule {
char *name;
uint num_component;
const struct camera_submodule_component *component;
};
static const struct camera_submodule_component camera_base[] = {
{&cam_req_mgr_init, &cam_req_mgr_exit},
{&cam_sync_init, &cam_sync_exit},
{&cam_smmu_init_module, &cam_smmu_exit_module},
{&cam_cpas_dev_init_module, &cam_cpas_dev_exit_module},
{&cam_cdm_intf_init_module, &cam_cdm_intf_exit_module},
{&cam_hw_cdm_init_module, &cam_hw_cdm_exit_module},
};
static const struct camera_submodule_component camera_tfe[] = {
#ifdef CONFIG_SPECTRA_TFE
{&cam_csid_ppi100_init_module, &cam_csid_ppi100_exit_module},
{&cam_tfe_init_module, &cam_tfe_exit_module},
{&cam_tfe_csid530_init_module, &cam_tfe_csid530_exit_module},
#endif
};
static const struct camera_submodule_component camera_isp[] = {
#ifdef CONFIG_SPECTRA_ISP
{&cam_top_tpg_init_module, &cam_top_tpg_exit_module},
{&cam_ife_csid17x_init_module, &cam_ife_csid17x_exit_module},
{&cam_ife_csid_lite_init_module, &cam_ife_csid_lite_exit_module},
{&cam_vfe_init_module, &cam_vfe_exit_module},
#ifdef CONFIG_SPECTRA_SFE
{&cam_sfe_init_module, &cam_sfe_exit_module},
#endif
{&cam_isp_dev_init_module, &cam_isp_dev_exit_module},
#endif
};
static const struct camera_submodule_component camera_sensor[] = {
#ifdef CONFIG_SPECTRA_SENSOR
{&cam_res_mgr_init, &cam_res_mgr_exit},
{&cam_cci_init_module, &cam_cci_exit_module},
{&cam_csiphy_init_module, &cam_csiphy_exit_module},
{&cam_actuator_driver_init, &cam_actuator_driver_exit},
{&cam_sensor_driver_init, &cam_sensor_driver_exit},
{&cam_eeprom_driver_init, &cam_eeprom_driver_exit},
{&cam_ois_driver_init, &cam_ois_driver_exit},
#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) || \
IS_REACHABLE(CONFIG_LEDS_QTI_FLASH)
{&cam_flash_init_module, &cam_flash_exit_module},
#endif
{&cam_sysfs_init_module, &cam_sysfs_exit_module},
#endif
};
static const struct camera_submodule_component camera_icp[] = {
#ifdef CONFIG_SPECTRA_ICP
{&cam_a5_init_module, &cam_a5_exit_module},
{&cam_ipe_init_module, &cam_ipe_exit_module},
{&cam_bps_init_module, &cam_bps_exit_module},
{&cam_icp_init_module, &cam_icp_exit_module},
#endif
};
static const struct camera_submodule_component camera_ope[] = {
#ifdef CONFIG_SPECTRA_OPE
{&cam_ope_init_module, &cam_ope_exit_module},
{&cam_ope_subdev_init_module, &cam_ope_subdev_exit_module},
#endif
};
static const struct camera_submodule_component camera_jpeg[] = {
#ifdef CONFIG_SPECTRA_JPEG
{&cam_jpeg_enc_init_module, &cam_jpeg_enc_exit_module},
{&cam_jpeg_dma_init_module, &cam_jpeg_dma_exit_module},
{&cam_jpeg_dev_init_module, &cam_jpeg_dev_exit_module},
#endif
};
static const struct camera_submodule_component camera_fd[] = {
#ifdef CONFIG_SPECTRA_FD
{&cam_fd_hw_init_module, &cam_fd_hw_exit_module},
{&cam_fd_dev_init_module, &cam_fd_dev_exit_module},
#endif
};
static const struct camera_submodule_component camera_lrme[] = {
#ifdef CONFIG_SPECTRA_LRME
{&cam_lrme_hw_init_module, &cam_lrme_hw_exit_module},
{&cam_lrme_dev_init_module, &cam_lrme_dev_exit_module},
#endif
};
static const struct camera_submodule_component camera_custom[] = {
#ifdef CONFIG_SPECTRA_CUSTOM
{&cam_custom_hw_sub_module_init, &cam_custom_hw_sub_module_exit},
{&cam_custom_csid_driver_init, &cam_custom_csid_driver_exit},
{&cam_custom_dev_init_module, &cam_custom_dev_exit_module},
#endif
};
static const struct camera_submodule_component camera_sbi[] = {
#ifdef CONFIG_SAMSUNG_SBI
{&cam_sbi_hw_init_module, &cam_sbi_hw_exit_module},
{&cam_custom_csid_driver_init, &cam_custom_csid_driver_exit},
{&cam_sbi_dev_init_module, &cam_sbi_dev_exit_module},
#endif
};
static const struct camera_submodule submodule_table[] = {
{
.name = "Camera BASE",
.num_component = ARRAY_SIZE(camera_base),
.component = camera_base,
},
{
.name = "Camera TFE",
.num_component = ARRAY_SIZE(camera_tfe),
.component = camera_tfe,
},
{
.name = "Camera ISP",
.num_component = ARRAY_SIZE(camera_isp),
.component = camera_isp,
},
{
.name = "Camera SENSOR",
.num_component = ARRAY_SIZE(camera_sensor),
.component = camera_sensor
},
{
.name = "Camera ICP",
.num_component = ARRAY_SIZE(camera_icp),
.component = camera_icp,
},
{
.name = "Camera OPE",
.num_component = ARRAY_SIZE(camera_ope),
.component = camera_ope,
},
{
.name = "Camera JPEG",
.num_component = ARRAY_SIZE(camera_jpeg),
.component = camera_jpeg,
},
{
.name = "Camera FD",
.num_component = ARRAY_SIZE(camera_fd),
.component = camera_fd,
},
{
.name = "Camera LRME",
.num_component = ARRAY_SIZE(camera_lrme),
.component = camera_lrme,
},
{
.name = "Camera CUSTOM",
.num_component = ARRAY_SIZE(camera_custom),
.component = camera_custom,
},
{
.name = "Camera SBI",
.num_component = ARRAY_SIZE(camera_sbi),
.component = camera_sbi,
}
};
static int camera_verify_submodules(void)
{
int rc = 0;
int i, j, num_components;
for (i = 0; i < ARRAY_SIZE(submodule_table); i++) {
num_components = submodule_table[i].num_component;
for (j = 0; j < num_components; j++) {
if (!submodule_table[i].component[j].init ||
!submodule_table[i].component[j].exit) {
CAM_ERR(CAM_UTIL,
"%s module has init = %ps, exit = %ps",
submodule_table[i].name,
submodule_table[i].component[j].init,
submodule_table[i].component[j].exit);
rc = -EINVAL;
goto end;
}
}
}
end:
return rc;
}
static void __camera_exit(int i, int j)
{
uint num_exits;
/* Exit from current submodule */
for (j -= 1; j >= 0; j--)
submodule_table[i].component[j].exit();
/* Exit remaining submodules */
for (i -= 1; i >= 0; i--) {
num_exits = submodule_table[i].num_component;
for (j = num_exits - 1; j >= 0; j--)
submodule_table[i].component[j].exit();
}
}
static int camera_init(void)
{
int rc;
uint i, j, num_inits;
rc = camera_verify_submodules();
if (rc)
goto end_init;
/* For Probing all available submodules */
for (i = 0; i < ARRAY_SIZE(submodule_table); i++) {
num_inits = submodule_table[i].num_component;
CAM_DBG(CAM_UTIL, "Number of %s components: %u",
submodule_table[i].name, num_inits);
for (j = 0; j < num_inits; j++) {
rc = submodule_table[i].component[j].init();
if (rc) {
CAM_ERR(CAM_UTIL,
"%s module failure at %ps rc = %d",
submodule_table[i].name,
submodule_table[i].component[j].init,
rc);
__camera_exit(i, j);
goto end_init;
}
}
}
CAM_INFO(CAM_UTIL, "Spectra camera driver initialized");
end_init:
return rc;
}
static void camera_exit(void)
{
__camera_exit(ARRAY_SIZE(submodule_table), 0);
CAM_INFO(CAM_UTIL, "Spectra camera driver exited!");
}
module_init(camera_init);
module_exit(camera_exit);
MODULE_DESCRIPTION("Spectra camera driver");
MODULE_LICENSE("GPL v2");
|