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_pwd_block(struct isp_io_param *param)
23 struct isp_dev_pre_wavelet_info_v1 pwd_info;
25 memset(&pwd_info, 0x00, sizeof(pwd_info));
27 ret = copy_from_user((void *)&pwd_info, param->property_param, sizeof(pwd_info));
29 printk("isp_k_pwd_block: copy error, ret=0x%x\n", (uint32_t)ret);
33 val = ((pwd_info.gain_thrs0 & 0x7FF) << 6) | ((pwd_info.gain_thrs1 & 0x7FF) << 17);
34 REG_MWR(ISP_PWD_PARAM, 0x0FFFFFC0, val);
36 val = (pwd_info.bitshift0 & 0x7) | ((pwd_info.bitshift1 & 0xFF) << 3);
37 REG_MWR(ISP_PWD_PARAM1, 0x7FF, val);
39 val = (pwd_info.offset & 0xFF) << 11;
40 REG_MWR(ISP_PWD_PARAM1, 0x7F800, val);
42 val = (pwd_info.nsr_slope & 0x3FF) << 4;
43 REG_MWR(ISP_PWD_PARAM2, 0x3FF0, val);
45 val = pwd_info.lum_ratio & 0xF;
46 REG_MWR(ISP_PWD_PARAM2, 0xF, val);
48 val = ((pwd_info.center_pos_x & 0x1FFF) << 12) | (pwd_info.center_pos_y & 0xFFF);
49 REG_WR(ISP_PWD_PARAM3, val);
51 val = pwd_info.delta_x2 & 0x3FFFFFF;
52 REG_WR(ISP_PWD_PARAM4, val);
53 val = pwd_info.delta_y2 & 0xFFFFFF;
54 REG_WR(ISP_PWD_PARAM5, val);
56 val = pwd_info.r2_thr & 0x3FFFFFF;
57 REG_WR(ISP_PWD_PARAM6, val);
59 val = ((pwd_info.p_param1 & 0x3FFF) << 12) | (pwd_info.p_param2 & 0xFFF);
60 REG_WR(ISP_PWD_PARAM7, val);
62 val = (pwd_info.addback & 0x7F) << 13;
63 REG_MWR(ISP_PWD_PARAM8, 0xFE000, val);
65 val = pwd_info.gain_max_thr & 0x1FFF;
66 REG_MWR(ISP_PWD_PARAM8, 0x1FFF, val);
68 val = ((pwd_info.pos_x & 0x1FFF) << 12) | (pwd_info.pos_y & 0xFFF);
69 REG_WR(ISP_PWD_PARAM10, val);
71 REG_MWR(ISP_PWD_PARAM, BIT_1, pwd_info.radial_bypass << 1);
72 REG_MWR(ISP_PWD_PARAM, BIT_0, pwd_info.bypass);
77 static int32_t isp_k_pwd_slice_size(struct isp_io_param *param)
81 struct isp_img_size size = {0, 0};
83 ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
85 printk("isp_k_pwd_slice_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
89 val = ((size.width & 0x1FFF) << 12) | (size.height & 0xFFF);
90 REG_WR(ISP_PWD_PARAM9, val);
95 int32_t isp_k_cfg_pwd(struct isp_io_param *param)
100 printk("isp_k_cfg_pwd: param is null error.\n");
104 if (NULL == param->property_param) {
105 printk("isp_k_cfg_pwd: property_param is null error.\n");
109 switch(param->property) {
110 case ISP_PRO_PWD_BLOCK:
111 ret = isp_k_pwd_block(param);
113 case ISP_PRO_PWD_SLICE_SIZE:
114 ret = isp_k_pwd_slice_size(param);
117 printk("isp_k_cfg_pwd: fail cmd id:%d, not supported.\n", param->property);