tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / drivers / media / sprd_isp / isp2.0 / tshark2 / src / isp_k_grgb.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
15 #include <linux/uaccess.h>
16 #include <linux/sprd_mm.h>
17 #include <video/sprd_isp.h>
18 #include "isp_reg.h"
19
20 static int32_t isp_k_grgb_block(struct isp_io_param *param)
21 {
22         int32_t ret = 0;
23         uint32_t val = 0;
24         struct isp_dev_grgb_info_v1 grgb_info;
25
26         memset(&grgb_info, 0x00, sizeof(grgb_info));
27
28         ret = copy_from_user((void *)&grgb_info, param->property_param, sizeof(grgb_info));
29         if (0 != ret) {
30                 printk("isp_k_grgb_block: copy error, ret=0x%x\n", (uint32_t)ret);
31                 return -1;
32         }
33
34         REG_MWR(ISP_GRGB_PARAM, BIT_0, grgb_info.bypass);
35
36         val = ((grgb_info.diff & 0x3FF) << 7) | ((grgb_info.edge & 0x3F) << 1);
37         REG_MWR(ISP_GRGB_PARAM, 0x1FFFE, val);
38         val = grgb_info.grid & 0xFFF;
39         REG_MWR(ISP_GRGB_GRID, 0xFFF, val);
40
41         return ret;
42
43 }
44
45 int32_t isp_k_cfg_grgb(struct isp_io_param *param)
46 {
47         int32_t ret = 0;
48
49         if (!param) {
50                 printk("isp_k_cfg_grgb: param is null error.\n");
51                 return -1;
52         }
53
54         if (NULL == param->property_param) {
55                 printk("isp_k_cfg_grgb: property_param is null error.\n");
56                 return -1;
57         }
58
59         switch(param->property) {
60         case ISP_PRO_GRGB_BLOCK:
61                 ret = isp_k_grgb_block(param);
62                 break;
63         default:
64                 printk("isp_k_cfg_grgb: fail cmd id:%d, not supported.\n", param->property);
65                 break;
66         }
67
68         return ret;
69 }
70