diff options
| author | Yuval Adam <_@yuv.al> | 2017-08-30 08:25:59 +0000 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2017-08-30 08:25:59 +0000 |
| commit | 8e4bff4cab0ddac6060645b0715210484d02ff40 (patch) | |
| tree | 3a5c3024371a04692a3a6d9974d001cdff8ebf84 /drivers/media/sprd_isp/isp2.0/pike/src/isp_k_y_gamma.c | |
Diffstat (limited to 'drivers/media/sprd_isp/isp2.0/pike/src/isp_k_y_gamma.c')
| -rw-r--r-- | drivers/media/sprd_isp/isp2.0/pike/src/isp_k_y_gamma.c | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_y_gamma.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_y_gamma.c new file mode 100644 index 00000000..ea66f99d --- /dev/null +++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_y_gamma.c @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2012 Spreadtrum Communications Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <linux/uaccess.h> +#include <linux/sprd_mm.h> +#include <video/sprd_isp.h> +#include "isp_reg.h" +#include "isp_drv.h" + + +#define ISP_YUV_YGAMMA_BUF0 0 +#define ISP_YUV_YGAMMA_BUF1 1 + +static int32_t isp_k_pingpang_yuv_ygamma(struct coordinate_xy *nodes, + struct isp_k_private *isp_private) +{ + int32_t ret = 0; + uint32_t i = 0, j = 0; + unsigned long ybuf_addr = 0; + struct coordinate_xy *p_nodes = NULL; + + if (!nodes) { + ret = -1; + printk("isp_k_pingpang_yuv_ygamma: node is null error .\n"); + return ret; + } + p_nodes = nodes; + +#if 0 + if (ISP_YUV_YGAMMA_BUF0 == isp_private->yuv_ygamma_buf_id) { + ybuf_addr = ISP_YGAMMA_BUF0_CH0; + isp_private->yuv_ygamma_buf_id = ISP_YUV_YGAMMA_BUF1; + } else { + ybuf_addr = ISP_YGAMMA_BUF0_CH0; + isp_private->yuv_ygamma_buf_id = ISP_YUV_YGAMMA_BUF0; + } +#endif + + isp_private->yuv_ygamma_buf_id = ISP_YUV_YGAMMA_BUF0; + if (isp_private->yuv_ygamma_buf_id) { + REG_OWR(ISP_YGAMMA_PARAM, BIT_1); + } else { + REG_MWR(ISP_YGAMMA_PARAM, BIT_1, 0); + } + + ybuf_addr = ISP_YGAMMA_BUF0_CH0; + isp_private->yuv_ygamma_buf_id = ISP_YUV_YGAMMA_BUF1; + + for (i = 0, j = 0; i < ISP_PINGPANG_YUV_YGAMMA_NUM; i++, j += 4) { + REG_WR(ybuf_addr + j, p_nodes[i].node_y & 0xff); + } + + if (isp_private->yuv_ygamma_buf_id) { + REG_OWR(ISP_YGAMMA_PARAM, BIT_1); + } else { + REG_MWR(ISP_YGAMMA_PARAM, BIT_1, 0); + } + + return ret; +} + +static int32_t isp_k_ygamma_block(struct isp_io_param *param, + struct isp_k_private *isp_private) +{ + int32_t ret = 0; + uint32_t bypass; + struct isp_dev_ygamma_info *ygamma_info = (struct isp_dev_ygamma_info *)param->property_param; + struct coordinate_xy *nodes = NULL; + + nodes = (struct coordinate_xy *)isp_private->yuv_ygamma_buf_addr; + if (!nodes) { + ret = -1; + printk("isp_k_ygamma_block: alloc memory error.\n"); + return -1; + } + + ret = copy_from_user((void *)&bypass, (void *)&ygamma_info->bypass, sizeof(uint32_t)); + if (0 != ret) { + printk("isp_k_ygamma_block: copy bypass error, ret=0x%x\n", (uint32_t)ret); + return -1; + } + ret = copy_from_user((void *)nodes, (void *)ygamma_info->nodes, ISP_YUV_YGAMMA_BUF_SIZE); + if (0 != ret) { + printk("isp_k_ygamma_block: copy nodes error, ret=0x%x\n", (uint32_t)ret); + return -1; + } + + ret = isp_k_pingpang_yuv_ygamma(nodes, isp_private); + if (0 != ret) { + printk("isp_k_ygamma_block: pingpang error, ret=0x%x\n", (uint32_t)ret); + return -1; + } + REG_MWR(ISP_YGAMMA_PARAM, BIT_0, bypass); + + return ret; +} + +int32_t isp_k_cfg_ygamma(struct isp_io_param *param, + struct isp_k_private *isp_private) +{ + int32_t ret = 0; + + if (!param) { + printk("isp_k_cfg_ygamma: param is null error.\n"); + return -1; + } + + if (NULL == param->property_param) { + printk("isp_k_cfg_ygamma: property_param is null error.\n"); + return -1; + } + + switch(param->property) { + case ISP_PRO_YGAMMA_BLOCK: + ret = isp_k_ygamma_block(param, isp_private); + break; + default: + printk("isp_k_cfg_ygamma: fail cmd id:%d, not supported.\n", param->property); + break; + } + + return ret; +} |
