2 * Copyright (C) 2012 Spreadtrum Communications Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include <linux/uaccess.h>
15 #include <linux/sprd_mm.h>
16 #include <video/sprd_isp.h>
19 static int32_t isp_k_1d_lsc_block(struct isp_io_param *param)
23 struct isp_dev_1d_lsc_info lnc_info;
25 ret = copy_from_user((void *)&lnc_info, param->property_param, sizeof(lnc_info));
27 printk("isp_k_1d_lsc_block: copy error, ret=0x%x\n", (uint32_t)ret);
31 REG_MWR(ISP_1D_LNC_PARAM, BIT_0, lnc_info.bypass);
33 val = (lnc_info.gain_max_thr & 0x1FFF) << 1;
34 REG_MWR(ISP_1D_LNC_PARAM, 0x3FFE, val);
36 val = ((lnc_info.center_r0c0_col_x & 0x1FFF) << 12) | (lnc_info.center_r0c0_row_y & 0xFFF);
37 REG_WR(ISP_1D_LNC_PARAM1, val);
38 val = ((lnc_info.center_r0c1_col_x & 0x1FFF) << 12) | (lnc_info.center_r0c1_row_y & 0xFFF);
39 REG_WR(ISP_1D_LNC_PARAM2, val);
40 val = ((lnc_info.center_r1c0_col_x & 0x1FFF) << 12) | (lnc_info.center_r1c0_row_y & 0xFFF);
41 REG_WR(ISP_1D_LNC_PARAM3, val);
42 val = ((lnc_info.center_r1c1_col_x & 0x1FFF) << 12) | (lnc_info.center_r1c1_row_y & 0xFFF);
43 REG_WR(ISP_1D_LNC_PARAM4, val);
45 val = lnc_info.delta_square_r0c0_x & 0x3FFFFFF;
46 REG_WR(ISP_1D_LNC_PARAM5, val);
47 val = lnc_info.delta_square_r0c1_x & 0x3FFFFFF;
48 REG_WR(ISP_1D_LNC_PARAM7, val);
49 val = lnc_info.delta_square_r1c0_x & 0x3FFFFFF;
50 REG_WR(ISP_1D_LNC_PARAM9, val);
51 val = lnc_info.delta_square_r1c1_x & 0x3FFFFFF;
52 REG_WR(ISP_1D_LNC_PARAM11, val);
53 val = lnc_info.delta_square_r0c0_y & 0xFFFFFF;
54 REG_WR(ISP_1D_LNC_PARAM6, val);
55 val = lnc_info.delta_square_r0c1_y & 0xFFFFFF;
56 REG_WR(ISP_1D_LNC_PARAM8, val);
57 val = lnc_info.delta_square_r1c0_y & 0xFFFFFF;
58 REG_WR(ISP_1D_LNC_PARAM10, val);
59 val = lnc_info.delta_square_r1c1_y & 0xFFFFFF;
60 REG_WR(ISP_1D_LNC_PARAM12, val);
62 val = ((lnc_info.coef_r0c0_p1 & 0xFFFF) << 11) | (lnc_info.coef_r0c0_p2 & 0x7FF);
63 REG_WR(ISP_1D_LNC_PARAM13, val);
64 val = ((lnc_info.coef_r0c1_p1 & 0xFFFF) << 11) | (lnc_info.coef_r0c1_p2 & 0x7FF);
65 REG_WR(ISP_1D_LNC_PARAM14, val);
66 val = ((lnc_info.coef_r1c0_p1 & 0xFFFF) << 11) | (lnc_info.coef_r1c0_p2 & 0x7FF);
67 REG_WR(ISP_1D_LNC_PARAM15, val);
68 val = ((lnc_info.coef_r1c1_p1 & 0xFFFF) << 11) | (lnc_info.coef_r1c1_p2 & 0x7FF);
69 REG_WR(ISP_1D_LNC_PARAM16, val);
71 val = ((lnc_info.start_pos.x & 0x1FFF) << 12) | (lnc_info.start_pos.y & 0xFFF);
72 REG_WR(ISP_1D_LNC_PARAM18, val);
77 static int32_t isp_k_1d_lsc_slice_size(struct isp_io_param *param)
81 struct isp_img_size size;
83 ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
85 printk("isp_k_1d_lsc_slice_size: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
89 val = ((size.width & 0x1FFF) << 12) | (size.height & 0xFFF);
91 REG_WR(ISP_1D_LNC_PARAM17, val);
96 static int32_t isp_k_1d_lsc_pos(struct isp_io_param *param)
100 struct img_offset pos;
102 ret = copy_from_user((void *)&pos, param->property_param, sizeof(struct img_offset));
104 printk("isp_k_1d_lsc_pos: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
108 val = ((pos.x & 0x1FFF) << 12) | (pos.y & 0xFFF);
110 REG_WR(ISP_1D_LNC_PARAM18, val);
115 int32_t isp_k_cfg_1d_lsc(struct isp_io_param *param)
120 printk("isp_k_cfg_1d_lsc: param is null error.\n");
124 if (NULL == param->property_param) {
125 printk("isp_k_cfg_1d_lsc: property_param is null error.\n");
129 switch(param->property) {
130 case ISP_PRO_1D_LSC_BLOCK:
131 ret = isp_k_1d_lsc_block(param);
133 case ISP_PRO_1D_LSC_SLICE_SIZE:
134 ret = isp_k_1d_lsc_slice_size(param);
136 case ISP_PRO_1D_LSC_POS:
137 ret = isp_k_1d_lsc_pos(param);
140 printk("isp_k_cfg_1d_lsc: fail cmd id:%d, not supported.\n", param->property);