summaryrefstree
path: root/kernel/drivers/media/platform/exynos/fimc-is2/fimc-is-interface-wrap.c
blob: 9a530c015529cde7b48d1494ae5165733b6a48e3 (plain)
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
/*
 * 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 "fimc-is-interface-wrap.h"
#include "fimc-is-interface-library.h"
#include "fimc-is-param.h"

int fimc_is_itf_s_param_wrap(struct fimc_is_device_ischain *device,
	u32 lindex, u32 hindex, u32 indexes)
{
	struct fimc_is_hardware *hardware = NULL;
	u32 instance = 0;
	int ret = 0;

	dbg_hw("%s\n", __func__);

	hardware = device->hardware;
	instance = device->instance;

	ret = fimc_is_hardware_set_param(hardware, instance, device->is_region,
		lindex, hindex, hardware->hw_map[instance]);
	if (ret) {
		merr("fimc_is_hardware_set_param is fail(%d)", device, ret);
		return ret;
	}

	return ret;
}

int fimc_is_itf_a_param_wrap(struct fimc_is_device_ischain *device, u32 group)
{
	struct fimc_is_hardware *hardware = NULL;
	u32 instance = 0;
	int ret = 0;

	dbg_hw("%s\n", __func__);

	hardware = device->hardware;
	instance = device->instance;

#if !defined(SETFILE_DISABLE)
	ret = fimc_is_hardware_apply_setfile(hardware, instance,
		(group & GROUP_ID_PARM_MASK), device->setfile,
		hardware->hw_map[instance]);
	if (ret) {
		merr("fimc_is_hardware_apply_setfile is fail(%d)", device, ret);
		return ret;
	}
#endif
	return ret;
}

int fimc_is_itf_f_param_wrap(struct fimc_is_device_ischain *device, u32 group)
{
	struct fimc_is_hardware *hardware= NULL;
	u32 instance = 0;
	int ret = 0;

	dbg_hw("%s\n", __func__);

	hardware = device->hardware;
	instance = device->instance;

#if !defined(SETFILE_DISABLE)
	ret = fimc_is_hardware_apply_setfile(hardware,
		instance,
		(group & GROUP_ID_PARM_MASK),
		device->setfile,
		hardware->hw_map[instance]);
	if (ret) {
		merr("fimc_is_hardware_apply_setfile is fail(%d)", device, ret);
		return ret;
	}
#endif
	return ret;
}

int fimc_is_itf_enum_wrap(struct fimc_is_device_ischain *device)
{
	int ret = 0;

	dbg_hw("%s\n", __func__);

	return ret;
}

void fimc_is_itf_storefirm_wrap(struct fimc_is_device_ischain *device)
{
	dbg_hw("%s\n", __func__);

	return;
}

void fimc_is_itf_restorefirm_wrap(struct fimc_is_device_ischain *device)
{
	dbg_hw("%s\n", __func__);

	return;
}

int fimc_is_itf_set_fwboot_wrap(struct fimc_is_device_ischain *device, u32 val)
{
	int ret = 0;

	dbg_hw("%s\n", __func__);

	return ret;
}

int fimc_is_itf_open_wrap(struct fimc_is_device_ischain *device, u32 module_id,
	u32 flag, u32 offset_path)
{
	struct fimc_is_hardware *hardware;
	struct fimc_is_path_info *path;
	struct fimc_is_group *group;
	struct is_region *region;
	u32 instance = 0;
	u32 hw_id = 0;
	u32 group_slot = -1;
	u32 group_id = -1;
	int ret = 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);

	instance = device->instance;
	hardware = device->hardware;
	path = (struct fimc_is_path_info *)&device->is_region->shared[offset_path];
	rsccount = atomic_read(&hardware->rsccount);

	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]);

	group_slot = GROUP_SLOT_3AA;
	group = &device->group_3aa;
	group_id = path->group[group_slot];
	dbg_hw("itf_open_wrap: group[SLOT_%d]=[%x]\n", group_slot, group_id);
	hw_maxnum = fimc_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 = fimc_is_hardware_open(hardware, hw_id, group, instance,
				flag, module_id);
		if (ret) {
			err("fimc_is_hardware_open(%d) is fail", hw_id);
			return ret;
		}
	}

	group_slot = GROUP_SLOT_ISP;
	group = &device->group_isp;
	group_id = path->group[group_slot];
	dbg_hw("itf_open_wrap: group[SLOT_%d]=[%x]\n", group_slot, group_id);
	hw_maxnum = fimc_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 = fimc_is_hardware_open(hardware, hw_id, group, instance,
				flag, module_id);
		if (ret) {
			err("fimc_is_hardware_open(%d) is fail", hw_id);
			return ret;
		}
	}

	group_slot = GROUP_SLOT_DIS;
	group = &device->group_dis;
	group_id = path->group[group_slot];
	dbg_hw("itf_open_wrap: group[SLOT_%d]=[%x]\n", group_slot, group_id);
	hw_maxnum = fimc_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 = fimc_is_hardware_open(hardware, hw_id, group, instance,
				flag, module_id);
		if (ret) {
			err("fimc_is_hardware_open(%d) is fail", hw_id);
			return ret;
		}
	}

	group_slot = GROUP_SLOT_MCS;
	group = &device->group_mcs;
	group_id = path->group[group_slot];
	dbg_hw("itf_open_wrap: group[SLOT_%d]=[%x]\n", group_slot, group_id);
	hw_maxnum = fimc_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 = fimc_is_hardware_open(hardware, hw_id, group, instance,
				flag, module_id);
		if (ret) {
			err("fimc_is_hardware_open(%d) is fail", hw_id);
			return ret;
		}
	}

	atomic_inc(&hardware->rsccount);

	info("%s: done: hw_map[0x%lx][RSC:%d]\n", __func__,
		hardware->hw_map[instance], atomic_read(&hardware->rsccount));

	return ret;
}

int fimc_is_itf_close_wrap(struct fimc_is_device_ischain *device)
{
	struct fimc_is_hardware *hardware;
	struct fimc_is_path_info *path;
	u32 offset_path = 0;
	u32 instance = 0;
	u32 hw_id = 0;
	u32 group_slot = -1;
	u32 group_id = -1;
	int ret = 0;
	int hw_list[GROUP_HW_MAX];
	int hw_index;
	int hw_maxnum = 0;
	u32 rsccount;

	dbg_hw("%s\n", __func__);

	hardware = device->hardware;
	instance = device->instance;
	offset_path = (sizeof(struct sensor_open_extended) / 4) + 1;
	path = (struct fimc_is_path_info *)&device->is_region->shared[offset_path];
	rsccount = atomic_read(&hardware->rsccount);

#if !defined(SETFILE_DISABLE)
	ret = fimc_is_hardware_delete_setfile(hardware, instance,
			hardware->hw_map[instance]);
	if (ret) {
		merr("fimc_is_hardware_delete_setfile is fail(%d)", device, ret);
			return ret;
	}
#endif

	if (rsccount == 1)
		fimc_is_flush_ddk_thread();

	group_slot = GROUP_SLOT_3AA;
	group_id = path->group[group_slot];
	dbg_hw("itf_close_wrap: group[SLOT_%d]=[%x]\n", group_slot, group_id);
	hw_maxnum = fimc_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 = fimc_is_hardware_close(hardware, hw_id, instance);
		if (ret) {
			err("fimc_is_hardware_close(%d) is fail", hw_id);
			return ret;
		}
	}

	group_slot = GROUP_SLOT_ISP;
	group_id = path->group[group_slot];
	dbg_hw("itf_close_wrap: group[SLOT_%d]=[%x]\n", group_slot, group_id);
	hw_maxnum = fimc_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 = fimc_is_hardware_close(hardware, hw_id, instance);
		if (ret) {
			err("fimc_is_hardware_close(%d) is fail", hw_id);
			return ret;
		}
	}

	group_slot = GROUP_SLOT_DIS;
	group_id = path->group[group_slot];
	dbg_hw("itf_close_wrap: group[SLOT_%d]=[%x]\n", group_slot, group_id);
	hw_maxnum = fimc_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 = fimc_is_hardware_close(hardware, hw_id, instance);
		if (ret) {
			err("fimc_is_hardware_close(%d) is fail", hw_id);
			return ret;
		}
	}

	group_slot = GROUP_SLOT_MCS;
	group_id = path->group[group_slot];
	dbg_hw("itf_close_wrap: group[SLOT_%d]=[%x]\n", group_slot, group_id);
	hw_maxnum = fimc_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 = fimc_is_hardware_close(hardware, hw_id, instance);
		if (ret) {
			err("fimc_is_hardware_close(%d) is fail", hw_id);
			return ret;
		}
	}

	atomic_dec(&hardware->rsccount);

	if (rsccount == 1)
		check_lib_memory_leak();

	info("%s: done: hw_map[0x%lx][RSC:%d]\n", __func__,
		hardware->hw_map[instance], atomic_read(&hardware->rsccount));

	return ret;
}

int fimc_is_itf_setaddr_wrap(struct fimc_is_interface *itf,
	struct fimc_is_device_ischain *device, u32 *setfile_addr)
{
	int ret = 0;

	dbg_hw("%s\n", __func__);

	*setfile_addr = FIMC_IS_SETFILE_OFFSET;

	return ret;
}

int fimc_is_itf_setfile_wrap(struct fimc_is_interface *itf, ulong setfile_addr,
	struct fimc_is_device_ischain *device)
{
	struct fimc_is_hardware *hardware;
	u32 instance = 0;
	int ret = 0;

	dbg_hw("%s\n", __func__);

	hardware = device->hardware;
	instance = device->instance;

#if !defined(SETFILE_DISABLE)
	ret = fimc_is_hardware_load_setfile(hardware, setfile_addr, instance,
				hardware->hw_map[instance]);
	if (ret) {
		merr("fimc_is_hardware_load_setfile is fail(%d)", device, ret);
		return ret;
	}
#endif

	return ret;
}

int fimc_is_itf_map_wrap(struct fimc_is_device_ischain *device,
	u32 group, u32 shot_addr, u32 shot_size)
{
	int ret = 0;

	dbg_hw("%s\n", __func__);

	return ret;
}

int fimc_is_itf_unmap_wrap(struct fimc_is_device_ischain *device, u32 group)
{
	int ret = 0;

	dbg_hw("%s\n", __func__);

	return ret;
}

int fimc_is_itf_stream_on_wrap(struct fimc_is_device_ischain *device)
{
	int ret = 0;
	struct fimc_is_hardware *hardware;
	u32 instance = 0;

	dbg_hw("%s\n", __func__);

	hardware = device->hardware;
	instance = device->instance;

	ret = fimc_is_hardware_stream_on(hardware, instance,
					hardware->hw_map[instance]);
	if (ret) {
		merr("fimc_is_hardware_stream_on is fail(%d)", device, ret);
		return ret;
	}

	return ret;
}

int fimc_is_itf_stream_off_wrap(struct fimc_is_device_ischain *device)
{
	struct fimc_is_hardware *hardware;
	u32 instance = 0;
	int ret = 0;

	dbg_hw("%s\n", __func__);

	hardware = device->hardware;
	instance = device->instance;

	ret = fimc_is_hardware_stream_off(hardware, instance,
					hardware->hw_map[instance]);
	if (ret) {
		merr("fimc_is_hardware_stream_off is fail(%d)", device, ret);
		return ret;
	}

	return ret;
}

int fimc_is_itf_process_on_wrap(struct fimc_is_device_ischain *device, u32 group)
{
	struct fimc_is_hardware *hardware;
	u32 instance = 0;
	int ret = 0;

	dbg_hw("%s\n", __func__);

	hardware = device->hardware;
	instance = device->instance;

	ret = fimc_is_hardware_process_start(hardware, instance, group);
	if (ret) {
		merr("fimc_is_hardware_process_start is fail(%d)", device, ret);
		return ret;
	}

	return ret;
}

int fimc_is_itf_process_off_wrap(struct fimc_is_device_ischain *device, u32 group,
	u32 fstop)
{
	struct fimc_is_hardware *hardware;
	u32 instance = 0;
	int ret = 0;

	dbg_hw("%s\n", __func__);

	hardware = device->hardware;
	instance = device->instance;

	ret = fimc_is_hardware_process_stop(hardware, instance, group, fstop);
	if (ret) {
		merr("fimc_is_hardware_process_stop is fail(%d)", device, ret);
		return ret;
	}

	return ret;
}

int fimc_is_itf_power_down_wrap(struct fimc_is_interface *interface, u32 instance)
{
	int ret = 0;

	dbg_hw("%s\n", __func__);

	return ret;
}

int fimc_is_itf_sys_ctl_wrap(struct fimc_is_device_ischain *device,
	int cmd, int val)
{
	int ret = 0;

	dbg_hw("%s\n", __func__);

	return ret;
}

int fimc_is_itf_sensor_mode_wrap(struct fimc_is_device_ischain *ischain,
	struct fimc_is_sensor_cfg *cfg)
{
	dbg_hw("%s\n", __func__);

	return 0;
}

void fimc_is_itf_fwboot_init(struct fimc_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;
}

int fimc_is_itf_shot_wrap(struct fimc_is_device_ischain *device,
	struct fimc_is_group *group, struct fimc_is_frame *frame)
{
	struct fimc_is_hardware *hardware;
	u32 instance = 0;
	int ret = 0;

	hardware = device->hardware;
	instance = device->instance;

	ret = fimc_is_hardware_grp_shot(hardware, instance, group, frame,
					hardware->hw_map[instance]);
	if (ret) {
		merr("fimc_is_hardware_grp_shot is fail(%d)", device, ret);
		return ret;
	}

	return ret;
}