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_edge_block(struct isp_io_param *param)
23 struct isp_dev_edge_info edge_info;
25 memset(&edge_info, 0x00, sizeof(edge_info));
27 ret = copy_from_user((void *)&edge_info, param->property_param, sizeof(edge_info));
29 printk("isp_k_edge_block: copy error, ret=0x%x\n", (uint32_t)ret);
33 val = ((edge_info.strength & 0x3F) << 17)
34 | ((edge_info.smooth_thrd & 0xFF) << 9)
35 | ((edge_info.detail_thrd & 0xFF) << 1);
36 REG_MWR(ISP_EDGE_PARAM, 0x7FFFFE, val);
38 if (edge_info.bypass) {
39 REG_OWR(ISP_EDGE_PARAM, BIT_0);
41 REG_MWR(ISP_EDGE_PARAM, BIT_0, 0);
47 static int32_t isp_k_edge_bypass(struct isp_io_param *param)
52 ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
54 printk("isp_k_edge_bypass: copy error, ret=0x%x\n", (uint32_t)ret);
59 REG_OWR(ISP_EDGE_PARAM, BIT_0);
61 REG_MWR(ISP_EDGE_PARAM, BIT_0, 0);
67 static int32_t isp_k_edge_param(struct isp_io_param *param)
71 struct isp_edge_thrd edge_thrd;
73 memset(&edge_thrd, 0x00, sizeof(edge_thrd));
75 ret = copy_from_user((void *)&edge_thrd, param->property_param, sizeof(edge_thrd));
77 printk("isp_k_edge_param: copy error, ret=0x%x\n", (uint32_t)ret);
81 val = ((edge_thrd.strength & 0x3F) << 17)
82 | ((edge_thrd.smooth & 0xFF) << 9)
83 | ((edge_thrd.detail & 0xFF) << 1);
84 REG_MWR(ISP_EDGE_PARAM, 0x7FFFFE, val);
89 int32_t isp_k_cfg_edge(struct isp_io_param *param)
94 printk("isp_k_cfg_edge: param is null error.\n");
98 if (NULL == param->property_param) {
99 printk("isp_k_cfg_edge: property_param is null error.\n");
103 switch (param->property) {
104 case ISP_PRO_EDGE_BLOCK:
105 ret = isp_k_edge_block(param);
107 case ISP_PRO_EDGE_BYPASS:
108 ret = isp_k_edge_bypass(param);
110 case ISP_PRO_EDGE_PARAM:
111 ret = isp_k_edge_param(param);
114 printk("isp_k_cfg_edge: fail cmd id:%d, not supported.\n", param->property);