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
|
/*
* 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 "isp_reg.h"
static int32_t isp_k_edge_block(struct isp_io_param *param)
{
int32_t ret = 0;
struct isp_dev_edge_info_v1 edge_info;
uint32_t val = 0;
memset(&edge_info, 0x00, sizeof(edge_info));
ret = copy_from_user((void *)&edge_info, param->property_param, sizeof(edge_info));
if (0 != ret) {
printk("isp_k_edge_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
return -1;
}
REG_MWR(ISP_EE_CFG0, BIT_29 | BIT_28, edge_info.mode << 28);
val = (edge_info.ee_str_m_n & 0x7F) | ((edge_info.ee_str_m_p & 0x7F) << 7)
| ((edge_info.ee_str_d_n & 0x7F) << 14) | ((edge_info.ee_str_d_p & 0x7F) << 21);
REG_MWR(ISP_EE_CFG0, 0xFFFFFFF, val);
val = ((edge_info.ee_incr_d_p & 0xFF) << 8) | (edge_info.ee_incr_d_n & 0xFF);
REG_MWR(ISP_EE_CFG1, 0xFFFF, val);
val = ((edge_info.ee_thr_d_n & 0xFF) << 16) | ((edge_info.ee_thr_d_p & 0xFF) << 24);
REG_MWR(ISP_EE_CFG1, 0xFFFF0000, val);
val = (edge_info.ee_flat_thr_1 & 0xFF) | ((edge_info.ee_flat_thr_2 & 0xFF) << 8);
REG_MWR(ISP_EE_CFG2, 0xFFFF, val);
val = ((edge_info.ee_incr_m_n & 0xFF) << 16) | ((edge_info.ee_incr_m_p & 0xFF) << 24);
REG_MWR(ISP_EE_CFG2, 0xFFFF0000, val);
val = (edge_info.ee_txt_thr_1 & 0xFF) | ((edge_info.ee_txt_thr_2 & 0xFF) << 8)
| ((edge_info.ee_txt_thr_3 & 0xFF) << 16);
REG_WR(ISP_EE_CFG3, val);
val = ((edge_info.ee_corner_cor & 0x1) << 28) | ((edge_info.ee_corner_th_p & 0x1F) << 23)
| ((edge_info.ee_corner_th_n & 0x1F) << 18) | ((edge_info.ee_corner_gain_p & 0x7F) << 11)
| ((edge_info.ee_corner_gain_n & 0x7F) << 4) | ((edge_info.ee_corner_sm_p & 0x3) << 2)
| (edge_info.ee_corner_sm_n & 0x3);
REG_WR(ISP_EE_CFG4, val);
val = ((edge_info.ee_edge_smooth_mode & 0x3) << 26) | ((edge_info.ee_flat_smooth_mode & 0x3) << 24)
| ((edge_info.ee_smooth_thr & 0xFF) << 8) | (edge_info.ee_smooth_strength & 0xFF);
REG_MWR(ISP_EE_CFG5, 0xF00FFFF, val);
val = (edge_info.sigma & 0xFF) << 16;
REG_MWR(ISP_EE_CFG5, 0xFF0000, val);
val = ((edge_info.ee_str_b_p & 0xFF) << 24) | ((edge_info.ee_str_b_n & 0xFF) << 16)
| ((edge_info.ee_incr_b_p & 0xFF) << 8) | (edge_info.ee_incr_b_n & 0xFF);
REG_WR(ISP_EE_CFG6, val);
val = ((edge_info.ratio[1] & 0xFF) << 8) | (edge_info.ratio[0] & 0xFF);
REG_MWR(ISP_EE_CFG7, 0xFFFF, val);
val = (edge_info.ee_clip_after_smooth_en & 0x1) << 25;
REG_MWR(ISP_EE_CFG7, BIT_25, val);
val = ((edge_info.ipd_bypass & 0x1) << 24) | ((edge_info.ipd_flat_thr & 0xFF) << 16);
REG_MWR(ISP_EE_CFG7, 0x1FF0000, val);
/*pike has no ADP_CFG0 ADP_CFG1 ADP_CFG2 registers*/
/* val = (edge_info.ee_t1_cfg & 0x3FF) | ((edge_info.ee_t2_cfg & 0x3FF) << 10)
| ((edge_info.ee_t3_cfg & 0x3FF) << 20);
REG_WR(ISP_EE_ADP_CFG0, val);
val = (edge_info.ee_t4_cfg & 0x3FF) | ((edge_info.ee_cv_clip_n & 0xFF) << 16)
| ((edge_info.ee_cv_clip_p & 0xFF) << 24);
REG_WR(ISP_EE_ADP_CFG1, val);
val = (edge_info.ee_r1_cfg & 0xFF) | ((edge_info.ee_r2_cfg & 0xFF) << 8)
| ((edge_info.ee_r3_cfg & 0xFF) << 16);
REG_WR(ISP_EE_ADP_CFG2, val);*/
if (edge_info.bypass) {
REG_OWR(ISP_EE_PARAM, BIT_0);
} else {
REG_MWR(ISP_EE_PARAM, BIT_0, 0);
}
return ret;
}
int32_t isp_k_cfg_edge(struct isp_io_param *param)
{
int32_t ret = 0;
if (!param) {
printk("isp_k_cfg_edge: param is null error.\n");
return -1;
}
if (NULL == param->property_param) {
printk("isp_k_cfg_edge: property_param is null error.\n");
return -1;
}
switch (param->property) {
case ISP_PRO_EDGE_BLOCK:
ret = isp_k_edge_block(param);
break;
default:
printk("isp_k_cfg_edge: fail cmd id:%d, not supported.\n", param->property);
break;
}
return ret;
}
|