1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
|
/*
* Samsung Exynos SoC series FIMC-IS2 driver
*
* exynos fimc-is2 device interface functions
*
* Copyright (c) 2015 Samsung Electronics Co., Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include "is-interface-wrap.h"
#include "is-interface-library.h"
#include "is-param.h"
int is_itf_s_param_wrap(struct is_device_ischain *device,
u32 lindex, u32 hindex, u32 indexes)
{
struct is_hardware *hardware = NULL;
u32 instance = 0;
int ret = 0;
dbg_hw(2, "%s\n", __func__);
hardware = device->hardware;
instance = device->instance;
ret = is_hardware_set_param(hardware, instance, device->is_region,
lindex, hindex, hardware->hw_map[instance]);
if (ret) {
merr("is_hardware_set_param is fail(%d)", device, ret);
return ret;
}
return ret;
}
int is_itf_a_param_wrap(struct is_device_ischain *device, u32 group)
{
struct is_hardware *hardware = NULL;
u32 instance = 0;
int ret = 0;
dbg_hw(2, "%s\n", __func__);
hardware = device->hardware;
instance = device->instance;
#if !defined(DISABLE_SETFILE)
ret = is_hardware_apply_setfile(hardware, instance,
device->setfile & IS_SETFILE_MASK,
hardware->hw_map[instance]);
if (ret) {
merr("is_hardware_apply_setfile is fail(%d)", device, ret);
return ret;
}
#endif
return ret;
}
int is_itf_f_param_wrap(struct is_device_ischain *device, u32 group)
{
struct is_hardware *hardware= NULL;
u32 instance = 0;
int ret = 0;
dbg_hw(2, "%s\n", __func__);
hardware = device->hardware;
instance = device->instance;
return ret;
}
int is_itf_enum_wrap(struct is_device_ischain *device)
{
int ret = 0;
dbg_hw(2, "%s\n", __func__);
return ret;
}
void is_itf_storefirm_wrap(struct is_device_ischain *device)
{
dbg_hw(2, "%s\n", __func__);
return;
}
void is_itf_restorefirm_wrap(struct is_device_ischain *device)
{
dbg_hw(2, "%s\n", __func__);
return;
}
int is_itf_set_fwboot_wrap(struct is_device_ischain *device, u32 val)
{
int ret = 0;
dbg_hw(2, "%s\n", __func__);
return ret;
}
int is_itf_open_wrap(struct is_device_ischain *device, u32 module_id,
u32 flag, u32 offset_path)
{
struct is_hardware *hardware;
struct is_path_info *path;
struct is_group *group;
struct is_region *region;
struct is_device_sensor *sensor;
u32 instance = 0;
u32 hw_id = 0;
u32 group_id = -1;
u32 group_slot, group_slot_c;
int ret = 0, ret_c = 0;
int hw_list[GROUP_HW_MAX];
int hw_index;
int hw_maxnum = 0;
u32 rsccount;
info_hw("%s: offset_path(0x%8x) flag(%d) sen(%d)\n", __func__, offset_path, flag, module_id);
sensor = device->sensor;
instance = device->instance;
hardware = device->hardware;
/*
* CAUTION: The path has physical group id.
* And physical group is must be used at open commnad.
*/
path = (struct is_path_info *)&device->is_region->shared[offset_path];
rsccount = atomic_read(&hardware->rsccount);
if (rsccount == 0) {
ret = is_init_ddk_thread();
if (ret) {
err("failed to create threads for DDK, ret %d", ret);
return ret;
}
atomic_set(&hardware->lic_updated, 0);
}
region = device->is_region;
region->shared[MAX_SHARED_COUNT-1] = MAGIC_NUMBER;
for (hw_id = 0; hw_id < DEV_HW_END; hw_id++)
clear_bit(hw_id, &hardware->hw_map[instance]);
for (group_slot = GROUP_SLOT_PAF; group_slot < GROUP_SLOT_MAX; group_slot++) {
switch (group_slot) {
case GROUP_SLOT_PAF:
group = &device->group_paf;
break;
case GROUP_SLOT_3AA:
group = &device->group_3aa;
break;
case GROUP_SLOT_ISP:
group = &device->group_isp;
break;
case GROUP_SLOT_MCS:
group = &device->group_mcs;
break;
case GROUP_SLOT_VRA:
group = &device->group_vra;
break;
case GROUP_SLOT_CLH:
group = &device->group_clh;
break;
default:
continue;
break;
}
group_id = path->group[group_slot];
dbg_hw(1, "itf_open_wrap: group[SLOT_%d]=[%s]\n",
group_slot, group_id_name[group_id]);
hw_maxnum = is_get_hw_list(group_id, hw_list);
for (hw_index = 0; hw_index < hw_maxnum; hw_index++) {
hw_id = hw_list[hw_index];
ret = is_hardware_open(hardware, hw_id, group, instance,
flag, module_id);
if (ret) {
merr("is_hardware_open(%d) is fail", device, hw_id);
goto hardware_close;
}
}
}
hardware->sensor_position[instance] = sensor->position;
atomic_inc(&hardware->rsccount);
info("%s: done: hw_map[0x%lx][RSC:%d][%d]\n", __func__,
hardware->hw_map[instance], atomic_read(&hardware->rsccount),
hardware->sensor_position[instance]);
return ret;
hardware_close:
group_slot_c = group_slot;
for (group_slot = GROUP_SLOT_PAF; group_slot <= group_slot_c; group_slot++) {
group_id = path->group[group_slot];
hw_maxnum = is_get_hw_list(group_id, hw_list);
for (hw_index = 0; hw_index < hw_maxnum; hw_index++) {
hw_id = hw_list[hw_index];
info_hw("[%d][ID:%d]itf_close_wrap: call hardware_close(), (%s), ret(%d)\n",
instance, hw_id, group_id_name[group_id], ret);
ret_c = is_hardware_close(hardware, hw_id, instance);
if (ret_c)
merr("is_hardware_close(%d) is fail", device, hw_id);
}
}
return ret;
}
int is_itf_close_wrap(struct is_device_ischain *device)
{
struct is_hardware *hardware;
struct is_path_info *path;
u32 offset_path = 0;
u32 instance = 0;
u32 hw_id = 0;
u32 group_id = -1;
u32 group_slot;
int ret = 0;
int hw_list[GROUP_HW_MAX];
int hw_index;
int hw_maxnum = 0;
u32 rsccount;
dbg_hw(2, "%s\n", __func__);
hardware = device->hardware;
instance = device->instance;
/*
* CAUTION: The path has physical group id.
* And physical group is must be used at close commnad.
*/
offset_path = (sizeof(struct sensor_open_extended) / 4) + 1;
path = (struct is_path_info *)&device->is_region->shared[offset_path];
rsccount = atomic_read(&hardware->rsccount);
if (rsccount == 1)
is_flush_ddk_thread();
#if !defined(DISABLE_SETFILE)
ret = is_hardware_delete_setfile(hardware, instance,
hardware->logical_hw_map[instance]);
if (ret) {
merr("is_hardware_delete_setfile is fail(%d)", device, ret);
return ret;
}
#endif
for (group_slot = GROUP_SLOT_PAF; group_slot < GROUP_SLOT_MAX; group_slot++) {
group_id = path->group[group_slot];
dbg_hw(1, "itf_close_wrap: group[SLOT_%d]=[%s]\n",
group_slot, group_id_name[group_id]);
hw_maxnum = is_get_hw_list(group_id, hw_list);
for (hw_index = 0; hw_index < hw_maxnum; hw_index++) {
hw_id = hw_list[hw_index];
ret = is_hardware_close(hardware, hw_id, instance);
if (ret)
merr("is_hardware_close(%d) is fail", device, hw_id);
}
}
atomic_dec(&hardware->rsccount);
info("%s: done: hw_map[0x%lx][RSC:%d]\n", __func__,
hardware->hw_map[instance], atomic_read(&hardware->rsccount));
return ret;
}
int is_itf_change_chain_wrap(struct is_device_ischain *device, struct is_group *group, u32 next_id)
{
int ret = 0;
struct is_hardware *hardware;
FIMC_BUG(!device);
hardware = device->hardware;
ret = is_hardware_change_chain(hardware, group, group->instance, next_id);
mginfo("%s: %s (next_id: %d)\n", group, group, __func__,
ret ? "fail" : "success", next_id);
return ret;
}
int is_itf_setaddr_wrap(struct is_interface *itf,
struct is_device_ischain *device, ulong *setfile_addr)
{
int ret = 0;
dbg_hw(2, "%s\n", __func__);
*setfile_addr = device->resourcemgr->minfo.kvaddr_setfile;
return ret;
}
int is_itf_setfile_wrap(struct is_interface *itf, ulong setfile_addr,
struct is_device_ischain *device)
{
struct is_hardware *hardware;
u32 instance = 0;
int ret = 0;
dbg_hw(2, "%s\n", __func__);
hardware = device->hardware;
instance = device->instance;
#if !defined(DISABLE_SETFILE)
ret = is_hardware_load_setfile(hardware, setfile_addr, instance,
hardware->logical_hw_map[instance]);
if (ret) {
merr("is_hardware_load_setfile is fail(%d)", device, ret);
return ret;
}
#endif
return ret;
}
int is_itf_map_wrap(struct is_device_ischain *device,
u32 group, u32 shot_addr, u32 shot_size)
{
int ret = 0;
dbg_hw(2, "%s\n", __func__);
return ret;
}
int is_itf_unmap_wrap(struct is_device_ischain *device, u32 group)
{
int ret = 0;
dbg_hw(2, "%s\n", __func__);
return ret;
}
int is_itf_stream_on_wrap(struct is_device_ischain *device)
{
struct is_hardware *hardware;
u32 instance;
ulong hw_map;
int ret = 0;
struct is_group *group_leader;
dbg_hw(2, "%s\n", __func__);
hardware = device->hardware;
instance = device->instance;
hw_map = hardware->hw_map[instance];
group_leader = get_ischain_leader_group(device);
ret = is_hardware_sensor_start(hardware, instance, hw_map, group_leader);
if (ret) {
merr("is_hardware_stream_on is fail(%d)", device, ret);
return ret;
}
return ret;
}
int is_itf_stream_off_wrap(struct is_device_ischain *device)
{
struct is_hardware *hardware;
u32 instance;
ulong hw_map;
int ret = 0;
struct is_group *group_leader;
dbg_hw(2, "%s\n", __func__);
hardware = device->hardware;
instance = device->instance;
hw_map = hardware->hw_map[instance];
group_leader = get_ischain_leader_group(device);
ret = is_hardware_sensor_stop(hardware, instance, hw_map, group_leader);
if (ret) {
merr("is_hardware_stream_off is fail(%d)", device, ret);
return ret;
}
return ret;
}
int is_itf_process_on_wrap(struct is_device_ischain *device, u32 group)
{
struct is_hardware *hardware;
u32 instance = 0;
u32 group_id;
int ret = 0;
hardware = device->hardware;
instance = device->instance;
minfo_hw("itf_process_on_wrap: [G:0x%x]\n", instance, group);
for (group_id = GROUP_ID_3AA0; group_id < GROUP_ID_MAX; group_id++) {
if (((group) & GROUP_ID(group_id)) &&
(GET_DEVICE_TYPE_BY_GRP(group_id) == IS_DEVICE_ISCHAIN)) {
ret = is_hardware_process_start(hardware, instance, group_id);
if (ret) {
merr("is_hardware_process_start is fail(%d)", device, ret);
return ret;
}
}
}
return ret;
}
int is_itf_process_off_wrap(struct is_device_ischain *device, u32 group,
u32 fstop)
{
struct is_hardware *hardware;
u32 instance = 0;
u32 group_id;
int ret = 0;
hardware = device->hardware;
instance = device->instance;
minfo_hw("itf_process_off_wrap: [G:0x%x](%d)\n", instance, group, fstop);
for (group_id = 0; group_id < GROUP_ID_MAX; group_id++) {
if ((group) & GROUP_ID(group_id)) {
if (GET_DEVICE_TYPE_BY_GRP(group_id) == IS_DEVICE_ISCHAIN) {
is_hardware_process_stop(hardware, instance, group_id, fstop);
} else {
/* in case of sensor group */
if (!test_bit(IS_ISCHAIN_REPROCESSING, &device->state))
is_sensor_group_force_stop(device->sensor, group_id);
}
}
}
return ret;
}
void is_itf_sudden_stop_wrap(struct is_device_ischain *device, u32 instance, struct is_group *group)
{
int ret = 0;
struct is_device_sensor *sensor;
if (!device) {
mwarn_hw("%s: device(null)\n", instance, __func__);
return;
}
sensor = device->sensor;
if (!sensor) {
mwarn_hw("%s: sensor(null)\n", instance, __func__);
return;
}
if (test_bit(IS_SENSOR_FRONT_START, &sensor->state)) {
minfo_hw("%s: sudden close, call sensor_front_stop()\n", instance, __func__);
ret = is_sensor_front_stop(sensor);
if (ret)
merr("is_sensor_front_stop is fail(%d)", sensor, ret);
}
if (group) {
if (test_bit(IS_GROUP_FORCE_STOP, &group->state)) {
ret = is_itf_force_stop(device, GROUP_ID(group->id));
if (ret)
mgerr(" is_itf_force_stop is fail(%d)", device, group, ret);
} else {
ret = is_itf_process_stop(device, GROUP_ID(group->id));
if (ret)
mgerr(" is_itf_process_stop is fail(%d)", device, group, ret);
}
}
return;
}
int __nocfi is_itf_power_down_wrap(struct is_interface *interface, u32 instance)
{
int ret = 0;
struct is_core *core;
#ifdef USE_DDK_SHUT_DOWN_FUNC
void *data = NULL;
#endif
dbg_hw(2, "%s\n", __func__);
core = (struct is_core *)interface->core;
if (!core) {
mwarn_hw("%s: core(null)\n", instance, __func__);
return ret;
}
is_itf_sudden_stop_wrap(&core->ischain[instance], instance, NULL);
#ifdef USE_DDK_SHUT_DOWN_FUNC
#ifdef ENABLE_FPSIMD_FOR_USER
fpsimd_get();
((ddk_shut_down_func_t)DDK_SHUT_DOWN_FUNC_ADDR)(data);
fpsimd_put();
#else
((ddk_shut_down_func_t)DDK_SHUT_DOWN_FUNC_ADDR)(data);
#endif
#endif
check_lib_memory_leak();
return ret;
}
int is_itf_sys_ctl_wrap(struct is_device_ischain *device,
int cmd, int val)
{
int ret = 0;
dbg_hw(2, "%s\n", __func__);
return ret;
}
int is_itf_sensor_mode_wrap(struct is_device_ischain *device,
struct is_sensor_cfg *cfg)
{
#ifdef USE_RTA_BINARY
void *data = NULL;
dbg_hw(2, "%s\n", __func__);
if (cfg && cfg->mode == SENSOR_MODE_DEINIT) {
info_hw("%s: call RTA_SHUT_DOWN\n", __func__);
#ifdef ENABLE_FPSIMD_FOR_USER
fpsimd_get();
((rta_shut_down_func_t)RTA_SHUT_DOWN_FUNC_ADDR)(data);
fpsimd_put();
#else
((rta_shut_down_func_t)RTA_SHUT_DOWN_FUNC_ADDR)(data);
#endif
}
#else
dbg_hw(2, "%s\n", __func__);
#endif
return 0;
}
void is_itf_fwboot_init(struct is_interface *this)
{
clear_bit(IS_IF_LAUNCH_FIRST, &this->launch_state);
clear_bit(IS_IF_LAUNCH_SUCCESS, &this->launch_state);
clear_bit(IS_IF_RESUME, &this->fw_boot);
clear_bit(IS_IF_SUSPEND, &this->fw_boot);
this->fw_boot_mode = COLD_BOOT;
}
bool check_setfile_change(struct is_group *group_leader,
struct is_group *group, struct is_hardware *hardware,
u32 instance, u32 scenario)
{
struct is_group *group_ischain = group;
struct is_hw_ip *hw_ip = NULL;
int hw_slot = -1;
u32 hw_id = DEV_HW_END;
enum exynos_sensor_position sensor_position;
if (group_leader->id != group->id)
return false;
if ((group->device_type == IS_DEVICE_SENSOR)
&& (group->next)) {
group_ischain = group->next;
}
hw_id = get_hw_id_from_group(group_ischain->id);
hw_slot = is_hw_slot_id(hw_id);
if (!valid_hw_slot_id(hw_slot)) {
merr_hw("[G:0x%x]: invalid slot (%d,%d)", instance,
GROUP_ID(group->id), hw_id, hw_slot);
return false;
}
hw_ip = &hardware->hw_ip[hw_slot];
if (!hw_ip) {
merr_hw("[G:0x%x]: hw_ip(null) (%d,%d)", instance,
GROUP_ID(group->id), hw_id, hw_slot);
return false;
}
sensor_position = hardware->sensor_position[instance];
/* If the 3AA hardware is shared between front preview and reprocessing instance, (e.g. PIP)
apply_setfile funciton needs to be called for sensor control. There is two options to check
this, one is to check instance change and the other is to check scenario(setfile_index) change.
The scenario(setfile_index) is different front preview instance and reprocessing instance.
So, second option is more efficient way to support PIP scenario.
*/
if (scenario != hw_ip->applied_scenario) {
msinfo_hw("[G:0x%x,0x%x,0x%x]%s: scenario(%d->%d), instance(%d->%d)\n", instance, hw_ip,
GROUP_ID(group_leader->id), GROUP_ID(group_ischain->id),
GROUP_ID(group->id), __func__,
hw_ip->applied_scenario, scenario,
atomic_read(&hw_ip->instance), instance);
return true;
}
return false;
}
int is_itf_shot_wrap(struct is_device_ischain *device,
struct is_group *group, struct is_frame *frame)
{
struct is_hardware *hardware;
struct is_interface *itf;
struct is_group *group_leader;
u32 instance = 0;
int ret = 0;
ulong flags;
u32 scenario;
bool apply_flag = false;
scenario = device->setfile & IS_SETFILE_MASK;
hardware = device->hardware;
instance = device->instance;
itf = device->interface;
group_leader = get_ischain_leader_group(device);
apply_flag = check_setfile_change(group_leader, group, hardware, instance, scenario);
if (!atomic_read(&group_leader->scount) || apply_flag) {
mdbg_hw(1, "[G:0x%x]%s: call apply_setfile()\n",
instance, GROUP_ID(group->id), __func__);
#if !defined(DISABLE_SETFILE)
ret = is_hardware_apply_setfile(hardware, instance,
scenario, hardware->hw_map[instance]);
if (ret) {
merr("is_hardware_apply_setfile is fail(%d)", device, ret);
return ret;
}
#endif
}
ret = is_hardware_grp_shot(hardware, instance, group, frame,
hardware->hw_map[instance]);
if (ret) {
merr("is_hardware_grp_shot is fail(%d)", device, ret);
return ret;
}
spin_lock_irqsave(&itf->shot_check_lock, flags);
atomic_set(&itf->shot_check[instance], 1);
spin_unlock_irqrestore(&itf->shot_check_lock, flags);
return ret;
}
void is_itf_sfr_dump_wrap(struct is_device_ischain *device, u32 group, bool flag_print_log)
{
u32 hw_maxnum;
u32 hw_id;
int hw_list[GROUP_HW_MAX];
struct is_hardware *hardware;
hardware = device->hardware;
hw_maxnum = is_get_hw_list(group, hw_list);
if (hw_maxnum > 0) {
hw_id = hw_list[hw_maxnum - 1];
is_hardware_sfr_dump(hardware, hw_id, flag_print_log);
}
}
|