tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / drivers / media / sprd_isp / isp2.0 / tshark2 / src / isp_k_pre_cdn_rgb.c
1 /*
2  * Copyright (C) 2012 Spreadtrum Communications Inc.
3  *
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.
7  *
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.
12  */
13
14 #include <linux/uaccess.h>
15 #include <linux/sprd_mm.h>
16 #include <video/sprd_isp.h>
17 #include "isp_reg.h"
18
19 static int32_t isp_k_pre_cdn_rgb_block(struct isp_io_param *param)
20 {
21         int32_t ret = 0;
22         uint32_t val = 0;
23         struct isp_dev_pre_cdn_rgb_info pcr_info;
24
25         memset(&pcr_info, 0x00, sizeof(pcr_info));
26
27         ret = copy_from_user((void *)&pcr_info, param->property_param, sizeof(pcr_info));
28         if (0 != ret) {
29                 printk("isp_k_pre_cdn_rgb_block: copy error, ret=0x%x\n", (uint32_t)ret);
30                 return -1;
31         }
32
33         REG_MWR(ISP_PRECNRNEW_CFG, BIT_0, pcr_info.bypass);
34
35         REG_MWR(ISP_PRECNRNEW_CFG, 0x3 << 1, pcr_info.median_mode << 1);
36
37         val = pcr_info.median_thr & 0xFFFF;
38         REG_WR(ISP_PRECNRNEW_MEDIAN_THR, val);
39         val = (pcr_info.thru0 & 0xFFFF) | ((pcr_info.thru1 & 0xFFFF) << 16);
40         REG_WR(ISP_PRECNRNEW_THRU, val);
41         val = (pcr_info.thrv0 & 0xFFFF) | ((pcr_info.thrv1 & 0xFFFF) << 16);
42         REG_WR(ISP_PRECNRNEW_THRV, val);
43
44         return ret;
45
46 }
47
48 int32_t isp_k_cfg_pre_cdn_rgb(struct isp_io_param *param)
49 {
50         int32_t ret = 0;
51
52         if (!param) {
53                 printk("isp_k_cfg_pre_cdn_rgb: param is null error.\n");
54                 return -1;
55         }
56
57         if (NULL == param->property_param) {
58                 printk("isp_k_cfg_pre_cdn_rgb: property_param is null error.\n");
59                 return -1;
60         }
61
62         switch(param->property) {
63         case ISP_PRO_PRE_CDN_RGB_BLOCK:
64                 ret = isp_k_pre_cdn_rgb_block(param);
65                 break;
66         default:
67                 printk("isp_k_cfg_pre_cdn_rgb: fail cmd id:%d, not supported.\n", param->property);
68                 break;
69         }
70
71         return ret;
72 }
73