tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / drivers / media / sprd_isp / isp2.0 / sharkl / src / isp_k_pre_wavelet.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_wavelet_block(struct isp_io_param *param)
20 {
21         int32_t ret = 0;
22         struct isp_dev_pre_wavelet_info pre_wavelet_info;
23
24         memset(&pre_wavelet_info, 0x00, sizeof(pre_wavelet_info));
25
26         ret = copy_from_user((void *)&pre_wavelet_info, param->property_param, sizeof(pre_wavelet_info));
27         if (0 != ret) {
28                 printk("isp_k_pre_wavelet_bypass: copy error, ret=0x%x\n", (uint32_t)ret);
29                 return -1;
30         }
31
32         if (pre_wavelet_info.bypass) {
33                 REG_OWR(ISP_PRE_WAVELET_PARAM, BIT_0);
34         } else {
35                 REG_MWR(ISP_PRE_WAVELET_PARAM, BIT_0, 0);
36         }
37
38         return ret;
39 }
40
41 static int32_t isp_k_pre_wavelet_bypass(struct isp_io_param *param)
42 {
43         int32_t ret = 0;
44         uint32_t bypass = 0;
45
46         ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
47         if (0 != ret) {
48                 printk("isp_k_pre_wavelet_bypass: copy error, ret=0x%x\n", (uint32_t)ret);
49                 return -1;
50         }
51
52         if (bypass) {
53                 REG_OWR(ISP_PRE_WAVELET_PARAM, BIT_0);
54         } else {
55                 REG_MWR(ISP_PRE_WAVELET_PARAM, BIT_0, 0);
56         }
57
58         return ret;
59 }
60
61 int32_t isp_k_cfg_pre_wavelet(struct isp_io_param *param)
62 {
63         int32_t ret = 0;
64
65         if (!param) {
66                 printk("isp_k_cfg_pre_wavelet: param is null error.\n");
67                 return -1;
68         }
69
70         if (NULL == param->property_param) {
71                 printk("isp_k_cfg_pre_wavelet: property_param is null error.\n");
72                 return -1;
73         }
74
75         switch(param->property) {
76         case ISP_PRO_PRE_WAVELET_BLOCK:
77                 ret = isp_k_pre_wavelet_block(param);
78                 break;
79         case ISP_PRO_PRE_WAVELET_BYPASS:
80                 ret = isp_k_pre_wavelet_bypass(param);
81                 break;
82         default:
83                 printk("isp_k_cfg_pre_wavelet: fail cmd id:%d, not supported.\n", param->property);
84                 break;
85         }
86
87         return ret;
88 }