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_hist_block(struct isp_io_param *param)
22 struct isp_dev_hist_info_v1 hist_info;
25 memset(&hist_info, 0x00, sizeof(hist_info));
27 ret = copy_from_user((void *)&hist_info, param->property_param, sizeof(hist_info));
29 printk("isp_k_hist_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
33 if (hist_info.buf_rst_en) {
34 REG_OWR(ISP_HIST_PARAM, BIT_1);
36 REG_MWR(ISP_HIST_PARAM, BIT_1, 0);
39 if (hist_info.pof_rst_en) {
40 REG_OWR(ISP_HIST_PARAM, BIT_9);
42 REG_MWR(ISP_HIST_PARAM, BIT_9, 0);
45 if (hist_info.skip_num_clr) {
46 REG_OWR(ISP_HIST_PARAM, BIT_8);
48 REG_MWR(ISP_HIST_PARAM, BIT_8, 0);
51 REG_MWR(ISP_HIST_PARAM, 0xF0, hist_info.skip_num << 4);
54 REG_OWR(ISP_HIST_PARAM, BIT_3);
56 REG_MWR(ISP_HIST_PARAM, BIT_3, 0);
59 val = ((hist_info.high_ratio & 0xFFFF) << 16)
60 | (hist_info.low_ratio & 0xFFFF);
62 REG_WR(ISP_HIST_RATIO, val);
64 val = (hist_info.dif_adj & 0xFF) | ((hist_info.small_adj & 0xFF) << 8)
65 | ((hist_info.big_adj & 0xFF) << 16);
67 REG_WR(ISP_HIST_ADJUST, val);
70 REG_OWR(ISP_HIST_PARAM, BIT_2);
72 REG_MWR(ISP_HIST_PARAM, BIT_2, 0);
75 if (hist_info.bypass) {
76 REG_OWR(ISP_HIST_PARAM, BIT_0);
78 REG_MWR(ISP_HIST_PARAM, BIT_0, 0);
84 static int32_t isp_k_hist_slice_size(struct isp_io_param *param)
88 struct isp_img_size size = {0};
90 ret = copy_from_user((void *)&size, param->property_param, sizeof(size));
92 printk("isp_k_hist_slice_size: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
96 val = ((size.height & 0xFFFF) << 16)
97 | (size.width & 0xFFFF);
99 REG_WR(ISP_HIST_SLICE_SIZE, val);
104 int32_t isp_k_cfg_hist(struct isp_io_param *param)
109 printk("isp_k_cfg_hist: param is null error.\n");
113 if (NULL == param->property_param) {
114 printk("isp_k_cfg_hist: property_param is null error.\n");
118 switch (param->property) {
119 case ISP_PRO_HIST_BLOCK:
120 ret = isp_k_hist_block(param);
122 case ISP_PRO_HIST_SLICE_SIZE:
123 ret = isp_k_hist_slice_size(param);
126 printk("isp_k_cfg_hist: fail cmd id:%d, not supported.\n", param->property);