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
|
/*
* Copyright (C) 2012 Spreadtrum Communications Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/uaccess.h>
#include <linux/sprd_mm.h>
#include <video/sprd_isp.h>
#include <asm/cacheflush.h>
#include "isp_reg.h"
#include "isp_drv.h"
static int32_t isp_k_afl_param_update(struct isp_k_private *isp_private)
{
int32_t ret = 0;
uint32_t addr = 0;
#ifndef CONFIG_64BIT
void *buf_ptr = (void *)isp_private->yiq_antiflicker_buf_addr;
#endif
uint32_t buf_len = isp_private->yiq_antiflicker_len;
if((0x00 != isp_private->yiq_antiflicker_buf_addr) && (0x00 != isp_private->yiq_antiflicker_len)) {
#ifndef CONFIG_64BIT
dmac_flush_range(buf_ptr, buf_ptr + buf_len);
outer_flush_range(__pa(buf_ptr), __pa(buf_ptr) + buf_len);
#endif
addr = (uint32_t)__pa(isp_private->yiq_antiflicker_buf_addr);
printk("$$LHC:addr %lp yiq_antiflicker_buf_addr %lp\n", addr, (int *)isp_private->yiq_antiflicker_buf_addr);
REG_WR(ISP_ANTI_FLICKER_DDR_INIT_ADDR, addr);
}
return ret;
}
static int32_t isp_k_afl_statistic(struct isp_io_param *param, struct isp_k_private *isp_private)
{
int32_t ret = 0;
int32_t i = 0;
int32_t *addr = NULL;
printk("$$LHC:isp_k_afl_statistic \n");
if((0x00 != isp_private->yiq_antiflicker_buf_addr) && (0x00 != param->property_param) \
&& (0x00 != isp_private->yiq_antiflicker_len) ) {
ret = copy_to_user(param->property_param, isp_private->yiq_antiflicker_buf_addr, isp_private->yiq_antiflicker_len);
if (0 != ret) {
ret = -1;
printk("isp_k_afl_statistic: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
}
addr = isp_private->yiq_antiflicker_buf_addr;
for(i = 0;i < 20;i++) {
printk("$$LHC %p, 0x%x\n", addr, *addr++);
}
}
}
static int32_t isp_k_afl_bypass(struct isp_io_param *param)
{
int32_t ret = 0;
uint32_t bypass = 0;
ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
if (0 != ret) {
printk("isp_k_afl_bypass: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
return -1;
}
printk("$$LHC:bypass %d \n", bypass);
if (bypass) {
REG_OWR(ISP_ANTI_FLICKER_PARAM0, BIT_0);
} else {
REG_MWR(ISP_ANTI_FLICKER_PARAM0, BIT_0, 0);
}
return ret;
}
static int32_t isp_k_anti_flicker_block(struct isp_io_param *param, struct isp_k_private *isp_private)
{
int32_t ret = 0;
struct isp_dev_anti_flicker_info_v1 afl_info;
memset(&afl_info, 0x00, sizeof(afl_info));
ret = copy_from_user((void *)&afl_info, param->property_param, sizeof(afl_info));
if (0 != ret) {
printk("isp_k_anti_flicker_block: copy error, ret=0x%x\n", (uint32_t)ret);
return -1;
}
REG_MWR(ISP_ANTI_FLICKER_PARAM0, BIT_0, afl_info.bypass);
REG_MWR(ISP_ANTI_FLICKER_PARAM0, BIT_1, afl_info.mode << 1);
REG_MWR(ISP_ANTI_FLICKER_PARAM0, 0xF << 2, afl_info.skip_frame_num << 2);
REG_MWR(ISP_ANTI_FLICKER_PARAM1, 0xF , afl_info.line_step);
REG_MWR(ISP_ANTI_FLICKER_PARAM1, 0xFF << 8, afl_info.frame_num << 8);
REG_MWR(ISP_ANTI_FLICKER_PARAM1, 0xFFFF << 16, afl_info.vheight << 16);
REG_MWR(ISP_ANTI_FLICKER_COL_POS, 0xFFFF , afl_info.start_col);
REG_MWR(ISP_ANTI_FLICKER_COL_POS, 0xFFFF << 16, afl_info.end_col << 16);
//config afl DDR initial address
isp_k_afl_param_update(isp_private);
//REG_WR(ISP_ANTI_FLICKER_DDR_INIT_ADDR, afl_info.addr);
return ret;
}
int32_t isp_k_cfg_anti_flicker(struct isp_io_param *param, struct isp_k_private *isp_private)
{
int32_t ret = 0;
if (!param) {
printk("isp_k_cfg_anti_flicker: param is null error.\n");
return -1;
}
if (NULL == param->property_param) {
printk("isp_k_cfg_anti_flicker: property_param is null error.\n");
return -1;
}
switch (param->property) {
case ISP_PRO_ANTI_FLICKER_BLOCK:
ret = isp_k_anti_flicker_block(param, isp_private);
break;
case ISP_PRO_ANTI_FLICKER_STATISTIC:
ret = isp_k_afl_statistic(param, isp_private);
break;
case ISP_PRO_ANTI_FLICKER_BYPASS:
ret = isp_k_afl_bypass(param);
break;
default:
printk("isp_k_cfg_anti_flicker: fail cmd id:%d, not supported.\n", param->property);
break;
}
return ret;
}
|