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_bdn_block(struct isp_io_param *param)
25 struct isp_dev_bdn_info_v1 bdn_info;
27 memset(&bdn_info, 0x00, sizeof(bdn_info));
29 ret = copy_from_user((void *)&bdn_info, param->property_param, sizeof(bdn_info));
31 printk("isp_k_bdn_block: copy error, ret=0x%x\n", (uint32_t)ret);
35 REG_MWR(ISP_BDN_PARAM, BIT_1, bdn_info.radial_bypass << 1);
37 REG_MWR(ISP_BDN_PARAM, 0x7F0, bdn_info.addback << 4);
39 for (i = 0; i < 10; i++) {
40 REG_WR(ISP_BDN_DISWEI0_0 + 40 * i, bdn_info.dis[i][0]);
42 REG_WR(ISP_BDN_DISWEI0_1 + 40 * i, bdn_info.dis[i][1]);
45 for (i = 0; i < 10; i++) {
46 for (j = 0; j < 7; j++) {
47 REG_WR(ISP_BDN_RANWEI0_0 + i * 40 + j * 4, bdn_info.ran[i][j]);
50 REG_WR(ISP_BDN_RANWEI0_7 + i * 40, bdn_info.ran[i][7]);
53 val = ((bdn_info.offset_x & 0x1FFF) << 12) | (bdn_info.offset_y & 0xFFF);
54 REG_WR(ISP_BDN_1DLNC_CENTER, val);
56 val = bdn_info.squ_x2 & 0x3FFFFFF;
57 REG_WR(ISP_BDN_1DLNC_SQUARE_X, val);
58 val = bdn_info.squ_y2 & 0xFFFFFF;
59 REG_WR(ISP_BDN_1DLNC_SQUARE_Y, val);
61 val = ((bdn_info.coef2 & 0xFFFF) << 11) | (bdn_info.coef & 0x7FF);
62 REG_WR(ISP_BDN_1DLNC_P, val);
64 val = ((bdn_info.start_pos_x & 0x1FFF) << 12) | (bdn_info.start_pos_y & 0xFFF);
65 REG_WR(ISP_BDN_1DLNC_POS, val);
67 REG_WR(ISP_BDN_1DLNC_OFFSET, bdn_info.offset & 0x3FFFFFF);
69 REG_MWR(ISP_BDN_PARAM, BIT_0, bdn_info.bypass);
75 static int32_t isp_k_bdn_1d_slice_size(struct isp_io_param *param)
78 struct isp_img_size size = {0, 0};
81 ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
83 printk("isp_k_bdn_1d_slice_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
87 val = ((size.width & 0x1FFF) << 12) | (size.height & 0xFFF);
88 REG_WR(ISP_BDN_1DLNC_SIZE, val);
93 int32_t isp_k_cfg_bdn(struct isp_io_param *param)
98 printk("isp_k_cfg_bdn: param is null error.\n");
102 if (NULL == param->property_param) {
103 printk("isp_k_cfg_bdn: property_param is null error.\n");
107 switch(param->property) {
108 case ISP_PRO_BDN_BLOCK:
109 ret = isp_k_bdn_block(param);
111 case ISP_PRO_BDN_SLICE_SIZE:
112 ret = isp_k_bdn_1d_slice_size(param);
115 printk("isp_k_cfg_bdn: fail cmd id:%d, not supported.\n", param->property);