summaryrefslogtreecommitdiff
path: root/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_y_gamma.c
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2017-08-30 08:25:59 +0000
committerYuval Adam <_@yuv.al>2017-08-30 08:25:59 +0000
commit8e4bff4cab0ddac6060645b0715210484d02ff40 (patch)
tree3a5c3024371a04692a3a6d9974d001cdff8ebf84 /drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_y_gamma.c
Initial file dump from open source releaseHEADmaster
Diffstat (limited to 'drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_y_gamma.c')
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_y_gamma.c121
1 files changed, 121 insertions, 0 deletions
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_y_gamma.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_y_gamma.c
new file mode 100644
index 00000000..cc485740
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_y_gamma.c
@@ -0,0 +1,121 @@
+/*
+ * 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 (ISP_YUV_YGAMMA_BUF0 == isp_private->yuv_ygamma_buf_id) {
+ ybuf_addr = ISP_YGAMMA_BUF1_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;
+ }
+
+ 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;
+}