Commit | Line | Data |
---|---|---|
1cac41cb MB |
1 | /* |
2 | * Samsung Exynos5 SoC series FIMC-IS driver | |
3 | * | |
4 | * exynos5 fimc-is core functions | |
5 | * | |
6 | * Copyright (c) 2011 Samsung Electronics Co., Ltd | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License version 2 as | |
10 | * published by the Free Software Foundation. | |
11 | */ | |
12 | ||
13 | #include <linux/pm_qos.h> | |
14 | #include <linux/device.h> | |
15 | ||
16 | #include "fimc-is-sysfs.h" | |
17 | #include "fimc-is-core.h" | |
18 | #include "fimc-is-err.h" | |
19 | #include "fimc-is-sec-define.h" | |
20 | #if defined (CONFIG_OIS_USE) | |
21 | #include "fimc-is-device-ois.h" | |
22 | #endif | |
23 | #ifdef CONFIG_AF_HOST_CONTROL | |
24 | #include "fimc-is-device-af.h" | |
25 | #endif | |
26 | #include "fimc-is-vender-specific.h" | |
27 | #include "fimc-is-interface-library.h" | |
28 | ||
29 | /* #define FORCE_CAL_LOAD */ | |
30 | ||
31 | extern struct device *fimc_is_dev; | |
32 | struct class *camera_class = NULL; | |
33 | struct device *camera_front_dev; | |
34 | struct device *camera_rear_dev; | |
35 | #ifdef CONFIG_SECURE_CAMERA_USE | |
36 | struct device *camera_secure_dev; | |
37 | #endif | |
38 | #if defined (CONFIG_OIS_USE) | |
39 | struct device *camera_ois_dev; | |
40 | #endif | |
41 | static struct fimc_is_core *sysfs_core; | |
42 | extern struct kset *devices_kset; | |
43 | extern struct fimc_is_lib_support gPtr_lib_support; | |
44 | ||
45 | extern bool crc32_fw_check; | |
46 | extern bool crc32_setfile_check; | |
47 | extern bool crc32_front_setfile_check; | |
48 | extern bool crc32_check; | |
49 | extern bool crc32_check_factory; | |
50 | extern bool fw_version_crc_check; | |
51 | extern bool is_latest_cam_module; | |
52 | extern bool is_final_cam_module; | |
53 | extern bool crc32_hifi_tunningfile_check; | |
54 | ||
55 | #ifdef CONFIG_COMPANION_USE | |
56 | extern bool crc32_c1_fw_check; | |
57 | extern bool crc32_c1_check; | |
58 | extern bool crc32_c1_check_factory; | |
59 | #endif /* CONFIG_COMPANION_USE */ | |
60 | extern bool crc32_check_factory_rear2; | |
61 | extern bool fw_version_crc_check; | |
62 | static struct fimc_is_from_info *pinfo = NULL; | |
63 | static struct fimc_is_from_info *finfo = NULL; | |
64 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_FRONT) | |
65 | extern bool crc32_check_factory_front; | |
66 | extern bool is_final_cam_module_front; | |
67 | static struct fimc_is_from_info *front_finfo = NULL; | |
68 | #endif | |
69 | ||
70 | #ifdef CAMERA_SYSFS_V2 | |
71 | static struct fimc_is_cam_info cam_infos[CAM_INFO_MAX]; | |
72 | #endif | |
73 | ||
74 | extern bool force_caldata_dump; | |
75 | #if defined (CONFIG_OIS_USE) | |
76 | static bool check_ois_power = false; | |
77 | int ois_threshold = 150; | |
78 | #ifdef CAMERA_REAR2_OIS | |
79 | int ois_threshold_rear2 = 150; | |
80 | #endif | |
81 | #endif | |
82 | static bool check_module_init = false; | |
83 | ||
84 | #ifdef CONFIG_COMPANION_FACTORY_VALIDATION | |
85 | extern int comp_fac_i2c_check; | |
86 | extern u16 comp_fac_valid_check; | |
87 | #endif | |
88 | ||
89 | #ifdef CONFIG_SECURE_CAMERA_USE | |
90 | extern bool is_final_cam_module_iris; | |
91 | extern bool is_iris_ver_read; | |
92 | extern bool is_iris_mtf_test_check; | |
93 | extern u8 is_iris_mtf_read_data[3]; /* 0:year 1:month 2:company */ | |
94 | #endif | |
95 | ||
96 | struct ssrm_camera_data { | |
97 | int operation; | |
98 | int cameraID; | |
99 | int previewSizeWidth; | |
100 | int previewSizeHeight; | |
101 | int previewMinFPS; | |
102 | int previewMaxFPS; | |
103 | int sensorOn; | |
104 | }; | |
105 | ||
106 | enum ssrm_camerainfo_operation { | |
107 | SSRM_CAMERA_INFO_CLEAR, | |
108 | SSRM_CAMERA_INFO_SET, | |
109 | SSRM_CAMERA_INFO_UPDATE, | |
110 | }; | |
111 | ||
112 | struct ssrm_camera_data SsrmCameraInfo[FIMC_IS_SENSOR_COUNT]; | |
113 | ||
114 | #ifdef CAMERA_SYSFS_V2 | |
115 | int fimc_is_get_cam_info(struct fimc_is_cam_info **caminfo) | |
116 | { | |
117 | *caminfo = cam_infos; | |
118 | return 0; | |
119 | } | |
120 | #endif | |
121 | ||
122 | static int read_from_firmware_version(int position) | |
123 | { | |
124 | struct device *is_dev = &sysfs_core->ischain[0].pdev->dev; | |
125 | int ret = 0; | |
126 | ||
127 | fimc_is_vender_check_hw_init_running(); | |
128 | fimc_is_sec_get_sysfs_pinfo(&pinfo); | |
129 | fimc_is_sec_get_sysfs_finfo(&finfo); | |
130 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_FRONT) | |
131 | fimc_is_sec_get_sysfs_finfo_front(&front_finfo); | |
132 | #endif | |
133 | ||
134 | if (((position == SENSOR_POSITION_REAR) && (!finfo->is_caldata_read)) | |
135 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_FRONT) | |
136 | || ((position == SENSOR_POSITION_FRONT) && (!front_finfo->is_caldata_read)) | |
137 | #endif | |
138 | ) { | |
139 | ret = fimc_is_sec_run_fw_sel(is_dev, position); | |
140 | if (ret) { | |
141 | err("fimc_is_sec_run_fw_sel is fail(%d)", ret); | |
142 | } | |
143 | } | |
144 | ||
145 | #ifdef CONFIG_COMPANION_USE | |
146 | if ((position == SENSOR_POSITION_REAR) && (!finfo->is_c1_caldata_read)) { | |
147 | fimc_is_sec_concord_fw_sel(sysfs_core, is_dev); | |
148 | } | |
149 | #endif | |
150 | ||
151 | return 0; | |
152 | } | |
153 | ||
154 | static int read_from_firmware_version_reload(int position) | |
155 | { | |
156 | int ret = 0; | |
157 | struct device *is_dev = &sysfs_core->ischain[0].pdev->dev; | |
158 | ||
159 | ret = fimc_is_sec_run_fw_sel(is_dev, position); | |
160 | if (ret) | |
161 | err("fimc_is_sec_run_fw_sel is fail(%d)", ret); | |
162 | ||
163 | return 0; | |
164 | } | |
165 | ||
166 | #if defined (CONFIG_OIS_USE) | |
167 | static bool read_ois_version(void) | |
168 | { | |
169 | bool ret = true; | |
170 | struct fimc_is_vender_specific *specific = sysfs_core->vender.private_data; | |
171 | ||
172 | if (!specific->running_rear_camera) { | |
173 | if (!specific->ois_ver_read || force_caldata_dump) { | |
174 | fimc_is_ois_gpio_on(sysfs_core); | |
175 | msleep(150); | |
176 | ||
177 | ret = fimc_is_ois_check_fw(sysfs_core); | |
178 | if (!specific->running_rear_camera) { | |
179 | fimc_is_ois_gpio_off(sysfs_core); | |
180 | } | |
181 | } | |
182 | } | |
183 | return ret; | |
184 | } | |
185 | #endif | |
186 | ||
187 | static ssize_t camera_front_sensorid_show(struct device *dev, | |
188 | struct device_attribute *attr, char *buf) | |
189 | { | |
190 | struct fimc_is_core *core = NULL; | |
191 | struct fimc_is_vender_specific *specific; | |
192 | ||
193 | int ret = 0; | |
194 | struct device *is_dev = &sysfs_core->ischain[0].pdev->dev; | |
195 | ||
196 | if (force_caldata_dump == false) { | |
197 | ret = fimc_is_sec_run_fw_sel(is_dev, SENSOR_POSITION_FRONT); | |
198 | if (ret) { | |
199 | err("fimc_is_sec_run_fw_sel is fail(%d)", ret); | |
200 | } | |
201 | } | |
202 | ||
203 | core = (struct fimc_is_core *)dev_get_drvdata(fimc_is_dev); | |
204 | specific = core->vender.private_data; | |
205 | ||
206 | dev_info(dev, "%s: E", __func__); | |
207 | ||
208 | return sprintf(buf, "%d\n", specific->front_sensor_id); | |
209 | } | |
210 | ||
211 | static ssize_t camera_rear_sensorid_show(struct device *dev, | |
212 | struct device_attribute *attr, char *buf) | |
213 | { | |
214 | struct fimc_is_core *core = NULL; | |
215 | struct fimc_is_vender_specific *specific; | |
216 | int ret = 0; | |
217 | struct device *is_dev = &sysfs_core->ischain[0].pdev->dev; | |
218 | ||
219 | if (force_caldata_dump == false) { | |
220 | ret = fimc_is_sec_run_fw_sel(is_dev, SENSOR_POSITION_REAR); | |
221 | if (ret) { | |
222 | err("fimc_is_sec_run_fw_sel is fail(%d)", ret); | |
223 | } | |
224 | } | |
225 | ||
226 | core = (struct fimc_is_core *)dev_get_drvdata(fimc_is_dev); | |
227 | specific = core->vender.private_data; | |
228 | dev_info(dev, "%s: E", __func__); | |
229 | ||
230 | return sprintf(buf, "%d\n", specific->rear_sensor_id); | |
231 | } | |
232 | ||
233 | static DEVICE_ATTR(front_sensorid, S_IRUGO, camera_front_sensorid_show, NULL); | |
234 | static DEVICE_ATTR(rear_sensorid, S_IRUGO, camera_rear_sensorid_show, NULL); | |
235 | ||
236 | static ssize_t camera_ssrm_camera_info_store(struct device *dev, | |
237 | struct device_attribute *attr, | |
238 | const char *buf, size_t count) | |
239 | { | |
240 | struct ssrm_camera_data temp; | |
241 | int ret_count; | |
242 | int index = -1; | |
243 | int i = 0; | |
244 | ||
245 | ret_count = sscanf(buf, "%d%d%d%d%d%d%d", &temp.operation, &temp.cameraID, &temp.previewMinFPS, | |
246 | &temp.previewMaxFPS, &temp.previewSizeWidth, &temp.previewSizeHeight, &temp.sensorOn); | |
247 | ||
b44930e0 | 248 | if (ret_count > sizeof(SsrmCameraInfo)/(sizeof(int))) |
1cac41cb MB |
249 | return -EINVAL; |
250 | ||
251 | switch (temp.operation) { | |
252 | case SSRM_CAMERA_INFO_CLEAR: | |
253 | for (i = 0; i < FIMC_IS_SENSOR_COUNT; i++) { /* clear */ | |
254 | if (SsrmCameraInfo[i].cameraID == temp.cameraID) { | |
255 | SsrmCameraInfo[i].previewMaxFPS = 0; | |
256 | SsrmCameraInfo[i].previewMinFPS = 0; | |
257 | SsrmCameraInfo[i].previewSizeHeight = 0; | |
258 | SsrmCameraInfo[i].previewSizeWidth = 0; | |
259 | SsrmCameraInfo[i].sensorOn = 0; | |
260 | SsrmCameraInfo[i].cameraID = -1; | |
261 | } | |
262 | } | |
263 | break; | |
264 | ||
265 | case SSRM_CAMERA_INFO_SET: | |
266 | for (i = 0; i < FIMC_IS_SENSOR_COUNT; i++) { /* find empty space*/ | |
267 | if (SsrmCameraInfo[i].cameraID == -1) { | |
268 | index = i; | |
269 | break; | |
270 | } | |
271 | } | |
272 | ||
273 | if (index == -1) | |
274 | return -EPERM; | |
275 | ||
276 | memcpy(&SsrmCameraInfo[i], &temp, sizeof(temp)); | |
277 | break; | |
278 | ||
279 | case SSRM_CAMERA_INFO_UPDATE: | |
280 | for (i = 0; i < FIMC_IS_SENSOR_COUNT; i++) { | |
281 | if (SsrmCameraInfo[i].cameraID == temp.cameraID) { | |
282 | SsrmCameraInfo[i].previewMaxFPS = temp.previewMaxFPS; | |
283 | SsrmCameraInfo[i].previewMinFPS = temp.previewMinFPS; | |
284 | SsrmCameraInfo[i].previewSizeHeight = temp.previewSizeHeight; | |
285 | SsrmCameraInfo[i].previewSizeWidth = temp.previewSizeWidth; | |
286 | SsrmCameraInfo[i].sensorOn = temp.sensorOn; | |
287 | break; | |
288 | } | |
289 | } | |
290 | break; | |
291 | default: | |
292 | break; | |
293 | } | |
294 | ||
295 | return count; | |
296 | } | |
297 | ||
298 | static ssize_t camera_ssrm_camera_info_show(struct device *dev, | |
299 | struct device_attribute *attr, char *buf) | |
300 | { | |
301 | char temp_buffer[50] = {0,}; | |
302 | int i = 0; | |
303 | ||
304 | for (i = 0; i < FIMC_IS_SENSOR_COUNT; i++) { | |
305 | if (SsrmCameraInfo[i].cameraID != -1) { | |
306 | strncat(buf, "ID=", strlen("ID=")); | |
307 | sprintf(temp_buffer, "%d;", SsrmCameraInfo[i].cameraID); | |
308 | strncat(buf, temp_buffer, strlen(temp_buffer)); | |
309 | ||
310 | strncat(buf, "ON=", strlen("ON=")); | |
311 | sprintf(temp_buffer, "%d;", SsrmCameraInfo[i].sensorOn); | |
312 | strncat(buf, temp_buffer, strlen(temp_buffer)); | |
313 | ||
314 | if (SsrmCameraInfo[i].previewMinFPS && SsrmCameraInfo[i].previewMaxFPS) { | |
315 | strncat(buf, "FPS=", strlen("FPS=")); | |
316 | sprintf(temp_buffer, "%d,%d;", | |
317 | SsrmCameraInfo[i].previewMinFPS, SsrmCameraInfo[i].previewMaxFPS); | |
318 | strncat(buf, temp_buffer, strlen(temp_buffer)); | |
319 | } | |
320 | if (SsrmCameraInfo[i].previewSizeWidth && SsrmCameraInfo[i].previewSizeHeight) { | |
321 | strncat(buf, "SIZE=", strlen("SIZE=")); | |
322 | sprintf(temp_buffer, "%d,%d;", | |
323 | SsrmCameraInfo[i].previewSizeWidth, SsrmCameraInfo[i].previewSizeHeight); | |
324 | strncat(buf, temp_buffer, strlen(temp_buffer)); | |
325 | } | |
326 | strncat(buf, "\n", strlen("\n")); | |
327 | } | |
328 | } | |
329 | return strlen(buf); | |
330 | } | |
331 | ||
332 | static DEVICE_ATTR(ssrm_camera_info, 0644, camera_ssrm_camera_info_show, camera_ssrm_camera_info_store); | |
333 | ||
334 | #ifdef CONFIG_SECURE_CAMERA_USE | |
335 | static ssize_t camera_secure_sensorid_show(struct device *dev, | |
336 | struct device_attribute *attr, char *buf) | |
337 | { | |
338 | struct fimc_is_core *core = NULL; | |
339 | struct fimc_is_vender_specific *specific; | |
340 | ||
341 | core = (struct fimc_is_core *)dev_get_drvdata(fimc_is_dev); | |
342 | specific = core->vender.private_data; | |
343 | ||
344 | dev_info(dev, "%s: E", __func__); | |
345 | ||
346 | return sprintf(buf, "%d\n", specific->secure_sensor_id); | |
347 | } | |
348 | static DEVICE_ATTR(secure_sensorid, S_IRUGO, camera_secure_sensorid_show, NULL); | |
349 | #endif | |
350 | ||
351 | static int fimc_is_get_sensor_data(struct device *dev, char *maker, char *name, int position) | |
352 | { | |
353 | struct fimc_is_core *core; | |
354 | struct fimc_is_vender_specific *specific = NULL; | |
355 | struct fimc_is_device_sensor *device; | |
356 | struct fimc_is_module_enum *module; | |
357 | int sensor_id = 0; | |
358 | int i = 0; | |
359 | ||
360 | if (!fimc_is_dev) { | |
361 | dev_err(dev, "%s: fimc_is_dev is not yet probed", __func__); | |
362 | return -ENODEV; | |
363 | } | |
364 | ||
365 | core = (struct fimc_is_core *)dev_get_drvdata(fimc_is_dev); | |
366 | if (!core) { | |
367 | dev_err(dev, "%s: core is NULL", __func__); | |
368 | return -EINVAL; | |
369 | } | |
370 | ||
371 | specific = core->vender.private_data; | |
372 | ||
373 | if (position == SENSOR_POSITION_REAR) { | |
374 | sensor_id = specific->rear_sensor_id; | |
375 | } else if(position == SENSOR_POSITION_FRONT) { | |
376 | sensor_id = specific->front_sensor_id; | |
377 | } | |
378 | #ifdef CONFIG_SECURE_CAMERA_USE | |
379 | else if(position == SENSOR_POSITION_SECURE) { | |
380 | sensor_id = specific->secure_sensor_id; | |
381 | } | |
382 | #endif | |
383 | else { | |
384 | dev_err(dev, "%s: position value is wrong", __func__); | |
385 | return -EINVAL; | |
386 | } | |
387 | ||
388 | for (i = 0; i < FIMC_IS_SENSOR_COUNT; i++) { | |
389 | device = &core->sensor[i]; | |
390 | fimc_is_search_sensor_module(&core->sensor[i], sensor_id, &module); | |
391 | if (module) | |
392 | break; | |
393 | } | |
394 | ||
395 | if(module) { | |
396 | if (maker != NULL) | |
397 | sprintf(maker, "%s", module->sensor_maker ? | |
398 | module->sensor_maker : "UNKNOWN"); | |
399 | if (name != NULL) | |
400 | sprintf(name, "%s", module->sensor_name ? | |
401 | module->sensor_name : "UNKNOWN"); | |
402 | return 0; | |
403 | } | |
404 | ||
405 | dev_err(dev, "%s: there's no matched sensor id", __func__); | |
406 | ||
407 | return -ENODEV; | |
408 | } | |
409 | ||
410 | static ssize_t camera_front_camtype_show(struct device *dev, | |
411 | struct device_attribute *attr, char *buf) | |
412 | { | |
413 | char sensor_maker[50]; | |
414 | char sensor_name[50]; | |
415 | int ret; | |
416 | ||
417 | ret = fimc_is_get_sensor_data(dev, sensor_maker, sensor_name, SENSOR_POSITION_FRONT); | |
418 | ||
419 | if (ret < 0) | |
420 | return sprintf(buf, "UNKNOWN_UNKNOWN_FIMC_IS\n"); | |
421 | else | |
422 | return sprintf(buf, "%s_%s_FIMC_IS\n", sensor_maker, sensor_name); | |
423 | } | |
424 | ||
425 | static ssize_t camera_front_camfw_show(struct device *dev, | |
426 | struct device_attribute *attr, char *buf) | |
427 | { | |
428 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_FRONT) | |
429 | char command_ack[20] = {0, }; | |
430 | ||
431 | fimc_is_vender_check_hw_init_running(); | |
432 | fimc_is_sec_get_sysfs_finfo_front(&front_finfo); | |
433 | if (force_caldata_dump || !front_finfo->is_check_cal_reload) { | |
434 | struct fimc_is_vender_specific *specific = sysfs_core->vender.private_data; | |
435 | ||
436 | if (specific->running_front_camera == false) | |
437 | read_from_firmware_version_reload(SENSOR_POSITION_FRONT); | |
438 | } else { | |
439 | read_from_firmware_version(SENSOR_POSITION_FRONT); | |
440 | } | |
441 | ||
442 | if (!fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_FRONT)) { | |
443 | err(" NG, invalid FROM version"); | |
444 | strcpy(command_ack, "NG_CD3"); | |
445 | return sprintf(buf, "%s %s\n", front_finfo->header_ver, command_ack); | |
446 | } | |
447 | ||
448 | if (crc32_check_factory_front) { | |
449 | return sprintf(buf, "%s %s\n", front_finfo->header_ver, front_finfo->header_ver); | |
450 | } else { | |
451 | err(" NG, crc check fail"); | |
452 | strcpy(command_ack, "NG_"); | |
453 | if (!crc32_check_factory_front) | |
454 | strcat(command_ack, "CD3"); | |
455 | if (front_finfo->header_ver[3] != 'L') | |
456 | strcat(command_ack, "_Q"); | |
457 | return sprintf(buf, "%s %s\n", front_finfo->header_ver, command_ack); | |
458 | } | |
459 | #else | |
460 | char sensor_name[50]; | |
461 | int ret; | |
462 | ||
463 | ret = fimc_is_get_sensor_data(dev, NULL, sensor_name, SENSOR_POSITION_FRONT); | |
464 | ||
465 | if (ret < 0) | |
466 | return sprintf(buf, "UNKNOWN UNKNOWN\n"); | |
467 | else | |
468 | return sprintf(buf, "%s N\n", sensor_name); | |
469 | #endif | |
470 | } | |
471 | ||
472 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_FRONT) | |
473 | static ssize_t camera_front_camfw_full_show(struct device *dev, | |
474 | struct device_attribute *attr, char *buf) | |
475 | { | |
476 | char command_ack[20] = {0, }; | |
477 | ||
478 | read_from_firmware_version(SENSOR_POSITION_FRONT); | |
479 | ||
480 | if (!fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_FRONT)) { | |
481 | err(" NG, invalid FROM version"); | |
482 | strcpy(command_ack, "NG_CD3"); | |
483 | return sprintf(buf, "%s %s %s\n", front_finfo->header_ver, "N", command_ack); | |
484 | } | |
485 | ||
486 | if (crc32_check_factory_front) { | |
487 | return sprintf(buf, "%s %s %s\n", front_finfo->header_ver, "N", front_finfo->header_ver); | |
488 | } else { | |
489 | err(" NG, crc check fail"); | |
490 | strcpy(command_ack, "NG_"); | |
491 | if (!crc32_check_factory_front) | |
492 | strcat(command_ack, "CD3"); | |
493 | if (front_finfo->header_ver[3] != 'L') | |
494 | strcat(command_ack, "_Q"); | |
495 | return sprintf(buf, "%s %s %s\n", front_finfo->header_ver, "N", command_ack); | |
496 | } | |
497 | } | |
498 | ||
499 | static ssize_t camera_front_checkfw_factory_show(struct device *dev, | |
500 | struct device_attribute *attr, char *buf) | |
501 | { | |
502 | char command_ack[10] = {0, }; | |
503 | ||
504 | read_from_firmware_version(SENSOR_POSITION_FRONT); | |
505 | ||
506 | if (!fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_FRONT)) { | |
507 | err(" NG, invalid FROM version"); | |
508 | #ifdef CAMERA_SYSFS_V2 | |
509 | return sprintf(buf, "%s\n", "NG_VER"); | |
510 | #else | |
511 | return sprintf(buf, "%s\n", "NG"); | |
512 | #endif | |
513 | } | |
514 | ||
515 | if (crc32_check_factory_front) { | |
516 | if (!is_final_cam_module_front) { | |
517 | err(" NG, not final cam module"); | |
518 | #ifdef CAMERA_SYSFS_V2 | |
519 | strcpy(command_ack, "NG_VER\n"); | |
520 | #else | |
521 | strcpy(command_ack, "NG\n"); | |
522 | #endif | |
523 | } else { | |
524 | strcpy(command_ack, "OK\n"); | |
525 | } | |
526 | } else { | |
527 | err(" NG, crc check fail"); | |
528 | #ifdef CAMERA_SYSFS_V2 | |
529 | strcpy(command_ack, "NG_CRC\n"); | |
530 | #else | |
531 | strcpy(command_ack, "NG\n"); | |
532 | #endif | |
533 | } | |
534 | return sprintf(buf, "%s", command_ack); | |
535 | } | |
536 | #endif | |
537 | ||
538 | #ifdef CAMERA_SYSFS_V2 | |
539 | static ssize_t camera_front_info_show(struct device *dev, | |
540 | struct device_attribute *attr, char *buf) | |
541 | { | |
542 | char camera_info[130] = {0, }; | |
543 | #ifdef CONFIG_OF | |
544 | struct fimc_is_cam_info *cam_info = &(cam_infos[CAM_INFO_FRONT]); | |
545 | if(!cam_info->valid) { | |
546 | strcpy(camera_info, "ISP=NULL;CALMEM=NULL;READVER=NULL;COREVOLT=NULL;UPGRADE=NULL;" | |
547 | "FWWRITE=NULL;FWDUMP=NULL;CC=NULL;OIS=NULL;VALID=N"); | |
548 | ||
549 | return sprintf(buf, "%s\n", camera_info); | |
550 | } else { | |
551 | strcpy(camera_info, "ISP="); | |
552 | switch(cam_info->isp) { | |
553 | case CAM_INFO_ISP_TYPE_INTERNAL : | |
554 | strncat(camera_info, "INT;", strlen("INT;")); | |
555 | break; | |
556 | case CAM_INFO_ISP_TYPE_EXTERNAL : | |
557 | strncat(camera_info, "EXT;", strlen("EXT;")); | |
558 | break; | |
559 | case CAM_INFO_ISP_TYPE_SOC : | |
560 | strncat(camera_info, "SOC;", strlen("SOC;")); | |
561 | break; | |
562 | default : | |
563 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
564 | break; | |
565 | } | |
566 | ||
567 | strncat(camera_info, "CALMEM=", strlen("CALMEM=")); | |
568 | switch(cam_info->cal_memory) { | |
569 | case CAM_INFO_CAL_MEM_TYPE_NONE : | |
570 | strncat(camera_info, "N;", strlen("N;")); | |
571 | break; | |
572 | case CAM_INFO_CAL_MEM_TYPE_FROM : | |
573 | case CAM_INFO_CAL_MEM_TYPE_EEPROM : | |
574 | case CAM_INFO_CAL_MEM_TYPE_OTP : | |
575 | strncat(camera_info, "Y;", strlen("Y;")); | |
576 | break; | |
577 | default : | |
578 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
579 | break; | |
580 | } | |
581 | ||
582 | strncat(camera_info, "READVER=", strlen("READVER=")); | |
583 | switch(cam_info->read_version) { | |
584 | case CAM_INFO_READ_VER_SYSFS : | |
585 | strncat(camera_info, "SYSFS;", strlen("SYSFS;")); | |
586 | break; | |
587 | case CAM_INFO_READ_VER_CAMON : | |
588 | strncat(camera_info, "CAMON;", strlen("CAMON;")); | |
589 | break; | |
590 | default : | |
591 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
592 | break; | |
593 | } | |
594 | ||
595 | strncat(camera_info, "COREVOLT=", strlen("COREVOLT=")); | |
596 | switch(cam_info->core_voltage) { | |
597 | case CAM_INFO_CORE_VOLT_NONE : | |
598 | strncat(camera_info, "N;", strlen("N;")); | |
599 | break; | |
600 | case CAM_INFO_CORE_VOLT_USE : | |
601 | strncat(camera_info, "Y;", strlen("Y;")); | |
602 | break; | |
603 | default : | |
604 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
605 | break; | |
606 | } | |
607 | ||
608 | strncat(camera_info, "UPGRADE=", strlen("UPGRADE=")); | |
609 | switch(cam_info->upgrade) { | |
610 | case CAM_INFO_FW_UPGRADE_NONE : | |
611 | strncat(camera_info, "N;", strlen("N;")); | |
612 | break; | |
613 | case CAM_INFO_FW_UPGRADE_SYSFS : | |
614 | strncat(camera_info, "SYSFS;", strlen("SYSFS;")); | |
615 | break; | |
616 | case CAM_INFO_FW_UPGRADE_CAMON : | |
617 | strncat(camera_info, "CAMON;", strlen("CAMON;")); | |
618 | break; | |
619 | default : | |
620 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
621 | break; | |
622 | } | |
623 | ||
624 | strncat(camera_info, "FWWRITE=", strlen("FWWRITE=")); | |
625 | switch(cam_info->fw_write) { | |
626 | case CAM_INFO_FW_WRITE_NONE : | |
627 | strncat(camera_info, "N;", strlen("N;")); | |
628 | break; | |
629 | case CAM_INFO_FW_WRITE_OS : | |
630 | strncat(camera_info, "OS;", strlen("OS;")); | |
631 | break; | |
632 | case CAM_INFO_FW_WRITE_SD : | |
633 | strncat(camera_info, "SD;", strlen("SD;")); | |
634 | break; | |
635 | case CAM_INFO_FW_WRITE_ALL : | |
636 | strncat(camera_info, "ALL;", strlen("ALL;")); | |
637 | break; | |
638 | default : | |
639 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
640 | break; | |
641 | } | |
642 | ||
643 | strncat(camera_info, "FWDUMP=", strlen("FWDUMP=")); | |
644 | switch(cam_info->fw_dump) { | |
645 | case CAM_INFO_FW_DUMP_NONE : | |
646 | strncat(camera_info, "N;", strlen("N;")); | |
647 | break; | |
648 | case CAM_INFO_FW_DUMP_USE : | |
649 | strncat(camera_info, "Y;", strlen("Y;")); | |
650 | break; | |
651 | default : | |
652 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
653 | break; | |
654 | } | |
655 | ||
656 | strncat(camera_info, "CC=", strlen("CC=")); | |
657 | switch(cam_info->companion) { | |
658 | case CAM_INFO_COMPANION_NONE : | |
659 | strncat(camera_info, "N;", strlen("N;")); | |
660 | break; | |
661 | case CAM_INFO_COMPANION_USE : | |
662 | strncat(camera_info, "Y;", strlen("Y;")); | |
663 | break; | |
664 | default : | |
665 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
666 | break; | |
667 | } | |
668 | ||
669 | strncat(camera_info, "OIS=", strlen("OIS=")); | |
670 | switch(cam_info->ois) { | |
671 | case CAM_INFO_OIS_NONE : | |
672 | strncat(camera_info, "N;", strlen("N;")); | |
673 | break; | |
674 | case CAM_INFO_OIS_USE : | |
675 | strncat(camera_info, "Y;", strlen("Y;")); | |
676 | break; | |
677 | default : | |
678 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
679 | break; | |
680 | } | |
681 | ||
682 | strncat(camera_info, "VALID=", strlen("VALID=")); | |
683 | switch(cam_info->valid) { | |
684 | case CAM_INFO_INVALID : | |
685 | strncat(camera_info, "N;", strlen("N;")); | |
686 | break; | |
687 | case CAM_INFO_VALID : | |
688 | strncat(camera_info, "Y;", strlen("Y;")); | |
689 | break; | |
690 | default : | |
691 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
692 | break; | |
693 | } | |
694 | ||
695 | return sprintf(buf, "%s\n", camera_info); | |
696 | } | |
697 | #endif | |
698 | strcpy(camera_info, "ISP=NULL;CALMEM=NULL;READVER=NULL;COREVOLT=NULL;UPGRADE=NULL;" | |
699 | "FWWRITE=NULL;FWDUMP=NULL;CC=NULL;OIS=NULL;VALID=N"); | |
700 | ||
701 | return sprintf(buf, "%s\n", camera_info); | |
702 | } | |
703 | #endif | |
704 | ||
705 | static DEVICE_ATTR(front_camtype, S_IRUGO, | |
706 | camera_front_camtype_show, NULL); | |
707 | #ifdef CAMERA_SYSFS_V2 | |
708 | static DEVICE_ATTR(front_caminfo, S_IRUGO, | |
709 | camera_front_info_show, NULL); | |
710 | #endif | |
711 | static DEVICE_ATTR(front_camfw, S_IRUGO, camera_front_camfw_show, NULL); | |
712 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_FRONT) | |
713 | static DEVICE_ATTR(front_camfw_full, S_IRUGO, camera_front_camfw_full_show, NULL); | |
714 | static DEVICE_ATTR(front_checkfw_factory, S_IRUGO, camera_front_checkfw_factory_show, NULL); | |
715 | #endif | |
716 | ||
717 | #ifdef CAMERA_MODULE_DUALIZE | |
718 | static ssize_t camera_rear_writefw_show(struct device *dev, | |
719 | struct device_attribute *attr, char *buf) | |
720 | { | |
721 | /* Disabled for product. Security Hole */ | |
722 | #if 0 | |
723 | struct device *is_dev = &sysfs_core->ischain[0].pdev->dev; | |
724 | int ret = 0; | |
725 | ||
726 | ret = fimc_is_sec_write_fw(sysfs_core, is_dev); | |
727 | ||
728 | if (ret) | |
729 | return sprintf(buf, "NG\n"); | |
730 | else | |
731 | return sprintf(buf, "OK\n"); | |
732 | #else | |
733 | return sprintf(buf, "OK\n"); | |
734 | #endif | |
735 | } | |
736 | #endif | |
737 | ||
738 | static ssize_t camera_rear_camtype_show(struct device *dev, | |
739 | struct device_attribute *attr, char *buf) | |
740 | { | |
741 | char sensor_maker[50]; | |
742 | char sensor_name[50]; | |
743 | int ret; | |
744 | ||
745 | ret = fimc_is_get_sensor_data(dev, sensor_maker, sensor_name, SENSOR_POSITION_REAR); | |
746 | ||
747 | if (ret < 0) | |
748 | return sprintf(buf, "UNKNOWN_UNKNOWN_FIMC_IS\n"); | |
749 | else | |
750 | return sprintf(buf, "%s_%s_FIMC_IS\n", sensor_maker, sensor_name); | |
751 | } | |
752 | ||
753 | static ssize_t camera_rear_camfw_show(struct device *dev, | |
754 | struct device_attribute *attr, char *buf) | |
755 | { | |
756 | char command_ack[20] = {0, }; | |
757 | char *loaded_fw; | |
758 | struct exynos_platform_fimc_is *core_pdata = NULL; | |
759 | ||
760 | core_pdata = dev_get_platdata(fimc_is_dev); | |
761 | ||
762 | fimc_is_vender_check_hw_init_running(); | |
763 | fimc_is_sec_get_sysfs_finfo(&finfo); | |
764 | if (force_caldata_dump || !finfo->is_check_cal_reload) { | |
765 | struct fimc_is_vender_specific *specific = sysfs_core->vender.private_data; | |
766 | ||
767 | if (specific->running_rear_camera == false) | |
768 | read_from_firmware_version_reload(SENSOR_POSITION_REAR); | |
769 | } else { | |
770 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
771 | } | |
772 | ||
773 | if (!fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_REAR)) { | |
774 | err(" NG, invalid FROM version"); | |
775 | #ifdef CAMERA_REAR2 | |
776 | strcpy(command_ack, "NG_FWCDFW1CD1CD4"); | |
777 | #else | |
778 | strcpy(command_ack, "NG_FWCDFW1CD1"); | |
779 | #endif | |
780 | return sprintf(buf, "%s %s\n", "NULL", command_ack); | |
781 | } | |
782 | ||
783 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_REAR) | |
784 | loaded_fw = pinfo->header_ver; | |
785 | #else | |
786 | fimc_is_sec_get_loaded_fw(&loaded_fw); | |
787 | #endif | |
788 | ||
789 | if (fw_version_crc_check) { | |
790 | if (crc32_fw_check && crc32_check_factory && crc32_setfile_check | |
791 | && crc32_front_setfile_check | |
792 | #ifdef CONFIG_COMPANION_USE | |
793 | && crc32_c1_fw_check && crc32_c1_check_factory | |
794 | #endif | |
795 | && crc32_check_factory_rear2 | |
796 | && crc32_hifi_tunningfile_check | |
797 | ) { | |
798 | return sprintf(buf, "%s %s\n", finfo->header_ver, loaded_fw); | |
799 | } else { | |
800 | err(" NG, crc check fail"); | |
801 | strcpy(command_ack, "NG_"); | |
802 | if (!crc32_fw_check) | |
803 | strcat(command_ack, "FW"); | |
804 | if (!crc32_check_factory) | |
805 | strcat(command_ack, "CD"); | |
806 | if (!crc32_setfile_check || !crc32_front_setfile_check) | |
807 | strcat(command_ack, "SET"); | |
808 | #ifdef CONFIG_COMPANION_USE | |
809 | if (!crc32_c1_fw_check) | |
810 | strcat(command_ack, "FW1"); | |
811 | if (!crc32_c1_check_factory) | |
812 | strcat(command_ack, "CD1"); | |
813 | #endif | |
814 | if (!crc32_check_factory_rear2) | |
815 | strcat(command_ack, "CD4"); | |
816 | if (finfo->header_ver[3] != 'L') | |
817 | strcat(command_ack, "_Q"); | |
818 | return sprintf(buf, "%s %s\n", finfo->header_ver, command_ack); | |
819 | } | |
820 | } else { | |
821 | err(" NG, fw ver crc check fail"); | |
822 | strcpy(command_ack, "NG_"); | |
823 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_REAR) | |
824 | strcat(command_ack, "CD"); | |
825 | #else | |
826 | strcat(command_ack, "FWCD"); | |
827 | #endif | |
828 | #ifdef CONFIG_COMPANION_USE | |
829 | strcat(command_ack, "FW1CD1"); | |
830 | #endif | |
831 | return sprintf(buf, "%s %s\n", finfo->header_ver, command_ack); | |
832 | } | |
833 | } | |
834 | ||
835 | static ssize_t camera_rear_camfw_full_show(struct device *dev, | |
836 | struct device_attribute *attr, char *buf) | |
837 | { | |
838 | char command_ack[20] = {0, }; | |
839 | char *loaded_fw; | |
840 | ||
841 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
842 | ||
843 | if (!fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_REAR)) { | |
844 | err(" NG, invalid FROM version"); | |
845 | strcpy(command_ack, "NG_FWCDFW1CD1"); | |
846 | return sprintf(buf, "%s %s %s\n", "NULL", "NULL", command_ack); | |
847 | } | |
848 | ||
849 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_REAR) | |
850 | loaded_fw = pinfo->header_ver; | |
851 | #else | |
852 | fimc_is_sec_get_loaded_fw(&loaded_fw); | |
853 | #endif | |
854 | ||
855 | if (fw_version_crc_check) { | |
856 | if (crc32_fw_check && crc32_check_factory && crc32_setfile_check | |
857 | && crc32_front_setfile_check | |
858 | #ifdef CONFIG_COMPANION_USE | |
859 | && crc32_c1_fw_check && crc32_c1_check_factory | |
860 | #endif | |
861 | && crc32_check_factory_rear2 | |
862 | && crc32_hifi_tunningfile_check | |
863 | ) { | |
864 | return sprintf(buf, "%s %s %s\n", finfo->header_ver, pinfo->header_ver, loaded_fw); | |
865 | } else { | |
866 | err(" NG, crc check fail"); | |
867 | strcpy(command_ack, "NG_"); | |
868 | if (!crc32_fw_check) | |
869 | strcat(command_ack, "FW"); | |
870 | if (!crc32_check_factory) | |
871 | strcat(command_ack, "CD"); | |
872 | if (!crc32_setfile_check || !crc32_front_setfile_check) | |
873 | strcat(command_ack, "SET"); | |
874 | #ifdef CONFIG_COMPANION_USE | |
875 | if (!crc32_c1_fw_check) | |
876 | strcat(command_ack, "FW1"); | |
877 | if (!crc32_c1_check_factory) | |
878 | strcat(command_ack, "CD1"); | |
879 | #endif | |
880 | if (!crc32_check_factory_rear2) | |
881 | strcat(command_ack, "CD4"); | |
882 | if (finfo->header_ver[3] != 'L') | |
883 | strcat(command_ack, "_Q"); | |
884 | return sprintf(buf, "%s %s %s\n", finfo->header_ver, pinfo->header_ver, command_ack); | |
885 | } | |
886 | } else { | |
887 | err(" NG, fw ver crc check fail"); | |
888 | strcpy(command_ack, "NG_"); | |
889 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_REAR) | |
890 | strcat(command_ack, "CD"); | |
891 | #else | |
892 | strcat(command_ack, "FWCD"); | |
893 | #endif | |
894 | #ifdef CONFIG_COMPANION_USE | |
895 | strcat(command_ack, "FW1CD1"); | |
896 | #endif | |
897 | return sprintf(buf, "%s %s %s\n", finfo->header_ver, pinfo->header_ver, command_ack); | |
898 | } | |
899 | } | |
900 | ||
901 | static ssize_t camera_rear_checkfw_user_show(struct device *dev, | |
902 | struct device_attribute *attr, char *buf) | |
903 | { | |
904 | char *cal_buf; | |
905 | ||
906 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
907 | ||
908 | /* 2T2 Sensor Only. Can be removed after development */ | |
909 | fimc_is_sec_get_cal_buf(&cal_buf); | |
910 | if (((finfo->header_ver[0] == 'A') && (finfo->header_ver[1] == '2') && (finfo->header_ver[2] == '0')) | |
911 | && (cal_buf[0xC0] < 0xC0)) { | |
912 | err(" NG, old sensor revision"); | |
913 | return sprintf(buf, "%s\n", "NG"); | |
914 | } | |
915 | ||
916 | if (!fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_REAR)) { | |
917 | err(" NG, invalid FROM version"); | |
918 | return sprintf(buf, "%s\n", "NG"); | |
919 | } | |
920 | ||
921 | if (fw_version_crc_check) { | |
922 | if (crc32_fw_check && crc32_check_factory | |
923 | #ifdef CONFIG_COMPANION_USE | |
924 | && crc32_c1_fw_check && crc32_c1_check_factory | |
925 | #endif | |
926 | && crc32_check_factory_rear2 | |
927 | ) { | |
928 | if (!is_latest_cam_module) { | |
929 | err(" NG, not latest cam module"); | |
930 | return sprintf(buf, "%s\n", "NG"); | |
931 | } else { | |
932 | return sprintf(buf, "%s\n", "OK"); | |
933 | } | |
934 | } else { | |
935 | err(" NG, crc check fail"); | |
936 | return sprintf(buf, "%s\n", "NG"); | |
937 | } | |
938 | } else { | |
939 | err(" NG, fw ver crc check fail"); | |
940 | return sprintf(buf, "%s\n", "NG"); | |
941 | } | |
942 | } | |
943 | ||
944 | static ssize_t camera_rear_checkfw_factory_show(struct device *dev, | |
945 | struct device_attribute *attr, char *buf) | |
946 | { | |
947 | char command_ack[10] = {0, }; | |
948 | #if defined (CONFIG_OIS_USE) | |
949 | struct fimc_is_ois_info *ois_minfo = NULL; | |
950 | bool ois_ret = false; | |
951 | ||
952 | ois_ret = read_ois_version(); | |
953 | fimc_is_ois_get_module_version(&ois_minfo); | |
954 | #endif | |
955 | ||
956 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
957 | ||
958 | if (!fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_REAR)) { | |
959 | err(" NG, invalid FROM version"); | |
960 | #ifdef CAMERA_SYSFS_V2 | |
961 | return sprintf(buf, "%s\n", "NG_VER"); | |
962 | #else | |
963 | return sprintf(buf, "%s\n", "NG"); | |
964 | #endif | |
965 | } | |
966 | ||
967 | if (fw_version_crc_check) { | |
968 | if (crc32_fw_check && crc32_check_factory && crc32_setfile_check | |
969 | && crc32_front_setfile_check | |
970 | #ifdef CONFIG_COMPANION_USE | |
971 | && crc32_c1_fw_check && crc32_c1_check_factory | |
972 | #endif | |
973 | && crc32_check_factory_rear2 | |
974 | && crc32_hifi_tunningfile_check | |
975 | ) { | |
976 | if (!is_final_cam_module) { | |
977 | err(" NG, not final cam module"); | |
978 | #ifdef CAMERA_SYSFS_V2 | |
979 | strcpy(command_ack, "NG_VER\n"); | |
980 | #else | |
981 | strcpy(command_ack, "NG\n"); | |
982 | #endif | |
983 | } else { | |
984 | #if defined (CONFIG_OIS_USE) | |
985 | if (ois_minfo->checksum != 0x00 || ois_minfo->caldata != 0x00 || !ois_ret) { | |
986 | err(" NG, OIS crc check fail, checksum = 0x%02x, caldata = 0x%02x, ois_ret = %d", | |
987 | ois_minfo->checksum, ois_minfo->caldata, ois_ret); | |
988 | #ifdef CAMERA_SYSFS_V2 | |
989 | strcpy(command_ack, "NG_CRC\n"); | |
990 | #else | |
991 | strcpy(command_ack, "NG\n"); | |
992 | #endif | |
993 | } else { | |
994 | strcpy(command_ack, "OK\n"); | |
995 | } | |
996 | #else | |
997 | strcpy(command_ack, "OK\n"); | |
998 | #endif | |
999 | } | |
1000 | } else { | |
1001 | err(" NG, crc check fail"); | |
1002 | #ifdef CAMERA_SYSFS_V2 | |
1003 | strcpy(command_ack, "NG_CRC\n"); | |
1004 | #else | |
1005 | strcpy(command_ack, "NG\n"); | |
1006 | #endif | |
1007 | } | |
1008 | } else { | |
1009 | err(" NG, fw ver crc check fail"); | |
1010 | #ifdef CAMERA_SYSFS_V2 | |
1011 | strcpy(command_ack, "NG_VER\n"); | |
1012 | #else | |
1013 | strcpy(command_ack, "NG\n"); | |
1014 | #endif | |
1015 | } | |
1016 | ||
1017 | return sprintf(buf, "%s", command_ack); | |
1018 | } | |
1019 | #ifdef CAMERA_SYSFS_V2 | |
1020 | static ssize_t camera_rear_info_show(struct device *dev, | |
1021 | struct device_attribute *attr, char *buf) | |
1022 | { | |
1023 | char camera_info[130] = {0, }; | |
1024 | #ifdef CONFIG_OF | |
1025 | struct fimc_is_cam_info *cam_info = &(cam_infos[CAM_INFO_REAR]); | |
1026 | ||
1027 | if(!cam_info->valid) { | |
1028 | strcpy(camera_info, "ISP=NULL;CALMEM=NULL;READVER=NULL;COREVOLT=NULL;UPGRADE=NULL;" | |
1029 | "FWWRITE=NULL;FWDUMP=NULL;CC=NULL;OIS=NULL;VALID=N"); | |
1030 | ||
1031 | return sprintf(buf, "%s\n", camera_info); | |
1032 | } else { | |
1033 | strcpy(camera_info, "ISP="); | |
1034 | switch(cam_info->isp) { | |
1035 | case CAM_INFO_ISP_TYPE_INTERNAL : | |
1036 | strncat(camera_info, "INT;", strlen("INT;")); | |
1037 | break; | |
1038 | case CAM_INFO_ISP_TYPE_EXTERNAL : | |
1039 | strncat(camera_info, "EXT;", strlen("EXT;")); | |
1040 | break; | |
1041 | case CAM_INFO_ISP_TYPE_SOC : | |
1042 | strncat(camera_info, "SOC;", strlen("SOC;")); | |
1043 | break; | |
1044 | default : | |
1045 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1046 | break; | |
1047 | } | |
1048 | ||
1049 | strncat(camera_info, "CALMEM=", strlen("CALMEM=")); | |
1050 | switch(cam_info->cal_memory) { | |
1051 | case CAM_INFO_CAL_MEM_TYPE_NONE : | |
1052 | strncat(camera_info, "N;", strlen("N;")); | |
1053 | break; | |
1054 | case CAM_INFO_CAL_MEM_TYPE_FROM : | |
1055 | case CAM_INFO_CAL_MEM_TYPE_EEPROM : | |
1056 | case CAM_INFO_CAL_MEM_TYPE_OTP : | |
1057 | strncat(camera_info, "Y;", strlen("Y;")); | |
1058 | break; | |
1059 | default : | |
1060 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1061 | break; | |
1062 | } | |
1063 | ||
1064 | strncat(camera_info, "READVER=", strlen("READVER=")); | |
1065 | switch(cam_info->read_version) { | |
1066 | case CAM_INFO_READ_VER_SYSFS : | |
1067 | strncat(camera_info, "SYSFS;", strlen("SYSFS;")); | |
1068 | break; | |
1069 | case CAM_INFO_READ_VER_CAMON : | |
1070 | strncat(camera_info, "CAMON;", strlen("CAMON;")); | |
1071 | break; | |
1072 | default : | |
1073 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1074 | break; | |
1075 | } | |
1076 | ||
1077 | strncat(camera_info, "COREVOLT=", strlen("COREVOLT=")); | |
1078 | switch(cam_info->core_voltage) { | |
1079 | case CAM_INFO_CORE_VOLT_NONE : | |
1080 | strncat(camera_info, "N;", strlen("N;")); | |
1081 | break; | |
1082 | case CAM_INFO_CORE_VOLT_USE : | |
1083 | strncat(camera_info, "Y;", strlen("Y;")); | |
1084 | break; | |
1085 | default : | |
1086 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1087 | break; | |
1088 | } | |
1089 | ||
1090 | strncat(camera_info, "UPGRADE=", strlen("UPGRADE=")); | |
1091 | switch(cam_info->upgrade) { | |
1092 | case CAM_INFO_FW_UPGRADE_NONE : | |
1093 | strncat(camera_info, "N;", strlen("N;")); | |
1094 | break; | |
1095 | case CAM_INFO_FW_UPGRADE_SYSFS : | |
1096 | strncat(camera_info, "SYSFS;", strlen("SYSFS;")); | |
1097 | break; | |
1098 | case CAM_INFO_FW_UPGRADE_CAMON : | |
1099 | strncat(camera_info, "CAMON;", strlen("CAMON;")); | |
1100 | break; | |
1101 | default : | |
1102 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1103 | break; | |
1104 | } | |
1105 | ||
1106 | strncat(camera_info, "FWWRITE=", strlen("FWWRITE=")); | |
1107 | switch(cam_info->fw_write) { | |
1108 | case CAM_INFO_FW_WRITE_NONE : | |
1109 | strncat(camera_info, "N;", strlen("N;")); | |
1110 | break; | |
1111 | case CAM_INFO_FW_WRITE_OS : | |
1112 | strncat(camera_info, "OS;", strlen("OS;")); | |
1113 | break; | |
1114 | case CAM_INFO_FW_WRITE_SD : | |
1115 | strncat(camera_info, "SD;", strlen("SD;")); | |
1116 | break; | |
1117 | case CAM_INFO_FW_WRITE_ALL : | |
1118 | strncat(camera_info, "ALL;", strlen("ALL;")); | |
1119 | break; | |
1120 | default : | |
1121 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1122 | break; | |
1123 | } | |
1124 | ||
1125 | strncat(camera_info, "FWDUMP=", strlen("FWDUMP=")); | |
1126 | switch(cam_info->fw_dump) { | |
1127 | case CAM_INFO_FW_DUMP_NONE : | |
1128 | strncat(camera_info, "N;", strlen("N;")); | |
1129 | break; | |
1130 | case CAM_INFO_FW_DUMP_USE : | |
1131 | strncat(camera_info, "Y;", strlen("Y;")); | |
1132 | break; | |
1133 | default : | |
1134 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1135 | break; | |
1136 | } | |
1137 | ||
1138 | strncat(camera_info, "CC=", strlen("CC=")); | |
1139 | switch(cam_info->companion) { | |
1140 | case CAM_INFO_COMPANION_NONE : | |
1141 | strncat(camera_info, "N;", strlen("N;")); | |
1142 | break; | |
1143 | case CAM_INFO_COMPANION_USE : | |
1144 | strncat(camera_info, "Y;", strlen("Y;")); | |
1145 | break; | |
1146 | default : | |
1147 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1148 | break; | |
1149 | } | |
1150 | ||
1151 | strncat(camera_info, "OIS=", strlen("OIS=")); | |
1152 | switch(cam_info->ois) { | |
1153 | case CAM_INFO_OIS_NONE : | |
1154 | strncat(camera_info, "N;", strlen("N;")); | |
1155 | break; | |
1156 | case CAM_INFO_OIS_USE : | |
1157 | strncat(camera_info, "Y;", strlen("Y;")); | |
1158 | break; | |
1159 | default : | |
1160 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1161 | break; | |
1162 | } | |
1163 | ||
1164 | strncat(camera_info, "VALID=", strlen("VALID=")); | |
1165 | switch(cam_info->valid) { | |
1166 | case CAM_INFO_INVALID : | |
1167 | strncat(camera_info, "N;", strlen("N;")); | |
1168 | break; | |
1169 | case CAM_INFO_VALID : | |
1170 | strncat(camera_info, "Y;", strlen("Y;")); | |
1171 | break; | |
1172 | default : | |
1173 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1174 | break; | |
1175 | } | |
1176 | ||
1177 | return sprintf(buf, "%s\n", camera_info); | |
1178 | } | |
1179 | #endif | |
1180 | strcpy(camera_info, "ISP=NULL;CALMEM=NULL;READVER=NULL;COREVOLT=NULL;UPGRADE=NULL;" | |
1181 | "FWWRITE=NULL;FWDUMP=NULL;CC=NULL;OIS=NULL;VALID=N"); | |
1182 | ||
1183 | return sprintf(buf, "%s\n", camera_info); | |
1184 | } | |
1185 | #endif | |
1186 | ||
1187 | #ifdef CAMERA_REAR2 | |
1188 | static ssize_t camera_rear2_sensorid_show(struct device *dev, | |
1189 | struct device_attribute *attr, char *buf) | |
1190 | { | |
1191 | struct fimc_is_core *core = NULL; | |
1192 | struct fimc_is_vender_specific *specific; | |
1193 | ||
1194 | core = (struct fimc_is_core *)dev_get_drvdata(fimc_is_dev); | |
1195 | specific = core->vender.private_data; | |
1196 | dev_info(dev, "%s: E", __func__); | |
1197 | ||
1198 | return sprintf(buf, "%d\n", specific->rear_second_sensor_id); | |
1199 | } | |
1200 | ||
1201 | static ssize_t camera_rear2_camfw_show(struct device *dev, | |
1202 | struct device_attribute *attr, char *buf) | |
1203 | { | |
1204 | char command_ack[20] = {0, }; | |
1205 | struct exynos_platform_fimc_is *core_pdata = NULL; | |
1206 | ||
1207 | core_pdata = dev_get_platdata(fimc_is_dev); | |
1208 | ||
1209 | fimc_is_vender_check_hw_init_running(); | |
1210 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
1211 | ||
1212 | if (!fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_REAR)) { | |
1213 | err(" NG, invalid FROM version"); | |
1214 | strcpy(command_ack, "NG_FWCDFW1CD1CD4"); | |
1215 | return sprintf(buf, "%s %s\n", "NULL", command_ack); | |
1216 | } | |
1217 | ||
1218 | if (fw_version_crc_check) { | |
1219 | if (crc32_check_factory_rear2) { | |
1220 | return sprintf(buf, "%s %s\n", finfo->header2_ver, finfo->header2_ver); | |
1221 | } else { | |
1222 | err(" NG, crc check fail"); | |
1223 | strcpy(command_ack, "NG_CD4"); | |
1224 | return sprintf(buf, "%s %s\n", finfo->header2_ver, command_ack); | |
1225 | } | |
1226 | } else { | |
1227 | err(" NG, fw ver crc check fail"); | |
1228 | strcpy(command_ack, "NG_CD4"); | |
1229 | return sprintf(buf, "%s %s\n", finfo->header2_ver, command_ack); | |
1230 | } | |
1231 | } | |
1232 | ||
1233 | static ssize_t camera_rear2_camfw_full_show(struct device *dev, | |
1234 | struct device_attribute *attr, char *buf) | |
1235 | { | |
1236 | char command_ack[20] = {0, }; | |
1237 | ||
1238 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
1239 | ||
1240 | if (!fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_REAR)) { | |
1241 | err(" NG, invalid FROM version"); | |
1242 | strcpy(command_ack, "NG_FWCDFW1CD1CD4"); | |
1243 | return sprintf(buf, "%s %s %s\n", "NULL", "NULL", command_ack); | |
1244 | } | |
1245 | ||
1246 | if (fw_version_crc_check) { | |
1247 | if (crc32_check_factory_rear2) { | |
1248 | return sprintf(buf, "%s %s %s\n", finfo->header2_ver, "N", finfo->header2_ver); | |
1249 | } else { | |
1250 | err(" NG, crc check fail"); | |
1251 | strcpy(command_ack, "NG_CD4"); | |
1252 | return sprintf(buf, "%s %s %s\n", finfo->header2_ver, "N", command_ack); | |
1253 | } | |
1254 | } else { | |
1255 | strcpy(command_ack, "NG_CD4"); | |
1256 | return sprintf(buf, "%s %s %s\n", finfo->header2_ver, "N", command_ack); | |
1257 | } | |
1258 | } | |
1259 | ||
1260 | static ssize_t camera_rear2_checkfw_user_show(struct device *dev, | |
1261 | struct device_attribute *attr, char *buf) | |
1262 | { | |
1263 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
1264 | ||
1265 | if (!fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_REAR)) { | |
1266 | err(" NG, invalid FROM version"); | |
1267 | return sprintf(buf, "%s\n", "NG"); | |
1268 | } | |
1269 | ||
1270 | if (fw_version_crc_check) { | |
1271 | if (crc32_check_factory_rear2) { | |
1272 | if (!is_latest_cam_module) { | |
1273 | err(" NG, not latest cam module"); | |
1274 | return sprintf(buf, "%s\n", "NG"); | |
1275 | } else { | |
1276 | return sprintf(buf, "%s\n", "OK"); | |
1277 | } | |
1278 | } else { | |
1279 | err(" NG, crc check fail"); | |
1280 | return sprintf(buf, "%s\n", "NG"); | |
1281 | } | |
1282 | } else { | |
1283 | err(" NG, fw ver crc check fail"); | |
1284 | return sprintf(buf, "%s\n", "NG"); | |
1285 | } | |
1286 | } | |
1287 | ||
1288 | static ssize_t camera_rear2_checkfw_factory_show(struct device *dev, | |
1289 | struct device_attribute *attr, char *buf) | |
1290 | { | |
1291 | char command_ack[10] = {0, }; | |
1292 | ||
1293 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
1294 | ||
1295 | if (!fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_REAR)) { | |
1296 | err(" NG, invalid FROM version"); | |
1297 | #ifdef CAMERA_SYSFS_V2 | |
1298 | return sprintf(buf, "%s\n", "NG_VER"); | |
1299 | #else | |
1300 | return sprintf(buf, "%s\n", "NG"); | |
1301 | #endif | |
1302 | } | |
1303 | ||
1304 | if (fw_version_crc_check) { | |
1305 | if (crc32_check_factory_rear2) { | |
1306 | if (!is_final_cam_module) { | |
1307 | err(" NG, not final cam module"); | |
1308 | #ifdef CAMERA_SYSFS_V2 | |
1309 | strcpy(command_ack, "NG_VER\n"); | |
1310 | #else | |
1311 | strcpy(command_ack, "NG\n"); | |
1312 | #endif | |
1313 | } else { | |
1314 | strcpy(command_ack, "OK\n"); | |
1315 | } | |
1316 | } else { | |
1317 | err(" NG, crc check fail"); | |
1318 | #ifdef CAMERA_SYSFS_V2 | |
1319 | strcpy(command_ack, "NG_CRC\n"); | |
1320 | #else | |
1321 | strcpy(command_ack, "NG\n"); | |
1322 | #endif | |
1323 | } | |
1324 | } else { | |
1325 | err(" NG, fw ver crc check fail"); | |
1326 | #ifdef CAMERA_SYSFS_V2 | |
1327 | strcpy(command_ack, "NG_VER\n"); | |
1328 | #else | |
1329 | strcpy(command_ack, "NG\n"); | |
1330 | #endif | |
1331 | } | |
1332 | ||
1333 | return sprintf(buf, "%s", command_ack); | |
1334 | } | |
1335 | #ifdef CAMERA_SYSFS_V2 | |
1336 | static ssize_t camera_rear2_info_show(struct device *dev, | |
1337 | struct device_attribute *attr, char *buf) | |
1338 | { | |
1339 | char camera_info[130] = {0, }; | |
1340 | #ifdef CONFIG_OF | |
1341 | struct fimc_is_cam_info *cam_info = &(cam_infos[CAM_INFO_REAR2]); | |
1342 | ||
1343 | if(!cam_info->valid) { | |
1344 | strcpy(camera_info, "ISP=NULL;CALMEM=NULL;READVER=NULL;COREVOLT=NULL;UPGRADE=NULL;" | |
1345 | "FWWRITE=NULL;FWDUMP=NULL;CC=NULL;OIS=NULL;VALID=N;DUALOPEN=N"); | |
1346 | ||
1347 | return sprintf(buf, "%s\n", camera_info); | |
1348 | } else { | |
1349 | strcpy(camera_info, "ISP="); | |
1350 | switch (cam_info->isp) { | |
1351 | case CAM_INFO_ISP_TYPE_INTERNAL: | |
1352 | strncat(camera_info, "INT;", strlen("INT;")); | |
1353 | break; | |
1354 | case CAM_INFO_ISP_TYPE_EXTERNAL: | |
1355 | strncat(camera_info, "EXT;", strlen("EXT;")); | |
1356 | break; | |
1357 | case CAM_INFO_ISP_TYPE_SOC: | |
1358 | strncat(camera_info, "SOC;", strlen("SOC;")); | |
1359 | break; | |
1360 | default: | |
1361 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1362 | break; | |
1363 | } | |
1364 | ||
1365 | strncat(camera_info, "CALMEM=", strlen("CALMEM=")); | |
1366 | switch (cam_info->cal_memory) { | |
1367 | case CAM_INFO_CAL_MEM_TYPE_NONE: | |
1368 | strncat(camera_info, "N;", strlen("N;")); | |
1369 | break; | |
1370 | case CAM_INFO_CAL_MEM_TYPE_FROM: | |
1371 | case CAM_INFO_CAL_MEM_TYPE_EEPROM: | |
1372 | case CAM_INFO_CAL_MEM_TYPE_OTP: | |
1373 | strncat(camera_info, "Y;", strlen("Y;")); | |
1374 | break; | |
1375 | default: | |
1376 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1377 | break; | |
1378 | } | |
1379 | ||
1380 | strncat(camera_info, "READVER=", strlen("READVER=")); | |
1381 | switch (cam_info->read_version) { | |
1382 | case CAM_INFO_READ_VER_SYSFS: | |
1383 | strncat(camera_info, "SYSFS;", strlen("SYSFS;")); | |
1384 | break; | |
1385 | case CAM_INFO_READ_VER_CAMON: | |
1386 | strncat(camera_info, "CAMON;", strlen("CAMON;")); | |
1387 | break; | |
1388 | default: | |
1389 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1390 | break; | |
1391 | } | |
1392 | ||
1393 | strncat(camera_info, "COREVOLT=", strlen("COREVOLT=")); | |
1394 | switch (cam_info->core_voltage) { | |
1395 | case CAM_INFO_CORE_VOLT_NONE: | |
1396 | strncat(camera_info, "N;", strlen("N;")); | |
1397 | break; | |
1398 | case CAM_INFO_CORE_VOLT_USE: | |
1399 | strncat(camera_info, "Y;", strlen("Y;")); | |
1400 | break; | |
1401 | default: | |
1402 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1403 | break; | |
1404 | } | |
1405 | ||
1406 | strncat(camera_info, "UPGRADE=", strlen("UPGRADE=")); | |
1407 | switch (cam_info->upgrade) { | |
1408 | case CAM_INFO_FW_UPGRADE_NONE: | |
1409 | strncat(camera_info, "N;", strlen("N;")); | |
1410 | break; | |
1411 | case CAM_INFO_FW_UPGRADE_SYSFS: | |
1412 | strncat(camera_info, "SYSFS;", strlen("SYSFS;")); | |
1413 | break; | |
1414 | case CAM_INFO_FW_UPGRADE_CAMON: | |
1415 | strncat(camera_info, "CAMON;", strlen("CAMON;")); | |
1416 | break; | |
1417 | default: | |
1418 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1419 | break; | |
1420 | } | |
1421 | ||
1422 | strncat(camera_info, "FWWRITE=", strlen("FWWRITE=")); | |
1423 | switch (cam_info->fw_write) { | |
1424 | case CAM_INFO_FW_WRITE_NONE: | |
1425 | strncat(camera_info, "N;", strlen("N;")); | |
1426 | break; | |
1427 | case CAM_INFO_FW_WRITE_OS: | |
1428 | strncat(camera_info, "OS;", strlen("OS;")); | |
1429 | break; | |
1430 | case CAM_INFO_FW_WRITE_SD: | |
1431 | strncat(camera_info, "SD;", strlen("SD;")); | |
1432 | break; | |
1433 | case CAM_INFO_FW_WRITE_ALL: | |
1434 | strncat(camera_info, "ALL;", strlen("ALL;")); | |
1435 | break; | |
1436 | default: | |
1437 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1438 | break; | |
1439 | } | |
1440 | ||
1441 | strncat(camera_info, "FWDUMP=", strlen("FWDUMP=")); | |
1442 | switch (cam_info->fw_dump) { | |
1443 | case CAM_INFO_FW_DUMP_NONE: | |
1444 | strncat(camera_info, "N;", strlen("N;")); | |
1445 | break; | |
1446 | case CAM_INFO_FW_DUMP_USE: | |
1447 | strncat(camera_info, "Y;", strlen("Y;")); | |
1448 | break; | |
1449 | default: | |
1450 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1451 | break; | |
1452 | } | |
1453 | ||
1454 | strncat(camera_info, "CC=", strlen("CC=")); | |
1455 | switch (cam_info->companion) { | |
1456 | case CAM_INFO_COMPANION_NONE: | |
1457 | strncat(camera_info, "N;", strlen("N;")); | |
1458 | break; | |
1459 | case CAM_INFO_COMPANION_USE: | |
1460 | strncat(camera_info, "Y;", strlen("Y;")); | |
1461 | break; | |
1462 | default: | |
1463 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1464 | break; | |
1465 | } | |
1466 | ||
1467 | strncat(camera_info, "OIS=", strlen("OIS=")); | |
1468 | switch (cam_info->ois) { | |
1469 | case CAM_INFO_OIS_NONE: | |
1470 | strncat(camera_info, "N;", strlen("N;")); | |
1471 | break; | |
1472 | case CAM_INFO_OIS_USE: | |
1473 | strncat(camera_info, "Y;", strlen("Y;")); | |
1474 | break; | |
1475 | default: | |
1476 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1477 | break; | |
1478 | } | |
1479 | ||
1480 | strncat(camera_info, "VALID=", strlen("VALID=")); | |
1481 | switch (cam_info->valid) { | |
1482 | case CAM_INFO_INVALID: | |
1483 | strncat(camera_info, "N;", strlen("N;")); | |
1484 | break; | |
1485 | case CAM_INFO_VALID: | |
1486 | strncat(camera_info, "Y;", strlen("Y;")); | |
1487 | break; | |
1488 | default: | |
1489 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1490 | break; | |
1491 | } | |
1492 | ||
1493 | strncat(camera_info, "DUALOPEN=", strlen("DUALOPEN=")); | |
1494 | switch (cam_info->dual_open) { | |
1495 | case CAM_INFO_SINGLE_OPEN: | |
1496 | strncat(camera_info, "N;", strlen("N;")); | |
1497 | break; | |
1498 | case CAM_INFO_DUAL_OPEN: | |
1499 | strncat(camera_info, "Y;", strlen("Y;")); | |
1500 | break; | |
1501 | default: | |
1502 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
1503 | break; | |
1504 | } | |
1505 | ||
1506 | return sprintf(buf, "%s\n", camera_info); | |
1507 | } | |
1508 | #endif | |
1509 | strcpy(camera_info, "ISP=NULL;CALMEM=NULL;READVER=NULL;COREVOLT=NULL;UPGRADE=NULL;" | |
1510 | "FWWRITE=NULL;FWDUMP=NULL;CC=NULL;OIS=NULL;VALID=N;DUALOPEN=N"); | |
1511 | ||
1512 | return sprintf(buf, "%s\n", camera_info); | |
1513 | } | |
1514 | #endif | |
1515 | ||
1516 | static ssize_t camera_rear2_afcal_show(struct device *dev, | |
1517 | struct device_attribute *attr, char *buf) | |
1518 | { | |
1519 | char tempbuf[10]; | |
1520 | char *cal_buf; | |
1521 | char N[] = "N "; | |
1522 | ||
1523 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
1524 | fimc_is_sec_get_cal_buf(&cal_buf); | |
1525 | ||
1526 | strncat(buf, "10 ", strlen("10 ")); | |
1527 | ||
1528 | #ifdef FROM_AF2_CAL_D10_ADDR | |
1529 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF2_CAL_D10_ADDR])); | |
1530 | #else | |
1531 | sprintf(tempbuf, "%s", N); | |
1532 | #endif | |
1533 | strncat(buf, tempbuf, strlen(tempbuf)); | |
1534 | ||
1535 | #ifdef FROM_AF2_CAL_D20_ADDR | |
1536 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF2_CAL_D20_ADDR])); | |
1537 | #else | |
1538 | sprintf(tempbuf, "%s", N); | |
1539 | #endif | |
1540 | strncat(buf, tempbuf, strlen(tempbuf)); | |
1541 | ||
1542 | #ifdef FROM_AF2_CAL_D30_ADDR | |
1543 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF2_CAL_D30_ADDR])); | |
1544 | #else | |
1545 | sprintf(tempbuf, "%s", N); | |
1546 | #endif | |
1547 | strncat(buf, tempbuf, strlen(tempbuf)); | |
1548 | ||
1549 | #ifdef FROM_AF2_CAL_D40_ADDR | |
1550 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF2_CAL_D40_ADDR])); | |
1551 | #else | |
1552 | sprintf(tempbuf, "%s", N); | |
1553 | #endif | |
1554 | strncat(buf, tempbuf, strlen(tempbuf)); | |
1555 | ||
1556 | #ifdef FROM_AF2_CAL_D50_ADDR | |
1557 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF2_CAL_D50_ADDR])); | |
1558 | #else | |
1559 | sprintf(tempbuf, "%s", N); | |
1560 | #endif | |
1561 | strncat(buf, tempbuf, strlen(tempbuf)); | |
1562 | ||
1563 | #ifdef FROM_AF2_CAL_D60_ADDR | |
1564 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF2_CAL_D60_ADDR])); | |
1565 | #else | |
1566 | sprintf(tempbuf, "%s", N); | |
1567 | #endif | |
1568 | strncat(buf, tempbuf, strlen(tempbuf)); | |
1569 | ||
1570 | #ifdef FROM_AF2_CAL_D70_ADDR | |
1571 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF2_CAL_D70_ADDR])); | |
1572 | #else | |
1573 | sprintf(tempbuf, "%s", N); | |
1574 | #endif | |
1575 | strncat(buf, tempbuf, strlen(tempbuf)); | |
1576 | ||
1577 | #ifdef FROM_AF2_CAL_D80_ADDR | |
1578 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF2_CAL_D80_ADDR])); | |
1579 | #else | |
1580 | sprintf(tempbuf, "%s", N); | |
1581 | #endif | |
1582 | strncat(buf, tempbuf, strlen(tempbuf)); | |
1583 | ||
1584 | #ifdef FROM_AF2_CAL_PAN_ADDR | |
1585 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF2_CAL_PAN_ADDR])); | |
1586 | #else | |
1587 | sprintf(tempbuf, "%s", N); | |
1588 | #endif | |
1589 | strncat(buf, tempbuf, strlen(tempbuf)); | |
1590 | ||
1591 | return strlen(buf); | |
1592 | } | |
1593 | ||
1594 | static ssize_t camera_rear2_sensorid_exif_show(struct device *dev, | |
1595 | struct device_attribute *attr, char *buf) | |
1596 | { | |
1597 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
1598 | ||
1599 | return sprintf(buf, "%s", finfo->from_sensor2_id); | |
1600 | } | |
1601 | ||
1602 | static ssize_t camera_rear2_mtf_exif_show(struct device *dev, | |
1603 | struct device_attribute *attr, char *buf) | |
1604 | { | |
1605 | char *cal_buf; | |
1606 | ||
1607 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
1608 | fimc_is_sec_get_cal_buf(&cal_buf); | |
1609 | ||
1610 | memcpy(buf, &cal_buf[finfo->mtf_data2_addr], FIMC_IS_RESOLUTION_DATA_SIZE); | |
1611 | return FIMC_IS_RESOLUTION_DATA_SIZE; | |
1612 | } | |
1613 | ||
1614 | static ssize_t camera_rear_dualcal_show(struct device *dev, | |
1615 | struct device_attribute *attr, char *buf) | |
1616 | { | |
1617 | char *cal_buf; | |
1618 | ||
1619 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
1620 | fimc_is_sec_get_cal_buf(&cal_buf); | |
1621 | ||
1622 | memcpy(buf, &cal_buf[FROM_REAR2_DUAL_CAL2], FROM_REAR2_DUAL_CAL2_SIZE); | |
1623 | return FROM_REAR2_DUAL_CAL2_SIZE; | |
1624 | } | |
1625 | ||
1626 | static ssize_t camera_rear_dualcal_size_show(struct device *dev, | |
1627 | struct device_attribute *attr, char *buf) | |
1628 | { | |
1629 | return sprintf(buf, "%d\n", FROM_REAR2_DUAL_CAL2_SIZE); | |
1630 | } | |
1631 | ||
1632 | static ssize_t camera_rear2_tilt_show(struct device *dev, | |
1633 | struct device_attribute *attr, char *buf) | |
1634 | { | |
1635 | char *cal_buf; | |
1636 | ||
1637 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
1638 | fimc_is_sec_get_cal_buf(&cal_buf); | |
1639 | ||
1640 | if (!fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_REAR)) { | |
1641 | err(" NG, invalid FROM version"); | |
1642 | return sprintf(buf, "%s\n", "NG"); | |
1643 | } | |
1644 | #ifdef FROM_REAR2_DUAL_TILT_X | |
1645 | if (fw_version_crc_check && crc32_check_factory_rear2) { | |
1646 | s32 *x = NULL, *y = NULL, *z = NULL, *sx = NULL, *sy = NULL; | |
1647 | s32 *range = NULL, *max_err = NULL, *avg_err = NULL, *dll_version = NULL; | |
1648 | ||
1649 | x = (s32 *)&cal_buf[FROM_REAR2_DUAL_TILT_X]; | |
1650 | y = (s32 *)&cal_buf[FROM_REAR2_DUAL_TILT_Y]; | |
1651 | z = (s32 *)&cal_buf[FROM_REAR2_DUAL_TILT_Z]; | |
1652 | sx = (s32 *)&cal_buf[FROM_REAR2_DUAL_TILT_SX]; | |
1653 | sy = (s32 *)&cal_buf[FROM_REAR2_DUAL_TILT_SY]; | |
1654 | range = (s32 *)&cal_buf[FROM_REAR2_DUAL_TILT_RANGE]; | |
1655 | max_err = (s32 *)&cal_buf[FROM_REAR2_DUAL_TILT_MAX_ERR]; | |
1656 | avg_err = (s32 *)&cal_buf[FROM_REAR2_DUAL_TILT_AVG_ERR]; | |
1657 | dll_version = (s32 *)&cal_buf[FROM_REAR2_DUAL_TILT_DLL_VERSION]; | |
1658 | ||
1659 | return sprintf(buf, "1 %d %d %d %d %d %d %d %d %d\n", | |
1660 | *x, *y, *z, *sx, *sy, *range, *max_err, *avg_err, *dll_version); | |
1661 | } else { | |
1662 | return sprintf(buf, "%s\n", "NG"); | |
1663 | } | |
1664 | #else | |
1665 | return sprintf(buf, "%s\n", "NG"); | |
1666 | #endif | |
1667 | } | |
1668 | #endif | |
1669 | ||
1670 | static ssize_t camera_rear_sensor_standby(struct device *dev, | |
1671 | struct device_attribute *attr, const char *buf, size_t count) | |
1672 | { | |
1673 | switch (buf[0]) { | |
1674 | case '0': | |
1675 | break; | |
1676 | case '1': | |
1677 | break; | |
1678 | default: | |
1679 | pr_debug("%s: %c\n", __func__, buf[0]); | |
1680 | break; | |
1681 | } | |
1682 | ||
1683 | return count; | |
1684 | } | |
1685 | ||
1686 | static ssize_t camera_rear_sensor_standby_show(struct device *dev, | |
1687 | struct device_attribute *attr, char *buf) | |
1688 | { | |
1689 | return sprintf(buf, "Rear sensor standby \n"); | |
1690 | } | |
1691 | ||
1692 | #ifdef CONFIG_COMPANION_USE | |
1693 | static ssize_t camera_rear_companionfw_show(struct device *dev, | |
1694 | struct device_attribute *attr, char *buf) | |
1695 | { | |
1696 | char *loaded_c1_fw; | |
1697 | ||
1698 | fimc_is_vender_check_hw_init_running(); | |
1699 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
1700 | fimc_is_sec_get_loaded_c1_fw(&loaded_c1_fw); | |
1701 | ||
1702 | return sprintf(buf, "%s %s\n", | |
1703 | finfo->concord_header_ver, loaded_c1_fw); | |
1704 | } | |
1705 | ||
1706 | static ssize_t camera_rear_companionfw_full_show(struct device *dev, | |
1707 | struct device_attribute *attr, char *buf) | |
1708 | { | |
1709 | char *loaded_c1_fw; | |
1710 | ||
1711 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
1712 | fimc_is_sec_get_loaded_c1_fw(&loaded_c1_fw); | |
1713 | ||
1714 | return sprintf(buf, "%s %s %s\n", | |
1715 | finfo->concord_header_ver, pinfo->concord_header_ver, loaded_c1_fw); | |
1716 | } | |
1717 | #endif | |
1718 | ||
1719 | static ssize_t camera_rear_camfw_write(struct device *dev, | |
1720 | struct device_attribute *attr, const char *buf, size_t size) | |
1721 | { | |
1722 | ssize_t ret = -EINVAL; | |
1723 | ||
1724 | if ((size == 1 || size == 2) && (buf[0] == 'F' || buf[0] == 'f')) { | |
1725 | fimc_is_sec_set_force_caldata_dump(true); | |
1726 | ret = size; | |
1727 | } else { | |
1728 | fimc_is_sec_set_force_caldata_dump(false); | |
1729 | } | |
1730 | return ret; | |
1731 | } | |
1732 | ||
1733 | static ssize_t camera_rear_calcheck_show(struct device *dev, | |
1734 | struct device_attribute *attr, char *buf) | |
1735 | { | |
1736 | char rear_sensor[10] = {0, }; | |
1737 | #ifdef CONFIG_COMPANION_USE | |
1738 | char rear_companion[10] = {0, }; | |
1739 | #endif | |
1740 | #ifdef CONFIG_CAMERA_EEPROM_SUPPORT_FRONT | |
1741 | char front_sensor[10] = {0, }; | |
1742 | #endif | |
1743 | ||
1744 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
1745 | ||
1746 | if (fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_REAR) && crc32_check_factory) | |
1747 | strcpy(rear_sensor, "Normal"); | |
1748 | else | |
1749 | strcpy(rear_sensor, "Abnormal"); | |
1750 | ||
1751 | #ifdef CONFIG_CAMERA_EEPROM_SUPPORT_FRONT | |
1752 | read_from_firmware_version(SENSOR_POSITION_FRONT); | |
1753 | #ifdef CONFIG_COMPANION_USE | |
1754 | if (fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_REAR) && crc32_c1_check_factory) | |
1755 | strcpy(rear_companion, "Normal"); | |
1756 | else | |
1757 | strcpy(rear_companion, "Abnormal"); | |
1758 | ||
1759 | if (fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_FRONT) && crc32_check_factory_front) | |
1760 | strcpy(front_sensor, "Normal"); | |
1761 | else | |
1762 | strcpy(front_sensor, "Abnormal"); | |
1763 | ||
1764 | return sprintf(buf, "%s %s %s\n", rear_sensor, rear_companion, front_sensor); | |
1765 | #else | |
1766 | return sprintf(buf, "%s %s\n", rear_sensor, front_sensor); | |
1767 | #endif | |
1768 | #else | |
1769 | #ifdef CONFIG_COMPANION_USE | |
1770 | if (fimc_is_sec_check_from_ver(sysfs_core, SENSOR_POSITION_REAR) && crc32_c1_check_factory) | |
1771 | strcpy(rear_companion, "Normal"); | |
1772 | else | |
1773 | strcpy(rear_companion, "Abnormal"); | |
1774 | ||
1775 | return sprintf(buf, "%s %s %s\n", rear_sensor, rear_companion, "Null"); | |
1776 | #else | |
1777 | return sprintf(buf, "%s %s\n", rear_sensor, "Null"); | |
1778 | #endif | |
1779 | #endif | |
1780 | } | |
1781 | ||
1782 | #ifdef CONFIG_COMPANION_USE | |
1783 | static ssize_t camera_isp_core_show(struct device *dev, | |
1784 | struct device_attribute *attr, char *buf) | |
1785 | { | |
1786 | #ifdef CONFIG_COMPANION_DCDC_USE | |
1787 | int sel; | |
1788 | struct fimc_is_vender_specific *specific = sysfs_core->vender.private_data; | |
1789 | ||
1790 | if (DCDC_VENDOR_NONE == specific->companion_dcdc.type) | |
1791 | return sprintf(buf, "none\n"); | |
1792 | ||
1793 | sel = fimc_is_power_binning(sysfs_core); | |
1794 | return sprintf(buf, "%s\n", specific->companion_dcdc.get_vout_str(sel)); | |
1795 | #else | |
1796 | return sprintf(buf, "none\n"); | |
1797 | #endif | |
1798 | } | |
1799 | #endif | |
1800 | ||
1801 | static ssize_t camera_hw_init_show(struct device *dev, | |
1802 | struct device_attribute *attr, char *buf) | |
1803 | { | |
1804 | struct fimc_is_vender *vender; | |
1805 | int i; | |
1806 | ||
1807 | vender = &sysfs_core->vender; | |
1808 | ||
1809 | if (!check_module_init | |
1810 | || gPtr_lib_support.binary_code_load_flg != BINARY_LOAD_ALL_DONE) { | |
1811 | fimc_is_vender_hw_init(vender); | |
1812 | check_module_init = true; | |
1813 | for (i = 0; i < FIMC_IS_SENSOR_COUNT; i++) { | |
1814 | SsrmCameraInfo[i].cameraID = -1; | |
1815 | } | |
1816 | } | |
1817 | ||
1818 | return sprintf(buf, "%s\n", "HW init done."); | |
1819 | } | |
1820 | ||
1821 | #if defined (CONFIG_OIS_USE) | |
1822 | static ssize_t camera_ois_power_store(struct device *dev, | |
1823 | struct device_attribute *attr, const char *buf, size_t count) | |
1824 | ||
1825 | { | |
1826 | struct fimc_is_vender_specific *specific = sysfs_core->vender.private_data; | |
1827 | ||
1828 | fimc_is_vender_check_hw_init_running(); | |
1829 | ||
1830 | switch (buf[0]) { | |
1831 | case '0': | |
1832 | if (!specific->running_rear_camera) { | |
1833 | fimc_is_ois_gpio_off(sysfs_core); | |
1834 | } else { | |
1835 | err("cannot control OIS PowerOff because camera is working.\n"); | |
1836 | } | |
1837 | check_ois_power = false; | |
1838 | break; | |
1839 | case '1': | |
1840 | fimc_is_ois_gpio_on(sysfs_core); | |
1841 | check_ois_power = true; | |
1842 | msleep(150); | |
1843 | break; | |
1844 | default: | |
1845 | pr_debug("%s: %c\n", __func__, buf[0]); | |
1846 | break; | |
1847 | } | |
1848 | return count; | |
1849 | } | |
1850 | ||
1851 | static ssize_t camera_ois_autotest_store(struct device *dev, | |
1852 | struct device_attribute *attr, const char *buf, size_t count) | |
1853 | ||
1854 | { | |
1855 | int value = 0; | |
1856 | ||
1857 | if (kstrtoint(buf, 10, &value)) { | |
1858 | err("convert fail"); | |
1859 | } | |
1860 | ||
1861 | ois_threshold = value; | |
1862 | ||
1863 | return count; | |
1864 | } | |
1865 | ||
1866 | static ssize_t camera_ois_autotest_show(struct device *dev, | |
1867 | struct device_attribute *attr, char *buf) | |
1868 | ||
1869 | { | |
1870 | bool x_result = false, y_result = false; | |
1871 | int sin_x = 0, sin_y = 0; | |
1872 | ||
1873 | if (check_ois_power) { | |
1874 | fimc_is_ois_auto_test(sysfs_core, ois_threshold, | |
1875 | &x_result, &y_result, &sin_x, &sin_y); | |
1876 | ||
1877 | if (x_result && y_result) { | |
1878 | return sprintf(buf, "%s,%d,%s,%d\n", "pass", 0, "pass", 0); | |
1879 | } else if (x_result) { | |
1880 | return sprintf(buf, "%s,%d,%s,%d\n", "pass", 0, "fail", sin_y); | |
1881 | } else if (y_result) { | |
1882 | return sprintf(buf, "%s,%d,%s,%d\n", "fail", sin_x, "pass", 0); | |
1883 | } else { | |
1884 | return sprintf(buf, "%s,%d,%s,%d\n", "fail", sin_x, "fail", sin_y); | |
1885 | } | |
1886 | } else { | |
1887 | err("OIS power is not enabled."); | |
1888 | return sprintf(buf, "%s,%d,%s,%d\n", "fail", sin_x, "fail", sin_y); | |
1889 | } | |
1890 | } | |
1891 | ||
1892 | #ifdef CAMERA_REAR2_OIS | |
1893 | static ssize_t camera_ois_autotest_2nd_store(struct device *dev, | |
1894 | struct device_attribute *attr, const char *buf, size_t count) | |
1895 | { | |
1896 | int value = 0; | |
1897 | ||
1898 | if (kstrtoint(buf, 10, &value)) { | |
1899 | err("convert fail"); | |
1900 | } | |
1901 | ||
1902 | ois_threshold_rear2 = value; | |
1903 | ||
1904 | return count; | |
1905 | } | |
1906 | ||
1907 | static ssize_t camera_ois_autotest_2nd_show(struct device *dev, | |
1908 | struct device_attribute *attr, char *buf) | |
1909 | { | |
1910 | bool x_result = false, y_result = false; | |
1911 | bool x_result_2nd = false, y_result_2nd = false; | |
1912 | int sin_x = 0, sin_y = 0; | |
1913 | int sin_x_2nd = 0, sin_y_2nd = 0; | |
1914 | char wide_buffer[60] = {0,}; | |
1915 | char tele_buffer[30] = {0,}; | |
1916 | ||
1917 | ||
1918 | if (check_ois_power) { | |
1919 | fimc_is_ois_auto_test_rear2(sysfs_core, ois_threshold_rear2, | |
1920 | &x_result, &y_result, &sin_x, &sin_y, | |
1921 | &x_result_2nd, &y_result_2nd, &sin_x_2nd, &sin_y_2nd); | |
1922 | ||
1923 | if (x_result && y_result) { | |
1924 | sprintf(wide_buffer, "%s,%d,%s,%d,", "pass", 0, "pass", 0); | |
1925 | } else if (x_result) { | |
1926 | sprintf(wide_buffer, "%s,%d,%s,%d,", "pass", 0, "fail", sin_y); | |
1927 | } else if (y_result) { | |
1928 | sprintf(wide_buffer, "%s,%d,%s,%d,", "fail", sin_x, "pass", 0); | |
1929 | } else { | |
1930 | sprintf(wide_buffer, "%s,%d,%s,%d,", "fail", sin_x, "fail", sin_y); | |
1931 | } | |
1932 | ||
1933 | if (x_result_2nd && y_result_2nd) { | |
1934 | sprintf(tele_buffer, "%s,%d,%s,%d", "pass", 0, "pass", 0); | |
1935 | } else if (x_result_2nd) { | |
1936 | sprintf(tele_buffer, "%s,%d,%s,%d", "pass", 0, "fail", sin_y_2nd); | |
1937 | } else if (y_result_2nd) { | |
1938 | sprintf(tele_buffer, "%s,%d,%s,%d", "fail", sin_x_2nd, "pass", 0); | |
1939 | } else { | |
1940 | sprintf(tele_buffer, "%s,%d,%s,%d", "fail", sin_x_2nd, "fail", sin_y_2nd); | |
1941 | } | |
1942 | ||
1943 | strncat(wide_buffer, tele_buffer, strlen(tele_buffer)); | |
1944 | return sprintf(buf, "%s\n", wide_buffer); | |
1945 | ||
1946 | } else { | |
1947 | err("OIS power is not enabled."); | |
1948 | return sprintf(buf, "%s,%d,%s,%d\n", "fail", sin_x, "fail", sin_y); | |
1949 | } | |
1950 | } | |
1951 | #endif | |
1952 | ||
1953 | static ssize_t camera_ois_selftest_show(struct device *dev, | |
1954 | struct device_attribute *attr, char *buf) | |
1955 | { | |
1956 | int result_total = 0; | |
1957 | bool result_offset = 0, result_selftest = 0; | |
1958 | int selftest_ret = 0; | |
1959 | long raw_data_x = 0, raw_data_y = 0; | |
1960 | ||
1961 | if (check_ois_power) { | |
1962 | fimc_is_ois_offset_test(sysfs_core, &raw_data_x, &raw_data_y); | |
1963 | msleep(50); | |
1964 | selftest_ret = fimc_is_ois_self_test(sysfs_core); | |
1965 | ||
1966 | if (selftest_ret == 0x0) { | |
1967 | result_selftest = true; | |
1968 | } else { | |
1969 | result_selftest = false; | |
1970 | } | |
1971 | ||
1972 | if (abs(raw_data_x) > CAMERA_OIS_GYRO_OFFSET_SPEC || abs(raw_data_y) > CAMERA_OIS_GYRO_OFFSET_SPEC) { | |
1973 | result_offset = false; | |
1974 | } else { | |
1975 | result_offset = true; | |
1976 | } | |
1977 | ||
1978 | if (result_offset && result_selftest) { | |
1979 | result_total = 0; | |
1980 | } else if (!result_offset && !result_selftest) { | |
1981 | result_total = 3; | |
1982 | } else if (!result_offset) { | |
1983 | result_total = 1; | |
1984 | } else if (!result_selftest) { | |
1985 | result_total = 2; | |
1986 | } | |
1987 | ||
1988 | if (raw_data_x < 0 && raw_data_y < 0) { | |
1989 | return sprintf(buf, "%d,-%ld.%03ld,-%ld.%03ld\n", result_total, abs(raw_data_x /1000), abs(raw_data_x % 1000), | |
1990 | abs(raw_data_y /1000), abs(raw_data_y % 1000)); | |
1991 | } else if (raw_data_x < 0) { | |
1992 | return sprintf(buf, "%d,-%ld.%03ld,%ld.%03ld\n", result_total, abs(raw_data_x /1000), abs(raw_data_x % 1000), | |
1993 | raw_data_y /1000, raw_data_y % 1000); | |
1994 | } else if (raw_data_y < 0) { | |
1995 | return sprintf(buf, "%d,%ld.%03ld,-%ld.%03ld\n", result_total, raw_data_x /1000, raw_data_x % 1000, | |
1996 | abs(raw_data_y /1000), abs(raw_data_y % 1000)); | |
1997 | } else { | |
1998 | return sprintf(buf, "%d,%ld.%03ld,%ld.%03ld\n", result_total, raw_data_x /1000, raw_data_x % 1000, | |
1999 | raw_data_y /1000, raw_data_y % 1000); | |
2000 | } | |
2001 | } else { | |
2002 | err("OIS power is not enabled."); | |
2003 | return sprintf(buf, "%d,%ld.%03ld,%ld.%03ld\n", result_total, raw_data_x /1000, raw_data_x % 1000, | |
2004 | raw_data_y /1000, raw_data_y % 1000); | |
2005 | } | |
2006 | } | |
2007 | ||
2008 | static ssize_t camera_ois_rawdata_show(struct device *dev, | |
2009 | struct device_attribute *attr, char *buf) | |
2010 | { | |
2011 | long raw_data_x = 0, raw_data_y = 0; | |
2012 | ||
2013 | if (check_ois_power) { | |
2014 | fimc_is_ois_get_offset_data(sysfs_core, &raw_data_x, &raw_data_y); | |
2015 | ||
2016 | if (raw_data_x < 0 && raw_data_y < 0) { | |
2017 | return sprintf(buf, "-%ld.%03ld,-%ld.%03ld\n", abs(raw_data_x /1000), abs(raw_data_x % 1000), | |
2018 | abs(raw_data_y /1000), abs(raw_data_y % 1000)); | |
2019 | } else if (raw_data_x < 0) { | |
2020 | return sprintf(buf, "-%ld.%03ld,%ld.%03ld\n", abs(raw_data_x /1000), abs(raw_data_x % 1000), | |
2021 | raw_data_y /1000, raw_data_y % 1000); | |
2022 | } else if (raw_data_y < 0) { | |
2023 | return sprintf(buf, "%ld.%03ld,-%ld.%03ld\n", raw_data_x /1000, raw_data_x % 1000, | |
2024 | abs(raw_data_y /1000), abs(raw_data_y % 1000)); | |
2025 | } else { | |
2026 | return sprintf(buf, "%ld.%03ld,%ld.%03ld\n", raw_data_x /1000, raw_data_x % 1000, | |
2027 | raw_data_y /1000, raw_data_y % 1000); | |
2028 | } | |
2029 | } else { | |
2030 | err("OIS power is not enabled."); | |
2031 | return sprintf(buf, "%ld.%03ld,%ld.%03ld\n", raw_data_x /1000, raw_data_x % 1000, | |
2032 | raw_data_y /1000, raw_data_y % 1000); | |
2033 | } | |
2034 | } | |
2035 | ||
2036 | static ssize_t camera_ois_version_show(struct device *dev, | |
2037 | struct device_attribute *attr, char *buf) | |
2038 | { | |
2039 | struct fimc_is_ois_info *ois_minfo = NULL; | |
2040 | struct fimc_is_ois_info *ois_pinfo = NULL; | |
2041 | bool ret = false; | |
2042 | ||
2043 | fimc_is_vender_check_hw_init_running(); | |
2044 | ret = read_ois_version(); | |
2045 | fimc_is_ois_get_module_version(&ois_minfo); | |
2046 | fimc_is_ois_get_phone_version(&ois_pinfo); | |
2047 | ||
2048 | if (ois_minfo->checksum != 0x00 || !ret) { | |
2049 | return sprintf(buf, "%s %s\n", "NG_FW2", "NULL"); | |
2050 | } else if (ois_minfo->caldata != 0x00) { | |
2051 | return sprintf(buf, "%s %s\n", "NG_CD2", ois_pinfo->header_ver); | |
2052 | } else { | |
2053 | return sprintf(buf, "%s %s\n", ois_minfo->header_ver, ois_pinfo->header_ver); | |
2054 | } | |
2055 | } | |
2056 | ||
2057 | static ssize_t camera_ois_diff_show(struct device *dev, | |
2058 | struct device_attribute *attr, char *buf) | |
2059 | { | |
2060 | int result = 0; | |
2061 | int x_diff = 0, y_diff = 0; | |
2062 | ||
2063 | if (check_ois_power) { | |
2064 | result = fimc_is_ois_diff_test(sysfs_core, &x_diff, &y_diff); | |
2065 | ||
2066 | return sprintf(buf, "%d,%d,%d\n", result == true ? 0 : 1, x_diff, y_diff); | |
2067 | } else { | |
2068 | err("OIS power is not enabled."); | |
2069 | return sprintf(buf, "%d,%d,%d\n", 0, x_diff, y_diff); | |
2070 | } | |
2071 | } | |
2072 | ||
2073 | static ssize_t camera_ois_exif_show(struct device *dev, | |
2074 | struct device_attribute *attr, char *buf) | |
2075 | { | |
2076 | struct fimc_is_ois_info *ois_minfo = NULL; | |
2077 | struct fimc_is_ois_info *ois_pinfo = NULL; | |
2078 | struct fimc_is_ois_info *ois_uinfo = NULL; | |
2079 | struct fimc_is_ois_exif *ois_exif = NULL; | |
2080 | ||
2081 | fimc_is_ois_get_module_version(&ois_minfo); | |
2082 | fimc_is_ois_get_phone_version(&ois_pinfo); | |
2083 | fimc_is_ois_get_user_version(&ois_uinfo); | |
2084 | fimc_is_ois_get_exif_data(&ois_exif); | |
2085 | ||
2086 | return sprintf(buf, "%s %s %s %d %d", ois_minfo->header_ver, ois_pinfo->header_ver, | |
2087 | ois_uinfo->header_ver, ois_exif->error_data, ois_exif->status_data); | |
2088 | } | |
2089 | #endif | |
2090 | ||
2091 | #ifdef CONFIG_COMPANION_FACTORY_VALIDATION | |
2092 | static ssize_t camera_comp_ic_check_store(struct device *dev, | |
2093 | struct device_attribute *attr, const char *buf, size_t count) | |
2094 | { | |
2095 | int ret = 0; | |
2096 | struct fimc_is_vender_specific *specific = sysfs_core->vender.private_data; | |
2097 | ||
2098 | info("%s: buf[0]=%c running_rear_camera=%d running_front_camera=%d\n", | |
2099 | __func__,buf[0], | |
2100 | specific->running_rear_camera,specific->running_front_camera); | |
2101 | ||
2102 | switch (buf[0]) { | |
2103 | case '0': | |
2104 | break; | |
2105 | case '1': | |
2106 | comp_fac_i2c_check = 0; | |
2107 | comp_fac_valid_check = 0; | |
2108 | if (!specific->running_rear_camera) { | |
2109 | if (!specific->running_front_camera) { | |
2110 | ret = fimc_is_comp_fac_valid(sysfs_core); | |
2111 | } | |
2112 | } | |
2113 | break; | |
2114 | default: | |
2115 | pr_debug("%s: %c\n", __func__, buf[0]); | |
2116 | break; | |
2117 | } | |
2118 | ||
2119 | return count; | |
2120 | } | |
2121 | ||
2122 | static ssize_t camera_comp_ic_check_show(struct device *dev, | |
2123 | struct device_attribute *attr, char *buf) | |
2124 | { | |
2125 | ssize_t len = 0; | |
2126 | ||
2127 | info("%s: comp_fac_i2c_check[%d] comp_fac_valid_check[0x%04x]\n", | |
2128 | __func__, comp_fac_i2c_check, comp_fac_valid_check); | |
2129 | ||
2130 | if (comp_fac_i2c_check) { | |
2131 | len = sprintf(buf, "%s\n", "NG_I2C"); | |
2132 | } else if (comp_fac_valid_check) { | |
2133 | len = sprintf(buf, "%04X\n", comp_fac_valid_check); | |
2134 | } else { | |
2135 | len = sprintf(buf, "%s\n", "NG"); | |
2136 | } | |
2137 | ||
2138 | info("buf: %s\n",buf); | |
2139 | ||
2140 | return len; | |
2141 | } | |
2142 | #endif | |
2143 | #ifdef FORCE_CAL_LOAD | |
2144 | static ssize_t camera_rear_force_cal_load_show(struct device *dev, | |
2145 | struct device_attribute *attr, char *buf) | |
2146 | { | |
2147 | fimc_is_sec_set_force_caldata_dump(true); | |
2148 | return sprintf(buf, "FORCE CALDATA LOAD\n"); | |
2149 | } | |
2150 | #endif | |
2151 | ||
2152 | static ssize_t camera_rear_afcal_show(struct device *dev, | |
2153 | struct device_attribute *attr, char *buf) | |
2154 | { | |
2155 | #ifdef CAMERA_REAR2 | |
2156 | char tempbuf[10]; | |
2157 | char *cal_buf; | |
2158 | char N[] = "N "; | |
2159 | #endif | |
2160 | ||
2161 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
2162 | ||
2163 | #ifdef CAMERA_REAR2 | |
2164 | fimc_is_sec_get_cal_buf(&cal_buf); | |
2165 | strncat(buf, "10 ", strlen("10 ")); | |
2166 | ||
2167 | #ifdef FROM_AF_CAL_D10_ADDR | |
2168 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF_CAL_D10_ADDR])); | |
2169 | #else | |
2170 | sprintf(tempbuf, "%s", N); | |
2171 | #endif | |
2172 | strncat(buf, tempbuf, strlen(tempbuf)); | |
2173 | ||
2174 | #ifdef FROM_AF_CAL_D20_ADDR | |
2175 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF_CAL_D20_ADDR])); | |
2176 | #else | |
2177 | sprintf(tempbuf, "%s", N); | |
2178 | #endif | |
2179 | strncat(buf, tempbuf, strlen(tempbuf)); | |
2180 | ||
2181 | #ifdef FROM_AF_CAL_D30_ADDR | |
2182 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF_CAL_D30_ADDR])); | |
2183 | #else | |
2184 | sprintf(tempbuf, "%s", N); | |
2185 | #endif | |
2186 | strncat(buf, tempbuf, strlen(tempbuf)); | |
2187 | ||
2188 | #ifdef FROM_AF_CAL_D40_ADDR | |
2189 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF_CAL_D40_ADDR])); | |
2190 | #else | |
2191 | sprintf(tempbuf, "%s", N); | |
2192 | #endif | |
2193 | strncat(buf, tempbuf, strlen(tempbuf)); | |
2194 | ||
2195 | #ifdef FROM_AF_CAL_D50_ADDR | |
2196 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF_CAL_D50_ADDR])); | |
2197 | #else | |
2198 | sprintf(tempbuf, "%s", N); | |
2199 | #endif | |
2200 | strncat(buf, tempbuf, strlen(tempbuf)); | |
2201 | ||
2202 | #ifdef FROM_AF_CAL_D60_ADDR | |
2203 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF_CAL_D60_ADDR])); | |
2204 | #else | |
2205 | sprintf(tempbuf, "%s", N); | |
2206 | #endif | |
2207 | strncat(buf, tempbuf, strlen(tempbuf)); | |
2208 | ||
2209 | #ifdef FROM_AF_CAL_D70_ADDR | |
2210 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF_CAL_D70_ADDR])); | |
2211 | #else | |
2212 | sprintf(tempbuf, "%s", N); | |
2213 | #endif | |
2214 | strncat(buf, tempbuf, strlen(tempbuf)); | |
2215 | ||
2216 | #ifdef FROM_AF_CAL_D80_ADDR | |
2217 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF_CAL_D80_ADDR])); | |
2218 | #else | |
2219 | sprintf(tempbuf, "%s", N); | |
2220 | #endif | |
2221 | strncat(buf, tempbuf, strlen(tempbuf)); | |
2222 | ||
2223 | #ifdef FROM_AF_CAL_PAN_ADDR | |
2224 | sprintf(tempbuf, "%d ", *((s32*)&cal_buf[FROM_AF_CAL_PAN_ADDR])); | |
2225 | #else | |
2226 | sprintf(tempbuf, "%s", N); | |
2227 | #endif | |
2228 | strncat(buf, tempbuf, strlen(tempbuf)); | |
2229 | ||
2230 | return strlen(buf); | |
2231 | #else | |
2232 | return sprintf(buf, "1 %d %d\n", finfo->af_cal_macro, finfo->af_cal_pan); | |
2233 | #endif | |
2234 | } | |
2235 | ||
2236 | static ssize_t camera_rear_paf_offset_far_show(struct device *dev, | |
2237 | struct device_attribute *attr, char *buf) | |
2238 | { | |
2239 | #ifdef FROM_PAF_OFFSET_FAR_ADDR | |
2240 | char *cal_buf; | |
2241 | char tempbuf[10]; | |
2242 | int i; | |
2243 | ||
2244 | memset(tempbuf, 0, 10); | |
2245 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
2246 | fimc_is_sec_get_cal_buf(&cal_buf); | |
2247 | ||
2248 | for (i = 0; i < FROM_PAF_OFFSET_FAR_SIZE / 2 - 1; i++) { | |
2249 | sprintf(tempbuf, "%d,", *((s16 *)&cal_buf[FROM_PAF_OFFSET_FAR_ADDR + 2 * i])); | |
2250 | strncat(buf, tempbuf, strlen(tempbuf)); | |
2251 | memset(tempbuf, 0, 10); | |
2252 | } | |
2253 | ||
2254 | sprintf(tempbuf, "%d", *((s16 *)&cal_buf[FROM_PAF_OFFSET_FAR_ADDR + 2 * i])); | |
2255 | strncat(buf, tempbuf, strlen(tempbuf)); | |
2256 | strncat(buf, "\n", strlen("\n")); | |
2257 | #endif | |
2258 | return strlen(buf); | |
2259 | } | |
2260 | static DEVICE_ATTR(rear_paf_offset_far, S_IRUGO, camera_rear_paf_offset_far_show, NULL); | |
2261 | ||
2262 | static ssize_t camera_rear_sensorid_exif_show(struct device *dev, | |
2263 | struct device_attribute *attr, char *buf) | |
2264 | { | |
2265 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
2266 | ||
2267 | return sprintf(buf, "%s", finfo->from_sensor_id); | |
2268 | } | |
2269 | ||
2270 | static ssize_t camera_rear_mtf_exif_show(struct device *dev, | |
2271 | struct device_attribute *attr, char *buf) | |
2272 | { | |
2273 | char *cal_buf; | |
2274 | ||
2275 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
2276 | fimc_is_sec_get_cal_buf(&cal_buf); | |
2277 | ||
2278 | memcpy(buf, &cal_buf[finfo->mtf_data_addr], FIMC_IS_RESOLUTION_DATA_SIZE); | |
2279 | return FIMC_IS_RESOLUTION_DATA_SIZE; | |
2280 | } | |
2281 | ||
2282 | static ssize_t camera_rear_awb_master_show(struct device *dev, | |
2283 | struct device_attribute *attr, char *buf) | |
2284 | { | |
2285 | char *cal_buf; | |
2286 | ||
2287 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
2288 | fimc_is_sec_get_cal_buf(&cal_buf); | |
2289 | ||
2290 | memcpy(buf, &cal_buf[finfo->awb_master_addr], FIMC_IS_AWB_MASTER_DATA_SIZE); | |
2291 | return FIMC_IS_AWB_MASTER_DATA_SIZE; | |
2292 | } | |
2293 | ||
2294 | static ssize_t camera_rear_awb_module_show(struct device *dev, | |
2295 | struct device_attribute *attr, char *buf) | |
2296 | { | |
2297 | char *cal_buf; | |
2298 | ||
2299 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
2300 | fimc_is_sec_get_cal_buf(&cal_buf); | |
2301 | ||
2302 | memcpy(buf, &cal_buf[finfo->awb_module_addr], FIMC_IS_AWB_MODULE_DATA_SIZE); | |
2303 | return FIMC_IS_AWB_MODULE_DATA_SIZE; | |
2304 | } | |
2305 | ||
2306 | static ssize_t camera_rear_moduleid_show(struct device *dev, | |
2307 | struct device_attribute *attr, char *buf) | |
2308 | { | |
2309 | read_from_firmware_version(SENSOR_POSITION_REAR); | |
2310 | ||
2311 | return sprintf(buf, "%c%c%c%c%c%02X%02X%02X%02X%02X\n", | |
2312 | finfo->from_module_id[0], finfo->from_module_id[1], finfo->from_module_id[2], | |
2313 | finfo->from_module_id[3], finfo->from_module_id[4], finfo->from_module_id[5], | |
2314 | finfo->from_module_id[6], finfo->from_module_id[7], finfo->from_module_id[8], | |
2315 | finfo->from_module_id[9]); | |
2316 | } | |
2317 | ||
2318 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_FRONT) | |
2319 | static ssize_t camera_front_afcal_show(struct device *dev, | |
2320 | struct device_attribute *attr, char *buf) | |
2321 | { | |
2322 | read_from_firmware_version(SENSOR_POSITION_FRONT); | |
2323 | ||
2324 | return sprintf(buf, "1 %d %d\n", front_finfo->af_cal_macro, front_finfo->af_cal_pan); | |
2325 | } | |
2326 | ||
2327 | static ssize_t camera_front_moduleid_show(struct device *dev, | |
2328 | struct device_attribute *attr, char *buf) | |
2329 | { | |
2330 | read_from_firmware_version(SENSOR_POSITION_FRONT); | |
2331 | ||
2332 | return sprintf(buf, "%c%c%c%c%c%02X%02X%02X%02X%02X\n", | |
2333 | front_finfo->eeprom_front_module_id[0], front_finfo->eeprom_front_module_id[1], front_finfo->eeprom_front_module_id[2], | |
2334 | front_finfo->eeprom_front_module_id[3], front_finfo->eeprom_front_module_id[4], front_finfo->eeprom_front_module_id[5], | |
2335 | front_finfo->eeprom_front_module_id[6], front_finfo->eeprom_front_module_id[7], front_finfo->eeprom_front_module_id[8], | |
2336 | front_finfo->eeprom_front_module_id[9]); | |
2337 | } | |
2338 | ||
2339 | static ssize_t camera_front_mtf_exif_show(struct device *dev, | |
2340 | struct device_attribute *attr, char *buf) | |
2341 | { | |
2342 | char *cal_buf; | |
2343 | ||
2344 | read_from_firmware_version(SENSOR_POSITION_FRONT); | |
2345 | fimc_is_sec_get_front_cal_buf(&cal_buf); | |
2346 | ||
2347 | memcpy(buf, &cal_buf[front_finfo->mtf_data_addr], FIMC_IS_RESOLUTION_DATA_SIZE); | |
2348 | return FIMC_IS_RESOLUTION_DATA_SIZE; | |
2349 | } | |
2350 | ||
2351 | static ssize_t camera_front_sensorid_exif_show(struct device *dev, | |
2352 | struct device_attribute *attr, char *buf) | |
2353 | { | |
2354 | read_from_firmware_version(SENSOR_POSITION_FRONT); | |
2355 | ||
2356 | return sprintf(buf, "%s", front_finfo->from_sensor_id); | |
2357 | } | |
2358 | #endif | |
2359 | ||
2360 | int camera_fw_show_sub(char *path, char *buf, int startPos, int readsize) | |
2361 | { | |
2362 | struct file *fp = NULL; | |
2363 | long fsize, nread; | |
2364 | int ret = 0; | |
2365 | ||
2366 | fp = filp_open(path, O_RDONLY, 0660); | |
2367 | ||
2368 | fsize = fp->f_path.dentry->d_inode->i_size; | |
2369 | ||
2370 | if (IS_ERR(fp)) { | |
2371 | err("Camera: Failed open phone firmware"); | |
2372 | ret = -EIO; | |
2373 | fp = NULL; | |
2374 | goto exit; | |
2375 | } | |
2376 | ||
2377 | if (startPos < 0) | |
2378 | fp->f_pos = fsize + startPos; | |
2379 | else | |
2380 | fp->f_pos = startPos; | |
2381 | ||
2382 | fsize = readsize; | |
2383 | nread = vfs_read(fp, (char __user *)buf, fsize, &fp->f_pos); | |
2384 | if (nread != fsize) { | |
2385 | err("failed to read firmware file, %ld Bytes", nread); | |
2386 | ret = -EIO; | |
2387 | } | |
2388 | ||
2389 | exit: | |
2390 | if (fp) { | |
2391 | filp_close(fp, current->files); | |
2392 | fp = NULL; | |
2393 | } | |
2394 | ||
2395 | return ret; | |
2396 | } | |
2397 | ||
2398 | char *rta_fw_list[] = { | |
2399 | #ifdef RTA_FW_LL | |
2400 | RTA_FW_LL, | |
2401 | #endif | |
2402 | #ifdef RTA_FW_LX | |
2403 | RTA_FW_LX, | |
2404 | #endif | |
2405 | #ifdef RTA_FW_LY | |
2406 | RTA_FW_LY, | |
2407 | #endif | |
2408 | #ifdef RTA_FW_LS | |
2409 | RTA_FW_LS | |
2410 | #endif | |
2411 | }; | |
2412 | ||
2413 | char *companion_fw_list[] = { | |
2414 | #ifdef COMPANION_FW_LL | |
2415 | COMPANION_FW_LL, | |
2416 | #endif | |
2417 | #ifdef COMPANION_FW_LX | |
2418 | COMPANION_FW_LX, | |
2419 | #endif | |
2420 | #ifdef COMPANION_FW_LY | |
2421 | COMPANION_FW_LY, | |
2422 | #endif | |
2423 | #ifdef COMPANION_FW_LS | |
2424 | COMPANION_FW_LS | |
2425 | #endif | |
2426 | }; | |
2427 | ||
2428 | static ssize_t camera_rear_camfw_all_show(struct device *dev, | |
2429 | struct device_attribute *attr, char *buf) | |
2430 | { | |
2431 | #define VER_MAX_SIZE 100 | |
2432 | int ret; | |
2433 | mm_segment_t old_fs; | |
2434 | char fw_ver[VER_MAX_SIZE] = {0, }; | |
2435 | char output[1024] = {0, }; | |
2436 | char path[128] = {0, }; | |
2437 | int cnt = 0, loop = 0, i; | |
2438 | ||
2439 | old_fs = get_fs(); | |
2440 | set_fs(KERNEL_DS); | |
2441 | ||
2442 | sprintf(output, "[RCAM]"); | |
2443 | cnt = 0; | |
2444 | ||
2445 | loop = sizeof(rta_fw_list) / sizeof(char *); | |
2446 | for (i = 0; i < loop; i++) { | |
2447 | sprintf(path, FIMC_IS_FW_PATH"%s", rta_fw_list[i]); | |
2448 | ret = camera_fw_show_sub(path, fw_ver, | |
2449 | (-FIMC_IS_HEADER_VER_OFFSET), FIMC_IS_HEADER_VER_SIZE); | |
2450 | if (ret == 0) { | |
2451 | if (cnt++ > 0) | |
2452 | strcat(output, ","); | |
2453 | strcat(output, fw_ver); | |
2454 | memset(fw_ver, 0, sizeof(fw_ver)); | |
2455 | } | |
2456 | } | |
2457 | ||
2458 | strcat(output, ";[COMPANION]"); | |
2459 | cnt = 0; | |
2460 | ||
2461 | loop = sizeof(companion_fw_list) / sizeof(char *); | |
2462 | for (i = 0; i < loop; i++) { | |
2463 | sprintf(path, FIMC_IS_FW_PATH"%s", companion_fw_list[i]); | |
2464 | ret = camera_fw_show_sub(path, fw_ver, | |
2465 | (-16), FIMC_IS_HEADER_VER_SIZE); | |
2466 | if (ret == 0) { | |
2467 | if (cnt++ > 0) | |
2468 | strcat(output, ","); | |
2469 | strcat(output, fw_ver); | |
2470 | memset(fw_ver, 0, sizeof(fw_ver)); | |
2471 | } | |
2472 | } | |
2473 | ||
2474 | set_fs(old_fs); | |
2475 | ||
2476 | strcat(output, ";[OIS]"); | |
2477 | ret = fimc_is_ois_read_fw_ver(sysfs_core, FIMC_IS_FW_PATH FIMC_OIS_FW_NAME_SEC, fw_ver); | |
2478 | if (ret == 0) { | |
2479 | strcat(output, fw_ver); | |
2480 | memset(fw_ver, 0, sizeof(fw_ver)); | |
2481 | } | |
2482 | ||
2483 | ret = fimc_is_ois_read_fw_ver(sysfs_core, FIMC_IS_FW_PATH FIMC_OIS_FW_NAME_DOM, fw_ver); | |
2484 | if (ret == 0) { | |
2485 | strcat(output, ","); | |
2486 | strcat(output, fw_ver); | |
2487 | memset(fw_ver, 0, sizeof(fw_ver)); | |
2488 | } | |
2489 | return sprintf(buf, "%s\n", output); | |
2490 | } | |
2491 | ||
2492 | #ifdef CONFIG_SECURE_CAMERA_USE | |
2493 | static ssize_t camera_iris_camfw_show(struct device *dev, | |
2494 | struct device_attribute *attr, char *buf) | |
2495 | { | |
2496 | char sensor_name[50]; | |
2497 | int ret; | |
2498 | ||
2499 | if (is_iris_ver_read) { | |
2500 | ret = fimc_is_get_sensor_data(dev, NULL, sensor_name, SENSOR_POSITION_SECURE); | |
2501 | ||
2502 | if (ret < 0) { | |
2503 | return sprintf(buf, "UNKNOWN N\n"); | |
2504 | } else { | |
2505 | return sprintf(buf, "%s N\n", sensor_name); | |
2506 | } | |
2507 | } else { | |
2508 | return sprintf(buf, "UNKNOWN N\n"); | |
2509 | } | |
2510 | } | |
2511 | ||
2512 | static ssize_t camera_iris_camfw_full_show(struct device *dev, | |
2513 | struct device_attribute *attr, char *buf) | |
2514 | { | |
2515 | char sensor_name[50]; | |
2516 | int ret; | |
2517 | ||
2518 | if (is_iris_ver_read) { | |
2519 | ret = fimc_is_get_sensor_data(dev, NULL, sensor_name, SENSOR_POSITION_SECURE); | |
2520 | ||
2521 | if (ret < 0) { | |
2522 | return sprintf(buf, "UNKNOWN N N\n"); | |
2523 | } else { | |
2524 | return sprintf(buf, "%s N N\n", sensor_name); | |
2525 | } | |
2526 | } else { | |
2527 | return sprintf(buf, "UNKNOWN N N\n"); | |
2528 | } | |
2529 | } | |
2530 | ||
2531 | static ssize_t camera_iris_checkfw_factory_show(struct device *dev, | |
2532 | struct device_attribute *attr, char *buf) | |
2533 | { | |
2534 | u8 year_month_company[3] = {'0', '0', '0'}; | |
2535 | ||
2536 | info("camera_iris_checkfw_factory_show\n"); | |
2537 | ||
2538 | if (is_iris_mtf_read_data[0] != 0x00 && is_iris_mtf_read_data[0] >= 'A' && is_iris_mtf_read_data[0] <= 'Z') | |
2539 | year_month_company[0] = is_iris_mtf_read_data[0]; | |
2540 | ||
2541 | if (is_iris_mtf_read_data[1] != 0x00 && is_iris_mtf_read_data[1] >= 'A' && is_iris_mtf_read_data[1] <= 'Z') | |
2542 | year_month_company[1] = is_iris_mtf_read_data[1]; | |
2543 | ||
2544 | if (is_iris_mtf_read_data[2] != 0x00 && is_iris_mtf_read_data[2] >= 'A' && is_iris_mtf_read_data[2] <= 'Z') | |
2545 | year_month_company[2] = is_iris_mtf_read_data[2]; | |
2546 | ||
2547 | if (is_iris_mtf_test_check == false) { | |
2548 | return sprintf(buf, "NG_RES %c %c %c\n", year_month_company[0], year_month_company[1], year_month_company[2]); | |
2549 | } | |
2550 | if (is_iris_ver_read) { | |
2551 | if (is_final_cam_module_iris) { | |
2552 | return sprintf(buf, "OK %c %c %c\n", year_month_company[0], year_month_company[1], year_month_company[2]); | |
2553 | } else { | |
2554 | #ifdef CAMERA_SYSFS_V2 | |
2555 | return sprintf(buf, "NG_VER %c %c %c\n", year_month_company[0], year_month_company[1], year_month_company[2]); | |
2556 | #else | |
2557 | return sprintf(buf, "NG %c %c %c\n", year_month_company[0], year_month_company[1], year_month_company[2]); | |
2558 | #endif | |
2559 | } | |
2560 | } else { | |
2561 | return sprintf(buf, "NG_VER %c %c %c\n", year_month_company[0], year_month_company[1], year_month_company[2]); | |
2562 | } | |
2563 | } | |
2564 | ||
2565 | #ifdef USE_CAMERA_HW_BIG_DATA | |
2566 | static ssize_t rear_camera_hw_param_show(struct device *dev, | |
2567 | struct device_attribute *attr, char *buf) | |
2568 | { | |
2569 | struct cam_hw_param *ec_param = NULL; | |
2570 | fimc_is_sec_get_hw_param(&ec_param, SENSOR_POSITION_REAR); | |
2571 | ||
2572 | if (fimc_is_sec_is_valid_moduleid(finfo->from_module_id)) { | |
2573 | return sprintf(buf, "\"CAMIR_ID\":\"%c%c%c%c%cXX%02X%02X%02X\",\"I2CR_AF\":\"%d\"," | |
2574 | "\"I2CR_COM\":\"%d\",\"I2CR_OIS\":\"%d\",\"I2CR_SEN\":\"%d\",\"MIPIR_COM\":\"%d\",\"MIPIR_SEN\":\"%d\"\n", | |
2575 | finfo->from_module_id[0], finfo->from_module_id[1], finfo->from_module_id[2], finfo->from_module_id[3], | |
2576 | finfo->from_module_id[4], finfo->from_module_id[7], finfo->from_module_id[8], finfo->from_module_id[9], | |
2577 | ec_param->i2c_af_err_cnt, ec_param->i2c_comp_err_cnt, ec_param->i2c_ois_err_cnt, | |
2578 | ec_param->i2c_sensor_err_cnt, ec_param->mipi_comp_err_cnt, ec_param->mipi_sensor_err_cnt); | |
2579 | } else { | |
2580 | return sprintf(buf, "\"CAMIR_ID\":\"MIR_ERR\",\"I2CR_AF\":\"%d\"," | |
2581 | "\"I2CR_COM\":\"%d\",\"I2CR_OIS\":\"%d\",\"I2CR_SEN\":\"%d\",\"MIPIR_COM\":\"%d\",\"MIPIR_SEN\":\"%d\"\n", | |
2582 | ec_param->i2c_af_err_cnt, ec_param->i2c_comp_err_cnt, ec_param->i2c_ois_err_cnt, | |
2583 | ec_param->i2c_sensor_err_cnt, ec_param->mipi_comp_err_cnt, ec_param->mipi_sensor_err_cnt); | |
2584 | } | |
2585 | } | |
2586 | ||
2587 | static ssize_t rear_camera_hw_param_store(struct device *dev, | |
2588 | struct device_attribute *attr, const char *buf, size_t count) | |
2589 | { | |
2590 | struct cam_hw_param *ec_param = NULL; | |
2591 | if (!strncmp(buf, "c", 1)) { | |
2592 | fimc_is_sec_get_hw_param(&ec_param, SENSOR_POSITION_REAR); | |
2593 | ||
2594 | if (ec_param) | |
2595 | fimc_is_sec_init_err_cnt(ec_param); | |
2596 | } | |
2597 | ||
2598 | return count; | |
2599 | } | |
2600 | ||
2601 | static ssize_t front_camera_hw_param_show(struct device *dev, | |
2602 | struct device_attribute *attr, char *buf) | |
2603 | { | |
2604 | struct cam_hw_param *ec_param = NULL; | |
2605 | fimc_is_sec_get_hw_param(&ec_param, SENSOR_POSITION_FRONT); | |
2606 | ||
2607 | if (fimc_is_sec_is_valid_moduleid(front_finfo->eeprom_front_module_id)) { | |
2608 | return sprintf(buf, "\"CAMIF_ID\":\"%c%c%c%c%cXX%02X%02X%02X\",\"I2CF_AF\":\"%d\"," | |
2609 | "\"I2CF_COM\":\"%d\",\"I2CF_OIS\":\"%d\",\"I2CF_SEN\":\"%d\",\"MIPIF_COM\":\"%d\",\"MIPIF_SEN\":\"%d\"\n", | |
2610 | front_finfo->eeprom_front_module_id[0], front_finfo->eeprom_front_module_id[1], front_finfo->eeprom_front_module_id[2], | |
2611 | front_finfo->eeprom_front_module_id[3], front_finfo->eeprom_front_module_id[4], front_finfo->eeprom_front_module_id[7], | |
2612 | front_finfo->eeprom_front_module_id[8], front_finfo->eeprom_front_module_id[9], ec_param->i2c_af_err_cnt, | |
2613 | ec_param->i2c_comp_err_cnt, ec_param->i2c_ois_err_cnt, ec_param->i2c_sensor_err_cnt, ec_param->mipi_comp_err_cnt, | |
2614 | ec_param->mipi_sensor_err_cnt); | |
2615 | } else { | |
2616 | return sprintf(buf, "\"CAMIF_ID\":\"MIR_ERR\",\"I2CF_AF\":\"%d\"," | |
2617 | "\"I2CF_COM\":\"%d\",\"I2CF_OIS\":\"%d\",\"I2CF_SEN\":\"%d\",\"MIPIF_COM\":\"%d\",\"MIPIF_SEN\":\"%d\"\n", | |
2618 | ec_param->i2c_af_err_cnt, ec_param->i2c_comp_err_cnt, ec_param->i2c_ois_err_cnt, ec_param->i2c_sensor_err_cnt, | |
2619 | ec_param->mipi_comp_err_cnt, ec_param->mipi_sensor_err_cnt); | |
2620 | } | |
2621 | } | |
2622 | ||
2623 | static ssize_t front_camera_hw_param_store(struct device *dev, | |
2624 | struct device_attribute *attr, const char *buf, size_t count) | |
2625 | { | |
2626 | struct cam_hw_param *ec_param = NULL; | |
2627 | if (!strncmp(buf, "c", 1)) { | |
2628 | fimc_is_sec_get_hw_param(&ec_param, SENSOR_POSITION_FRONT); | |
2629 | ||
2630 | if (ec_param) | |
2631 | fimc_is_sec_init_err_cnt(ec_param); | |
2632 | } | |
2633 | ||
2634 | return count; | |
2635 | } | |
2636 | ||
2637 | #ifdef CAMERA_REAR2 | |
2638 | static ssize_t rear2_camera_hw_param_show(struct device *dev, | |
2639 | struct device_attribute *attr, char *buf) | |
2640 | { | |
2641 | struct cam_hw_param *ec_param = NULL; | |
2642 | fimc_is_sec_get_hw_param(&ec_param, SENSOR_POSITION_REAR2); | |
2643 | ||
2644 | if (fimc_is_sec_is_valid_moduleid(finfo->from_module_id)) { | |
2645 | return sprintf(buf, "\"CAMIR2_ID\":\"%c%c%c%c%cXX%02X%02X%02X\",\"I2CR2_AF\":\"%d\"," | |
2646 | "\"I2CR2_COM\":\"%d\",\"I2CR2_OIS\":\"%d\",\"I2CR2_SEN\":\"%d\",\"MIPIR2_COM\":\"%d\",\"MIPIR2_SEN\":\"%d\"\n", | |
2647 | finfo->from_module_id[0], finfo->from_module_id[1], finfo->from_module_id[2], finfo->from_module_id[3], | |
2648 | finfo->from_module_id[4], finfo->from_module_id[7], finfo->from_module_id[8], finfo->from_module_id[9], | |
2649 | ec_param->i2c_af_err_cnt, ec_param->i2c_comp_err_cnt, ec_param->i2c_ois_err_cnt, | |
2650 | ec_param->i2c_sensor_err_cnt, ec_param->mipi_comp_err_cnt, ec_param->mipi_sensor_err_cnt); | |
2651 | } else { | |
2652 | return sprintf(buf, "\"CAMIR2_ID\":\"MIR_ERR\",\"I2CR2_AF\":\"%d\"," | |
2653 | "\"I2CR2_COM\":\"%d\",\"I2CR2_OIS\":\"%d\",\"I2CR2_SEN\":\"%d\",\"MIPIR2_COM\":\"%d\",\"MIPIR2_SEN\":\"%d\"\n", | |
2654 | ec_param->i2c_af_err_cnt, ec_param->i2c_comp_err_cnt, ec_param->i2c_ois_err_cnt, | |
2655 | ec_param->i2c_sensor_err_cnt, ec_param->mipi_comp_err_cnt, ec_param->mipi_sensor_err_cnt); | |
2656 | } | |
2657 | } | |
2658 | ||
2659 | static ssize_t rear2_camera_hw_param_store(struct device *dev, | |
2660 | struct device_attribute *attr, const char *buf, size_t count) | |
2661 | { | |
2662 | struct cam_hw_param *ec_param = NULL; | |
2663 | if (!strncmp(buf, "c", 1)) { | |
2664 | fimc_is_sec_get_hw_param(&ec_param, SENSOR_POSITION_REAR2); | |
2665 | ||
2666 | if (ec_param) | |
2667 | fimc_is_sec_init_err_cnt(ec_param); | |
2668 | } | |
2669 | ||
2670 | return count; | |
2671 | } | |
2672 | #endif | |
2673 | ||
2674 | #ifdef CONFIG_SECURE_CAMERA_USE | |
2675 | static ssize_t iris_camera_hw_param_show(struct device *dev, | |
2676 | struct device_attribute *attr, char *buf) | |
2677 | { | |
2678 | struct cam_hw_param *ec_param = NULL; | |
2679 | fimc_is_sec_get_hw_param(&ec_param, SENSOR_POSITION_SECURE); | |
2680 | ||
2681 | return sprintf(buf, "\"CAMII_ID\":\"MI_NO\",\"I2CI_AF\":\"%d\",\"I2CI_COM\":\"%d\",\"I2CI_OIS\":\"%d\"," | |
2682 | "\"I2CI_SEN\":\"%d\",\"MIPII_COM\":\"%d\",\"MIPII_SEN\":\"%d\"\n", | |
2683 | ec_param->i2c_af_err_cnt, ec_param->i2c_comp_err_cnt, ec_param->i2c_ois_err_cnt, | |
2684 | ec_param->i2c_sensor_err_cnt, ec_param->mipi_comp_err_cnt, ec_param->mipi_sensor_err_cnt); | |
2685 | } | |
2686 | ||
2687 | static ssize_t iris_camera_hw_param_store(struct device *dev, | |
2688 | struct device_attribute *attr, const char *buf, size_t count) | |
2689 | { | |
2690 | struct cam_hw_param *ec_param = NULL; | |
2691 | ||
2692 | if (!strncmp(buf, "c", 1)) { | |
2693 | fimc_is_sec_get_hw_param(&ec_param, SENSOR_POSITION_SECURE); | |
2694 | ||
2695 | if (ec_param) | |
2696 | fimc_is_sec_init_err_cnt(ec_param); | |
2697 | } | |
2698 | ||
2699 | return count; | |
2700 | } | |
2701 | #endif | |
2702 | #endif | |
2703 | ||
2704 | static ssize_t camera_iris_checkfw_user_show(struct device *dev, | |
2705 | struct device_attribute *attr, char *buf) | |
2706 | { | |
2707 | if (is_iris_ver_read) { | |
2708 | if (is_final_cam_module_iris) | |
2709 | return sprintf(buf, "%s\n", "OK"); | |
2710 | else | |
2711 | return sprintf(buf, "%s\n", "NG"); | |
2712 | } else { | |
2713 | return sprintf(buf, "%s\n", "NG"); | |
2714 | } | |
2715 | } | |
2716 | ||
2717 | #ifdef CAMERA_SYSFS_V2 | |
2718 | static ssize_t camera_iris_info_show(struct device *dev, | |
2719 | struct device_attribute *attr, char *buf) | |
2720 | { | |
2721 | char camera_info[130] = {0, }; | |
2722 | #ifdef CONFIG_OF | |
2723 | struct fimc_is_cam_info *cam_info = &(cam_infos[CAM_INFO_IRIS]); | |
2724 | ||
2725 | if(!cam_info->valid) { | |
2726 | strcpy(camera_info, "ISP=NULL;CALMEM=NULL;READVER=NULL;COREVOLT=NULL;UPGRADE=NULL;" | |
2727 | "FWWRITE=NULL;FWDUMP=NULL;CC=NULL;OIS=NULL;VALID=N"); | |
2728 | ||
2729 | return sprintf(buf, "%s\n", camera_info); | |
2730 | } else { | |
2731 | strcpy(camera_info, "ISP="); | |
2732 | switch(cam_info->isp) { | |
2733 | case CAM_INFO_ISP_TYPE_INTERNAL : | |
2734 | strncat(camera_info, "INT;", strlen("INT;")); | |
2735 | break; | |
2736 | case CAM_INFO_ISP_TYPE_EXTERNAL : | |
2737 | strncat(camera_info, "EXT;", strlen("EXT;")); | |
2738 | break; | |
2739 | case CAM_INFO_ISP_TYPE_SOC : | |
2740 | strncat(camera_info, "SOC;", strlen("SOC;")); | |
2741 | break; | |
2742 | default : | |
2743 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
2744 | break; | |
2745 | } | |
2746 | ||
2747 | strncat(camera_info, "CALMEM=", strlen("CALMEM=")); | |
2748 | switch(cam_info->cal_memory) { | |
2749 | case CAM_INFO_CAL_MEM_TYPE_NONE : | |
2750 | strncat(camera_info, "N;", strlen("N;")); | |
2751 | break; | |
2752 | case CAM_INFO_CAL_MEM_TYPE_FROM : | |
2753 | case CAM_INFO_CAL_MEM_TYPE_EEPROM : | |
2754 | case CAM_INFO_CAL_MEM_TYPE_OTP : | |
2755 | strncat(camera_info, "Y;", strlen("Y;")); | |
2756 | break; | |
2757 | default : | |
2758 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
2759 | break; | |
2760 | } | |
2761 | ||
2762 | strncat(camera_info, "READVER=", strlen("READVER=")); | |
2763 | switch(cam_info->read_version) { | |
2764 | case CAM_INFO_READ_VER_SYSFS : | |
2765 | strncat(camera_info, "SYSFS;", strlen("SYSFS;")); | |
2766 | break; | |
2767 | case CAM_INFO_READ_VER_CAMON : | |
2768 | strncat(camera_info, "CAMON;", strlen("CAMON;")); | |
2769 | break; | |
2770 | default : | |
2771 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
2772 | break; | |
2773 | } | |
2774 | ||
2775 | strncat(camera_info, "COREVOLT=", strlen("COREVOLT=")); | |
2776 | switch(cam_info->core_voltage) { | |
2777 | case CAM_INFO_CORE_VOLT_NONE : | |
2778 | strncat(camera_info, "N;", strlen("N;")); | |
2779 | break; | |
2780 | case CAM_INFO_CORE_VOLT_USE : | |
2781 | strncat(camera_info, "Y;", strlen("Y;")); | |
2782 | break; | |
2783 | default : | |
2784 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
2785 | break; | |
2786 | } | |
2787 | ||
2788 | strncat(camera_info, "UPGRADE=", strlen("UPGRADE=")); | |
2789 | switch(cam_info->upgrade) { | |
2790 | case CAM_INFO_FW_UPGRADE_NONE : | |
2791 | strncat(camera_info, "N;", strlen("N;")); | |
2792 | break; | |
2793 | case CAM_INFO_FW_UPGRADE_SYSFS : | |
2794 | strncat(camera_info, "SYSFS;", strlen("SYSFS;")); | |
2795 | break; | |
2796 | case CAM_INFO_FW_UPGRADE_CAMON : | |
2797 | strncat(camera_info, "CAMON;", strlen("CAMON;")); | |
2798 | break; | |
2799 | default : | |
2800 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
2801 | break; | |
2802 | } | |
2803 | ||
2804 | strncat(camera_info, "FWWRITE=", strlen("FWWRITE=")); | |
2805 | switch(cam_info->fw_write) { | |
2806 | case CAM_INFO_FW_WRITE_NONE : | |
2807 | strncat(camera_info, "N;", strlen("N;")); | |
2808 | break; | |
2809 | case CAM_INFO_FW_WRITE_OS : | |
2810 | strncat(camera_info, "OS;", strlen("OS;")); | |
2811 | break; | |
2812 | case CAM_INFO_FW_WRITE_SD : | |
2813 | strncat(camera_info, "SD;", strlen("SD;")); | |
2814 | break; | |
2815 | case CAM_INFO_FW_WRITE_ALL : | |
2816 | strncat(camera_info, "ALL;", strlen("ALL;")); | |
2817 | break; | |
2818 | default : | |
2819 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
2820 | break; | |
2821 | } | |
2822 | ||
2823 | strncat(camera_info, "FWDUMP=", strlen("FWDUMP=")); | |
2824 | switch(cam_info->fw_dump) { | |
2825 | case CAM_INFO_FW_DUMP_NONE : | |
2826 | strncat(camera_info, "N;", strlen("N;")); | |
2827 | break; | |
2828 | case CAM_INFO_FW_DUMP_USE : | |
2829 | strncat(camera_info, "Y;", strlen("Y;")); | |
2830 | break; | |
2831 | default : | |
2832 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
2833 | break; | |
2834 | } | |
2835 | ||
2836 | strncat(camera_info, "CC=", strlen("CC=")); | |
2837 | switch(cam_info->companion) { | |
2838 | case CAM_INFO_COMPANION_NONE : | |
2839 | strncat(camera_info, "N;", strlen("N;")); | |
2840 | break; | |
2841 | case CAM_INFO_COMPANION_USE : | |
2842 | strncat(camera_info, "Y;", strlen("Y;")); | |
2843 | break; | |
2844 | default : | |
2845 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
2846 | break; | |
2847 | } | |
2848 | ||
2849 | strncat(camera_info, "OIS=", strlen("OIS=")); | |
2850 | switch(cam_info->ois) { | |
2851 | case CAM_INFO_OIS_NONE : | |
2852 | strncat(camera_info, "N;", strlen("N;")); | |
2853 | break; | |
2854 | case CAM_INFO_OIS_USE : | |
2855 | strncat(camera_info, "Y;", strlen("Y;")); | |
2856 | break; | |
2857 | default : | |
2858 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
2859 | break; | |
2860 | } | |
2861 | ||
2862 | strncat(camera_info, "VALID=", strlen("VALID=")); | |
2863 | switch(cam_info->valid) { | |
2864 | case CAM_INFO_INVALID : | |
2865 | strncat(camera_info, "N;", strlen("N;")); | |
2866 | break; | |
2867 | case CAM_INFO_VALID : | |
2868 | strncat(camera_info, "Y;", strlen("Y;")); | |
2869 | break; | |
2870 | default : | |
2871 | strncat(camera_info, "NULL;", strlen("NULL;")); | |
2872 | break; | |
2873 | } | |
2874 | ||
2875 | return sprintf(buf, "%s\n", camera_info); | |
2876 | } | |
2877 | #endif | |
2878 | strcpy(camera_info, "ISP=NULL;CALMEM=NULL;READVER=NULL;COREVOLT=NULL;UPGRADE=NULL;" | |
2879 | "FWWRITE=NULL;FWDUMP=NULL;CC=NULL;OIS=NULL;VALID=N"); | |
2880 | ||
2881 | return sprintf(buf, "%s\n", camera_info); | |
2882 | } | |
2883 | #endif | |
2884 | #endif | |
2885 | ||
2886 | #ifdef CAMERA_MODULE_DUALIZE | |
2887 | static DEVICE_ATTR(from_write, S_IRUGO, | |
2888 | camera_rear_writefw_show, NULL); | |
2889 | #endif | |
2890 | static DEVICE_ATTR(rear_camtype, S_IRUGO, | |
2891 | camera_rear_camtype_show, NULL); | |
2892 | static DEVICE_ATTR(rear_camfw, S_IRUGO, | |
2893 | camera_rear_camfw_show, camera_rear_camfw_write); | |
2894 | static DEVICE_ATTR(rear_camfw_full, S_IRUGO, | |
2895 | camera_rear_camfw_full_show, NULL); | |
2896 | #ifdef CONFIG_COMPANION_USE | |
2897 | static DEVICE_ATTR(rear_companionfw, S_IRUGO, | |
2898 | camera_rear_companionfw_show, NULL); | |
2899 | static DEVICE_ATTR(rear_companionfw_full, S_IRUGO, | |
2900 | camera_rear_companionfw_full_show, NULL); | |
2901 | #endif | |
2902 | static DEVICE_ATTR(rear_calcheck, S_IRUGO, | |
2903 | camera_rear_calcheck_show, NULL); | |
2904 | static DEVICE_ATTR(rear_checkfw_user, S_IRUGO, | |
2905 | camera_rear_checkfw_user_show, NULL); | |
2906 | static DEVICE_ATTR(rear_checkfw_factory, S_IRUGO, | |
2907 | camera_rear_checkfw_factory_show, NULL); | |
2908 | #ifdef CAMERA_REAR2 | |
2909 | static DEVICE_ATTR(rear2_camfw, S_IRUGO, | |
2910 | camera_rear2_camfw_show, camera_rear_camfw_write); | |
2911 | static DEVICE_ATTR(rear2_camfw_full, S_IRUGO, | |
2912 | camera_rear2_camfw_full_show, NULL); | |
2913 | static DEVICE_ATTR(rear2_checkfw_user, S_IRUGO, | |
2914 | camera_rear2_checkfw_user_show, NULL); | |
2915 | static DEVICE_ATTR(rear2_checkfw_factory, S_IRUGO, | |
2916 | camera_rear2_checkfw_factory_show, NULL); | |
2917 | static DEVICE_ATTR(rear2_sensorid_exif, S_IRUGO, camera_rear2_sensorid_exif_show, NULL); | |
2918 | static DEVICE_ATTR(rear2_mtf_exif, S_IRUGO, camera_rear2_mtf_exif_show, NULL); | |
2919 | static DEVICE_ATTR(rear2_sensorid, S_IRUGO, camera_rear2_sensorid_show, NULL); | |
2920 | static DEVICE_ATTR(rear2_afcal, S_IRUGO, camera_rear2_afcal_show, NULL); | |
2921 | static DEVICE_ATTR(rear_dualcal, S_IRUGO, camera_rear_dualcal_show, NULL); | |
2922 | static DEVICE_ATTR(rear_dualcal_size, S_IRUGO, camera_rear_dualcal_size_show, NULL); | |
2923 | static DEVICE_ATTR(rear2_tilt, S_IRUGO, camera_rear2_tilt_show, NULL); | |
2924 | #endif | |
2925 | static DEVICE_ATTR(rear_sensor_standby, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH, | |
2926 | camera_rear_sensor_standby_show, camera_rear_sensor_standby); | |
2927 | #ifdef CAMERA_SYSFS_V2 | |
2928 | static DEVICE_ATTR(rear_caminfo, S_IRUGO, | |
2929 | camera_rear_info_show, NULL); | |
2930 | #ifdef CAMERA_REAR2 | |
2931 | static DEVICE_ATTR(rear2_caminfo, S_IRUGO, | |
2932 | camera_rear2_info_show, NULL); | |
2933 | #endif | |
2934 | #endif | |
2935 | #ifdef CONFIG_COMPANION_USE | |
2936 | static DEVICE_ATTR(isp_core, S_IRUGO, | |
2937 | camera_isp_core_show, NULL); | |
2938 | #endif | |
2939 | static DEVICE_ATTR(fw_update, S_IRUGO, | |
2940 | camera_hw_init_show, NULL); | |
2941 | #ifdef CONFIG_COMPANION_FACTORY_VALIDATION | |
2942 | static DEVICE_ATTR(companion_ic_check, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH, | |
2943 | camera_comp_ic_check_show, camera_comp_ic_check_store); | |
2944 | #endif | |
2945 | #if defined (CONFIG_OIS_USE) | |
2946 | static DEVICE_ATTR(selftest, S_IRUGO, | |
2947 | camera_ois_selftest_show, NULL); | |
2948 | static DEVICE_ATTR(ois_power, S_IWUSR, | |
2949 | NULL, camera_ois_power_store); | |
2950 | static DEVICE_ATTR(autotest, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH, | |
2951 | camera_ois_autotest_show, camera_ois_autotest_store); | |
2952 | #ifdef CAMERA_REAR2_OIS | |
2953 | static DEVICE_ATTR(autotest_2nd, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH, | |
2954 | camera_ois_autotest_2nd_show, camera_ois_autotest_2nd_store); | |
2955 | #endif | |
2956 | static DEVICE_ATTR(ois_rawdata, S_IRUGO, | |
2957 | camera_ois_rawdata_show, NULL); | |
2958 | static DEVICE_ATTR(oisfw, S_IRUGO, | |
2959 | camera_ois_version_show, NULL); | |
2960 | static DEVICE_ATTR(ois_diff, S_IRUGO, | |
2961 | camera_ois_diff_show, NULL); | |
2962 | static DEVICE_ATTR(ois_exif, S_IRUGO, | |
2963 | camera_ois_exif_show, NULL); | |
2964 | #endif | |
2965 | #ifdef FORCE_CAL_LOAD | |
2966 | static DEVICE_ATTR(rear_force_cal_load, S_IRUGO, camera_rear_force_cal_load_show, NULL); | |
2967 | #endif | |
2968 | static DEVICE_ATTR(rear_afcal, S_IRUGO, camera_rear_afcal_show, NULL); | |
2969 | static DEVICE_ATTR(rear_sensorid_exif, S_IRUGO, camera_rear_sensorid_exif_show, NULL); | |
2970 | static DEVICE_ATTR(rear_moduleid, S_IRUGO, camera_rear_moduleid_show, NULL); | |
2971 | static DEVICE_ATTR(rear_mtf_exif, S_IRUGO, camera_rear_mtf_exif_show, NULL); | |
2972 | static DEVICE_ATTR(rear_awb_master, S_IRUGO, camera_rear_awb_master_show, NULL); | |
2973 | static DEVICE_ATTR(rear_awb_module, S_IRUGO, camera_rear_awb_module_show, NULL); | |
2974 | static DEVICE_ATTR(SVC_rear_module, S_IRUGO, camera_rear_moduleid_show, NULL); | |
2975 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_FRONT) | |
2976 | static DEVICE_ATTR(front_afcal, S_IRUGO, camera_front_afcal_show, NULL); | |
2977 | static DEVICE_ATTR(front_moduleid, S_IRUGO, camera_front_moduleid_show, NULL); | |
2978 | static DEVICE_ATTR(front_mtf_exif, S_IRUGO, camera_front_mtf_exif_show, NULL); | |
2979 | static DEVICE_ATTR(front_sensorid_exif, S_IRUGO, camera_front_sensorid_exif_show, NULL); | |
2980 | static DEVICE_ATTR(SVC_front_module, S_IRUGO, camera_front_moduleid_show, NULL); | |
2981 | #endif | |
2982 | ||
2983 | static DEVICE_ATTR(rear_camfw_all, S_IRUGO, camera_rear_camfw_all_show, NULL); | |
2984 | ||
2985 | #ifdef CONFIG_SECURE_CAMERA_USE | |
2986 | static DEVICE_ATTR(iris_camfw, S_IRUGO, camera_iris_camfw_show, NULL); | |
2987 | static DEVICE_ATTR(iris_camfw_full, S_IRUGO, camera_iris_camfw_full_show, NULL); | |
2988 | static DEVICE_ATTR(iris_checkfw_factory, S_IRUGO, camera_iris_checkfw_factory_show, NULL); | |
2989 | static DEVICE_ATTR(iris_checkfw_user, S_IRUGO, camera_iris_checkfw_user_show, NULL); | |
2990 | #ifdef CAMERA_SYSFS_V2 | |
2991 | static DEVICE_ATTR(iris_caminfo, S_IRUGO, camera_iris_info_show, NULL); | |
2992 | #endif | |
2993 | #endif | |
2994 | ||
2995 | #ifdef USE_CAMERA_HW_BIG_DATA | |
2996 | static DEVICE_ATTR(rear_hwparam, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH, | |
2997 | rear_camera_hw_param_show, rear_camera_hw_param_store); | |
2998 | static DEVICE_ATTR(front_hwparam, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH, | |
2999 | front_camera_hw_param_show, front_camera_hw_param_store); | |
3000 | #ifdef CAMERA_REAR2 | |
3001 | static DEVICE_ATTR(rear2_hwparam, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH, | |
3002 | rear2_camera_hw_param_show, rear2_camera_hw_param_store); | |
3003 | #endif | |
3004 | #ifdef CONFIG_SECURE_CAMERA_USE | |
3005 | static DEVICE_ATTR(iris_hwparam, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH, | |
3006 | iris_camera_hw_param_show, iris_camera_hw_param_store); | |
3007 | #endif | |
3008 | #endif | |
3009 | ||
3010 | int svc_cheating_prevent_device_file_create(struct kobject **obj) | |
3011 | { | |
3012 | struct kernfs_node *svc_sd; | |
3013 | struct kobject *data; | |
3014 | struct kobject *Camera; | |
3015 | ||
3016 | /* To find svc kobject */ | |
3017 | svc_sd = sysfs_get_dirent(devices_kset->kobj.sd, "svc"); | |
3018 | if (IS_ERR_OR_NULL(svc_sd)) { | |
3019 | /* try to create svc kobject */ | |
3020 | data = kobject_create_and_add("svc", &devices_kset->kobj); | |
3021 | if (IS_ERR_OR_NULL(data)) | |
3022 | pr_info("Failed to create sys/devices/svc already exist svc : 0x%pK\n", data); | |
3023 | else | |
3024 | pr_info("Success to create sys/devices/svc svc : 0x%pK\n", data); | |
3025 | } else { | |
3026 | data = (struct kobject *)svc_sd->priv; | |
3027 | pr_info("Success to find svc_sd : 0x%pK svc : 0x%pK\n", svc_sd, data); | |
3028 | } | |
3029 | ||
3030 | Camera = kobject_create_and_add("Camera", data); | |
3031 | if (IS_ERR_OR_NULL(Camera)) | |
3032 | pr_info("Failed to create sys/devices/svc/Camera : 0x%pK\n", Camera); | |
3033 | else | |
3034 | pr_info("Success to create sys/devices/svc/Camera : 0x%pK\n", Camera); | |
3035 | ||
3036 | *obj = Camera; | |
3037 | ||
3038 | return 0; | |
3039 | } | |
3040 | ||
3041 | int fimc_is_create_sysfs(struct fimc_is_core *core) | |
3042 | { | |
3043 | struct kobject *svc = 0; | |
3044 | ||
3045 | if (!core) { | |
3046 | err("fimc_is_core is null"); | |
3047 | return -EINVAL; | |
3048 | } | |
3049 | ||
3050 | svc_cheating_prevent_device_file_create(&svc); | |
3051 | ||
3052 | if (camera_class == NULL) { | |
3053 | camera_class = class_create(THIS_MODULE, "camera"); | |
3054 | if (IS_ERR(camera_class)) { | |
3055 | pr_err("Failed to create class(camera)!\n"); | |
3056 | return PTR_ERR(camera_class); | |
3057 | } | |
3058 | } | |
3059 | ||
3060 | camera_front_dev = device_create(camera_class, NULL, 0, NULL, "front"); | |
3061 | if (IS_ERR(camera_front_dev)) { | |
3062 | printk(KERN_ERR "failed to create front device!\n"); | |
3063 | } else { | |
3064 | if (device_create_file(camera_front_dev, | |
3065 | &dev_attr_front_sensorid) < 0) { | |
3066 | printk(KERN_ERR "failed to create front device file, %s\n", | |
3067 | dev_attr_front_sensorid.attr.name); | |
3068 | } | |
3069 | ||
3070 | if (device_create_file(camera_front_dev, | |
3071 | &dev_attr_front_camtype) < 0) { | |
3072 | printk(KERN_ERR | |
3073 | "failed to create front device file, %s\n", | |
3074 | dev_attr_front_camtype.attr.name); | |
3075 | } | |
3076 | if (device_create_file(camera_front_dev, | |
3077 | &dev_attr_front_camfw) < 0) { | |
3078 | printk(KERN_ERR | |
3079 | "failed to create front device file, %s\n", | |
3080 | dev_attr_front_camfw.attr.name); | |
3081 | } | |
3082 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_FRONT) | |
3083 | if (device_create_file(camera_front_dev, | |
3084 | &dev_attr_front_camfw_full) < 0) { | |
3085 | printk(KERN_ERR | |
3086 | "failed to create front device file, %s\n", | |
3087 | dev_attr_front_camfw_full.attr.name); | |
3088 | } | |
3089 | if (device_create_file(camera_front_dev, | |
3090 | &dev_attr_front_checkfw_factory) < 0) { | |
3091 | printk(KERN_ERR | |
3092 | "failed to create front device file, %s\n", | |
3093 | dev_attr_front_checkfw_factory.attr.name); | |
3094 | } | |
3095 | if (device_create_file(camera_front_dev, | |
3096 | &dev_attr_front_sensorid_exif) < 0) { | |
3097 | printk(KERN_ERR | |
3098 | "failed to create front device file, %s\n", | |
3099 | dev_attr_front_sensorid_exif.attr.name); | |
3100 | } | |
3101 | if (device_create_file(camera_front_dev, &dev_attr_front_moduleid) < 0) { | |
3102 | printk(KERN_ERR "failed to create front device file, %s\n", | |
3103 | dev_attr_front_moduleid.attr.name); | |
3104 | } | |
3105 | if (device_create_file(camera_front_dev, &dev_attr_front_mtf_exif) < 0) { | |
3106 | printk(KERN_ERR "failed to create front device file, %s\n", | |
3107 | dev_attr_front_mtf_exif.attr.name); | |
3108 | } | |
3109 | if (device_create_file(camera_front_dev, &dev_attr_front_afcal) < 0) { | |
3110 | printk(KERN_ERR "failed to create front device file, %s\n", | |
3111 | dev_attr_front_afcal.attr.name); | |
3112 | } | |
3113 | if (sysfs_create_file(svc, &dev_attr_SVC_front_module.attr) < 0) { | |
3114 | printk(KERN_ERR "failed to create front device file, %s\n", | |
3115 | dev_attr_SVC_front_module.attr.name); | |
3116 | } | |
3117 | #endif | |
3118 | #ifdef USE_CAMERA_HW_BIG_DATA | |
3119 | if (device_create_file(camera_front_dev, | |
3120 | &dev_attr_front_hwparam) < 0) { | |
3121 | printk(KERN_ERR | |
3122 | "failed to create front device file, %s\n", | |
3123 | dev_attr_front_hwparam.attr.name); | |
3124 | } | |
3125 | #endif | |
3126 | } | |
3127 | #ifdef CAMERA_SYSFS_V2 | |
3128 | if (device_create_file(camera_front_dev, | |
3129 | &dev_attr_front_caminfo) < 0) { | |
3130 | printk(KERN_ERR | |
3131 | "failed to create front device file, %s\n", | |
3132 | dev_attr_front_caminfo.attr.name); | |
3133 | } | |
3134 | #endif | |
3135 | camera_rear_dev = device_create(camera_class, NULL, 1, NULL, "rear"); | |
3136 | if (IS_ERR(camera_rear_dev)) { | |
3137 | printk(KERN_ERR "failed to create rear device!\n"); | |
3138 | } else { | |
3139 | if (device_create_file(camera_rear_dev, &dev_attr_rear_sensorid) < 0) { | |
3140 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3141 | dev_attr_rear_sensorid.attr.name); | |
3142 | } | |
3143 | #ifdef CAMERA_REAR2 | |
3144 | if (device_create_file(camera_rear_dev, &dev_attr_rear2_sensorid) < 0) { | |
3145 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3146 | dev_attr_rear2_sensorid.attr.name); | |
3147 | } | |
3148 | #endif | |
3149 | #ifdef CAMERA_MODULE_DUALIZE | |
3150 | if (device_create_file(camera_rear_dev, &dev_attr_from_write) < 0) { | |
3151 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3152 | dev_attr_from_write.attr.name); | |
3153 | } | |
3154 | #endif | |
3155 | if (device_create_file(camera_rear_dev, &dev_attr_rear_camtype) < 0) { | |
3156 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3157 | dev_attr_rear_camtype.attr.name); | |
3158 | } | |
3159 | if (device_create_file(camera_rear_dev, &dev_attr_rear_camfw) < 0) { | |
3160 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3161 | dev_attr_rear_camfw.attr.name); | |
3162 | } | |
3163 | if (device_create_file(camera_rear_dev, &dev_attr_rear_camfw_full) < 0) { | |
3164 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3165 | dev_attr_rear_camfw_full.attr.name); | |
3166 | } | |
3167 | if (device_create_file(camera_rear_dev, &dev_attr_rear_checkfw_user) < 0) { | |
3168 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3169 | dev_attr_rear_checkfw_user.attr.name); | |
3170 | } | |
3171 | if (device_create_file(camera_rear_dev, &dev_attr_rear_checkfw_factory) < 0) { | |
3172 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3173 | dev_attr_rear_checkfw_factory.attr.name); | |
3174 | } | |
3175 | #ifdef CAMERA_REAR2 | |
3176 | if (device_create_file(camera_rear_dev, &dev_attr_rear2_camfw) < 0) { | |
3177 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3178 | dev_attr_rear2_camfw.attr.name); | |
3179 | } | |
3180 | if (device_create_file(camera_rear_dev, &dev_attr_rear2_camfw_full) < 0) { | |
3181 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3182 | dev_attr_rear2_camfw_full.attr.name); | |
3183 | } | |
3184 | if (device_create_file(camera_rear_dev, &dev_attr_rear2_checkfw_user) < 0) { | |
3185 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3186 | dev_attr_rear2_checkfw_user.attr.name); | |
3187 | } | |
3188 | if (device_create_file(camera_rear_dev, &dev_attr_rear2_checkfw_factory) < 0) { | |
3189 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3190 | dev_attr_rear2_checkfw_factory.attr.name); | |
3191 | } | |
3192 | if (device_create_file(camera_rear_dev, &dev_attr_rear2_sensorid_exif) < 0) { | |
3193 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3194 | dev_attr_rear2_sensorid_exif.attr.name); | |
3195 | } | |
3196 | if (device_create_file(camera_rear_dev, &dev_attr_rear2_mtf_exif) < 0) { | |
3197 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3198 | dev_attr_rear2_mtf_exif.attr.name); | |
3199 | } | |
3200 | if (device_create_file(camera_rear_dev, &dev_attr_rear_dualcal) < 0) { | |
3201 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3202 | dev_attr_rear_dualcal.attr.name); | |
3203 | } | |
3204 | if (device_create_file(camera_rear_dev, &dev_attr_rear_dualcal_size) < 0) { | |
3205 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3206 | dev_attr_rear_dualcal_size.attr.name); | |
3207 | } | |
3208 | if (device_create_file(camera_rear_dev, &dev_attr_rear2_afcal) < 0) { | |
3209 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3210 | dev_attr_rear2_afcal.attr.name); | |
3211 | } | |
3212 | if (device_create_file(camera_rear_dev, &dev_attr_rear2_tilt) < 0) { | |
3213 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3214 | dev_attr_rear2_tilt.attr.name); | |
3215 | } | |
3216 | #ifdef USE_CAMERA_HW_BIG_DATA | |
3217 | if (device_create_file(camera_rear_dev, &dev_attr_rear2_hwparam) < 0) { | |
3218 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3219 | dev_attr_rear2_hwparam.attr.name); | |
3220 | } | |
3221 | #endif | |
3222 | #endif | |
3223 | if (device_create_file(camera_rear_dev, | |
3224 | &dev_attr_ssrm_camera_info) < 0) { | |
3225 | printk(KERN_ERR | |
3226 | "failed to create front device file, %s\n", | |
3227 | dev_attr_ssrm_camera_info.attr.name); | |
3228 | } | |
3229 | ||
3230 | if (device_create_file(camera_rear_dev, &dev_attr_rear_sensor_standby) < 0) { | |
3231 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3232 | dev_attr_rear_sensor_standby.attr.name); | |
3233 | } | |
3234 | #ifdef CAMERA_SYSFS_V2 | |
3235 | if (device_create_file(camera_rear_dev, | |
3236 | &dev_attr_rear_caminfo) < 0) { | |
3237 | printk(KERN_ERR | |
3238 | "failed to create rear device file, %s\n", | |
3239 | dev_attr_rear_caminfo.attr.name); | |
3240 | } | |
3241 | #ifdef CAMERA_REAR2 | |
3242 | if (device_create_file(camera_rear_dev, | |
3243 | &dev_attr_rear2_caminfo) < 0) { | |
3244 | printk(KERN_ERR | |
3245 | "failed to create rear device file, %s\n", | |
3246 | dev_attr_rear_caminfo.attr.name); | |
3247 | } | |
3248 | #endif | |
3249 | #endif | |
3250 | #ifdef USE_CAMERA_HW_BIG_DATA | |
3251 | if (device_create_file(camera_rear_dev, | |
3252 | &dev_attr_rear_hwparam) < 0) { | |
3253 | printk(KERN_ERR | |
3254 | "failed to create rear device file, %s\n", | |
3255 | dev_attr_rear_hwparam.attr.name); | |
3256 | } | |
3257 | #endif | |
3258 | #ifdef CONFIG_COMPANION_USE | |
3259 | if (device_create_file(camera_rear_dev, &dev_attr_rear_companionfw) < 0) { | |
3260 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3261 | dev_attr_rear_companionfw.attr.name); | |
3262 | } | |
3263 | if (device_create_file(camera_rear_dev, &dev_attr_rear_companionfw_full) < 0) { | |
3264 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3265 | dev_attr_rear_companionfw_full.attr.name); | |
3266 | } | |
3267 | #endif | |
3268 | if (device_create_file(camera_rear_dev, &dev_attr_rear_calcheck) < 0) { | |
3269 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3270 | dev_attr_rear_calcheck.attr.name); | |
3271 | } | |
3272 | #ifdef CONFIG_COMPANION_USE | |
3273 | if (device_create_file(camera_rear_dev, &dev_attr_isp_core) < 0) { | |
3274 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3275 | dev_attr_isp_core.attr.name); | |
3276 | } | |
3277 | #endif | |
3278 | if (device_create_file(camera_rear_dev, &dev_attr_fw_update) < 0) { | |
3279 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3280 | dev_attr_fw_update.attr.name); | |
3281 | } | |
3282 | #ifdef FORCE_CAL_LOAD | |
3283 | if (device_create_file(camera_rear_dev, &dev_attr_rear_force_cal_load) < 0) { | |
3284 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3285 | dev_attr_rear_force_cal_load.attr.name); | |
3286 | } | |
3287 | #endif | |
3288 | if (device_create_file(camera_rear_dev, &dev_attr_rear_afcal) < 0) { | |
3289 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3290 | dev_attr_rear_afcal.attr.name); | |
3291 | } | |
3292 | if (device_create_file(camera_rear_dev, &dev_attr_rear_sensorid_exif) < 0) { | |
3293 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3294 | dev_attr_rear_sensorid_exif.attr.name); | |
3295 | } | |
3296 | if (device_create_file(camera_rear_dev, &dev_attr_rear_moduleid) < 0) { | |
3297 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3298 | dev_attr_rear_moduleid.attr.name); | |
3299 | } | |
3300 | if (device_create_file(camera_rear_dev, &dev_attr_rear_mtf_exif) < 0) { | |
3301 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3302 | dev_attr_rear_mtf_exif.attr.name); | |
3303 | } | |
3304 | if (device_create_file(camera_rear_dev, &dev_attr_rear_awb_master) < 0) { | |
3305 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3306 | dev_attr_rear_awb_master.attr.name); | |
3307 | } | |
3308 | if (device_create_file(camera_rear_dev, &dev_attr_rear_awb_module) < 0) { | |
3309 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3310 | dev_attr_rear_awb_module.attr.name); | |
3311 | } | |
3312 | if (sysfs_create_file(svc, &dev_attr_SVC_rear_module.attr) < 0) { | |
3313 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3314 | dev_attr_SVC_rear_module.attr.name); | |
3315 | } | |
3316 | #ifdef CONFIG_COMPANION_FACTORY_VALIDATION | |
3317 | if (device_create_file(camera_rear_dev, &dev_attr_companion_ic_check) < 0) { | |
3318 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3319 | dev_attr_companion_ic_check.attr.name); | |
3320 | } | |
3321 | #endif | |
3322 | if (device_create_file(camera_rear_dev, &dev_attr_rear_camfw_all) < 0) { | |
3323 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3324 | dev_attr_rear_camfw_all.attr.name); | |
3325 | } | |
3326 | if (device_create_file(camera_rear_dev, &dev_attr_rear_paf_offset_far) < 0) { | |
3327 | printk(KERN_ERR "failed to create rear device file, %s\n", | |
3328 | dev_attr_rear_paf_offset_far.attr.name); | |
3329 | } | |
3330 | } | |
3331 | ||
3332 | #if defined (CONFIG_OIS_USE) | |
3333 | camera_ois_dev = device_create(camera_class, NULL, 2, NULL, "ois"); | |
3334 | if (IS_ERR(camera_ois_dev)) { | |
3335 | printk(KERN_ERR "failed to create ois device!\n"); | |
3336 | } else { | |
3337 | if (device_create_file(camera_ois_dev, &dev_attr_selftest) < 0) { | |
3338 | printk(KERN_ERR "failed to create ois device file, %s\n", | |
3339 | dev_attr_selftest.attr.name); | |
3340 | } | |
3341 | if (device_create_file(camera_ois_dev, &dev_attr_ois_power) < 0) { | |
3342 | printk(KERN_ERR "failed to create ois device file, %s\n", | |
3343 | dev_attr_ois_power.attr.name); | |
3344 | } | |
3345 | if (device_create_file(camera_ois_dev, &dev_attr_autotest) < 0) { | |
3346 | printk(KERN_ERR "failed to create ois device file, %s\n", | |
3347 | dev_attr_autotest.attr.name); | |
3348 | } | |
3349 | #ifdef CAMERA_REAR2_OIS | |
3350 | if (device_create_file(camera_ois_dev, &dev_attr_autotest_2nd) < 0) { | |
3351 | printk(KERN_ERR "failed to create ois device file, %s\n", | |
3352 | dev_attr_autotest_2nd.attr.name); | |
3353 | } | |
3354 | #endif | |
3355 | if (device_create_file(camera_ois_dev, &dev_attr_ois_rawdata) < 0) { | |
3356 | printk(KERN_ERR "failed to create ois device file, %s\n", | |
3357 | dev_attr_ois_rawdata.attr.name); | |
3358 | } | |
3359 | if (device_create_file(camera_ois_dev, &dev_attr_oisfw) < 0) { | |
3360 | printk(KERN_ERR "failed to create ois device file, %s\n", | |
3361 | dev_attr_oisfw.attr.name); | |
3362 | } | |
3363 | if (device_create_file(camera_ois_dev, &dev_attr_ois_diff) < 0) { | |
3364 | printk(KERN_ERR "failed to create ois device file, %s\n", | |
3365 | dev_attr_ois_diff.attr.name); | |
3366 | } | |
3367 | if (device_create_file(camera_ois_dev, &dev_attr_ois_exif) < 0) { | |
3368 | printk(KERN_ERR "failed to create ois device file, %s\n", | |
3369 | dev_attr_ois_exif.attr.name); | |
3370 | } | |
3371 | } | |
3372 | #endif | |
3373 | #ifdef CONFIG_SECURE_CAMERA_USE | |
3374 | camera_secure_dev = device_create(camera_class, NULL, 3, NULL, "secure"); | |
3375 | if (IS_ERR(camera_secure_dev)) { | |
3376 | printk(KERN_ERR "failed to create secure device!\n"); | |
3377 | } else { | |
3378 | if (device_create_file(camera_secure_dev, &dev_attr_secure_sensorid) < 0) { | |
3379 | printk(KERN_ERR "failed to create secure device file, %s\n", | |
3380 | dev_attr_secure_sensorid.attr.name); | |
3381 | } | |
3382 | if (device_create_file(camera_secure_dev, &dev_attr_iris_camfw) < 0) { | |
3383 | printk(KERN_ERR "failed to create iris device file, %s\n", | |
3384 | dev_attr_iris_camfw.attr.name); | |
3385 | } | |
3386 | if (device_create_file(camera_secure_dev, &dev_attr_iris_camfw_full) < 0) { | |
3387 | printk(KERN_ERR "failed to create iris device file, %s\n", | |
3388 | dev_attr_iris_camfw_full.attr.name); | |
3389 | } | |
3390 | if (device_create_file(camera_secure_dev, &dev_attr_iris_checkfw_user) < 0) { | |
3391 | printk(KERN_ERR "failed to create iris device file, %s\n", | |
3392 | dev_attr_iris_checkfw_user.attr.name); | |
3393 | } | |
3394 | if (device_create_file(camera_secure_dev, &dev_attr_iris_checkfw_factory) < 0) { | |
3395 | printk(KERN_ERR "failed to create iris device file, %s\n", | |
3396 | dev_attr_iris_checkfw_factory.attr.name); | |
3397 | } | |
3398 | #ifdef CAMERA_SYSFS_V2 | |
3399 | if (device_create_file(camera_secure_dev, | |
3400 | &dev_attr_iris_caminfo) < 0) { | |
3401 | printk(KERN_ERR | |
3402 | "failed to create iris device file, %s\n", | |
3403 | dev_attr_iris_caminfo.attr.name); | |
3404 | } | |
3405 | #endif | |
3406 | #ifdef USE_CAMERA_HW_BIG_DATA | |
3407 | if (device_create_file(camera_secure_dev, | |
3408 | &dev_attr_iris_hwparam) < 0) { | |
3409 | printk(KERN_ERR | |
3410 | "failed to create iris device file, %s\n", | |
3411 | dev_attr_iris_hwparam.attr.name); | |
3412 | } | |
3413 | #endif | |
3414 | } | |
3415 | #endif | |
3416 | ||
3417 | sysfs_core = core; | |
3418 | ||
3419 | return 0; | |
3420 | } | |
3421 | ||
3422 | int fimc_is_destroy_sysfs(struct fimc_is_core *core) | |
3423 | { | |
3424 | if (camera_front_dev) { | |
3425 | device_remove_file(camera_front_dev, &dev_attr_front_sensorid); | |
3426 | device_remove_file(camera_front_dev, &dev_attr_front_camtype); | |
3427 | device_remove_file(camera_front_dev, &dev_attr_front_camfw); | |
3428 | #if defined(CONFIG_CAMERA_EEPROM_SUPPORT_FRONT) | |
3429 | device_remove_file(camera_front_dev, &dev_attr_front_afcal); | |
3430 | device_remove_file(camera_front_dev, &dev_attr_front_camfw_full); | |
3431 | device_remove_file(camera_front_dev, &dev_attr_front_checkfw_factory); | |
3432 | device_remove_file(camera_front_dev, &dev_attr_front_moduleid); | |
3433 | device_remove_file(camera_front_dev, &dev_attr_front_mtf_exif); | |
3434 | device_remove_file(camera_front_dev, &dev_attr_front_sensorid_exif); | |
3435 | #endif | |
3436 | #ifdef CAMERA_SYSFS_V2 | |
3437 | device_remove_file(camera_front_dev, &dev_attr_front_caminfo); | |
3438 | #endif | |
3439 | #ifdef USE_CAMERA_HW_BIG_DATA | |
3440 | device_remove_file(camera_front_dev, &dev_attr_front_hwparam); | |
3441 | #endif | |
3442 | } | |
3443 | ||
3444 | if (camera_rear_dev) { | |
3445 | device_remove_file(camera_rear_dev, &dev_attr_rear_sensorid); | |
3446 | ||
3447 | #ifdef CAMERA_MODULE_DUALIZE | |
3448 | device_remove_file(camera_rear_dev, &dev_attr_from_write); | |
3449 | #endif | |
3450 | device_remove_file(camera_rear_dev, &dev_attr_rear_camtype); | |
3451 | device_remove_file(camera_rear_dev, &dev_attr_rear_camfw); | |
3452 | device_remove_file(camera_rear_dev, &dev_attr_rear_camfw_full); | |
3453 | device_remove_file(camera_rear_dev, &dev_attr_rear_checkfw_user); | |
3454 | device_remove_file(camera_rear_dev, &dev_attr_rear_checkfw_factory); | |
3455 | #ifdef CAMERA_REAR2 | |
3456 | device_remove_file(camera_rear_dev, &dev_attr_rear2_sensorid); | |
3457 | device_remove_file(camera_rear_dev, &dev_attr_rear2_camfw); | |
3458 | device_remove_file(camera_rear_dev, &dev_attr_rear2_camfw_full); | |
3459 | device_remove_file(camera_rear_dev, &dev_attr_rear2_checkfw_user); | |
3460 | device_remove_file(camera_rear_dev, &dev_attr_rear2_checkfw_factory); | |
3461 | device_remove_file(camera_rear_dev, &dev_attr_rear2_sensorid_exif); | |
3462 | device_remove_file(camera_rear_dev, &dev_attr_rear2_mtf_exif); | |
3463 | device_remove_file(camera_rear_dev, &dev_attr_rear2_afcal); | |
3464 | device_remove_file(camera_rear_dev, &dev_attr_rear_dualcal); | |
3465 | device_remove_file(camera_rear_dev, &dev_attr_rear_dualcal_size); | |
3466 | device_remove_file(camera_rear_dev, &dev_attr_rear2_tilt); | |
3467 | #ifdef USE_CAMERA_HW_BIG_DATA | |
3468 | device_remove_file(camera_rear_dev, &dev_attr_rear2_hwparam); | |
3469 | #endif | |
3470 | #endif | |
3471 | device_remove_file(camera_rear_dev, &dev_attr_rear_sensor_standby); | |
3472 | #ifdef CONFIG_COMPANION_USE | |
3473 | device_remove_file(camera_rear_dev, &dev_attr_rear_companionfw); | |
3474 | device_remove_file(camera_rear_dev, &dev_attr_rear_companionfw_full); | |
3475 | #endif | |
3476 | device_remove_file(camera_rear_dev, &dev_attr_rear_calcheck); | |
3477 | #ifdef CAMERA_SYSFS_V2 | |
3478 | device_remove_file(camera_rear_dev, &dev_attr_rear_caminfo); | |
3479 | #ifdef CAMERA_REAR2 | |
3480 | device_remove_file(camera_rear_dev, &dev_attr_rear2_caminfo); | |
3481 | #endif | |
3482 | #endif | |
3483 | #ifdef CONFIG_COMPANION_USE | |
3484 | device_remove_file(camera_rear_dev, &dev_attr_isp_core); | |
3485 | #endif | |
3486 | #ifdef FORCE_CAL_LOAD | |
3487 | device_remove_file(camera_rear_dev, &dev_attr_rear_force_cal_load); | |
3488 | #endif | |
3489 | device_remove_file(camera_rear_dev, &dev_attr_rear_afcal); | |
3490 | device_remove_file(camera_rear_dev, &dev_attr_rear_sensorid_exif); | |
3491 | device_remove_file(camera_rear_dev, &dev_attr_rear_moduleid); | |
3492 | device_remove_file(camera_rear_dev, &dev_attr_rear_mtf_exif); | |
3493 | device_remove_file(camera_rear_dev, &dev_attr_rear_awb_master); | |
3494 | device_remove_file(camera_rear_dev, &dev_attr_rear_awb_module); | |
3495 | device_remove_file(camera_rear_dev, &dev_attr_fw_update); | |
3496 | #ifdef CONFIG_COMPANION_FACTORY_VALIDATION | |
3497 | device_remove_file(camera_rear_dev, &dev_attr_companion_ic_check); | |
3498 | #endif | |
3499 | device_remove_file(camera_rear_dev, &dev_attr_ssrm_camera_info); | |
3500 | #ifdef USE_CAMERA_HW_BIG_DATA | |
3501 | device_remove_file(camera_rear_dev, &dev_attr_rear_hwparam); | |
3502 | #endif | |
3503 | device_remove_file(camera_rear_dev, &dev_attr_rear_camfw_all); | |
3504 | device_remove_file(camera_rear_dev, &dev_attr_rear_paf_offset_far); | |
3505 | } | |
3506 | ||
3507 | #if defined (CONFIG_OIS_USE) | |
3508 | if (camera_ois_dev) { | |
3509 | device_remove_file(camera_ois_dev, &dev_attr_selftest); | |
3510 | device_remove_file(camera_ois_dev, &dev_attr_ois_power); | |
3511 | device_remove_file(camera_ois_dev, &dev_attr_autotest); | |
3512 | #ifdef CAMERA_REAR2_OIS | |
3513 | device_remove_file(camera_ois_dev, &dev_attr_autotest_2nd); | |
3514 | #endif | |
3515 | device_remove_file(camera_ois_dev, &dev_attr_ois_rawdata); | |
3516 | device_remove_file(camera_ois_dev, &dev_attr_oisfw); | |
3517 | device_remove_file(camera_ois_dev, &dev_attr_ois_diff); | |
3518 | device_remove_file(camera_ois_dev, &dev_attr_ois_exif); | |
3519 | } | |
3520 | #endif | |
3521 | #ifdef CONFIG_SECURE_CAMERA_USE | |
3522 | if (camera_secure_dev) { | |
3523 | device_remove_file(camera_secure_dev, &dev_attr_secure_sensorid); | |
3524 | device_remove_file(camera_secure_dev, &dev_attr_iris_camfw); | |
3525 | device_remove_file(camera_secure_dev, &dev_attr_iris_camfw_full); | |
3526 | device_remove_file(camera_secure_dev, &dev_attr_iris_checkfw_user); | |
3527 | device_remove_file(camera_secure_dev, &dev_attr_iris_checkfw_factory); | |
3528 | #ifdef CAMERA_SYSFS_V2 | |
3529 | device_remove_file(camera_secure_dev, &dev_attr_iris_caminfo); | |
3530 | #endif | |
3531 | #ifdef USE_CAMERA_HW_BIG_DATA | |
3532 | device_remove_file(camera_secure_dev, &dev_attr_iris_hwparam); | |
3533 | #endif | |
3534 | } | |
3535 | #endif | |
3536 | ||
3537 | if (camera_class) { | |
3538 | if (camera_front_dev) | |
3539 | device_destroy(camera_class, camera_front_dev->devt); | |
3540 | ||
3541 | if (camera_rear_dev) | |
3542 | device_destroy(camera_class, camera_rear_dev->devt); | |
3543 | ||
3544 | #if defined (CONFIG_OIS_USE) | |
3545 | if (camera_ois_dev) | |
3546 | device_destroy(camera_class, camera_ois_dev->devt); | |
3547 | #endif | |
3548 | #ifdef CONFIG_SECURE_CAMERA_USE | |
3549 | if (camera_secure_dev) | |
3550 | device_destroy(camera_class, camera_secure_dev->devt); | |
3551 | #endif | |
3552 | } | |
3553 | ||
3554 | class_destroy(camera_class); | |
3555 | ||
3556 | return 0; | |
3557 | } |