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
|
/*
* 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/vmalloc.h>
#include <linux/sprd_mm.h>
#include <video/sprd_isp.h>
#include "isp_reg.h"
#include "isp_drv.h"
#define ISP_FRGB_GAMC_BUF0 0
#define ISP_FRGB_GAMC_BUF1 1
static int32_t isp_k_pingpang_frgb_gamc(struct coordinate_xy *nodes,
struct isp_k_private *isp_private)
{
int32_t ret = 0;
uint32_t i, j;
uint32_t val = 0;
unsigned long r_buf_addr;
unsigned long g_buf_addr;
unsigned long b_buf_addr;
struct coordinate_xy *p_nodes = NULL;
if (!nodes) {
ret = -1;
printk("isp_k_pingpang_frgb_gamc: node is null error .\n");
return ret;
}
p_nodes = nodes;
if (ISP_FRGB_GAMC_BUF0 == isp_private->full_gamma_buf_id) {
r_buf_addr = ISP_FGAMMA_R_BUF1_CH0;
g_buf_addr = ISP_FGAMMA_G_BUF1_CH0;
b_buf_addr = ISP_FGAMMA_B_BUF1_CH0;
isp_private->full_gamma_buf_id = ISP_FRGB_GAMC_BUF1;
} else {
r_buf_addr = ISP_FGAMMA_R_BUF0_CH0;
g_buf_addr = ISP_FGAMMA_G_BUF0_CH0;
b_buf_addr = ISP_FGAMMA_B_BUF0_CH0;
isp_private->full_gamma_buf_id = ISP_FRGB_GAMC_BUF0;
}
for(i = 0,j = 0;i < ISP_PINGPANG_FRGB_GAMC_NUM;i++,j+=4) {
REG_WR(r_buf_addr + j, p_nodes[i].node_y & 0xff);
REG_WR(g_buf_addr + j, p_nodes[i].node_y & 0xff);
REG_WR(b_buf_addr + j, p_nodes[i].node_y & 0xff);
}
val = ((isp_private->full_gamma_buf_id & 0x1 ) << 1) | ((isp_private->full_gamma_buf_id & 0x1) << 2) | ((isp_private->full_gamma_buf_id & 0x1 ) << 3);
REG_MWR(ISP_GAMMA_PARAM, 0x0000000E, val);
return ret;
}
static int32_t isp_k_gamma_block(struct isp_io_param *param,
struct isp_k_private *isp_private)
{
int32_t ret = 0;
uint32_t bypass;
struct isp_dev_gamma_info_v1 *param_p= (struct isp_dev_gamma_info_v1 *)param->property_param;
struct coordinate_xy *nodes = NULL;
nodes = (struct coordinate_xy *)isp_private->full_gamma_buf_addr;
if (!nodes) {
ret = -1;
printk("isp_k_gamma_block: alloc memory error.\n");
return -1;
}
ret = copy_from_user((void *)&bypass, (void *)¶m_p->bypass, sizeof(uint32_t));
if (0 != ret) {
printk("isp_k_gamma_block: copy bypass error, ret=0x%x\n", (uint32_t)ret);
return -1;
}
ret = copy_from_user((void *)nodes, (void *)param_p->nodes, ISP_FRGB_GAMMA_BUF_SIZE);
if (0 != ret) {
printk("isp_k_gamma_block: copy nodes error, ret=0x%x\n", (uint32_t)ret);
return -1;
}
ret = isp_k_pingpang_frgb_gamc(nodes, isp_private);
if (0 != ret) {
printk("isp_k_gamma_block: pingpang error, ret=0x%x\n", (uint32_t)ret);
return -1;
}
REG_MWR(ISP_GAMMA_PARAM, BIT_0, bypass);
return ret;
}
int32_t isp_k_cfg_gamma(struct isp_io_param *param,
struct isp_k_private *isp_private)
{
int32_t ret = 0;
if (!param) {
printk("isp_k_cfg_gamma: param is null error.\n");
return -1;
}
if (NULL == param->property_param) {
printk("isp_k_cfg_gamma: property_param is null error.\n");
return -1;
}
switch(param->property) {
case ISP_PRO_GAMMA_BLOCK:
ret = isp_k_gamma_block(param, isp_private);
break;
default:
printk("isp_k_cfg_gamma: fail cmd id:%d, not supported.\n", param->property);
break;
}
return ret;
}
|