summaryrefslogtreecommitdiff
path: root/drivers/media/sprd_isp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/sprd_isp')
-rw-r--r--drivers/media/sprd_isp/Kconfig10
-rw-r--r--drivers/media/sprd_isp/Makefile186
-rw-r--r--drivers/media/sprd_isp/Shark_reg_isp.h70
-rwxr-xr-xdrivers/media/sprd_isp/compat_isp_drv.c356
-rw-r--r--drivers/media/sprd_isp/compat_isp_drv.h23
-rw-r--r--drivers/media/sprd_isp/compat_isp_drv_kernel.c327
-rw-r--r--drivers/media/sprd_isp/compat_isp_drv_kernel.h26
-rw-r--r--drivers/media/sprd_isp/isp1.0/Shark_reg_isp.h70
-rw-r--r--drivers/media/sprd_isp/isp1.0/Tiger_reg_isp.h91
-rw-r--r--drivers/media/sprd_isp/isp1.0/compat_isp_drv_kernel.c327
-rw-r--r--drivers/media/sprd_isp/isp1.0/compat_isp_drv_kernel.h26
-rw-r--r--drivers/media/sprd_isp/isp1.0/isp_drv_kernel.c1494
-rw-r--r--drivers/media/sprd_isp/isp1.0/isp_drv_null.c305
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/inc/isp_block.h72
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/inc/isp_drv.h94
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/inc/isp_reg.h801
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_cfg_param.c133
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_1d_lsc.c146
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_2d_lsc.c537
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_aca.c78
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_anti_flicker.c155
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_arbiter.c177
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_awb.c191
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_bdn.c121
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_binning4awb.c231
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_blc.c66
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_bpc.c101
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_brightness.c67
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_capability.c195
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cce.c147
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cdn.c109
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cfa.c90
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cmc10.c93
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cmc8.c92
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_common.c411
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_contrast.c67
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_csa.c68
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_csc.c114
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_css.c112
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_ct.c92
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_dispatch.c143
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_edge.c128
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_emboss.c74
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_fetch.c127
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_gamma.c143
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_grgb.c70
-rwxr-xr-xdrivers/media/sprd_isp/isp2.0/pike/src/isp_k_hdr.c142
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hist.c131
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hist2.c95
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hsv.c95
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hua.c68
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_isr.c101
-rwxr-xr-xdrivers/media/sprd_isp/isp2.0/pike/src/isp_k_nlc.c83
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_nlm.c202
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pgg.c67
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_post_cdn.c129
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pre_cdn.c135
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pre_cdn_rgb.c73
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_prefilter.c73
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pstrz.c71
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pwd.c123
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_raw_aem.c255
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_raw_afm.c497
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb2y.c62
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb_afm.c415
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb_gain.c69
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb_gain2.c67
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_store.c101
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_uv_prefilter.c68
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_y_delay.c63
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_y_gamma.c133
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_yiq_aem.c121
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_yiq_afm.c120
-rw-r--r--drivers/media/sprd_isp/isp2.0/pike/src/isp_k_yuv_nlm.c135
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/inc/isp_block.h67
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/inc/isp_drv.h95
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/inc/isp_reg.h676
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_cfg_param.c131
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_1d_lsc.c146
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_2d_lsc.c537
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_aca.c78
-rwxr-xr-xdrivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_anti_flicker.c150
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_arbiter.c177
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_awb.c192
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_bdn.c121
-rwxr-xr-xdrivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_binning4awb.c249
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_blc.c66
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_bpc.c101
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_brightness.c67
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_capability.c202
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cce.c147
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cdn.c109
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cfa.c90
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cmc10.c93
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cmc8.c92
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_common.c533
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_contrast.c67
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_csa.c68
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_csc.c114
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_css.c112
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_ct.c98
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_dispatch.c143
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_edge.c126
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_emboss.c74
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_fetch.c126
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_gamma.c131
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_grgb.c70
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hist.c131
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hist2.c94
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hsv.c95
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hua.c68
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_iircnr.c133
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_isr.c102
-rwxr-xr-xdrivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_nlc.c83
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_nlm.c250
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pgg.c67
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_post_cdn.c128
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pre_cdn.c135
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pre_cdn_rgb.c73
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_prefilter.c73
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pstrz.c71
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pwd.c123
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_raw_aem.c255
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_raw_afm.c497
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_raw_sizer.c369
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_rgb_gain.c69
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_rgb_gain2.c69
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_store.c101
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_y_delay.c63
-rw-r--r--drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_y_gamma.c121
-rwxr-xr-xdrivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_yiq_aem.c256
-rwxr-xr-xdrivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_yiq_afm.c193
-rw-r--r--drivers/media/sprd_isp/isp_drv.c1800
133 files changed, 22917 insertions, 0 deletions
diff --git a/drivers/media/sprd_isp/Kconfig b/drivers/media/sprd_isp/Kconfig
new file mode 100644
index 00000000..92c45005
--- /dev/null
+++ b/drivers/media/sprd_isp/Kconfig
@@ -0,0 +1,10 @@
+menu "SoC Video for the SPREADTRUM SC88XX"
+
+config SND_SC88XX_SOC_SPRDPHONE
+ tristate "sprdphone -- SoC Audio for the SPREADTRUM SC88XX chips with intergrated VBC codec"
+# depends on ARCH_SC8800S
+ select SND_PCM
+ help
+ Say Y if you want to built in to kernel, Say M for ko module.
+
+endmenu
diff --git a/drivers/media/sprd_isp/Makefile b/drivers/media/sprd_isp/Makefile
new file mode 100644
index 00000000..d9f2fb31
--- /dev/null
+++ b/drivers/media/sprd_isp/Makefile
@@ -0,0 +1,186 @@
+include drivers/media/sprd_dcam/common/Makefile.inc
+#ccflags-y += -Idrivers/media/sprd_dcam/common
+
+tshark2_isp_like:=0
+
+ifeq ($(CONFIG_MACH_SP9830IEA_5M_H100),y)
+tshark2_isp_like=1
+endif
+
+ifeq ($(CONFIG_MACH_SP9830IEB_5M_H100),y)
+tshark2_isp_like=1
+endif
+
+ifeq ($(CONFIG_MACH_SP9830IEC_4M_H100),y)
+tshark2_isp_like=1
+endif
+
+ifeq ($(CONFIG_MACH_SP7720EA),y)
+pike_isp_like=1
+endif
+
+ifeq ($(CONFIG_ARCH_SCX30G2),y)
+tshark2_isp_like=1
+endif
+
+ifeq ($(CONFIG_ARCH_SCX35LT8),y)
+tshark2_isp_like=1
+endif
+
+ifeq ($(CONFIG_MACH_SHARKLS_Z3LTE),y)
+tshark2_isp_like=1
+endif
+
+obj-y += sprd_isp.o
+ccflags-y += -Idrivers/media/sprd_dcam/common
+
+
+ifeq ($(CONFIG_ARCH_SCX35),y)
+
+ifeq ($(CONFIG_ARCH_SCX15),y)
+sprd_isp-objs := isp1.0/isp_drv_null.o
+
+else ifeq ($(strip $(tshark2_isp_like)),1)
+ccflags-y += -Idrivers/media/sprd_isp/isp2.0/tshark2/inc
+
+sprd_isp-objs := isp_drv.o \
+ isp2.0/tshark2/src/isp_cfg_param.o \
+ isp2.0/tshark2/src/isp_k_capability.o \
+ isp2.0/tshark2/src/isp_k_isr.o \
+ isp2.0/tshark2/src/isp_k_pgg.o \
+ isp2.0/tshark2/src/isp_k_blc.o \
+ isp2.0/tshark2/src/isp_k_rgb_gain.o \
+ isp2.0/tshark2/src/isp_k_pwd.o \
+ isp2.0/tshark2/src/isp_k_nlc.o \
+ isp2.0/tshark2/src/isp_k_2d_lsc.o \
+ isp2.0/tshark2/src/isp_k_1d_lsc.o \
+ isp2.0/tshark2/src/isp_k_binning4awb.o \
+ isp2.0/tshark2/src/isp_k_awb.o \
+ isp2.0/tshark2/src/isp_k_raw_aem.o \
+ isp2.0/tshark2/src/isp_k_bpc.o \
+ isp2.0/tshark2/src/isp_k_bdn.o \
+ isp2.0/tshark2/src/isp_k_grgb.o \
+ isp2.0/tshark2/src/isp_k_rgb_gain2.o \
+ isp2.0/tshark2/src/isp_k_nlm.o \
+ isp2.0/tshark2/src/isp_k_cfa.o \
+ isp2.0/tshark2/src/isp_k_cmc10.o \
+ isp2.0/tshark2/src/isp_k_gamma.o \
+ isp2.0/tshark2/src/isp_k_cmc8.o \
+ isp2.0/tshark2/src/isp_k_ct.o \
+ isp2.0/tshark2/src/isp_k_cce.o \
+ isp2.0/tshark2/src/isp_k_hsv.o \
+ isp2.0/tshark2/src/isp_k_csc.o \
+ isp2.0/tshark2/src/isp_k_pre_cdn_rgb.o \
+ isp2.0/tshark2/src/isp_k_pstrz.o \
+ isp2.0/tshark2/src/isp_k_raw_afm.o \
+ isp2.0/tshark2/src/isp_k_yiq_aem.o \
+ isp2.0/tshark2/src/isp_k_anti_flicker.o \
+ isp2.0/tshark2/src/isp_k_yiq_afm.o \
+ isp2.0/tshark2/src/isp_k_pre_cdn.o \
+ isp2.0/tshark2/src/isp_k_prefilter.o \
+ isp2.0/tshark2/src/isp_k_brightness.o \
+ isp2.0/tshark2/src/isp_k_contrast.o \
+ isp2.0/tshark2/src/isp_k_hist.o \
+ isp2.0/tshark2/src/isp_k_hist2.o \
+ isp2.0/tshark2/src/isp_k_aca.o \
+ isp2.0/tshark2/src/isp_k_cdn.o \
+ isp2.0/tshark2/src/isp_k_edge.o \
+ isp2.0/tshark2/src/isp_k_css.o \
+ isp2.0/tshark2/src/isp_k_csa.o \
+ isp2.0/tshark2/src/isp_k_hua.o \
+ isp2.0/tshark2/src/isp_k_post_cdn.o \
+ isp2.0/tshark2/src/isp_k_emboss.o \
+ isp2.0/tshark2/src/isp_k_y_gamma.o \
+ isp2.0/tshark2/src/isp_k_y_delay.o \
+ isp2.0/tshark2/src/isp_k_iircnr.o \
+ isp2.0/tshark2/src/isp_k_fetch.o \
+ isp2.0/tshark2/src/isp_k_store.o \
+ isp2.0/tshark2/src/isp_k_dispatch.o \
+ isp2.0/tshark2/src/isp_k_arbiter.o \
+ isp2.0/tshark2/src/isp_k_raw_sizer.o \
+ isp2.0/tshark2/src/isp_k_common.o
+
+ifeq ($(CONFIG_64BIT),y)
+sprd_isp-objs += compat_isp_drv.o
+endif
+
+else ifeq ($(strip $(pike_isp_like)),1)
+ccflags-y += -Idrivers/media/sprd_isp/isp2.0/pike/inc
+
+sprd_isp-objs := isp_drv.o \
+ isp2.0/pike/src/isp_cfg_param.o \
+ isp2.0/pike/src/isp_k_capability.o \
+ isp2.0/pike/src/isp_k_isr.o \
+ isp2.0/pike/src/isp_k_pgg.o \
+ isp2.0/pike/src/isp_k_blc.o \
+ isp2.0/pike/src/isp_k_rgb_gain.o \
+ isp2.0/pike/src/isp_k_pwd.o \
+ isp2.0/pike/src/isp_k_nlc.o \
+ isp2.0/pike/src/isp_k_2d_lsc.o \
+ isp2.0/pike/src/isp_k_1d_lsc.o \
+ isp2.0/pike/src/isp_k_binning4awb.o \
+ isp2.0/pike/src/isp_k_awb.o \
+ isp2.0/pike/src/isp_k_raw_aem.o \
+ isp2.0/pike/src/isp_k_bpc.o \
+ isp2.0/pike/src/isp_k_bdn.o \
+ isp2.0/pike/src/isp_k_grgb.o \
+ isp2.0/pike/src/isp_k_rgb_gain2.o \
+ isp2.0/pike/src/isp_k_nlm.o \
+ isp2.0/pike/src/isp_k_cfa.o \
+ isp2.0/pike/src/isp_k_cmc10.o \
+ isp2.0/pike/src/isp_k_gamma.o \
+ isp2.0/pike/src/isp_k_cmc8.o \
+ isp2.0/pike/src/isp_k_ct.o \
+ isp2.0/pike/src/isp_k_cce.o \
+ isp2.0/pike/src/isp_k_hsv.o \
+ isp2.0/pike/src/isp_k_csc.o \
+ isp2.0/pike/src/isp_k_pre_cdn_rgb.o \
+ isp2.0/pike/src/isp_k_pstrz.o \
+ isp2.0/pike/src/isp_k_raw_afm.o \
+ isp2.0/pike/src/isp_k_yiq_aem.o \
+ isp2.0/pike/src/isp_k_anti_flicker.o \
+ isp2.0/pike/src/isp_k_yiq_afm.o \
+ isp2.0/pike/src/isp_k_pre_cdn.o \
+ isp2.0/pike/src/isp_k_prefilter.o \
+ isp2.0/pike/src/isp_k_brightness.o \
+ isp2.0/pike/src/isp_k_contrast.o \
+ isp2.0/pike/src/isp_k_hist.o \
+ isp2.0/pike/src/isp_k_hist2.o \
+ isp2.0/pike/src/isp_k_aca.o \
+ isp2.0/pike/src/isp_k_cdn.o \
+ isp2.0/pike/src/isp_k_edge.o \
+ isp2.0/pike/src/isp_k_css.o \
+ isp2.0/pike/src/isp_k_csa.o \
+ isp2.0/pike/src/isp_k_hua.o \
+ isp2.0/pike/src/isp_k_post_cdn.o \
+ isp2.0/pike/src/isp_k_emboss.o \
+ isp2.0/pike/src/isp_k_y_gamma.o \
+ isp2.0/pike/src/isp_k_y_delay.o \
+ isp2.0/pike/src/isp_k_fetch.o \
+ isp2.0/pike/src/isp_k_store.o \
+ isp2.0/pike/src/isp_k_dispatch.o \
+ isp2.0/pike/src/isp_k_arbiter.o \
+ isp2.0/pike/src/isp_k_hdr.o \
+ isp2.0/pike/src/isp_k_rgb2y.o \
+ isp2.0/pike/src/isp_k_uv_prefilter.o \
+ isp2.0/pike/src/isp_k_yuv_nlm.o \
+ isp2.0/pike/src/isp_k_common.o
+
+else
+ccflags-y += -Idrivers/media/sprd_isp/isp1.0
+sprd_isp-objs := isp1.0/isp_drv_kernel.o
+ifeq ($(CONFIG_64BIT),y)
+sprd_isp-objs += isp1.0/compat_isp_drv_kernel.o
+endif
+endif
+
+endif
+
+ifeq ($(CONFIG_ARCH_SC8825),y)
+ccflags-y += -Idrivers/media/sprd_isp/isp1.0
+sprd_isp-objs := isp1.0/isp_drv_kernel.o
+endif
+
+obj-y += sprd_isp.o
+
+
diff --git a/drivers/media/sprd_isp/Shark_reg_isp.h b/drivers/media/sprd_isp/Shark_reg_isp.h
new file mode 100644
index 00000000..6b99f9ea
--- /dev/null
+++ b/drivers/media/sprd_isp/Shark_reg_isp.h
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+#ifndef _TIGER_REG_ISP_H_
+#define _TIGER_REG_ISP_H_
+#ifndef CONFIG_64BIT
+#include <soc/sprd/globalregs.h>
+#else
+#include <soc/sprd/irqs.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+
+#define ISP_DCAM_BASE DCAM_BASE
+#define ISP_DCAM_INT_STS (ISP_DCAM_BASE + 0x003CUL)
+#define ISP_DCAM_INT_CLR (ISP_DCAM_BASE + 0x0044UL)
+
+#define ISP_BASE_ADDR ISP_BASE
+#define ISP_LNC_STATUS (ISP_BASE_ADDR+0x0200UL)
+#define ISP_LNC_LOAD (ISP_BASE_ADDR+0x0220UL)
+#define ISP_AXI_MASTER (ISP_BASE_ADDR+0x2000UL)
+#define ISP_INT_RAW (ISP_BASE_ADDR+0x2080UL)
+#define ISP_INT_STATUS (ISP_BASE_ADDR+0x2084UL)
+#define ISP_INT_EN (ISP_BASE_ADDR+0x2078UL)
+#define ISP_INT_CLEAR (ISP_BASE_ADDR+0x207cUL)
+#define ISP_REG_MAX_SIZE SPRD_ISP_SIZE
+#define ISP_AXI_MASTER_STOP (ISP_BASE_ADDR + 0X2054UL)
+
+#define ISP_AHB_BASE SPRD_MMAHB_BASE
+#define ISP_MODULE_EB (ISP_AHB_BASE + 0x0000UL)
+#define ISP_MODULE_RESET (ISP_AHB_BASE + 0x0004UL)
+#define ISP_CORE_CLK_EB (ISP_AHB_BASE + 0x0008UL)
+
+#define ISP_CLOCK_BASE SPRD_MMCKG_BASE
+#define ISP_CLOCK (ISP_CLOCK_BASE + 0X34)
+
+
+/*irq line number in system*/
+#define ISP_IRQ IRQ_ISP_INT
+
+#define ISP_EB_BIT BIT_2
+#define ISP_RST_LOG_BIT BIT_2
+#define ISP_RST_CFG_BIT BIT_3
+#define ISP_CORE_CLK_EB_BIT BIT_4
+#define ISP_AXI_MASTER_STOP_BIT BIT_0
+
+#define ISP_IRQ_HW_MASK_V0001 (0x1fffffff)
+#define ISP_IRQ_NUM_V0001 (29)
+#define ISP_TMP_BUF_SIZE_MAX_V0001 (32 * 1024)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //_TIGER_REG_ISP_H_
diff --git a/drivers/media/sprd_isp/compat_isp_drv.c b/drivers/media/sprd_isp/compat_isp_drv.c
new file mode 100755
index 00000000..497ae777
--- /dev/null
+++ b/drivers/media/sprd_isp/compat_isp_drv.c
@@ -0,0 +1,356 @@
+/*
+ * 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/compat.h>
+#include <linux/fs.h>
+#include <linux/uaccess.h>
+#include <video/sprd_isp.h>
+#include "compat_isp_drv.h"
+
+
+struct compat_isp_capability {
+ uint32_t isp_id;
+ uint32_t index;
+ compat_uptr_t property_param;
+};
+
+struct compat_isp_io_param {
+ uint32_t isp_id;
+ uint32_t sub_block;
+ uint32_t property;
+ compat_uptr_t property_param;
+};
+
+struct compat_isp_reg_param {
+ compat_ulong_t reg_param;
+ uint32_t counts;
+};
+
+struct compat_isp_reg_bits {
+ compat_ulong_t reg_addr;
+ compat_ulong_t reg_value;
+};
+
+
+#define COMPAT_ISP_IO_CAPABILITY _IOR(ISP_IO_MAGIC, 0, struct compat_isp_capability)
+#define COMPAT_ISP_IO_READ _IOR(ISP_IO_MAGIC, 2, struct compat_isp_reg_param)
+#define COMPAT_ISP_IO_WRITE _IOW(ISP_IO_MAGIC, 3, struct compat_isp_reg_param)
+#define CAMPAT_ISP_IO_CFG_PARAM _IOWR(ISP_IO_MAGIC, 7, struct compat_isp_io_param)
+#define CAMPAT_ISP_REG_READ _IOR(ISP_IO_MAGIC, 8, struct compat_isp_reg_bits)
+
+
+static int compat_get_capability_param(
+ struct compat_isp_capability __user *data32,
+ struct isp_capability __user *data)
+{
+ int err = 0;
+ uint32_t tmp;
+ compat_uptr_t parm;
+
+ err = get_user(tmp, &data32->isp_id);
+ err |= put_user(tmp, &data->isp_id);
+ err |= get_user(tmp, &data32->index);
+ err |= put_user(tmp, &data->index);
+ err |= get_user(parm, &data32->property_param);
+ err |= put_user(parm, &data->property_param);
+
+ return err;
+}
+
+static int compat_get_cfg_param(
+ struct compat_isp_io_param __user *data32,
+ struct isp_io_param __user *data)
+{
+ int err =0;
+ uint32_t tmp;
+ compat_uptr_t parm;
+
+ err = get_user(tmp, &data32->isp_id);
+ err |= put_user(tmp, &data->isp_id);
+ err |= get_user(tmp, &data32->sub_block);
+ err |= put_user(tmp, &data->sub_block);
+ err |= get_user(tmp, &data32->property);
+ err |= put_user(tmp, &data->property);
+ err |= get_user(parm, &data32->property_param);
+ err |= put_user(parm, &data->property_param);
+
+ return err;
+}
+
+static int compat_get_rw_param(
+ struct compat_isp_reg_param __user *data32,
+ struct isp_reg_param __user *data)
+{
+ int err = 0;
+ compat_ulong_t addr;
+ uint32_t cnt;
+
+ err = get_user(addr, &data32->reg_param);
+ err |= put_user(addr, &data->reg_param);
+ err |= get_user(cnt, &data32->counts);
+ err |= put_user(cnt, &data->counts);
+
+ return err;
+}
+
+static int compat_get_rw_param_detail(
+ struct isp_reg_param __user *data)
+
+{
+ int err = 0;
+ int i;
+ int cnt;
+ compat_ulong_t addr;
+ compat_ulong_t val;
+ struct compat_isp_reg_bits __user *data32;
+ struct isp_reg_bits __user *reg_data;
+ struct isp_reg_bits __user *data_tmp;
+
+ if (NULL == data) {
+ printk("compat_get_rw_param_detail: data is NULL.\n");
+ return -EFAULT;
+ }
+
+ cnt = data->counts;
+ data32 = compat_ptr(data->reg_param);
+ reg_data = (struct isp_reg_bits __user *)((unsigned long)data + sizeof(struct isp_reg_param));
+ data->reg_param = reg_data;
+ if (NULL == reg_data) {
+ printk("compat_get_rw_param_detail: reg_data is NULL.\n");
+ return -EFAULT;
+ }
+
+ data_tmp = reg_data;
+ for (i = 0; i < cnt; i++) {
+ err = get_user(addr, &data32->reg_addr);
+ err |= put_user(addr, &data_tmp->reg_addr);
+ err |= get_user(val, &data32->reg_value);
+ err |= put_user(val, &data_tmp->reg_value);
+ if (err) {
+ printk("compat_get_rw_param_detail: failed to get register addr&val cnt %d err %d\n", cnt, err);
+ break;
+ }
+ data32++;
+ data_tmp++;
+ }
+
+ return err;
+}
+
+static int compat_put_read_param(
+ struct compat_isp_reg_param __user *data32,
+ struct isp_reg_param __user *data)
+
+{
+ int err = 0;
+ int i;
+ int cnt;
+ compat_ulong_t val;
+ struct compat_isp_reg_bits __user *reg_data32;
+ struct isp_reg_bits __user *reg_data;
+
+ cnt = data->counts;
+ reg_data32 = (struct compat_isp_reg_bits __user *)data32->reg_param;
+ reg_data = (struct isp_reg_bits __user *)data->reg_param;
+ for (i = 0; i < cnt; i++) {
+ err = get_user(val, &reg_data->reg_value);
+ err |= put_user(val, &reg_data32->reg_value);
+ if (err) {
+ printk("compat_put_read_param: failed to get register val err %d\n", err);
+ break;
+ }
+ reg_data32++;
+ reg_data++;
+ }
+
+ return err;
+}
+
+long compat_isp_ioctl(struct file *file, unsigned int cmd, unsigned long param)
+{
+ long ret;
+ int err = 0;
+ void __user *up = compat_ptr(param);
+
+ if (!file->f_op || !file->f_op->unlocked_ioctl)
+ return -ENOTTY;
+
+ switch (cmd) {
+ case ISP_IO_IRQ:
+ case ISP_IO_RST:
+ case ISP_IO_STOP:
+ case ISP_IO_INT:
+ ret = file->f_op->unlocked_ioctl(file, cmd, (unsigned long)up);
+ break;
+
+ case COMPAT_ISP_IO_CAPABILITY:
+ {
+ struct compat_isp_capability __user *data32;
+ struct isp_capability __user *data;
+
+ data32 = compat_ptr(param);
+ data = compat_alloc_user_space(sizeof(*data));
+ if (NULL == data) {
+ printk("compat_isp_ioctl: failed to compat_alloc_user_space.\n");
+ return -EFAULT;
+ }
+
+ err = compat_get_capability_param(data32, data);
+ if (err) {
+ printk("compat_isp_ioctl: failed to get capability param.\n");
+ return err;
+ }
+
+ ret = file->f_op->unlocked_ioctl(file, ISP_IO_CAPABILITY, (unsigned long)data);
+ break;
+ }
+
+ case COMPAT_ISP_IO_READ:
+ {
+ struct compat_isp_reg_param __user *data32;
+ struct isp_reg_param __user *data;
+ uint32_t cnt;
+
+ data32 = compat_ptr(param);
+ err = get_user(cnt, &data32->counts);
+
+ data = compat_alloc_user_space(sizeof(struct isp_reg_param) + cnt*sizeof(struct isp_reg_bits));
+ if (NULL == data) {
+ printk("compat_isp_ioctl: failed to compat_alloc_user_space.\n");
+ return -EFAULT;
+ }
+
+ err = compat_get_rw_param(data32, data);
+ if (err) {
+ printk("compat_isp_ioctl: failed to get isp_reg_param.\n");
+ return err;
+ }
+
+ err = compat_get_rw_param_detail(data);
+ if (err) {
+ printk("compat_isp_ioctl: failed to get isp_reg_param detail.\n");
+ return err;
+ }
+
+ ret = file->f_op->unlocked_ioctl(file, ISP_IO_READ, (unsigned long)data);
+ err = compat_put_read_param(data32, data);
+ ret = ret ? ret : err;
+ break;
+ }
+
+ case CAMPAT_ISP_REG_READ:
+ {
+ struct compat_isp_reg_bits __user *data32;
+ struct isp_reg_bits __user *data;
+ unsigned long reg_cnt = 20467;
+ compat_ulong_t addr;
+ compat_ulong_t val;
+ int i;
+ int err = 0;
+
+ data32 = compat_ptr(param);
+ data = compat_alloc_user_space(reg_cnt * sizeof(struct isp_reg_bits));
+ if (NULL == data) {
+ printk("compat_isp_ioctl: CAMPAT_ISP_REG_READ:failed to compat_alloc_user_space.\n");
+ return -EFAULT;
+ }
+
+ ret = file->f_op->unlocked_ioctl(file, ISP_REG_READ, (unsigned long)data);
+ for (i = 0; i < reg_cnt; i++) {
+ err = get_user(val, &data->reg_value);
+ err |= put_user(val, &data32->reg_value);
+ if (err) {
+ printk("compat_put_read_param: CAMPAT_ISP_REG_READ:failed to get reg_value%d\n", err);
+ break;
+ }
+
+ err = get_user(val, &data->reg_addr);
+ err |= put_user(val, &data32->reg_addr);
+ if (err) {
+ printk("compat_put_read_param: CAMPAT_ISP_REG_READ:failed to get reg_addr%d\n", err);
+ break;
+ }
+
+ data32++;
+ data++;
+ }
+ ret = ret ? ret : err;
+ break;
+ }
+
+ case COMPAT_ISP_IO_WRITE:
+ {
+ struct compat_isp_reg_param __user *data32;
+ struct isp_reg_param __user *data;
+ uint32_t cnt;
+
+ data32 = compat_ptr(param);
+ err = get_user(cnt, &data32->counts);
+ if (err) {
+ printk("compat_isp_ioctl: failed to get register count.\n");
+ return err;
+ }
+
+ data = compat_alloc_user_space(sizeof(struct isp_reg_param) + cnt*sizeof(struct isp_reg_bits));
+ if (NULL == data) {
+ printk("compat_isp_ioctl: failed to compat_alloc_user_space.\n");
+ return -EFAULT;
+ }
+
+ err = compat_get_rw_param(data32, data);
+ if (err) {
+ printk("compat_isp_ioctl: failed to get isp_reg_param.\n");
+ return err;
+ }
+
+ err = compat_get_rw_param_detail(data);
+ if (err) {
+ printk("compat_isp_ioctl: failed to get isp_reg_param detail.\n");
+ return err;
+ }
+
+ ret = file->f_op->unlocked_ioctl(file, ISP_IO_WRITE, (unsigned long)data);
+ break;
+ }
+
+ case CAMPAT_ISP_IO_CFG_PARAM:
+ {
+ struct compat_isp_io_param __user *data32;
+ struct isp_io_param __user *data;
+
+ data32 = compat_ptr(param);
+ data = compat_alloc_user_space(sizeof(*data));
+ if (NULL == data) {
+ printk("compat_isp_ioctl: failed to compat_alloc_user_space.\n");
+ return -EFAULT;
+ }
+
+ err = compat_get_cfg_param(data32, data);
+ if (err) {
+ printk("compat_isp_ioctl: failed to get cfg param.\n");
+ return err;
+ }
+
+ ret = file->f_op->unlocked_ioctl(file, ISP_IO_CFG_PARAM, (unsigned long)data);
+ break;
+ }
+
+ default:
+ printk("compat_isp_ioctl, don't support cmd 0x%x", cmd);
+ break;
+ }
+
+exit:
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/compat_isp_drv.h b/drivers/media/sprd_isp/compat_isp_drv.h
new file mode 100644
index 00000000..cda56912
--- /dev/null
+++ b/drivers/media/sprd_isp/compat_isp_drv.h
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+#ifndef _COMPAT_ISP_DRV_H_
+#define _COMPAT_ISP_DRV_H_
+
+#if IS_ENABLED(CONFIG_COMPAT)
+long compat_isp_ioctl(struct file *file, unsigned int cmd, unsigned long param);
+#else
+#define compat_isp_ioctl NULL
+#endif /* CONFIG_COMPAT */
+
+#endif
diff --git a/drivers/media/sprd_isp/compat_isp_drv_kernel.c b/drivers/media/sprd_isp/compat_isp_drv_kernel.c
new file mode 100644
index 00000000..ae0ad4f0
--- /dev/null
+++ b/drivers/media/sprd_isp/compat_isp_drv_kernel.c
@@ -0,0 +1,327 @@
+#include <linux/compat.h>
+#include <linux/fs.h>
+#include <linux/uaccess.h>
+#include <video/isp_drv_kernel.h>
+#include "compat_isp_drv_kernel.h"
+
+struct compat_isp_irq_param {
+ compat_uint_t isp_irq_val;
+ compat_uint_t dcam_irq_val;
+ compat_uint_t irq_val;
+ compat_int_t ret_val;
+};
+
+struct compat_isp_reg_bits {
+ compat_ulong_t reg_addr;
+ compat_ulong_t reg_value;
+} ;
+
+struct compat_isp_reg_param {
+ compat_ulong_t reg_param;
+ uint32_t counts;
+} ;
+
+
+#define COMPAT_ISP_IO_READ _IOR(ISP_IO_MAGIC, 1, struct compat_isp_reg_param)
+#define COMPAT_ISP_IO_WRITE _IOW(ISP_IO_MAGIC, 2, struct compat_isp_reg_param)
+#define COMPAT_ISP_IO_LNC_PARAM _IOW(ISP_IO_MAGIC, 8, struct compat_isp_reg_param)
+#define COMPAT_ISP_IO_LNC _IOW(ISP_IO_MAGIC, 9, struct compat_isp_reg_param)
+#define COMPAT_ISP_IO_ALLOC _IOW(ISP_IO_MAGIC, 10, struct compat_isp_reg_param)
+
+
+static int compat_get_rw_param(
+ struct compat_isp_reg_param __user *data32,
+ struct isp_reg_param __user *data)
+{
+ int err = 0;
+ compat_ulong_t addr;
+ uint32_t cnt;
+
+ err = get_user(addr, &data32->reg_param);
+ err |= put_user(addr, &data->reg_param);
+ err |= get_user(cnt, &data32->counts);
+ err |= put_user(cnt, &data->counts);
+
+ //printk("compat_get_rw_param, addr: 0x%x data32->reg_param: 0x%x data->reg_param: 0x%lx cnt: %d\n",
+ // addr, data32->reg_param, data->reg_param, cnt);
+
+ return err;
+}
+
+static int compat_get_rw_param_detail(struct isp_reg_param __user *data)
+{
+ struct compat_isp_reg_bits __user *data32;
+ struct isp_reg_bits __user *reg_data;
+ int err = 0;
+ int i = 0;
+ int cnt = data->counts;
+ compat_ulong_t addr;
+ compat_ulong_t val;
+ struct isp_reg_bits __user *data_tmp;
+
+ data32 = compat_ptr(data->reg_param);
+// printk("compat_get_rw_param_detail param: %p cnt %d\n", data32, cnt);
+ reg_data = (struct isp_reg_bits __user*)((unsigned long)data + sizeof(struct isp_reg_param));
+ data->reg_param = reg_data;
+ if (reg_data == NULL) {
+ printk("compat_isp_k failed to compat_alloc_user_space \n");
+ return -EFAULT;
+ }
+// printk("compat_get_rw_param_detail param: data %p \n", reg_data);
+ data_tmp = reg_data;
+ for (i=0 ; i< cnt; i++) {
+ err = get_user(addr, &data32->reg_addr);
+ err |= put_user(addr, &data_tmp->reg_addr);
+ err |= get_user(val, &data32->reg_value);
+ err |= put_user(val, &data_tmp->reg_value);
+ if (err) {
+ printk("compat_isp_k, read_param_detail failed cnt %d ret %d\n", cnt, err);
+ break;
+ }
+ data32++;
+ data_tmp++;
+ }
+ return err;
+}
+
+static int compat_put_read_param(
+ struct compat_isp_reg_param __user *data32,
+ struct isp_reg_param __user *data)
+
+{
+ int err = 0;
+ compat_ulong_t val;
+ uint32_t cnt;
+ int i = 0;
+ struct compat_isp_reg_bits __user *reg_data32;
+ struct isp_reg_bits __user *reg_data;
+
+ cnt = data->counts;
+ reg_data32 = (struct compat_isp_reg_bits __user *)data32->reg_param;
+ reg_data = (struct isp_reg_bits __user *)data->reg_param;
+ for (i=0 ; i<cnt; i++) {
+ err = get_user(val, &reg_data->reg_value);
+ err |= put_user(val, &reg_data32->reg_value);
+ if (err) {
+ printk("compat_isp_k, compat_put_read_param ret %d\n", err);
+ break;
+ }
+ reg_data32++;
+ reg_data++;
+ }
+
+ return err;
+}
+
+static int compat_get_alloc_param(
+ struct compat_isp_reg_param __user *data32,
+ struct isp_reg_param __user *data)
+{
+ int err = 0;
+ compat_ulong_t addr;
+ uint32_t cnt;
+ struct compat_isp_reg_bits __user *reg_data32;
+ struct isp_reg_bits __user *reg_data;
+
+ err = get_user(addr, &data32->reg_param);
+ err |= put_user(addr, &data->reg_param);
+ err |= get_user(cnt, &data32->counts);
+ err |= put_user(cnt, &data->counts);
+
+ return err;
+}
+
+static int compat_put_alloc(
+ struct compat_isp_reg_param __user *data32,
+ struct isp_reg_param __user *data)
+
+{
+ int err = 0;
+ compat_ulong_t addr;
+ uint32_t cnt;
+ struct compat_isp_reg_bits __user *reg_data32;
+ struct isp_reg_bits __user *reg_data;
+
+ err = get_user(addr, &data->reg_param);
+ err |= put_user(addr, &data32->reg_param);
+ err |= get_user(cnt, &data->counts);
+ err |= put_user(cnt, &data32->counts);
+
+ return err;
+}
+
+
+
+
+long compat_isp_kernel_ioctl( struct file *fl, unsigned int cmd, unsigned long param)
+{
+ long ret;
+ int err = 0;
+ void __user *up = compat_ptr(param);
+
+ if(ISP_IO_IRQ == cmd) {
+ ret = fl->f_op->unlocked_ioctl(fl, cmd, (unsigned long)up);
+ } else {
+ switch (cmd) {
+ case COMPAT_ISP_IO_READ:
+ {
+ struct compat_isp_reg_param __user *data32;
+ struct isp_reg_param __user *data;
+ uint32_t cnt;
+
+
+ data32 = compat_ptr(param);
+ err = get_user(cnt, &data32->counts);
+
+// printk("COMPAT_ISP_IO_WRITE param: %p \n", data32);
+ data = compat_alloc_user_space(sizeof(struct isp_reg_param)+cnt*sizeof(struct isp_reg_bits));
+ if (data == NULL) {
+ printk("compat_isp_k failed to compat_alloc_user_space \n");
+ return -EFAULT;
+ }
+// printk("@@1 %p", data);
+ err = compat_get_rw_param(data32, data);
+ if (err) {
+ return err;
+ }
+ err = compat_get_rw_param_detail(data);
+ if (err) {
+ printk("compat_isp_k error %d\n", err);
+ return err;
+ }
+ err = fl->f_op->unlocked_ioctl(fl, ISP_IO_READ, (unsigned long)data);
+ err = compat_put_read_param(data32, data);
+ ret = ret ? ret : err;
+ break;
+ }
+ case COMPAT_ISP_IO_WRITE:
+ {
+ struct compat_isp_reg_param __user *data32;
+ struct isp_reg_param __user *data;
+ uint32_t cnt;
+
+
+ data32 = compat_ptr(param);
+ err = get_user(cnt, &data32->counts);
+
+// printk("COMPAT_ISP_IO_WRITE param: %p \n", data32);
+ data = compat_alloc_user_space(sizeof(struct isp_reg_param)+cnt*sizeof(struct isp_reg_bits));
+ if (data == NULL) {
+ printk("compat_isp_k failed to compat_alloc_user_space \n");
+ return -EFAULT;
+ }
+// printk("@@1 %p", data);
+ err = compat_get_rw_param(data32, data);
+ if (err) {
+ return err;
+ }
+ err = compat_get_rw_param_detail(data);
+ if (err) {
+ printk("compat_isp_k error %d\n", err);
+ return err;
+ }
+ err = fl->f_op->unlocked_ioctl(fl, ISP_IO_WRITE, (unsigned long)data);
+ break;
+ }
+ case COMPAT_ISP_IO_LNC_PARAM:
+ {
+ struct compat_isp_reg_param __user *data32;
+ struct isp_reg_param __user *data;
+ char __user *lnc_data;
+
+
+ data32 = compat_ptr(param);
+ data = compat_alloc_user_space(sizeof(*data));
+ if (data == NULL) {
+ printk("compat_isp_k failed to compat_alloc_user_space \n");
+ return -EFAULT;
+ }
+ err = compat_get_rw_param(data32, data);
+ if (err) {
+ printk("compat_isp_k COMPAT_ISP_IO_LNC_PARAM error\n");
+ return err;
+ }
+ /*lnc_data = compat_alloc_user_space(sizeof(*lnc_data)*data->counts);
+ data->reg_param = (unsigned long)lnc_data;
+ ret = copy_from_user((void*)data->reg_param, (void*)data32->reg_param, data->counts);
+ if (ret) {
+ return ret;
+ }*/
+// printk("test 123\n");
+ ret = fl->f_op->unlocked_ioctl(fl, ISP_IO_LNC_PARAM, (unsigned long)data);
+// printk("test 123 end\n");
+ break;
+ }
+ case COMPAT_ISP_IO_LNC:
+ {
+ struct compat_isp_reg_param __user *data32;
+ struct isp_reg_param __user *data;
+ uint32_t cnt;
+
+
+ data32 = compat_ptr(param);
+ err = get_user(cnt, &data32->counts);
+
+// printk("COMPAT_ISP_IO_WRITE param: %p \n", data32);
+ data = compat_alloc_user_space(sizeof(struct isp_reg_param)+cnt*sizeof(struct isp_reg_bits));
+ if (data == NULL) {
+ printk("compat_isp_k failed to compat_alloc_user_space \n");
+ return -EFAULT;
+ }
+// printk("@@1 %p", data);
+ err = compat_get_rw_param(data32, data);
+ if (err) {
+ return err;
+ }
+ err = compat_get_rw_param_detail(data);
+ if (err) {
+ printk("compat_isp_k error %d\n", err);
+ return err;
+ }
+ // printk("test ISP_IO_LNC\n");
+ err = fl->f_op->unlocked_ioctl(fl, ISP_IO_LNC, (unsigned long)data);
+ // printk("test ISP_IO_LNC end\n");
+ break;
+ }
+ case COMPAT_ISP_IO_ALLOC:
+ {
+ struct compat_isp_reg_param __user *data32;
+ struct isp_reg_param __user *data;
+
+ data32 = compat_ptr(param);
+ data = compat_alloc_user_space(sizeof(*data));
+ if (data == NULL) {
+ printk("compat_isp_k failed to compat_alloc_user_space \n");
+ return -EFAULT;
+ }
+ err = compat_get_alloc_param(data32, data);
+ if (err) {
+ return err;
+ }
+ ret = fl->f_op->unlocked_ioctl(fl, ISP_IO_ALLOC, (unsigned long)data);
+ if (ret) {
+ printk("compat_isp_k,failed to ISP_IO_ALLOC %ld", ret);
+ goto exit;
+ }
+ err = compat_put_alloc(data32, data);
+ ret = err;
+ break;
+ }
+
+ case ISP_IO_RST:
+ case ISP_IO_SETCLK:
+ case ISP_IO_STOP:
+ case ISP_IO_INT:
+ case ISP_IO_DCAM_INT:
+ {
+ ret = fl->f_op->unlocked_ioctl(fl, cmd, (unsigned long)up);
+ break;
+ }
+ default:
+ printk("compat_isp_k, don't support cmd 0x%x", cmd);
+ break;
+ }
+ }
+exit:
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/compat_isp_drv_kernel.h b/drivers/media/sprd_isp/compat_isp_drv_kernel.h
new file mode 100644
index 00000000..a24cce52
--- /dev/null
+++ b/drivers/media/sprd_isp/compat_isp_drv_kernel.h
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+#ifndef _COMPAT_ISP_DRV_KERNEL_H_
+#define _COMPAT_ISP_DRV_KERNEL_H_
+
+#if IS_ENABLED(CONFIG_COMPAT)
+
+long compat_isp_kernel_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+
+#else
+
+#define compat_isp_kernel_ioctl NULL
+
+#endif /* CONFIG_COMPAT */
+
+#endif
diff --git a/drivers/media/sprd_isp/isp1.0/Shark_reg_isp.h b/drivers/media/sprd_isp/isp1.0/Shark_reg_isp.h
new file mode 100644
index 00000000..6b99f9ea
--- /dev/null
+++ b/drivers/media/sprd_isp/isp1.0/Shark_reg_isp.h
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+#ifndef _TIGER_REG_ISP_H_
+#define _TIGER_REG_ISP_H_
+#ifndef CONFIG_64BIT
+#include <soc/sprd/globalregs.h>
+#else
+#include <soc/sprd/irqs.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+
+#define ISP_DCAM_BASE DCAM_BASE
+#define ISP_DCAM_INT_STS (ISP_DCAM_BASE + 0x003CUL)
+#define ISP_DCAM_INT_CLR (ISP_DCAM_BASE + 0x0044UL)
+
+#define ISP_BASE_ADDR ISP_BASE
+#define ISP_LNC_STATUS (ISP_BASE_ADDR+0x0200UL)
+#define ISP_LNC_LOAD (ISP_BASE_ADDR+0x0220UL)
+#define ISP_AXI_MASTER (ISP_BASE_ADDR+0x2000UL)
+#define ISP_INT_RAW (ISP_BASE_ADDR+0x2080UL)
+#define ISP_INT_STATUS (ISP_BASE_ADDR+0x2084UL)
+#define ISP_INT_EN (ISP_BASE_ADDR+0x2078UL)
+#define ISP_INT_CLEAR (ISP_BASE_ADDR+0x207cUL)
+#define ISP_REG_MAX_SIZE SPRD_ISP_SIZE
+#define ISP_AXI_MASTER_STOP (ISP_BASE_ADDR + 0X2054UL)
+
+#define ISP_AHB_BASE SPRD_MMAHB_BASE
+#define ISP_MODULE_EB (ISP_AHB_BASE + 0x0000UL)
+#define ISP_MODULE_RESET (ISP_AHB_BASE + 0x0004UL)
+#define ISP_CORE_CLK_EB (ISP_AHB_BASE + 0x0008UL)
+
+#define ISP_CLOCK_BASE SPRD_MMCKG_BASE
+#define ISP_CLOCK (ISP_CLOCK_BASE + 0X34)
+
+
+/*irq line number in system*/
+#define ISP_IRQ IRQ_ISP_INT
+
+#define ISP_EB_BIT BIT_2
+#define ISP_RST_LOG_BIT BIT_2
+#define ISP_RST_CFG_BIT BIT_3
+#define ISP_CORE_CLK_EB_BIT BIT_4
+#define ISP_AXI_MASTER_STOP_BIT BIT_0
+
+#define ISP_IRQ_HW_MASK_V0001 (0x1fffffff)
+#define ISP_IRQ_NUM_V0001 (29)
+#define ISP_TMP_BUF_SIZE_MAX_V0001 (32 * 1024)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //_TIGER_REG_ISP_H_
diff --git a/drivers/media/sprd_isp/isp1.0/Tiger_reg_isp.h b/drivers/media/sprd_isp/isp1.0/Tiger_reg_isp.h
new file mode 100644
index 00000000..d68a8ff9
--- /dev/null
+++ b/drivers/media/sprd_isp/isp1.0/Tiger_reg_isp.h
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+#ifndef _TIGER_REG_ISP_H_
+#define _TIGER_REG_ISP_H_
+#include <mach/globalregs.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define BIT_0 0x01
+#define BIT_1 0x02
+#define BIT_2 0x04
+#define BIT_3 0x08
+#define BIT_4 0x10
+#define BIT_5 0x20
+#define BIT_6 0x40
+#define BIT_7 0x80
+#define BIT_8 0x0100
+#define BIT_9 0x0200
+#define BIT_10 0x0400
+#define BIT_11 0x0800
+#define BIT_12 0x1000
+#define BIT_13 0x2000
+#define BIT_14 0x4000
+#define BIT_15 0x8000
+#define BIT_16 0x010000
+#define BIT_17 0x020000
+#define BIT_18 0x040000
+#define BIT_19 0x080000
+#define BIT_20 0x100000
+#define BIT_21 0x200000
+#define BIT_22 0x400000
+#define BIT_23 0x800000
+#define BIT_24 0x01000000
+#define BIT_25 0x02000000
+#define BIT_26 0x04000000
+#define BIT_27 0x08000000
+#define BIT_28 0x10000000
+#define BIT_29 0x20000000
+#define BIT_30 0x40000000
+#define BIT_31 0x80000000
+
+
+#define ISP_DCAM_BASE DCAM_BASE
+#define ISP_DCAM_INT_STS (ISP_DCAM_BASE + 0x0030UL)
+#define ISP_DCAM_INT_CLR (ISP_DCAM_BASE + 0x0038UL)
+
+#define ISP_BASE_ADDR ISP_BASE
+#define ISP_LNC_LOAD (ISP_BASE_ADDR+0x0220UL)
+#define ISP_AXI_MASTER (ISP_BASE_ADDR+0x2000UL)
+#define ISP_INT_RAW (ISP_BASE_ADDR+0x2080UL)
+#define ISP_INT_STATUS (ISP_BASE_ADDR+0x2084UL)
+#define ISP_INT_EN (ISP_BASE_ADDR+0x2078UL)
+#define ISP_INT_CLEAR (ISP_BASE_ADDR+0x207cUL)
+#define ISP_REG_MAX_SIZE SPRD_ISP_SIZE
+
+#define ISP_AHB_BASE SPRD_AHB_BASE
+#define ISP_AHB_CTL0 (ISP_AHB_BASE + 0x0200UL)
+#define ISP_MODULE_EB (ISP_AHB_CTL0 + 0x0000UL)
+#define ISP_MODULE_RESET (ISP_AHB_CTL0 + 0x0010UL)
+
+#define ISP_CORE_CLK_EB (ISP_AHB_BASE + 0x0208UL)
+
+/*irq line number in system*/
+#define ISP_IRQ IRQ_ISP_INT
+#define DCAM_IRQ IRQ_DCAM_INT
+
+#define ISP_EB_BIT BIT_12
+#define ISP_RST_BIT BIT_8
+#define ISP_CORE_CLK_EB_BIT BIT_7
+#define ISP_IRQ_HW_MASK_V0000 (0xfff)
+#define ISP_IRQ_NUM_V0000 (12)
+#define ISP_TMP_BUF_SIZE_MAX_V0000 (36 * 1024)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //_TIGER_REG_ISP_H_ \ No newline at end of file
diff --git a/drivers/media/sprd_isp/isp1.0/compat_isp_drv_kernel.c b/drivers/media/sprd_isp/isp1.0/compat_isp_drv_kernel.c
new file mode 100644
index 00000000..ae0ad4f0
--- /dev/null
+++ b/drivers/media/sprd_isp/isp1.0/compat_isp_drv_kernel.c
@@ -0,0 +1,327 @@
+#include <linux/compat.h>
+#include <linux/fs.h>
+#include <linux/uaccess.h>
+#include <video/isp_drv_kernel.h>
+#include "compat_isp_drv_kernel.h"
+
+struct compat_isp_irq_param {
+ compat_uint_t isp_irq_val;
+ compat_uint_t dcam_irq_val;
+ compat_uint_t irq_val;
+ compat_int_t ret_val;
+};
+
+struct compat_isp_reg_bits {
+ compat_ulong_t reg_addr;
+ compat_ulong_t reg_value;
+} ;
+
+struct compat_isp_reg_param {
+ compat_ulong_t reg_param;
+ uint32_t counts;
+} ;
+
+
+#define COMPAT_ISP_IO_READ _IOR(ISP_IO_MAGIC, 1, struct compat_isp_reg_param)
+#define COMPAT_ISP_IO_WRITE _IOW(ISP_IO_MAGIC, 2, struct compat_isp_reg_param)
+#define COMPAT_ISP_IO_LNC_PARAM _IOW(ISP_IO_MAGIC, 8, struct compat_isp_reg_param)
+#define COMPAT_ISP_IO_LNC _IOW(ISP_IO_MAGIC, 9, struct compat_isp_reg_param)
+#define COMPAT_ISP_IO_ALLOC _IOW(ISP_IO_MAGIC, 10, struct compat_isp_reg_param)
+
+
+static int compat_get_rw_param(
+ struct compat_isp_reg_param __user *data32,
+ struct isp_reg_param __user *data)
+{
+ int err = 0;
+ compat_ulong_t addr;
+ uint32_t cnt;
+
+ err = get_user(addr, &data32->reg_param);
+ err |= put_user(addr, &data->reg_param);
+ err |= get_user(cnt, &data32->counts);
+ err |= put_user(cnt, &data->counts);
+
+ //printk("compat_get_rw_param, addr: 0x%x data32->reg_param: 0x%x data->reg_param: 0x%lx cnt: %d\n",
+ // addr, data32->reg_param, data->reg_param, cnt);
+
+ return err;
+}
+
+static int compat_get_rw_param_detail(struct isp_reg_param __user *data)
+{
+ struct compat_isp_reg_bits __user *data32;
+ struct isp_reg_bits __user *reg_data;
+ int err = 0;
+ int i = 0;
+ int cnt = data->counts;
+ compat_ulong_t addr;
+ compat_ulong_t val;
+ struct isp_reg_bits __user *data_tmp;
+
+ data32 = compat_ptr(data->reg_param);
+// printk("compat_get_rw_param_detail param: %p cnt %d\n", data32, cnt);
+ reg_data = (struct isp_reg_bits __user*)((unsigned long)data + sizeof(struct isp_reg_param));
+ data->reg_param = reg_data;
+ if (reg_data == NULL) {
+ printk("compat_isp_k failed to compat_alloc_user_space \n");
+ return -EFAULT;
+ }
+// printk("compat_get_rw_param_detail param: data %p \n", reg_data);
+ data_tmp = reg_data;
+ for (i=0 ; i< cnt; i++) {
+ err = get_user(addr, &data32->reg_addr);
+ err |= put_user(addr, &data_tmp->reg_addr);
+ err |= get_user(val, &data32->reg_value);
+ err |= put_user(val, &data_tmp->reg_value);
+ if (err) {
+ printk("compat_isp_k, read_param_detail failed cnt %d ret %d\n", cnt, err);
+ break;
+ }
+ data32++;
+ data_tmp++;
+ }
+ return err;
+}
+
+static int compat_put_read_param(
+ struct compat_isp_reg_param __user *data32,
+ struct isp_reg_param __user *data)
+
+{
+ int err = 0;
+ compat_ulong_t val;
+ uint32_t cnt;
+ int i = 0;
+ struct compat_isp_reg_bits __user *reg_data32;
+ struct isp_reg_bits __user *reg_data;
+
+ cnt = data->counts;
+ reg_data32 = (struct compat_isp_reg_bits __user *)data32->reg_param;
+ reg_data = (struct isp_reg_bits __user *)data->reg_param;
+ for (i=0 ; i<cnt; i++) {
+ err = get_user(val, &reg_data->reg_value);
+ err |= put_user(val, &reg_data32->reg_value);
+ if (err) {
+ printk("compat_isp_k, compat_put_read_param ret %d\n", err);
+ break;
+ }
+ reg_data32++;
+ reg_data++;
+ }
+
+ return err;
+}
+
+static int compat_get_alloc_param(
+ struct compat_isp_reg_param __user *data32,
+ struct isp_reg_param __user *data)
+{
+ int err = 0;
+ compat_ulong_t addr;
+ uint32_t cnt;
+ struct compat_isp_reg_bits __user *reg_data32;
+ struct isp_reg_bits __user *reg_data;
+
+ err = get_user(addr, &data32->reg_param);
+ err |= put_user(addr, &data->reg_param);
+ err |= get_user(cnt, &data32->counts);
+ err |= put_user(cnt, &data->counts);
+
+ return err;
+}
+
+static int compat_put_alloc(
+ struct compat_isp_reg_param __user *data32,
+ struct isp_reg_param __user *data)
+
+{
+ int err = 0;
+ compat_ulong_t addr;
+ uint32_t cnt;
+ struct compat_isp_reg_bits __user *reg_data32;
+ struct isp_reg_bits __user *reg_data;
+
+ err = get_user(addr, &data->reg_param);
+ err |= put_user(addr, &data32->reg_param);
+ err |= get_user(cnt, &data->counts);
+ err |= put_user(cnt, &data32->counts);
+
+ return err;
+}
+
+
+
+
+long compat_isp_kernel_ioctl( struct file *fl, unsigned int cmd, unsigned long param)
+{
+ long ret;
+ int err = 0;
+ void __user *up = compat_ptr(param);
+
+ if(ISP_IO_IRQ == cmd) {
+ ret = fl->f_op->unlocked_ioctl(fl, cmd, (unsigned long)up);
+ } else {
+ switch (cmd) {
+ case COMPAT_ISP_IO_READ:
+ {
+ struct compat_isp_reg_param __user *data32;
+ struct isp_reg_param __user *data;
+ uint32_t cnt;
+
+
+ data32 = compat_ptr(param);
+ err = get_user(cnt, &data32->counts);
+
+// printk("COMPAT_ISP_IO_WRITE param: %p \n", data32);
+ data = compat_alloc_user_space(sizeof(struct isp_reg_param)+cnt*sizeof(struct isp_reg_bits));
+ if (data == NULL) {
+ printk("compat_isp_k failed to compat_alloc_user_space \n");
+ return -EFAULT;
+ }
+// printk("@@1 %p", data);
+ err = compat_get_rw_param(data32, data);
+ if (err) {
+ return err;
+ }
+ err = compat_get_rw_param_detail(data);
+ if (err) {
+ printk("compat_isp_k error %d\n", err);
+ return err;
+ }
+ err = fl->f_op->unlocked_ioctl(fl, ISP_IO_READ, (unsigned long)data);
+ err = compat_put_read_param(data32, data);
+ ret = ret ? ret : err;
+ break;
+ }
+ case COMPAT_ISP_IO_WRITE:
+ {
+ struct compat_isp_reg_param __user *data32;
+ struct isp_reg_param __user *data;
+ uint32_t cnt;
+
+
+ data32 = compat_ptr(param);
+ err = get_user(cnt, &data32->counts);
+
+// printk("COMPAT_ISP_IO_WRITE param: %p \n", data32);
+ data = compat_alloc_user_space(sizeof(struct isp_reg_param)+cnt*sizeof(struct isp_reg_bits));
+ if (data == NULL) {
+ printk("compat_isp_k failed to compat_alloc_user_space \n");
+ return -EFAULT;
+ }
+// printk("@@1 %p", data);
+ err = compat_get_rw_param(data32, data);
+ if (err) {
+ return err;
+ }
+ err = compat_get_rw_param_detail(data);
+ if (err) {
+ printk("compat_isp_k error %d\n", err);
+ return err;
+ }
+ err = fl->f_op->unlocked_ioctl(fl, ISP_IO_WRITE, (unsigned long)data);
+ break;
+ }
+ case COMPAT_ISP_IO_LNC_PARAM:
+ {
+ struct compat_isp_reg_param __user *data32;
+ struct isp_reg_param __user *data;
+ char __user *lnc_data;
+
+
+ data32 = compat_ptr(param);
+ data = compat_alloc_user_space(sizeof(*data));
+ if (data == NULL) {
+ printk("compat_isp_k failed to compat_alloc_user_space \n");
+ return -EFAULT;
+ }
+ err = compat_get_rw_param(data32, data);
+ if (err) {
+ printk("compat_isp_k COMPAT_ISP_IO_LNC_PARAM error\n");
+ return err;
+ }
+ /*lnc_data = compat_alloc_user_space(sizeof(*lnc_data)*data->counts);
+ data->reg_param = (unsigned long)lnc_data;
+ ret = copy_from_user((void*)data->reg_param, (void*)data32->reg_param, data->counts);
+ if (ret) {
+ return ret;
+ }*/
+// printk("test 123\n");
+ ret = fl->f_op->unlocked_ioctl(fl, ISP_IO_LNC_PARAM, (unsigned long)data);
+// printk("test 123 end\n");
+ break;
+ }
+ case COMPAT_ISP_IO_LNC:
+ {
+ struct compat_isp_reg_param __user *data32;
+ struct isp_reg_param __user *data;
+ uint32_t cnt;
+
+
+ data32 = compat_ptr(param);
+ err = get_user(cnt, &data32->counts);
+
+// printk("COMPAT_ISP_IO_WRITE param: %p \n", data32);
+ data = compat_alloc_user_space(sizeof(struct isp_reg_param)+cnt*sizeof(struct isp_reg_bits));
+ if (data == NULL) {
+ printk("compat_isp_k failed to compat_alloc_user_space \n");
+ return -EFAULT;
+ }
+// printk("@@1 %p", data);
+ err = compat_get_rw_param(data32, data);
+ if (err) {
+ return err;
+ }
+ err = compat_get_rw_param_detail(data);
+ if (err) {
+ printk("compat_isp_k error %d\n", err);
+ return err;
+ }
+ // printk("test ISP_IO_LNC\n");
+ err = fl->f_op->unlocked_ioctl(fl, ISP_IO_LNC, (unsigned long)data);
+ // printk("test ISP_IO_LNC end\n");
+ break;
+ }
+ case COMPAT_ISP_IO_ALLOC:
+ {
+ struct compat_isp_reg_param __user *data32;
+ struct isp_reg_param __user *data;
+
+ data32 = compat_ptr(param);
+ data = compat_alloc_user_space(sizeof(*data));
+ if (data == NULL) {
+ printk("compat_isp_k failed to compat_alloc_user_space \n");
+ return -EFAULT;
+ }
+ err = compat_get_alloc_param(data32, data);
+ if (err) {
+ return err;
+ }
+ ret = fl->f_op->unlocked_ioctl(fl, ISP_IO_ALLOC, (unsigned long)data);
+ if (ret) {
+ printk("compat_isp_k,failed to ISP_IO_ALLOC %ld", ret);
+ goto exit;
+ }
+ err = compat_put_alloc(data32, data);
+ ret = err;
+ break;
+ }
+
+ case ISP_IO_RST:
+ case ISP_IO_SETCLK:
+ case ISP_IO_STOP:
+ case ISP_IO_INT:
+ case ISP_IO_DCAM_INT:
+ {
+ ret = fl->f_op->unlocked_ioctl(fl, cmd, (unsigned long)up);
+ break;
+ }
+ default:
+ printk("compat_isp_k, don't support cmd 0x%x", cmd);
+ break;
+ }
+ }
+exit:
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp1.0/compat_isp_drv_kernel.h b/drivers/media/sprd_isp/isp1.0/compat_isp_drv_kernel.h
new file mode 100644
index 00000000..a24cce52
--- /dev/null
+++ b/drivers/media/sprd_isp/isp1.0/compat_isp_drv_kernel.h
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+#ifndef _COMPAT_ISP_DRV_KERNEL_H_
+#define _COMPAT_ISP_DRV_KERNEL_H_
+
+#if IS_ENABLED(CONFIG_COMPAT)
+
+long compat_isp_kernel_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
+
+#else
+
+#define compat_isp_kernel_ioctl NULL
+
+#endif /* CONFIG_COMPAT */
+
+#endif
diff --git a/drivers/media/sprd_isp/isp1.0/isp_drv_kernel.c b/drivers/media/sprd_isp/isp1.0/isp_drv_kernel.c
new file mode 100644
index 00000000..9a6acbef
--- /dev/null
+++ b/drivers/media/sprd_isp/isp1.0/isp_drv_kernel.c
@@ -0,0 +1,1494 @@
+/*
+ * 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/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/poll.h>
+#include <linux/fs.h>
+#include <linux/irq.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/miscdevice.h>
+#include <asm/io.h>
+#include <linux/file.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/sched.h>
+#include <linux/spinlock_types.h>
+#include <linux/semaphore.h>
+#include <linux/delay.h>
+#include <linux/proc_fs.h>
+#include <video/isp_drv_kernel.h>
+#include <soc/sprd/sci.h>
+#include <linux/clk.h>
+#include <asm/cacheflush.h>
+#ifndef CONFIG_64BIT
+#include <soc/sprd/hardware.h>
+#endif
+#include "compat_isp_drv_kernel.h"
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/vmalloc.h>
+#include <linux/kthread.h>
+
+#include "Shark_reg_isp.h"
+#include "parse_hwinfo.h"
+
+
+#define DEBUG_ISP_DRV
+#ifdef DEBUG_ISP_DRV
+#define ISP_PRINT printk
+#else
+#define ISP_PRINT(...)
+#endif
+
+#define ISP_QUEUE_LENGTH 16
+#define SA_SHIRQ IRQF_SHARED
+static uint32_t g_isp_irq = 0x12345678;/*for share irq handler function*/
+//static uint32_t g_dcam_irq = 0x12345678;/*for share irq handler function*/
+
+#define ISP_MINOR MISC_DYNAMIC_MINOR/*isp minor number*/
+#define init_MUTEX(sem) sema_init(sem, 1)
+#define init_MUTEX_LOCKED(sem) sema_init(sem, 0)
+#define IO_PTR volatile void __iomem *
+#define ISP_READL(a) __raw_readl((IO_PTR)a)
+#define ISP_WRITEL(a,v) __raw_writel(v,(IO_PTR)a)
+#define ISP_OWR(a,v) __raw_writel((__raw_readl((IO_PTR)a) | v), (IO_PTR)a)
+#define ISP_AWR(a,v) __raw_writel((__raw_readl((IO_PTR)a) & v), (IO_PTR)a)
+#define ISP_NAWR(a,v) __raw_writel((__raw_readl((IO_PTR)a) & ~v), (IO_PTR)a)
+#define ISP_REG_RD(a) ISP_READL(((IO_PTR)a))
+#define DEBUG_STR "Error L %d, %s \n"
+#define DEBUG_ARGS __LINE__,__FUNCTION__
+#define ISP_LOWEST_ADDR 0x800
+#define ISP_ADDR_INVALID(addr) ((unsigned long)(addr) < (unsigned long)ISP_LOWEST_ADDR)
+#define ISP_CHECK_ZERO(a) \
+ do { \
+ if (ISP_ADDR_INVALID(a)) { \
+ printk("isp_k, zero pointer \n"); \
+ printk(DEBUG_STR, DEBUG_ARGS); \
+ return -EFAULT; \
+ } \
+ } while(0)
+
+#define ISP_CHECK_ZERO_VOID(a) \
+ do { \
+ if (ISP_ADDR_INVALID(a)) { \
+ printk("isp_k, zero pointer \n"); \
+ printk(DEBUG_STR, DEBUG_ARGS); \
+ return; \
+ } \
+ } while(0)
+
+#define ISP_DCAM_IRQ_MASK 0x03
+#define ISP_DCAM_IRQ_NUM 0x02
+#define ISP_BUF_MAX_SIZE ISP_TMP_BUF_SIZE_MAX_V0001
+#define ISP_IRQ_NUM ISP_IRQ_NUM_V0001
+#define ISP_IRQ_HW_MASK ISP_IRQ_HW_MASK_V0001
+#define ISP_TIME_OUT_MAX (500)
+
+struct isp_node {
+ uint32_t isp_irq_val;
+ uint32_t dcam_irq_val;
+ uint64_t system_time;
+};
+
+struct isp_queue {
+ struct isp_node node[ISP_QUEUE_LENGTH];
+ struct isp_node *write;
+ struct isp_node *read;
+};
+
+struct isp_lnc_load {
+ uint8_t load_lnc_flag;
+ uint8_t cap_eof_flag;
+ uint32_t param_counts;
+ unsigned long load_buf;
+ struct semaphore load_done_sem;
+};
+struct isp_device_t
+{
+ unsigned long reg_base_addr;/*the pointer of isp register context*/
+ uint32_t size;/* struct size*/
+ unsigned long buf_addr;
+ uint32_t buf_len;
+ struct isp_queue queue;
+ struct semaphore sem_isr;/*for interrupts*/
+ struct semaphore sem_isp;/*for the isp device, protect the isp hardware; protect only one caller use the oi*/
+ /*controll/read/write functions*/
+ struct clk* s_isp_clk_mm_i;
+ struct clk *s_isp_clk;
+ struct semaphore kernel_sem;
+ struct task_struct* kernel_thread;
+ struct isp_lnc_load lnc_load;
+ uint32_t is_kernel_thread_stop;
+};
+enum dcam_irq_id {
+ DCAM_SN_SOF = 0,
+ DCAM_SN_EOF,
+ DCAM_CAP_SOF,
+ DCAM_CAP_EOF,
+ DCAM_PATH0_DONE,
+ DCAM_PATH0_OV,
+ DCAM_PATH1_DONE,
+ DCAM_PATH1_OV,
+ DCAM_PATH2_DONE,
+ DCAM_PATH2_OV,
+ DCAM_SN_LINE_ERR,
+ DCAM_SN_FRAME_ERR,
+ DCAM_JPEG_BUF_OV,
+ DCAM_ISP_OV,
+ DCAM_MIPI_OV,
+ DCAM_ROT_DONE,
+ DCAM_PATH1_SLICE_DONE,
+ DCAM_PATH2_SLICE_DONE,
+ DCAM_RAW_SLICE_DONE,
+ DCAM_PATH1_SOF,
+ DCAM_PATH2_SOF,
+ DCAM_IRQ_NUMBER
+};
+struct dcam_frame {
+ uint32_t type;
+ uint32_t lock;
+ uint32_t flags;
+ uint32_t fid;
+ uint32_t width;
+ uint32_t height;
+ uint32_t yaddr;
+ uint32_t uaddr;
+ uint32_t vaddr;
+ struct dcam_frame *prev;
+ struct dcam_frame *next;
+};
+typedef int (*dcam_isr_func)(struct dcam_frame* frame, void* u_data);
+extern int32_t dcam_reg_isr(enum dcam_irq_id id, dcam_isr_func user_func, void* user_data);
+
+static atomic_t s_isp_users = ATOMIC_INIT(0);
+static struct mutex s_isp_lock; /*for the isp driver, protect the isp module; protect only one user open this module*/
+static struct proc_dir_entry* isp_proc_file;
+static struct isp_device_t *g_isp_dev_ptr = NULL;
+
+uint32_t s_dcam_int_eb = 0x00;
+unsigned long s_isp_alloc_addr = 0x00;
+uint32_t s_isp_alloc_order = 0x00;
+uint32_t s_isp_alloc_len = 0x00;
+
+static DEFINE_SPINLOCK(isp_spin_lock);
+static int32_t _isp_set_clk(enum isp_clk_sel clk_sel);
+static int32_t _isp_module_eb(void);
+static int32_t _isp_module_dis(void);
+static int _isp_registerirq(void);
+static void _isp_unregisterirq(void);
+static irqreturn_t _isp_irq_root(int irq, void *dev_id);
+void _dcam_isp_root(void);
+static int _isp_queue_init(struct isp_queue *queue);
+static int _isp_queue_write(struct isp_queue *queue, struct isp_node *node);
+static int _isp_queue_read(struct isp_queue *queue, struct isp_node *node);
+static inline void _isp_regread(char *dst, char *src, size_t n);
+static inline void _isp_regwrite(char *dst, char *src, size_t n);
+static void _read_reg(struct isp_reg_bits *reg_bits_ptr, uint32_t counts);
+static void _write_reg(struct isp_reg_bits *reg_bits_ptr, uint32_t counts);
+
+/**file operation functions declare**/
+static int32_t _isp_kernel_open(struct inode *node, struct file *filp);
+static int32_t _isp_kernel_release(struct inode *node, struct file *filp);
+static long _isp_kernel_ioctl( struct file *fl, unsigned int cmd, unsigned long param);
+/**driver' functions declare**/
+static int32_t _isp_probe(struct platform_device *pdev);
+static int32_t _isp_remove(struct platform_device *dev);
+/**module' functions declare**/
+static int32_t __init isp_kernel_init(void);
+static void isp_kernel_exit(void);
+static int32_t _isp_lnc_param_load_ex(struct isp_reg_bits *reg_bits_ptr, uint32_t counts);
+static int _isp_stop_kernel_thread(void* param);
+
+static struct file_operations isp_fops = {
+ .owner = THIS_MODULE,
+ .open = _isp_kernel_open,
+ .unlocked_ioctl = _isp_kernel_ioctl,
+ .compat_ioctl = compat_isp_kernel_ioctl,
+ .release = _isp_kernel_release,
+};
+
+static struct miscdevice isp_dev = {
+ .minor = ISP_MINOR,
+ .name = "sprd_isp",
+ .fops = &isp_fops,
+};
+
+static const struct of_device_id of_match_table_isp[] = {
+ { .compatible = "sprd,sprd_isp", },
+ { },
+};
+
+static struct platform_driver isp_driver = {
+ .probe = _isp_probe,
+ .remove = _isp_remove,
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "sprd_isp",
+ .of_match_table = of_match_ptr(of_match_table_isp),
+ },
+};
+
+static int32_t _isp_get_systemtime(struct timeval *tv)
+{
+ struct timespec ts;
+
+ ktime_get_ts(&ts);
+ tv->tv_sec = ts.tv_sec;
+ tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
+ return 0;
+}
+
+static int32_t _isp_module_eb(void)
+{
+ int32_t ret = 0;
+
+ if (0x01 == atomic_inc_return(&s_isp_users)) {
+
+ ret = clk_mm_i_eb(isp_dev.this_device->of_node,1);
+ ret = _isp_set_clk(ISP_CLK_312M);
+ if (unlikely(0 != ret)) {
+ ISP_PRINT("isp_k: set clock error\n");
+ ret = -EIO;
+ }
+ }
+
+ ISP_PRINT("_isp_module_eb: end\n");
+
+ return ret;
+}
+
+static int32_t _isp_module_dis(void)
+{
+ int32_t ret = 0;
+
+ if (0x00 == atomic_dec_return(&s_isp_users)) {
+
+ ret = _isp_set_clk(ISP_CLK_NONE);
+ if (unlikely(0 != ret)) {
+ ISP_PRINT("isp_k: close clock error\n");
+ ret = -EFAULT;
+ return ret;
+ }
+ ret = clk_mm_i_eb(isp_dev.this_device->of_node,0);
+ }
+ return ret;
+}
+
+static int32_t _isp_module_rst(void)
+{
+ int32_t ret = 0;
+ uint32_t reg_value=0x00;
+ int32_t time_out_cnt = 0;
+
+ if (0x00 != atomic_read(&s_isp_users)) {
+
+ ISP_OWR(ISP_AXI_MASTER_STOP, BIT_0);
+
+ reg_value=ISP_READL(ISP_AXI_MASTER);
+ while((0x00==(reg_value&0x08)) && (time_out_cnt < (ISP_TIME_OUT_MAX * 2)))
+ {
+ time_out_cnt++;
+ udelay(50);
+ reg_value=ISP_READL(ISP_AXI_MASTER);
+ }
+ if (time_out_cnt >= ISP_TIME_OUT_MAX) {
+ ret = -1;
+ ISP_PRINT("_isp_module_rst: time out\n");
+ }
+
+ ISP_WRITEL(ISP_INT_CLEAR, ISP_IRQ_HW_MASK);
+
+ sci_glb_set(ISP_MODULE_RESET, ISP_RST_LOG_BIT);
+ sci_glb_set(ISP_MODULE_RESET, ISP_RST_CFG_BIT);
+ sci_glb_set(ISP_MODULE_RESET, ISP_RST_LOG_BIT);
+ sci_glb_set(ISP_MODULE_RESET, ISP_RST_CFG_BIT);
+ sci_glb_set(ISP_MODULE_RESET, ISP_RST_LOG_BIT);
+ sci_glb_set(ISP_MODULE_RESET, ISP_RST_CFG_BIT);
+
+ sci_glb_clr(ISP_MODULE_RESET, ISP_RST_CFG_BIT);
+ sci_glb_clr(ISP_MODULE_RESET, ISP_RST_LOG_BIT);
+ }
+
+ ISP_PRINT("_isp_module_rst: exit\n");
+
+ return 0;
+}
+
+void* _isp_cap_eof(struct dcam_frame* frame, void* u_data)
+{
+ struct isp_device_t * p_isp = (struct isp_device_t *)u_data;
+ if (p_isp) {
+ p_isp->lnc_load.cap_eof_flag = 1;
+ if (p_isp->lnc_load.load_lnc_flag) {
+ up(&p_isp->kernel_sem);
+ p_isp->lnc_load.load_lnc_flag = 0;
+ } else {
+ }
+ }
+}
+int _isp_kernel_proc(void *arg)
+{
+ struct isp_device_t *dev = (struct isp_device_t*)arg;
+ int32_t time_out_cnt = 0;
+ uint32_t reg_value=0x00;
+ int ret = 0;
+ struct isp_reg_bits *reg_bits_ptr;
+ uint32_t counts;
+ while(1) {
+ if (0 == down_interruptible(&dev->kernel_sem)) {
+ if (dev->is_kernel_thread_stop) {
+ printk("isp_k: _isp_kernel_proc stop \n");
+ break;
+ }
+ reg_bits_ptr = (struct isp_reg_bits*) g_isp_dev_ptr->lnc_load.load_buf;
+ counts = g_isp_dev_ptr->lnc_load.param_counts;
+ ret = _isp_lnc_param_load_ex(reg_bits_ptr, counts);
+ memset((void *)g_isp_dev_ptr->lnc_load.load_buf, 0x00, ISP_BUF_MAX_SIZE);
+ }
+ }
+ dev->is_kernel_thread_stop = 0;
+ return 0;
+}
+int _isp_kernel_thread(void* param)
+{
+ struct isp_device_t *dev = (struct isp_device_t*)param;
+ if (dev == NULL) {
+ printk("isp_k: _isp_kernel_thread, dev is NULL \n");
+ return -1;
+ }
+ dev->lnc_load.load_lnc_flag = 0;
+ dev->lnc_load.cap_eof_flag = 0;
+ dev->is_kernel_thread_stop = 0;
+ sema_init(&dev->kernel_sem, 0);
+ sema_init(&dev->lnc_load.load_done_sem, 0);
+ dev->kernel_thread = kthread_run(_isp_kernel_proc, param, "isp_kernel_proc_thread");
+ if (IS_ERR(dev->kernel_thread)) {
+ printk("isp_k: _isp_kernel_thread error!\n");
+ return -1;
+ }
+ return 0;
+}
+static int _isp_stop_kernel_thread(void* param)
+{
+ struct isp_device_t *dev = (struct isp_device_t*)param;
+ int cnt = 0;
+ if (dev == NULL) {
+ printk("SPRD_IMG: sprd_img_opt_flash, dev is NULL \n");
+ return -1;
+ }
+ if (dev->kernel_thread) {
+ dev->is_kernel_thread_stop = 1;
+ up(&dev->kernel_sem);
+ if (0 != dev->is_kernel_thread_stop) {
+ while (cnt < 500) {
+ cnt++;
+ if (0 == dev->is_kernel_thread_stop)
+ break;
+ msleep(1);
+ }
+ }
+ dev->kernel_thread = NULL;
+ }
+ return 0;
+}
+static int32_t _isp_lnc_param_load_ex(struct isp_reg_bits *reg_bits_ptr, uint32_t counts)
+{
+ int32_t ret = 0;
+ int32_t time_out_cnt = 0;
+ volatile uint32_t reg_value=0x00;
+
+ if((0x00!=s_isp_alloc_addr)
+ &&(0x00!=s_isp_alloc_len)) {
+
+ void *ptr = (void*)s_isp_alloc_addr;
+ uint32_t len=s_isp_alloc_len;
+
+ #ifndef CONFIG_64BIT
+ dmac_flush_range(ptr, ptr + len);
+ outer_flush_range(__pa(ptr), __pa(ptr) + len);
+ #endif
+
+ reg_bits_ptr->reg_value=(uint32_t)__pa(reg_bits_ptr->reg_value);
+//#if defined(CONFIG_MACH_CORE3)
+
+
+ reg_value=ISP_READL(ISP_LNC_STATUS);
+ while((0x00==(reg_value&ISP_LNC_STATUS_OK)) && (time_out_cnt < (ISP_TIME_OUT_MAX*1000))) {
+ udelay(1);
+ reg_value=ISP_READL(ISP_LNC_STATUS);
+ time_out_cnt++;
+ }
+ if (time_out_cnt >= (ISP_TIME_OUT_MAX*1000)) {
+ ret = -1;
+ ISP_PRINT("isp_k: isp lnc status time out\n");
+ }
+ ISP_OWR(ISP_INT_EN, ISP_INT_LENS_LOAD);
+ _write_reg(reg_bits_ptr, counts);
+ }else {
+ ISP_PRINT("isp_k: isp load lnc param error\n");
+ }
+ return ret;
+}
+static int32_t _isp_lnc_param_load(struct isp_reg_bits *reg_bits_ptr, uint32_t counts)
+{
+ int32_t ret = 0;
+ int32_t time_out_cnt = 0;
+ uint32_t reg_value=0x00;
+ printk("isp_k: _isp_lnc_param_load \n");
+ if((0x00!=s_isp_alloc_addr)
+ &&(0x00!=s_isp_alloc_len)) {
+ void *ptr = (void*)s_isp_alloc_addr;
+ uint32_t len=s_isp_alloc_len;
+ #ifndef CONFIG_64BIT
+ dmac_flush_range(ptr, ptr + len);
+ outer_flush_range(__pa(ptr), __pa(ptr) + len);
+ #endif
+ reg_bits_ptr->reg_value=(uint32_t)__pa(reg_bits_ptr->reg_value);
+ {
+ unsigned long flags;
+ reg_value=ISP_READL(ISP_LNC_STATUS);
+ while((0x00==(reg_value&ISP_LNC_STATUS_OK)) && (time_out_cnt < (ISP_TIME_OUT_MAX*1000))) {
+ udelay(1);
+ reg_value=ISP_READL(ISP_LNC_STATUS);
+ time_out_cnt++;
+ }
+ if (time_out_cnt >= (ISP_TIME_OUT_MAX*1000)) {
+ ret = -1;
+ ISP_PRINT("isp_k: isp lnc status time out\n");
+ }
+ _write_reg(reg_bits_ptr, counts);
+ printk("isp_k: load, 0x%x: 0x%x, 0x%x, counts %d \n", reg_bits_ptr, reg_bits_ptr->reg_addr, reg_bits_ptr->reg_value, counts);
+ }
+
+ time_out_cnt = 0;
+ reg_value=ISP_READL(ISP_INT_RAW);
+
+ while ((0x00 == (reg_value&ISP_INT_LENS_LOAD)) && (time_out_cnt < ISP_TIME_OUT_MAX)) {
+ udelay(1);
+ reg_value=ISP_READL(ISP_INT_RAW);
+ time_out_cnt++;
+ }
+ if (time_out_cnt >= ISP_TIME_OUT_MAX) {
+ ret = -1;
+ ISP_PRINT("isp_k: isp load lnc param time out\n");
+ }
+ ISP_OWR(ISP_INT_CLEAR, ISP_INT_LENS_LOAD);
+ }else {
+ ISP_PRINT("isp_k: isp load lnc param error\n");
+ }
+
+ return ret;
+}
+
+static int32_t _isp_lnc_param_set(uint32_t* addr, uint32_t len)
+{
+ int32_t ret = 0;
+
+ if((0x00!=s_isp_alloc_addr)
+ &&(0x00!=addr)) {
+ memcpy((void*)s_isp_alloc_addr, (void*)addr, len);
+ }
+
+ return ret;
+}
+
+static int32_t _isp_free(void)
+{
+ int32_t ret = 0;
+
+ if((0x00!=s_isp_alloc_addr)
+ &&(0x00!=s_isp_alloc_order)) {
+ free_pages(s_isp_alloc_addr, s_isp_alloc_order);
+ s_isp_alloc_order = 0x00;
+ s_isp_alloc_addr = 0x00;
+ s_isp_alloc_len=0x00;
+ }
+
+ return ret;
+}
+
+static int32_t _isp_alloc(unsigned long* addr, uint32_t len)
+{
+ int32_t ret = 0x00;
+ unsigned long buf=0x00;
+ void *ptr = 0x00;
+
+ if((0x00!=s_isp_alloc_addr)
+ &&(len<=s_isp_alloc_len)) {
+ *addr = s_isp_alloc_addr;
+ } else {
+ _isp_free();
+ }
+
+ if(0x00==s_isp_alloc_addr) {
+ s_isp_alloc_len=len;
+ s_isp_alloc_order = get_order(len);
+ s_isp_alloc_addr = __get_free_pages(GFP_KERNEL | __GFP_COMP, s_isp_alloc_order);
+ if (NULL == (void*)s_isp_alloc_addr) {
+ ISP_PRINT("ISP_RAW:_isp_alloc order:0x%x, addr:0x%lx, len:0x%x error\n", s_isp_alloc_order, s_isp_alloc_addr, s_isp_alloc_len);
+ return 1;
+ }
+ ptr = (void*)s_isp_alloc_addr;
+ *addr = s_isp_alloc_addr;
+ buf = virt_to_phys((volatile void *)s_isp_alloc_addr);
+
+ #ifndef CONFIG_64BIT
+ dmac_flush_range(ptr, ptr + len);
+ outer_flush_range(__pa(ptr), __pa(ptr) + len);
+ #endif
+ }
+
+ return ret;
+}
+
+static int32_t _isp_set_clk(enum isp_clk_sel clk_sel)
+{
+ struct clk *clk_parent;
+ char *parent = "clk_256m";
+ int32_t rtn = 0;
+
+ ISP_CHECK_ZERO(g_isp_dev_ptr);
+
+#ifdef CONFIG_SC_FPGA
+ return 0;
+#endif
+
+ switch (clk_sel) {
+ case ISP_CLK_312M:
+ parent = "clk_312m";
+ break;
+ case ISP_CLK_256M:
+ parent = "clk_256m";
+ break;
+ case ISP_CLK_128M:
+ parent = "clk_128m";
+ break;
+ case ISP_CLK_48M:
+ parent = "clk_48m";
+ break;
+ case ISP_CLK_76M8:
+ parent = "clk_76p8m";
+ break;
+
+ case ISP_CLK_NONE:
+ ISP_PRINT("isp_k: ISP close CLK %d \n", (int)clk_get_rate(g_isp_dev_ptr->s_isp_clk));
+ if (g_isp_dev_ptr->s_isp_clk) {
+ clk_disable(g_isp_dev_ptr->s_isp_clk);
+ clk_put(g_isp_dev_ptr->s_isp_clk);
+ g_isp_dev_ptr->s_isp_clk = NULL;
+ }
+ return 0;
+ default:
+ parent = "clk_128m";
+ break;
+ }
+
+ if (NULL == g_isp_dev_ptr->s_isp_clk) {
+ g_isp_dev_ptr->s_isp_clk = parse_clk(isp_dev.this_device->of_node, "clk_isp");
+ if (IS_ERR(g_isp_dev_ptr->s_isp_clk)) {
+ ISP_PRINT("isp_k: parse_clk fail, %p \n", (int)g_isp_dev_ptr->s_isp_clk);
+ return -1;
+ } else {
+ ISP_PRINT("isp_k: get clk_parent ok \n");
+ }
+ } else {
+ clk_disable(g_isp_dev_ptr->s_isp_clk);
+ }
+
+ clk_parent = clk_get(NULL, parent);
+ if (IS_ERR(clk_parent)) {
+ ISP_PRINT("isp_k: dcam_set_clk fail, %p \n", clk_parent);
+ return -1;
+ } else {
+ ISP_PRINT("isp_k: get clk_parent ok \n");
+ }
+
+ rtn = clk_set_parent(g_isp_dev_ptr->s_isp_clk, clk_parent);
+ if(rtn){
+ ISP_PRINT("isp_k: clk_set_parent fail, %d \n", rtn);
+ }
+
+ rtn = clk_enable(g_isp_dev_ptr->s_isp_clk);
+ if (rtn) {
+ ISP_PRINT("isp_k: enable isp clk error.\n");
+ return -1;
+ }
+
+ return rtn;
+}
+
+static int _isp_queue_init(struct isp_queue *queue)
+{
+ if (NULL == queue)
+ return -EINVAL;
+
+ memset(queue, 0x00, sizeof(*queue));
+ queue->write = &queue->node[0];
+ queue->read = &queue->node[0];
+
+ return 0;
+}
+
+static int _isp_queue_write(struct isp_queue *queue, struct isp_node *node)
+{
+ struct isp_node *ori_node;
+
+ if (NULL == queue || NULL == node)
+ return -EINVAL;
+
+ ori_node = queue->write;
+
+ //ISP_PRINT("_isp_queue_write called!\n");
+ *queue->write++ = *node;
+ if (queue->write > &queue->node[ISP_QUEUE_LENGTH-1]) {
+ queue->write = &queue->node[0];
+ }
+
+ if (queue->write == queue->read) {
+ queue->write = ori_node;
+ }
+
+ //ISP_PRINT("_isp_queue_write finished!\n");
+ return 0;
+}
+
+static int _isp_queue_read(struct isp_queue *queue, struct isp_node *node)
+{
+ int ret = 0;
+
+ if (NULL == queue || NULL == node)
+ return -EINVAL;
+ //ISP_PRINT("_isp_queue_read called!\n");
+ if (queue->read != queue->write) {
+ *node = *queue->read++;
+ if (queue->read > &queue->node[ISP_QUEUE_LENGTH-1]) {
+ queue->read = &queue->node[0];
+ }
+ }
+ //ISP_PRINT("_isp_queue_read finished!\n");
+ return ret;
+}
+
+static inline void _isp_regread(char *dst, char *src, size_t n)
+{
+ char tmp = 0;
+ uint32_t tmp2 = 0;
+ char *char_src = 0,*d = 0;
+ uint32_t *d2 = (uint32_t*) dst;
+ uint32_t *int_src = (uint32_t*) src;
+ uint32_t counts = (n>>2)<<2;
+ uint32_t res_counts = n -counts;
+ counts = counts>>2;
+
+ while (counts--) {
+ tmp2 = ISP_READL(int_src);
+ *d2++ = tmp2;
+ int_src++;
+ }
+
+ if(res_counts) {
+ d = (char*) d2;
+ char_src = (char*) int_src;
+ while(res_counts--) {
+ tmp = __raw_readb(char_src);
+ *d = tmp;
+ char_src++;
+ }
+ }
+}
+
+static inline void _isp_regwrite(char *dst, char *src, size_t n)
+{
+ uint32_t tmp2 = 0;
+ char *char_src = 0, *d = 0;
+ uint32_t *int_src = 0, *d2 = 0;
+ uint32_t counts = 0, res_counts = 0;
+
+ int_src = (uint32_t*) src;
+ d2 = (uint32_t*) dst;
+ counts = (n>>2)<<2;
+ res_counts = n - counts;
+ counts = counts>>2;
+
+ while (counts--) {
+ tmp2 = *int_src++;
+ ISP_WRITEL(d2, tmp2);
+ d2++;
+ }
+
+ if(res_counts) {
+ d = (char*) d2;
+ char_src = (char*) int_src;
+
+ while(res_counts--) {
+ tmp2 = *char_src++;
+ __raw_writeb(tmp2, d);
+ d++;
+ }
+ }
+
+}
+static int32_t _isp_get_ctlr(void *param)
+{
+ struct isp_device_t *dev_ptr = (struct isp_device_t *) param;
+
+ down(&dev_ptr->sem_isp);
+
+ return 0;
+}
+static int32_t _isp_put_ctlr(void *param)
+{
+ struct isp_device_t *dev_ptr = (struct isp_device_t *) param;
+
+ up(&dev_ptr->sem_isp);
+
+ return 0;
+}
+
+static int _isp_en_irq(unsigned long int_num)
+{
+ uint32_t ret = 0;
+
+ ISP_WRITEL(ISP_INT_CLEAR, ISP_IRQ_HW_MASK);
+ ISP_WRITEL(ISP_INT_EN, int_num);
+
+ return ret;
+}
+
+static int _isp_registerirq(void)
+{
+ uint32_t ret = 0;
+
+ ret = request_irq(ISP_IRQ, _isp_irq_root, IRQF_SHARED, "ISP", &g_isp_irq);
+
+ return ret;
+}
+static void _isp_unregisterirq(void)
+{
+ free_irq (ISP_IRQ, &g_isp_irq);
+}
+
+static int _isp_cfg_dcam_int(uint32_t param)
+{
+ uint32_t ret = 0;
+
+ s_dcam_int_eb = param;
+
+ return ret;
+}
+
+static void _read_reg(struct isp_reg_bits *reg_bits_ptr, uint32_t counts)
+{
+ uint32_t i = 0;
+ unsigned long reg_val = 0;
+ unsigned long reg_addr = 0;
+
+ for (i = 0; i<counts; ++i) {
+ //reg_addr = reg_bits_ptr[i].reg_addr;
+ reg_addr = ISP_BASE_ADDR + reg_bits_ptr[i].reg_addr;
+ reg_val = ISP_READL(reg_addr);
+ reg_bits_ptr[i].reg_value = reg_val;
+ }
+
+}
+
+static void _write_reg(struct isp_reg_bits *reg_bits_ptr, uint32_t counts)
+{
+ uint32_t i = 0;
+ unsigned long reg_val = 0;
+ unsigned long reg_addr = 0;
+
+ for (i = 0; i<counts; ++i) {
+ reg_addr = reg_bits_ptr[i].reg_addr+ISP_BASE_ADDR;
+ reg_val = reg_bits_ptr[i].reg_value;
+ ISP_WRITEL(reg_addr, reg_val);
+ }
+}
+
+/**********************************************************
+*open the device
+*
+***********************************************************/
+static int32_t _isp_kernel_open (struct inode *node, struct file *pf)
+{
+ int32_t ret = 0;
+ ISP_PRINT ("isp_k: open start \n");
+
+ ISP_CHECK_ZERO(g_isp_dev_ptr);
+
+ ret = _isp_get_ctlr(g_isp_dev_ptr);
+ if (unlikely(ret)) {
+ ISP_PRINT ("isp_k: get control error \n");
+ ret = -EFAULT;
+ return ret;
+ }
+
+ g_isp_dev_ptr->reg_base_addr = (unsigned long)ISP_BASE_ADDR;
+ g_isp_dev_ptr->size = ISP_REG_MAX_SIZE;
+
+ ret = _isp_queue_init(&(g_isp_dev_ptr->queue));
+ if (unlikely(0 != ret)) {
+ ISP_PRINT("isp_k: queue init error\n");
+ ret = -EIO;
+ goto ISP_K_OPEN_ERROR_EXIT;
+ }
+
+ ret = _isp_module_eb();
+ if (unlikely(0 != ret)) {
+ ISP_PRINT("isp_k: enable isp module error\n");
+ ret = -EIO;
+ goto ISP_K_OPEN_ERROR_EXIT;
+ }
+
+ ret = _isp_module_rst();
+ if (unlikely(0 != ret)) {
+ ISP_PRINT("isp_k: reset isp module error \n");
+ ret = -EIO;
+ _isp_module_dis();
+ goto ISP_K_OPEN_ERROR_EXIT;
+ }
+
+ dcam_reg_isr(DCAM_CAP_EOF, _isp_cap_eof, g_isp_dev_ptr);
+ ret = _isp_kernel_thread(g_isp_dev_ptr);
+ if (unlikely(0 != ret)) {
+ ISP_PRINT("isp_k: create isp_kernel_thread fail \n");
+ ret = -EIO;
+ _isp_module_dis();
+ goto ISP_K_OPEN_ERROR_EXIT;
+ }
+
+ ret = _isp_registerirq();
+ if (unlikely(0 != ret)) {
+ ISP_PRINT("isp_k: reg irq fail \n");
+ ret = -EIO;
+ _isp_stop_kernel_thread(g_isp_dev_ptr);
+ _isp_module_dis();
+ goto ISP_K_OPEN_ERROR_EXIT;
+ }
+
+ ISP_PRINT ("isp_k: open end \n");
+ return ret;
+
+ISP_K_OPEN_ERROR_EXIT:
+ ret = _isp_put_ctlr(g_isp_dev_ptr);
+ if (unlikely(ret)) {
+ ISP_PRINT ("isp_k: get control error \n");
+ ret = -EFAULT;
+ }
+ ISP_PRINT ("isp_k: open error \n");
+ return -EIO;
+}
+
+static irqreturn_t _isp_irq_root(int irq, void *dev_id)
+{
+ int32_t ret = 0;
+ uint32_t status = 0;
+ uint32_t irq_line = 0;
+ uint32_t irq_status = 0;
+ unsigned long flag = 0;
+ int32_t i = 0;
+ struct isp_node node = { 0 };
+ struct timeval system_time;
+
+ status = ISP_REG_RD(ISP_INT_STATUS);
+ irq_line = status&ISP_IRQ_HW_MASK;
+ //ISP_PRINT("ISP_RAW:isp_k: isp irq: 0x%x\n", irq_line);
+ if ( 0 == irq_line ) {
+ return IRQ_NONE;
+ }
+
+ spin_lock_irqsave(&isp_spin_lock,flag);
+ if ((ISP_INT_LENS_LOAD & irq_line) == ISP_INT_LENS_LOAD) {
+ irq_line &= ~ISP_INT_LENS_LOAD;
+ ISP_OWR(ISP_INT_CLEAR, ISP_INT_LENS_LOAD);
+ up(&g_isp_dev_ptr->lnc_load.load_done_sem);
+ if (!irq_line) {
+ spin_unlock_irqrestore(&isp_spin_lock, flag);
+ return IRQ_HANDLED;
+ }
+ }
+ for (i = ISP_IRQ_NUM- 1; i >= 0; i--) {
+ if (irq_line & (1 << (uint32_t)i)) {
+ irq_status |= 1 << (uint32_t)i;
+ }
+ irq_line &= ~(uint32_t)(1 << (uint32_t)i); //clear the interrupt flag
+ if(!irq_line) //no interrupt source left
+ break;
+ }
+
+ ISP_WRITEL(ISP_INT_CLEAR, irq_status);
+ node.isp_irq_val = irq_status;
+ _isp_get_systemtime(&system_time);
+ system_time.tv_sec = system_time.tv_sec * 1000000;
+ node.system_time = (uint64_t)(system_time.tv_sec+system_time.tv_usec);
+ ret = _isp_queue_write((struct isp_queue *)&g_isp_dev_ptr->queue, (struct isp_node*)&node);
+ spin_unlock_irqrestore(&isp_spin_lock, flag);
+ up(&g_isp_dev_ptr->sem_isr);
+
+ return IRQ_HANDLED;
+}
+//static irqreturn_t _dcam_irq_root(int irq, void *dev_id)
+void _dcam_isp_root(void)
+{
+ int32_t ret = 0;
+ unsigned long flag = 0;
+ struct isp_node node = { 0 };
+ struct timeval system_time;
+
+ //ISP_PRINT ("ISP_RAW: isp_k: _dcam_isp_root %d \n", s_dcam_int_eb);
+
+ if(0x00 !=s_dcam_int_eb)
+ {
+ spin_lock_irqsave(&isp_spin_lock,flag);
+ #if defined(CONFIG_MACH_CORE3)
+ node.dcam_irq_val = ISP_INT_FETCH_EOF;
+ #else
+ node.dcam_irq_val = ISP_INT_FETCH_SOF;
+ #endif
+
+ //ISP_PRINT("isp_k: dcam sof irq :0x%x\n", node.dcam_irq_val);
+ _isp_get_systemtime(&system_time);
+ system_time.tv_sec = system_time.tv_sec * 1000000;
+ node.system_time = (uint64_t)(system_time.tv_sec+system_time.tv_usec);
+ ret = _isp_queue_write((struct isp_queue *)&g_isp_dev_ptr->queue, (struct isp_node*)&node);
+ spin_unlock_irqrestore(&isp_spin_lock, flag);
+ up(&g_isp_dev_ptr->sem_isr);
+ }
+
+ //return IRQ_HANDLED;
+}
+
+/**********************************************************
+*release the device
+*
+***********************************************************/
+static int32_t _isp_kernel_release (struct inode *node, struct file *pf)
+{
+ int ret = 0;
+ ISP_PRINT ("isp_k: release start \n");
+
+ mutex_lock(&s_isp_lock);
+
+ _isp_unregisterirq();
+ ret = _isp_module_dis();
+
+ mutex_unlock(&s_isp_lock);
+
+ _isp_stop_kernel_thread(g_isp_dev_ptr);
+ ISP_CHECK_ZERO(g_isp_dev_ptr);
+ ret = _isp_put_ctlr(g_isp_dev_ptr);
+ if (unlikely (ret) ) {
+ ISP_PRINT ("isp_k: release control error \n");
+ return -EFAULT;
+ }
+ ISP_PRINT ("isp_k: release end \n");
+ return ret;
+}
+/**********************************************************
+*read info from file
+*size_t size:
+*loff_t p:
+***********************************************************/
+#if 0
+static int32_t _isp_kernel_proc_read (char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ int len = 0;
+ uint32_t reg_buf_len = 200;
+ uint32_t print_len = 0, print_cnt = 0;
+ uint32_t *reg_ptr = 0;
+
+ ISP_PRINT ("isp_k: _isp_kernel_proc_read 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x \n", (uint32_t)page, (uint32_t)start, (uint32_t)off, (uint32_t)count, (uint32_t)eof, (uint32_t)data);
+
+ (void)start; (void)off; (void)count; (void)eof;
+
+ if(0x00==g_isp_device.reg_base_addr)
+ {
+ return 0x00;
+ }
+
+ reg_ptr = (uint32_t*)g_isp_device.reg_base_addr;
+ len += sprintf(page + len, "Context for ISP device \n");
+ len += sprintf(page + len, "********************************************* \n");
+ while (print_len < reg_buf_len) {
+ len += sprintf(page + len, "offset 0x%x : 0x%x, 0x%x, 0x%x, 0x%x \n",
+ print_len,
+ reg_ptr[print_cnt],
+ reg_ptr[print_cnt+1],
+ reg_ptr[print_cnt+2],
+ reg_ptr[print_cnt+3]);
+ print_cnt += 4;
+ print_len += 16;
+ }
+ len += sprintf(page + len, "********************************************* \n");
+ len += sprintf(page + len, "The end of ISP device \n");
+ return len;
+}
+#endif
+/**********************************************************
+*the io controller of isp
+*unsigned int cmd:
+*unsigned long param:
+***********************************************************/
+static long _isp_kernel_ioctl( struct file *fl, unsigned int cmd, unsigned long param)
+{
+ long ret = 0;
+ uint32_t isp_irq, dcam_irq;
+ struct isp_irq_param irq_param = { 0 };
+ struct isp_node isp_node = { 0 };
+ struct isp_reg_param reg_param = { 0 };
+ struct isp_reg_bits *reg_bits_ptr = 0;
+
+ //ISP_PRINT("isp_k:_ioctl called, cmd: %x\n", cmd);
+
+ if (!fl) {
+ return -EINVAL;
+ }
+
+ ISP_CHECK_ZERO(g_isp_dev_ptr);
+
+ if(ISP_IO_IRQ==cmd)
+ {
+ ret = down_interruptible(&g_isp_dev_ptr->sem_isr);
+ if (ret) {
+ ISP_PRINT("isp_k: ioctl irq: down failed ret = %ld",ret);
+ memset(&irq_param, 0, sizeof(irq_param));
+ irq_param.ret_val = ret;
+ ret = copy_to_user ((void*) param, (void*)&irq_param, sizeof(irq_param));
+ if ( 0 != ret) {
+ ISP_PRINT("isp_k: ioctl irq: copy_to_user failed ret = %ld", ret);
+ }
+ ret = -ERESTARTSYS;
+ goto ISP_IOCTL_EXIT;
+ }
+ ret=_isp_queue_read(&g_isp_dev_ptr->queue, &isp_node);
+ if ( 0 != ret) {
+
+ ISP_PRINT("isp_k: ioctl irq: _isp_queue_read error, ret = 0x%x", (uint32_t)ret);
+ ret = -EFAULT;
+ goto ISP_IOCTL_EXIT;
+ }
+
+ irq_param.dcam_irq_val = isp_node.dcam_irq_val;
+ irq_param.isp_irq_val = isp_node.isp_irq_val;
+ isp_irq = isp_node.isp_irq_val;
+ dcam_irq = isp_node.dcam_irq_val;
+ irq_param.irq_val = dcam_irq|isp_irq;
+ irq_param.system_time = isp_node.system_time;
+ ret = copy_to_user ((void*) param, (void*)&irq_param, sizeof(struct isp_irq_param));
+ if ( 0 != ret) {
+
+ ISP_PRINT("isp_k: ioctl irq: copy_to_user error, ret = 0x%x", (uint32_t)ret);
+ ret = -EFAULT;
+ }
+
+ } else {
+
+ mutex_lock(&s_isp_lock);
+
+ switch (cmd)
+ {
+ case ISP_IO_READ: {
+ uint32_t buf_size = 0;
+ //ISP_PRINT(" isp_k:_ioctl read called \n");
+ ret = copy_from_user((void*)&reg_param, (void*)param, sizeof(struct isp_reg_param));
+ if ( 0 != ret) {
+
+ ISP_PRINT("isp_k: ioctl read: copy_to_user error, ret = 0x%x", (uint32_t)ret);
+ ret = -EFAULT;
+ goto IO_READ_EXIT;
+ }
+ buf_size = reg_param.counts*sizeof(struct isp_reg_bits);
+ if (buf_size > g_isp_dev_ptr->buf_len) {
+ ret =-EFAULT;
+ goto IO_READ_EXIT;
+ }
+ reg_bits_ptr = (struct isp_reg_bits*) g_isp_dev_ptr->buf_addr;
+ ret = copy_from_user((void*)reg_bits_ptr, (void*)reg_param.reg_param, buf_size);
+ if ( 0 != ret) {
+
+ ISP_PRINT("isp_k: ioctl read: copy_to_user error, ret = 0x%x", (uint32_t)ret);
+ ret =-EFAULT;
+ goto IO_READ_EXIT;
+ }
+ _read_reg(reg_bits_ptr, reg_param.counts);
+
+ ret = copy_to_user((void*)reg_param.reg_param, (void*)reg_bits_ptr, buf_size);
+ if ( 0 != ret) {
+
+ ISP_PRINT("isp_k: ioctl read: copy_to_user error, ret = 0x%x", (uint32_t)ret);
+ ret = -EFAULT;
+ goto IO_READ_EXIT;
+ }
+ IO_READ_EXIT:
+ if(reg_bits_ptr) {
+ memset((void *)g_isp_dev_ptr->buf_addr, 0x00, buf_size);
+ reg_bits_ptr = NULL;
+ }
+ }
+ break;
+
+ case ISP_IO_WRITE: {
+ uint32_t buf_size = 0;
+ //ISP_PRINT(" isp_k:_ioctl write called \n");
+ ret = copy_from_user((void*)&reg_param, (void*)param, sizeof(struct isp_reg_param));
+ if ( 0 != ret) {
+
+ ISP_PRINT("isp_k: ioctl write: copy_to_user error, ret = 0x%x", (uint32_t)ret);
+ ret = -EFAULT;
+ goto IO_WRITE_EXIT;
+ }
+ buf_size = reg_param.counts*sizeof(struct isp_reg_bits);
+ if(buf_size > g_isp_dev_ptr->buf_len)
+ {
+ ret = -EFAULT;
+ goto IO_WRITE_EXIT;
+ }
+ reg_bits_ptr = (struct isp_reg_bits*) g_isp_dev_ptr->buf_addr;
+
+ ret = copy_from_user((void*)reg_bits_ptr, (void*)reg_param.reg_param, buf_size);
+ if ( 0 != ret) {
+
+ ISP_PRINT("isp_k: ioctl write: copy_to_user error, ret = 0x%x", (uint32_t)ret);
+ ret = -EFAULT;
+ goto IO_WRITE_EXIT;
+ }
+ _write_reg(reg_bits_ptr, reg_param.counts);
+
+ IO_WRITE_EXIT:
+ if(reg_bits_ptr) {
+ memset((void *)g_isp_dev_ptr->buf_addr, 0x00, buf_size);
+ reg_bits_ptr = NULL;
+ }
+
+ }
+ break;
+
+ case ISP_IO_RST: {
+ ISP_PRINT(" isp_k:ioctl restet start \n");
+ g_isp_dev_ptr->lnc_load.cap_eof_flag = 0;
+ ret = _isp_module_rst();
+ if (ret) {
+
+ ISP_PRINT("isp_k: ioctl restet error!\n");
+ ret = -EFAULT;
+ }
+ }
+ break;
+
+ case ISP_IO_SETCLK: {
+ ISP_PRINT(" isp_k:ioctl set clock start \n");
+ }
+ break;
+
+ case ISP_IO_STOP: {
+ unsigned long flag = 0;
+ struct isp_node node = { 0 };
+ ret = _isp_en_irq(0);//dis-enable the interrupt
+ ISP_PRINT("isp_k: ioctl stop start !\n");
+ spin_lock_irqsave(&isp_spin_lock,flag);
+ node.dcam_irq_val = ISP_INT_STOP;
+ ret = _isp_queue_write((struct isp_queue *)&g_isp_dev_ptr->queue, (struct isp_node*)&node);
+ spin_unlock_irqrestore(&isp_spin_lock, flag);
+ up(&g_isp_dev_ptr->sem_isr);
+ }
+ break;
+
+ case ISP_IO_INT: {
+ unsigned long int_num;
+ ret = copy_from_user((void*)&int_num, (void*)param, 0x04);
+ if (ret) {
+ ISP_PRINT ("isp_k:io int copy param error, ret = %d \n", (uint32_t)ret);
+ ret = -EFAULT;
+ goto ISP_IOCTL_LOCKED_CMD_EXIT;
+ }
+ ret = _isp_en_irq(int_num);
+ //ret = _isp_registerirq();
+ if (unlikely(ret)) {
+ ISP_PRINT ("isp_k:enable interrupt error \n");
+ ret = -EFAULT;
+ }
+ }
+ break;
+
+ case ISP_IO_DCAM_INT: {
+ unsigned long int_param;
+ ret = copy_from_user((void*)&int_param, (void*)param, 0x04);
+ if (ret) {
+ ISP_PRINT ("isp_k:dcam int copy params error, ret = %d \n", (uint32_t)ret);
+ ret = -EFAULT;
+ goto ISP_IOCTL_LOCKED_CMD_EXIT;
+ }
+ ret = _isp_cfg_dcam_int(int_param);
+ if (unlikely(ret)) {
+ ISP_PRINT ("isp_k:cfg dcam interrupt error \n");
+ ret = -EFAULT;
+ }
+ }
+ break;
+
+ case ISP_IO_LNC_PARAM: {
+ uint32_t buf_size = 0;
+ uint32_t* addr = 0;
+ ret = copy_from_user((void*)&reg_param, (void*)param, sizeof(struct isp_reg_param));
+ if ( 0 != ret) {
+
+ ISP_PRINT("isp_k: ioctl lnc param: copy_to_user error, ret = 0x%x", (uint32_t)ret);
+ ret = -EFAULT;
+ goto IO_LNC_PARAM_EXIT;
+ }
+ buf_size = reg_param.counts;
+ if(buf_size > g_isp_dev_ptr->buf_len){
+
+ ret = -EFAULT;
+ goto IO_LNC_PARAM_EXIT;
+ }
+ addr = (uint32_t*) g_isp_dev_ptr->buf_addr;
+ ret = copy_from_user((void*)addr, (void*)reg_param.reg_param, buf_size);
+ if ( 0 != ret) {
+
+ ISP_PRINT("isp_k: ioctl lnc param: copy_to_user error, ret = 0x%x", (uint32_t)ret);
+ ret = -EFAULT;
+ goto IO_LNC_PARAM_EXIT;
+ }
+ ret = _isp_lnc_param_set(addr, buf_size);
+ if ( 0 != ret) {
+ ISP_PRINT("isp_k: ioctl lnc param error, ret = 0x%x", (uint32_t)ret);
+ ret = -EFAULT;
+ goto IO_LNC_PARAM_EXIT;
+ }
+
+ IO_LNC_PARAM_EXIT:
+ if(addr) {
+ memset((void *)g_isp_dev_ptr->buf_addr, 0x00, buf_size);
+ addr = NULL;
+ }
+ }
+ break;
+
+ case ISP_IO_LNC: {
+ uint32_t buf_size = 0;
+ ret = copy_from_user((void*)&reg_param, (void*)param, sizeof(struct isp_reg_param));
+ if ( 0 != ret) {
+ ISP_PRINT("isp_k: ioctl lnc: copy_to_user error, ret = 0x%x", (uint32_t)ret);
+ ret = -EFAULT;
+ goto IO_LNC_EXIT;
+ }
+ buf_size = reg_param.counts*sizeof(struct isp_reg_bits);
+ if(buf_size > g_isp_dev_ptr->buf_len)
+ {
+ ret = -EFAULT;
+ ISP_PRINT("isp_k: isp_io_lnc: buf len failed\n");
+ goto IO_LNC_EXIT;
+ }
+ reg_bits_ptr = (struct isp_reg_bits*) g_isp_dev_ptr->buf_addr;
+ ret = copy_from_user((void*)reg_bits_ptr, (void*)reg_param.reg_param, buf_size);
+ if ( 0 != ret) {
+ ISP_PRINT("isp_k: ioctl lnc: copy_to_user error, ret = 0x%x", (uint32_t)ret);
+ ret = -EFAULT;
+ goto IO_LNC_EXIT;
+ }
+
+ if (g_isp_dev_ptr->lnc_load.cap_eof_flag == 0) {
+ ret = _isp_lnc_param_load(reg_bits_ptr, reg_param.counts);
+ } else {
+ memcpy((void *)g_isp_dev_ptr->lnc_load.load_buf, (void *)reg_bits_ptr, buf_size);
+ g_isp_dev_ptr->lnc_load.param_counts = reg_param.counts;
+ g_isp_dev_ptr->lnc_load.load_lnc_flag = 1;
+ ret = down_timeout(&g_isp_dev_ptr->lnc_load.load_done_sem, msecs_to_jiffies(500));
+ }
+ if (unlikely(ret)) {
+ ISP_PRINT ("isp_k:load lnc error \n");
+ ret = -EFAULT;
+ }
+ IO_LNC_EXIT:
+ if(reg_bits_ptr) {
+ memset((void *)g_isp_dev_ptr->buf_addr, 0x00, buf_size);
+ reg_bits_ptr = NULL;
+ }
+ }
+ break;
+
+ case ISP_IO_ALLOC: {
+
+ ret = copy_from_user((void*)&reg_param, (void*)param, sizeof(struct isp_reg_param));
+ if ( 0 != ret) {
+ ISP_PRINT("isp_k: ioctl write: copy_to_user error, ret = 0x%x", (uint32_t)ret);
+ ret = -EFAULT;
+ break;
+ }
+ ret = _isp_alloc(&reg_param.reg_param, reg_param.counts);
+ if ( 0 == ret) {
+ ret = copy_to_user((void*)param, (void*)&reg_param, sizeof(struct isp_reg_param));
+ } else {
+ ISP_PRINT("isp_k: ioctl alloc error, ret = 0x%x", (uint32_t)ret);
+ ret = -EFAULT;
+ }
+ }
+ break;
+
+ default:
+ mutex_unlock(&s_isp_lock);
+ ISP_PRINT("isp_k:_ioctl cmd is unsupported, cmd = %x\n", (int32_t)cmd);
+ return -EFAULT;
+ }
+
+ ISP_IOCTL_LOCKED_CMD_EXIT:
+ mutex_unlock(&s_isp_lock);
+ }
+
+ //ISP_PRINT("isp_k:_ioctl finished\n");
+ ISP_IOCTL_EXIT:
+ return ret;
+}
+
+static int _isp_probe(struct platform_device *pdev)
+{
+ int ret = 0;
+ ISP_PRINT ("isp_k:probe start\n");
+
+ ret = misc_register(&isp_dev);
+ if (ret) {
+ ISP_PRINT ( "isp_k:probe cannot register miscdev on minor=%d (%d)\n",(int32_t)ISP_MINOR, (int32_t)ret);
+ return ret;
+ }
+ mutex_init(&s_isp_lock);
+/*
+ isp_proc_file = create_proc_read_entry("driver/sprd_isp" ,
+ 0444,
+ NULL,
+ _isp_kernel_proc_read,
+ NULL);
+ if (unlikely(NULL == isp_proc_file)) {
+ ISP_PRINT("isp_k:probe Can't create an entry for isp in /proc \n");
+ ret = ENOMEM;
+ return ret;
+ }
+*/
+ isp_dev.this_device->of_node = pdev->dev.of_node;
+ parse_baseaddress(pdev->dev.of_node);
+ ISP_PRINT (" isp_k:probe end\n");
+ return 0;
+}
+
+static int _isp_remove(struct platform_device * dev)
+{
+ ISP_PRINT ("isp_k: remove start \n");
+
+ misc_deregister(&isp_dev);
+
+ if (isp_proc_file) {
+ remove_proc_entry("driver/sprd_isp", NULL);
+ }
+
+ ISP_PRINT ("isp_k: remove end !\n");
+
+ return 0;
+}
+
+static int32_t __init isp_kernel_init(void)
+{
+ int32_t ret = 0;
+ unsigned long addr = 0;
+ ISP_PRINT ("isp_k: init start \n");
+ if (platform_driver_register(&isp_driver) != 0) {
+ ISP_PRINT ("isp_kernel_init: platform device register error \n");
+ return -1;
+ }
+
+ g_isp_dev_ptr = (struct isp_device_t*)vzalloc(sizeof(struct isp_device_t));
+ ISP_CHECK_ZERO(g_isp_dev_ptr);
+ init_MUTEX(&g_isp_dev_ptr->sem_isp);
+ init_MUTEX_LOCKED(&g_isp_dev_ptr->sem_isr); /*for interrupt */
+ g_isp_dev_ptr->s_isp_clk = NULL;
+ g_isp_dev_ptr->s_isp_clk_mm_i = NULL;
+ g_isp_dev_ptr->buf_addr = 0;
+ g_isp_dev_ptr->buf_len = 0;
+
+ g_isp_dev_ptr->buf_addr = (unsigned long)vzalloc(ISP_BUF_MAX_SIZE);
+ if (0 == g_isp_dev_ptr->buf_addr) {
+ ret = -1;
+ ISP_PRINT ("isp_kernel_init 1: alloc error \n");
+ goto ISP_K_INIT_EXIT;
+ }
+ g_isp_dev_ptr->buf_len = ISP_BUF_MAX_SIZE;
+
+ g_isp_dev_ptr->lnc_load.load_buf = (unsigned long)vzalloc(ISP_BUF_MAX_SIZE);
+ if (0 == g_isp_dev_ptr->lnc_load.load_buf) {
+ ret = -1;
+ ISP_PRINT ("isp_kernel_init 3: alloc error \n");
+ goto ISP_K_INIT_EXIT;
+ }
+ ret = _isp_alloc(&addr, ISP_BUF_MAX_SIZE);
+ if (ret) {
+ ret = -1;
+ ISP_PRINT ("isp_kernel_init 2: alloc error \n");
+ goto ISP_K_INIT_EXIT;
+ }
+
+ ISP_PRINT ("isp_k: init end\n");
+
+ return ret;
+
+ISP_K_INIT_EXIT:
+ _isp_free();
+ if (g_isp_dev_ptr->buf_addr) {
+ vfree((void *)g_isp_dev_ptr->buf_addr);
+ g_isp_dev_ptr->buf_addr = 0;
+ g_isp_dev_ptr->buf_len = 0;
+ }
+ if (g_isp_dev_ptr->lnc_load.load_buf) {
+ vfree((void *)g_isp_dev_ptr->lnc_load.load_buf);
+ g_isp_dev_ptr->lnc_load.load_buf = 0;
+ }
+ if (g_isp_dev_ptr) {
+ vfree(g_isp_dev_ptr);
+ g_isp_dev_ptr = 0;
+ }
+
+ return ret;
+}
+
+static void isp_kernel_exit(void)
+{
+ ISP_PRINT ("isp_k: exit start \n");
+
+ platform_driver_unregister(&isp_driver);
+ mutex_destroy(&s_isp_lock);
+ _isp_free();
+ ISP_CHECK_ZERO_VOID(g_isp_dev_ptr);
+ if (g_isp_dev_ptr->buf_addr) {
+ vfree((void *)g_isp_dev_ptr->buf_addr);
+ g_isp_dev_ptr->buf_addr = 0;
+ g_isp_dev_ptr->buf_len = 0;
+ }
+ if(g_isp_dev_ptr->lnc_load.load_buf) {
+ vfree((void *)g_isp_dev_ptr->lnc_load.load_buf);
+ g_isp_dev_ptr->lnc_load.load_buf = 0;
+ }
+ vfree(g_isp_dev_ptr);
+ g_isp_dev_ptr = NULL;
+
+ ISP_PRINT ("isp_k: exit end \n");
+}
+
+module_init(isp_kernel_init);
+module_exit(isp_kernel_exit);
+
+MODULE_DESCRIPTION("Isp Driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/sprd_isp/isp1.0/isp_drv_null.c b/drivers/media/sprd_isp/isp1.0/isp_drv_null.c
new file mode 100644
index 00000000..4e8b84e0
--- /dev/null
+++ b/drivers/media/sprd_isp/isp1.0/isp_drv_null.c
@@ -0,0 +1,305 @@
+/*
+ * 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/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/poll.h>
+#include <linux/fs.h>
+#include <linux/irq.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/miscdevice.h>
+#include <asm/io.h>
+#include <linux/file.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/sched.h>
+#include <linux/spinlock_types.h>
+#include <linux/semaphore.h>
+#include <linux/delay.h>
+#include <linux/proc_fs.h>
+#include <video/isp_drv_kernel.h>
+
+#include <linux/clk.h>
+#include <asm/cacheflush.h>
+
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#include "Shark_reg_isp.h"
+
+
+#define DEBUG_ISP_DRV
+#ifdef DEBUG_ISP_DRV
+#define ISP_PRINT printk
+#else
+#define ISP_PRINT(...)
+#endif
+#define ISP_MINOR MISC_DYNAMIC_MINOR/*isp minor number*/
+static struct proc_dir_entry* isp_proc_file;
+
+/**file operation functions declare**/
+static int32_t _isp_kernel_open(struct inode *node, struct file *filp);
+static int32_t _isp_kernel_release(struct inode *node, struct file *filp);
+static long _isp_kernel_ioctl( struct file *fl, unsigned int cmd, unsigned long param);
+/**driver' functions declare**/
+static int32_t _isp_probe(struct platform_device *pdev);
+static int32_t _isp_remove(struct platform_device *dev);
+/**module' functions declare**/
+static int32_t __init isp_kernel_init(void);
+static void isp_kernel_exit(void);
+
+static struct file_operations isp_fops = {
+ .owner = THIS_MODULE,
+ .open = _isp_kernel_open,
+ .unlocked_ioctl = _isp_kernel_ioctl,
+ .release = _isp_kernel_release,
+};
+
+static struct miscdevice isp_dev = {
+ .minor = ISP_MINOR,
+ .name = "sprd_isp",
+ .fops = &isp_fops,
+};
+
+static const struct of_device_id of_match_table_isp[] = {
+ { .compatible = "sprd,sprd_isp", },
+ { },
+};
+
+static struct platform_driver isp_driver = {
+ .probe = _isp_probe,
+ .remove = _isp_remove,
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "sprd_isp",
+ .of_match_table = of_match_ptr(of_match_table_isp),
+ },
+};
+
+/**********************************************************
+*open the device
+*
+***********************************************************/
+static int32_t _isp_kernel_open (struct inode *node, struct file *pf)
+{
+ int32_t ret = 0;
+ ISP_PRINT ("isp_k: open start \n");
+
+ return ret;
+}
+
+//static irqreturn_t _dcam_irq_root(int irq, void *dev_id)
+void _dcam_isp_root(void)
+{
+ int32_t ret = 0;
+
+ return IRQ_HANDLED;
+}
+
+/**********************************************************
+*release the device
+*
+***********************************************************/
+static int32_t _isp_kernel_release (struct inode *node, struct file *pf)
+{
+ int ret = 0;
+ ISP_PRINT ("isp_k: release start \n");
+
+ ISP_PRINT ("isp_k: release end \n");
+ return ret;
+}
+/**********************************************************
+*read info from file
+*size_t size:
+*loff_t p:
+***********************************************************/
+static int32_t _isp_kernel_proc_read (char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ int len = 0;
+#if 0
+ uint32_t reg_buf_len = 200;
+ uint32_t print_len = 0, print_cnt = 0;
+ uint32_t *reg_ptr = 0;
+
+ ISP_PRINT ("isp_k: _isp_kernel_proc_read 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x \n", (uint32_t)page, (uint32_t)start, (uint32_t)off, (uint32_t)count, (uint32_t)eof, (uint32_t)data);
+
+ (void)start; (void)off; (void)count; (void)eof;
+
+ if(0x00==g_isp_device.reg_base_addr)
+ {
+ return 0x00;
+ }
+
+ reg_ptr = (uint32_t*)g_isp_device.reg_base_addr;
+ len += sprintf(page + len, "Context for ISP device \n");
+ len += sprintf(page + len, "********************************************* \n");
+ while (print_len < reg_buf_len) {
+ len += sprintf(page + len, "offset 0x%x : 0x%x, 0x%x, 0x%x, 0x%x \n",
+ print_len,
+ reg_ptr[print_cnt],
+ reg_ptr[print_cnt+1],
+ reg_ptr[print_cnt+2],
+ reg_ptr[print_cnt+3]);
+ print_cnt += 4;
+ print_len += 16;
+ }
+ len += sprintf(page + len, "********************************************* \n");
+ len += sprintf(page + len, "The end of ISP device \n");
+#endif
+ return len;
+}
+
+/**********************************************************
+*the io controller of isp
+*unsigned int cmd:
+*unsigned long param:
+***********************************************************/
+static long _isp_kernel_ioctl( struct file *fl, unsigned int cmd, unsigned long param)
+{
+ long ret = 0;
+
+ if(ISP_IO_IRQ==cmd)
+ {
+ } else {
+
+ switch (cmd)
+ {
+ case ISP_IO_READ: {
+ }
+ break;
+
+ case ISP_IO_WRITE: {
+ }
+ break;
+
+ case ISP_IO_RST: {
+ ISP_PRINT(" isp_k:ioctl restet start \n");
+ }
+ break;
+
+ case ISP_IO_SETCLK:
+ ISP_PRINT(" isp_k:ioctl set clock start \n");
+ break;
+
+ case ISP_IO_STOP: {
+ }
+ break;
+
+ case ISP_IO_INT: {
+ }
+ break;
+
+ case ISP_IO_DCAM_INT: {
+ }
+ break;
+
+ case ISP_IO_LNC_PARAM: {
+ }
+ break;
+
+ case ISP_IO_LNC: {
+ }
+ break;
+
+ case ISP_IO_ALLOC: {
+ }
+ break;
+
+ default:
+ ISP_PRINT("isp_k:_ioctl cmd is unsupported, cmd = %x\n", (int32_t)cmd);
+ return -EFAULT;
+ }
+
+ }
+
+ //ISP_PRINT("isp_k:_ioctl finished\n");
+ ISP_IOCTL_EXIT:
+ return ret;
+}
+
+static int _isp_probe(struct platform_device *pdev)
+{
+ int ret = 0;
+ ISP_PRINT ("isp_k:probe start\n");
+
+ ret = misc_register(&isp_dev);
+ if (ret) {
+ ISP_PRINT ( "isp_k:probe cannot register miscdev on minor=%d (%d)\n",(int32_t)ISP_MINOR, (int32_t)ret);
+ return ret;
+ }
+/*
+ isp_proc_file = create_proc_read_entry("driver/sprd_isp" ,
+ 0444,
+ NULL,
+ _isp_kernel_proc_read,
+ NULL);
+ if (unlikely(NULL == isp_proc_file)) {
+ ISP_PRINT("isp_k:probe Can't create an entry for isp in /proc \n");
+ ret = ENOMEM;
+ return ret;
+ }
+*/
+ isp_dev.this_device->of_node = pdev->dev.of_node;
+ ISP_PRINT (" isp_k:probe end\n");
+ return 0;
+}
+
+static int _isp_remove(struct platform_device * dev)
+{
+ ISP_PRINT ("isp_k: remove start \n");
+
+ misc_deregister(&isp_dev);
+
+ if (isp_proc_file) {
+ remove_proc_entry("driver/sprd_isp", NULL);
+ }
+
+ ISP_PRINT ("isp_k: remove end !\n");
+
+ return 0;
+}
+
+static int32_t __init isp_kernel_init(void)
+{
+ int32_t ret = 0;
+ uint32_t addr = 0;
+ ISP_PRINT ("isp_k: init start \n");
+ if (platform_driver_register(&isp_driver) != 0) {
+ ISP_PRINT ("isp_kernel_init: platform device register error \n");
+ return -1;
+ }
+
+ ISP_PRINT ("isp_k: init end\n");
+
+ return ret;
+}
+
+static void isp_kernel_exit(void)
+{
+ ISP_PRINT ("isp_k: exit start \n");
+
+ platform_driver_unregister(&isp_driver);
+
+ ISP_PRINT ("isp_k: exit end \n");
+}
+
+module_init(isp_kernel_init);
+module_exit(isp_kernel_exit);
+
+MODULE_DESCRIPTION("Isp Driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/sprd_isp/isp2.0/pike/inc/isp_block.h b/drivers/media/sprd_isp/isp2.0/pike/inc/isp_block.h
new file mode 100644
index 00000000..63103ea0
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/inc/isp_block.h
@@ -0,0 +1,72 @@
+/*
+ * 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 "isp_drv.h"
+
+int32_t isp_k_cfg_pgg(struct isp_io_param *param);
+int32_t isp_k_cfg_blc(struct isp_io_param *param);
+int32_t isp_k_cfg_rgb_gain(struct isp_io_param *param);
+int32_t isp_k_cfg_pwd(struct isp_io_param *param);
+int32_t isp_k_cfg_nlc(struct isp_io_param *param);
+int32_t isp_k_cfg_2d_lsc(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_1d_lsc(struct isp_io_param *param);
+int32_t isp_k_cfg_binning(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_awb(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_raw_aem(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_bpc(struct isp_io_param *param);
+int32_t isp_k_cfg_bdn(struct isp_io_param *param);
+int32_t isp_k_cfg_grgb(struct isp_io_param *param);
+int32_t isp_k_cfg_rgb_gain2(struct isp_io_param *param);
+int32_t isp_k_cfg_nlm(struct isp_io_param *param);
+int32_t isp_k_cfg_cfa(struct isp_io_param *param);
+int32_t isp_k_cfg_cmc10(struct isp_io_param *param);
+int32_t isp_k_cfg_hdr(struct isp_io_param *param);
+int32_t isp_k_cfg_gamma(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_cmc8(struct isp_io_param *param);
+int32_t isp_k_cfg_ct(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_hsv(struct isp_io_param *param);
+int32_t isp_k_cfg_rgb_afm(struct isp_io_param *param);
+int32_t isp_k_cfg_cce(struct isp_io_param *param);
+int32_t isp_k_cfg_pre_cdn_rgb(struct isp_io_param *param);
+int32_t isp_k_cfg_yuv_precdn(struct isp_io_param *param);
+int32_t isp_k_cfg_posterize(struct isp_io_param *param);
+int32_t isp_k_cfg_csc(struct isp_io_param *param);
+int32_t isp_k_cfg_yiq_aem(struct isp_io_param *param);
+int32_t isp_k_cfg_anti_flicker(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_yiq_afm(struct isp_io_param *param);
+int32_t isp_k_cfg_prefilter(struct isp_io_param *param);
+int32_t isp_k_cfg_brightness(struct isp_io_param *param);
+int32_t isp_k_cfg_contrast(struct isp_io_param *param);
+int32_t isp_k_cfg_hist(struct isp_io_param *param);
+int32_t isp_k_cfg_hist2(struct isp_io_param *param);
+int32_t isp_k_cfg_aca(struct isp_io_param *param);
+int32_t isp_k_cfg_yuv_cdn(struct isp_io_param *param);
+int32_t isp_k_cfg_edge(struct isp_io_param *param);
+int32_t isp_k_cfg_css(struct isp_io_param *param);
+int32_t isp_k_cfg_csa(struct isp_io_param *param);
+int32_t isp_k_cfg_post_cdn(struct isp_io_param *param);
+int32_t isp_k_cfg_hue(struct isp_io_param *param);
+int32_t isp_k_cfg_emboss(struct isp_io_param *param);
+int32_t isp_k_cfg_ydelay(struct isp_io_param *param);
+int32_t isp_k_cfg_ygamma(struct isp_io_param *param, struct isp_k_private *isp_private);;
+int32_t isp_k_cfg_iircnr(struct isp_io_param *param);
+int32_t isp_k_cfg_fetch(struct isp_io_param *param);
+int32_t isp_k_cfg_store(struct isp_io_param *param);
+int32_t isp_k_cfg_dispatch(struct isp_io_param *param);
+int32_t isp_k_cfg_arbiter(struct isp_io_param *param);
+int32_t isp_k_cfg_common(struct isp_io_param *param);
+int32_t isp_k_cfg_raw_sizer(struct isp_io_param *param);
+//pike add
+int32_t isp_k_cfg_yuv_nlm(struct isp_io_param *param);
+int32_t isp_k_cfg_uv_prefilter(struct isp_io_param *param);
+int32_t isp_k_cfg_rgb2y(struct isp_io_param *param); \ No newline at end of file
diff --git a/drivers/media/sprd_isp/isp2.0/pike/inc/isp_drv.h b/drivers/media/sprd_isp/isp2.0/pike/inc/isp_drv.h
new file mode 100644
index 00000000..d27f4e40
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/inc/isp_drv.h
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+#ifndef _ISP_DRV_HEADER_
+#define _ISP_DRV_HEADER_
+
+#include <linux/semaphore.h>
+#include <linux/spinlock_types.h>
+
+#define ISP_QUEUE_LENGTH 16
+#define ISP_BING4AWB_NUM 2
+
+struct isp_node {
+ uint32_t irq_val0;
+ uint32_t irq_val1;
+ uint32_t irq_val2;
+ uint32_t irq_val3;
+ uint32_t reserved;
+ struct isp_time time;
+};
+
+struct isp_queue {
+ struct isp_node node[ISP_QUEUE_LENGTH];
+ struct isp_node *write;
+ struct isp_node *read;
+};
+
+struct isp_b4awb_buf {
+ uint32_t buf_id;
+ uint32_t buf_flag;
+ unsigned long buf_phys_addr;
+};
+
+struct isp_k_private {
+ atomic_t users;
+ struct device_node *dn;
+ struct clk *clock;
+ struct semaphore device_lock;
+ struct semaphore ioctl_lock;
+ unsigned long block_buf_addr;
+ uint32_t block_buf_len;
+ unsigned long reg_buf_addr;
+ uint32_t reg_buf_len;
+ uint32_t lsc_load_buf_id;
+ uint32_t lsc_update_buf_id;
+ unsigned long raw_aem_buf_addr;
+ uint32_t raw_aem_buf_len;
+ uint32_t ct_load_buf_id;
+ unsigned long full_gamma_buf_addr;
+ uint32_t full_gamma_buf_len;
+ uint32_t full_gamma_buf_id;
+ unsigned long yuv_ygamma_buf_addr;
+ uint32_t yuv_ygamma_buf_len;
+ uint32_t yuv_ygamma_buf_id;
+ unsigned long raw_awbm_buf_addr;
+ uint32_t raw_awbm_buf_len;
+ struct isp_b4awb_buf b4awb_buf[ISP_BING4AWB_NUM];
+ uint32_t lsc_buf_phys_addr;
+ unsigned long yiq_antiflicker_buf_addr;
+ uint32_t yiq_antiflicker_len;
+ uint32_t yiq_antiflicker_order;
+ unsigned long yiq_aem_buf_addr;
+ uint32_t yiq_aem_buf_len;
+};
+
+struct isp_drv_private {
+ spinlock_t isr_lock;
+ struct semaphore isr_done_lock;
+ struct isp_queue queue;
+};
+
+struct isp_k_file {
+ struct isp_k_private *isp_private;
+ struct isp_drv_private drv_private;
+};
+
+int32_t isp_get_int_num(struct isp_node *node);
+void isp_clr_int(void);
+void isp_en_irq(uint32_t irq_mode);
+int32_t isp_axi_bus_waiting(void);
+int32_t isp_capability(void *param);
+int32_t isp_cfg_param(void *param, struct isp_k_private *isp_private);
+
+#endif
diff --git a/drivers/media/sprd_isp/isp2.0/pike/inc/isp_reg.h b/drivers/media/sprd_isp/isp2.0/pike/inc/isp_reg.h
new file mode 100644
index 00000000..48e9b4fe
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/inc/isp_reg.h
@@ -0,0 +1,801 @@
+/*
+ * 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 <mach/hardware.h>
+#ifndef CONFIG_64BIT
+#include <soc/sprd/hardware.h>
+#endif
+#include "parse_hwinfo_tshark2.h"
+
+#define ISP_BASE_ADDR ISP_BASE//SPRD_ISP_BASE
+
+/*isp sub block: Interrupt*/
+#define ISP_INT_STATUS (ISP_BASE_ADDR+0x0000UL)
+#define ISP_INT_EN0 (ISP_BASE_ADDR+0x0014UL)
+#define ISP_INT_CLR0 (ISP_BASE_ADDR+0x0018UL)
+#define ISP_INT_RAW0 (ISP_BASE_ADDR+0x001CUL)
+#define ISP_INT_INT0 (ISP_BASE_ADDR+0x0020UL)
+#define ISP_INT_EN1 (ISP_BASE_ADDR+0x0024UL)
+#define ISP_INT_CLR1 (ISP_BASE_ADDR+0x0028UL)
+#define ISP_INT_RAW1 (ISP_BASE_ADDR+0x002CUL)
+#define ISP_INT_INT1 (ISP_BASE_ADDR+0x0030UL)
+#define ISP_INT_EN2 (ISP_BASE_ADDR+0x0034UL)
+#define ISP_INT_CLR2 (ISP_BASE_ADDR+0x0038UL)
+#define ISP_INT_RAW2 (ISP_BASE_ADDR+0x003CUL)
+#define ISP_INT_INT2 (ISP_BASE_ADDR+0x0040UL)
+#define ISP_INT_EN3 (ISP_BASE_ADDR+0x0044UL)
+#define ISP_INT_CLR3 (ISP_BASE_ADDR+0x0048UL)
+#define ISP_INT_RAW3 (ISP_BASE_ADDR+0x004CUL)
+#define ISP_INT_INT3 (ISP_BASE_ADDR+0x0050UL)
+#define ISP_INT_ALL_DONE_CTRL (ISP_BASE_ADDR+0x0054UL)
+
+/*isp sub block: Fetch*/
+#define ISP_FETCH_MEM_STATUS0 (ISP_BASE_ADDR+0x0100UL)
+#define ISP_FETCH_MEM_STATUS1 (ISP_BASE_ADDR+0x0104UL)
+#define ISP_FETCH_DCAM_STATUS0 (ISP_BASE_ADDR+0x0108UL)
+#define ISP_FETCH_DCAM_STATUS1 (ISP_BASE_ADDR+0x010CUL)
+#define ISP_FETCH_PARAM (ISP_BASE_ADDR+0x0114UL)
+#define ISP_FETCH_START (ISP_BASE_ADDR+0x0118UL)
+#define ISP_FETCH_SLICE_SIZE (ISP_BASE_ADDR+0x0120UL)
+#define ISP_FETCH_SLICE_Y_ADDR (ISP_BASE_ADDR+0x0124UL)
+#define ISP_FETCH_SLICE_Y_PITCH (ISP_BASE_ADDR+0x0128UL)
+#define ISP_FETCH_SLICE_U_ADDR (ISP_BASE_ADDR+0x012CUL)
+#define ISP_FETCH_SLICE_U_PITCH (ISP_BASE_ADDR+0x0130UL)
+#define ISP_FETCH_SLICE_V_ADDR (ISP_BASE_ADDR+0x0134UL)
+#define ISP_FETCH_SLICE_V_PITCH (ISP_BASE_ADDR+0x0138UL)
+#define ISP_FETCH_MIPI_WORD_INFO (ISP_BASE_ADDR+0x013CUL)
+#define ISP_FETCH_MIPI_BYTE_INFO (ISP_BASE_ADDR+0x0140UL)
+#define ISP_FETCH_BAYER_MODE (ISP_BASE_ADDR+0x0144UL)
+
+/*isp sub block: Store*/
+#define ISP_STORE_STATUS_MEM0 (ISP_BASE_ADDR+0x0200UL)
+#define ISP_STORE_STATUS_MEM1 (ISP_BASE_ADDR+0x0204UL)
+#define ISP_STORE_STATUS_DCAM0 (ISP_BASE_ADDR+0x0208UL)
+#define ISP_STORE_STATUS_DCAM1 (ISP_BASE_ADDR+0x020CUL)
+#define ISP_STORE_PARAM (ISP_BASE_ADDR+0x0214UL)
+#define ISP_STORE_SLICE_SIZE (ISP_BASE_ADDR+0x0218UL)
+#define ISP_STORE_BORDER (ISP_BASE_ADDR+0x021CUL)
+#define ISP_STORE_Y_ADDR (ISP_BASE_ADDR+0x0220UL)
+#define ISP_STORE_Y_PITCH (ISP_BASE_ADDR+0x0224UL)
+#define ISP_STORE_U_ADDR (ISP_BASE_ADDR+0x0228UL)
+#define ISP_STORE_U_PITCH (ISP_BASE_ADDR+0x022CUL)
+#define ISP_STORE_V_ADDR (ISP_BASE_ADDR+0x0230UL)
+#define ISP_STORE_V_PITCH (ISP_BASE_ADDR+0x0234UL)
+#define ISP_STORE_SHADOW_CLR (ISP_BASE_ADDR+0x0238UL)
+
+/*isp sub block: dispatch(pike different from tshark2)*/
+#define ISP_DISPATCH_STATUS_CH0 (ISP_BASE_ADDR+0x0300UL)
+#define ISP_DISPATCH_STATUS_CH1 (ISP_BASE_ADDR+0x0304UL)
+//#define ISP_DISPATCH_STATUS_COMM (ISP_BASE_ADDR+0x0308UL)
+//#define ISP_DISPATCH_STATUS1_CH0 (ISP_BASE_ADDR+0x030CUL)
+//#define ISP_DISPATCH_STATUS1_CH1 (ISP_BASE_ADDR+0x0310UL)
+#define ISP_DISPATCH_CH0_BAYER (ISP_BASE_ADDR+0x0314UL)
+#define ISP_DISPATCH_CH0_SIZE (ISP_BASE_ADDR+0x0318UL)
+#define ISP_DISPATCH_CH1_SIZE (ISP_BASE_ADDR+0x031CUL)
+//#define ISP_DISPATCH_DLY (ISP_BASE_ADDR+0x0320UL)
+//#define ISP_DISPATCH_CH1_BAYER (ISP_BASE_ADDR+0x0324UL)
+//#define ISP_DISPATCH_HW_CTRL_CH0 (ISP_BASE_ADDR+0x0328UL)
+//#define ISP_DISPATCH_HW_CTRL_CH1 (ISP_BASE_ADDR+0x032CUL)
+
+/*isp sub block: arbiter*/
+#define ISP_ARBITER_WR_STATUS (ISP_BASE_ADDR+0x0400UL)
+#define ISP_ARBITER_RD_STATUS (ISP_BASE_ADDR+0x0404UL)
+#define ISP_ARBITER_PARAM (ISP_BASE_ADDR+0x0414UL)
+#define ISP_ARBITER_ENDIAN_CH0 (ISP_BASE_ADDR+0x0418UL)
+#define ISP_ARBITER_ENDIAN_CH1 (ISP_BASE_ADDR+0x041CUL)
+//#define ISP_ARBITER_CTRL (ISP_BASE_ADDR+0x0420UL)//pike has no this register
+
+/*isp sub block: axi*/
+#define ISP_AXI_WR_MASTER_STATUS (ISP_BASE_ADDR+0x0500UL)
+#define ISP_AXI_RD_MASTER_STATUS (ISP_BASE_ADDR+0x0504UL)
+#define ISP_AXI_ITI2AXIM_CTRL (ISP_BASE_ADDR+0x0514UL)
+//#define ISP_AXI_CONVERT_WR_CTRL (ISP_BASE_ADDR+0x0518UL)//pike has no this register
+
+/*isp sub block: raw sizer(pike has no this module)*/
+/*#define ISP_RAW_SIZER_STATUS0 (ISP_BASE_ADDR+0x0600UL)
+#define ISP_RAW_SIZER_PARAM (ISP_BASE_ADDR+0x0614UL)
+#define ISP_RAW_SIZER_CROP_SRC (ISP_BASE_ADDR+0x0618UL)
+#define ISP_RAW_SIZER_CROP_DST (ISP_BASE_ADDR+0x061CUL)
+#define ISP_RAW_SIZER_CROP_START (ISP_BASE_ADDR+0x0620UL)
+#define ISP_RAW_SIZER_DST (ISP_BASE_ADDR+0x0624UL)
+#define ISP_RAW_SIZER_BPC (ISP_BASE_ADDR+0x0628UL)
+#define ISP_RAW_SIZER_HCOEFF0 (ISP_BASE_ADDR+0x062CUL)
+#define ISP_RAW_SIZER_VCOEFF0 (ISP_BASE_ADDR+0x0684UL)
+#define ISP_RAW_SIZER_INIT_HOR0 (ISP_BASE_ADDR+0x06B0UL)
+#define ISP_RAW_SIZER_INIT_HOR1 (ISP_BASE_ADDR+0x06B4UL)
+#define ISP_RAW_SIZER_INIT_HOR2 (ISP_BASE_ADDR+0x06B8UL)
+#define ISP_RAW_SIZER_INIT_VER0 (ISP_BASE_ADDR+0x06BCUL)
+#define ISP_RAW_SIZER_INIT_VER1 (ISP_BASE_ADDR+0x06C0UL)
+#define ISP_RAW_SIZER_INIT_VER2 (ISP_BASE_ADDR+0x06C4UL)*/
+
+/*isp sub block: common*/
+#define ISP_COMMON_VERSION (ISP_BASE_ADDR+0x0700UL)
+#define ISP_COMMON_STATUS0 (ISP_BASE_ADDR+0x0704UL)
+#define ISP_COMMON_STATUS1 (ISP_BASE_ADDR+0x0708UL)
+#define ISP_COMMON_CTRL_CH0 (ISP_BASE_ADDR+0x0714UL)
+#define ISP_COMMON_SPACE_SEL (ISP_BASE_ADDR+0x0718UL)
+//#define ISP_COMMON_CTRL_CH1 (ISP_BASE_ADDR+0x071CUL)
+//#define ISP_COMMON_CTRL_AWBM (ISP_BASE_ADDR+0x0720UL)
+#define ISP_COMMON_PMU_RAW_MASK (ISP_BASE_ADDR+0x0724UL)
+#define ISP_COMMON_PMU_HW_MASK (ISP_BASE_ADDR+0x0728UL)
+#define ISP_COMMON_PMU_HW_ENABLE (ISP_BASE_ADDR+0x072CUL)
+#define ISP_COMMON_PMU_SW_SWITCH (ISP_BASE_ADDR+0x0730UL)
+#define ISP_COMMON_PMU_SW_TOGGLE (ISP_BASE_ADDR+0x0734UL)
+#define ISP_COMMON_LBUF_OFFSET (ISP_BASE_ADDR+0x0738UL)
+#define ISP_SHADOW_CTRL_CH0 (ISP_BASE_ADDR+0x073CUL)
+#define ISP_SHADOW_CTRL_CH1 (ISP_BASE_ADDR+0x0740UL)
+//#define ISP_COMMON_3A_CTRL0 (ISP_BASE_ADDR+0x0744UL)
+//#define ISP_COMMON_LBUF_OFFSET1 (ISP_BASE_ADDR+0x0748UL)
+//#define ISP_COMMON_3A_CTRL1 (ISP_BASE_ADDR+0x074CUL)
+#define ISP_COMMON_RESERVED0 (ISP_BASE_ADDR+0x0750UL)
+#define ISP_COMMON_RESERVED1 (ISP_BASE_ADDR+0x0754UL)
+
+/*isp sub block: Pre Global Gain*/
+#define ISP_PGG_STATUS (ISP_BASE_ADDR+0x1000UL)
+#define ISP_PGG_PARAM (ISP_BASE_ADDR+0x1014UL)
+
+/*isp sub block: BLC: back level calibration*/
+#define ISP_BLC_STATUS (ISP_BASE_ADDR+0x1100UL)
+#define ISP_BLC_PARAM (ISP_BASE_ADDR+0x1114UL)
+#define ISP_BLC_B_PARAM_R_B (ISP_BASE_ADDR+0x1118UL)
+#define ISP_BLC_B_PARAM_G (ISP_BASE_ADDR+0x111CUL)
+
+/*isp sub block: RGBG*/
+#define ISP_RGBG_STATUS (ISP_BASE_ADDR+0x1200UL)
+#define ISP_RGBG_PARAM (ISP_BASE_ADDR+0x1214UL)
+#define ISP_RGBG_RB (ISP_BASE_ADDR+0x1218UL)
+#define ISP_RGBG_G (ISP_BASE_ADDR+0x121CUL)
+
+/*isp sub block: PWD*/
+#define ISP_PWD_STATUS0 (ISP_BASE_ADDR+0x1300UL)
+#define ISP_PWD_STATUS1 (ISP_BASE_ADDR+0x1304UL)
+#define ISP_PWD_PARAM (ISP_BASE_ADDR+0x1314UL)
+#define ISP_PWD_PARAM1 (ISP_BASE_ADDR+0x1318UL)
+#define ISP_PWD_PARAM2 (ISP_BASE_ADDR+0x131CUL)
+#define ISP_PWD_PARAM3 (ISP_BASE_ADDR+0x1320UL)
+#define ISP_PWD_PARAM4 (ISP_BASE_ADDR+0x1324UL)
+#define ISP_PWD_PARAM5 (ISP_BASE_ADDR+0x1328UL)
+#define ISP_PWD_PARAM6 (ISP_BASE_ADDR+0x132CUL)
+#define ISP_PWD_PARAM7 (ISP_BASE_ADDR+0x1330UL)
+#define ISP_PWD_PARAM8 (ISP_BASE_ADDR+0x1334UL)
+#define ISP_PWD_PARAM9 (ISP_BASE_ADDR+0x1338UL)
+#define ISP_PWD_PARAM10 (ISP_BASE_ADDR+0x133CUL)
+
+/*isp sub block: NLC*/
+#define ISP_NLC_STATUS (ISP_BASE_ADDR+0x1400UL)
+#define ISP_NLC_PARA (ISP_BASE_ADDR+0x1414UL)
+#define ISP_NLC_PARA_R0 (ISP_BASE_ADDR+0x1418UL)
+#define ISP_NLC_PARA_R9 (ISP_BASE_ADDR+0x143CUL)
+#define ISP_NLC_PARA_G0 (ISP_BASE_ADDR+0x1440UL)
+#define ISP_NLC_PARA_G9 (ISP_BASE_ADDR+0x1464UL)
+#define ISP_NLC_PARA_B0 (ISP_BASE_ADDR+0x1468UL)
+#define ISP_NLC_PARA_B9 (ISP_BASE_ADDR+0x148CUL)
+#define ISP_NLC_PARA_L0 (ISP_BASE_ADDR+0x1490UL)
+
+/*isp sub block: lens shading calibration*/
+#define ISP_LENS_STATUS (ISP_BASE_ADDR+0x1500UL)
+#define ISP_LENS_PARAM (ISP_BASE_ADDR+0x1514UL)
+#define ISP_LENS_PARAM_ADDR (ISP_BASE_ADDR+0x1518UL)
+#define ISP_LENS_SLICE_POS (ISP_BASE_ADDR+0x151CUL)
+#define ISP_LENS_LOAD_EB (ISP_BASE_ADDR+0x1520UL)
+#define ISP_LENS_GRID_PITCH (ISP_BASE_ADDR+0x1524UL)
+#define ISP_LENS_GRID_SIZE (ISP_BASE_ADDR+0x1528UL)
+#define ISP_LENS_LOAD_BUF (ISP_BASE_ADDR+0x152CUL)
+#define ISP_LENS_MISC (ISP_BASE_ADDR+0x1530UL)
+#define ISP_LENS_SLICE_SIZE (ISP_BASE_ADDR+0x1534UL)
+#define ISP_LENS_INIT_COOR (ISP_BASE_ADDR+0x1538UL)
+#define ISP_LENS_Q0_VALUE (ISP_BASE_ADDR+0x153CUL)
+
+/*isp sub block: binning*/
+#define ISP_BINNING_STATUS (ISP_BASE_ADDR+0x1600UL)
+#define ISP_BINNING_PARAM (ISP_BASE_ADDR+0x1614UL)
+#define ISP_BINNING_MEM_ADDR (ISP_BASE_ADDR+0x1618UL)
+#define ISP_BINNING_PITCH (ISP_BASE_ADDR+0x161CUL)
+
+/*isp sub block: AWBM*/
+#define ISP_AWBM_STATUS (ISP_BASE_ADDR+0x1700UL)
+#define ISP_AWBM_PARAM (ISP_BASE_ADDR+0x1714UL)
+#define ISP_AWBM_BLOCK_OFFSET (ISP_BASE_ADDR+0x1718UL)
+#define ISP_AWBM_BLOCK_SIZE (ISP_BASE_ADDR+0x171CUL)
+#define ISP_AWBM_WR_0_S (ISP_BASE_ADDR+0x1720UL)
+#define ISP_AWBM_WR_0_E (ISP_BASE_ADDR+0x1724UL)
+#define ISP_AWBM_NW_0_XYR (ISP_BASE_ADDR+0x1748UL)
+#define ISP_AWBM_CLCTOR_0_S (ISP_BASE_ADDR+0x175CUL)
+#define ISP_AWBM_CLCTOR_0_E (ISP_BASE_ADDR+0x1760UL)
+#define ISP_AWBM_CLCTR_0_PIXEL_NUM (ISP_BASE_ADDR+0x1784UL)
+#define ISP_AWBM_MEM_ADDR (ISP_BASE_ADDR+0x1798UL)
+#define ISP_AWBM_POSITION_SEL (ISP_BASE_ADDR+0x179CUL)
+#define ISP_AWBM_THR_VALUE1 (ISP_BASE_ADDR+0x17A0UL)
+#define ISP_AWBM_THR_VALUE2 (ISP_BASE_ADDR+0x17A4UL)
+
+/*isp sub block: AWBC*/
+#define ISP_AWBC_STATUS (ISP_BASE_ADDR+0x1800UL)
+#define ISP_AWBC_PARAM (ISP_BASE_ADDR+0x1814UL)
+#define ISP_AWBC_GAIN0 (ISP_BASE_ADDR+0x1818UL)
+#define ISP_AWBC_GAIN1 (ISP_BASE_ADDR+0x181CUL)
+#define ISP_AWBC_THRD (ISP_BASE_ADDR+0x1820UL)
+#define ISP_AWBC_OFFSET0 (ISP_BASE_ADDR+0x1824UL)
+#define ISP_AWBC_OFFSET1 (ISP_BASE_ADDR+0x1828UL)
+#define ISP_AWBC_GAIN0_BUF (ISP_BASE_ADDR+0x182CUL)
+#define ISP_AWBC_GAIN1_BUF (ISP_BASE_ADDR+0x1830UL)
+#define ISP_AWBC_OFFSET0_BUF (ISP_BASE_ADDR+0x1834UL)
+#define ISP_AWBC_OFFSET1_BUF (ISP_BASE_ADDR+0x1838UL)
+#define ISP_AWBC_GAIN0_READ (ISP_BASE_ADDR+0x183CUL)
+#define ISP_AWBC_GAIN1_READ (ISP_BASE_ADDR+0x1840UL)
+#define ISP_AWBC_OFFSET0_READ (ISP_BASE_ADDR+0x1844UL)
+#define ISP_AWBC_OFFSET1_READ (ISP_BASE_ADDR+0x1848UL)
+
+/*isp sub block: AEM*/
+#define ISP_AEM_STATUS (ISP_BASE_ADDR+0x1900UL)
+#define ISP_AEM_PARAM (ISP_BASE_ADDR+0x1914UL)
+#define ISP_AEM_OFFSET (ISP_BASE_ADDR+0x1918UL)
+#define ISP_AEM_BLK_SIZE (ISP_BASE_ADDR+0x191CUL)
+#define ISP_AEM_SLICE_SIZE (ISP_BASE_ADDR+0x1920UL)
+
+/*isp sub block: BPC: bad pixel correction*/
+#define ISP_BPC_STATUS (ISP_BASE_ADDR+0x1A00UL)
+#define ISP_BPC_PARAM (ISP_BASE_ADDR+0x1A14UL)
+#define ISP_BPC_CFG (ISP_BASE_ADDR+0x1A18UL)
+#define ISP_BPC_FACTOR (ISP_BASE_ADDR+0x1A1CUL)
+#define ISP_BPC_COEFF (ISP_BASE_ADDR+0x1A20UL)
+#define ISP_BPC_LUTWORD0 (ISP_BASE_ADDR+0x1A24UL)
+#define ISP_BPC_NEW_OLD_SEL (ISP_BASE_ADDR+0x1A44UL)
+#define ISP_BPC_MAP_ADDR (ISP_BASE_ADDR+0x1A48UL)
+
+/*isp sub block: GRGB*/
+#define ISP_GRGB_STATUS (ISP_BASE_ADDR+0x1B00UL)
+#define ISP_GRGB_PARAM (ISP_BASE_ADDR+0x1B14UL)
+#define ISP_GRGB_GRID (ISP_BASE_ADDR+0x1B18UL)
+
+/*isp sub block: BDN*/
+#define ISP_BDN_STATUS (ISP_BASE_ADDR+0x1C00UL)
+#define ISP_BDN_PARAM (ISP_BASE_ADDR+0x1C14UL)
+#define ISP_BDN_DISWEI0_0 (ISP_BASE_ADDR+0x1C18UL)
+#define ISP_BDN_DISWEI0_1 (ISP_BASE_ADDR+0x1C1CUL)
+#define ISP_BDN_RANWEI0_0 (ISP_BASE_ADDR+0x1C20UL)
+#define ISP_BDN_RANWEI0_7 (ISP_BASE_ADDR+0x1C3CUL)
+#define ISP_BDN_1DLNC_CENTER (ISP_BASE_ADDR+0x1DA8UL)
+#define ISP_BDN_1DLNC_SQUARE_X (ISP_BASE_ADDR+0x1DACUL)
+#define ISP_BDN_1DLNC_SQUARE_Y (ISP_BASE_ADDR+0x1DB0UL)
+#define ISP_BDN_1DLNC_P (ISP_BASE_ADDR+0x1DB4UL)
+#define ISP_BDN_1DLNC_SIZE (ISP_BASE_ADDR+0x1DB8UL)
+#define ISP_BDN_1DLNC_POS (ISP_BASE_ADDR+0x1DBCUL)
+#define ISP_BDN_1DLNC_OFFSET (ISP_BASE_ADDR+0x1DC0UL)
+
+/*isp sub block: RGBG2*/
+#define ISP_RGBG2_STATUS (ISP_BASE_ADDR+0x1E00UL)
+#define ISP_RGBG2_PARAM (ISP_BASE_ADDR+0x1E14UL)
+#define ISP_RGBG2_OFFSET (ISP_BASE_ADDR+0x1E18UL)
+
+/*isp sub block: 1d lnc*/
+#define ISP_1D_LNC_STATUS (ISP_BASE_ADDR+0x1F00UL)
+#define ISP_1D_LNC_PARAM (ISP_BASE_ADDR+0x1F14UL)
+#define ISP_1D_LNC_PARAM1 (ISP_BASE_ADDR+0x1F18UL)
+#define ISP_1D_LNC_PARAM2 (ISP_BASE_ADDR+0x1F1CUL)
+#define ISP_1D_LNC_PARAM3 (ISP_BASE_ADDR+0x1F20UL)
+#define ISP_1D_LNC_PARAM4 (ISP_BASE_ADDR+0x1F24UL)
+#define ISP_1D_LNC_PARAM5 (ISP_BASE_ADDR+0x1F28UL)
+#define ISP_1D_LNC_PARAM6 (ISP_BASE_ADDR+0x1F2CUL)
+#define ISP_1D_LNC_PARAM7 (ISP_BASE_ADDR+0x1F30UL)
+#define ISP_1D_LNC_PARAM8 (ISP_BASE_ADDR+0x1F34UL)
+#define ISP_1D_LNC_PARAM9 (ISP_BASE_ADDR+0x1F38UL)
+#define ISP_1D_LNC_PARAM10 (ISP_BASE_ADDR+0x1F3CUL)
+#define ISP_1D_LNC_PARAM11 (ISP_BASE_ADDR+0x1F40UL)
+#define ISP_1D_LNC_PARAM12 (ISP_BASE_ADDR+0x1F44UL)
+#define ISP_1D_LNC_PARAM13 (ISP_BASE_ADDR+0x1F48UL)
+#define ISP_1D_LNC_PARAM14 (ISP_BASE_ADDR+0x1F4CUL)
+#define ISP_1D_LNC_PARAM15 (ISP_BASE_ADDR+0x1F50UL)
+#define ISP_1D_LNC_PARAM16 (ISP_BASE_ADDR+0x1F54UL)
+#define ISP_1D_LNC_PARAM17 (ISP_BASE_ADDR+0x1F58UL)
+#define ISP_1D_LNC_PARAM18 (ISP_BASE_ADDR+0x1F5CUL)
+
+/*isp sub block: NLM VST IVST*/
+#define ISP_VST_PARA (ISP_BASE_ADDR+0x2014UL)
+#define ISP_IVST_PARA (ISP_BASE_ADDR+0x2214UL)
+#define ISP_NLM_LB_STATUS0 (ISP_BASE_ADDR+0x2100UL)
+#define ISP_NLM_LB_STATUS1 (ISP_BASE_ADDR+0x2104UL)
+#define ISP_NLM_STATUS (ISP_BASE_ADDR+0x2108UL)
+#define ISP_NLM_PARA (ISP_BASE_ADDR+0x2114UL)
+#define ISP_NLM_FLAT_PARA_0 (ISP_BASE_ADDR+0x2118UL)
+#define ISP_NLM_STERNGTH (ISP_BASE_ADDR+0x212CUL)
+#define ISP_NLM_IS_FLAT (ISP_BASE_ADDR+0x2130UL)
+#define ISP_NLM_ADD_BACK (ISP_BASE_ADDR+0x2134UL)
+//#define ISP_NLM_DIRECTION_0 (ISP_BASE_ADDR+0x2138UL)
+//#define ISP_NLM_DIRECTION_1 (ISP_BASE_ADDR+0x213CUL)
+#define ISP_NLM_LUT_W_0 (ISP_BASE_ADDR+0x2140UL)
+
+/*isp sub block: CFA: clolor filter array*/
+#define ISP_CFAE_STATUS (ISP_BASE_ADDR+0x3000UL)
+#define ISP_CFAE_EE_CFG0 (ISP_BASE_ADDR+0x3014UL)
+#define ISP_CFAE_THRD_0 (ISP_BASE_ADDR+0x3018UL)
+#define ISP_CFAE_THRD_1 (ISP_BASE_ADDR+0x301CUL)
+#define ISP_CFAE_THRD_2 (ISP_BASE_ADDR+0x3020UL)
+#define ISP_CFAE_THRD_3 (ISP_BASE_ADDR+0x3024UL)
+#define ISP_CFAE_THRD_4 (ISP_BASE_ADDR+0x3028UL)
+#define ISP_CFAE_EE_CFG1 (ISP_BASE_ADDR+0x302CUL)
+
+/*isp sub block:CMC: Color matrix correction for 10 bit */
+#define ISP_CMC10_STATUS0 (ISP_BASE_ADDR+0x3100UL)
+#define ISP_CMC10_STATUS1 (ISP_BASE_ADDR+0x3104UL)
+#define ISP_CMC10_PARAM (ISP_BASE_ADDR+0x3114UL)
+#define ISP_CMC10_MATRIX0 (ISP_BASE_ADDR+0x3118UL)
+#define ISP_CMC10_MATRIX0_BUF (ISP_BASE_ADDR+0x312CUL)
+
+/*isp sub block: FRGB WDR */
+#define ISP_HDR_STATUS (ISP_BASE_ADDR+0x3200UL)
+#define ISP_HDR_PARAM (ISP_BASE_ADDR+0x3214UL)
+
+//#define ISP_HDR_STATUS (ISP_BASE_ADDR+0x1A00UL)
+//#define ISP_HDR_PARAM (ISP_BASE_ADDR+0x1A14UL)
+//#define ISP_HDR_INDEX (ISP_BASE_ADDR+0x1A18UL)
+
+/*isp sub block: GAMMA */
+#define ISP_GAMMA_STATUS (ISP_BASE_ADDR+0x3300UL)
+#define ISP_GAMMA_PARAM (ISP_BASE_ADDR+0x3314UL)
+
+/*isp sub block:CMC: Color matrix correction for 8 bit */
+#define ISP_CMC8_STATUS0 (ISP_BASE_ADDR+0x3500UL)
+#define ISP_CMC8_STATUS1 (ISP_BASE_ADDR+0x3504UL)
+#define ISP_CMC8_PARAM (ISP_BASE_ADDR+0x3514UL)
+#define ISP_CMC8_MATRIX0 (ISP_BASE_ADDR+0x3518UL)
+#define ISP_CMC8_MATRIX0_BUF (ISP_BASE_ADDR+0x352CUL)
+
+/*CT: Color transformation*/
+#define ISP_CT_STATUS0 (ISP_BASE_ADDR+0x3600UL)
+#define ISP_CT_STATUS1 (ISP_BASE_ADDR+0x3604UL)
+#define ISP_CT_PARAM (ISP_BASE_ADDR+0x3614UL)
+
+/*isp sub block: CCE: clolor conversion enhancement*/
+#define ISP_CCE_STATUS0 (ISP_BASE_ADDR+0x3700UL)
+#define ISP_CCE_STATUS1 (ISP_BASE_ADDR+0x3704UL)
+#define ISP_CCE_PARAM (ISP_BASE_ADDR+0x3714UL)
+#define ISP_CCE_MATRIX0 (ISP_BASE_ADDR+0x3718UL)
+#define ISP_CCE_MATRIX1 (ISP_BASE_ADDR+0x371CUL)
+#define ISP_CCE_MATRIX2 (ISP_BASE_ADDR+0x3720UL)
+#define ISP_CCE_MATRIX3 (ISP_BASE_ADDR+0x3724UL)
+#define ISP_CCE_MATRIX4 (ISP_BASE_ADDR+0x3728UL)
+#define ISP_CCE_SHIFT (ISP_BASE_ADDR+0x372CUL)
+#define ISP_CCE_UVD_PARAM0 (ISP_BASE_ADDR+0x3730UL)
+#define ISP_CCE_UVD_PARAM1 (ISP_BASE_ADDR+0x3734UL)
+#define ISP_CCE_UVD_PARAM2 (ISP_BASE_ADDR+0x3738UL)
+#define ISP_CCE_UVD_PARAM3 (ISP_BASE_ADDR+0x373CUL)
+#define ISP_CCE_UVD_PARAM4 (ISP_BASE_ADDR+0x3740UL)
+#define ISP_CCE_UVD_PARAM5 (ISP_BASE_ADDR+0x3744UL)
+
+/*isp sub block:HSV*/
+#define ISP_HSV_STATUS (ISP_BASE_ADDR+0x3800UL)
+#define ISP_HSV_PARAM (ISP_BASE_ADDR+0x3814UL)
+
+/*isp sub block:Radial CSC*/
+#define ISP_CSC_STATUS (ISP_BASE_ADDR + 0x3900UL)
+#define ISP_CSC_CTRL (ISP_BASE_ADDR + 0x3914UL)
+#define ISP_CSC_RCC (ISP_BASE_ADDR + 0x3918UL)
+#define ISP_CSC_BCC (ISP_BASE_ADDR + 0x391CUL)
+#define ISP_CSC_REDX2INIT (ISP_BASE_ADDR + 0x3920UL)
+#define ISP_CSC_REDY2INIT (ISP_BASE_ADDR + 0x3924UL)
+#define ISP_CSC_BLUEX2INIT (ISP_BASE_ADDR + 0x3928UL)
+#define ISP_CSC_BLUEY2INIT (ISP_BASE_ADDR + 0x392CUL)
+#define ISP_CSC_REDTHR (ISP_BASE_ADDR + 0x3930UL)
+#define ISP_CSC_BLUETHR (ISP_BASE_ADDR + 0x3934UL)
+#define ISP_CSC_REDPOLY (ISP_BASE_ADDR + 0x3938UL)
+#define ISP_CSC_BLUEPOLY (ISP_BASE_ADDR + 0x393CUL)
+#define ISP_CSC_MAXGAIN (ISP_BASE_ADDR + 0x3940UL)
+#define ISP_CSC_PICSIZE (ISP_BASE_ADDR + 0x3944UL)
+#define ISP_CSC_START_ROW_COL (ISP_BASE_ADDR + 0x3948UL)
+
+/*isp sub block:ISP_PRECNRNEW*/
+#define ISP_PRECNRNEW_STATUS0 (ISP_BASE_ADDR+0x3A00UL)
+#define ISP_PRECNRNEW_STATUS1 (ISP_BASE_ADDR+0x3A04UL)
+#define ISP_PRECNRNEW_CFG (ISP_BASE_ADDR+0x3A14UL)
+#define ISP_PRECNRNEW_MEDIAN_THR (ISP_BASE_ADDR+0x3A18UL)
+#define ISP_PRECNRNEW_THRU (ISP_BASE_ADDR+0x3A1CUL)
+#define ISP_PRECNRNEW_THRV (ISP_BASE_ADDR+0x3A20UL)
+
+/*isp sub block:ISP_PSTRZ*/
+#define ISP_PSTRZ_STATUS (ISP_BASE_ADDR+0x3B00UL)
+#define ISP_PSTRZ_PARAM (ISP_BASE_ADDR+0x3B14UL)
+#define ISP_PSTRZ_LEVEL0 (ISP_BASE_ADDR+0x3B18UL)
+#define ISP_PSTRZ_LEVEL1 (ISP_BASE_ADDR+0x3B1CUL)
+#define ISP_PSTRZ_LEVEL2 (ISP_BASE_ADDR+0x3B20UL)
+#define ISP_PSTRZ_LEVEL3 (ISP_BASE_ADDR+0x3B24UL)
+#define ISP_PSTRZ_LEVEL4 (ISP_BASE_ADDR+0x3B28UL)
+#define ISP_PSTRZ_LEVEL5 (ISP_BASE_ADDR+0x3B2CUL)
+#define ISP_PSTRZ_LEVEL6 (ISP_BASE_ADDR+0x3B30UL)
+#define ISP_PSTRZ_LEVEL7 (ISP_BASE_ADDR+0x3B34UL)
+
+/*isp sub block: AFM : auto focus monitor*/
+#define ISP_RGB_AFM_STATUS0 (ISP_BASE_ADDR+0x3C00UL)
+#define ISP_RGB_AFM_STATUS1 (ISP_BASE_ADDR+0x3C04UL)
+#define ISP_RGB_AFM_PARAM (ISP_BASE_ADDR+0x3C14UL)
+#define ISP_RGB_AFM_FRAME_RANGE (ISP_BASE_ADDR+0x3C18UL)
+#define ISP_RGB_AFM_SOBEL_THRESHOLD (ISP_BASE_ADDR+0x3C1CUL)
+#define ISP_RGB_AFM_SPSMD_THRESHOLD_MAX (ISP_BASE_ADDR+0x3C20UL)
+#define ISP_RGB_AFM_WIN_RANGE0 (ISP_BASE_ADDR+0x3C24UL)
+#define ISP_RGB_AFM_TYPE1_VAL00 (ISP_BASE_ADDR+0x3CECUL)
+#define ISP_RGB_AFM_TYPE2_VAL00 (ISP_BASE_ADDR+0x3D50UL)
+#define ISP_RGB_AFM_SPSMD_THRESHOLD_MIN (ISP_BASE_ADDR+0x3DB4UL)
+
+/*isp sub block:RGB2Y*/
+#define ISP_Y_RGB2Y_STATUS0 (ISP_BASE_ADDR+0x4000UL)
+#define ISP_Y_RGB2Y_STATUS1 (ISP_BASE_ADDR+0x4004UL)
+#define ISP_Y_RGB2Y_PARAM (ISP_BASE_ADDR+0x4014UL)
+
+/*isp sub block:YIQ AEM*/
+#define ISP_YIQ_AEM_STATUS (ISP_BASE_ADDR + 0x4100UL)
+#define ISP_YIQ_AEM_PARAM (ISP_BASE_ADDR + 0x4114UL)
+#define ISP_YIQ_YGAMMA_NODE_X0 (ISP_BASE_ADDR + 0x4118UL)
+#define ISP_YIQ_YGAMMA_NODE_X1 (ISP_BASE_ADDR + 0x411CUL)
+#define ISP_YIQ_YGAMMA_NODE_Y0 (ISP_BASE_ADDR + 0x4120UL)
+#define ISP_YIQ_YGAMMA_NODE_Y1 (ISP_BASE_ADDR + 0x4124UL)
+#define ISP_YIQ_YGAMMA_NODE_Y2 (ISP_BASE_ADDR + 0x4128UL)
+#define ISP_YIQ_YGAMMA_NODE_IDX (ISP_BASE_ADDR + 0x412CUL)
+#define ISP_YIQ_AEM_OFFSET (ISP_BASE_ADDR + 0x4130UL)
+#define ISP_YIQ_AEM_BLK_SIZE (ISP_BASE_ADDR + 0x4134UL)
+#define ISP_YIQ_AEM_SLICE_SIZE (ISP_BASE_ADDR + 0x4138UL)
+
+/*isp sub block:ANTI FLICKER*/
+#define ISP_ANTI_FLICKER_STATUS0 (ISP_BASE_ADDR + 0x4200UL)
+#define ISP_ANTI_FLICKER_STATUS1 (ISP_BASE_ADDR + 0x4204UL)
+#define ISP_ANTI_FLICKER_PARAM0 (ISP_BASE_ADDR + 0x4214UL)
+#define ISP_ANTI_FLICKER_PARAM1 (ISP_BASE_ADDR + 0x4218UL)
+#define ISP_ANTI_FLICKER_COL_POS (ISP_BASE_ADDR + 0x421CUL)
+#define ISP_ANTI_FLICKER_DDR_INIT_ADDR (ISP_BASE_ADDR + 0x4220UL)
+
+/*isp sub block:YIQ AFM*/
+#define ISP_YIQ_AFM_STATUS0 (ISP_BASE_ADDR + 0x4300UL)
+#define ISP_YIQ_AFM_STATUS1 (ISP_BASE_ADDR + 0x4304UL)
+#define ISP_YIQ_AFM_PARAM (ISP_BASE_ADDR + 0x4314UL)
+#define ISP_YIQ_AFM_WIN_RANGE0 (ISP_BASE_ADDR + 0x4318UL)
+#define ISP_YIQ_AFM_COEF0_1 (ISP_BASE_ADDR + 0x43E0UL)
+#define ISP_YIQ_AFM_COEF2_3 (ISP_BASE_ADDR + 0x43E4UL)
+#define ISP_YIQ_AFM_COEF4_5 (ISP_BASE_ADDR + 0x43E8UL)
+#define ISP_YIQ_AFM_COEF6_7 (ISP_BASE_ADDR + 0x43ECUL)
+#define ISP_YIQ_AFM_COEF8_9 (ISP_BASE_ADDR + 0x43F0UL)
+#define ISP_YIQ_AFM_COEF10 (ISP_BASE_ADDR + 0x43F4UL)
+#define ISP_YIQ_AFM_LAPLACE0 (ISP_BASE_ADDR + 0x43F8UL)
+#define ISP_YIQ_AFM_SLICE_SIZE (ISP_BASE_ADDR + 0x4588UL)
+
+/*isp sub block: Pre-CDN*/
+#define ISP_PRECDN_STATUS0 (ISP_BASE_ADDR+0x5000UL)
+#define ISP_PRECDN_STATUS1 (ISP_BASE_ADDR+0x5004UL)
+#define ISP_PRECDN_PARAM (ISP_BASE_ADDR+0x5014UL)
+#define ISP_PRECDN_MEDIAN_THRUV01 (ISP_BASE_ADDR+0x5018UL)
+#define ISP_PRECDN_THRYUV (ISP_BASE_ADDR+0x501CUL)
+#define ISP_PRECDN_SEGU_0 (ISP_BASE_ADDR+0x5020UL)
+#define ISP_PRECDN_SEGU_3 (ISP_BASE_ADDR+0x502CUL)
+#define ISP_PRECDN_SEGV_0 (ISP_BASE_ADDR+0x5030UL)
+#define ISP_PRECDN_SEGV_3 (ISP_BASE_ADDR+0x503CUL)
+#define ISP_PRECDN_SEGY_0 (ISP_BASE_ADDR+0x5040UL)
+#define ISP_PRECDN_SEGY_3 (ISP_BASE_ADDR+0x504CUL)
+#define ISP_PRECDN_DISTW0 (ISP_BASE_ADDR+0x5050UL)
+#define ISP_PRECDN_DISTW3 (ISP_BASE_ADDR+0x505CUL)
+
+/*isp sub block: Pre-Filter*/
+#define ISP_PREF_STATUS0 (ISP_BASE_ADDR+0x5100UL)
+#define ISP_PREF_STATUS1 (ISP_BASE_ADDR+0x5104UL)
+#define ISP_PREF_PARAM (ISP_BASE_ADDR+0x5114UL)
+#define ISP_PREF_THRD (ISP_BASE_ADDR+0x5118UL)
+
+/*isp sub block: UV Pre-Filter*/
+#define ISP_UV_PREF_STATUS0 (ISP_BASE_ADDR+0x5200UL)
+#define ISP_UV_PREF_STATUS1 (ISP_BASE_ADDR+0x5204UL)
+#define ISP_UV_PREF_PARAM (ISP_BASE_ADDR+0x5214UL)
+#define ISP_UV_PREF_THRD (ISP_BASE_ADDR+0x5218UL)
+
+/*isp sub block: Brightness*/
+#define ISP_BRIGHT_STATUS (ISP_BASE_ADDR+0x5300UL)
+#define ISP_BRIGHT_PARAM (ISP_BASE_ADDR+0x5314UL)
+
+/*isp sub block: Contrast*/
+#define ISP_CONTRAST_STATUS (ISP_BASE_ADDR+0x5400UL)
+#define ISP_CONTRAST_PARAM (ISP_BASE_ADDR+0x5414UL)
+
+/*isp sub block: HIST : histogram*/
+#define ISP_HIST_STATUS (ISP_BASE_ADDR+0x5500UL)
+#define ISP_HIST_PARAM (ISP_BASE_ADDR+0x5514UL)
+#define ISP_HIST_RATIO (ISP_BASE_ADDR+0x5518UL)
+#define ISP_HIST_MAX_MIN (ISP_BASE_ADDR+0x551CUL)
+#define ISP_HIST_SLICE_SIZE (ISP_BASE_ADDR+0x5520UL)
+#define ISP_HIST_ADJUST (ISP_BASE_ADDR+0x5524UL)
+
+/*isp sub block: HIST2*/
+#define ISP_HIST2_STATUS (ISP_BASE_ADDR+0x5600UL)
+#define ISP_HIST2_PARAM (ISP_BASE_ADDR+0x5614UL)
+#define ISP_HIST2_ROI_S0 (ISP_BASE_ADDR+0x5618UL)
+#define ISP_HIST2_ROI_E0 (ISP_BASE_ADDR+0x561CUL)
+
+/*isp sub block: AUTOCONT : auto contrast adjustment*/
+#define ISP_AUTOCONT_STATUS (ISP_BASE_ADDR+0x5700UL)
+#define ISP_AUTOCONT_PARAM (ISP_BASE_ADDR+0x5714UL)
+#define ISP_AUTOCONT_MAX_MIN (ISP_BASE_ADDR+0x5718UL)
+
+/*isp sub block: cdn*/
+#define ISP_CDN_STATUS0 (ISP_BASE_ADDR+0x5800UL)
+#define ISP_CDN_STATUS1 (ISP_BASE_ADDR+0x5804UL)
+#define ISP_CDN_PARAM (ISP_BASE_ADDR+0x5814UL)
+#define ISP_CDN_THRUV (ISP_BASE_ADDR+0x5818UL)
+#define ISP_CDN_U_RANWEI_0 (ISP_BASE_ADDR+0x581CUL)
+#define ISP_CDN_U_RANWEI_7 (ISP_BASE_ADDR+0x5838UL)
+#define ISP_CDN_V_RANWEI_0 (ISP_BASE_ADDR+0x583CUL)
+#define ISP_CDN_V_RANWEI_7 (ISP_BASE_ADDR+0x5858UL)
+
+/*isp sub block: edge*/
+#define ISP_EE_STATUS (ISP_BASE_ADDR+0x5900UL)
+#define ISP_EE_PARAM (ISP_BASE_ADDR+0x5914UL)
+#define ISP_EE_CFG0 (ISP_BASE_ADDR+0x5918UL)
+#define ISP_EE_CFG1 (ISP_BASE_ADDR+0x591CUL)
+#define ISP_EE_CFG2 (ISP_BASE_ADDR+0x5920UL)
+#define ISP_EE_CFG3 (ISP_BASE_ADDR+0x5924UL)
+#define ISP_EE_CFG4 (ISP_BASE_ADDR+0x5928UL)
+#define ISP_EE_CFG5 (ISP_BASE_ADDR+0x592CUL)
+#define ISP_EE_CFG6 (ISP_BASE_ADDR+0x5930UL)
+#define ISP_EE_CFG7 (ISP_BASE_ADDR+0x5934UL)
+//pike has no registers ISP_EE_ADP_CFG0 ~ ISP_EE_ADP_CFG2
+//#define ISP_EE_ADP_CFG0 (ISP_BASE_ADDR+0x5938UL)
+//#define ISP_EE_ADP_CFG1 (ISP_BASE_ADDR+0x593CUL)
+//#define ISP_EE_ADP_CFG2 (ISP_BASE_ADDR+0x5940UL)
+
+/*isp sub block: emboss(pike has no this module)*/
+#define ISP_EMBOSS_Y_STATUS (ISP_BASE_ADDR+0x5A00UL)
+#define ISP_EMBOSS_Y_PARAM (ISP_BASE_ADDR+0x5A14UL)
+#define ISP_EMBOSS_UV_STATUS (ISP_BASE_ADDR+0x5F00UL)
+#define ISP_EMBOSS_UV_PARAM (ISP_BASE_ADDR+0x5F14UL)
+
+/*isp sub block: CSS*/
+#define ISP_CSS_STATUS (ISP_BASE_ADDR+0x5B00UL)
+#define ISP_CSS_PARAM (ISP_BASE_ADDR+0x5B14UL)
+#define ISP_CSS_THRD0 (ISP_BASE_ADDR+0x5B18UL)
+#define ISP_CSS_LH_RATIO (ISP_BASE_ADDR+0x5B1CUL)
+#define ISP_CSS_EX_TH_0 (ISP_BASE_ADDR+0x5B20UL)
+#define ISP_CSS_EX_TH_1 (ISP_BASE_ADDR+0x5B24UL)
+#define ISP_CSS_CHROM_L_TH_0 (ISP_BASE_ADDR+0x5B28UL)
+#define ISP_CSS_CHROM_L_TH_1 (ISP_BASE_ADDR+0x5B2CUL)
+#define ISP_CSS_CHROM_H_TH_0 (ISP_BASE_ADDR+0x5B30UL)
+#define ISP_CSS_CHROM_H_TH_1 (ISP_BASE_ADDR+0x5B34UL)
+#define ISP_CSS_RATIO (ISP_BASE_ADDR+0x5B38UL)
+
+/*isp sub block: csa*/
+#define ISP_CSA_STATUS (ISP_BASE_ADDR+0x5C00UL)
+#define ISP_CSA_PARAM (ISP_BASE_ADDR+0x5C14UL)
+
+/*isp sub block: hua*/
+#define ISP_HUA_STATUS (ISP_BASE_ADDR+0x5D00UL)
+#define ISP_HUA_PARAM (ISP_BASE_ADDR+0x5D14UL)
+
+/*isp sub block: post-cdn*/
+#define ISP_POSTCDN_STATUS (ISP_BASE_ADDR+0x5E00UL)
+#define ISP_POSTCDN_COMMON_CTRL (ISP_BASE_ADDR+0x5E14UL)
+#define ISP_POSTCDN_ADPT_THR (ISP_BASE_ADDR+0x5E18UL)
+#define ISP_POSTCDN_UVTHR (ISP_BASE_ADDR+0x5E1CUL)
+#define ISP_POSTCDN_THRU (ISP_BASE_ADDR+0x5E20UL)
+#define ISP_POSTCDN_THRV (ISP_BASE_ADDR+0x5E24UL)
+#define ISP_POSTCDN_RSEGU01 (ISP_BASE_ADDR+0x5E28UL)
+#define ISP_POSTCDN_RSEGU23 (ISP_BASE_ADDR+0x5E2CUL)
+#define ISP_POSTCDN_RSEGU45 (ISP_BASE_ADDR+0x5E30UL)
+#define ISP_POSTCDN_RSEGU6 (ISP_BASE_ADDR+0x5E34UL)
+#define ISP_POSTCDN_RSEGV01 (ISP_BASE_ADDR+0x5E38UL)
+#define ISP_POSTCDN_RSEGV23 (ISP_BASE_ADDR+0x5E3CUL)
+#define ISP_POSTCDN_RSEGV45 (ISP_BASE_ADDR+0x5E40UL)
+#define ISP_POSTCDN_RSEGV6 (ISP_BASE_ADDR+0x5E44UL)
+#define ISP_POSTCDN_R_DISTW0 (ISP_BASE_ADDR+0x5E48UL)
+//pike has no this register ISP_POSTCDN_START_ROW_MOD4
+//#define ISP_POSTCDN_START_ROW_MOD4 (ISP_BASE_ADDR+0x5E84UL)
+
+/*isp sub block: ygamma*/
+#define ISP_YGAMMA_STATUS (ISP_BASE_ADDR+0x6000UL)
+#define ISP_YGAMMA_PARAM (ISP_BASE_ADDR+0x6014UL)
+
+/*isp sub block: ydelay*/
+#define ISP_YDELAY_STATUS (ISP_BASE_ADDR+0x6100UL)
+#define ISP_YDELAY_PARAM (ISP_BASE_ADDR+0x6114UL)
+
+/*isp sub block: yuv nlm*/
+#define ISP_YNLM_STATUS0 (ISP_BASE_ADDR+0x6200UL)
+#define ISP_YNLM_STATUS1 (ISP_BASE_ADDR+0x6204UL)
+#define ISP_YNLM_PARAM (ISP_BASE_ADDR+0x6214UL)
+#define ISP_YNLM_ADAPT_PARAM1 (ISP_BASE_ADDR+0x6218UL)
+#define ISP_YNLM_ADAPT_PARAM2 (ISP_BASE_ADDR+0x621CUL)
+#define ISP_YNLM_ADAPT_PARAM3 (ISP_BASE_ADDR+0x6220UL)
+#define ISP_YNLM_ADAPT_PARAM4 (ISP_BASE_ADDR+0x6224UL)
+#define ISP_YNLM_ADAPT_PARAM5 (ISP_BASE_ADDR+0x6228UL)
+#define ISP_YNLM_ADAPT_PARAM6 (ISP_BASE_ADDR+0x622CUL)
+#define ISP_YNLM_ADAPT_PARAM7 (ISP_BASE_ADDR+0x6230UL)
+#define ISP_YNLM_ADAPT_PARAM8 (ISP_BASE_ADDR+0x6234UL)
+#define ISP_YNLM_DEN_STERNGTH (ISP_BASE_ADDR+0x6238UL)
+#define ISP_YNLM_CENTER (ISP_BASE_ADDR+0x623CUL)
+#define ISP_YNLM_CENTER_X2 (ISP_BASE_ADDR+0x6240UL)
+#define ISP_YNLM_CENTER_Y2 (ISP_BASE_ADDR+0x6244UL)
+#define ISP_YNLM_RADIUS (ISP_BASE_ADDR+0x6248UL)
+#define ISP_YNLM_RADIUS_RANGE (ISP_BASE_ADDR+0x624CUL)
+#define ISP_YNLM_GAIN_MAX (ISP_BASE_ADDR+0x6250UL)
+#define ISP_YNLM_IMG_PARAM0 (ISP_BASE_ADDR+0x6254UL)
+#define ISP_YNLM_IMG_PARAM1 (ISP_BASE_ADDR+0x6258UL)
+#define ISP_YNLM_ADD_BACK (ISP_BASE_ADDR+0x625CUL)
+#define ISP_YNLM_LUT_W_0 (ISP_BASE_ADDR+0x6260UL)
+#define ISP_YNLM_LUT_W_1 (ISP_BASE_ADDR+0x6264UL)
+#define ISP_YNLM_LUT_W_2 (ISP_BASE_ADDR+0x6268UL)
+#define ISP_YNLM_LUT_W_3 (ISP_BASE_ADDR+0x626CUL)
+#define ISP_YNLM_LUT_W_4 (ISP_BASE_ADDR+0x6270UL)
+#define ISP_YNLM_LUT_W_5 (ISP_BASE_ADDR+0x6274UL)
+#define ISP_YNLM_LUT_W_6 (ISP_BASE_ADDR+0x6278UL)
+#define ISP_YNLM_LUT_W_7 (ISP_BASE_ADDR+0x627CUL)
+#define ISP_YNLM_LUT_W_8 (ISP_BASE_ADDR+0x6280UL)
+#define ISP_YNLM_LUT_W_9 (ISP_BASE_ADDR+0x6284UL)
+#define ISP_YNLM_LUT_W_10 (ISP_BASE_ADDR+0x6288UL)
+#define ISP_YNLM_LUT_W_11 (ISP_BASE_ADDR+0x628CUL)
+#define ISP_YNLM_LUT_W_12 (ISP_BASE_ADDR+0x6290UL)
+#define ISP_YNLM_LUT_W_13 (ISP_BASE_ADDR+0x6294UL)
+#define ISP_YNLM_LUT_W_14 (ISP_BASE_ADDR+0x6298UL)
+#define ISP_YNLM_LUT_W_15 (ISP_BASE_ADDR+0x629CUL)
+#define ISP_YNLM_LUT_W_16 (ISP_BASE_ADDR+0x62A0UL)
+#define ISP_YNLM_LUT_W_17 (ISP_BASE_ADDR+0x62A4UL)
+#define ISP_YNLM_LUT_W_18 (ISP_BASE_ADDR+0x62A8UL)
+#define ISP_YNLM_LUT_W_19 (ISP_BASE_ADDR+0x62ACUL)
+#define ISP_YNLM_LUT_W_20 (ISP_BASE_ADDR+0x62B0UL)
+#define ISP_YNLM_LUT_W_21 (ISP_BASE_ADDR+0x62B4UL)
+#define ISP_YNLM_LUT_W_22 (ISP_BASE_ADDR+0x62B8UL)
+#define ISP_YNLM_LUT_W_23 (ISP_BASE_ADDR+0x62BCUL)
+#define ISP_YNLM_LUT_VS_0 (ISP_BASE_ADDR+0x6300UL)
+#define ISP_YNLM_LUT_VS_1 (ISP_BASE_ADDR+0x6304UL)
+#define ISP_YNLM_LUT_VS_2 (ISP_BASE_ADDR+0x6308UL)
+#define ISP_YNLM_LUT_VS_3 (ISP_BASE_ADDR+0x630CUL)
+#define ISP_YNLM_LUT_VS_4 (ISP_BASE_ADDR+0x6310UL)
+#define ISP_YNLM_LUT_VS_5 (ISP_BASE_ADDR+0x6314UL)
+#define ISP_YNLM_LUT_VS_6 (ISP_BASE_ADDR+0x6318UL)
+#define ISP_YNLM_LUT_VS_7 (ISP_BASE_ADDR+0x631CUL)
+#define ISP_YNLM_LUT_VS_8 (ISP_BASE_ADDR+0x6320UL)
+#define ISP_YNLM_LUT_VS_9 (ISP_BASE_ADDR+0x6324UL)
+#define ISP_YNLM_LUT_VS_10 (ISP_BASE_ADDR+0x6328UL)
+#define ISP_YNLM_LUT_VS_11 (ISP_BASE_ADDR+0x632CUL)
+#define ISP_YNLM_LUT_VS_12 (ISP_BASE_ADDR+0x6330UL)
+#define ISP_YNLM_LUT_VS_13 (ISP_BASE_ADDR+0x6334UL)
+#define ISP_YNLM_LUT_VS_14 (ISP_BASE_ADDR+0x6338UL)
+#define ISP_YNLM_LUT_VS_15 (ISP_BASE_ADDR+0x633CUL)
+#define ISP_YNLM_LUT_VS_16 (ISP_BASE_ADDR+0x6340UL)
+#define ISP_YNLM_LUT_VS_17 (ISP_BASE_ADDR+0x6344UL)
+#define ISP_YNLM_LUT_VS_18 (ISP_BASE_ADDR+0x6348UL)
+#define ISP_YNLM_LUT_VS_19 (ISP_BASE_ADDR+0x634CUL)
+#define ISP_YNLM_LUT_VS_20 (ISP_BASE_ADDR+0x6350UL)
+#define ISP_YNLM_LUT_VS_21 (ISP_BASE_ADDR+0x6354UL)
+#define ISP_YNLM_LUT_VS_22 (ISP_BASE_ADDR+0x6358UL)
+#define ISP_YNLM_LUT_VS_23 (ISP_BASE_ADDR+0x635CUL)
+#define ISP_YNLM_LUT_VS_24 (ISP_BASE_ADDR+0x6360UL)
+#define ISP_YNLM_LUT_VS_25 (ISP_BASE_ADDR+0x6364UL)
+#define ISP_YNLM_LUT_VS_26 (ISP_BASE_ADDR+0x6368UL)
+#define ISP_YNLM_LUT_VS_27 (ISP_BASE_ADDR+0x636CUL)
+#define ISP_YNLM_LUT_VS_28 (ISP_BASE_ADDR+0x6370UL)
+#define ISP_YNLM_LUT_VS_29 (ISP_BASE_ADDR+0x6374UL)
+#define ISP_YNLM_LUT_VS_30 (ISP_BASE_ADDR+0x6378UL)
+#define ISP_YNLM_LUT_VS_31 (ISP_BASE_ADDR+0x637CUL)
+#define ISP_YNLM_LUT_VS_32 (ISP_BASE_ADDR+0x6380UL)
+#define ISP_YNLM_LUT_VS_33 (ISP_BASE_ADDR+0x6384UL)
+#define ISP_YNLM_LUT_VS_34 (ISP_BASE_ADDR+0x6388UL)
+#define ISP_YNLM_LUT_VS_35 (ISP_BASE_ADDR+0x638CUL)
+#define ISP_YNLM_LUT_VS_36 (ISP_BASE_ADDR+0x6390UL)
+#define ISP_YNLM_LUT_VS_37 (ISP_BASE_ADDR+0x6394UL)
+#define ISP_YNLM_LUT_VS_38 (ISP_BASE_ADDR+0x6398UL)
+#define ISP_YNLM_LUT_VS_39 (ISP_BASE_ADDR+0x639CUL)
+#define ISP_YNLM_LUT_VS_40 (ISP_BASE_ADDR+0x63A0UL)
+#define ISP_YNLM_LUT_VS_41 (ISP_BASE_ADDR+0x63A4UL)
+#define ISP_YNLM_LUT_VS_42 (ISP_BASE_ADDR+0x63A8UL)
+#define ISP_YNLM_LUT_VS_43 (ISP_BASE_ADDR+0x63ACUL)
+#define ISP_YNLM_LUT_VS_44 (ISP_BASE_ADDR+0x63B0UL)
+#define ISP_YNLM_LUT_VS_45 (ISP_BASE_ADDR+0x63B4UL)
+#define ISP_YNLM_LUT_VS_46 (ISP_BASE_ADDR+0x63B8UL)
+#define ISP_YNLM_LUT_VS_47 (ISP_BASE_ADDR+0x63BCUL)
+#define ISP_YNLM_LUT_VS_48 (ISP_BASE_ADDR+0x63C0UL)
+#define ISP_YNLM_LUT_VS_49 (ISP_BASE_ADDR+0x63C4UL)
+#define ISP_YNLM_LUT_VS_50 (ISP_BASE_ADDR+0x63C8UL)
+#define ISP_YNLM_LUT_VS_51 (ISP_BASE_ADDR+0x63CCUL)
+#define ISP_YNLM_LUT_VS_52 (ISP_BASE_ADDR+0x63D0UL)
+#define ISP_YNLM_LUT_VS_53 (ISP_BASE_ADDR+0x63D4UL)
+#define ISP_YNLM_LUT_VS_54 (ISP_BASE_ADDR+0x63D8UL)
+#define ISP_YNLM_LUT_VS_55 (ISP_BASE_ADDR+0x63DCUL)
+#define ISP_YNLM_LUT_VS_56 (ISP_BASE_ADDR+0x63E0UL)
+#define ISP_YNLM_LUT_VS_57 (ISP_BASE_ADDR+0x63E4UL)
+#define ISP_YNLM_LUT_VS_58 (ISP_BASE_ADDR+0x63E8UL)
+#define ISP_YNLM_LUT_VS_59 (ISP_BASE_ADDR+0x63ECUL)
+#define ISP_YNLM_LUT_VS_60 (ISP_BASE_ADDR+0x63F0UL)
+#define ISP_YNLM_LUT_VS_61 (ISP_BASE_ADDR+0x63F4UL)
+#define ISP_YNLM_LUT_VS_62 (ISP_BASE_ADDR+0x63F8UL)
+#define ISP_YNLM_LUT_VS_63 (ISP_BASE_ADDR+0x63FCUL)
+
+
+
+/*isp sub block: iircnr(pike has no this module)*/
+/*#define ISP_IIRCNR_STATUS0 (ISP_BASE_ADDR+0x6400UL)
+#define ISP_IIRCNR_STATUS1 (ISP_BASE_ADDR+0x6404UL)
+#define ISP_IIRCNR_PARAM (ISP_BASE_ADDR+0x6414UL)
+#define ISP_IIRCNR_PARAM1 (ISP_BASE_ADDR+0x6418UL)
+#define ISP_IIRCNR_PARAM2 (ISP_BASE_ADDR+0x641CUL)
+#define ISP_IIRCNR_PARAM3 (ISP_BASE_ADDR+0x6420UL)
+#define ISP_IIRCNR_PARAM4 (ISP_BASE_ADDR+0x6424UL)
+#define ISP_IIRCNR_PARAM5 (ISP_BASE_ADDR+0x6428UL)
+#define ISP_IIRCNR_PARAM6 (ISP_BASE_ADDR+0x642CUL)
+#define ISP_IIRCNR_PARAM7 (ISP_BASE_ADDR+0x6430UL)
+#define ISP_IIRCNR_PARAM8 (ISP_BASE_ADDR+0x6434UL)
+#define ISP_IIRCNR_PARAM9 (ISP_BASE_ADDR+0x6438UL)
+#define ISP_YRANDOM_PARAM0 (ISP_BASE_ADDR+0x643CUL)
+#define ISP_YRANDOM_PARAM1 (ISP_BASE_ADDR+0x6440UL)
+#define ISP_YRANDOM_PARAM2 (ISP_BASE_ADDR+0x6444UL)
+#define ISP_YRANDOM_STATUS0 (ISP_BASE_ADDR+0x6448UL)
+#define ISP_YRANDOM_STATUS1 (ISP_BASE_ADDR+0x644CUL)
+#define ISP_YRANDOM_STATUS2 (ISP_BASE_ADDR+0x6450UL)*/
+
+/*pingpang buffer*/
+#define ISP_3D_LUT_BUF0_CH0 (ISP_BASE_ADDR+0x17000UL)
+#define ISP_HSV_BUF0_CH0 (ISP_BASE_ADDR+0x18000UL)
+#define ISP_VST_BUF0_CH0 (ISP_BASE_ADDR+0x19000UL)
+#define ISP_IVST_BUF0_CH0 (ISP_BASE_ADDR+0x1A000UL)
+#define ISP_FGAMMA_R_BUF0_CH0 (ISP_BASE_ADDR+0x1B000UL)
+#define ISP_FGAMMA_G_BUF0_CH0 (ISP_BASE_ADDR+0x1C000UL)
+#define ISP_FGAMMA_B_BUF0_CH0 (ISP_BASE_ADDR+0x1D000UL)
+#define ISP_YGAMMA_BUF0_CH0 (ISP_BASE_ADDR+0x1E000UL)
+//#define ISP_NLM_BUF0_CH0 (ISP_BASE_ADDR+0x1F000UL)
+//#define ISP_3D_LUT_BUF1_CH0 (ISP_BASE_ADDR+0x20000UL)
+#define ISP_HSV_BUF1_CH0 (ISP_BASE_ADDR+0x1F000UL)
+//#define ISP_VST_BUF1_CH0 (ISP_BASE_ADDR+0x22000UL)
+//#define ISP_IVST_BUF1_CH0 (ISP_BASE_ADDR+0x23000UL)
+//#define ISP_FGAMMA_R_BUF1_CH0 (ISP_BASE_ADDR+0x24000UL)
+//#define ISP_FGAMMA_G_BUF1_CH0 (ISP_BASE_ADDR+0x25000UL)
+//#define ISP_FGAMMA_B_BUF1_CH0 (ISP_BASE_ADDR+0x26000UL)
+//#define ISP_YGAMMA_BUF1_CH0 (ISP_BASE_ADDR+0x27000UL)
+//#define ISP_NLM_BUF1_CH0 (ISP_BASE_ADDR+0x28000UL)
+#define ISP_LEN_BUF0_CH0 (ISP_BASE_ADDR+0x29000UL)
+#define ISP_LEN_BUF1_CH0 (ISP_BASE_ADDR+0x2b000UL)
+
+#define ISP_AHB_BASE SPRD_MMAHB_BASE
+#define ISP_MODULE_EB (ISP_AHB_BASE+0x0000UL)
+#define ISP_MODULE_RESET (ISP_AHB_BASE+0x0004UL)
+#define ISP_CORE_CLK_EB (ISP_AHB_BASE+0x0008UL)
+
+/*isp v memory1: awbm*/
+#define ISP_RAW_AWBM_OUTPUT (ISP_BASE_ADDR+0x10000)
+/*#define ISP_RAW_AWBM_ITEM 256*/
+
+/*isp v memory2: aem*/
+#define ISP_RAW_AEM_OUTPUT (ISP_BASE_ADDR+0x12000)
+/*#define ISP_RAW_AEM_ITEM 1024*/
+
+/*isp v memory11: 3D_LUT0*/
+#define ISP_3D_LUT0_OUTPUT (ISP_BASE_ADDR+0x17000)
+/*#define ISP_3D_LUT0_ITEM 729*/
+
+/*isp v memory12: HSV BUF0*/
+#define ISP_HSV_BUF0_OUTPUT (ISP_BASE_ADDR+0x18000)
+/*#define ISP_HSV_ITEM 361*/
+
+/*isp v memory20: 3D_LUT1*/
+//#define ISP_3D_LUT1_OUTPUT (ISP_BASE_ADDR+0x20000)
+/*#define ISP_3D_LUT1_ITEM 729*/
+
+/*isp v memory21: HSV BUF1*/
+#define ISP_HSV_BUF1_OUTPUT (ISP_BASE_ADDR+0x21000)
+/*#define ISP_HSV_ITEM 361*/
+
+/*irq line number in system*/
+#define ISP_IRQ IRQ_ISP_INT
+
+#define ISP_RST_LOG_BIT BIT_2
+#define ISP_RST_CFG_BIT BIT_3
+
+#define ISP_IRQ_HW_MASK (0xFFFFFFFF)
+#define ISP_IRQ_NUM (32)
+#define ISP_REG_BUF_SIZE (4 * 1024)
+#define ISP_RAW_AE_BUF_SIZE (1024 * 4 * 3)
+#define ISP_FRGB_GAMMA_BUF_SIZE (129 * 4)
+#define ISP_YUV_YGAMMA_BUF_SIZE (129 * 4 )
+#define ISP_RAW_AWB_BUF_SIZE (256 * 4 * 9)
+#define ISP_BING4AWB_SIZE (640 * 480 * 2)
+#define ISP_YIQ_ANTIFLICKER_SIZE (1944 * 4 * 16)
+#define ISP_YIQ_AEM_BUF_SIZE (1024 * 4)
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_cfg_param.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_cfg_param.c
new file mode 100644
index 00000000..e75aec4d
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_cfg_param.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_block.h"
+
+typedef int32_t (*isp_cfg_fun_ptr)(struct isp_io_param *isp_param);
+
+struct isp_cfg_fun {
+ uint32_t sub_block;
+ isp_cfg_fun_ptr cfg_fun;
+};
+
+static struct isp_cfg_fun isp_cfg_fun_tab[] = {
+ {ISP_BLOCK_PRE_GLB_GAIN, isp_k_cfg_pgg},
+ {ISP_BLOCK_BLC, isp_k_cfg_blc},
+ {ISP_BLOCK_RGB_GAIN, isp_k_cfg_rgb_gain},
+ {ISP_BLOCK_PRE_WAVELET, isp_k_cfg_pwd},
+ {ISP_BLOCK_NLC, isp_k_cfg_nlc},
+ /*{ISP_BLOCK_2D_LSC, isp_k_cfg_2d_lsc},*/
+ {ISP_BLOCK_1D_LSC, isp_k_cfg_1d_lsc},
+ /*{ISP_BLOCK_BINNING4AWB, isp_k_cfg_binning},*/
+ /*{ISP_BLOCK_AWB, isp_k_cfg_awb},*/
+ /*{ISP_BLOCK_RAW_AEM, isp_k_cfg_raw_aem},*/
+ {ISP_BLOCK_BPC, isp_k_cfg_bpc},
+ {ISP_BLOCK_BDN, isp_k_cfg_bdn},
+ {ISP_BLOCK_GRGB, isp_k_cfg_grgb},
+ {ISP_BLOCK_RGB_GAIN2, isp_k_cfg_rgb_gain2},
+ {ISP_BLOCK_NLM, isp_k_cfg_nlm},
+ {ISP_BLOCK_CFA, isp_k_cfg_cfa},
+ {ISP_BLOCK_CMC, isp_k_cfg_cmc10},
+ {ISP_BLOCK_HDR, isp_k_cfg_hdr},//pike add module,this module is same to sharkl's hdr module
+ /*{ISP_BLOCK_GAMMA, isp_k_cfg_gamma},*/
+ {ISP_BLOCK_CMC8, isp_k_cfg_cmc8},
+ /*{ISP_BLOCK_CT, isp_k_cfg_ct},*/
+ {ISP_BLOCK_CCE, isp_k_cfg_cce},
+ {ISP_BLOCK_HSV, isp_k_cfg_hsv},
+ {ISP_BLOCK_CSC, isp_k_cfg_csc},
+ {ISP_BLOCK_PRE_CDN_RGB, isp_k_cfg_pre_cdn_rgb},
+ {ISP_BLOCK_POSTERIZE, isp_k_cfg_posterize},
+ {ISP_BLOCK_AFM_V1, isp_k_cfg_rgb_afm},
+ {ISP_BLOCK_RGB2Y, isp_k_cfg_rgb2y},//pike add module
+ {ISP_BLOCK_YIQ_AEM, isp_k_cfg_yiq_aem},
+ /*{ISP_BLOCK_ANTI_FLICKER, isp_k_cfg_anti_flicker},*/
+ {ISP_BLOCK_YIQ_AFM, isp_k_cfg_yiq_afm},
+ {ISP_BLOCK_YUV_PRECDN, isp_k_cfg_yuv_precdn},
+ {ISP_BLOCK_PRE_FILTER, isp_k_cfg_prefilter},
+ {ISP_BLOCK_UV_PREFILTER, isp_k_cfg_uv_prefilter},//pike add module
+ {ISP_BLOCK_BRIGHTNESS, isp_k_cfg_brightness},
+ {ISP_BLOCK_CONTRAST, isp_k_cfg_contrast},
+ {ISP_BLOCK_HIST, isp_k_cfg_hist},
+ {ISP_BLOCK_HIST2, isp_k_cfg_hist2},
+ {ISP_BLOCK_ACA, isp_k_cfg_aca},
+ {ISP_BLOCK_YUV_CDN, isp_k_cfg_yuv_cdn},
+ {ISP_BLOCK_EDGE, isp_k_cfg_edge},
+ {ISP_BLOCK_CSS, isp_k_cfg_css},
+ {ISP_BLOCK_CSA, isp_k_cfg_csa},
+ {ISP_BLOCK_HUE, isp_k_cfg_hue},
+ {ISP_BLOCK_POST_CDN, isp_k_cfg_post_cdn},
+ {ISP_BLOCK_EMBOSS, isp_k_cfg_emboss},
+ /*{ISP_BLOCK_YGAMMA, isp_k_cfg_ygamma},*/
+ {ISP_BLOCK_YDELAY, isp_k_cfg_ydelay},
+ {ISP_BLOCK_YUV_NLM, isp_k_cfg_yuv_nlm},//pike add module
+ //{ISP_BLOCK_IIRCNR, isp_k_cfg_iircnr},//pike has no this module
+ {ISP_BLOCK_FETCH, isp_k_cfg_fetch},
+ {ISP_BLOCK_STORE, isp_k_cfg_store},
+ {ISP_BLOCK_DISPATCH, isp_k_cfg_dispatch},
+ {ISP_BLOCK_ARBITER_V1, isp_k_cfg_arbiter},
+ //{ISP_BLOCK_RAW_SIZER, isp_k_cfg_raw_sizer},//pike has no this module
+ {ISP_BLOCK_COMMON_V1, isp_k_cfg_common},
+};
+
+int32_t isp_cfg_param(void *param, struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t i = 0, cnt = 0;
+ isp_cfg_fun_ptr cfg_fun_ptr = NULL;
+ struct isp_io_param isp_param = {0, 0, 0, NULL};
+
+ if (!param) {
+ printk("isp_cfg_param: param is null error.\n");
+ return -1;
+ }
+
+ ret = copy_from_user((void *)&isp_param, (void *)param, sizeof(isp_param));
+ if ( 0 != ret) {
+ printk("isp_cfg_param: copy error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (ISP_BLOCK_ANTI_FLICKER == isp_param.sub_block) {
+ ret = isp_k_cfg_anti_flicker(&isp_param, isp_private);
+ } else if (ISP_BLOCK_2D_LSC == isp_param.sub_block) {
+ ret = isp_k_cfg_2d_lsc(&isp_param, isp_private);
+ } else if (ISP_BLOCK_RAW_AEM == isp_param.sub_block) {
+ ret = isp_k_cfg_raw_aem(&isp_param, isp_private);
+ } else if (ISP_BLOCK_GAMMA == isp_param.sub_block) {
+ ret = isp_k_cfg_gamma(&isp_param, isp_private);
+ } else if (ISP_BLOCK_CT == isp_param.sub_block) {
+ ret = isp_k_cfg_ct(&isp_param, isp_private);
+ } else if (ISP_BLOCK_YGAMMA == isp_param.sub_block) {
+ ret = isp_k_cfg_ygamma(&isp_param, isp_private);
+ } else if (ISP_BLOCK_AWB == isp_param.sub_block) {
+ ret = isp_k_cfg_awb(&isp_param, isp_private);
+ } else if(ISP_BLOCK_BINNING4AWB == isp_param.sub_block){
+ ret = isp_k_cfg_binning(&isp_param, isp_private);
+ } else {
+ cnt = sizeof(isp_cfg_fun_tab) / sizeof(isp_cfg_fun_tab[0]);
+ for (i = 0; i < cnt; i++) {
+ if (isp_param.sub_block == isp_cfg_fun_tab[i].sub_block) {
+ cfg_fun_ptr = isp_cfg_fun_tab[i].cfg_fun;
+ break;
+ }
+ }
+
+ if (NULL != cfg_fun_ptr)
+ ret = cfg_fun_ptr(&isp_param);
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_1d_lsc.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_1d_lsc.c
new file mode 100644
index 00000000..3daa3ef5
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_1d_lsc.c
@@ -0,0 +1,146 @@
+/*
+ * 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"
+
+static int32_t isp_k_1d_lsc_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_1d_lsc_info lnc_info;
+
+ ret = copy_from_user((void *)&lnc_info, param->property_param, sizeof(lnc_info));
+ if (0 != ret) {
+ printk("isp_k_1d_lsc_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_1D_LNC_PARAM, BIT_0, lnc_info.bypass);
+
+ val = (lnc_info.gain_max_thr & 0x1FFF) << 1;
+ REG_MWR(ISP_1D_LNC_PARAM, 0x3FFE, val);
+
+ val = ((lnc_info.center_r0c0_col_x & 0x1FFF) << 12) | (lnc_info.center_r0c0_row_y & 0xFFF);
+ REG_WR(ISP_1D_LNC_PARAM1, val);
+ val = ((lnc_info.center_r0c1_col_x & 0x1FFF) << 12) | (lnc_info.center_r0c1_row_y & 0xFFF);
+ REG_WR(ISP_1D_LNC_PARAM2, val);
+ val = ((lnc_info.center_r1c0_col_x & 0x1FFF) << 12) | (lnc_info.center_r1c0_row_y & 0xFFF);
+ REG_WR(ISP_1D_LNC_PARAM3, val);
+ val = ((lnc_info.center_r1c1_col_x & 0x1FFF) << 12) | (lnc_info.center_r1c1_row_y & 0xFFF);
+ REG_WR(ISP_1D_LNC_PARAM4, val);
+
+ val = lnc_info.delta_square_r0c0_x & 0x3FFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM5, val);
+ val = lnc_info.delta_square_r0c1_x & 0x3FFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM7, val);
+ val = lnc_info.delta_square_r1c0_x & 0x3FFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM9, val);
+ val = lnc_info.delta_square_r1c1_x & 0x3FFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM11, val);
+ val = lnc_info.delta_square_r0c0_y & 0xFFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM6, val);
+ val = lnc_info.delta_square_r0c1_y & 0xFFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM8, val);
+ val = lnc_info.delta_square_r1c0_y & 0xFFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM10, val);
+ val = lnc_info.delta_square_r1c1_y & 0xFFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM12, val);
+
+ val = ((lnc_info.coef_r0c0_p1 & 0xFFFF) << 11) | (lnc_info.coef_r0c0_p2 & 0x7FF);
+ REG_WR(ISP_1D_LNC_PARAM13, val);
+ val = ((lnc_info.coef_r0c1_p1 & 0xFFFF) << 11) | (lnc_info.coef_r0c1_p2 & 0x7FF);
+ REG_WR(ISP_1D_LNC_PARAM14, val);
+ val = ((lnc_info.coef_r1c0_p1 & 0xFFFF) << 11) | (lnc_info.coef_r1c0_p2 & 0x7FF);
+ REG_WR(ISP_1D_LNC_PARAM15, val);
+ val = ((lnc_info.coef_r1c1_p1 & 0xFFFF) << 11) | (lnc_info.coef_r1c1_p2 & 0x7FF);
+ REG_WR(ISP_1D_LNC_PARAM16, val);
+
+ val = ((lnc_info.start_pos.x & 0x1FFF) << 12) | (lnc_info.start_pos.y & 0xFFF);
+ REG_WR(ISP_1D_LNC_PARAM18, val);
+
+ return ret;
+}
+
+static int32_t isp_k_1d_lsc_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size;
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
+ if (0 != ret) {
+ printk("isp_k_1d_lsc_slice_size: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.width & 0x1FFF) << 12) | (size.height & 0xFFF);
+
+ REG_WR(ISP_1D_LNC_PARAM17, val);
+
+ return ret;
+}
+
+static int32_t isp_k_1d_lsc_pos(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct img_offset pos;
+
+ ret = copy_from_user((void *)&pos, param->property_param, sizeof(struct img_offset));
+ if (0 != ret) {
+ printk("isp_k_1d_lsc_pos: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((pos.x & 0x1FFF) << 12) | (pos.y & 0xFFF);
+
+ REG_WR(ISP_1D_LNC_PARAM18, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_1d_lsc(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_1d_lsc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_1d_lsc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_1D_LSC_BLOCK:
+ ret = isp_k_1d_lsc_block(param);
+ break;
+ case ISP_PRO_1D_LSC_SLICE_SIZE:
+ ret = isp_k_1d_lsc_slice_size(param);
+ break;
+ case ISP_PRO_1D_LSC_POS:
+ ret = isp_k_1d_lsc_pos(param);
+ break;
+ default:
+ printk("isp_k_cfg_1d_lsc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_2d_lsc.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_2d_lsc.c
new file mode 100644
index 00000000..94f1f2c4
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_2d_lsc.c
@@ -0,0 +1,537 @@
+/*
+ * 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 <asm/cacheflush.h>
+#include <linux/delay.h>
+#include "isp_reg.h"
+#include "isp_drv.h"
+
+
+#define ISP_LSC_TIME_OUT_MAX 500
+#define ISP_LSC_BUF0 0
+#define ISP_LSC_BUF1 1
+
+#if 0
+#define CLIP(input,top, bottom) {if (input>top) input = top; if (input < bottom) input = bottom;}
+#define TABLE_LEN_128 128
+#define TABLE_LEN_96 96
+
+typedef struct lnc_bicubic_weight_t_64_tag
+{
+ int16_t w0;
+ int16_t w1;
+ int16_t w2;
+ int16_t w3;
+}LNC_BICUBIC_WEIGHT_TABLE_T;
+////////10bit precision//////////////////////////////////////
+static LNC_BICUBIC_WEIGHT_TABLE_T lnc_bicubic_weight_t_96_simple[] =
+{
+ {0, 1024, 0},
+ {-5,1024, 6},
+ {-10,1023, 12},
+ {-15,1022, 18},
+ {-20,1020, 25},
+ {-24,1017, 32},
+ {-28,1014, 40},
+ {-32,1011, 48},
+ {-36,1007, 56},
+ {-39,1003, 65},
+ {-43,998, 74},
+ {-46,993, 83},
+ {-49,987, 93},
+ {-52,981, 103},
+ {-54,974, 113},
+ {-57,967, 124},
+ {-59,960, 135},
+ {-61,952, 146},
+ {-63,944, 158},
+ {-65,936, 170},
+ {-67,927, 182},
+ {-68,918, 194},
+ {-70,908, 206},
+ {-71,898, 219},
+ {-72,888, 232},
+ {-73,878, 245},
+ {-74,867, 258},
+ {-74,856, 272},
+ {-75,844, 285},
+ {-75,833, 299},
+ {-76,821, 313},
+ {-76,809, 327},
+ {-76,796, 341},
+ {-76,784, 356},
+ {-76,771, 370},
+ {-75,758, 384},
+ {-75,745, 399},
+ {-75,732, 414},
+ {-74,718, 428},
+ {-73,704, 443},
+ {-73,691, 458},
+ {-72,677, 473},
+ {-71,663, 487},
+ {-70,648, 502},
+ {-69,634, 517},
+ {-68,620, 532},
+ {-67,605, 547},
+ {-65,591, 561},
+ {-64,576, 576},
+};
+
+static LNC_BICUBIC_WEIGHT_TABLE_T lnc_bicubic_weight_t_128_simple[] =
+{
+ {0, 1024, 0},
+ {-4, 1024, 4},
+ {-8, 1023, 8},
+ {-11, 1023, 13},
+ {-15, 1022, 18},
+ {-18, 1020, 23},
+ {-22, 1019, 28},
+ {-25, 1017, 34},
+ {-28, 1014, 40},
+ {-31, 1012, 46},
+ {-34, 1009, 52},
+ {-37, 1006, 58},
+ {-39, 1003, 65},
+ {-42, 999, 72},
+ {-44, 995, 78},
+ {-47, 991, 86},
+ {-49, 987, 93},
+ {-51, 982, 101},
+ {-53, 978, 108},
+ {-55, 973, 116},
+ {-57, 967, 124},
+ {-59, 962, 132},
+ {-60, 956, 141},
+ {-62, 950, 149},
+ {-63, 944, 158},
+ {-65, 938, 167},
+ {-66, 931, 176},
+ {-67, 925, 185},
+ {-68, 918, 194},
+ {-69, 910, 203},
+ {-70, 903, 213},
+ {-71, 896, 222},
+ {-72, 888, 232},
+ {-73, 880, 242},
+ {-73, 872, 252},
+ {-74, 864, 262},
+ {-74, 856, 272},
+ {-75, 847, 282},
+ {-75, 839, 292},
+ {-75, 830, 303},
+ {-76, 821, 313},
+ {-76, 812, 324},
+ {-76, 803, 334},
+ {-76, 793, 345},
+ {-76, 784, 356},
+ {-76, 774, 366},
+ {-76, 765, 377},
+ {-75, 755, 388},
+ {-75, 745, 399},
+ {-75, 735, 410},
+ {-74, 725, 421},
+ {-74, 715, 432},
+ {-73, 704, 443},
+ {-73, 694, 454},
+ {-72, 684, 465},
+ {-72, 673, 476},
+ {-71, 663, 487},
+ {-70, 652, 498},
+ {-69, 641, 510},
+ {-69, 631, 521},
+ {-68, 620, 532},
+ {-67, 609, 543},
+ {-66, 598, 554},
+ {-65, 587, 565},
+ {-64, 576, 576},
+};
+
+static uint16_t ISP_Cubic1D(uint16_t a, uint16_t b, uint16_t c, uint16_t d, uint16_t u, uint16_t box)
+{
+ int32_t out_value;
+ uint16_t out_value_uint16_t;
+ int16_t w0, w1, w2, w3;
+ uint32_t out_value_tmp;
+ int16_t sub_tmp0;
+ int16_t sub_tmp1;
+ int16_t sub_tmp2;
+
+ if(box ==96)
+ {
+ //use simple table
+ if ( u < (TABLE_LEN_96/2 + 1) )
+ {
+ w0 = lnc_bicubic_weight_t_96_simple[u].w0 ;
+ w1 = lnc_bicubic_weight_t_96_simple[u].w1 ;
+ w2 = lnc_bicubic_weight_t_96_simple[u].w2 ;
+
+ sub_tmp0 = a-d;
+ sub_tmp1 = b-d;
+ sub_tmp2 = c-d;
+ out_value_tmp = ((uint32_t)d)<<10;
+ out_value = out_value_tmp + sub_tmp0 * w0 + sub_tmp1 * w1 + sub_tmp2 * w2;
+ }
+ else
+ {
+ w1 = lnc_bicubic_weight_t_96_simple[TABLE_LEN_96 - u].w2 ;
+ w2 = lnc_bicubic_weight_t_96_simple[TABLE_LEN_96 - u].w1 ;
+ w3 = lnc_bicubic_weight_t_96_simple[TABLE_LEN_96 - u].w0 ;
+
+ sub_tmp0 = b-a;
+ sub_tmp1 = c-a;
+ sub_tmp2 = d-a;
+ out_value_tmp = ((uint32_t)a)<<10;
+ out_value = out_value_tmp + sub_tmp0 * w1 + sub_tmp1 * w2 + sub_tmp2 * w3;
+ }
+
+ }
+ else
+ {
+ u = u * (TABLE_LEN_128 / box);
+
+ //use simple table
+ if ( u < (TABLE_LEN_128/2 + 1) )
+ {
+ w0 = lnc_bicubic_weight_t_128_simple[u].w0 ;
+ w1 = lnc_bicubic_weight_t_128_simple[u].w1 ;
+ w2 = lnc_bicubic_weight_t_128_simple[u].w2 ;
+
+ sub_tmp0 = a-d;
+ sub_tmp1 = b-d;
+ sub_tmp2 = c-d;
+ out_value_tmp = ((uint32_t)d)<<10;
+ out_value = out_value_tmp + sub_tmp0 * w0 + sub_tmp1 * w1 + sub_tmp2 * w2;
+ }
+ else
+ {
+ w1 = lnc_bicubic_weight_t_128_simple[TABLE_LEN_128 - u].w2 ;
+ w2 = lnc_bicubic_weight_t_128_simple[TABLE_LEN_128 - u].w1 ;
+ w3 = lnc_bicubic_weight_t_128_simple[TABLE_LEN_128 - u].w0 ;
+
+ sub_tmp0 = b-a;
+ sub_tmp1 = c-a;
+ sub_tmp2 = d-a;
+ out_value_tmp = ((uint32_t)a)<<10;
+ out_value = out_value_tmp + sub_tmp0 * w1 + sub_tmp1 * w2 + sub_tmp2 * w3;
+ }
+ }
+
+ //CLIP(out_value, 4095*1024*2, 1024*1024); // for LSC gain, 1024 = 1.0, 4095 = 4.0 ; 4095*2 is for boundary extension.
+ CLIP(out_value, 16383*1024, 1024*1024); // for LSC gain, 1024 = 1.0, 16383 = 16.0 ; 16383 is for boundary extension, 14 bit parameter is used.
+
+ out_value_uint16_t = (uint16_t)((out_value + 512) >> 10);
+
+ return out_value_uint16_t;
+}
+
+
+static int32_t ISP_GenerateQValues(uint32_t word_endian, uint32_t q_val[][5], unsigned long param_address, uint16_t grid_w, uint16_t grid_num, uint16_t u)
+{
+ uint8_t i;
+ uint16_t A0, B0, C0, D0;
+ uint16_t A1, B1, C1, D1;
+ uint32_t *addr = (uint32_t *)param_address;
+
+ if (param_address == 0x0 || grid_num == 0x0) {
+ printk("ISP_GenerateQValues param_address error addr=0x%lx grid_num=%d \n",param_address, grid_num);
+ return -1;
+ }
+
+ //printk("ISP_GenerateQValues:addr=%x grid_w=%d grid_num=%d u=%d \n",param_address,grid_w,grid_num,u);
+ #if 0
+ for (i = 0; i < 5; i++) {
+ A0 = (uint16_t)*(addr + i * 2) & 0xFFFF;
+ B0 = (uint16_t)*(addr + i * 2 + grid_w * 2) & 0xFFFF;
+ C0 = (uint16_t)*(addr + i * 2 + grid_w * 2 * 2) & 0xFFFF;
+ D0 = (uint16_t)*(addr + i * 2 + grid_w * 2 * 3) & 0xFFFF;
+ A1 = (uint16_t)(*(addr + i * 2) >> 16);
+ B1 = (uint16_t)(*(addr + i * 2 + grid_w * 2) >> 16);
+ C1 = (uint16_t)(*(addr + i * 2 + grid_w * 2 * 2) >> 16);
+ D1 = (uint16_t)(*(addr + i * 2 + grid_w * 2 * 3) >> 16);
+ q_val[0][i] = ISP_Cubic1D(A0, B0, C0, D0, u, grid_num);
+ q_val[1][i] = ISP_Cubic1D(A1, B1, C1, D1, u, grid_num);
+ }
+ #endif
+ #if 1
+ for (i = 0; i < 5; i++) {
+ if (1 == word_endian) { // ABCD = 1 word
+ A0 = *(addr + i * 2) >> 16; // AB
+ B0 = *(addr + i * 2 + grid_w * 2) >> 16; // AB
+ C0 = *(addr + i * 2 + grid_w * 2 * 2) >> 16; // AB
+ D0 = *(addr + i * 2 + grid_w * 2 * 3) >> 16; // AB
+ A1 = *(addr + i * 2) & 0xFFFF; // CD
+ B1 = *(addr + i * 2 + grid_w * 2) & 0xFFFF; // CD
+ C1 = *(addr + i * 2 + grid_w * 2 * 2) & 0xFFFF;// CD
+ D1 = *(addr + i * 2 + grid_w * 2 * 3) & 0xFFFF;// CD
+ } else if (2 == word_endian) { // CDAB = 1 word
+ A0 = *(addr + i * 2) & 0xFFFF;
+ B0 = *(addr + i * 2 + grid_w * 2) & 0xFFFF;
+ C0 = *(addr + i * 2 + grid_w * 2 * 2) & 0xFFFF;
+ D0 = *(addr + i * 2 + grid_w * 2 * 3) & 0xFFFF;
+ A1 = *(addr + i * 2) >> 16;
+ B1 = *(addr + i * 2 + grid_w * 2) >> 16;
+ C1 = *(addr + i * 2 + grid_w * 2 * 2) >> 16;
+ D1 = *(addr + i * 2 + grid_w * 2 * 3) >> 16;
+ } else if (0 == word_endian) { // DCBA = 1 word
+ A0 = ((*(addr + i * 2) << 8) & 0x0000FF00) | ((*(addr + i * 2) >> 8) & 0x000000FF);
+ B0 = ((*(addr + i * 2 + grid_w * 2) << 8) & 0x0000FF00) | ((*(addr + i * 2 + grid_w * 2) >> 8) & 0x000000FF);
+ C0 = ((*(addr + i * 2 + grid_w * 2 * 2) << 8) & 0x0000FF00) | ((*(addr + i * 2 + grid_w * 2 * 2) >> 8) & 0x000000FF);
+ D0 = ((*(addr + i * 2 + grid_w * 2 * 3) << 8) & 0x0000FF00) | ((*(addr + i * 2 + grid_w * 2 * 3) >> 8) & 0x000000FF);
+ A1 = ((*(addr + i * 2) << 8) & 0xFF000000) | ((*(addr + i * 2) >> 8) & 0x00FF0000);
+ B1 = ((*(addr + i * 2 + grid_w * 2) << 8) & 0xFF000000) | ((*(addr + i * 2 + grid_w * 2) >> 8) & 0x00FF0000);
+ C1 = ((*(addr + i * 2 + grid_w * 2 * 2) << 8) & 0xFF000000) | ((*(addr + i * 2 + grid_w * 2 * 2) >> 8) & 0x00FF0000);
+ D1 = ((*(addr + i * 2 + grid_w * 2 * 3) << 8) & 0xFF000000) | ((*(addr + i * 2 + grid_w * 2 * 3) >> 8) & 0x00FF0000);
+ } else if (3 == word_endian) { // BADC = 1 word
+ A0 = ((*(addr + i * 2) << 8) & 0xFF000000) | ((*(addr + i * 2) >> 8) & 0x00FF0000);
+ B0 = ((*(addr + i * 2 + grid_w * 2) << 8) & 0xFF000000) | ((*(addr + i * 2 + grid_w * 2) >> 8) & 0x00FF0000);
+ C0 = ((*(addr + i * 2 + grid_w * 2 * 2) << 8) & 0xFF000000) | ((*(addr + i * 2 + grid_w * 2 * 2) >> 8) & 0x00FF0000);
+ D0 = ((*(addr + i * 2 + grid_w * 2 * 3) << 8) & 0xFF000000) | ((*(addr + i * 2 + grid_w * 2 * 3) >> 8) & 0x00FF0000);
+ A1 = ((*(addr + i * 2) << 8) & 0x0000FF00) | ((*(addr + i * 2) >> 8) & 0x000000FF);
+ B1 = ((*(addr + i * 2 + grid_w * 2) << 8) & 0x0000FF00) | ((*(addr + i * 2 + grid_w * 2) >> 8) & 0x000000FF);
+ C1 = ((*(addr + i * 2 + grid_w * 2 * 2) << 8) & 0x0000FF00) | ((*(addr + i * 2 + grid_w * 2 * 2) >> 8) & 0x000000FF);
+ D1 = ((*(addr + i * 2 + grid_w * 2 * 3) << 8) & 0x0000FF00) | ((*(addr + i * 2 + grid_w * 2 * 3) >> 8) & 0x000000FF);
+ }
+ //printk("ISP_GenerateQValues: A0=%x B0=%x C0=%x D0=%x A1=%x B1=%x C1=%x D1=%x \n",A0,B0,C0,D0,A1,B1,C1,D1);
+ q_val[0][i] = ISP_Cubic1D(A0, B0, C0, D0, u, grid_num);
+ q_val[1][i] = ISP_Cubic1D(A1, B1, C1, D1, u, grid_num);
+ //printk("ISP_GenerateQValues: q_val[0][%d] = %d q_val[1][%d] = %d \n",i,q_val[0][i],i ,q_val[1][i] );
+ }
+ #endif
+
+ return 0;
+}
+#endif
+
+static int32_t isp_k_2d_lsc_param_load(struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t time_out_cnt = 0;
+ uint32_t addr = 0, reg_value = 0;
+
+ if (ISP_LSC_BUF0 == isp_private->lsc_load_buf_id) {
+ isp_private->lsc_load_buf_id = ISP_LSC_BUF1;
+ } else {
+ isp_private->lsc_load_buf_id = ISP_LSC_BUF0;
+ }
+ REG_MWR(ISP_LENS_LOAD_BUF, BIT_0, isp_private->lsc_load_buf_id);
+ REG_WR(ISP_LENS_PARAM_ADDR, isp_private->lsc_buf_phys_addr);
+ REG_OWR(ISP_LENS_LOAD_EB, BIT_0);
+ REG_MWR(ISP_LENS_PARAM, BIT_1, isp_private->lsc_load_buf_id << 1);
+ isp_private->lsc_update_buf_id = isp_private->lsc_load_buf_id;
+
+ reg_value = REG_RD(ISP_INT_RAW0);
+
+ while ((0x00 == (reg_value & ISP_INT_EVT_LSC_LOAD))
+ && (time_out_cnt < ISP_LSC_TIME_OUT_MAX)) {
+ udelay(1);
+ reg_value = REG_RD(ISP_INT_RAW0);
+ time_out_cnt++;
+ }
+ if (time_out_cnt >= ISP_LSC_TIME_OUT_MAX) {
+ ret = -1;
+ printk("isp_k_2d_lsc_param_load: lsc load time out error.\n");
+ }
+ REG_OWR(ISP_INT_CLR0, ISP_INT_EVT_LSC_LOAD);
+
+ return ret;
+}
+
+static int32_t isp_k_2d_lsc_block(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ //uint32_t qvalue_addr = ISP_LEN_BUF0_CH0;
+ struct isp_dev_2d_lsc_info lens_info;
+
+ memset(&lens_info, 0x00, sizeof(lens_info));
+
+ ret = copy_from_user((void *)&lens_info, param->property_param, sizeof(lens_info));
+ if (0 != ret) {
+ printk("isp_k_2d_lsc_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((lens_info.offset_y & 0xFFFF) << 16) | (lens_info.offset_x & 0xFFFF);
+ REG_WR(ISP_LENS_SLICE_POS, val);
+
+ val = lens_info.grid_pitch & 0x1FF;
+ REG_MWR(ISP_LENS_GRID_PITCH, 0x1FF, val);
+
+ val = (lens_info.grid_width & 0xFF) << 16;
+ REG_MWR(ISP_LENS_GRID_PITCH, 0xFF0000, val);
+
+ val = ((lens_info.grid_num_t & 0xFFFF) << 16) | ((lens_info.grid_y_num & 0xFF) << 8) | (lens_info.grid_x_num & 0xFF);
+ REG_WR(ISP_LENS_GRID_SIZE, val);
+
+ REG_MWR(ISP_LENS_LOAD_BUF, BIT_1, lens_info.load_chn_sel << 1);
+
+ REG_MWR(ISP_LENS_MISC, (BIT_1 | BIT_0), (lens_info.endian & 0x03));
+
+ val = ((lens_info.slice_size.height & 0xFFFF) << 16) | (lens_info.slice_size.width & 0xFFFF);
+ REG_WR(ISP_LENS_SLICE_SIZE, val);
+
+ val = ((lens_info.relative_y & 0xFF) << 8) | (lens_info.relative_x & 0xFF);
+ REG_WR(ISP_LENS_INIT_COOR, val);
+
+ /*ret = isp_k_2d_lsc_param_load(&src_buf, isp_private, &qvalue_addr);
+ REG_WR(ISP_LENS_PARAM_ADDR, qvalue_addr);
+ printk("isp_k_2d_lsc_block:qvalue_addr=%x grid_x_num=%d grid_width=%d relative_y=%d \n",qvalue_addr,(lens_info.grid_x_num & 0xFF),(lens_info.grid_width & 0xFF), (lens_info.relative_y & 0xFF)>>1);
+
+ ISP_GenerateQValues(1, lens_info.q_value, qvalue_addr, ((uint16_t)lens_info.grid_x_num & 0xFF) + 2,(lens_info.grid_width & 0xFF), (lens_info.relative_y & 0xFF)>>1);
+ */
+
+ ret = isp_k_2d_lsc_param_load(isp_private);
+ if (0 != ret) {
+ printk("isp_k_2d_lsc_block: lsc load para error, ret=0x%x\n", (uint32_t)ret);
+ REG_MWR(ISP_LENS_PARAM, BIT_0, ISP_BYPASS_EB);
+ return -1;
+ }
+
+ for (i = 0; i < 5; i++) {
+ val = ((lens_info.q_value[0][i] & 0x3FFF) << 16) | (lens_info.q_value[1][i] & 0x3FFF);
+ REG_WR(ISP_LENS_Q0_VALUE + i * 4, val);
+ }
+
+ REG_MWR(ISP_LENS_PARAM, BIT_0, lens_info.bypass);
+
+ return ret;
+
+}
+
+static int32_t isp_k_2d_lsc_param_update(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ REG_MWR(ISP_LENS_PARAM, BIT_1, isp_private->lsc_update_buf_id << 1);
+
+ return ret;
+}
+
+static int32_t isp_k_2d_lsc_pos(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_offset offset = {0, 0};
+
+ ret = copy_from_user((void *)&offset, param->property_param, sizeof(offset));
+ if (0 != ret) {
+ printk("isp_k_lens_pos: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((offset.y & 0xFFFF) << 16) | (offset.x & 0xFFFF);
+
+ REG_WR(ISP_LENS_SLICE_POS, val);
+
+ return ret;
+}
+
+static int32_t isp_k_2d_lsc_grid_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t grid_total = 0;
+ struct isp_img_size size = {0, 0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(size));
+ if (0 != ret) {
+ printk("isp_k_2d_lsc_grid_size: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ grid_total = (size.height + 2) * (size.width + 2);
+ val = ((grid_total & 0xFFFF) << 16) | ((size.height & 0xFF) << 8) | (size.width & 0xFF);
+ REG_WR(ISP_LENS_GRID_SIZE, val);
+
+ return ret;
+}
+
+static int32_t isp_k_2d_lsc_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size = {0, 0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(size));
+ if (0 != ret) {
+ printk("isp_k_2d_lsc_slice_size: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height & 0xFFFF) << 16) | (size.width & 0xFFFF);
+
+ REG_WR(ISP_LENS_SLICE_SIZE, val);
+
+ return ret;
+}
+
+static int32_t isp_k_2d_lsc_transaddr(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ struct isp_lsc_addr lsc_addr;
+
+ ret = copy_from_user((void *)&lsc_addr, param->property_param, sizeof(struct isp_lsc_addr));
+
+ isp_private->lsc_buf_phys_addr = lsc_addr.phys_addr;
+
+ printk("lsc phys addr 0x%x,\n",isp_private->lsc_buf_phys_addr);
+ return ret;
+}
+
+int32_t isp_k_cfg_2d_lsc(struct isp_io_param *param, struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_2d_lsc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_2d_lsc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_2D_LSC_BLOCK:
+ ret = isp_k_2d_lsc_block(param, isp_private);
+ break;
+ case ISP_PRO_2D_LSC_PARAM_UPDATE:
+ ret = isp_k_2d_lsc_param_update(param, isp_private);
+ break;
+ case ISP_PRO_2D_LSC_POS:
+ ret = isp_k_2d_lsc_pos(param);
+ break;
+ case ISP_PRO_2D_LSC_GRID_SIZE:
+ ret = isp_k_2d_lsc_grid_size(param);
+ break;
+ case ISP_PRO_2D_LSC_SLICE_SIZE:
+ ret = isp_k_2d_lsc_slice_size(param);
+ break;
+ case ISP_PRO_2D_LSC_TRANSADDR:
+ ret = isp_k_2d_lsc_transaddr(param, isp_private);
+ break;
+ default:
+ printk("isp_k_cfg_2d_lsc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_aca.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_aca.c
new file mode 100644
index 00000000..0d784c73
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_aca.c
@@ -0,0 +1,78 @@
+/*
+ * 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"
+
+static int32_t isp_k_aca_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_autocont_info_v1 autocont_info;
+ uint32_t val = 0;
+
+ memset(&autocont_info, 0x00, sizeof(autocont_info));
+
+ ret = copy_from_user((void *)&autocont_info, param->property_param, sizeof(autocont_info));
+ if (0 != ret) {
+ printk("isp_k_aca_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((autocont_info.out_max & 0xFF) << 24)
+ | ((autocont_info.out_min & 0xFF) << 16)
+ | ((autocont_info.in_max & 0xFF) << 8)
+ | (autocont_info.in_min & 0xFF);
+
+ REG_WR(ISP_AUTOCONT_MAX_MIN, val);
+
+ if (autocont_info.mode) {
+ REG_OWR(ISP_AUTOCONT_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_AUTOCONT_PARAM, BIT_1, 0);
+ }
+
+ if (autocont_info.bypass) {
+ REG_OWR(ISP_AUTOCONT_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_AUTOCONT_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_aca(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_aca: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_aca: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_ACA_BLOCK:
+ ret = isp_k_aca_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_aca: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_anti_flicker.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_anti_flicker.c
new file mode 100644
index 00000000..cadd5e36
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_anti_flicker.c
@@ -0,0 +1,155 @@
+/*
+ * 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 <asm/cacheflush.h>
+#include "isp_reg.h"
+#include "isp_drv.h"
+
+static int32_t isp_k_afl_param_update(struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t addr = 0;
+#ifndef CONFIG_64BIT
+ void *buf_ptr = (void *)isp_private->yiq_antiflicker_buf_addr;
+#endif
+ uint32_t buf_len = isp_private->yiq_antiflicker_len;
+
+ if((0x00 != isp_private->yiq_antiflicker_buf_addr) && (0x00 != isp_private->yiq_antiflicker_len)) {
+
+#ifndef CONFIG_64BIT
+ dmac_flush_range(buf_ptr, buf_ptr + buf_len);
+ outer_flush_range(__pa(buf_ptr), __pa(buf_ptr) + buf_len);
+#endif
+ addr = (uint32_t)__pa(isp_private->yiq_antiflicker_buf_addr);
+
+ printk("$$LHC:addr %lp yiq_antiflicker_buf_addr %lp\n", addr, (int *)isp_private->yiq_antiflicker_buf_addr);
+ REG_WR(ISP_ANTI_FLICKER_DDR_INIT_ADDR, addr);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_afl_statistic(struct isp_io_param *param, struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ int32_t i = 0;
+ int32_t *addr = NULL;
+ printk("$$LHC:isp_k_afl_statistic \n");
+ if((0x00 != isp_private->yiq_antiflicker_buf_addr) && (0x00 != param->property_param) \
+ && (0x00 != isp_private->yiq_antiflicker_len) ) {
+
+ ret = copy_to_user(param->property_param, isp_private->yiq_antiflicker_buf_addr, isp_private->yiq_antiflicker_len);
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_afl_statistic: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+ addr = isp_private->yiq_antiflicker_buf_addr;
+ for(i = 0;i < 20;i++) {
+ printk("$$LHC %p, 0x%x\n", addr, *addr++);
+ }
+ }
+}
+
+static int32_t isp_k_afl_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
+ if (0 != ret) {
+ printk("isp_k_afl_bypass: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ printk("$$LHC:bypass %d \n", bypass);
+ if (bypass) {
+ REG_OWR(ISP_ANTI_FLICKER_PARAM0, BIT_0);
+ } else {
+ REG_MWR(ISP_ANTI_FLICKER_PARAM0, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+
+static int32_t isp_k_anti_flicker_block(struct isp_io_param *param, struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ struct isp_dev_anti_flicker_info_v1 afl_info;
+
+ memset(&afl_info, 0x00, sizeof(afl_info));
+
+ ret = copy_from_user((void *)&afl_info, param->property_param, sizeof(afl_info));
+ if (0 != ret) {
+ printk("isp_k_anti_flicker_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_ANTI_FLICKER_PARAM0, BIT_0, afl_info.bypass);
+
+ REG_MWR(ISP_ANTI_FLICKER_PARAM0, BIT_1, afl_info.mode << 1);
+
+ REG_MWR(ISP_ANTI_FLICKER_PARAM0, 0xF << 2, afl_info.skip_frame_num << 2);
+
+ REG_MWR(ISP_ANTI_FLICKER_PARAM1, 0xF , afl_info.line_step);
+
+ REG_MWR(ISP_ANTI_FLICKER_PARAM1, 0xFF << 8, afl_info.frame_num << 8);
+
+ REG_MWR(ISP_ANTI_FLICKER_PARAM1, 0xFFFF << 16, afl_info.vheight << 16);
+
+ REG_MWR(ISP_ANTI_FLICKER_COL_POS, 0xFFFF , afl_info.start_col);
+
+ REG_MWR(ISP_ANTI_FLICKER_COL_POS, 0xFFFF << 16, afl_info.end_col << 16);
+
+ //config afl DDR initial address
+ isp_k_afl_param_update(isp_private);
+
+ //REG_WR(ISP_ANTI_FLICKER_DDR_INIT_ADDR, afl_info.addr);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_anti_flicker(struct isp_io_param *param, struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_anti_flicker: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_anti_flicker: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_ANTI_FLICKER_BLOCK:
+ ret = isp_k_anti_flicker_block(param, isp_private);
+ break;
+ case ISP_PRO_ANTI_FLICKER_STATISTIC:
+ ret = isp_k_afl_statistic(param, isp_private);
+ break;
+ case ISP_PRO_ANTI_FLICKER_BYPASS:
+ ret = isp_k_afl_bypass(param);
+ break;
+ default:
+ printk("isp_k_cfg_anti_flicker: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_arbiter.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_arbiter.c
new file mode 100644
index 00000000..4031b04e
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_arbiter.c
@@ -0,0 +1,177 @@
+/*
+ * 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"
+
+static int32_t isp_k_arbiter_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_arbiter_info_v1 arbiter_info;
+ uint32_t val = 0;
+
+ memset(&arbiter_info, 0x00, sizeof(arbiter_info));
+
+ ret = copy_from_user((void *)&arbiter_info, param->property_param, sizeof(arbiter_info));
+ if (0 != ret) {
+ printk("isp_k_arbiter_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((arbiter_info.endian_ch0.bpc_endian & 0x3) << 8) | ((arbiter_info.endian_ch0.lens_endian & 0x3) << 6)
+ | ((arbiter_info.endian_ch0.store_endian & 0x3) << 4) | ((arbiter_info.endian_ch0.fetch_bit_reorder & 0x1) << 2)
+ | (arbiter_info.endian_ch0.fetch_endian & 0x3);
+ REG_WR(ISP_ARBITER_ENDIAN_CH0, val);
+
+ val = ((arbiter_info.endian_ch1.bpc_endian & 0x3) << 8) | ((arbiter_info.endian_ch1.lens_endian & 0x3) << 6)
+ | ((arbiter_info.endian_ch1.store_endian & 0x3) << 4) | ((arbiter_info.endian_ch1.fetch_bit_reorder & 0x1) << 2)
+ | (arbiter_info.endian_ch1.fetch_endian & 0x3);
+ REG_WR(ISP_ARBITER_ENDIAN_CH1, val);
+
+ val = (arbiter_info.para.pause_cycle & 0xFF) | ((arbiter_info.para.reset & 0x1) << 8);
+ REG_WR(ISP_ARBITER_PARAM, val);
+
+ return ret;
+}
+
+static int32_t isp_k_arbiter_wr_status(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t status = 0;
+
+ status = REG_RD(ISP_PRO_ARBITER_WR_STATUS);
+
+ ret = copy_to_user(param->property_param, (void*)&status, sizeof(status));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_arbiter_wr_status: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_arbiter_rd_status(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t status = 0;
+
+ status = REG_RD(ISP_PRO_ARBITER_RD_STATUS);
+
+ ret = copy_to_user(param->property_param, (void*)&status, sizeof(status));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_arbiter_rd_status: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_arbiter_endian_ch0(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct arbiter_endian_v1 endian = {0};
+
+ ret = copy_from_user((void *)&endian, param->property_param, sizeof(endian));
+ if (0 != ret) {
+ printk("isp_k_arbiter_endian_ch0: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((endian.bpc_endian & 0x3) << 8) | ((endian.lens_endian & 0x3) << 6) | ((endian.store_endian & 0x3) << 4)
+ | ((endian.fetch_bit_reorder & 0x1) << 2) | (endian.fetch_endian & 0x3);
+ REG_WR(ISP_ARBITER_ENDIAN_CH0, val);
+
+ return ret;
+}
+
+static int32_t isp_k_arbiter_endian_ch1(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct arbiter_endian_v1 endian = {0};
+
+ ret = copy_from_user((void *)&endian, param->property_param, sizeof(endian));
+ if (0 != ret) {
+ printk("isp_k_arbiter_endian_ch1: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((endian.bpc_endian & 0x3) << 8) | ((endian.lens_endian & 0x3) << 6) | ((endian.store_endian & 0x3) << 4)
+ | ((endian.fetch_bit_reorder & 0x1) << 2) | (endian.fetch_endian & 0x3);
+ REG_WR(ISP_ARBITER_ENDIAN_CH1, val);
+
+ return ret;
+}
+
+static int32_t isp_k_arbiter_param(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct arbiter_param_v1 para = {0};
+
+ ret = copy_from_user((void *)&para, param->property_param, sizeof(para));
+ if (0 != ret) {
+ printk("isp_k_arbiter_param: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (para.pause_cycle & 0xFF) | ((para.reset & 0x1) << 8);
+ REG_WR(ISP_ARBITER_PARAM, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_arbiter(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_arbiter: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_arbiter: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_ARBITER_BLOCK:
+ ret = isp_k_arbiter_block(param);
+ break;
+ case ISP_PRO_ARBITER_WR_STATUS:
+ ret = isp_k_arbiter_wr_status(param);
+ break;
+ case ISP_PRO_ARBITER_RD_STATUS:
+ ret = isp_k_arbiter_rd_status(param);
+ break;
+ case ISP_PRO_ARBITER_PARAM:
+ ret = isp_k_arbiter_param(param);
+ break;
+ case ISP_PRO_ARBITER_ENDIAN_CH0:
+ ret = isp_k_arbiter_endian_ch0(param);
+ break;
+ case ISP_PRO_ARBITER_ENDIAN_CH1:
+ ret = isp_k_arbiter_endian_ch1(param);
+ break;
+ default:
+ printk("isp_k_cfg_arbiter: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_awb.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_awb.c
new file mode 100644
index 00000000..3d9706b4
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_awb.c
@@ -0,0 +1,191 @@
+/*
+ * 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"
+
+static int32_t isp_k_awb_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ struct isp_dev_awb_info_v2 awb_info;
+
+ ret = copy_from_user((void *)&awb_info, param->property_param, sizeof(awb_info));
+ if (0 != ret) {
+ printk("isp_k_awbm_bypass: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ //printk("isp_k_awb_block: %d %d %d %d \n",awb_info.slice_size.width,awb_info.slice_size.height,awb_info.block_size.width,awb_info.block_size.height);
+ //printk("isp_k_awb_block: gain r=%d gr=%d b=%d \n",awb_info.gain.r,awb_info.gain.gr,awb_info.gain.b);
+ //printk("isp_k_awb_block: offset r=%d gr=%d b=%d \n",awb_info.gain_offset.r,awb_info.gain_offset.gr,awb_info.gain_offset.b);
+ /*AWBM*/
+
+ REG_MWR(ISP_AWBM_PARAM, BIT_0, awb_info.awbm_bypass);
+
+ REG_MWR(ISP_AWBM_PARAM, BIT_1, awb_info.mode << 1);
+
+ val = (awb_info.skip_num & 0x0F) << 2;
+ REG_MWR(ISP_AWBM_PARAM, (BIT_5 | BIT_4 | BIT_3 | BIT_2), val);
+
+ val = ((awb_info.block_offset.y & 0xFFFF) << 16) | (awb_info.block_offset.x & 0xFFFF);
+ REG_WR(ISP_AWBM_BLOCK_OFFSET, val);
+
+ val = ((awb_info.block_size.height & 0x1FF) << 9) | (awb_info.block_size.width & 0x1FF);
+ REG_MWR(ISP_AWBM_BLOCK_SIZE, 0x1FFFF, val);
+
+ val = (awb_info.shift & 0x1F) << 18;
+ REG_MWR(ISP_AWBM_BLOCK_SIZE, (0x1F << 18), val);
+
+ REG_MWR(ISP_AWBM_PARAM, BIT_8, awb_info.thr_bypass << 8);
+
+ for (i = 0; i < 5; i++) {
+ val = ((awb_info.rect_pos.start_x[i] & 0x3FF) << 16) | (awb_info.rect_pos.start_y[i] & 0x3FF);
+ REG_WR(ISP_AWBM_WR_0_S + i * 8, val);
+ val = ((awb_info.rect_pos.end_x[i] & 0x3FF) << 16) | (awb_info.rect_pos.end_y[i] & 0x3FF);
+ REG_WR(ISP_AWBM_WR_0_E + i * 8, val);
+ }
+
+ for (i = 0; i < 5; i++) {
+ val = ((awb_info.circle_pos.x[i] & 0x3FF) << 18) | ((awb_info.circle_pos.y[i] & 0x3FF) << 8) | (awb_info.circle_pos.r[i] & 0xFF);
+ REG_WR(ISP_AWBM_NW_0_XYR + i * 4, val);
+ }
+
+ for (i = 0; i < 5; i++) {
+ val = ((awb_info.clctor_pos.start_x[i] & 0x3FF) << 16) | (awb_info.clctor_pos.start_y[i] & 0x3FF);
+ REG_WR(ISP_AWBM_CLCTOR_0_S + i * 8, val);
+ val = ((awb_info.clctor_pos.end_x[i] & 0x3FF) << 16) | (awb_info.clctor_pos.end_y[i] & 0x3FF);
+ REG_WR(ISP_AWBM_CLCTOR_0_E + i * 8, val);
+ }
+
+ val = ((awb_info.thr.g_low & 0x3FF) << 20) | ((awb_info.thr.r_high & 0x3FF) << 10) | (awb_info.thr.r_low & 0x3FF);
+ REG_WR(ISP_AWBM_THR_VALUE1, val);
+ val = ((awb_info.thr.b_high & 0x3FF) << 20) | ((awb_info.thr.b_low & 0x3FF) << 10) | (awb_info.thr.g_high & 0x3FF);
+ REG_WR(ISP_AWBM_THR_VALUE2, val);
+
+// val = ((awb_info.slice_size.height & 0xFFFF) << 16) | (awb_info.slice_size.width & 0xFFFF);
+// REG_WR(ISP_AEM_SLICE_SIZE, val);
+
+ REG_MWR(ISP_AWBM_PARAM, BIT_6, awb_info.skip_num_clear << 6);
+ REG_MWR(ISP_AWBM_POSITION_SEL, BIT_0, awb_info.position_sel);
+
+ REG_WR(ISP_AWBM_MEM_ADDR, awb_info.mem_addr);
+
+ /*AWBC*/
+
+ REG_MWR(ISP_AWBC_PARAM, BIT_0, awb_info.awbc_bypass);
+
+ REG_MWR(ISP_AWBC_PARAM, BIT_1, awb_info.alpha_bypass << 1);
+
+ val = (awb_info.alpha_value & 0x3FF) << 4;
+ REG_MWR(ISP_AWBC_PARAM, 0x3FF0, val);
+
+ REG_MWR(ISP_AWBC_PARAM, BIT_3, awb_info.buf_sel << 3);
+
+ val = ((awb_info.gain.b & 0x3FFF) << 16) | (awb_info.gain.r & 0x3FFF);
+ REG_WR(ISP_AWBC_GAIN0, val);
+ val = ((awb_info.gain.gb & 0x3FFF) << 16) | (awb_info.gain.gr & 0x3FFF);
+ REG_WR(ISP_AWBC_GAIN1, val);
+
+ val = ((awb_info.thrd.b & 0x3FF) << 20) | ((awb_info.thrd.g & 0x3FF) << 10) | (awb_info.thrd.r & 0x3FF);
+ REG_WR(ISP_AWBC_THRD, val);
+
+ val = ((awb_info.gain_offset.b & 0xFFFF) << 16) | (awb_info.gain_offset.r & 0xFFFF);
+ REG_WR(ISP_AWBC_OFFSET0, val);
+ val = ((awb_info.gain_offset.gb & 0xFFFF) << 16) | (awb_info.gain_offset.gr & 0xFFFF);
+ REG_WR(ISP_AWBC_OFFSET1, val);
+
+ val = ((awb_info.gain_buff.b & 0x3FFF) << 16) | (awb_info.gain_buff.r & 0x3FFF);
+ REG_WR(ISP_AWBC_GAIN0_BUF, val);
+ val = ((awb_info.gain_buff.gb & 0x3FFF) << 16) | (awb_info.gain_buff.gr & 0x3FFF);
+ REG_WR(ISP_AWBC_GAIN1_BUF, val);
+
+ val = ((awb_info.gain_offset_buff.b & 0xFFFF) << 16) | (awb_info.gain_offset_buff.r & 0xFFFF);
+ REG_WR(ISP_AWBC_OFFSET0_BUF, val);
+ val = ((awb_info.gain_offset_buff.gb & 0xFFFF) << 16) | (awb_info.gain_offset_buff.gr & 0xFFFF);
+ REG_WR(ISP_AWBC_OFFSET1_BUF, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_awb_statistics(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0, i = 0;
+ unsigned long addr = 0;
+ struct isp_raw_awbm_statistics *awbm_statistics = NULL;
+
+ awbm_statistics = (struct isp_raw_awbm_statistics *)isp_private->raw_awbm_buf_addr;
+ if (!awbm_statistics) {
+ ret = -1;
+ printk("isp_k_raw_awb_statistics: alloc memory error.\n");
+ return -1;
+ }
+
+ addr = ISP_RAW_AWBM_OUTPUT;
+
+ for (i = 0x00; i < ISP_RAW_AWBM_ITEM; i++) {
+ (awbm_statistics + i)->num4 = REG_RD(addr) >> 16;
+ (awbm_statistics + i)->num_t = REG_RD(addr) & 0xffff;
+ (awbm_statistics + i)->num2 = REG_RD(addr + 4) >> 16;
+ (awbm_statistics + i)->num3 = REG_RD(addr + 4) & 0xffff;
+ (awbm_statistics + i)->num0 = REG_RD(addr + 8) >> 16;
+ (awbm_statistics + i)->num1 = REG_RD(addr + 8) & 0xffff;
+ (awbm_statistics + i)->block_b = REG_RD(addr + 12);
+ (awbm_statistics + i)->block_g = REG_RD(addr + 16);
+ (awbm_statistics + i)->block_r = REG_RD(addr + 20);
+ addr += 32;
+ }
+
+ ret = copy_to_user(param->property_param, (void*)awbm_statistics, sizeof(struct isp_raw_awbm_statistics) * ISP_RAW_AWBM_ITEM);
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_raw_awb_statistics: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_awb(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_awb: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_awb: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_AWB_BLOCK:
+ ret = isp_k_awb_block(param);
+ break;
+ case ISP_PRO_AWBM_STATISTICS:
+ ret = isp_k_raw_awb_statistics(param, isp_private);
+ break;
+ default:
+ printk("isp_k_cfg_awb: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_bdn.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_bdn.c
new file mode 100644
index 00000000..9589b8c3
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_bdn.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"
+
+static int32_t isp_k_bdn_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ uint32_t j = 0;
+ struct isp_dev_bdn_info_v1 bdn_info;
+
+ memset(&bdn_info, 0x00, sizeof(bdn_info));
+
+ ret = copy_from_user((void *)&bdn_info, param->property_param, sizeof(bdn_info));
+ if (0 != ret) {
+ printk("isp_k_bdn_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_BDN_PARAM, BIT_1, bdn_info.radial_bypass << 1);
+
+ REG_MWR(ISP_BDN_PARAM, 0x7F0, bdn_info.addback << 4);
+
+ for (i = 0; i < 10; i++) {
+ REG_WR(ISP_BDN_DISWEI0_0 + 40 * i, bdn_info.dis[i][0]);
+
+ REG_WR(ISP_BDN_DISWEI0_1 + 40 * i, bdn_info.dis[i][1]);
+ }
+
+ for (i = 0; i < 10; i++) {
+ for (j = 0; j < 7; j++) {
+ REG_WR(ISP_BDN_RANWEI0_0 + i * 40 + j * 4, bdn_info.ran[i][j]);
+ }
+
+ REG_WR(ISP_BDN_RANWEI0_7 + i * 40, bdn_info.ran[i][7]);
+ }
+
+ val = ((bdn_info.offset_x & 0x1FFF) << 12) | (bdn_info.offset_y & 0xFFF);
+ REG_WR(ISP_BDN_1DLNC_CENTER, val);
+
+ val = bdn_info.squ_x2 & 0x3FFFFFF;
+ REG_WR(ISP_BDN_1DLNC_SQUARE_X, val);
+ val = bdn_info.squ_y2 & 0xFFFFFF;
+ REG_WR(ISP_BDN_1DLNC_SQUARE_Y, val);
+
+ val = ((bdn_info.coef2 & 0xFFFF) << 11) | (bdn_info.coef & 0x7FF);
+ REG_WR(ISP_BDN_1DLNC_P, val);
+
+ val = ((bdn_info.start_pos_x & 0x1FFF) << 12) | (bdn_info.start_pos_y & 0xFFF);
+ REG_WR(ISP_BDN_1DLNC_POS, val);
+
+ REG_WR(ISP_BDN_1DLNC_OFFSET, bdn_info.offset & 0x3FFFFFF);
+
+ REG_MWR(ISP_BDN_PARAM, BIT_0, bdn_info.bypass);
+
+ return ret;
+
+}
+
+static int32_t isp_k_bdn_1d_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size size = {0, 0};
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
+ if (0 != ret) {
+ printk("isp_k_bdn_1d_slice_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.width & 0x1FFF) << 12) | (size.height & 0xFFF);
+ REG_WR(ISP_BDN_1DLNC_SIZE, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_bdn(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_bdn: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_bdn: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_BDN_BLOCK:
+ ret = isp_k_bdn_block(param);
+ break;
+ case ISP_PRO_BDN_SLICE_SIZE:
+ ret = isp_k_bdn_1d_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_bdn: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_binning4awb.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_binning4awb.c
new file mode 100644
index 00000000..86778075
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_binning4awb.c
@@ -0,0 +1,231 @@
+/*
+ * 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 <asm/cacheflush.h>
+#include "isp_reg.h"
+#include "isp_drv.h"
+
+static int32_t isp_k_binging_param_update(struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ /*config buf_id 0 as default*/
+ isp_private->b4awb_buf[0].buf_flag = 1;
+ REG_WR(ISP_BINNING_MEM_ADDR, isp_private->b4awb_buf[0].buf_phys_addr);
+
+ return ret;
+}
+
+static int32_t isp_k_binning_block(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_binning4awb_info_v1 binning_info;
+
+ ret = copy_from_user((void *)&binning_info, param->property_param, sizeof(binning_info));
+ if (0 != ret) {
+ printk("isp_k_binning_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (isp_private->b4awb_buf[0].buf_phys_addr == 0 || isp_private->b4awb_buf[1].buf_phys_addr == 0) {
+ REG_MWR(ISP_BINNING_PARAM, BIT_0, 0x1);
+ return ret;
+ }
+
+ isp_k_binging_param_update(isp_private);
+
+ val = (binning_info.burst_mode & 0x3) << 2;
+ REG_MWR(ISP_BINNING_PARAM, 0xC, val);
+
+ val = (binning_info.endian & 0x1) << 1;
+ REG_MWR(ISP_BINNING_PARAM, BIT_1, val);
+
+ val = (binning_info.mem_fifo_clr & 0x1) << 7;
+ REG_MWR(ISP_BINNING_PARAM, 0x80, val);
+
+ val = ((binning_info.hx & 0x7) << 4) | ((binning_info.vx & 0x7) << 8);
+ REG_MWR(ISP_BINNING_PARAM, 0x770, val);
+
+ REG_WR(ISP_BINNING_PITCH, binning_info.pitch);
+
+ REG_MWR(ISP_BINNING_PARAM, BIT_0, binning_info.bypass);
+
+ return ret;
+
+}
+
+static int32_t isp_k_binging_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(uint32_t));
+ if (0 != ret) {
+ printk("isp_k_binning_scaling_ratio: copy_from_user error, ret = 0x%x\n",(uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_BINNING_PARAM, BIT_0, bypass);
+
+ return ret;
+}
+
+static int32_t isp_k_binning_scaling_ratio(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_scaling_ratio scaling_ratio;
+ ret = copy_from_user((void *)&scaling_ratio, param->property_param, sizeof(struct isp_scaling_ratio));
+ if (0 != ret) {
+ printk("isp_k_binning_scaling_ratio: copy_from_user error, ret = 0x%x\n",(uint32_t)ret);
+ return -1;
+ }
+
+ val = ((scaling_ratio.vertical & 0x7)<< 8)| ((scaling_ratio.horizontal & 0x7) << 4);
+ REG_MWR(ISP_BINNING_PARAM, 0x770, val);
+
+ return ret;
+}
+
+static int32_t isp_k_binning_get_scaling_ratio(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_scaling_ratio scaling_ratio;
+
+ val = REG_RD(ISP_BINNING_PARAM);
+
+ scaling_ratio.vertical= (val >> 8) & 0x7;
+ scaling_ratio.horizontal = (val >> 4) & 0x7;
+
+ ret = copy_to_user(param->property_param, (void *)&scaling_ratio, sizeof(struct isp_scaling_ratio));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_binning_get_scaling_ratio: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_binging_mem_addr(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t addr = 0;
+
+ ret = copy_from_user((void *)&addr, param->property_param, sizeof(uint32_t));
+ if (0 != ret) {
+ printk("isp_k_binning_scaling_ratio: copy_from_user error, ret = 0x%x\n",(uint32_t)ret);
+ return -1;
+ }
+
+ REG_WR(ISP_BINNING_MEM_ADDR, addr);
+
+ return ret;
+}
+
+static int32_t isp_k_binning_statistics_buf(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t buf_id = 0;
+
+ if (isp_private->b4awb_buf[0].buf_flag == 0) {
+ buf_id = isp_private->b4awb_buf[0].buf_id;
+ } else if (isp_private->b4awb_buf[1].buf_flag == 0) {
+ buf_id = isp_private->b4awb_buf[0].buf_id;
+ }
+
+ ret = copy_to_user(param->property_param, (void*)&buf_id, sizeof(uint32_t));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_binning_statistics_buf: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_binning_buffaddr(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ int32_t i = 0;
+ unsigned long phys_addr[2];
+ struct isp_b4awb_phys phy_addr;
+
+ ret = copy_from_user((void *)&phy_addr, param->property_param, sizeof(struct isp_b4awb_phys));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_binning_buffaddr: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ phys_addr[0] = phy_addr.phys0;
+ phys_addr[1] = phy_addr.phys1;
+
+ for (i = 0; i < ISP_BING4AWB_NUM; i++) {
+ isp_private->b4awb_buf[i].buf_id = i;
+ isp_private->b4awb_buf[i].buf_flag = 0;
+ isp_private->b4awb_buf[i].buf_phys_addr = phys_addr[i];
+ }
+
+ printk("phys_addr 0x%lx, 0x%lx\n",phys_addr[0], phys_addr[1]);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_binning(struct isp_io_param *param, struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_binning: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_binning: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_BINNING4AWB_BLOCK:
+ ret = isp_k_binning_block(param, isp_private);
+ break;
+ case ISP_PRO_BINNING4AWB_BYPASS:
+ ret = isp_k_binging_bypass(param);
+ break;
+ case ISP_PRO_BINNING4AWB_SCALING_RATIO:
+ ret = isp_k_binning_scaling_ratio(param);
+ break;
+ case ISP_PRO_BINNING4AWB_GET_SCALING_RATIO:
+ ret = isp_k_binning_get_scaling_ratio(param);
+ break;
+ case ISP_PRO_BINNING4AWB_MEM_ADDR:
+ ret = isp_k_binging_mem_addr(param);
+ break;
+ case ISP_PRO_BINNING4AWB_STATISTICS_BUF:
+ ret = isp_k_binning_statistics_buf(param, isp_private);
+ break;
+ case ISP_PRO_BINNING4AWB_TRANSADDR:
+ ret = isp_k_binning_buffaddr(param, isp_private);
+ break;
+ default:
+ printk("isp_k_cfg_binning: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_blc.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_blc.c
new file mode 100644
index 00000000..af18c2a7
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_blc.c
@@ -0,0 +1,66 @@
+/*
+ * 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"
+
+static int32_t isp_k_blc_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_blc_info blc_info;
+
+ ret = copy_from_user((void *)&blc_info, param->property_param, sizeof(blc_info));
+ if (0 != ret) {
+ printk("isp_k_blc_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((blc_info.b & 0x3FF) << 10) | (blc_info.r & 0x3FF);
+ REG_WR(ISP_BLC_B_PARAM_R_B, val);
+ val = ((blc_info.gb & 0x3FF) << 10) | (blc_info.gr & 0x3FF);
+ REG_WR(ISP_BLC_B_PARAM_G, val);
+
+ REG_MWR(ISP_BLC_PARAM, BIT_0, blc_info.bypass);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_blc(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_blc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_blc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_BLC_BLOCK:
+ ret = isp_k_blc_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_blc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_bpc.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_bpc.c
new file mode 100644
index 00000000..29248946
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_bpc.c
@@ -0,0 +1,101 @@
+/*
+ * 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"
+
+static int32_t isp_k_bpc_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ struct isp_dev_bpc_info_v1 bpc_info;
+
+ memset(&bpc_info, 0x00, sizeof(bpc_info));
+
+ ret = copy_from_user((void *)&bpc_info, param->property_param, sizeof(bpc_info));
+ if (0 != ret) {
+ printk("isp_k_bpc_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_BPC_PARAM, BIT_0, bpc_info.bypass);
+
+ REG_MWR(ISP_BPC_PARAM, BIT_1, bpc_info.pvd_bypass << 1);
+
+ REG_MWR(ISP_BPC_PARAM, BIT_4 | BIT_5, bpc_info.bpc_mode << 4);
+
+ REG_MWR(ISP_BPC_PARAM, BIT_10 | BIT_9 | BIT_8, bpc_info.mask_mode << 8);
+
+ val = ((bpc_info.kmax & 0x7) << 20) | ((bpc_info.kmin & 0x7) << 16);
+ REG_MWR(ISP_BPC_PARAM, 0x770000, val);
+
+ REG_MWR(ISP_BPC_NEW_OLD_SEL, BIT_0, bpc_info.new_old_sel);
+
+ REG_MWR(ISP_BPC_NEW_OLD_SEL, BIT_1, bpc_info.map_done_sel << 1);
+
+ val = ((bpc_info.safe_factor & 0x1F) << 4) | (bpc_info.flat_factor & 0x7);
+ REG_WR(ISP_BPC_FACTOR, val);
+
+ val = ((bpc_info.dead_coeff & 0x7) << 4) | (bpc_info.spike_coeff & 0x7);
+ REG_WR(ISP_BPC_COEFF, val);
+
+ for (i = 0; i < 8; i++) {
+ val = ((bpc_info.lut_level[i] & 0x3FF) << 20) | ((bpc_info.slope_k[i] & 0x3FF) << 10) | (bpc_info.intercept_b[i] & 0x3FF);
+ REG_WR(ISP_BPC_LUTWORD0 + i * 4, val);
+ }
+
+ REG_MWR(ISP_BPC_CFG, BIT_10 | BIT_9 | BIT_8, bpc_info.delta << 8);
+
+ REG_MWR(ISP_BPC_CFG, BIT_7, bpc_info.bpc_map_fifo_clr << 7);
+
+ REG_MWR(ISP_BPC_CFG, BIT_6 | BIT_5 | BIT_4, bpc_info.ktimes << 4);
+
+ REG_MWR(ISP_BPC_CFG, 0x7, bpc_info.cntr_threshold);
+
+ REG_MWR(ISP_BPC_CFG, BIT_3, bpc_info.bad_map_hw_fifo_clr_en << 3);
+
+ REG_WR(ISP_BPC_MAP_ADDR, bpc_info.bpc_map_addr_new);
+
+ REG_MWR(ISP_BPC_CFG, 0xFFFF0000, bpc_info.bad_pixel_num << 16);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_bpc(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_bpc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_bpc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_BPC_BLOCK:
+ ret = isp_k_bpc_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_bpc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_brightness.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_brightness.c
new file mode 100644
index 00000000..4c649621
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_brightness.c
@@ -0,0 +1,67 @@
+/*
+ * 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"
+
+static int32_t isp_k_brightness_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_brightness_info brightness_info;
+
+ memset(&brightness_info, 0x00, sizeof(brightness_info));
+
+ ret = copy_from_user((void *)&brightness_info, param->property_param, sizeof(brightness_info));
+ if (0 != ret) {
+ printk("isp_k_brightness_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_BRIGHT_PARAM, 0x1FE, ((brightness_info.factor & 0xFF) << 1));
+
+ if (brightness_info.bypass) {
+ REG_OWR(ISP_BRIGHT_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_BRIGHT_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_brightness(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_brightness: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_brightness: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_BRIGHT_BLOCK:
+ ret = isp_k_brightness_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_brightness: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_capability.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_capability.c
new file mode 100644
index 00000000..d5ce492d
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_capability.c
@@ -0,0 +1,195 @@
+/*
+ * 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"
+
+#define ISP_MAX_WIDTH 3280
+#define ISP_MAX_HEIGHT 2464
+#define ISP_MAX_SLICE_WIDTH 3280
+#define ISP_MAX_SLICE_HEIGHT 2464
+#define ISP_AWB_WIN_UNIT 32
+#define ISP_AWB_DEFAULT_GAIN 0x400
+#define ISP_AF_MAX_WIN_NUM 9
+
+static int32_t isp_k_capability_chip_id(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ uint32_t chip_id = 0;
+
+ chip_id = ISP_CHIP_ID_PIKE;
+
+ ret = copy_to_user(param->property_param, (void*)&chip_id, sizeof(chip_id));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_capability_chip_id: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_capability_single_size(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size size = {0, 0};
+
+ size.width = ISP_MAX_WIDTH;
+ size.height = ISP_MAX_HEIGHT;
+
+ ret = copy_to_user(param->property_param, (void*)&size, sizeof(size));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_capability_single_size: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_capability_continue_size(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size size = {0, 0};
+
+ size.width = ISP_MAX_SLICE_WIDTH;
+ size.height = ISP_MAX_SLICE_HEIGHT;
+
+ ret = copy_to_user(param->property_param, (void*)&size, sizeof(size));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_capability_continue_size: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_capability_awb_win(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size size = {0, 0};
+
+ size.width = ISP_AWB_WIN_UNIT;
+ size.height = ISP_AWB_WIN_UNIT;
+
+ ret = copy_to_user(param->property_param, (void*)&size, sizeof(size));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_capability_awb_win: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_capability_awb_default_gain(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ uint32_t gain = 0;
+
+ gain = ISP_AWB_DEFAULT_GAIN;
+
+ ret = copy_to_user(param->property_param, (void*)&gain, sizeof(gain));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_capability_awb_default_gain: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_capability_af_max_win_num(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ uint32_t win_num = 0;
+
+ win_num = ISP_AF_MAX_WIN_NUM;
+
+ ret = copy_to_user(param->property_param, (void*)&win_num, sizeof(win_num));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_capability_af_max_win_num: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_capability_time(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ struct isp_time time;
+ struct timespec ts;
+
+ ktime_get_ts(&ts);
+ time.sec = ts.tv_sec;
+ time.usec = ts.tv_nsec / NSEC_PER_USEC;
+
+ ret = copy_to_user(param->property_param, (void*)&time, sizeof(time));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_capability_time: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+int32_t isp_capability(void *param)
+{
+ int32_t ret = 0;
+ struct isp_capability cap_param = {0, 0, NULL};
+
+ if (!param) {
+ printk("isp_capability: param is null error.\n");
+ return -1;
+ }
+
+ ret = copy_from_user((void *)&cap_param, (void*)param, sizeof(cap_param));
+ if ( 0 != ret) {
+ printk("isp_capability: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (NULL == cap_param.property_param) {
+ printk("isp_capability: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(cap_param.index) {
+ case ISP_CAPABILITY_CHIP_ID:
+ ret = isp_k_capability_chip_id(&cap_param);
+ break;
+ case ISP_CAPABILITY_SINGLE_SIZE:
+ ret = isp_k_capability_single_size(&cap_param);
+ break;
+ case ISP_CAPABILITY_CONTINE_SIZE:
+ ret = isp_k_capability_continue_size(&cap_param);
+ break;
+ case ISP_CAPABILITY_AWB_WIN:
+ ret = isp_k_capability_awb_win(&cap_param);
+ break;
+ case ISP_CAPABILITY_AWB_DEFAULT_GAIN:
+ ret = isp_k_capability_awb_default_gain(&cap_param);
+ break;
+ case ISP_CAPABILITY_AF_MAX_WIN_NUM:
+ ret = isp_k_capability_af_max_win_num(&cap_param);
+ break;
+ case ISP_CAPABILITY_TIME:
+ ret = isp_k_capability_time(&cap_param);
+ break;
+ default:
+ printk("isp_capability: fail cmd id:%d, not supported.\n", cap_param.index);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cce.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cce.c
new file mode 100644
index 00000000..06a84ab9
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cce.c
@@ -0,0 +1,147 @@
+/*
+ * 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"
+
+static int32_t isp_k_cce_block_uv(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_cce_uvd_info cce_uvd_info;
+
+ memset(&cce_uvd_info, 0x00, sizeof(cce_uvd_info));
+
+ ret = copy_from_user((void *)&cce_uvd_info, param->property_param, sizeof(cce_uvd_info));
+ if (0 != ret) {
+ printk("isp_k_cce_block_uv: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (cce_uvd_info.lum_th_h_len & 0xF)
+ | ((cce_uvd_info.lum_th_h & 0xFF) << 8)
+ | ((cce_uvd_info.lum_th_l_len & 0xF) << 16)
+ | ((cce_uvd_info.lum_th_l & 0xFF) << 24);
+ REG_WR(ISP_CCE_UVD_PARAM0, val);
+
+ val = (cce_uvd_info.chroma_min_h & 0xFF)
+ | ((cce_uvd_info.chroma_min_l & 0xFF) << 8)
+ | ((cce_uvd_info.chroma_max_h & 0xFF) << 16)
+ | ((cce_uvd_info.chroma_max_l & 0xFF) << 24);
+ REG_WR(ISP_CCE_UVD_PARAM1, val);
+
+ val = (cce_uvd_info.u_th1_h & 0xFF)
+ | ((cce_uvd_info.u_th1_l & 0xFF) << 8)
+ | ((cce_uvd_info.u_th0_h & 0xFF) << 16)
+ | ((cce_uvd_info.u_th0_l & 0xFF) << 24);
+ REG_WR(ISP_CCE_UVD_PARAM2, val);
+
+ val = (cce_uvd_info.v_th1_h & 0xFF)
+ | ((cce_uvd_info.v_th1_l & 0xFF) << 8)
+ | ((cce_uvd_info.v_th0_h & 0xFF) << 16)
+ | ((cce_uvd_info.v_th0_l & 0xFF) << 24);
+ REG_WR(ISP_CCE_UVD_PARAM3, val);
+
+ val = (cce_uvd_info.ratio[7] & 0xF)
+ | ((cce_uvd_info.ratio[6] & 0xF) << 4)
+ | ((cce_uvd_info.ratio[5] & 0xF) << 8)
+ | ((cce_uvd_info.ratio[4] & 0xF) << 12)
+ | ((cce_uvd_info.ratio[3] & 0xF) << 16)
+ | ((cce_uvd_info.ratio[2] & 0xF) << 20)
+ | ((cce_uvd_info.ratio[1] & 0xF) << 24)
+ | ((cce_uvd_info.ratio[0] & 0xF) << 28);
+ REG_WR(ISP_CCE_UVD_PARAM4, val);
+
+ val = (cce_uvd_info.base & 0xF)
+ | ((cce_uvd_info.ratio[8] & 0xF) << 8);
+ REG_WR(ISP_CCE_UVD_PARAM5, val);
+
+ REG_MWR(ISP_CCE_PARAM, BIT_0, cce_uvd_info.uvdiv_bypass);
+
+ return ret;
+}
+
+static int32_t isp_k_cce_block_matrix(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t val1 = 0;
+ struct isp_dev_cce_info_v1 cce_info;
+
+ memset(&cce_info, 0x00, sizeof(cce_info));
+
+ ret = copy_from_user((void *)&cce_info, param->property_param, sizeof(cce_info));
+ if (0 != ret) {
+ printk("isp_k_cce_block_matrix: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((cce_info.matrix[1] & 0x7FF) << 11) | (cce_info.matrix[0] & 0x7FF);
+ val1 = ((cce_info.matrix[3] & 0x7FF) << 11) | (cce_info.matrix[2] & 0x7FF);
+ if ((0 == val)
+ || (0 == val1)) {
+ printk("isp_k_cce_block_matrix: copy error, 0x%x, 0x%x, 0x%x, 0x%x\n", cce_info.matrix[0], cce_info.matrix[1], cce_info.matrix[2], cce_info.matrix[3]);
+ return ret;
+ }
+
+ REG_MWR(ISP_CCE_PARAM, BIT_1, cce_info.mode << 1);
+
+ val = ((cce_info.matrix[1] & 0x7FF) << 11) | (cce_info.matrix[0] & 0x7FF);
+ REG_WR(ISP_CCE_MATRIX0, val);
+ val = ((cce_info.matrix[3] & 0x7FF) << 11) | (cce_info.matrix[2] & 0x7FF);
+ REG_WR(ISP_CCE_MATRIX1, val);
+ val = ((cce_info.matrix[5] & 0x7FF) << 11) | (cce_info.matrix[4] & 0x7FF);
+ REG_WR(ISP_CCE_MATRIX2, val);
+ val = ((cce_info.matrix[7] & 0x7FF) << 11) | (cce_info.matrix[6] & 0x7FF);
+ REG_WR(ISP_CCE_MATRIX3, val);
+ val = cce_info.matrix[8] & 0x7FF;
+ REG_WR(ISP_CCE_MATRIX4, val);
+
+ val = (cce_info.y_offset & 0x1FF) | ((cce_info.u_offset & 0x1FF) << 9)
+ | ((cce_info.v_offset & 0x1FF) << 18);
+ REG_WR(ISP_CCE_SHIFT, (val & 0x7FFFFFF));
+
+ return ret;
+}
+
+int32_t isp_k_cfg_cce(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_cce: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_cce: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CCE_BLOCK_MATRIX:
+ ret = isp_k_cce_block_matrix(param);
+ break;
+ case ISP_PRO_CCE_BLOCK_UV:
+ ret = isp_k_cce_block_uv(param);
+ break;
+ default:
+ printk("isp_k_cfg_cce: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cdn.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cdn.c
new file mode 100644
index 00000000..e8b8e716
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cdn.c
@@ -0,0 +1,109 @@
+/*
+ * 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"
+
+static int32_t isp_k_yuv_cdn_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_yuv_cdn_info cdn_info;
+ uint32_t val = 0;
+ uint32_t i = 0;
+
+ memset(&cdn_info, 0x00, sizeof(cdn_info));
+
+ ret = copy_from_user((void *)&cdn_info, param->property_param, sizeof(cdn_info));
+ if (0 != ret) {
+ printk("isp_k_yuv_cdn_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (cdn_info.median_writeback_en) {
+ REG_OWR(ISP_CDN_PARAM, BIT_2);
+ } else {
+ REG_MWR(ISP_CDN_PARAM, BIT_2, 0);
+ }
+
+ REG_MWR(ISP_CDN_PARAM, 0x38, cdn_info.median_mode << 3);
+
+ REG_MWR(ISP_CDN_PARAM, BIT_7 | BIT_6, cdn_info.gaussian_mode << 6);
+
+ REG_MWR(ISP_CDN_PARAM, 0x3FFF00, cdn_info.median_thr << 8);
+
+ val = (cdn_info.median_thru0 & 0x7F) | ((cdn_info.median_thru1 & 0xFF) << 8)
+ | ((cdn_info.median_thrv0 & 0x7F) << 16) | ((cdn_info.median_thrv1 & 0xFF) << 24);
+ REG_WR(ISP_CDN_THRUV, val);
+
+ for (i = 0; i < 7; i++) {
+ val = (cdn_info.rangewu[i*4] & 0x3F) | ((cdn_info.rangewu[i*4+1] & 0x3F) << 8)
+ | ((cdn_info.rangewu[i*4+2] & 0x3F) << 16) | ((cdn_info.rangewu[i*4+3] & 0x3F) << 24);
+ REG_WR(ISP_CDN_U_RANWEI_0 + i * 4, val);
+ }
+
+ val = (cdn_info.rangewu[28] & 0x3F) | ((cdn_info.rangewu[29] & 0x3F) << 8)
+ | ((cdn_info.rangewu[30] & 0x3F) << 16);
+ REG_WR(ISP_CDN_U_RANWEI_7, val);
+
+ for (i = 0; i < 7; i++) {
+ val = (cdn_info.rangewv[i*4] & 0x3F) | ((cdn_info.rangewv[i*4+1] & 0x3F) << 8)
+ | ((cdn_info.rangewv[i*4+2] & 0x3F) << 16) | ((cdn_info.rangewv[i*4+3] & 0x3F) << 24);
+ REG_WR(ISP_CDN_V_RANWEI_0 + i * 4, val);
+ }
+
+ val = (cdn_info.rangewv[28] & 0x3F) | ((cdn_info.rangewv[29] & 0x3F) << 8)
+ | ((cdn_info.rangewv[30] & 0x3F) << 16);
+ REG_WR(ISP_CDN_V_RANWEI_7, val);
+
+ if (cdn_info.filter_bypass) {
+ REG_OWR(ISP_CDN_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_CDN_PARAM, BIT_1, 0);
+ }
+
+ if (cdn_info.bypass) {
+ REG_OWR(ISP_CDN_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_CDN_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_yuv_cdn(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_yuv_cdn: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_yuv_cdn: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_YUV_CDN_BLOCK:
+ ret = isp_k_yuv_cdn_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_yuv_cdn: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cfa.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cfa.c
new file mode 100644
index 00000000..ceeed46a
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cfa.c
@@ -0,0 +1,90 @@
+/*
+ * 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"
+
+static int32_t isp_k_cfa_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_cfa_info_v1 cfa_info;
+
+ memset(&cfa_info, 0x00, sizeof(cfa_info));
+
+ ret = copy_from_user((void *)&cfa_info, param->property_param, sizeof(cfa_info));
+ if (0 != ret) {
+ printk("isp_k_cfa_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_CFAE_EE_CFG0, BIT_0, cfa_info.bypass);
+
+ REG_MWR(ISP_CFAE_EE_CFG0, 0xF<<28, cfa_info.grid_gain << 28);
+
+ REG_MWR(ISP_CFAE_EE_CFG0, 0x3<<24, cfa_info.avg_mode << 24);
+
+ REG_MWR(ISP_CFAE_EE_CFG0, 0xFFF<<12, cfa_info.gbuf_addr_max << 12);
+
+ REG_MWR(ISP_CFAE_EE_CFG0, BIT_1, cfa_info.ee_bypass << 1);
+
+ REG_MWR(ISP_CFAE_EE_CFG0, 0x3F<<4, cfa_info.doee_base << 4);
+
+ REG_MWR(ISP_CFAE_EE_CFG1, 0xF<<16, cfa_info.inter_chl_gain << 16);
+
+ val = (cfa_info.cfa_uni_dir_intplt_tr & 0xFFFF) | ((cfa_info.cfai_ee_uni_dir_tr & 0xFFFF) << 16);
+ REG_WR(ISP_CFAE_THRD_0,val);
+ val = (cfa_info.cfai_ee_edge_tr & 0xFFF) | ((cfa_info.cfai_ee_diagonal_tr & 0xFFF) << 16);
+ REG_WR(ISP_CFAE_THRD_1,val);
+ val =(cfa_info.cfai_ee_grid_tr & 0xFFF) | ((cfa_info.cfai_doee_clip_tr & 0x3F) << 12)
+ | ((cfa_info.cfai_ee_saturation_level & 0x3FF) << 22);
+ REG_WR(ISP_CFAE_THRD_2,val);
+ val = (cfa_info.plt_diff_tr & 0xFFFF) | ((cfa_info.grid_min_tr & 0xFFFF) << 16);
+ REG_WR(ISP_CFAE_THRD_3,val);
+ val = (cfa_info.strength_tr_neg & 0xFFFF) | ((cfa_info.strength_tr_pos & 0xFFFF) << 16);
+ REG_WR(ISP_CFAE_THRD_4,val);
+ REG_MWR(ISP_CFAE_EE_CFG1, 0x3F, cfa_info.ee_strength_neg);
+ REG_MWR(ISP_CFAE_EE_CFG1, 0x3F << 8, cfa_info.ee_strength_pos << 8);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_cfa(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_cfa: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_cfa: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CFA_BLOCK:
+ ret = isp_k_cfa_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_cfa: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cmc10.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cmc10.c
new file mode 100644
index 00000000..8c127c9a
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cmc10.c
@@ -0,0 +1,93 @@
+/*
+ * 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"
+
+static int32_t isp_k_cmc10_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_cmc10_info cmc10_info;
+
+ memset(&cmc10_info, 0x00, sizeof(cmc10_info));
+
+ ret = copy_from_user((void *)&cmc10_info, param->property_param, sizeof(cmc10_info));
+ if (0 != ret) {
+ printk("isp_k_cmc10_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_CMC10_PARAM, BIT_0, cmc10_info.bypass);
+
+ REG_MWR(ISP_CMC10_PARAM, BIT_3, cmc10_info.buf_sel << 3);
+
+ REG_MWR(ISP_CMC10_PARAM, 0x3FF << 4, cmc10_info.alpha << 4);
+
+ REG_MWR(ISP_CMC10_PARAM, BIT_1, cmc10_info.alpha_bypass << 1);
+
+ val = ((cmc10_info.matrix.val[1] & 0x3FFF) << 14) | (cmc10_info.matrix.val[0] & 0x3FFF);
+ REG_WR(ISP_CMC10_MATRIX0, val);
+ val = ((cmc10_info.matrix.val[3] & 0x3FFF) << 14) | (cmc10_info.matrix.val[2] & 0x3FFF);
+ REG_WR((ISP_CMC10_MATRIX0 + 4), val);
+ val = ((cmc10_info.matrix.val[5] & 0x3FFF) << 14) | (cmc10_info.matrix.val[4] & 0x3FFF);
+ REG_WR((ISP_CMC10_MATRIX0 + 8), val);
+ val = ((cmc10_info.matrix.val[7] & 0x3FFF) << 14) | (cmc10_info.matrix.val[6] & 0x3FFF);
+ REG_WR((ISP_CMC10_MATRIX0 + 12), val);
+ val = cmc10_info.matrix.val[8] & 0x3FFF;
+ REG_WR((ISP_CMC10_MATRIX0 + 16), val);
+
+ val = ((cmc10_info.matrix_buf.val[1] & 0x3FFF) << 14) | (cmc10_info.matrix_buf.val[0] & 0x3FFF);
+ REG_WR(ISP_CMC10_MATRIX0_BUF, val);
+ val = ((cmc10_info.matrix_buf.val[3] & 0x3FFF) << 14) | (cmc10_info.matrix_buf.val[2] & 0x3FFF);
+ REG_WR((ISP_CMC10_MATRIX0_BUF + 4), val);
+ val = ((cmc10_info.matrix_buf.val[5] & 0x3FFF) << 14) | (cmc10_info.matrix_buf.val[4] & 0x3FFF);
+ REG_WR((ISP_CMC10_MATRIX0_BUF + 8), val);
+ val = ((cmc10_info.matrix_buf.val[7] & 0x3FFF) << 14) | (cmc10_info.matrix_buf.val[6] & 0x3FFF);
+ REG_WR((ISP_CMC10_MATRIX0_BUF + 12), val);
+ val = cmc10_info.matrix_buf.val[8] & 0x3FFF;
+ REG_WR((ISP_CMC10_MATRIX0_BUF + 16), val);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_cmc10(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_cmc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_cmc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CMC_BLOCK:
+ ret = isp_k_cmc10_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_cmc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cmc8.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cmc8.c
new file mode 100644
index 00000000..35121772
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_cmc8.c
@@ -0,0 +1,92 @@
+/*
+ * 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"
+
+static int32_t isp_k_cmc8_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_cmc8_info_v1 cmc8_info;
+
+ memset(&cmc8_info, 0x00, sizeof(cmc8_info));
+
+ ret = copy_from_user((void *)&cmc8_info, param->property_param, sizeof(cmc8_info));
+ if (0 != ret) {
+ printk("isp_k_cmc8_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_CMC8_PARAM, BIT_0, cmc8_info.bypass);
+
+ REG_MWR(ISP_CMC8_PARAM, BIT_3, cmc8_info.buf_sel << 3);
+
+ REG_MWR(ISP_CMC8_PARAM, 0x3FF << 4, cmc8_info.alpha << 4);
+
+ REG_MWR(ISP_CMC8_PARAM, BIT_1, cmc8_info.alpha_bypass << 1);
+
+ val = ((cmc8_info.matrix.val[1] & 0x3FFF) << 14) | (cmc8_info.matrix.val[0] & 0x3FFF);
+ REG_WR(ISP_CMC8_MATRIX0, val);
+ val = ((cmc8_info.matrix.val[3] & 0x3FFF) << 14) | (cmc8_info.matrix.val[2] & 0x3FFF);
+ REG_WR((ISP_CMC8_MATRIX0 + 4), val);
+ val = ((cmc8_info.matrix.val[5] & 0x3FFF) << 14) | (cmc8_info.matrix.val[4] & 0x3FFF);
+ REG_WR((ISP_CMC8_MATRIX0 + 8), val);
+ val = ((cmc8_info.matrix.val[7] & 0x3FFF) << 14) | (cmc8_info.matrix.val[6] & 0x3FFF);
+ REG_WR((ISP_CMC8_MATRIX0 + 12), val);
+ val = cmc8_info.matrix.val[8] & 0x3FFF;
+ REG_WR((ISP_CMC8_MATRIX0 + 16), val);
+
+ val = ((cmc8_info.matrix_buf.val[1] & 0x3FFF) << 14) | (cmc8_info.matrix_buf.val[0] & 0x3FFF);
+ REG_WR(ISP_CMC8_MATRIX0_BUF, val);
+ val = ((cmc8_info.matrix_buf.val[3] & 0x3FFF) << 14) | (cmc8_info.matrix_buf.val[2] & 0x3FFF);
+ REG_WR((ISP_CMC8_MATRIX0_BUF + 4), val);
+ val = ((cmc8_info.matrix_buf.val[5] & 0x3FFF) << 14) | (cmc8_info.matrix_buf.val[4] & 0x3FFF);
+ REG_WR((ISP_CMC8_MATRIX0_BUF + 8), val);
+ val = ((cmc8_info.matrix_buf.val[7] & 0x3FFF) << 14) | (cmc8_info.matrix_buf.val[6] & 0x3FFF);
+ REG_WR((ISP_CMC8_MATRIX0_BUF + 12), val);
+ val = cmc8_info.matrix_buf.val[8] & 0x3FFF;
+ REG_WR((ISP_CMC8_MATRIX0_BUF + 16), val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_cmc8(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_cmc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_cmc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CMC8_BLOCK:
+ ret = isp_k_cmc8_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_cmc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_common.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_common.c
new file mode 100644
index 00000000..336f173a
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_common.c
@@ -0,0 +1,411 @@
+/*
+ * 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"
+
+static int32_t isp_k_common_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_common_info_v2 common_info;
+
+ memset(&common_info, 0x00, sizeof(common_info));
+
+ ret = copy_from_user((void *)&common_info, param->property_param, sizeof(common_info));
+ if (0 != ret) {
+ printk("isp_k_common_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3, common_info.fetch_sel_0);
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 4, common_info.sizer_sel_0 << 4);
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 16, common_info.store_sel_0 << 16);
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 2, common_info.fetch_sel_1);
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 6, common_info.sizer_sel_1);
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 18, common_info.store_sel_1);
+ //REG_MWR(ISP_COMMON_CTRL_CH1, 3, common_info.fetch_sel_1);
+ //REG_MWR(ISP_COMMON_CTRL_CH1, 3 << 4, common_info.sizer_sel_1 << 4);
+ //REG_MWR(ISP_COMMON_CTRL_CH1, 3 << 16, common_info.store_sel_1 << 16);
+ REG_MWR(ISP_COMMON_SPACE_SEL, 3 , common_info.fetch_color_format) ;
+ REG_MWR(ISP_COMMON_SPACE_SEL, 3 << 2, common_info.store_color_format << 2) ;
+ //REG_MWR(ISP_COMMON_CTRL_AWBM, BIT_0 , common_info.awbm_pos) ;
+ //REG_MWR(ISP_COMMON_3A_CTRL0, 3, common_info.y_afm_pos_0);
+ //REG_MWR(ISP_COMMON_3A_CTRL0, 3 << 4, common_info.y_aem_pos_0 << 4);
+ //REG_MWR(ISP_COMMON_3A_CTRL1, 3, common_info.y_afm_pos_1);
+ //REG_MWR(ISP_COMMON_3A_CTRL1, 3 << 4, common_info.y_aem_pos_1 << 4);
+
+ REG_MWR(ISP_COMMON_LBUF_OFFSET, 0xFFFF, 0x460);
+ //REG_WR(ISP_COMMON_LBUF_OFFSET0, ((common_info.lbuf_off.cfae_lbuf_offset & 0xFFFF) << 16 ) | (common_info.lbuf_off.comm_lbuf_offset & 0xFFFF));
+ //REG_WR(ISP_COMMON_LBUF_OFFSET1, ((common_info.lbuf_off.ydly_lbuf_offset& 0xFFFF) << 16 ) | (common_info.lbuf_off.awbm_lbuf_offset & 0xFFFF));
+
+ return ret;
+}
+
+static int32_t isp_k_common_version(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t version = 0;
+
+ version = REG_RD(ISP_COMMON_VERSION);
+
+ ret = copy_to_user(param->property_param, (void*)&version, sizeof(version));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_common_version: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_common_status0(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t status = 0;
+
+ status = REG_RD(ISP_COMMON_STATUS0);
+
+ ret = copy_to_user(param->property_param, (void*)&status, sizeof(status));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_common_status0: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_common_status1(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t status = 0;
+
+ status = REG_RD(ISP_COMMON_STATUS1);
+
+ ret = copy_to_user(param->property_param, (void*)&status, sizeof(status));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_common_status1: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel0_fetch_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t fetch_sel = 0;
+
+ ret = copy_from_user((void *)&fetch_sel, param->property_param, sizeof(fetch_sel));
+ if (0 != ret) {
+ printk("isp_k_channel0_fetch_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3, fetch_sel);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel0_sizer_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t sizer_sel = 0;
+
+ ret = copy_from_user((void *)&sizer_sel, param->property_param, sizeof(sizer_sel));
+ if (0 != ret) {
+ printk("isp_k_channel0_sizer_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 4, sizer_sel << 4);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel0_store_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t store_sel = 0;
+
+ ret = copy_from_user((void *)&store_sel, param->property_param, sizeof(store_sel));
+ if (0 != ret) {
+ printk("isp_k_common_channel0_store_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 16, store_sel << 16);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel1_fetch_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t fetch_sel = 0;
+
+ ret = copy_from_user((void *)&fetch_sel, param->property_param, sizeof(fetch_sel));
+ if (0 != ret) {
+ printk("isp_k_channel1_fetch_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 2, fetch_sel << 2);
+
+// REG_MWR(ISP_COMMON_CTRL_CH1, 3, fetch_sel);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel1_sizer_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t sizer_sel = 0;
+
+ ret = copy_from_user((void *)&sizer_sel, param->property_param, sizeof(sizer_sel));
+ if (0 != ret) {
+ printk("isp_k_common_channel1_sizer_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 6, sizer_sel << 6);
+
+ //REG_MWR(ISP_COMMON_CTRL_CH1, 3 << 4, sizer_sel << 4);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel1_store_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t store_sel = 0;
+
+ ret = copy_from_user((void *)&store_sel, param->property_param, sizeof(store_sel));
+ if (0 != ret) {
+ printk("isp_k_common_channel1_store_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 18, store_sel << 18);
+
+// REG_MWR(ISP_COMMON_CTRL_CH1, 3 << 16, store_sel << 16);
+
+ return ret;
+}
+
+static int32_t isp_k_common_fetch_color_space_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t color_space = 0;
+
+ ret = copy_from_user((void *)&color_space, param->property_param, sizeof(color_space));
+ if (0 != ret) {
+ printk("isp_k_common_fetch_color_space_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_SPACE_SEL, 3 , color_space) ;
+
+ return ret;
+}
+
+static int32_t isp_k_common_store_color_space_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t color_space = 0;
+
+ ret = copy_from_user((void *)&color_space, param->property_param, sizeof(color_space));
+ if (0 != ret) {
+ printk("isp_k_common_store_color_space_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_SPACE_SEL, 3 << 2, color_space << 2) ;
+
+ return ret;
+}
+
+static int32_t isp_k_common_awbm_pos_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t awbm_pos = 0;
+
+ ret = copy_from_user((void *)&awbm_pos, param->property_param, sizeof(awbm_pos));
+ if (0 != ret) {
+ printk("isp_k_common_awbm_pos_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ //REG_MWR(ISP_COMMON_CTRL_AWBM, BIT_0 , awbm_pos) ;
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel0_y_afm_pos(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t position = 0;
+
+ ret = copy_from_user((void *)&position, param->property_param, sizeof(position));
+ if (0 != ret) {
+ printk("isp_k_common_channel0_y_afm_pos: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+// REG_MWR(ISP_COMMON_3A_CTRL0, 3, position);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel0_y_aem_pos(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t position = 0;
+
+ ret = copy_from_user((void *)&position, param->property_param, sizeof(position));
+ if (0 != ret) {
+ printk("isp_k_common_channel0_y_aem_pos: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+// REG_MWR(ISP_COMMON_3A_CTRL0, 3 << 4, position << 4);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel1_y_afm_pos(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t position = 0;
+
+ ret = copy_from_user((void *)&position, param->property_param, sizeof(position));
+ if (0 != ret) {
+ printk("isp_k_common_channel1_y_afm_pos: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+// REG_MWR(ISP_COMMON_3A_CTRL1, 3, position);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel1_y_aem_pos(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t position = 0;
+
+ ret = copy_from_user((void *)&position, param->property_param, sizeof(position));
+ if (0 != ret) {
+ printk("isp_k_common_channel1_y_aem_pos: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+// REG_MWR(ISP_COMMON_3A_CTRL1, 3 << 4, position << 4);
+
+ return ret;
+}
+
+static int32_t isp_k_common_lbuf_offset(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t lbuf_off;
+
+ memset(&lbuf_off, 0x00, sizeof(lbuf_off));
+ ret = copy_from_user((void *)&lbuf_off, param->property_param, sizeof(lbuf_off));
+ if (0 != ret) {
+ printk("isp_k_common_lbuf_offset: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+
+ REG_MWR(ISP_COMMON_LBUF_OFFSET, 0xFFFF, lbuf_off);
+
+// REG_WR(ISP_COMMON_LBUF_OFFSET0, ((lbuf_off.cfae_lbuf_offset & 0xFFFF) << 16 ) | (lbuf_off.comm_lbuf_offset & 0xFFFF));
+// REG_WR(ISP_COMMON_LBUF_OFFSET1, ((lbuf_off.ydly_lbuf_offset& 0xFFFF) << 16 ) | (lbuf_off.awbm_lbuf_offset & 0xFFFF));
+
+ return ret;
+}
+
+int32_t isp_k_cfg_common(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_common: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_common: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_COMMON_BLOCK:
+ ret = isp_k_common_block(param);
+ break;
+ case ISP_PRO_COMMON_VERSION:
+ ret = isp_k_common_version(param);
+ break;
+ case ISP_PRO_COMMON_STATUS0:
+ ret = isp_k_common_status0(param);
+ break;
+ case ISP_PRO_COMMON_STATUS1:
+ ret = isp_k_common_status1(param);
+ break;
+ case ISP_PRO_COMMON_CH0_FETCH_SEL:
+ ret = isp_k_common_channel0_fetch_sel(param);
+ break;
+ case ISP_PRO_COMMON_CH0_SIZER_SEL:
+ ret = isp_k_common_channel0_sizer_sel(param);
+ break;
+ case ISP_PRO_COMMON_CH0_STORE_SEL:
+ ret = isp_k_common_channel0_store_sel(param);
+ break;
+ case ISP_PRO_COMMON_CH1_FETCH_SEL:
+ ret = isp_k_common_channel1_fetch_sel(param);
+ break;
+ case ISP_PRO_COMMON_CH1_SIZER_SEL:
+ ret = isp_k_common_channel1_sizer_sel(param);
+ break;
+ case ISP_PRO_COMMON_CH1_STORE_SEL:
+ ret = isp_k_common_channel1_store_sel(param);
+ break;
+ case ISP_PRO_COMMON_FETCH_COLOR_SPACE_SEL:
+ ret = isp_k_common_fetch_color_space_sel(param);
+ break;
+ case ISP_PRO_COMMON_STORE_COLOR_SPACE_SEL:
+ ret = isp_k_common_store_color_space_sel(param);
+ break;
+ case ISP_PRO_COMMON_AWBM_POS_SEL:
+ ret = isp_k_common_awbm_pos_sel(param);
+ break;
+ case ISP_PRO_COMMON_CH0_AEM2_POS:
+ ret = isp_k_common_channel0_y_aem_pos(param);
+ break;
+ case ISP_PRO_COMMON_CH0_Y_AFM_POS:
+ ret = isp_k_common_channel0_y_afm_pos(param);
+ break;
+ case ISP_PRO_COMMON_CH1_AEM2_POS:
+ ret = isp_k_common_channel1_y_aem_pos(param);
+ break;
+ case ISP_PRO_COMMON_CH1_Y_AFM_POS:
+ ret = isp_k_common_channel1_y_afm_pos(param);
+ break;
+ case ISP_PRO_COMMON_LBUF_OFFSET:
+ ret = isp_k_common_lbuf_offset(param);
+ break;
+ default:
+ printk("isp_k_cfg_common: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_contrast.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_contrast.c
new file mode 100644
index 00000000..36f7750d
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_contrast.c
@@ -0,0 +1,67 @@
+/*
+ * 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"
+
+static int32_t isp_k_contrast_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_contrast_info contrast_info;
+
+ memset(&contrast_info, 0x00, sizeof(contrast_info));
+
+ ret = copy_from_user((void *)&contrast_info, param->property_param, sizeof(contrast_info));
+ if (0 != ret) {
+ printk("isp_k_contrast_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_CONTRAST_PARAM, 0x1FE, (contrast_info.factor << 1));
+
+ if (contrast_info.bypass) {
+ REG_OWR(ISP_CONTRAST_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_CONTRAST_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_contrast(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_contrast: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_contrast: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CONTRAST_BLOCK:
+ ret = isp_k_contrast_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_contrast: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_csa.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_csa.c
new file mode 100644
index 00000000..1aa7ef49
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_csa.c
@@ -0,0 +1,68 @@
+/*
+ * 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"
+
+static int32_t isp_k_csa_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_csa_info_v1 csa_info;
+ uint32_t val = 0;
+
+ memset(&csa_info, 0x00, sizeof(csa_info));
+
+ ret = copy_from_user((void *)&csa_info, param->property_param, sizeof(csa_info));
+ if (0 != ret) {
+ printk("isp_k_csa_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((csa_info.factor_v & 0xFF) << 8) | ((csa_info.factor_u & 0xFF) << 16);
+ REG_MWR(ISP_CSA_PARAM, 0xFFFF00, val);
+
+ if (csa_info.bypass) {
+ REG_OWR(ISP_CSA_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_CSA_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_csa(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_csa: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_csa: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CSA_BLOCK:
+ ret = isp_k_csa_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_csa: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_csc.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_csc.c
new file mode 100644
index 00000000..7612b698
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_csc.c
@@ -0,0 +1,114 @@
+/*
+ * 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"
+
+static int32_t isp_k_csc_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_csc_info csc_info;
+
+ memset(&csc_info, 0x00, sizeof(csc_info));
+
+ ret = copy_from_user((void *)&csc_info, param->property_param, sizeof(csc_info));
+ if (0 != ret) {
+ printk("isp_k_csc_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_CSC_CTRL, BIT_0, csc_info.bypass);
+
+ val = (csc_info.red_centre_x & 0x1FFF) | ((csc_info.red_centre_y & 0xFFF) << 16);
+ REG_WR(ISP_CSC_RCC, val);
+
+ val = (csc_info.blue_centre_x & 0x1FFF) | ((csc_info.blue_centre_y & 0xFFF) << 16);
+ REG_WR(ISP_CSC_BCC, val);
+
+ REG_WR(ISP_CSC_REDTHR, csc_info.red_threshold & 0x3FFFFFF);
+
+ REG_WR(ISP_CSC_BLUETHR, (csc_info.blue_threshold & 0x3FFFFFF));
+
+ val = (csc_info.red_p1_param & 0x1FFF) | ((csc_info.red_p2_param & 0x7FF) << 16);
+ REG_WR(ISP_CSC_REDPOLY, val);
+
+ val = (csc_info.blue_p1_param & 0x1FFF) | ((csc_info.blue_p2_param & 0x7FF) << 16);
+ REG_WR(ISP_CSC_BLUEPOLY, val);
+
+ REG_WR(ISP_CSC_MAXGAIN, (csc_info.max_gain_thr & 0x1FFF));
+
+ val = (csc_info.start_pos.x & 0xFFF) | ((csc_info.start_pos.y & 0x1FFF) << 12);
+ REG_WR(ISP_CSC_START_ROW_COL, val );
+
+ val = csc_info.red_x2_init;
+ REG_WR( ISP_CSC_REDX2INIT, (val & 0x3FFFFFF));
+ val = csc_info.red_y2_init;
+ REG_WR( ISP_CSC_REDY2INIT, (val & 0x3FFFFFF));
+
+ val = csc_info.blue_x2_init;
+ REG_WR( ISP_CSC_BLUEX2INIT, (val & 0x3FFFFFF));
+ val = csc_info.blue_y2_init;
+ REG_WR( ISP_CSC_BLUEY2INIT, (val & 0x3FFFFFF));
+
+ return ret;
+
+}
+
+static int32_t isp_k_csc_pic_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size pic_size = {0, 0};
+
+ ret = copy_from_user((void *)&pic_size, param->property_param, sizeof(pic_size));
+ if (0 != ret) {
+ printk("isp_k_csc_pic_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ val = (pic_size.width& 0x1FFF) | ((pic_size.height& 0xFFF) << 16);
+ REG_WR(ISP_CSC_PICSIZE, val );
+
+ return ret;
+}
+
+int32_t isp_k_cfg_csc(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_csc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_csc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CSC_BLOCK:
+ ret = isp_k_csc_block(param);
+ break;
+ case ISP_PRO_CSC_PIC_SIZE:
+ ret = isp_k_csc_pic_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_csc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_css.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_css.c
new file mode 100644
index 00000000..2147bd53
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_css.c
@@ -0,0 +1,112 @@
+/*
+ * 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"
+
+static int32_t isp_k_css_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_css_info_v1 css_info;
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&css_info, param->property_param, sizeof(css_info));
+ if (0 != ret) {
+ printk("isp_k_css_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (css_info.lh_chrom_th & 0x1F) << 24;
+ REG_MWR(ISP_CSS_PARAM, 0x1F000000, val);
+
+ val = ((css_info.chrom_lower_th[0] & 0x1F) << 16) | ((css_info.chrom_lower_th[1] & 0x1F) << 8)
+ | (css_info.chrom_lower_th[2] & 0x1F);
+ REG_MWR(ISP_CSS_CHROM_L_TH_0, 0x1F1F1F, val);
+
+ val = ((css_info.chrom_lower_th[3] & 0x1F) << 24) | ((css_info.chrom_lower_th[4] & 0x1F) << 16)
+ | ((css_info.chrom_lower_th[5] & 0x1F) << 8) | (css_info.chrom_lower_th[6] & 0x1F);
+ REG_WR(ISP_CSS_CHROM_L_TH_1, val);
+
+ val = ((css_info.chrom_high_th[0] & 0x1F) << 16) | ((css_info.chrom_high_th[1] & 0x1F) << 8)
+ | (css_info.chrom_high_th[2] & 0x1F);
+ REG_WR(ISP_CSS_CHROM_H_TH_0, val);
+
+ val = ((css_info.chrom_high_th[3] & 0x1F) << 24) | ((css_info.chrom_high_th[4] & 0x1F) << 16)
+ | ((css_info.chrom_high_th[5] & 0x1F) << 8) | (css_info.chrom_high_th[6] & 0x1F);
+ REG_WR(ISP_CSS_CHROM_H_TH_1, val);
+
+ val = ((css_info.lum_low_shift & 0x7) << 16) | ((css_info.lum_hig_shift & 0x7) << 8);
+ REG_MWR(ISP_CSS_PARAM, 0x70700, val);
+
+ val = (css_info.lh_ratio[7] & 0xF) | ((css_info.lh_ratio[6] & 0xF) << 4)
+ | ((css_info.lh_ratio[5] & 0xF) << 8) | ((css_info.lh_ratio[4] & 0xF) << 12)
+ | ((css_info.lh_ratio[3] & 0xF) << 16) | ((css_info.lh_ratio[2] & 0xF) << 20)
+ | ((css_info.lh_ratio[1] & 0xF) << 24) | ((css_info.lh_ratio[0] & 0xF) << 28);
+ REG_WR(ISP_CSS_LH_RATIO, val);
+
+ val = (css_info.ratio[7] & 0xF) | ((css_info.ratio[6] & 0xF) << 4)
+ | ((css_info.ratio[5] & 0xF) << 8) | ((css_info.ratio[4] & 0xF) << 12)
+ | ((css_info.ratio[3] & 0xF) << 16) | ((css_info.ratio[2] & 0xF) << 20)
+ | ((css_info.ratio[1] & 0xF) << 24) | ((css_info.ratio[0] & 0xF) << 28);
+ REG_WR(ISP_CSS_RATIO, val);
+
+ val = (css_info.lum_hh_th & 0xFF) | ((css_info.lum_hig_th & 0xFF) << 8)
+ | ((css_info.lum_ll_th & 0xFF) << 16) | ((css_info.lum_low_th & 0xFF) << 24);
+ REG_WR(ISP_CSS_THRD0, val);
+
+ val = (css_info.v_th_0_h & 0xFF) | ((css_info.v_th_0_l & 0xFF) << 8)
+ | ((css_info.u_th_0_h & 0xFF) << 16) | ((css_info.u_th_0_l & 0xFF) << 24);
+ REG_WR(ISP_CSS_EX_TH_0, val);
+
+ val = (css_info.v_th_1_h & 0xFF) | ((css_info.v_th_1_l & 0xFF) << 8)
+ | ((css_info.u_th_1_h & 0xFF) << 16) | ((css_info.u_th_1_l & 0xFF) << 24);
+ REG_WR(ISP_CSS_EX_TH_1, val);
+
+ REG_MWR(ISP_CSS_CHROM_L_TH_0, 0x1F000000, css_info.cutoff_th << 24);
+
+ if (css_info.bypass) {
+ REG_OWR(ISP_CSS_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_CSS_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_css(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_css: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_css: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CSS_BLOCK:
+ ret = isp_k_css_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_css: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_ct.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_ct.c
new file mode 100644
index 00000000..376b3ce4
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_ct.c
@@ -0,0 +1,92 @@
+/*
+ * 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_3D_LUT_BUF0 0
+#define ISP_3D_LUT_BUF1 1
+
+static int32_t isp_k_ct_block(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t buf_size = 0;
+ unsigned long dst_buf = 0;
+ struct isp_dev_ct_info ct_info;
+ void *data_ptr = NULL;
+
+ buf_size = ISP_3D_LUT_ITEM * 4;
+ memset(&ct_info, 0x00, sizeof(ct_info));
+
+ ret = copy_from_user((void *)&ct_info, param->property_param, sizeof(ct_info));
+ if (0 != ret) {
+ printk("isp_k_ct_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+#ifdef CONFIG_64BIT
+ data_ptr = (void*)(((unsigned long)ct_info.data_ptr[1] << 32) | ct_info.data_ptr[0]);
+#else
+ data_ptr = (void*)(ct_info.data_ptr[0]);
+#endif
+ if (NULL == data_ptr || ct_info.size > buf_size) {
+ printk("isp_k_ct_block: memory error: %p %x.\n",
+ data_ptr, ct_info.size);
+ }
+
+ dst_buf = ISP_3D_LUT0_OUTPUT;
+ isp_private->ct_load_buf_id = ISP_3D_LUT_BUF0;
+
+ ret = copy_from_user((void *)dst_buf, data_ptr, ct_info.size);
+ if (0 != ret) {
+ printk("isp_k_ct_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ //REG_MWR(ISP_CT_PARAM, BIT_1, (isp_private->ct_load_buf_id << 1));
+
+ REG_MWR(ISP_CT_PARAM, BIT_0, ct_info.bypass);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_ct(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_ct: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_ct: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CT_BLOCK:
+ ret = isp_k_ct_block(param, isp_private);
+ break;
+ default:
+ printk("isp_k_cfg_ct: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_dispatch.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_dispatch.c
new file mode 100644
index 00000000..f998c27d
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_dispatch.c
@@ -0,0 +1,143 @@
+/*
+ * 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"
+
+static int32_t isp_k_dispatch_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_dispatch_info_v1 dispatch_info;
+
+ memset(&dispatch_info, 0x00, sizeof(dispatch_info));
+
+ ret = copy_from_user((void *)&dispatch_info, param->property_param, sizeof(dispatch_info));
+ if (0 != ret) {
+ printk("isp_k_dispatch_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_DISPATCH_CH0_BAYER, 0x03, dispatch_info.bayer_ch0);
+ REG_MWR(ISP_DISPATCH_CH0_BAYER, 0x0C, dispatch_info.bayer_ch1);
+
+ return ret;
+}
+
+static int32_t isp_k_dispatch_ch0_bayer(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&val, param->property_param, sizeof(uint32_t));
+ if (0 != ret) {
+ printk("isp_k_dispatch_ch0_bayer: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_DISPATCH_CH0_BAYER, 0x03, val);
+
+ return ret;
+}
+
+static int32_t isp_k_dispatch_ch1_bayer(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&val, param->property_param, sizeof(uint32_t));
+ if (0 != ret) {
+ printk("isp_k_dispatch_ch1_bayer: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_DISPATCH_CH0_BAYER, 0x0C, val);
+
+ return ret;
+}
+
+static int32_t isp_k_dispatch_ch0_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size = {0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(size));
+ if (0 != ret) {
+ printk("isp_k_dispatch_ch0_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height & 0xFFFF) << 16) | (size.width & 0xFFFF);
+ REG_WR(ISP_DISPATCH_CH0_SIZE, val);
+
+ return ret;
+}
+
+static int32_t isp_k_dispatch_ch1_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size = {0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(size));
+ if (0 != ret) {
+ printk("isp_k_dispatch_ch1_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height & 0xFFFF) << 16) | (size.width & 0xFFFF);
+ REG_WR(ISP_DISPATCH_CH1_SIZE, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_dispatch(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_dispatch: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_dispatch: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_DISPATCH_BLOCK:
+ ret = isp_k_dispatch_block(param);
+ break;
+ case ISP_PRO_DISPATCH_CH0_BAYER:
+ ret = isp_k_dispatch_ch0_bayer(param);
+ break;
+ case ISP_PRO_DISPATCH_CH1_BAYER:
+ ret = isp_k_dispatch_ch1_bayer(param);
+ break;
+ case ISP_PRO_DISPATCH_CH0_SIZE:
+ ret = isp_k_dispatch_ch0_size(param);
+ break;
+ case ISP_PRO_DISPATCH_CH1_SIZE:
+ ret = isp_k_dispatch_ch1_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_dispatch: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_edge.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_edge.c
new file mode 100644
index 00000000..2c298147
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_edge.c
@@ -0,0 +1,128 @@
+/*
+ * 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"
+
+static int32_t isp_k_edge_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_edge_info_v1 edge_info;
+ uint32_t val = 0;
+
+ memset(&edge_info, 0x00, sizeof(edge_info));
+
+ ret = copy_from_user((void *)&edge_info, param->property_param, sizeof(edge_info));
+ if (0 != ret) {
+ printk("isp_k_edge_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_EE_CFG0, BIT_29 | BIT_28, edge_info.mode << 28);
+
+ val = (edge_info.ee_str_m_n & 0x7F) | ((edge_info.ee_str_m_p & 0x7F) << 7)
+ | ((edge_info.ee_str_d_n & 0x7F) << 14) | ((edge_info.ee_str_d_p & 0x7F) << 21);
+ REG_MWR(ISP_EE_CFG0, 0xFFFFFFF, val);
+
+ val = ((edge_info.ee_incr_d_p & 0xFF) << 8) | (edge_info.ee_incr_d_n & 0xFF);
+ REG_MWR(ISP_EE_CFG1, 0xFFFF, val);
+
+ val = ((edge_info.ee_thr_d_n & 0xFF) << 16) | ((edge_info.ee_thr_d_p & 0xFF) << 24);
+ REG_MWR(ISP_EE_CFG1, 0xFFFF0000, val);
+
+ val = (edge_info.ee_flat_thr_1 & 0xFF) | ((edge_info.ee_flat_thr_2 & 0xFF) << 8);
+ REG_MWR(ISP_EE_CFG2, 0xFFFF, val);
+
+ val = ((edge_info.ee_incr_m_n & 0xFF) << 16) | ((edge_info.ee_incr_m_p & 0xFF) << 24);
+ REG_MWR(ISP_EE_CFG2, 0xFFFF0000, val);
+
+ val = (edge_info.ee_txt_thr_1 & 0xFF) | ((edge_info.ee_txt_thr_2 & 0xFF) << 8)
+ | ((edge_info.ee_txt_thr_3 & 0xFF) << 16);
+ REG_WR(ISP_EE_CFG3, val);
+
+ val = ((edge_info.ee_corner_cor & 0x1) << 28) | ((edge_info.ee_corner_th_p & 0x1F) << 23)
+ | ((edge_info.ee_corner_th_n & 0x1F) << 18) | ((edge_info.ee_corner_gain_p & 0x7F) << 11)
+ | ((edge_info.ee_corner_gain_n & 0x7F) << 4) | ((edge_info.ee_corner_sm_p & 0x3) << 2)
+ | (edge_info.ee_corner_sm_n & 0x3);
+ REG_WR(ISP_EE_CFG4, val);
+
+ val = ((edge_info.ee_edge_smooth_mode & 0x3) << 26) | ((edge_info.ee_flat_smooth_mode & 0x3) << 24)
+ | ((edge_info.ee_smooth_thr & 0xFF) << 8) | (edge_info.ee_smooth_strength & 0xFF);
+ REG_MWR(ISP_EE_CFG5, 0xF00FFFF, val);
+
+ val = (edge_info.sigma & 0xFF) << 16;
+ REG_MWR(ISP_EE_CFG5, 0xFF0000, val);
+
+ val = ((edge_info.ee_str_b_p & 0xFF) << 24) | ((edge_info.ee_str_b_n & 0xFF) << 16)
+ | ((edge_info.ee_incr_b_p & 0xFF) << 8) | (edge_info.ee_incr_b_n & 0xFF);
+ REG_WR(ISP_EE_CFG6, val);
+
+ val = ((edge_info.ratio[1] & 0xFF) << 8) | (edge_info.ratio[0] & 0xFF);
+ REG_MWR(ISP_EE_CFG7, 0xFFFF, val);
+
+ val = (edge_info.ee_clip_after_smooth_en & 0x1) << 25;
+ REG_MWR(ISP_EE_CFG7, BIT_25, val);
+
+ val = ((edge_info.ipd_bypass & 0x1) << 24) | ((edge_info.ipd_flat_thr & 0xFF) << 16);
+ REG_MWR(ISP_EE_CFG7, 0x1FF0000, val);
+
+/*pike has no ADP_CFG0 ADP_CFG1 ADP_CFG2 registers*/
+
+/* val = (edge_info.ee_t1_cfg & 0x3FF) | ((edge_info.ee_t2_cfg & 0x3FF) << 10)
+ | ((edge_info.ee_t3_cfg & 0x3FF) << 20);
+ REG_WR(ISP_EE_ADP_CFG0, val);
+
+ val = (edge_info.ee_t4_cfg & 0x3FF) | ((edge_info.ee_cv_clip_n & 0xFF) << 16)
+ | ((edge_info.ee_cv_clip_p & 0xFF) << 24);
+ REG_WR(ISP_EE_ADP_CFG1, val);
+
+ val = (edge_info.ee_r1_cfg & 0xFF) | ((edge_info.ee_r2_cfg & 0xFF) << 8)
+ | ((edge_info.ee_r3_cfg & 0xFF) << 16);
+ REG_WR(ISP_EE_ADP_CFG2, val);*/
+
+
+ if (edge_info.bypass) {
+ REG_OWR(ISP_EE_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_EE_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_edge(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_edge: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_edge: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_EDGE_BLOCK:
+ ret = isp_k_edge_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_edge: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_emboss.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_emboss.c
new file mode 100644
index 00000000..27319afc
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_emboss.c
@@ -0,0 +1,74 @@
+/*
+ * 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"
+
+static int32_t isp_k_emboss_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_emboss_info_v1 emboss_info;
+
+ memset(&emboss_info, 0x00, sizeof(emboss_info));
+
+ ret = copy_from_user((void *)&emboss_info, param->property_param, sizeof(emboss_info));
+ if (0 != ret) {
+ printk("isp_k_emboss_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_EMBOSS_Y_PARAM, 0x7E, (emboss_info.y_step & 0x3F) << 1);
+
+ if (emboss_info.y_bypass) {
+ REG_OWR(ISP_EMBOSS_Y_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_EMBOSS_Y_PARAM, BIT_0, 0);
+ }
+
+ REG_MWR(ISP_EMBOSS_UV_PARAM, 0x7E, (emboss_info.uv_step & 0x3F) << 1);
+
+ if (emboss_info.uv_bypass) {
+ REG_OWR(ISP_EMBOSS_UV_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_EMBOSS_UV_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_emboss(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_emboss: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_emboss: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_EMBOSS_BLOCK:
+ ret = isp_k_emboss_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_emboss: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_fetch.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_fetch.c
new file mode 100644
index 00000000..04df07df
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_fetch.c
@@ -0,0 +1,127 @@
+/*
+ * 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"
+
+static int32_t isp_k_fetch_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_fetch_info_v1 fetch_info;
+
+ memset(&fetch_info, 0x00, sizeof(fetch_info));
+
+ ret = copy_from_user((void *)&fetch_info, param->property_param, sizeof(fetch_info));
+ if (0 != ret) {
+ printk("isp_k_fetch_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (fetch_info.substract) {
+ REG_OWR(ISP_FETCH_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_FETCH_PARAM, BIT_1, 0);
+ }
+
+ REG_MWR(ISP_FETCH_PARAM, 0xF0, (fetch_info.color_format << 4));
+
+ REG_WR(ISP_FETCH_SLICE_Y_ADDR, fetch_info.addr.chn0);
+ REG_WR(ISP_FETCH_SLICE_Y_PITCH, fetch_info.pitch.chn0);
+ REG_WR(ISP_FETCH_SLICE_U_ADDR, fetch_info.addr.chn1);
+ REG_WR(ISP_FETCH_SLICE_U_PITCH, fetch_info.pitch.chn1);
+ REG_WR(ISP_FETCH_SLICE_V_ADDR, fetch_info.addr.chn2);
+ REG_WR(ISP_FETCH_SLICE_V_PITCH, fetch_info.pitch.chn2);
+ REG_WR(ISP_FETCH_MIPI_WORD_INFO, (fetch_info.mipi_word_num & 0xFFFF));
+ REG_WR(ISP_FETCH_MIPI_BYTE_INFO, (fetch_info.mipi_byte_rel_pos & 0x0F));
+ REG_WR(ISP_FETCH_BAYER_MODE, 0x2);
+
+ if (fetch_info.bypass) {
+ REG_OWR(ISP_FETCH_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_FETCH_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_fetch_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t size = 0;
+ struct isp_img_size slice_size = {0, 0};
+
+ ret = copy_from_user((void *)&slice_size, param->property_param, sizeof(struct isp_img_size));
+ if (0 != ret) {
+ printk("isp_k_fetch_slice_size: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ size = ((slice_size.height & 0xFFFF) << 16) | (slice_size.width & 0xFFFF);
+
+ REG_WR(ISP_FETCH_SLICE_SIZE, size);
+
+ return ret;
+}
+
+static int32_t isp_k_fetch_start_isp(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t fetch_start = 0;
+
+ ret = copy_from_user((void *)&fetch_start, param->property_param, sizeof(uint32_t));
+ if (0 != ret) {
+ printk("isp_k_fetch_start_isp: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (fetch_start) {
+ REG_OWR(ISP_FETCH_START, BIT_0);
+ } else {
+ REG_MWR(ISP_FETCH_START, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_fetch(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_fetch: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_fetch: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_FETCH_BLOCK:
+ ret = isp_k_fetch_block(param);
+ break;
+ case ISP_PRO_FETCH_SLICE_SIZE:
+ ret = isp_k_fetch_slice_size(param);
+ break;
+ case ISP_PRO_FETCH_START_ISP:
+ ret = isp_k_fetch_start_isp(param);
+ break;
+ default:
+ printk("isp_k_cfg_fetch: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_gamma.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_gamma.c
new file mode 100644
index 00000000..99b9d1b4
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_gamma.c
@@ -0,0 +1,143 @@
+/*
+ * 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/vmalloc.h>
+#include <linux/sprd_mm.h>
+#include <video/sprd_isp.h>
+#include "isp_reg.h"
+#include "isp_drv.h"
+
+#define ISP_FRGB_GAMC_BUF0 0
+#define ISP_FRGB_GAMC_BUF1 1
+
+static int32_t isp_k_pingpang_frgb_gamc(struct coordinate_xy *nodes,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t i, j;
+ uint32_t val = 0;
+ unsigned long r_buf_addr;
+ unsigned long g_buf_addr;
+ unsigned long b_buf_addr;
+ struct coordinate_xy *p_nodes = NULL;
+
+ if (!nodes) {
+ ret = -1;
+ printk("isp_k_pingpang_frgb_gamc: node is null error .\n");
+ return ret;
+ }
+
+ p_nodes = nodes;
+
+#if 0
+ if (ISP_FRGB_GAMC_BUF0 == isp_private->full_gamma_buf_id) {
+ r_buf_addr = ISP_FGAMMA_R_BUF0_CH0;
+ g_buf_addr = ISP_FGAMMA_G_BUF0_CH0;
+ b_buf_addr = ISP_FGAMMA_B_BUF0_CH0;
+ isp_private->full_gamma_buf_id = ISP_FRGB_GAMC_BUF1;
+ } else {
+ r_buf_addr = ISP_FGAMMA_R_BUF0_CH0;
+ g_buf_addr = ISP_FGAMMA_G_BUF0_CH0;
+ b_buf_addr = ISP_FGAMMA_B_BUF0_CH0;
+ isp_private->full_gamma_buf_id = ISP_FRGB_GAMC_BUF0;
+ }
+#endif
+
+ isp_private->full_gamma_buf_id = ISP_FRGB_GAMC_BUF0;
+ val = ((isp_private->full_gamma_buf_id & 0x1 ) << 1) | ((isp_private->full_gamma_buf_id & 0x1) << 2) | ((isp_private->full_gamma_buf_id & 0x1 ) << 3);
+ REG_MWR(ISP_GAMMA_PARAM, 0x0000000E, val);
+
+ r_buf_addr = ISP_FGAMMA_R_BUF0_CH0;
+ g_buf_addr = ISP_FGAMMA_G_BUF0_CH0;
+ b_buf_addr = ISP_FGAMMA_B_BUF0_CH0;
+
+ for(i = 0,j = 0;i < ISP_PINGPANG_FRGB_GAMC_NUM;i++,j+=4) {
+ REG_WR(r_buf_addr + j, p_nodes[i].node_y & 0xff);
+ REG_WR(g_buf_addr + j, p_nodes[i].node_y & 0xff);
+ REG_WR(b_buf_addr + j, p_nodes[i].node_y & 0xff);
+ }
+
+ isp_private->full_gamma_buf_id = ISP_FRGB_GAMC_BUF1;
+
+ val = ((isp_private->full_gamma_buf_id & 0x1 ) << 1) | ((isp_private->full_gamma_buf_id & 0x1) << 2) | ((isp_private->full_gamma_buf_id & 0x1 ) << 3);
+ REG_MWR(ISP_GAMMA_PARAM, 0x0000000E, val);
+
+ return ret;
+}
+
+static int32_t isp_k_gamma_block(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ uint32_t bypass;
+ struct isp_dev_gamma_info_v1 *param_p= (struct isp_dev_gamma_info_v1 *)param->property_param;
+ struct coordinate_xy *nodes = NULL;
+
+ nodes = (struct coordinate_xy *)isp_private->full_gamma_buf_addr;
+ if (!nodes) {
+ ret = -1;
+ printk("isp_k_gamma_block: alloc memory error.\n");
+ return -1;
+ }
+ ret = copy_from_user((void *)nodes, (void *)param_p->nodes, ISP_FRGB_GAMMA_BUF_SIZE);
+ if (0 != ret) {
+ printk("isp_k_gamma_block: copy nodes error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ ret = isp_k_pingpang_frgb_gamc(nodes, isp_private);
+ if (0 != ret) {
+ printk("isp_k_gamma_block: pingpang error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ ret = copy_from_user((void *)&bypass, (void *)&param_p->bypass, sizeof(uint32_t));
+ if (0 != ret) {
+ printk("isp_k_gamma_block: copy bypass error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_GAMMA_PARAM, BIT_0, bypass);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_gamma(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_gamma: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_gamma: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_GAMMA_BLOCK:
+ ret = isp_k_gamma_block(param, isp_private);
+ break;
+ default:
+ printk("isp_k_cfg_gamma: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_grgb.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_grgb.c
new file mode 100644
index 00000000..6bf40d2a
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_grgb.c
@@ -0,0 +1,70 @@
+/*
+ * 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"
+
+static int32_t isp_k_grgb_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_grgb_info_v1 grgb_info;
+
+ memset(&grgb_info, 0x00, sizeof(grgb_info));
+
+ ret = copy_from_user((void *)&grgb_info, param->property_param, sizeof(grgb_info));
+ if (0 != ret) {
+ printk("isp_k_grgb_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_GRGB_PARAM, BIT_0, grgb_info.bypass);
+
+ val = ((grgb_info.diff & 0x3FF) << 7) | ((grgb_info.edge & 0x3F) << 1);
+ REG_MWR(ISP_GRGB_PARAM, 0x1FFFE, val);
+ val = grgb_info.grid & 0xFFF;
+ REG_MWR(ISP_GRGB_GRID, 0xFFF, val);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_grgb(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_grgb: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_grgb: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_GRGB_BLOCK:
+ ret = isp_k_grgb_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_grgb: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hdr.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hdr.c
new file mode 100755
index 00000000..ba03b911
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hdr.c
@@ -0,0 +1,142 @@
+/*
+ * 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"
+
+static int32_t isp_k_hdr_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t i = 0, index = 0, addr = 0, val = 0;
+ struct isp_dev_hdr_info hdr_info;
+
+ ret = copy_from_user((void *)&hdr_info, param->property_param, sizeof(hdr_info));
+ if (0 != ret) {
+ printk("isp_k_hdr_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ printk("$$LHC:isp_k_hdr_block");
+ REG_MWR(ISP_HDR_PARAM, BIT_1, (hdr_info.level << 1));
+
+ val = ((hdr_info.b_index & 0xFF) << 24)
+ | ((hdr_info.g_index & 0xFF) << 16)
+ | ((hdr_info.r_index & 0xFF) << 8);
+ REG_WR(ISP_HDR_PARAM, val);
+
+ if (hdr_info.bypass) {
+ REG_OWR(ISP_HDR_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_HDR_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_hdr_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
+ if (0 != ret) {
+ printk("isp_k_hdr_bypass: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (bypass) {
+ REG_OWR(ISP_HDR_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_HDR_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_hdr_level(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t level= 0;
+
+ ret = copy_from_user((void *)&level, param->property_param, sizeof(level));
+ if (0 != ret) {
+ printk("isp_k_hdr_level: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_HDR_PARAM, BIT_1, (level << 1));
+
+ return ret;
+}
+
+static int32_t isp_k_hdr_index(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_hdr_rgb_index index;
+
+ memset(&index, 0x00, sizeof(index));
+
+ ret = copy_from_user((void *)&index, param->property_param, sizeof(index));
+ if (0 != ret) {
+ printk("isp_k_hdr_index: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((index.b & 0xFF) << 24)
+ | ((index.g & 0xFF) << 16)
+ | ((index.r & 0xFF) << 8);
+ REG_WR(ISP_HDR_PARAM, val);
+
+ return ret;
+}
+
+
+int32_t isp_k_cfg_hdr(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_hdr: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_hdr: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_HDR_BLOCK:
+ ret = isp_k_hdr_block(param);
+ break;
+ case ISP_PRO_HDR_BYPASS:
+ ret = isp_k_hdr_bypass(param);
+ break;
+ case ISP_PRO_HDR_LEVEL:
+ ret = isp_k_hdr_level(param);
+ break;
+ case ISP_PRO_HDR_INDEX:
+ ret = isp_k_hdr_index(param);
+ break;
+ case ISP_PRO_HDR_TAB:
+ //ret = isp_k_hdr_tab(param);
+ break;
+ default:
+ printk("isp_k_cfg_hdr: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hist.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hist.c
new file mode 100644
index 00000000..5ab1a8c3
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hist.c
@@ -0,0 +1,131 @@
+/*
+ * 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"
+
+static int32_t isp_k_hist_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_hist_info_v1 hist_info;
+ uint32_t val = 0;
+
+ memset(&hist_info, 0x00, sizeof(hist_info));
+
+ ret = copy_from_user((void *)&hist_info, param->property_param, sizeof(hist_info));
+ if (0 != ret) {
+ printk("isp_k_hist_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (hist_info.buf_rst_en) {
+ REG_OWR(ISP_HIST_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_HIST_PARAM, BIT_1, 0);
+ }
+//pike has no bit9
+/* if (hist_info.pof_rst_en) {
+ REG_OWR(ISP_HIST_PARAM, BIT_9);
+ } else {
+ REG_MWR(ISP_HIST_PARAM, BIT_9, 0);
+ }*/
+
+ if (hist_info.skip_num_clr) {
+ REG_OWR(ISP_HIST_PARAM, BIT_8);
+ } else {
+ REG_MWR(ISP_HIST_PARAM, BIT_8, 0);
+ }
+
+ REG_MWR(ISP_HIST_PARAM, 0xF0, hist_info.skip_num << 4);
+
+ if (hist_info.mode) {
+ REG_OWR(ISP_HIST_PARAM, BIT_3);
+ } else {
+ REG_MWR(ISP_HIST_PARAM, BIT_3, 0);
+ }
+
+ val = ((hist_info.high_ratio & 0xFFFF) << 16)
+ | (hist_info.low_ratio & 0xFFFF);
+
+ REG_WR(ISP_HIST_RATIO, val);
+
+ val = (hist_info.dif_adj & 0xFF) | ((hist_info.small_adj & 0xFF) << 8)
+ | ((hist_info.big_adj & 0xFF) << 16);
+
+ REG_WR(ISP_HIST_ADJUST, val);
+
+ if (hist_info.off) {
+ REG_OWR(ISP_HIST_PARAM, BIT_2);
+ } else {
+ REG_MWR(ISP_HIST_PARAM, BIT_2, 0);
+ }
+
+ if (hist_info.bypass) {
+ REG_OWR(ISP_HIST_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_HIST_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_hist_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size = {0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(size));
+ if (0 != ret) {
+ printk("isp_k_hist_slice_size: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height & 0xFFFF) << 16)
+ | (size.width & 0xFFFF);
+
+ REG_WR(ISP_HIST_SLICE_SIZE, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_hist(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_hist: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_hist: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_HIST_BLOCK:
+ ret = isp_k_hist_block(param);
+ break;
+ case ISP_PRO_HIST_SLICE_SIZE:
+ ret = isp_k_hist_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_hist: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hist2.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hist2.c
new file mode 100644
index 00000000..7f8c5d05
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hist2.c
@@ -0,0 +1,95 @@
+/*
+ * 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"
+
+static int32_t isp_k_hist2_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_hist2_info_v1 hist2_info;
+ uint32_t val = 0;
+ uint32_t i = 0;
+
+ memset(&hist2_info, 0x00, sizeof(hist2_info));
+
+ ret = copy_from_user((void *)&hist2_info, param->property_param, sizeof(hist2_info));
+ if (0 != ret) {
+ printk("isp_k_hist2_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (hist2_info.skip_num_clr) {
+ REG_OWR(ISP_HIST2_PARAM, BIT_8);
+ } else {
+ REG_MWR(ISP_HIST2_PARAM, BIT_8, 0);
+ }
+
+ REG_MWR(ISP_HIST2_PARAM, 0xF0, hist2_info.skip_num << 4);
+
+ if (hist2_info.mode) {
+ REG_OWR(ISP_HIST2_PARAM, BIT_3);
+ } else {
+ REG_MWR(ISP_HIST2_PARAM, BIT_3, 0);
+ }
+
+ for (i = 0; i < 4; i++) {
+ val = (hist2_info.hist_roi_y_s[i] & 0xFFFF) | ((hist2_info.hist_roi_x_s[i] & 0xFFFF) << 16);
+ REG_WR(ISP_HIST2_ROI_S0 + i * 8, val);
+
+ val = (hist2_info.hist_roi_y_e[i] & 0xFFFF) | ((hist2_info.hist_roi_x_e[i] & 0xFFFF) << 16);
+ REG_WR(ISP_HIST2_ROI_E0 + i * 8, val);
+ }
+
+//pike has no bit1 of ISP_HIST2_PARAM
+/* if (hist2_info.en) {
+ REG_OWR(ISP_HIST2_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_HIST2_PARAM, BIT_1, 0);
+ }*/
+
+ if (hist2_info.bypass) {
+ REG_OWR(ISP_HIST2_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_HIST2_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_hist2(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_hist2: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_hist2: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_HIST2_BLOCK:
+ ret = isp_k_hist2_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_hist2: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hsv.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hsv.c
new file mode 100644
index 00000000..5083242b
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hsv.c
@@ -0,0 +1,95 @@
+/*
+ * 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"
+
+static int32_t isp_k_hsv_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ int32_t buf_size = 0;
+ unsigned long dst_addr = 0;
+ struct isp_dev_hsv_info_v1 hsv_info;
+ void *data_ptr = NULL;
+
+ memset(&hsv_info, 0x00, sizeof(hsv_info));
+
+ ret = copy_from_user((void *)&hsv_info, param->property_param, sizeof(hsv_info));
+ if (0 != ret) {
+ printk("isp_k_hsv_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+#ifdef CONFIG_64BIT
+ data_ptr = (void*)(((unsigned long)hsv_info.data_ptr[1] << 32) | hsv_info.data_ptr[0]);
+#else
+ data_ptr = (void*)(hsv_info.data_ptr[0]);
+#endif
+
+ buf_size = ISP_HSV_ITEM * 4;
+ if (NULL == data_ptr || hsv_info.size > buf_size) {
+ printk("isp_k_hsv_block : memory error %p %x \n",
+ data_ptr, hsv_info.size);
+ return -1;
+ }
+
+ if (hsv_info.buf_sel << 1 & BIT_1) {
+ dst_addr = ISP_HSV_BUF1_OUTPUT;
+ } else {
+ dst_addr = ISP_HSV_BUF0_OUTPUT;
+ }
+
+ ret = copy_from_user((void *)dst_addr, data_ptr, hsv_info.size);
+ if (0 != ret) {
+ printk("isp_k_hsv_block: copy error 0x%x \n",(uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_HSV_PARAM, BIT_1, hsv_info.buf_sel << 1);
+
+ REG_MWR(ISP_HSV_PARAM, BIT_0, hsv_info.bypass);
+
+ return ret;
+
+}
+
+
+int32_t isp_k_cfg_hsv(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_hsv: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_hsv: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_HSV_BLOCK:
+ ret = isp_k_hsv_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_hsv: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hua.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hua.c
new file mode 100644
index 00000000..f4570330
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_hua.c
@@ -0,0 +1,68 @@
+/*
+ * 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"
+
+static int32_t isp_k_hue_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_hue_info_v1 hua_info;
+
+ memset(&hua_info, 0x00, sizeof(hua_info));
+
+ ret = copy_from_user((void *)&hua_info, param->property_param, sizeof(hua_info));
+ if (0 != ret) {
+ printk("isp_k_hue_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_HUA_PARAM, 0x1FF0, hua_info.theta << 4);
+
+ if (hua_info.bypass) {
+ REG_OWR(ISP_HUA_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_HUA_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+
+int32_t isp_k_cfg_hue(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_hue: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_hue: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_HUE_BLOCK:
+ ret = isp_k_hue_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_hue: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_isr.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_isr.c
new file mode 100644
index 00000000..bcec6583
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_isr.c
@@ -0,0 +1,101 @@
+/*
+ * 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 <linux/delay.h>
+#include "isp_reg.h"
+#include "isp_drv.h"
+
+#define ISP_TIME_OUT_MAX (500)
+
+int32_t isp_get_int_num(struct isp_node *node)
+{
+
+ node->irq_val1 = REG_RD(ISP_INT_INT0);
+ node->irq_val2 = REG_RD(ISP_INT_INT1);
+ node->irq_val3 = REG_RD(ISP_INT_INT2);
+
+ if ((0 == node->irq_val1)
+ && (0 == node->irq_val2)
+ && (0 == node->irq_val3)) {
+ printk("isp_get_int_num: int error.\n");
+ return -1;
+ }
+
+ REG_WR(ISP_INT_CLR0, ISP_IRQ_HW_MASK);
+ REG_WR(ISP_INT_CLR1, ISP_IRQ_HW_MASK);
+ REG_WR(ISP_INT_CLR2, ISP_IRQ_HW_MASK);
+
+ return 0;
+}
+
+void isp_clr_int(void)
+{
+ REG_WR(ISP_INT_CLR0, ISP_IRQ_HW_MASK);
+ REG_WR(ISP_INT_CLR1, ISP_IRQ_HW_MASK);
+ REG_WR(ISP_INT_CLR2, ISP_IRQ_HW_MASK);
+}
+
+void isp_en_irq(uint32_t irq_mode)
+{
+ REG_WR(ISP_INT_CLR0, ISP_IRQ_HW_MASK);
+ REG_WR(ISP_INT_CLR1, ISP_IRQ_HW_MASK);
+ REG_WR(ISP_INT_CLR2, ISP_IRQ_HW_MASK);
+
+ switch(irq_mode) {
+ case ISP_INT_VIDEO_MODE:
+ REG_WR(ISP_INT_EN0, ISP_INT_DCAMERA_SOF | ISP_INT_AEM_DONE | ISP_INT_AFM_RGB_DONE | ISP_INT_AFL_DONE);
+ REG_WR(ISP_INT_EN1, 0);
+ REG_WR(ISP_INT_EN2, 0);
+ break;
+ case ISP_INT_CAPTURE_MODE:
+ REG_WR(ISP_INT_EN0, ISP_INT_STORE_DONE);
+ REG_WR(ISP_INT_EN1, 0);
+ REG_WR(ISP_INT_EN2, 0);
+ break;
+ case ISP_INT_CLEAR_MODE:
+ REG_WR(ISP_INT_EN0, 0);
+ REG_WR(ISP_INT_EN1, 0);
+ REG_WR(ISP_INT_EN2, 0);
+ break;
+ default:
+ printk("isp_en_irq: irq_mode error.\n");
+ break;
+ }
+}
+
+int32_t isp_axi_bus_waiting(void)
+{
+ int32_t ret = 0;
+ uint32_t reg_value = 0;
+ uint32_t time_out_cnt = 0;
+
+ REG_OWR(ISP_AXI_ITI2AXIM_CTRL, BIT_18);
+
+ reg_value = REG_RD(ISP_INT_STATUS);
+ while ((0x00 == (reg_value & BIT_3))
+ && (time_out_cnt < ISP_TIME_OUT_MAX)) {
+ time_out_cnt++;
+ udelay(50);
+ reg_value = REG_RD(ISP_INT_STATUS);
+ }
+
+ if (time_out_cnt >= ISP_TIME_OUT_MAX) {
+ ret = -1;
+ printk("isp_axi_bus_waiting: time out.\n");
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_nlc.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_nlc.c
new file mode 100755
index 00000000..1be70137
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_nlc.c
@@ -0,0 +1,83 @@
+/*
+ * 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"
+
+static int32_t isp_k_nlc_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ struct isp_dev_nlc_info_v1 nlc_info;
+
+ memset(&nlc_info, 0x00, sizeof(nlc_info));
+
+ ret = copy_from_user((void *)&nlc_info, param->property_param, sizeof(nlc_info));
+ if (0 != ret) {
+ printk("isp_k_nlc_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ for (i = 0; i < 9; i++) {
+ val = ((nlc_info.node.r_node[i*3] & 0x3FF) << 20) | ((nlc_info.node.r_node[i*3+1] & 0x3FF) << 10) | (nlc_info.node.r_node[i*3+2] & 0x3FF);
+ REG_WR(ISP_NLC_PARA_R0 + i * 4, val);
+ val = ((nlc_info.node.g_node[i*3] & 0x3FF) << 20) | ((nlc_info.node.g_node[i*3+1] & 0x3FF) << 10) | (nlc_info.node.g_node[i*3+2] & 0x3FF);
+ REG_WR(ISP_NLC_PARA_G0 + i * 4, val);
+ val = ((nlc_info.node.b_node[i*3] & 0x3FF) << 20) | ((nlc_info.node.b_node[i*3+1] & 0x3FF) << 10) | (nlc_info.node.b_node[i*3+2] & 0x3FF);
+ REG_WR(ISP_NLC_PARA_B0 + i * 4, val);
+ val = ((nlc_info.node.l_node[i*3] & 0x3FF) << 20) | ((nlc_info.node.l_node[i*3+1] & 0x3FF) << 10) | (nlc_info.node.l_node[i*3+2] & 0x3FF);
+ REG_WR(ISP_NLC_PARA_L0 + i * 4, val);
+ }
+
+ val = ((nlc_info.node.r_node[27] & 0x3FF) << 20) | ((nlc_info.node.r_node[28] & 0x3FF) << 10);
+ REG_WR(ISP_NLC_PARA_R9, val);
+ val = ((nlc_info.node.g_node[27] & 0x3FF) << 20) | ((nlc_info.node.g_node[28] & 0x3FF) << 10);
+ REG_WR(ISP_NLC_PARA_G9, val);
+ val = ((nlc_info.node.b_node[27] & 0x3FF) << 20) | ((nlc_info.node.b_node[28] & 0x3FF) << 10);
+ REG_WR(ISP_NLC_PARA_B9, val);
+
+ REG_MWR(ISP_NLC_PARA, BIT_0, nlc_info.bypass);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_nlc(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_nlc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_nlc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_NLC_BLOCK:
+ ret = isp_k_nlc_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_nlc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_nlm.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_nlm.c
new file mode 100644
index 00000000..ee4d4076
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_nlm.c
@@ -0,0 +1,202 @@
+/*
+ * 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 <linux/vmalloc.h>
+#include "isp_reg.h"
+
+static int32_t isp_k_vst_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_vst_info_v1 vst_info;
+
+ ret = copy_from_user((void *)&vst_info, param->property_param, sizeof(vst_info));
+ if (0 != ret) {
+ printk("isp_k_vst_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_VST_PARA, BIT_0, vst_info.bypass);
+
+ REG_MWR(ISP_VST_PARA, BIT_1, vst_info.buf_sel << 1);
+
+ return ret;
+
+}
+
+static int32_t isp_k_nlm_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ struct isp_dev_nlm_info_v2 nlm_info;
+ uint32_t *buff0 = NULL;
+ uint32_t *buff1 = NULL;
+ unsigned long buf_addr = 0;
+ void *vst_addr = NULL;
+ void *ivst_addr = NULL;
+ void *nlm_addr = NULL;
+
+ ret = copy_from_user((void *)&nlm_info, param->property_param, sizeof(nlm_info));
+ if (0 != ret) {
+ printk("isp_k_nlm_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ buff0 = vzalloc(nlm_info.vst_len);
+ if (NULL == buff0) {
+ printk("isp_k_nlm_block:vst kmalloc error\n");
+ return -1;
+ }
+
+ buff1 = vzalloc(nlm_info.ivst_len);
+ if (NULL == buff1) {
+ printk("isp_k_nlm_block:ivst kmalloc error\n");
+ vfree(buff0);
+ return -1;
+ }
+
+#ifdef CONFIG_64BIT
+ vst_addr = (void*)(((unsigned long)nlm_info.vst_addr[1] << 32) | nlm_info.vst_addr[0]);
+#else
+ vst_addr = (void*)(nlm_info.vst_addr[0]);
+#endif
+ ret = copy_from_user((void *)buff0, vst_addr, nlm_info.vst_len);
+ if (0 != ret) {
+ printk("isp_k_nlm_block: vst copy error, ret=0x%x\n", (uint32_t)ret);
+ vfree(buff0);
+ vfree(buff1);
+ return -1;
+ }
+
+#ifdef CONFIG_64BIT
+ ivst_addr = (void*)(((unsigned long)nlm_info.ivst_addr[1] << 32) | nlm_info.ivst_addr[0]);
+#else
+ ivst_addr = (void*)(nlm_info.ivst_addr[0]);
+#endif
+ ret = copy_from_user((void *)buff1, ivst_addr, nlm_info.ivst_len);
+ if (0 != ret) {
+ printk("isp_k_nlm_block: ivst copy error, ret=0x%x\n", (uint32_t)ret);
+ vfree(buff0);
+ vfree(buff1);
+ return -1;
+ }
+
+ REG_MWR(ISP_NLM_PARA, BIT_1, nlm_info.imp_opt_bypass << 1);
+ REG_MWR(ISP_NLM_PARA, BIT_2, nlm_info.flat_opt_bypass << 2);
+
+ for (i = 0; i < 5; i++) {
+ val = (nlm_info.thresh[i] & 0x3FFF) | ((nlm_info.cnt[i] & 0x1F) << 16)
+ | ((nlm_info.strength[i] & 0x7F) << 24);
+ REG_WR(ISP_NLM_FLAT_PARA_0 + i * 4, val);
+ }
+
+ REG_MWR(ISP_NLM_STERNGTH, 0x7F, nlm_info.streng_th);
+
+ REG_MWR(ISP_NLM_STERNGTH, 0x7F80, nlm_info.texture_dec << 7);
+
+ REG_WR(ISP_NLM_IS_FLAT, nlm_info.is_flat & 0xFF);
+
+ REG_MWR(ISP_NLM_ADD_BACK, 0x7F, nlm_info.addback);
+
+
+ for (i = 0; i < 24; i++) {
+ val = (nlm_info.lut_w[i*3+0] & 0x3FF) | ((nlm_info.lut_w[i*3+1] & 0x3FF) << 10)
+ | ((nlm_info.lut_w[i*3+2] & 0x3FF) << 20);
+ REG_WR(ISP_NLM_LUT_W_0 + i * 4, val);
+ }
+
+
+ if (nlm_info.buf_sel ) {
+ //buf_addr = ISP_VST_BUF1_CH0;
+ //memcpy((void *)buf_addr, buff0, ISP_VST_IVST_NUM * sizeof(uint32_t));
+ } else {
+ buf_addr = ISP_VST_BUF0_CH0;
+ memcpy((void *)buf_addr, buff0, ISP_VST_IVST_NUM * sizeof(uint32_t));
+ }
+
+ if (nlm_info.buf_sel ) {
+ //buf_addr = ISP_IVST_BUF1_CH0;
+ //memcpy((void *)buf_addr, buff1, ISP_VST_IVST_NUM * sizeof(uint32_t));
+ } else {
+ buf_addr = ISP_IVST_BUF0_CH0;
+ memcpy((void *)buf_addr, buff1, ISP_VST_IVST_NUM * sizeof(uint32_t));
+ }
+
+ /*vst ivst follow nlm*/
+ REG_MWR(ISP_VST_PARA, BIT_1, nlm_info.buf_sel << 1);
+ REG_MWR(ISP_IVST_PARA, BIT_1, nlm_info.buf_sel << 1);
+
+ REG_MWR(ISP_NLM_PARA, BIT_0, nlm_info.bypass);
+ REG_MWR(ISP_IVST_PARA, BIT_0, nlm_info.bypass);
+ REG_MWR(ISP_VST_PARA, BIT_0, nlm_info.bypass);
+
+ vfree(buff0);
+ vfree(buff1);
+ return ret;
+
+}
+
+static int32_t isp_k_ivst_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ struct isp_dev_ivst_info_v1 ivst_info;
+
+ ret = copy_from_user((void *)&ivst_info, param->property_param, sizeof(ivst_info));
+ if (0 != ret) {
+ printk("isp_k_ivst_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_IVST_PARA, BIT_0, ivst_info.bypass);
+
+ REG_MWR(ISP_IVST_PARA, BIT_1, ivst_info.buf_sel << 1);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_nlm(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_nlm: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_nlm: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_VST_BLOCK:
+ ret = isp_k_vst_block(param);
+ break;
+ case ISP_PRO_NLM_BLOCK:
+ ret = isp_k_nlm_block(param);
+ break;
+ case ISP_PRO_IVST_BLOCK:
+ ret = isp_k_ivst_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_nlm: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pgg.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pgg.c
new file mode 100644
index 00000000..8cdd023d
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pgg.c
@@ -0,0 +1,67 @@
+/*
+ * 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"
+
+static int32_t isp_k_pgg_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_pre_glb_gain_info pgg_info;
+
+ memset(&pgg_info, 0x00, sizeof(pgg_info));
+
+ ret = copy_from_user((void *)&pgg_info, param->property_param, sizeof(pgg_info));
+ if (0 != ret) {
+ printk("isp_k_pgg_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_PGG_PARAM, 0xFFFF00, (pgg_info.gain << 8));
+
+ if (pgg_info.bypass) {
+ REG_OWR(ISP_PGG_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_PGG_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_pgg(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_pgg: param is null error.\n");
+ return -1;
+ }
+
+ if (!param->property_param) {
+ printk("isp_k_cfg_pgg: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_PRE_GLB_GAIN_BLOCK:
+ ret = isp_k_pgg_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_pgg: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_post_cdn.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_post_cdn.c
new file mode 100644
index 00000000..e61ad33e
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_post_cdn.c
@@ -0,0 +1,129 @@
+/*
+ * 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"
+
+static int32_t isp_k_post_cdn_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_post_cdn_info post_cdn_info;
+ uint32_t val = 0;
+ uint32_t i = 0;
+
+ memset(&post_cdn_info, 0x00, sizeof(post_cdn_info));
+
+ ret = copy_from_user((void *)&post_cdn_info, param->property_param, sizeof(post_cdn_info));
+ if (0 != ret) {
+ printk("isp_k_post_cdn_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+
+ REG_WR(ISP_POSTCDN_ADPT_THR, post_cdn_info.adapt_med_thr & 0x3FFF);
+
+ REG_MWR(ISP_POSTCDN_COMMON_CTRL, 0xE0, post_cdn_info.median_mode << 5);
+
+ if (post_cdn_info.uvjoint) {
+ REG_OWR(ISP_POSTCDN_COMMON_CTRL, BIT_4);
+ } else {
+ REG_MWR(ISP_POSTCDN_COMMON_CTRL, BIT_4, 0);
+ }
+
+ if (post_cdn_info.writeback_en) {
+ REG_OWR(ISP_POSTCDN_COMMON_CTRL, BIT_3);
+ } else {
+ REG_MWR(ISP_POSTCDN_COMMON_CTRL, BIT_3, 0);
+ }
+
+ if (post_cdn_info.mode) {
+ REG_OWR(ISP_POSTCDN_COMMON_CTRL, BIT_2);
+ } else {
+ REG_MWR(ISP_POSTCDN_COMMON_CTRL, BIT_2, 0);
+ }
+
+ val = (post_cdn_info.uvthr0 & 0x1FF) | ((post_cdn_info.uvthr1 & 0x1FF) << 16);
+ REG_WR(ISP_POSTCDN_UVTHR, val);
+ val = (post_cdn_info.thru0 & 0xFF) | ((post_cdn_info.thru1 & 0xFF) << 16);
+ REG_WR(ISP_POSTCDN_THRU, val);
+ val = (post_cdn_info.thrv0 & 0xFF) | ((post_cdn_info.thrv1 & 0xFF) << 16);
+ REG_WR(ISP_POSTCDN_THRV, val);
+
+ for (i = 0; i < 3; i++) {
+ val = (post_cdn_info.r_segu[0][i*2] & 0xFF) | ((post_cdn_info.r_segu[1][i*2] & 0x7) << 8)
+ | ((post_cdn_info.r_segu[0][i*2+1] & 0xFF) << 16) | ((post_cdn_info.r_segu[1][i*2+1] & 0x7) << 24);
+ REG_WR(ISP_POSTCDN_RSEGU01 + i * 4, val);
+ }
+ val = (post_cdn_info.r_segu[0][6] & 0xFF) | ((post_cdn_info.r_segu[1][6] & 0x7) << 8);
+ REG_WR(ISP_POSTCDN_RSEGU6, val);
+ for (i = 0; i < 3; i++) {
+ val = (post_cdn_info.r_segv[0][i*2] & 0xFF) | ((post_cdn_info.r_segv[1][i*2] & 0x7) << 8)
+ | ((post_cdn_info.r_segv[0][i*2+1] & 0xFF) << 16) | ((post_cdn_info.r_segv[1][i*2+1] & 0x7) << 24);
+ REG_WR(ISP_POSTCDN_RSEGV01 + i * 4, val);
+ }
+ val = (post_cdn_info.r_segv[0][6] & 0xFF) | ((post_cdn_info.r_segv[1][6] & 0x7) << 8);
+ REG_WR(ISP_POSTCDN_RSEGV6, val);
+
+
+ for (i = 0; i < 15; i++) {
+ val = (post_cdn_info.r_distw[i][0] & 0x7) | ((post_cdn_info.r_distw[i][1] & 0x7) << 3)
+ | ((post_cdn_info.r_distw[i][2] & 0x7) << 6) | ((post_cdn_info.r_distw[i][3] & 0x7) << 9)
+ | ((post_cdn_info.r_distw[i][4] & 0x7) << 12);
+ REG_WR(ISP_POSTCDN_R_DISTW0 + i * 4, val);
+ }
+
+//pike has no this register
+ //REG_WR(ISP_POSTCDN_START_ROW_MOD4, post_cdn_info.start_row_mod4 & 0x3);
+
+ if (post_cdn_info.downsample_bypass) {
+ REG_OWR(ISP_POSTCDN_COMMON_CTRL, BIT_1);
+ } else {
+ REG_MWR(ISP_POSTCDN_COMMON_CTRL, BIT_1, 0);
+ }
+
+ if (post_cdn_info.bypass) {
+ REG_OWR(ISP_POSTCDN_COMMON_CTRL, BIT_0);
+ } else {
+ REG_MWR(ISP_POSTCDN_COMMON_CTRL, BIT_0, 0);
+ }
+
+
+ return ret;
+}
+
+int32_t isp_k_cfg_post_cdn(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_post_cdn: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_post_cdn: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_POST_CDN_BLOCK:
+ ret = isp_k_post_cdn_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_post_cdn: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pre_cdn.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pre_cdn.c
new file mode 100644
index 00000000..f4be5578
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pre_cdn.c
@@ -0,0 +1,135 @@
+/*
+ * 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"
+
+static int32_t isp_k_yuv_precdn_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_yuv_precdn_info pre_cdn_info;
+ uint32_t val = 0;
+ uint32_t i = 0;
+
+ memset(&pre_cdn_info, 0x00, sizeof(pre_cdn_info));
+
+ ret = copy_from_user((void *)&pre_cdn_info, param->property_param, sizeof(pre_cdn_info));
+ if (0 != ret) {
+ printk("isp_k_yuv_precdn_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (pre_cdn_info.mode) {
+ REG_OWR(ISP_PRECDN_PARAM, BIT_4);
+ } else {
+ REG_MWR(ISP_PRECDN_PARAM, BIT_4, 0);
+ }
+
+ if (pre_cdn_info.median_writeback_en) {
+ REG_OWR(ISP_PRECDN_PARAM, BIT_8);
+ } else {
+ REG_MWR(ISP_PRECDN_PARAM, BIT_8, 0);
+ }
+
+ REG_MWR(ISP_PRECDN_PARAM, BIT_13 | BIT_12, pre_cdn_info.median_mode << 12);
+
+ if (pre_cdn_info.uv_joint) {
+ REG_OWR(ISP_PRECDN_PARAM, BIT_20);
+ } else {
+ REG_MWR(ISP_PRECDN_PARAM, BIT_20, 0);
+ }
+
+ REG_MWR(ISP_PRECDN_PARAM, BIT_17 | BIT_16, pre_cdn_info.den_stren << 16);
+
+ val = (pre_cdn_info.median_thr_u[0] & 0x7F) | ((pre_cdn_info.median_thr_u[1] & 0xFF) << 8)
+ | ((pre_cdn_info.median_thr_v[0] & 0x7F) << 16) | ((pre_cdn_info.median_thr_v[1] & 0xFF) << 24);
+ REG_WR(ISP_PRECDN_MEDIAN_THRUV01, val);
+
+ val = (pre_cdn_info.median_thr & 0x1FF) | ((pre_cdn_info.uv_thr & 0xFF) << 16)
+ | ((pre_cdn_info.y_thr & 0xFF) << 24);
+ REG_WR(ISP_PRECDN_THRYUV, val);
+
+ for (i = 0; i < 3; i++) {
+ val = (pre_cdn_info.r_segu[0][i*2] & 0xFF) | ((pre_cdn_info.r_segu[1][i*2] & 0x7) << 8)
+ | ((pre_cdn_info.r_segu[0][i*2+1] & 0xFF) << 16) | ((pre_cdn_info.r_segu[1][i*2+1] & 0x7) << 24);
+ REG_WR(ISP_PRECDN_SEGU_0 + i * 4, val);
+ }
+
+ val = (pre_cdn_info.r_segu[0][6] & 0xFF) | ((pre_cdn_info.r_segu[1][6] & 0x7) << 8);
+ REG_WR(ISP_PRECDN_SEGU_3, val);
+
+ for (i = 0; i < 3; i++) {
+ val = (pre_cdn_info.r_segv[0][i*2] & 0xFF) | ((pre_cdn_info.r_segv[1][i*2] & 0x7) << 8)
+ | ((pre_cdn_info.r_segv[0][i*2+1] & 0xFF) << 16) | ((pre_cdn_info.r_segv[1][i*2+1] & 0x7) << 24);
+ REG_WR(ISP_PRECDN_SEGV_0 + i * 4, val);
+ }
+
+ val = (pre_cdn_info.r_segv[0][6] & 0xFF) | ((pre_cdn_info.r_segv[1][6] & 0x7) << 8);
+ REG_WR(ISP_PRECDN_SEGV_3, val);
+
+ for (i = 0; i < 3; i++) {
+ val = (pre_cdn_info.r_segy[0][i*2] & 0xFF) | ((pre_cdn_info.r_segy[1][i*2] & 0x7) << 8)
+ | ((pre_cdn_info.r_segy[0][i*2+1] & 0xFF) << 16) | ((pre_cdn_info.r_segy[1][i*2+1] & 0x7) << 24);
+ REG_WR(ISP_PRECDN_SEGY_0 + i * 4, val);
+ }
+
+ val = (pre_cdn_info.r_segy[0][6] & 0xFF) | ((pre_cdn_info.r_segy[1][6] & 0x7) << 8);
+ REG_WR(ISP_PRECDN_SEGY_3, val);
+
+ for (i = 0; i < 3; i++) {
+ val = (pre_cdn_info.r_distw[i*8] & 0x7) | ((pre_cdn_info.r_distw[i*8+1] & 0x7) << 4)
+ | ((pre_cdn_info.r_distw[i*8+2] & 0x7) << 8) | ((pre_cdn_info.r_distw[i*8+3] & 0x7) << 12)
+ | ((pre_cdn_info.r_distw[i*8+4] & 0x7) << 16) | ((pre_cdn_info.r_distw[i*8+5] & 0x7) << 20)
+ | ((pre_cdn_info.r_distw[i*8+6] & 0x7) << 24) | ((pre_cdn_info.r_distw[i*8+7] & 0x7) << 28);
+ REG_WR(ISP_PRECDN_DISTW0 + i * 4, val);
+ }
+
+ val = pre_cdn_info.r_distw[24] & 0x7;
+ REG_WR(ISP_PRECDN_DISTW3, val);
+
+ if (pre_cdn_info.bypass) {
+ REG_OWR(ISP_PRECDN_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_PRECDN_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_yuv_precdn(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_yuv_precdn: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_yuv_precdn: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_YUV_PRECDN_BLOCK:
+ ret = isp_k_yuv_precdn_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_yuv_precdn: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pre_cdn_rgb.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pre_cdn_rgb.c
new file mode 100644
index 00000000..d5bde126
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pre_cdn_rgb.c
@@ -0,0 +1,73 @@
+/*
+ * 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"
+
+static int32_t isp_k_pre_cdn_rgb_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_pre_cdn_rgb_info pcr_info;
+
+ memset(&pcr_info, 0x00, sizeof(pcr_info));
+
+ ret = copy_from_user((void *)&pcr_info, param->property_param, sizeof(pcr_info));
+ if (0 != ret) {
+ printk("isp_k_pre_cdn_rgb_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_PRECNRNEW_CFG, BIT_0, pcr_info.bypass);
+
+ REG_MWR(ISP_PRECNRNEW_CFG, 0x3 << 1, pcr_info.median_mode << 1);
+
+ val = pcr_info.median_thr & 0xFFFF;
+ REG_WR(ISP_PRECNRNEW_MEDIAN_THR, val);
+ val = (pcr_info.thru0 & 0xFFFF) | ((pcr_info.thru1 & 0xFFFF) << 16);
+ REG_WR(ISP_PRECNRNEW_THRU, val);
+ val = (pcr_info.thrv0 & 0xFFFF) | ((pcr_info.thrv1 & 0xFFFF) << 16);
+ REG_WR(ISP_PRECNRNEW_THRV, val);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_pre_cdn_rgb(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_pre_cdn_rgb: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_pre_cdn_rgb: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_PRE_CDN_RGB_BLOCK:
+ ret = isp_k_pre_cdn_rgb_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_pre_cdn_rgb: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_prefilter.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_prefilter.c
new file mode 100644
index 00000000..ea25ccf1
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_prefilter.c
@@ -0,0 +1,73 @@
+/*
+ * 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"
+
+static int32_t isp_k_prefilter_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_prefilter_info_v1 prefilter_info;
+
+ memset(&prefilter_info, 0x00, sizeof(prefilter_info));
+
+ ret = copy_from_user((void *)&prefilter_info, param->property_param, sizeof(prefilter_info));
+ if (0 != ret) {
+ printk("isp_k_prefilter_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (prefilter_info.writeback) {
+ REG_OWR(ISP_PREF_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_PREF_PARAM, BIT_1, 0);
+ }
+
+ REG_WR(ISP_PREF_THRD, prefilter_info.thrd & 0xFF);
+
+ if (prefilter_info.bypass) {
+ REG_OWR(ISP_PREF_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_PREF_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_prefilter(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_prefilter: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_prefilter: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_PREF_BLOCK:
+ ret = isp_k_prefilter_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_prefilter: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pstrz.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pstrz.c
new file mode 100644
index 00000000..0db4e234
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pstrz.c
@@ -0,0 +1,71 @@
+/*
+ * 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"
+
+static int32_t isp_k_posterize_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ struct isp_dev_posterize_info pstrz_info;
+
+ memset(&pstrz_info, 0x00, sizeof(pstrz_info));
+
+ ret = copy_from_user((void *)&pstrz_info, param->property_param, sizeof(pstrz_info));
+ if (0 != ret) {
+ printk("isp_k_posterize_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_PSTRZ_PARAM, BIT_0, pstrz_info.bypass);
+
+ for (i = 0; i < 8; i++) {
+ val = (pstrz_info.posterize_level_out[i] & 0xFF) | ((pstrz_info.posterize_level_top[i] & 0xFF) << 8)
+ | ((pstrz_info.posterize_level_bottom[i] & 0xFF) << 16);
+ REG_WR(ISP_PSTRZ_LEVEL0 + i * 4, val);
+ }
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_posterize(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_posterize: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_posterize: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_POSTERIZE_BLOCK:
+ ret = isp_k_posterize_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_posterize: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pwd.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pwd.c
new file mode 100644
index 00000000..88b6355f
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_pwd.c
@@ -0,0 +1,123 @@
+/*
+ * 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"
+
+static int32_t isp_k_pwd_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_pre_wavelet_info_v1 pwd_info;
+
+ memset(&pwd_info, 0x00, sizeof(pwd_info));
+
+ ret = copy_from_user((void *)&pwd_info, param->property_param, sizeof(pwd_info));
+ if (0 != ret) {
+ printk("isp_k_pwd_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((pwd_info.gain_thrs0 & 0x7FF) << 6) | ((pwd_info.gain_thrs1 & 0x7FF) << 17);
+ REG_MWR(ISP_PWD_PARAM, 0x0FFFFFC0, val);
+
+ val = (pwd_info.bitshift0 & 0x7) | ((pwd_info.bitshift1 & 0xFF) << 3);
+ REG_MWR(ISP_PWD_PARAM1, 0x7FF, val);
+
+ val = (pwd_info.offset & 0xFF) << 11;
+ REG_MWR(ISP_PWD_PARAM1, 0x7F800, val);
+
+ val = (pwd_info.nsr_slope & 0x3FF) << 4;
+ REG_MWR(ISP_PWD_PARAM2, 0x3FF0, val);
+
+ val = pwd_info.lum_ratio & 0xF;
+ REG_MWR(ISP_PWD_PARAM2, 0xF, val);
+
+ val = ((pwd_info.center_pos_x & 0x1FFF) << 12) | (pwd_info.center_pos_y & 0xFFF);
+ REG_WR(ISP_PWD_PARAM3, val);
+
+ val = pwd_info.delta_x2 & 0x3FFFFFF;
+ REG_WR(ISP_PWD_PARAM4, val);
+ val = pwd_info.delta_y2 & 0xFFFFFF;
+ REG_WR(ISP_PWD_PARAM5, val);
+
+ val = pwd_info.r2_thr & 0x3FFFFFF;
+ REG_WR(ISP_PWD_PARAM6, val);
+
+ val = ((pwd_info.p_param1 & 0x1FFF) << 11) | (pwd_info.p_param2 & 0x7FF);
+ REG_WR(ISP_PWD_PARAM7, val);
+
+ val = (pwd_info.addback & 0x7F) << 13;
+ REG_MWR(ISP_PWD_PARAM8, 0xFE000, val);
+
+ val = pwd_info.gain_max_thr & 0x1FFF;
+ REG_MWR(ISP_PWD_PARAM8, 0x1FFF, val);
+
+ val = ((pwd_info.pos_x & 0x1FFF) << 12) | (pwd_info.pos_y & 0xFFF);
+ REG_WR(ISP_PWD_PARAM10, val);
+
+ REG_MWR(ISP_PWD_PARAM, BIT_1, pwd_info.radial_bypass << 1);
+ REG_MWR(ISP_PWD_PARAM, BIT_0, pwd_info.bypass);
+
+ return ret;
+}
+
+static int32_t isp_k_pwd_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size = {0, 0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
+ if (0 != ret) {
+ printk("isp_k_pwd_slice_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.width & 0x1FFF) << 12) | (size.height & 0xFFF);
+ REG_WR(ISP_PWD_PARAM9, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_pwd(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_pwd: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_pwd: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_PWD_BLOCK:
+ ret = isp_k_pwd_block(param);
+ break;
+ case ISP_PRO_PWD_SLICE_SIZE:
+ ret = isp_k_pwd_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_pwd: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_raw_aem.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_raw_aem.c
new file mode 100644
index 00000000..5e4509d5
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_raw_aem.c
@@ -0,0 +1,255 @@
+/*
+ * 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"
+
+static int32_t isp_k_raw_aem_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_raw_aem_info aem_info;
+
+ memset(&aem_info, 0x00, sizeof(aem_info));
+
+ ret = copy_from_user((void *)&aem_info, param->property_param, sizeof(aem_info));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_AEM_PARAM, BIT_0, aem_info.bypass);
+
+ val = (aem_info.shift & 0x1F) << 18;
+ if(0 != val) {
+ printk("isp_k_raw_aem_block: shift error, 0x%x\n", val);
+ }
+ REG_MWR(ISP_AEM_BLK_SIZE, 0x7C0000, 0);
+
+ REG_MWR(ISP_AEM_PARAM, BIT_1, aem_info.mode << 1);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_bypass: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_AEM_PARAM, BIT_0, bypass);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_mode(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t mode = 0;
+
+ ret = copy_from_user((void *)&mode, param->property_param, sizeof(mode));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_mode: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_AEM_PARAM, BIT_1, mode << 1);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_statistics(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0, i = 0;
+ uint32_t val0 = 0, val1 = 0;
+ unsigned long addr = 0;
+ struct isp_raw_aem_statistics *aem_statistics = NULL;
+
+ aem_statistics = (struct isp_raw_aem_statistics *)isp_private->raw_aem_buf_addr;
+ if (!aem_statistics) {
+ ret = -1;
+ printk("isp_k_raw_aem_statistics: alloc memory error.\n");
+ return -1;
+ }
+
+ addr = ISP_RAW_AEM_OUTPUT;
+ for (i = 0x00; i < ISP_RAW_AEM_ITEM; i++) {
+ val0 = REG_RD(addr);
+ val1 = REG_RD(addr + 4);
+ aem_statistics->r[i]= (val1 >> 11) & 0x1fffff;
+ aem_statistics->g[i]= val0 & 0x3fffff;
+ aem_statistics->b[i]= ((val1 & 0x7ff) << 10) | ((val0 >> 22) & 0x3ff);
+ addr += 8;
+ }
+
+ ret = copy_to_user(param->property_param, (void*)aem_statistics, sizeof(struct isp_raw_aem_statistics));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_raw_aem_statistics: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_skip_num(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t skip_num;
+
+ ret = copy_from_user((void *)&skip_num, param->property_param, sizeof(skip_num));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_skip_num: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (skip_num & 0xF) << 4;
+ REG_MWR(ISP_AEM_PARAM, 0xF0, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_shift(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t shift = 0;
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&shift, param->property_param, sizeof(shift));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_shift: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (shift & 0x1F) << 18;
+ if(0 != val) {
+ printk("isp_k_raw_aem_shift: shift error, 0x%x\n", val);
+ }
+ REG_MWR(ISP_AEM_BLK_SIZE, 0x7C0000, 0);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_offset(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct img_offset offset;
+
+ ret = copy_from_user((void *)&offset, param->property_param, sizeof(struct img_offset));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_offset: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((offset.y & 0xFFFF) << 16) | (offset.x & 0xFFFF);
+ REG_WR(ISP_AEM_OFFSET, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_blk_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size size;
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_blk_size: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height & 0x1FF) << 9) | (size.width & 0x1FF);
+ REG_MWR(ISP_AEM_BLK_SIZE, 0x3FFFF, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size size;
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_slice_size: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height & 0xFFFF) << 16) | (size.width & 0xFFFF);
+ REG_WR(ISP_AEM_SLICE_SIZE, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_raw_aem(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_raw_aem: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_raw_aem: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_RAW_AEM_BLOCK:
+ ret = isp_k_raw_aem_block(param);
+ break;
+ case ISP_PRO_RAW_AEM_BYPASS:
+ ret = isp_k_raw_aem_bypass(param);
+ break;
+ case ISP_PRO_RAW_AEM_MODE:
+ ret = isp_k_raw_aem_mode(param);
+ break;
+ case ISP_PRO_RAW_AEM_STATISTICS:
+ ret = isp_k_raw_aem_statistics(param, isp_private);
+ break;
+ case ISP_PRO_RAW_AEM_SKIP_NUM:
+ ret = isp_k_raw_aem_skip_num(param);
+ break;
+ case ISP_PRO_RAW_AEM_SHIFT:
+ ret = isp_k_raw_aem_shift(param);
+ break;
+ case ISP_PRO_RAW_AEM_OFFSET:
+ ret = isp_k_raw_aem_offset(param);
+ break;
+ case ISP_PRO_RAW_AEM_BLK_SIZE:
+ ret = isp_k_raw_aem_blk_size(param);
+ break;
+ case ISP_PRO_RAW_AEM_SLICE_SIZE:
+ ret = isp_k_raw_aem_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_raw_aem: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_raw_afm.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_raw_afm.c
new file mode 100644
index 00000000..b3f97c3f
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_raw_afm.c
@@ -0,0 +1,497 @@
+/*
+ * 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"
+
+#define ISP_AFM_WIN_NUM_V1 25
+static int32_t isp_k_raw_afm_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ int max_num = ISP_AFM_WIN_NUM_V1;
+ struct isp_dev_rgb_afm_info_v1 rafm_info;
+
+ memset(&rafm_info, 0x00, sizeof(rafm_info));
+
+ ret = copy_from_user((void *)&rafm_info, param->property_param, sizeof(rafm_info));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_0, rafm_info.bypass);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_1, rafm_info.mode << 1);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, 0xF<<2, (rafm_info.skip_num << 2));
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_6, rafm_info.skip_num_clear << 6);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_7, rafm_info.spsmd_rtgbot_enable << 7);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_8, rafm_info.spsmd_diagonal_enable << 8);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_9, rafm_info.spsmd_cal_mode << 9);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_10, rafm_info.af_sel_filter1 << 10);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_11, rafm_info.af_sel_filter2 << 11);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_12, rafm_info.sobel_type << 12);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, (BIT_13)|(BIT_14), rafm_info.spsmd_type << 13);
+
+ val = ((rafm_info.sobel_threshold_max << 16) & 0xffff0000)
+ | (rafm_info.sobel_threshold_min & 0xffff);
+ REG_WR(ISP_RGB_AFM_SOBEL_THRESHOLD, val);
+
+ REG_WR(ISP_RGB_AFM_SPSMD_THRESHOLD_MIN, rafm_info.spsmd_threshold_min);
+ REG_WR(ISP_RGB_AFM_SPSMD_THRESHOLD_MAX, rafm_info.spsmd_threshold_max);
+
+ for (i = 0; i < max_num; i++) {
+ val = ((rafm_info.coord[i].start_y <<16) & 0xffff0000)
+ | (rafm_info.coord[i].start_x & 0xffff);
+ REG_WR((ISP_RGB_AFM_WIN_RANGE0 + 4*2*i), val);
+
+ val = ((rafm_info.coord[i].end_y <<16) & 0xffff0000)
+ | (rafm_info.coord[i].end_x & 0xffff);
+ REG_WR((ISP_RGB_AFM_WIN_RANGE0 + 4*(2*i+1)), val);
+ }
+
+ return ret;
+
+}
+
+static int32_t isp_k_raw_afm_frame_range(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size frame_size = {0, 0};
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&frame_size, param->property_param, sizeof(frame_size));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_frame_range: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (frame_size.height & 0xFFFF) | ((frame_size.width & 0xFFFF) << 16);
+ REG_WR(ISP_RGB_AFM_FRAME_RANGE, val);
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_type1_statistic(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ int i = 0;
+ int max_item = ISP_AFM_WIN_NUM_V1;
+ struct isp_raw_afm_statistic item;
+
+ memset(&item, 0, sizeof(struct isp_raw_afm_statistic));
+ for (i = 0; i < max_item; i++) {
+ item.val[i] = REG_RD((ISP_RGB_AFM_TYPE1_VAL00 + 4*i));
+ }
+ ret = copy_to_user(param->property_param, (void*)&item, sizeof(item));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_raw_afm_statistic: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_type2_statistic(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ int i = 0;
+ int max_item = ISP_AFM_WIN_NUM_V1;
+ struct isp_raw_afm_statistic item;
+
+ memset(&item, 0, sizeof(struct isp_raw_afm_statistic));
+ for (i = 0; i < max_item; i++) {
+ item.val[i] = REG_RD((ISP_RGB_AFM_TYPE2_VAL00 + 4*i));
+ }
+ ret = copy_to_user(param->property_param, (void*)&item, sizeof(item));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_raw_afm_statistic: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_bypass: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (bypass) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_mode(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t mode = 0;
+
+ ret = copy_from_user((void *)&mode, param->property_param, sizeof(mode));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_mode: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (mode) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_1, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_skip_num(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t skip_num = 0;
+
+ ret = copy_from_user((void *)&skip_num, param->property_param, sizeof(skip_num));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_skip_num: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_RGB_AFM_PARAM, 0xF<<2, (skip_num <<2));
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_skip_num_clr(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t is_clear = 0;
+
+ ret = copy_from_user((void *)&is_clear, param->property_param, sizeof(is_clear));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_skip_num_clr: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (is_clear) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_6);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_6, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_spsmd_rtgbot_enable(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t is_enable = 0;
+
+ ret = copy_from_user((void *)&is_enable, param->property_param, sizeof(is_enable));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_spsmd_rtgbot_enable: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (is_enable) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_7);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_7, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_spsmd_diagonal_enable(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t is_enable = 0;
+
+ ret = copy_from_user((void *)&is_enable, param->property_param, sizeof(is_enable));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_spsmd_diagonal_enable: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (is_enable) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_8);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_8, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_spsmd_cal_mode(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t cal_mode = 0;
+
+ ret = copy_from_user((void *)&cal_mode, param->property_param, sizeof(cal_mode));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_spsmd_cal_mode: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ if (cal_mode) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_9);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_9, 0);
+ }
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_sel_filter1(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t af_sel_filter = 0;
+
+ ret = copy_from_user((void *)&af_sel_filter, param->property_param, sizeof(af_sel_filter));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_sel_filter1: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ if (af_sel_filter) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_10);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_10, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_sel_filter2(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t af_sel_filter = 0;
+
+ ret = copy_from_user((void *)&af_sel_filter, param->property_param, sizeof(af_sel_filter));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_sel_filter2: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ if (af_sel_filter) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_11);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_11, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_sobel_type(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t sobel_type = 0;
+
+ ret = copy_from_user((void *)&sobel_type, param->property_param, sizeof(sobel_type));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_sel_filter2: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (sobel_type) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_12);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_12, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_spsmd_type(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t spsmd_type = 0;
+
+ ret = copy_from_user((void *)&spsmd_type, param->property_param, sizeof(spsmd_type));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_sel_filter2: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_RGB_AFM_PARAM, (BIT_13)|(BIT_14), spsmd_type<<13);
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_sobel_threshold(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct sobel_thrd sobel_threshold = {0, 0};
+
+ ret = copy_from_user((void *)&sobel_threshold, param->property_param, sizeof(sobel_threshold));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_sel_filter2: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ val = ((sobel_threshold.max<<16) & 0xffff0000)
+ | (sobel_threshold.min & 0xffff);
+ REG_WR(ISP_RGB_AFM_SOBEL_THRESHOLD, val);
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_spsmd_threshold(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct spsmd_thrd spsmd_threshold = {0, 0};
+
+ ret = copy_from_user((void *)&spsmd_threshold, param->property_param, sizeof(spsmd_threshold));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_spsmd_threshold: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ REG_WR(ISP_RGB_AFM_SPSMD_THRESHOLD_MIN, spsmd_threshold.min);
+ REG_WR(ISP_RGB_AFM_SPSMD_THRESHOLD_MAX, spsmd_threshold.max);
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_win(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ int i = 0;
+ int max_num = ISP_AFM_WIN_NUM_V1;
+ struct isp_coord coord[ISP_AFM_WIN_NUM_V1];
+ uint32_t val = 0;
+
+
+ memset(coord, 0, sizeof(coord));
+ ret = copy_from_user((void *)&coord, param->property_param, sizeof(coord));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_win: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ for (i = 0; i < max_num; i++) {
+ val = ((coord[i].start_y <<16) & 0xffff0000)
+ | (coord[i].start_x & 0xffff);
+ REG_WR((ISP_RGB_AFM_WIN_RANGE0 + 4*2*i), val);
+
+ val = ((coord[i].end_y <<16) & 0xffff0000)
+ | (coord[i].end_x & 0xffff);
+ REG_WR((ISP_RGB_AFM_WIN_RANGE0 + 4*(2*i+1)), val);
+ }
+
+ return ret;
+}
+
+
+static int32_t isp_k_raw_afm_win_num(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t num = ISP_AFM_WIN_NUM_V1;
+
+ ret = copy_to_user(param->property_param, (void*)&num, sizeof(num));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_raw_afm_win_num: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_rgb_afm(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_afm: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_afm: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_RGB_AFM_BLOCK:
+ ret = isp_k_raw_afm_block(param);
+ break;
+ case ISP_PRO_RGB_AFM_FRAME_SIZE:
+ ret = isp_k_raw_afm_frame_range(param);
+ break;
+ case ISP_PRO_RGB_AFM_TYPE1_STATISTIC:
+ ret = isp_k_raw_afm_type1_statistic(param);
+ break;
+ case ISP_PRO_RGB_AFM_TYPE2_STATISTIC:
+ ret = isp_k_raw_afm_type2_statistic(param);
+ break;
+ case ISP_PRO_RGB_AFM_BYPASS:
+ ret = isp_k_raw_afm_bypass(param);
+ break;
+ case ISP_PRO_RGB_AFM_MODE:
+ ret = isp_k_raw_afm_mode(param);
+ break;
+ case ISP_PRO_RGB_AFM_SKIP_NUM:
+ ret = isp_k_raw_afm_skip_num(param);
+ break;
+ case ISP_PRO_RGB_AFM_SKIP_NUM_CLR:
+ ret = isp_k_raw_afm_skip_num_clr(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_RTGBOT_ENABLE:
+ ret = isp_k_raw_afm_spsmd_rtgbot_enable(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_DIAGONAL_ENABLE:
+ ret = isp_k_raw_afm_spsmd_diagonal_enable(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_CAL_MOD:
+ ret = isp_k_raw_afm_spsmd_cal_mode(param);
+ break;
+ case ISP_PRO_RGB_AFM_SEL_FILTER1:
+ ret = isp_k_raw_afm_sel_filter1(param);
+ break;
+ case ISP_PRO_RGB_AFM_SEL_FILTER2:
+ ret = isp_k_raw_afm_sel_filter2(param);
+ break;
+ case ISP_PRO_RGB_AFM_SOBEL_TYPE:
+ ret = isp_k_raw_afm_sobel_type(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_TYPE:
+ ret = isp_k_raw_afm_spsmd_type(param);
+ break;
+ case ISP_PRO_RGB_AFM_SOBEL_THRESHOLD:
+ ret = isp_k_raw_afm_sobel_threshold(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_THRESHOLD:
+ ret = isp_k_raw_afm_spsmd_threshold(param);
+ break;
+ case ISP_PRO_RGB_AFM_WIN:
+ ret = isp_k_raw_afm_win(param);
+ break;
+ case ISP_PRO_RGB_AFM_WIN_NUM:
+ ret = isp_k_raw_afm_win_num(param);
+ break;
+ default:
+ printk("isp_k_cfg_afm: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb2y.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb2y.c
new file mode 100644
index 00000000..3cc48264
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb2y.c
@@ -0,0 +1,62 @@
+/*
+ * 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"
+
+static int32_t isp_k_rgb2y_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_rgb2y_info rgb2y_info;
+
+ memset(&rgb2y_info, 0x00, sizeof(rgb2y_info));
+
+ ret = copy_from_user((void *)&rgb2y_info, param->property_param, sizeof(rgb2y_info));
+ if (0 != ret) {
+ printk("isp_k_rgb2y_block: copy error, ret = 0x%x \n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_Y_RGB2Y_PARAM, 0x3, rgb2y_info.signal_sel);
+
+ return -1;
+}
+
+int32_t isp_k_cfg_rgb2y(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_rgb2y: param is null error \n");
+ return -1;
+ }
+
+ if (!param->property_param) {
+ printk("isp_k_cfg_rgb2y: property_param is null error \n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_RGB2Y_BLOCK:
+ ret = isp_k_rgb2y_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_rgb2y: fail cmd id %d, not supported \n", param->property);
+ break;
+ }
+
+ return ret;
+} \ No newline at end of file
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb_afm.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb_afm.c
new file mode 100644
index 00000000..25f8326b
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb_afm.c
@@ -0,0 +1,415 @@
+/*
+ * 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"
+
+
+#define ISP_AFM_WIN_NUM_V1 25
+
+static int32_t isp_k_rgb_afm_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_bypass: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (bypass) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_mode(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t mode = 0;
+
+ ret = copy_from_user((void *)&mode, param->property_param, sizeof(mode));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_mode: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (mode) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_1, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_skip_num(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t skip_num = 0;
+
+ ret = copy_from_user((void *)&skip_num, param->property_param, sizeof(skip_num));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_skip_num: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_RGB_AFM_PARAM, 0xF<<2, (skip_num <<2));
+
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_skip_num_clr(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t is_clear = 0;
+
+ ret = copy_from_user((void *)&is_clear, param->property_param, sizeof(is_clear));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_skip_num_clr: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (is_clear) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_6);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_6, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_spsmd_rtgbot_enable(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t is_enable = 0;
+
+ ret = copy_from_user((void *)&is_enable, param->property_param, sizeof(is_enable));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_spsmd_rtgbot_enable: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (is_enable) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_7);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_7, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_spsmd_diagonal_enable(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t is_enable = 0;
+
+ ret = copy_from_user((void *)&is_enable, param->property_param, sizeof(is_enable));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_spsmd_diagonal_enable: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (is_enable) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_8);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_8, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_spsmd_cal_mode(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t cal_mode = 0;
+
+ ret = copy_from_user((void *)&cal_mode, param->property_param, sizeof(cal_mode));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_spsmd_cal_mode: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ if (cal_mode) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_9);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_9, 0);
+ }
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_sel_filter1(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t af_sel_filter = 0;
+
+ ret = copy_from_user((void *)&af_sel_filter, param->property_param, sizeof(af_sel_filter));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_sel_filter1: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ if (af_sel_filter) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_10);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_10, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_sel_filter2(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t af_sel_filter = 0;
+
+ ret = copy_from_user((void *)&af_sel_filter, param->property_param, sizeof(af_sel_filter));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_sel_filter2: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ if (af_sel_filter) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_11);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_11, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_sobel_type(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t sobel_type = 0;
+
+ ret = copy_from_user((void *)&sobel_type, param->property_param, sizeof(sobel_type));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_sel_filter2: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (sobel_type) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_12);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_12, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_spsmd_type(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t spsmd_type = 0;
+
+ ret = copy_from_user((void *)&spsmd_type, param->property_param, sizeof(spsmd_type));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_sel_filter2: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_RGB_AFM_PARAM, (BIT_13)|(BIT_14), spsmd_type<<13);
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_sobel_threshold(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct sobel_thrd sobel_threshold = {0, 0};
+
+ ret = copy_from_user((void *)&sobel_threshold, param->property_param, sizeof(sobel_threshold));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_sel_filter2: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ val = ((sobel_threshold.max<<16) & 0xffff0000)
+ | (sobel_threshold.min & 0xffff);
+ REG_WR(ISP_RGB_AFM_SOBEL_THRESHOLD, val);
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_spsmd_threshold(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct spsmd_thrd spsmd_threshold = {0, 0};
+
+ ret = copy_from_user((void *)&spsmd_threshold, param->property_param, sizeof(spsmd_threshold));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_spsmd_threshold: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ REG_WR(ISP_RGB_AFM_SPSMD_THRESHOLD_MIN, spsmd_threshold.min);
+ REG_WR(ISP_RGB_AFM_SPSMD_THRESHOLD_MAX, spsmd_threshold.max);
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_frame_range(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct frm_size frame_size = {0, 0};
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&frame_size, param->property_param, sizeof(frame_size));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_frame_range: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (frame_size.height & 0xFFFF) | ((frame_size.width & 0xFFFF) << 16);
+ REG_WR(ISP_RGB_AFM_FRAME_RANGE, val);
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_win(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ int i = 0;
+ int max_num = ISP_AFM_WIN_NUM_V1;
+ struct isp_coord coord[ISP_AFM_WIN_NUM_V1];
+ uint32_t val = 0;
+
+
+ memset(coord, 0, sizeof(coord));
+ ret = copy_from_user((void *)&coord, param->property_param, sizeof(coord));
+ if (0 != ret) {
+ printk("isp_k_rgb_afm_win: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ for (i = 0; i < max_num; i++) {
+ val = ((coord[i].start_y <<16) & 0xffff0000)
+ | (coord[i].start_x & 0xffff);
+ REG_WR((ISP_RGB_AFM_WIN_RANGE0 + 4*2*i), val);
+
+ val = ((coord[i].end_y <<16) & 0xffff0000)
+ | (coord[i].end_x & 0xffff);
+ REG_WR((ISP_RGB_AFM_WIN_RANGE0 + 4*(2*i+1)), val);
+ }
+
+ return ret;
+}
+
+
+static int32_t isp_k_rgb_afm_statistic(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ int i = 0;
+ int max_item = ISP_AFM_WIN_NUM_V1;
+ struct afm_statistic item[ISP_AFM_WIN_NUM_V1];
+ uint32_t val = 0;
+ memset(item, 0, sizeof(item));
+ for (i = 0; i < max_item; i++) {
+ val = REG_RD((ISP_RGB_AFM_TYPE1_VAL00 + 4*i));
+ item[i].val = val;
+ }
+ ret = copy_to_user(param->property_param, (void*)&item, sizeof(item));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_rgb_afm_statistic: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_rgb_afm_win_num(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t num = ISP_AFM_WIN_NUM_V1;
+
+ ret = copy_to_user(param->property_param, (void*)&num, sizeof(num));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_rgb_afm_win_num: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_rgb_afm(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_afm: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_afm: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_RGB_AFM_BYPASS:
+ ret = isp_k_rgb_afm_bypass(param);
+ break;
+ case ISP_PRO_RGB_AFM_MODE:
+ ret = isp_k_rgb_afm_mode(param);
+ break;
+ case ISP_PRO_RGB_AFM_SKIP_NUM:
+ ret = isp_k_rgb_afm_skip_num(param);
+ break;
+ case ISP_PRO_RGB_AFM_SKIP_NUM_CLR:
+ ret = isp_k_rgb_afm_skip_num_clr(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_RTGBOT_ENABLE:
+ ret = isp_k_rgb_afm_spsmd_rtgbot_enable(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_DIAGONAL_ENABLE:
+ ret = isp_k_rgb_afm_spsmd_diagonal_enable(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_CAL_MOD:
+ ret = isp_k_rgb_afm_spsmd_cal_mode(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_SEL_FILTER1:
+ ret = isp_k_rgb_afm_sel_filter1(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_SEL_FILTER2:
+ ret = isp_k_rgb_afm_sel_filter2(param);
+ break;
+ case ISP_PRO_RGB_AFM_SOBEL_TYPE:
+ ret = isp_k_rgb_afm_sobel_type(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_TYPE:
+ ret = isp_k_rgb_afm_spsmd_type(param);
+ break;
+ case ISP_PRO_RGB_AFM_SOBEL_THRESHOLD:
+ ret = isp_k_rgb_afm_sobel_threshold(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_THRESHOLD:
+ ret = isp_k_rgb_afm_spsmd_threshold(param);
+ break;
+ case ISP_PRO_RGB_AFM_FRAME_RANGE:
+ ret = isp_k_rgb_afm_frame_range(param);
+ break;
+ case ISP_PRO_RGB_AFM_WIN:
+ ret = isp_k_rgb_afm_win(param);
+ break;
+ case ISP_PRO_RGB_AFM_STATISTIC:
+ ret = isp_k_rgb_afm_statistic(param);
+ break;
+ case ISP_PRO_RGB_AFM_WIN_NUM:
+ ret = isp_k_rgb_afm_win_num(param);
+ break;
+ default:
+ printk("isp_k_cfg_afm: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb_gain.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb_gain.c
new file mode 100644
index 00000000..5cc2c554
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb_gain.c
@@ -0,0 +1,69 @@
+/*
+ * 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"
+
+static int32_t isp_k_rgb_gain_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_rgb_gain_info_v1 gain_info;
+
+ ret = copy_from_user((void *)&gain_info, param->property_param, sizeof(gain_info));
+ if (0 != ret) {
+ printk("isp_k_rgb_gain_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (gain_info.global_gain & 0xFFFF) << 16;
+ REG_MWR(ISP_RGBG_PARAM, 0xFFFF0000, val);
+
+ val = ((gain_info.r_gain & 0xFFFF) << 16) | (gain_info.b_gain & 0xFFFF);
+ REG_WR(ISP_RGBG_RB, val);
+ val = gain_info.g_gain & 0xFFFF;
+ REG_WR(ISP_RGBG_G, val);
+
+ REG_MWR(ISP_RGBG_PARAM, BIT_0, gain_info.bypass);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_rgb_gain(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_rgb_gain: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_rgb_gain: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_RGB_GAIN_BLOCK:
+ ret = isp_k_rgb_gain_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_rgb_gain: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb_gain2.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb_gain2.c
new file mode 100644
index 00000000..a8b31537
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_rgb_gain2.c
@@ -0,0 +1,67 @@
+/*
+ * 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"
+
+static int32_t isp_k_rgb_gain2_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_rgb_gain2_info gain_info;
+
+ ret = copy_from_user((void *)&gain_info, param->property_param, sizeof(gain_info));
+ if (0 != ret) {
+ printk("isp_k_rgb_gain2_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((gain_info.r_gain & 0xFF) << 24) | ((gain_info.g_gain & 0xFF) << 16) | ((gain_info.b_gain & 0xFF) << 8);
+ REG_MWR(ISP_RGBG2_PARAM, 0xFFFFFF00, val);
+
+ val = ((gain_info.r_offset & 0x3FF) << 20) | ((gain_info.g_offset & 0x3FF) << 10) | (gain_info.b_offset & 0x3FF);
+ REG_WR(ISP_RGBG2_OFFSET, val);
+
+ REG_MWR(ISP_RGBG2_PARAM, BIT_0, gain_info.bypass);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_rgb_gain2(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_rgb_gain2: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_rgb_gain2: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_RGB_GAIN2_BLOCK:
+ ret = isp_k_rgb_gain2_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_rgb_gain2: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_store.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_store.c
new file mode 100644
index 00000000..2ae73bec
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_store.c
@@ -0,0 +1,101 @@
+/*
+ * 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"
+
+static int32_t isp_k_store_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_store_info_v1 store_info;
+
+ memset(&store_info, 0x00, sizeof(store_info));
+
+ ret = copy_from_user((void *)&store_info, param->property_param, sizeof(store_info));
+ if (0 != ret) {
+ printk("isp_k_store_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (store_info.substract) {
+ REG_OWR(ISP_STORE_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_STORE_PARAM, BIT_1, 0);
+ }
+
+ REG_MWR(ISP_STORE_PARAM, 0xF0, (store_info.color_format << 4));
+
+ REG_WR(ISP_STORE_Y_ADDR, store_info.addr.chn0);
+ REG_WR(ISP_STORE_Y_PITCH, store_info.pitch.chn0);
+ REG_WR(ISP_STORE_U_ADDR, store_info.addr.chn1);
+ REG_WR(ISP_STORE_U_PITCH, store_info.pitch.chn1);
+ REG_WR(ISP_STORE_V_ADDR, store_info.addr.chn2);
+ REG_WR(ISP_STORE_V_PITCH, store_info.pitch.chn2);
+
+ if (store_info.bypass) {
+ REG_OWR(ISP_STORE_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_STORE_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_store_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size = {0, 0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(size));
+ if (0 != ret) {
+ printk("isp_k_store_slice_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height& 0xFFFF) << 16) | (size.width & 0xFFFF);
+ REG_WR(ISP_STORE_SLICE_SIZE, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_store(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_store: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_store: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_STORE_BLOCK:
+ ret = isp_k_store_block(param);
+ break;
+ case ISP_PRO_STORE_SLICE_SIZE:
+ ret = isp_k_store_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_store: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_uv_prefilter.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_uv_prefilter.c
new file mode 100644
index 00000000..7ee3dc90
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_uv_prefilter.c
@@ -0,0 +1,68 @@
+/*
+ * 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"
+
+static int32_t isp_k_uv_prefilter_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_uv_prefilter_info uv_info;
+
+ memset(&uv_info, 0x00, sizeof(uv_info));
+
+ ret = copy_from_user((void *)&uv_info, param->property_param, sizeof(uv_info));
+ if (0 != ret) {
+ printk("isp_k_uv_prefilter_block: copy error, ret = 0x%x \n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_UV_PREF_PARAM, BIT_1, uv_info.writeback << 1);
+
+ val = (uv_info.nr_thr_u & 0xFF) | ((uv_info.nr_thr_v & 0xFF) << 8);
+ REG_WR(ISP_UV_PREF_THRD, val);
+
+ REG_MWR(ISP_UV_PREF_PARAM, BIT_0, uv_info.bypass);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_uv_prefilter(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_uv_prefilter: param is null error \n");
+ return -1;
+ }
+
+ if (!param->property_param) {
+ printk("isp_k_cfg_uv_prefilter: property_param is null error \n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_UV_PREFILTER_BLOCK:
+ ret = isp_k_uv_prefilter_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_uv_prefilter: fail cmd id %d, not supported \n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_y_delay.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_y_delay.c
new file mode 100644
index 00000000..b735c790
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_y_delay.c
@@ -0,0 +1,63 @@
+/*
+ * 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"
+
+static int32_t isp_k_ydelay_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_ydelay_info ydelay_info;
+
+ ret = copy_from_user((void *)&ydelay_info, param->property_param, sizeof(ydelay_info));
+ if (0 != ret) {
+ printk("isp_k_ydelay_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (ydelay_info.bypass) {
+ REG_OWR(ISP_YDELAY_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_YDELAY_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_ydelay(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_ydelay: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_ydelay: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_YDELAY_BLOCK:
+ ret = isp_k_ydelay_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_ydelay: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
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;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_yiq_aem.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_yiq_aem.c
new file mode 100644
index 00000000..fe8710a9
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_yiq_aem.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"
+
+static int32_t isp_k_yiq_aem_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_yiq_aem_info_v2 yaem_info;
+
+ memset(&yaem_info, 0x00, sizeof(yaem_info));
+
+ ret = copy_from_user((void *)&yaem_info, param->property_param, sizeof(yaem_info));
+ if (0 != ret) {
+ printk("isp_k_yiq_aem_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_YIQ_AEM_PARAM, BIT_7, yaem_info.ygamma_bypass << 7);
+
+ val = ((yaem_info.gamma_xnode[0] & 0xFF)<<24) | ((yaem_info.gamma_xnode[1] & 0xFF)<<16)
+ | ((yaem_info.gamma_xnode[2] & 0xFF)<<8) | (yaem_info.gamma_xnode[3] & 0xFF);
+ REG_WR(ISP_YIQ_YGAMMA_NODE_X0 , val);
+ val = ((yaem_info.gamma_xnode[4] & 0xFF)<<24) | ((yaem_info.gamma_xnode[5] & 0xFF)<<16)
+ | ((yaem_info.gamma_xnode[6] & 0xFF)<<8) | (yaem_info.gamma_xnode[7] & 0xFF);
+ REG_WR(ISP_YIQ_YGAMMA_NODE_X1 , val);
+
+ val = ((yaem_info.gamma_ynode[0] & 0xFF)<<24) | ((yaem_info.gamma_ynode[1] & 0xFF)<<16)
+ | ((yaem_info.gamma_ynode[2] & 0xFF)<<8) | (yaem_info.gamma_ynode[3] & 0xFF);
+ REG_WR( ISP_YIQ_YGAMMA_NODE_Y0 , val);
+ val = ((yaem_info.gamma_ynode[4] & 0xFF)<<24) | ((yaem_info.gamma_ynode[5] & 0xFF)<<16)
+ | ((yaem_info.gamma_ynode[6] & 0xFF)<<8) | (yaem_info.gamma_ynode[7] & 0xFF);
+ REG_WR(ISP_YIQ_YGAMMA_NODE_Y1 , val);
+ val = ((yaem_info.gamma_ynode[8] & 0xFF)<<24) | ((yaem_info.gamma_ynode[9] & 0xFF)<<16);
+ REG_WR(ISP_YIQ_YGAMMA_NODE_Y2 , val);
+
+ val = ((yaem_info.gamma_node_idx[1]&0x7) << 24) | ((yaem_info.gamma_node_idx[2]&0x7) << 21) |
+ ((yaem_info.gamma_node_idx[3]&0x7) << 18) | ((yaem_info.gamma_node_idx[4]&0x7) << 15) |
+ ((yaem_info.gamma_node_idx[5]&0x7) << 12) | ((yaem_info.gamma_node_idx[6]&0x7) << 9) |
+ ((yaem_info.gamma_node_idx[7]&0x7) << 6) | ((yaem_info.gamma_node_idx[8]&0x7) << 3) |
+ (yaem_info.gamma_node_idx[9]&0x7);
+ REG_WR( ISP_YIQ_YGAMMA_NODE_IDX, val);
+
+ REG_MWR(ISP_YIQ_AEM_PARAM, BIT_0, yaem_info.aem_bypass);
+
+ REG_MWR(ISP_YIQ_AEM_PARAM, BIT_1, yaem_info.aem_mode << 1);
+
+ REG_MWR(ISP_YIQ_AEM_PARAM, 0xF << 2, yaem_info.aem_skip_num << 2);
+
+ val = (yaem_info.offset_x & 0xFFFF) | ((yaem_info.offset_y & 0xFFFF) << 16);
+ REG_WR( ISP_YIQ_AEM_OFFSET, val);
+
+ val = (yaem_info.width& 0x1FF) | ((yaem_info.height& 0x1FF) << 9) | ((yaem_info.avgshift & 0x1F) << 18);
+ REG_WR( ISP_YIQ_AEM_BLK_SIZE, val);
+
+ return ret;
+
+}
+
+static int32_t isp_k_yiq_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size slice_size= {0, 0};
+
+ ret = copy_from_user((void *)&slice_size, param->property_param, sizeof(slice_size));
+ if (0 != ret) {
+ printk("isp_k_ae_skip_num: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (slice_size.width& 0xFFFF) | ((slice_size.height& 0xFFFF) << 16);
+ REG_WR( ISP_YIQ_AEM_SLICE_SIZE, val);
+
+
+ return ret;
+}
+
+int32_t isp_k_cfg_yiq_aem(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_yiq: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_yiq: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_YIQ_AEM_BLOCK:
+ ret = isp_k_yiq_aem_block(param);
+ break;
+ case ISP_PRO_YIQ_AEM_SLICE_SIZE:
+ ret = isp_k_yiq_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_yiq: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_yiq_afm.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_yiq_afm.c
new file mode 100644
index 00000000..20df0101
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_yiq_afm.c
@@ -0,0 +1,120 @@
+/*
+ * 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"
+
+#define ISP_AFM_WIN_NUM_V1 25
+
+static int32_t isp_k_yiq_afm_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ int max_num = ISP_AFM_WIN_NUM_V1;
+ struct isp_dev_yiq_afm_info_v2 afm_info;
+
+ memset(&afm_info, 0x00, sizeof(afm_info));
+
+ ret = copy_from_user((void *)&afm_info, param->property_param, sizeof(afm_info));
+ if (0 != ret) {
+ printk("isp_k_yiq_afm_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, BIT_6, afm_info.mode << 6);
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, 0x1F<<1, (afm_info.shift << 1));
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, 0xF<<7, (afm_info.skip_num << 7));
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, BIT_11, afm_info.skip_num_clear << 11);
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, BIT_12, afm_info.af_position << 12);
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, 0x7<<13, (afm_info.format << 13));
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, BIT_16, afm_info.iir_bypass << 16);
+
+ for (i = 0; i < max_num; i++) {
+ val = ((afm_info.coord[i].start_y <<16) & 0xffff0000)
+ | (afm_info.coord[i].start_x & 0xffff);
+ REG_WR((ISP_YIQ_AFM_WIN_RANGE0 + 4*2*i), val);
+
+ val = ((afm_info.coord[i].end_y <<16) & 0xffff0000)
+ | (afm_info.coord[i].end_x & 0xffff);
+ REG_WR((ISP_YIQ_AFM_WIN_RANGE0 + 4*(2*i+1)), val);
+ }
+
+ for (i = 0; i < 10; i+= 2) {
+ val = (afm_info.IIR_c[i] & 0xFFF) | ((afm_info.IIR_c[i + 1] & 0xFFF) << 16);
+ REG_WR(ISP_YIQ_AFM_COEF0_1 + (i / 2) * 4, val);
+ }
+ val = afm_info.IIR_c[10] & 0xFFF;
+ REG_WR(ISP_YIQ_AFM_COEF10, val);
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, BIT_0, afm_info.bypass);
+
+ return ret;
+
+}
+
+static int32_t isp_k_yiq_afm_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size slice_size= {0, 0};
+
+ ret = copy_from_user((void *)&slice_size, param->property_param, sizeof(slice_size));
+ if (0 != ret) {
+ printk("isp_k_ae_skip_num: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (slice_size.width& 0xFFFF) | ((slice_size.height& 0xFFFF) << 16);
+ REG_WR( ISP_YIQ_AFM_SLICE_SIZE, val);
+
+
+ return ret;
+}
+
+int32_t isp_k_cfg_yiq_afm(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_afm: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_afm: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_YIQ_AFM_BLOCK:
+ ret = isp_k_yiq_afm_block(param);
+ break;
+ case ISP_PRO_YIQ_AFM_SLICE_SIZE:
+ ret = isp_k_yiq_afm_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_yiq_afm: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_yuv_nlm.c b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_yuv_nlm.c
new file mode 100644
index 00000000..d0b5d063
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/pike/src/isp_k_yuv_nlm.c
@@ -0,0 +1,135 @@
+/*
+ * 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"
+
+static int32_t isp_k_yuv_nlm_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t i =0;
+ uint32_t val = 0;
+ struct isp_dev_yuv_nlm_info ynlm_info;
+
+ memset(&ynlm_info, 0x00, sizeof(ynlm_info));
+
+ ret = copy_from_user((void *)&ynlm_info, param->property_param, sizeof(ynlm_info));
+ if (0 != ret) {
+ printk("isp_k_yuv_nlm_block: copy error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_YNLM_PARAM, BIT_0, ynlm_info.nlm_bypass);
+ REG_MWR(ISP_YNLM_PARAM, BIT_1, ynlm_info.nlm_radial_bypass << 1);
+ REG_MWR(ISP_YNLM_PARAM, BIT_2, ynlm_info.nlm_adaptive_bypass << 2);
+ REG_MWR(ISP_YNLM_PARAM, BIT_3, ynlm_info.nlm_vst_bypass << 3);
+
+ for (i = 0;i < 7; i++) {
+ val = (ynlm_info.edge_str_cmp[i] & 0x3FF) | ((ynlm_info.edge_str_req[i] & 0x7F) << 10);
+ REG_WR(ISP_YNLM_ADAPT_PARAM1 + i * 4, val);
+ }
+
+ val = (ynlm_info.edge_range_l & 0xFF) | ((ynlm_info.edge_range_h & 0xFF) << 8) |
+ ((ynlm_info.edge_time_str & 0x3) << 16) | ((ynlm_info.avg_mode & 0x3) << 18);
+ REG_WR(ISP_YNLM_ADAPT_PARAM8, val);
+
+ REG_MWR(ISP_YNLM_DEN_STERNGTH, 0x7F, ynlm_info.den_strength);
+
+ val = (ynlm_info.center_x & 0x1FFF) | ((ynlm_info.center_y & 0xFFF) << 13);
+ REG_WR(ISP_YNLM_CENTER, val);
+
+ val = ynlm_info.center_x2 & 0x3FFFFFF;
+ REG_WR(ISP_YNLM_CENTER_X2, val);
+
+ val = ynlm_info.center_y2 & 0xFFFFFF;
+ REG_WR(ISP_YNLM_CENTER_Y2, val);
+
+ val = ynlm_info.radius & 0x3FFFFFF;
+ REG_WR(ISP_YNLM_RADIUS, val);
+
+ val = (ynlm_info.radius_p1 & 0x7FF) | ((ynlm_info.radius_p2 & 0x3FFF) << 11);
+ REG_WR(ISP_YNLM_RADIUS_RANGE, val);
+
+ val = ynlm_info.gain_max & 0xFFF;
+ REG_WR(ISP_YNLM_GAIN_MAX, val);
+
+ val = (ynlm_info.start_raw & 0xFFF) | ((ynlm_info.start_col & 0x1FFF) << 12);
+ REG_WR(ISP_YNLM_IMG_PARAM1, val);
+
+ val = ynlm_info.add_back & 0x7F;
+ REG_WR(ISP_YNLM_ADD_BACK, val);
+
+ for (i = 0; i < 24; i++) {
+ val = ynlm_info.lut_w[i] & 0x3FFFFFFF;
+ REG_WR(ISP_YNLM_LUT_W_0 + i * 4, val);
+ }
+
+ for (i = 0; i < 64; i++) {
+ val = ynlm_info.lut_vs[i];
+ REG_WR(ISP_YNLM_LUT_VS_0 + i * 4, val);
+ }
+
+ REG_WR(ISP_YNLM_IMG_PARAM0, (((2592 & 0xFFF) << 12) | (1944 & 0xFFF)));
+
+ return ret;
+
+}
+
+static int32_t isp_k_yuv_nlm_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size slice_size;
+
+ ret = copy_from_user((void *)&slice_size, param->property_param, sizeof(slice_size));
+ if (0 != ret) {
+ printk("isp_k_yuv_nlm_slice_size: copy_from_user error, ret = 0x%x\n",(uint32_t)ret);
+ return -1;
+ }
+
+ val = (slice_size.height & 0xFFF) | ((slice_size.width & 0x1FFF) << 12);
+ REG_WR(ISP_YNLM_IMG_PARAM0, val);
+
+ return -1;
+}
+
+int32_t isp_k_cfg_yuv_nlm(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_yuv_nlm: param is null error \n");
+ return -1;
+ }
+
+ if (!param->property_param) {
+ printk("isp_k_cfg_yuv_nlm: property_param is null error \n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_YUV_NLM_BLOCK:
+ ret = isp_k_yuv_nlm_block(param);
+ break;
+ case ISP_PRO_YUV_NLM_SLICE_SIZE:
+ ret = isp_k_yuv_nlm_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_yuv_nlm: fail cmd id is %d, not supported \n", param->property);
+ break;
+ }
+
+ return ret;
+} \ No newline at end of file
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/inc/isp_block.h b/drivers/media/sprd_isp/isp2.0/tshark2/inc/isp_block.h
new file mode 100644
index 00000000..0a18650c
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/inc/isp_block.h
@@ -0,0 +1,67 @@
+/*
+ * 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 "isp_drv.h"
+
+int32_t isp_k_cfg_pgg(struct isp_io_param *param);
+int32_t isp_k_cfg_blc(struct isp_io_param *param);
+int32_t isp_k_cfg_rgb_gain(struct isp_io_param *param);
+int32_t isp_k_cfg_pwd(struct isp_io_param *param);
+int32_t isp_k_cfg_nlc(struct isp_io_param *param);
+int32_t isp_k_cfg_2d_lsc(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_1d_lsc(struct isp_io_param *param);
+int32_t isp_k_cfg_binning(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_awb(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_raw_aem(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_bpc(struct isp_io_param *param);
+int32_t isp_k_cfg_bdn(struct isp_io_param *param);
+int32_t isp_k_cfg_grgb(struct isp_io_param *param);
+int32_t isp_k_cfg_rgb_gain2(struct isp_io_param *param);
+int32_t isp_k_cfg_nlm(struct isp_io_param *param);
+int32_t isp_k_cfg_cfa(struct isp_io_param *param);
+int32_t isp_k_cfg_cmc10(struct isp_io_param *param);
+int32_t isp_k_cfg_gamma(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_cmc8(struct isp_io_param *param);
+int32_t isp_k_cfg_ct(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_hsv(struct isp_io_param *param);
+int32_t isp_k_cfg_rgb_afm(struct isp_io_param *param);
+int32_t isp_k_cfg_cce(struct isp_io_param *param);
+int32_t isp_k_cfg_pre_cdn_rgb(struct isp_io_param *param);
+int32_t isp_k_cfg_yuv_precdn(struct isp_io_param *param);
+int32_t isp_k_cfg_posterize(struct isp_io_param *param);
+int32_t isp_k_cfg_csc(struct isp_io_param *param);
+int32_t isp_k_cfg_yiq_aem(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_anti_flicker(struct isp_io_param *param, struct isp_k_private *isp_private);
+int32_t isp_k_cfg_yiq_afm(struct isp_io_param *param);
+int32_t isp_k_cfg_prefilter(struct isp_io_param *param);
+int32_t isp_k_cfg_brightness(struct isp_io_param *param);
+int32_t isp_k_cfg_contrast(struct isp_io_param *param);
+int32_t isp_k_cfg_hist(struct isp_io_param *param);
+int32_t isp_k_cfg_hist2(struct isp_io_param *param);
+int32_t isp_k_cfg_aca(struct isp_io_param *param);
+int32_t isp_k_cfg_yuv_cdn(struct isp_io_param *param);
+int32_t isp_k_cfg_edge(struct isp_io_param *param);
+int32_t isp_k_cfg_css(struct isp_io_param *param);
+int32_t isp_k_cfg_csa(struct isp_io_param *param);
+int32_t isp_k_cfg_post_cdn(struct isp_io_param *param);
+int32_t isp_k_cfg_hue(struct isp_io_param *param);
+int32_t isp_k_cfg_emboss(struct isp_io_param *param);
+int32_t isp_k_cfg_ydelay(struct isp_io_param *param);
+int32_t isp_k_cfg_ygamma(struct isp_io_param *param, struct isp_k_private *isp_private);;
+int32_t isp_k_cfg_iircnr(struct isp_io_param *param);
+int32_t isp_k_cfg_fetch(struct isp_io_param *param);
+int32_t isp_k_cfg_store(struct isp_io_param *param);
+int32_t isp_k_cfg_dispatch(struct isp_io_param *param);
+int32_t isp_k_cfg_arbiter(struct isp_io_param *param);
+int32_t isp_k_cfg_common(struct isp_io_param *param);
+int32_t isp_k_cfg_raw_sizer(struct isp_io_param *param); \ No newline at end of file
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/inc/isp_drv.h b/drivers/media/sprd_isp/isp2.0/tshark2/inc/isp_drv.h
new file mode 100644
index 00000000..444a1b27
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/inc/isp_drv.h
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+#ifndef _ISP_DRV_HEADER_
+#define _ISP_DRV_HEADER_
+
+#include <linux/semaphore.h>
+#include <linux/spinlock_types.h>
+
+#define ISP_QUEUE_LENGTH 16
+#define ISP_BING4AWB_NUM 2
+
+
+struct isp_node {
+ uint32_t irq_val0;
+ uint32_t irq_val1;
+ uint32_t irq_val2;
+ uint32_t irq_val3;
+ uint32_t reserved;
+ struct isp_time time;
+};
+
+struct isp_queue {
+ struct isp_node node[ISP_QUEUE_LENGTH];
+ struct isp_node *write;
+ struct isp_node *read;
+};
+
+struct isp_b4awb_buf {
+ uint32_t buf_id;
+ uint32_t buf_flag;
+ unsigned long buf_phys_addr;
+};
+
+struct isp_k_private {
+ atomic_t users;
+ struct device_node *dn;
+ struct clk *clock;
+ struct semaphore device_lock;
+ struct semaphore ioctl_lock;
+ unsigned long block_buf_addr;
+ uint32_t block_buf_len;
+ unsigned long reg_buf_addr;
+ uint32_t reg_buf_len;
+ uint32_t lsc_load_buf_id;
+ uint32_t lsc_update_buf_id;
+ unsigned long raw_aem_buf_addr;
+ uint32_t raw_aem_buf_len;
+ uint32_t ct_load_buf_id;
+ unsigned long full_gamma_buf_addr;
+ uint32_t full_gamma_buf_len;
+ uint32_t full_gamma_buf_id;
+ unsigned long yuv_ygamma_buf_addr;
+ uint32_t yuv_ygamma_buf_len;
+ uint32_t yuv_ygamma_buf_id;
+ unsigned long raw_awbm_buf_addr;
+ uint32_t raw_awbm_buf_len;
+ struct isp_b4awb_buf b4awb_buf[ISP_BING4AWB_NUM];
+ uint32_t lsc_buf_phys_addr;
+ unsigned long yiq_antiflicker_buf_addr;
+ uint32_t yiq_antiflicker_len;
+ uint32_t yiq_antiflicker_order;
+ unsigned long yiq_aem_buf_addr;
+ uint32_t yiq_aem_buf_len;
+};
+
+struct isp_drv_private {
+ spinlock_t isr_lock;
+ struct semaphore isr_done_lock;
+ struct isp_queue queue;
+};
+
+struct isp_k_file {
+ struct isp_k_private *isp_private;
+ struct isp_drv_private drv_private;
+};
+
+int32_t isp_get_int_num(struct isp_node *node);
+void isp_clr_int(void);
+void isp_en_irq(uint32_t irq_mode);
+int32_t isp_axi_bus_waiting(void);
+int32_t isp_capability(void *param);
+int32_t isp_cfg_param(void *param, struct isp_k_private *isp_private);
+
+#endif
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/inc/isp_reg.h b/drivers/media/sprd_isp/isp2.0/tshark2/inc/isp_reg.h
new file mode 100644
index 00000000..755b5c24
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/inc/isp_reg.h
@@ -0,0 +1,676 @@
+/*
+ * 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 <mach/hardware.h>
+#ifndef CONFIG_64BIT
+#include <soc/sprd/hardware.h>
+#else
+#include <soc/sprd/irqs.h>
+#endif
+#include "parse_hwinfo_tshark2.h"
+
+#define ISP_BASE_ADDR ISP_BASE
+
+/*isp sub block: Interrupt*/
+#define ISP_INT_STATUS (ISP_BASE_ADDR+0x0000UL)
+#define ISP_INT_EN0 (ISP_BASE_ADDR+0x0014UL)
+#define ISP_INT_CLR0 (ISP_BASE_ADDR+0x0018UL)
+#define ISP_INT_RAW0 (ISP_BASE_ADDR+0x001CUL)
+#define ISP_INT_INT0 (ISP_BASE_ADDR+0x0020UL)
+#define ISP_INT_EN1 (ISP_BASE_ADDR+0x0024UL)
+#define ISP_INT_CLR1 (ISP_BASE_ADDR+0x0028UL)
+#define ISP_INT_RAW1 (ISP_BASE_ADDR+0x002CUL)
+#define ISP_INT_INT1 (ISP_BASE_ADDR+0x0030UL)
+#define ISP_INT_EN2 (ISP_BASE_ADDR+0x0034UL)
+#define ISP_INT_CLR2 (ISP_BASE_ADDR+0x0038UL)
+#define ISP_INT_RAW2 (ISP_BASE_ADDR+0x003CUL)
+#define ISP_INT_INT2 (ISP_BASE_ADDR+0x0040UL)
+#define ISP_INT_EN3 (ISP_BASE_ADDR+0x0044UL)
+#define ISP_INT_CLR3 (ISP_BASE_ADDR+0x0048UL)
+#define ISP_INT_RAW3 (ISP_BASE_ADDR+0x004CUL)
+#define ISP_INT_INT3 (ISP_BASE_ADDR+0x0050UL)
+#define ISP_INT_ALL_DONE_CTRL (ISP_BASE_ADDR+0x0054UL)
+
+/*isp sub block: Fetch*/
+#define ISP_FETCH_MEM_STATUS0 (ISP_BASE_ADDR+0x0100UL)
+#define ISP_FETCH_MEM_STATUS1 (ISP_BASE_ADDR+0x0104UL)
+#define ISP_FETCH_DCAM_STATUS0 (ISP_BASE_ADDR+0x0108UL)
+#define ISP_FETCH_MIPI_STATUS (ISP_BASE_ADDR+0x010CUL)
+#define ISP_FETCH_PARAM (ISP_BASE_ADDR+0x0114UL)
+#define ISP_FETCH_START (ISP_BASE_ADDR+0x0118UL)
+#define ISP_FETCH_SLICE_SIZE (ISP_BASE_ADDR+0x0120UL)
+#define ISP_FETCH_SLICE_Y_ADDR (ISP_BASE_ADDR+0x0124UL)
+#define ISP_FETCH_SLICE_Y_PITCH (ISP_BASE_ADDR+0x0128UL)
+#define ISP_FETCH_SLICE_U_ADDR (ISP_BASE_ADDR+0x012CUL)
+#define ISP_FETCH_SLICE_U_PITCH (ISP_BASE_ADDR+0x0130UL)
+#define ISP_FETCH_SLICE_V_ADDR (ISP_BASE_ADDR+0x0134UL)
+#define ISP_FETCH_SLICE_V_PITCH (ISP_BASE_ADDR+0x0138UL)
+#define ISP_FETCH_MIPI_WORD_INFO (ISP_BASE_ADDR+0x013CUL)
+#define ISP_FETCH_MIPI_BYTE_INFO (ISP_BASE_ADDR+0x0140UL)
+#define ISP_FETCH_LINE_DLY_CTRL (ISP_BASE_ADDR+0x0144UL)
+
+/*isp sub block: Store*/
+#define ISP_STORE_STATUS_MEM0 (ISP_BASE_ADDR+0x0200UL)
+#define ISP_STORE_STATUS_MEM1 (ISP_BASE_ADDR+0x0204UL)
+#define ISP_STORE_STATUS_DCAM0 (ISP_BASE_ADDR+0x0208UL)
+#define ISP_STORE_STATUS_DCAM1 (ISP_BASE_ADDR+0x020CUL)
+#define ISP_STORE_PARAM (ISP_BASE_ADDR+0x0214UL)
+#define ISP_STORE_SLICE_SIZE (ISP_BASE_ADDR+0x0218UL)
+#define ISP_STORE_BORDER (ISP_BASE_ADDR+0x021CUL)
+#define ISP_STORE_Y_ADDR (ISP_BASE_ADDR+0x0220UL)
+#define ISP_STORE_Y_PITCH (ISP_BASE_ADDR+0x0224UL)
+#define ISP_STORE_U_ADDR (ISP_BASE_ADDR+0x0228UL)
+#define ISP_STORE_U_PITCH (ISP_BASE_ADDR+0x022CUL)
+#define ISP_STORE_V_ADDR (ISP_BASE_ADDR+0x0230UL)
+#define ISP_STORE_V_PITCH (ISP_BASE_ADDR+0x0234UL)
+#define ISP_STORE_SHADOW_CLR (ISP_BASE_ADDR+0x0238UL)
+
+/*isp sub block: dispatch*/
+#define ISP_DISPATCH_STATUS_CH0 (ISP_BASE_ADDR+0x0300UL)
+#define ISP_DISPATCH_STATUS_CH1 (ISP_BASE_ADDR+0x0304UL)
+#define ISP_DISPATCH_STATUS_COMM (ISP_BASE_ADDR+0x0308UL)
+#define ISP_DISPATCH_STATUS1_CH0 (ISP_BASE_ADDR+0x030CUL)
+#define ISP_DISPATCH_STATUS1_CH1 (ISP_BASE_ADDR+0x0310UL)
+#define ISP_DISPATCH_CH0_BAYER (ISP_BASE_ADDR+0x0314UL)
+#define ISP_DISPATCH_CH0_SIZE (ISP_BASE_ADDR+0x0318UL)
+#define ISP_DISPATCH_CH1_SIZE (ISP_BASE_ADDR+0x031CUL)
+#define ISP_DISPATCH_DLY (ISP_BASE_ADDR+0x0320UL)
+#define ISP_DISPATCH_CH1_BAYER (ISP_BASE_ADDR+0x0324UL)
+#define ISP_DISPATCH_HW_CTRL_CH0 (ISP_BASE_ADDR+0x0328UL)
+#define ISP_DISPATCH_HW_CTRL_CH1 (ISP_BASE_ADDR+0x032CUL)
+
+/*isp sub block: arbiter*/
+#define ISP_ARBITER_WR_STATUS (ISP_BASE_ADDR+0x0400UL)
+#define ISP_ARBITER_RD_STATUS (ISP_BASE_ADDR+0x0404UL)
+#define ISP_ARBITER_PARAM (ISP_BASE_ADDR+0x0414UL)
+#define ISP_ARBITER_ENDIAN_CH0 (ISP_BASE_ADDR+0x0418UL)
+#define ISP_ARBITER_ENDIAN_CH1 (ISP_BASE_ADDR+0x041CUL)
+#define ISP_ARBITER_CTRL (ISP_BASE_ADDR+0x0420UL)
+
+/*isp sub block: axi*/
+#define ISP_AXI_WR_MASTER_STATUS (ISP_BASE_ADDR+0x0500UL)
+#define ISP_AXI_RD_MASTER_STATUS (ISP_BASE_ADDR+0x0504UL)
+#define ISP_AXI_ITI2AXIM_CTRL (ISP_BASE_ADDR+0x0514UL)
+#define ISP_AXI_CONVERT_WR_CTRL (ISP_BASE_ADDR+0x0518UL)
+
+/*isp sub block: raw sizer*/
+#define ISP_RAW_SIZER_STATUS0 (ISP_BASE_ADDR+0x0600UL)
+#define ISP_RAW_SIZER_PARAM (ISP_BASE_ADDR+0x0614UL)
+#define ISP_RAW_SIZER_CROP_SRC (ISP_BASE_ADDR+0x0618UL)
+#define ISP_RAW_SIZER_CROP_DST (ISP_BASE_ADDR+0x061CUL)
+#define ISP_RAW_SIZER_CROP_START (ISP_BASE_ADDR+0x0620UL)
+#define ISP_RAW_SIZER_DST (ISP_BASE_ADDR+0x0624UL)
+#define ISP_RAW_SIZER_BPC (ISP_BASE_ADDR+0x0628UL)
+#define ISP_RAW_SIZER_HCOEFF0 (ISP_BASE_ADDR+0x062CUL)
+#define ISP_RAW_SIZER_VCOEFF0 (ISP_BASE_ADDR+0x0684UL)
+#define ISP_RAW_SIZER_INIT_HOR0 (ISP_BASE_ADDR+0x06B0UL)
+#define ISP_RAW_SIZER_INIT_HOR1 (ISP_BASE_ADDR+0x06B4UL)
+#define ISP_RAW_SIZER_INIT_HOR2 (ISP_BASE_ADDR+0x06B8UL)
+#define ISP_RAW_SIZER_INIT_VER0 (ISP_BASE_ADDR+0x06BCUL)
+#define ISP_RAW_SIZER_INIT_VER1 (ISP_BASE_ADDR+0x06C0UL)
+#define ISP_RAW_SIZER_INIT_VER2 (ISP_BASE_ADDR+0x06C4UL)
+
+/*isp sub block: common*/
+#define ISP_COMMON_VERSION (ISP_BASE_ADDR+0x0700UL)
+#define ISP_COMMON_STATUS0 (ISP_BASE_ADDR+0x0704UL)
+#define ISP_COMMON_STATUS1 (ISP_BASE_ADDR+0x0708UL)
+#define ISP_COMMON_CTRL_CH0 (ISP_BASE_ADDR+0x0714UL)
+#define ISP_COMMON_SPACE_SEL (ISP_BASE_ADDR+0x0718UL)
+#define ISP_COMMON_CTRL_CH1 (ISP_BASE_ADDR+0x071CUL)
+#define ISP_COMMON_CTRL_AWBM (ISP_BASE_ADDR+0x0720UL)
+#define ISP_COMMON_PMU_RAW_MASK (ISP_BASE_ADDR+0x0724UL)
+#define ISP_COMMON_PMU_HW_MASK (ISP_BASE_ADDR+0x0728UL)
+#define ISP_COMMON_PMU_HW_ENABLE (ISP_BASE_ADDR+0x072CUL)
+#define ISP_COMMON_PMU_SW_SWITCH (ISP_BASE_ADDR+0x0730UL)
+#define ISP_COMMON_PMU_SW_TOGGLE (ISP_BASE_ADDR+0x0734UL)
+#define ISP_COMMON_LBUF_OFFSET0 (ISP_BASE_ADDR+0x0738UL)
+#define ISP_SHADOW_CTRL_CH0 (ISP_BASE_ADDR+0x073CUL)
+#define ISP_SHADOW_CTRL_CH1 (ISP_BASE_ADDR+0x0740UL)
+#define ISP_COMMON_3A_CTRL0 (ISP_BASE_ADDR+0x0744UL)
+#define ISP_COMMON_LBUF_OFFSET1 (ISP_BASE_ADDR+0x0748UL)
+#define ISP_COMMON_3A_CTRL1 (ISP_BASE_ADDR+0x074CUL)
+#define ISP_COMMON_RESERVED0 (ISP_BASE_ADDR+0x0750UL)
+
+/*isp sub block: Pre Global Gain*/
+#define ISP_PGG_STATUS (ISP_BASE_ADDR+0x1000UL)
+#define ISP_PGG_PARAM (ISP_BASE_ADDR+0x1014UL)
+
+/*isp sub block: BLC: back level calibration*/
+#define ISP_BLC_STATUS (ISP_BASE_ADDR+0x1100UL)
+#define ISP_BLC_PARAM (ISP_BASE_ADDR+0x1114UL)
+#define ISP_BLC_B_PARAM_R_B (ISP_BASE_ADDR+0x1118UL)
+#define ISP_BLC_B_PARAM_G (ISP_BASE_ADDR+0x111CUL)
+
+/*isp sub block: RGBG*/
+#define ISP_RGBG_STATUS (ISP_BASE_ADDR+0x1200UL)
+#define ISP_RGBG_PARAM (ISP_BASE_ADDR+0x1214UL)
+#define ISP_RGBG_RB (ISP_BASE_ADDR+0x1218UL)
+#define ISP_RGBG_G (ISP_BASE_ADDR+0x121CUL)
+
+/*isp sub block: PWD*/
+#define ISP_PWD_STATUS0 (ISP_BASE_ADDR+0x1300UL)
+#define ISP_PWD_STATUS1 (ISP_BASE_ADDR+0x1304UL)
+#define ISP_PWD_PARAM (ISP_BASE_ADDR+0x1314UL)
+#define ISP_PWD_PARAM1 (ISP_BASE_ADDR+0x1318UL)
+#define ISP_PWD_PARAM2 (ISP_BASE_ADDR+0x131CUL)
+#define ISP_PWD_PARAM3 (ISP_BASE_ADDR+0x1320UL)
+#define ISP_PWD_PARAM4 (ISP_BASE_ADDR+0x1324UL)
+#define ISP_PWD_PARAM5 (ISP_BASE_ADDR+0x1328UL)
+#define ISP_PWD_PARAM6 (ISP_BASE_ADDR+0x132CUL)
+#define ISP_PWD_PARAM7 (ISP_BASE_ADDR+0x1330UL)
+#define ISP_PWD_PARAM8 (ISP_BASE_ADDR+0x1334UL)
+#define ISP_PWD_PARAM9 (ISP_BASE_ADDR+0x1338UL)
+#define ISP_PWD_PARAM10 (ISP_BASE_ADDR+0x133CUL)
+
+/*isp sub block: NLC*/
+#define ISP_NLC_STATUS (ISP_BASE_ADDR+0x1400UL)
+#define ISP_NLC_PARA (ISP_BASE_ADDR+0x1414UL)
+#define ISP_NLC_PARA_R0 (ISP_BASE_ADDR+0x1418UL)
+#define ISP_NLC_PARA_R9 (ISP_BASE_ADDR+0x143CUL)
+#define ISP_NLC_PARA_G0 (ISP_BASE_ADDR+0x1440UL)
+#define ISP_NLC_PARA_G9 (ISP_BASE_ADDR+0x1464UL)
+#define ISP_NLC_PARA_B0 (ISP_BASE_ADDR+0x1468UL)
+#define ISP_NLC_PARA_B9 (ISP_BASE_ADDR+0x148CUL)
+#define ISP_NLC_PARA_L0 (ISP_BASE_ADDR+0x1490UL)
+
+/*isp sub block: lens shading calibration*/
+#define ISP_LENS_STATUS (ISP_BASE_ADDR+0x1500UL)
+#define ISP_LENS_PARAM (ISP_BASE_ADDR+0x1514UL)
+#define ISP_LENS_PARAM_ADDR (ISP_BASE_ADDR+0x1518UL)
+#define ISP_LENS_SLICE_POS (ISP_BASE_ADDR+0x151CUL)
+#define ISP_LENS_LOAD_EB (ISP_BASE_ADDR+0x1520UL)
+#define ISP_LENS_GRID_PITCH (ISP_BASE_ADDR+0x1524UL)
+#define ISP_LENS_GRID_SIZE (ISP_BASE_ADDR+0x1528UL)
+#define ISP_LENS_LOAD_BUF (ISP_BASE_ADDR+0x152CUL)
+#define ISP_LENS_MISC (ISP_BASE_ADDR+0x1530UL)
+#define ISP_LENS_SLICE_SIZE (ISP_BASE_ADDR+0x1534UL)
+#define ISP_LENS_INIT_COOR (ISP_BASE_ADDR+0x1538UL)
+#define ISP_LENS_Q0_VALUE (ISP_BASE_ADDR+0x153CUL)
+
+/*isp sub block: binning*/
+#define ISP_BINNING_STATUS (ISP_BASE_ADDR+0x1600UL)
+#define ISP_BINNING_PARAM (ISP_BASE_ADDR+0x1614UL)
+#define ISP_BINNING_MEM_ADDR (ISP_BASE_ADDR+0x1618UL)
+#define ISP_BINNING_PITCH (ISP_BASE_ADDR+0x161CUL)
+
+/*isp sub block: AWBM*/
+#define ISP_AWBM_STATUS (ISP_BASE_ADDR+0x1700UL)
+#define ISP_AWBM_PARAM (ISP_BASE_ADDR+0x1714UL)
+#define ISP_AWBM_BLOCK_OFFSET (ISP_BASE_ADDR+0x1718UL)
+#define ISP_AWBM_BLOCK_SIZE (ISP_BASE_ADDR+0x171CUL)
+#define ISP_AWBM_WR_0_S (ISP_BASE_ADDR+0x1720UL)
+#define ISP_AWBM_WR_0_E (ISP_BASE_ADDR+0x1724UL)
+#define ISP_AWBM_NW_0_XYR (ISP_BASE_ADDR+0x1748UL)
+#define ISP_AWBM_CLCTOR_0_S (ISP_BASE_ADDR+0x175CUL)
+#define ISP_AWBM_CLCTOR_0_E (ISP_BASE_ADDR+0x1760UL)
+#define ISP_AWBM_CLCTR_0_PIXEL_NUM (ISP_BASE_ADDR+0x1784UL)
+#define ISP_AWBM_MEM_ADDR (ISP_BASE_ADDR+0x1798UL)
+#define ISP_AWBM_THR_VALUE1 (ISP_BASE_ADDR+0x17A0UL)
+#define ISP_AWBM_THR_VALUE2 (ISP_BASE_ADDR+0x17A4UL)
+
+/*isp sub block: AWBC*/
+#define ISP_AWBC_STATUS (ISP_BASE_ADDR+0x1800UL)
+#define ISP_AWBC_PARAM (ISP_BASE_ADDR+0x1814UL)
+#define ISP_AWBC_GAIN0 (ISP_BASE_ADDR+0x1818UL)
+#define ISP_AWBC_GAIN1 (ISP_BASE_ADDR+0x181CUL)
+#define ISP_AWBC_THRD (ISP_BASE_ADDR+0x1820UL)
+#define ISP_AWBC_OFFSET0 (ISP_BASE_ADDR+0x1824UL)
+#define ISP_AWBC_OFFSET1 (ISP_BASE_ADDR+0x1828UL)
+#define ISP_AWBC_GAIN0_BUF (ISP_BASE_ADDR+0x182CUL)
+#define ISP_AWBC_GAIN1_BUF (ISP_BASE_ADDR+0x1830UL)
+#define ISP_AWBC_OFFSET0_BUF (ISP_BASE_ADDR+0x1834UL)
+#define ISP_AWBC_OFFSET1_BUF (ISP_BASE_ADDR+0x1838UL)
+#define ISP_AWBC_GAIN0_READ (ISP_BASE_ADDR+0x183CUL)
+#define ISP_AWBC_GAIN1_READ (ISP_BASE_ADDR+0x1840UL)
+#define ISP_AWBC_OFFSET0_READ (ISP_BASE_ADDR+0x1844UL)
+#define ISP_AWBC_OFFSET1_READ (ISP_BASE_ADDR+0x1848UL)
+
+/*isp sub block: AEM*/
+#define ISP_AEM_STATUS (ISP_BASE_ADDR+0x1900UL)
+#define ISP_AEM_PARAM (ISP_BASE_ADDR+0x1914UL)
+#define ISP_AEM_OFFSET (ISP_BASE_ADDR+0x1918UL)
+#define ISP_AEM_BLK_SIZE (ISP_BASE_ADDR+0x191CUL)
+#define ISP_AEM_SLICE_SIZE (ISP_BASE_ADDR+0x1920UL)
+
+/*isp sub block: BPC: bad pixel correction*/
+#define ISP_BPC_STATUS (ISP_BASE_ADDR+0x1A00UL)
+#define ISP_BPC_PARAM (ISP_BASE_ADDR+0x1A14UL)
+#define ISP_BPC_CFG (ISP_BASE_ADDR+0x1A18UL)
+#define ISP_BPC_FACTOR (ISP_BASE_ADDR+0x1A1CUL)
+#define ISP_BPC_COEFF (ISP_BASE_ADDR+0x1A20UL)
+#define ISP_BPC_LUTWORD0 (ISP_BASE_ADDR+0x1A24UL)
+#define ISP_BPC_NEW_OLD_SEL (ISP_BASE_ADDR+0x1A44UL)
+#define ISP_BPC_MAP_ADDR (ISP_BASE_ADDR+0x1A48UL)
+
+/*isp sub block: GRGB*/
+#define ISP_GRGB_STATUS (ISP_BASE_ADDR+0x1B00UL)
+#define ISP_GRGB_PARAM (ISP_BASE_ADDR+0x1B14UL)
+#define ISP_GRGB_GRID (ISP_BASE_ADDR+0x1B18UL)
+
+/*isp sub block: BDN*/
+#define ISP_BDN_STATUS (ISP_BASE_ADDR+0x1C00UL)
+#define ISP_BDN_PARAM (ISP_BASE_ADDR+0x1C14UL)
+#define ISP_BDN_DISWEI0_0 (ISP_BASE_ADDR+0x1C18UL)
+#define ISP_BDN_DISWEI0_1 (ISP_BASE_ADDR+0x1C1CUL)
+#define ISP_BDN_RANWEI0_0 (ISP_BASE_ADDR+0x1C20UL)
+#define ISP_BDN_RANWEI0_7 (ISP_BASE_ADDR+0x1C3CUL)
+#define ISP_BDN_1DLNC_CENTER (ISP_BASE_ADDR+0x1DA8UL)
+#define ISP_BDN_1DLNC_SQUARE_X (ISP_BASE_ADDR+0x1DACUL)
+#define ISP_BDN_1DLNC_SQUARE_Y (ISP_BASE_ADDR+0x1DB0UL)
+#define ISP_BDN_1DLNC_P (ISP_BASE_ADDR+0x1DB4UL)
+#define ISP_BDN_1DLNC_SIZE (ISP_BASE_ADDR+0x1DB8UL)
+#define ISP_BDN_1DLNC_POS (ISP_BASE_ADDR+0x1DBCUL)
+#define ISP_BDN_1DLNC_OFFSET (ISP_BASE_ADDR+0x1DC0UL)
+
+/*isp sub block: RGBG2*/
+#define ISP_RGBG2_STATUS (ISP_BASE_ADDR+0x1E00UL)
+#define ISP_RGBG2_PARAM (ISP_BASE_ADDR+0x1E14UL)
+#define ISP_RGBG2_GAIN (ISP_BASE_ADDR+0x1E18UL)
+#define ISP_RGBG2_OFFSET (ISP_BASE_ADDR+0x1E1CUL)
+
+/*isp sub block: 1d lnc*/
+#define ISP_1D_LNC_STATUS (ISP_BASE_ADDR+0x1F00UL)
+#define ISP_1D_LNC_PARAM (ISP_BASE_ADDR+0x1F14UL)
+#define ISP_1D_LNC_PARAM1 (ISP_BASE_ADDR+0x1F18UL)
+#define ISP_1D_LNC_PARAM2 (ISP_BASE_ADDR+0x1F1CUL)
+#define ISP_1D_LNC_PARAM3 (ISP_BASE_ADDR+0x1F20UL)
+#define ISP_1D_LNC_PARAM4 (ISP_BASE_ADDR+0x1F24UL)
+#define ISP_1D_LNC_PARAM5 (ISP_BASE_ADDR+0x1F28UL)
+#define ISP_1D_LNC_PARAM6 (ISP_BASE_ADDR+0x1F2CUL)
+#define ISP_1D_LNC_PARAM7 (ISP_BASE_ADDR+0x1F30UL)
+#define ISP_1D_LNC_PARAM8 (ISP_BASE_ADDR+0x1F34UL)
+#define ISP_1D_LNC_PARAM9 (ISP_BASE_ADDR+0x1F38UL)
+#define ISP_1D_LNC_PARAM10 (ISP_BASE_ADDR+0x1F3CUL)
+#define ISP_1D_LNC_PARAM11 (ISP_BASE_ADDR+0x1F40UL)
+#define ISP_1D_LNC_PARAM12 (ISP_BASE_ADDR+0x1F44UL)
+#define ISP_1D_LNC_PARAM13 (ISP_BASE_ADDR+0x1F48UL)
+#define ISP_1D_LNC_PARAM14 (ISP_BASE_ADDR+0x1F4CUL)
+#define ISP_1D_LNC_PARAM15 (ISP_BASE_ADDR+0x1F50UL)
+#define ISP_1D_LNC_PARAM16 (ISP_BASE_ADDR+0x1F54UL)
+#define ISP_1D_LNC_PARAM17 (ISP_BASE_ADDR+0x1F58UL)
+#define ISP_1D_LNC_PARAM18 (ISP_BASE_ADDR+0x1F5CUL)
+
+/*isp sub block: NLM VST IVST*/
+#define ISP_VST_PARA (ISP_BASE_ADDR+0x2014UL)
+#define ISP_IVST_PARA (ISP_BASE_ADDR+0x2214UL)
+#define ISP_NLM_LB_STATUS0 (ISP_BASE_ADDR+0x2100UL)
+#define ISP_NLM_LB_STATUS1 (ISP_BASE_ADDR+0x2104UL)
+#define ISP_NLM_STATUS (ISP_BASE_ADDR+0x2108UL)
+#define ISP_NLM_PARA (ISP_BASE_ADDR+0x2114UL)
+#define ISP_NLM_FLAT_PARA_0 (ISP_BASE_ADDR+0x2118UL)
+#define ISP_NLM_STERNGTH (ISP_BASE_ADDR+0x212CUL)
+#define ISP_NLM_IS_FLAT (ISP_BASE_ADDR+0x2130UL)
+#define ISP_NLM_ADD_BACK (ISP_BASE_ADDR+0x2134UL)
+#define ISP_NLM_DIRECTION_0 (ISP_BASE_ADDR+0x2138UL)
+#define ISP_NLM_DIRECTION_1 (ISP_BASE_ADDR+0x213CUL)
+#define ISP_NLM_LUT_W_0 (ISP_BASE_ADDR+0x2140UL)
+
+/*isp sub block: CFA: clolor filter array*/
+#define ISP_CFAE_STATUS (ISP_BASE_ADDR+0x3000UL)
+#define ISP_CFAE_EE_CFG0 (ISP_BASE_ADDR+0x3014UL)
+#define ISP_CFAE_THRD_0 (ISP_BASE_ADDR+0x3018UL)
+#define ISP_CFAE_THRD_1 (ISP_BASE_ADDR+0x301CUL)
+#define ISP_CFAE_THRD_2 (ISP_BASE_ADDR+0x3020UL)
+#define ISP_CFAE_THRD_3 (ISP_BASE_ADDR+0x3024UL)
+#define ISP_CFAE_THRD_4 (ISP_BASE_ADDR+0x3028UL)
+#define ISP_CFAE_EE_CFG1 (ISP_BASE_ADDR+0x302CUL)
+
+/*isp sub block:CMC: Color matrix correction for 10 bit */
+#define ISP_CMC10_STATUS0 (ISP_BASE_ADDR+0x3100UL)
+#define ISP_CMC10_STATUS1 (ISP_BASE_ADDR+0x3104UL)
+#define ISP_CMC10_PARAM (ISP_BASE_ADDR+0x3114UL)
+#define ISP_CMC10_MATRIX0 (ISP_BASE_ADDR+0x3118UL)
+#define ISP_CMC10_MATRIX0_BUF (ISP_BASE_ADDR+0x312CUL)
+
+/*isp sub block: GAMMA */
+#define ISP_GAMMA_STATUS (ISP_BASE_ADDR+0x3300UL)
+#define ISP_GAMMA_PARAM (ISP_BASE_ADDR+0x3314UL)
+
+/*isp sub block:CMC: Color matrix correction for 8 bit */
+#define ISP_CMC8_STATUS0 (ISP_BASE_ADDR+0x3500UL)
+#define ISP_CMC8_STATUS1 (ISP_BASE_ADDR+0x3504UL)
+#define ISP_CMC8_PARAM (ISP_BASE_ADDR+0x3514UL)
+#define ISP_CMC8_MATRIX0 (ISP_BASE_ADDR+0x3518UL)
+#define ISP_CMC8_MATRIX0_BUF (ISP_BASE_ADDR+0x352CUL)
+
+/*CT: Color transformation*/
+#define ISP_CT_STATUS0 (ISP_BASE_ADDR+0x3600UL)
+#define ISP_CT_STATUS1 (ISP_BASE_ADDR+0x3604UL)
+#define ISP_CT_PARAM (ISP_BASE_ADDR+0x3614UL)
+
+/*isp sub block: CCE: clolor conversion enhancement*/
+#define ISP_CCE_STATUS0 (ISP_BASE_ADDR+0x3700UL)
+#define ISP_CCE_STATUS1 (ISP_BASE_ADDR+0x3704UL)
+#define ISP_CCE_PARAM (ISP_BASE_ADDR+0x3714UL)
+#define ISP_CCE_MATRIX0 (ISP_BASE_ADDR+0x3718UL)
+#define ISP_CCE_MATRIX1 (ISP_BASE_ADDR+0x371CUL)
+#define ISP_CCE_MATRIX2 (ISP_BASE_ADDR+0x3720UL)
+#define ISP_CCE_MATRIX3 (ISP_BASE_ADDR+0x3724UL)
+#define ISP_CCE_MATRIX4 (ISP_BASE_ADDR+0x3728UL)
+#define ISP_CCE_SHIFT (ISP_BASE_ADDR+0x372CUL)
+#define ISP_CCE_UVD_PARAM0 (ISP_BASE_ADDR+0x3730UL)
+#define ISP_CCE_UVD_PARAM1 (ISP_BASE_ADDR+0x3734UL)
+#define ISP_CCE_UVD_PARAM2 (ISP_BASE_ADDR+0x3738UL)
+#define ISP_CCE_UVD_PARAM3 (ISP_BASE_ADDR+0x373CUL)
+#define ISP_CCE_UVD_PARAM4 (ISP_BASE_ADDR+0x3740UL)
+#define ISP_CCE_UVD_PARAM5 (ISP_BASE_ADDR+0x3744UL)
+
+/*isp sub block:HSV*/
+#define ISP_HSV_STATUS (ISP_BASE_ADDR+0x3800UL)
+#define ISP_HSV_PARAM (ISP_BASE_ADDR+0x3814UL)
+
+/*isp sub block:Radial CSC*/
+#define ISP_CSC_STATUS (ISP_BASE_ADDR + 0x3900UL)
+#define ISP_CSC_CTRL (ISP_BASE_ADDR + 0x3914UL)
+#define ISP_CSC_RCC (ISP_BASE_ADDR + 0x3918UL)
+#define ISP_CSC_BCC (ISP_BASE_ADDR + 0x391CUL)
+#define ISP_CSC_REDX2INIT (ISP_BASE_ADDR + 0x3920UL)
+#define ISP_CSC_REDY2INIT (ISP_BASE_ADDR + 0x3924UL)
+#define ISP_CSC_BLUEX2INIT (ISP_BASE_ADDR + 0x3928UL)
+#define ISP_CSC_BLUEY2INIT (ISP_BASE_ADDR + 0x392CUL)
+#define ISP_CSC_REDTHR (ISP_BASE_ADDR + 0x3930UL)
+#define ISP_CSC_BLUETHR (ISP_BASE_ADDR + 0x3934UL)
+#define ISP_CSC_REDPOLY (ISP_BASE_ADDR + 0x3938UL)
+#define ISP_CSC_BLUEPOLY (ISP_BASE_ADDR + 0x393CUL)
+#define ISP_CSC_MAXGAIN (ISP_BASE_ADDR + 0x3940UL)
+#define ISP_CSC_PICSIZE (ISP_BASE_ADDR + 0x3944UL)
+#define ISP_CSC_START_ROW_COL (ISP_BASE_ADDR + 0x3948UL)
+
+/*isp sub block:ISP_PRECNRNEW*/
+#define ISP_PRECNRNEW_STATUS0 (ISP_BASE_ADDR+0x3A00UL)
+#define ISP_PRECNRNEW_STATUS1 (ISP_BASE_ADDR+0x3A04UL)
+#define ISP_PRECNRNEW_CFG (ISP_BASE_ADDR+0x3A14UL)
+#define ISP_PRECNRNEW_MEDIAN_THR (ISP_BASE_ADDR+0x3A18UL)
+#define ISP_PRECNRNEW_THRU (ISP_BASE_ADDR+0x3A1CUL)
+#define ISP_PRECNRNEW_THRV (ISP_BASE_ADDR+0x3A20UL)
+
+/*isp sub block:ISP_PSTRZ*/
+#define ISP_PSTRZ_STATUS (ISP_BASE_ADDR+0x3B00UL)
+#define ISP_PSTRZ_PARAM (ISP_BASE_ADDR+0x3B14UL)
+#define ISP_PSTRZ_LEVEL0 (ISP_BASE_ADDR+0x3B18UL)
+#define ISP_PSTRZ_LEVEL1 (ISP_BASE_ADDR+0x3B1CUL)
+#define ISP_PSTRZ_LEVEL2 (ISP_BASE_ADDR+0x3B20UL)
+#define ISP_PSTRZ_LEVEL3 (ISP_BASE_ADDR+0x3B24UL)
+#define ISP_PSTRZ_LEVEL4 (ISP_BASE_ADDR+0x3B28UL)
+#define ISP_PSTRZ_LEVEL5 (ISP_BASE_ADDR+0x3B2CUL)
+#define ISP_PSTRZ_LEVEL6 (ISP_BASE_ADDR+0x3B30UL)
+#define ISP_PSTRZ_LEVEL7 (ISP_BASE_ADDR+0x3B34UL)
+
+/*isp sub block: AFM : auto focus monitor*/
+#define ISP_RGB_AFM_STATUS0 (ISP_BASE_ADDR+0x3C00UL)
+#define ISP_RGB_AFM_STATUS1 (ISP_BASE_ADDR+0x3C04UL)
+#define ISP_RGB_AFM_PARAM (ISP_BASE_ADDR+0x3C14UL)
+#define ISP_RGB_AFM_FRAME_RANGE (ISP_BASE_ADDR+0x3C18UL)
+#define ISP_RGB_AFM_SOBEL_THRESHOLD (ISP_BASE_ADDR+0x3C1CUL)
+#define ISP_RGB_AFM_SPSMD_THRESHOLD_MAX (ISP_BASE_ADDR+0x3C20UL)
+#define ISP_RGB_AFM_WIN_RANGE0 (ISP_BASE_ADDR+0x3C24UL)
+#define ISP_RGB_AFM_TYPE1_VAL00 (ISP_BASE_ADDR+0x3CECUL)
+#define ISP_RGB_AFM_TYPE2_VAL00 (ISP_BASE_ADDR+0x3D50UL)
+#define ISP_RGB_AFM_SPSMD_THRESHOLD_MIN (ISP_BASE_ADDR+0x3DB4UL)
+
+/*isp sub block:YIQ AEM*/
+#define ISP_YIQ_AEM_STATUS (ISP_BASE_ADDR + 0x4100UL)
+#define ISP_YIQ_AEM_PARAM (ISP_BASE_ADDR + 0x4114UL)
+#define ISP_YIQ_YGAMMA_NODE_X0 (ISP_BASE_ADDR + 0x4118UL)
+#define ISP_YIQ_YGAMMA_NODE_X1 (ISP_BASE_ADDR + 0x411CUL)
+#define ISP_YIQ_YGAMMA_NODE_Y0 (ISP_BASE_ADDR + 0x4120UL)
+#define ISP_YIQ_YGAMMA_NODE_Y1 (ISP_BASE_ADDR + 0x4124UL)
+#define ISP_YIQ_YGAMMA_NODE_Y2 (ISP_BASE_ADDR + 0x4128UL)
+#define ISP_YIQ_YGAMMA_NODE_IDX (ISP_BASE_ADDR + 0x412CUL)
+#define ISP_YIQ_AEM_OFFSET (ISP_BASE_ADDR + 0x4130UL)
+#define ISP_YIQ_AEM_BLK_SIZE (ISP_BASE_ADDR + 0x4134UL)
+#define ISP_YIQ_AEM_SLICE_SIZE (ISP_BASE_ADDR + 0x4138UL)
+
+/*isp sub block:ANTI FLICKER*/
+#define ISP_ANTI_FLICKER_STATUS0 (ISP_BASE_ADDR + 0x4200UL)
+#define ISP_ANTI_FLICKER_STATUS1 (ISP_BASE_ADDR + 0x4204UL)
+#define ISP_ANTI_FLICKER_PARAM0 (ISP_BASE_ADDR + 0x4214UL)
+#define ISP_ANTI_FLICKER_PARAM1 (ISP_BASE_ADDR + 0x4218UL)
+#define ISP_ANTI_FLICKER_COL_POS (ISP_BASE_ADDR + 0x421CUL)
+#define ISP_ANTI_FLICKER_DDR_INIT_ADDR (ISP_BASE_ADDR + 0x4220UL)
+
+/*isp sub block:YIQ AFM*/
+#define ISP_YIQ_AFM_STATUS0 (ISP_BASE_ADDR + 0x4300UL)
+#define ISP_YIQ_AFM_STATUS1 (ISP_BASE_ADDR + 0x4304UL)
+#define ISP_YIQ_AFM_PARAM (ISP_BASE_ADDR + 0x4314UL)
+#define ISP_YIQ_AFM_WIN_RANGE0 (ISP_BASE_ADDR + 0x4318UL)
+#define ISP_YIQ_AFM_COEF0_1 (ISP_BASE_ADDR + 0x43E0UL)
+#define ISP_YIQ_AFM_COEF2_3 (ISP_BASE_ADDR + 0x43E4UL)
+#define ISP_YIQ_AFM_COEF4_5 (ISP_BASE_ADDR + 0x43E8UL)
+#define ISP_YIQ_AFM_COEF6_7 (ISP_BASE_ADDR + 0x43ECUL)
+#define ISP_YIQ_AFM_COEF8_9 (ISP_BASE_ADDR + 0x43F0UL)
+#define ISP_YIQ_AFM_COEF10 (ISP_BASE_ADDR + 0x43F4UL)
+#define ISP_YIQ_AFM_LAPLACE0 (ISP_BASE_ADDR + 0x43F8UL)
+#define ISP_YIQ_AFM_SLICE_SIZE (ISP_BASE_ADDR + 0x4588UL)
+
+/*isp sub block: Pre-CDN*/
+#define ISP_PRECDN_STATUS0 (ISP_BASE_ADDR+0x5000UL)
+#define ISP_PRECDN_STATUS1 (ISP_BASE_ADDR+0x5004UL)
+#define ISP_PRECDN_PARAM (ISP_BASE_ADDR+0x5014UL)
+#define ISP_PRECDN_MEDIAN_THRUV01 (ISP_BASE_ADDR+0x5018UL)
+#define ISP_PRECDN_THRYUV (ISP_BASE_ADDR+0x501CUL)
+#define ISP_PRECDN_SEGU_0 (ISP_BASE_ADDR+0x5020UL)
+#define ISP_PRECDN_SEGU_3 (ISP_BASE_ADDR+0x502CUL)
+#define ISP_PRECDN_SEGV_0 (ISP_BASE_ADDR+0x5030UL)
+#define ISP_PRECDN_SEGV_3 (ISP_BASE_ADDR+0x503CUL)
+#define ISP_PRECDN_SEGY_0 (ISP_BASE_ADDR+0x5040UL)
+#define ISP_PRECDN_SEGY_3 (ISP_BASE_ADDR+0x504CUL)
+#define ISP_PRECDN_DISTW0 (ISP_BASE_ADDR+0x5050UL)
+#define ISP_PRECDN_DISTW3 (ISP_BASE_ADDR+0x505CUL)
+
+/*isp sub block: Pre-Filter*/
+#define ISP_PREF_STATUS0 (ISP_BASE_ADDR+0x5100UL)
+#define ISP_PREF_STATUS1 (ISP_BASE_ADDR+0x5104UL)
+#define ISP_PREF_PARAM (ISP_BASE_ADDR+0x5114UL)
+#define ISP_PREF_THRD (ISP_BASE_ADDR+0x5118UL)
+
+/*isp sub block: Brightness*/
+#define ISP_BRIGHT_STATUS (ISP_BASE_ADDR+0x5300UL)
+#define ISP_BRIGHT_PARAM (ISP_BASE_ADDR+0x5314UL)
+
+/*isp sub block: Contrast*/
+#define ISP_CONTRAST_STATUS (ISP_BASE_ADDR+0x5400UL)
+#define ISP_CONTRAST_PARAM (ISP_BASE_ADDR+0x5414UL)
+
+/*isp sub block: HIST : histogram*/
+#define ISP_HIST_STATUS (ISP_BASE_ADDR+0x5500UL)
+#define ISP_HIST_PARAM (ISP_BASE_ADDR+0x5514UL)
+#define ISP_HIST_RATIO (ISP_BASE_ADDR+0x5518UL)
+#define ISP_HIST_MAX_MIN (ISP_BASE_ADDR+0x551CUL)
+#define ISP_HIST_SLICE_SIZE (ISP_BASE_ADDR+0x5520UL)
+#define ISP_HIST_ADJUST (ISP_BASE_ADDR+0x5524UL)
+
+/*isp sub block: HIST2*/
+#define ISP_HIST2_STATUS (ISP_BASE_ADDR+0x5600UL)
+#define ISP_HIST2_PARAM (ISP_BASE_ADDR+0x5614UL)
+#define ISP_HIST2_ROI_S0 (ISP_BASE_ADDR+0x5618UL)
+#define ISP_HIST2_ROI_E0 (ISP_BASE_ADDR+0x561CUL)
+
+/*isp sub block: AUTOCONT : auto contrast adjustment*/
+#define ISP_AUTOCONT_STATUS (ISP_BASE_ADDR+0x5700UL)
+#define ISP_AUTOCONT_PARAM (ISP_BASE_ADDR+0x5714UL)
+#define ISP_AUTOCONT_MAX_MIN (ISP_BASE_ADDR+0x5718UL)
+
+/*isp sub block: cdn*/
+#define ISP_CDN_STATUS0 (ISP_BASE_ADDR+0x5800UL)
+#define ISP_CDN_STATUS1 (ISP_BASE_ADDR+0x5804UL)
+#define ISP_CDN_PARAM (ISP_BASE_ADDR+0x5814UL)
+#define ISP_CDN_THRUV (ISP_BASE_ADDR+0x5818UL)
+#define ISP_CDN_U_RANWEI_0 (ISP_BASE_ADDR+0x581CUL)
+#define ISP_CDN_U_RANWEI_7 (ISP_BASE_ADDR+0x5838UL)
+#define ISP_CDN_V_RANWEI_0 (ISP_BASE_ADDR+0x583CUL)
+#define ISP_CDN_V_RANWEI_7 (ISP_BASE_ADDR+0x5858UL)
+
+/*isp sub block: edge*/
+#define ISP_EE_STATUS (ISP_BASE_ADDR+0x5900UL)
+#define ISP_EE_PARAM (ISP_BASE_ADDR+0x5914UL)
+#define ISP_EE_CFG0 (ISP_BASE_ADDR+0x5918UL)
+#define ISP_EE_CFG1 (ISP_BASE_ADDR+0x591CUL)
+#define ISP_EE_CFG2 (ISP_BASE_ADDR+0x5920UL)
+#define ISP_EE_CFG3 (ISP_BASE_ADDR+0x5924UL)
+#define ISP_EE_CFG4 (ISP_BASE_ADDR+0x5928UL)
+#define ISP_EE_CFG5 (ISP_BASE_ADDR+0x592CUL)
+#define ISP_EE_CFG6 (ISP_BASE_ADDR+0x5930UL)
+#define ISP_EE_CFG7 (ISP_BASE_ADDR+0x5934UL)
+#define ISP_EE_ADP_CFG0 (ISP_BASE_ADDR+0x5938UL)
+#define ISP_EE_ADP_CFG1 (ISP_BASE_ADDR+0x593CUL)
+#define ISP_EE_ADP_CFG2 (ISP_BASE_ADDR+0x5940UL)
+
+/*isp sub block: emboss*/
+#define ISP_EMBOSS_Y_STATUS (ISP_BASE_ADDR+0x5A00UL)
+#define ISP_EMBOSS_Y_PARAM (ISP_BASE_ADDR+0x5A14UL)
+#define ISP_EMBOSS_UV_STATUS (ISP_BASE_ADDR+0x5F00UL)
+#define ISP_EMBOSS_UV_PARAM (ISP_BASE_ADDR+0x5F14UL)
+
+/*isp sub block: CSS*/
+#define ISP_CSS_STATUS (ISP_BASE_ADDR+0x5B00UL)
+#define ISP_CSS_PARAM (ISP_BASE_ADDR+0x5B14UL)
+#define ISP_CSS_THRD0 (ISP_BASE_ADDR+0x5B18UL)
+#define ISP_CSS_LH_RATIO (ISP_BASE_ADDR+0x5B1CUL)
+#define ISP_CSS_EX_TH_0 (ISP_BASE_ADDR+0x5B20UL)
+#define ISP_CSS_EX_TH_1 (ISP_BASE_ADDR+0x5B24UL)
+#define ISP_CSS_CHROM_L_TH_0 (ISP_BASE_ADDR+0x5B28UL)
+#define ISP_CSS_CHROM_L_TH_1 (ISP_BASE_ADDR+0x5B2CUL)
+#define ISP_CSS_CHROM_H_TH_0 (ISP_BASE_ADDR+0x5B30UL)
+#define ISP_CSS_CHROM_H_TH_1 (ISP_BASE_ADDR+0x5B34UL)
+#define ISP_CSS_RATIO (ISP_BASE_ADDR+0x5B38UL)
+
+/*isp sub block: csa*/
+#define ISP_CSA_STATUS (ISP_BASE_ADDR+0x5C00UL)
+#define ISP_CSA_PARAM (ISP_BASE_ADDR+0x5C14UL)
+
+/*isp sub block: hua*/
+#define ISP_HUA_STATUS (ISP_BASE_ADDR+0x5D00UL)
+#define ISP_HUA_PARAM (ISP_BASE_ADDR+0x5D14UL)
+
+/*isp sub block: post-cdn*/
+#define ISP_POSTCDN_STATUS (ISP_BASE_ADDR+0x5E00UL)
+#define ISP_POSTCDN_COMMON_CTRL (ISP_BASE_ADDR+0x5E14UL)
+#define ISP_POSTCDN_ADPT_THR (ISP_BASE_ADDR+0x5E18UL)
+#define ISP_POSTCDN_UVTHR (ISP_BASE_ADDR+0x5E1CUL)
+#define ISP_POSTCDN_THRU (ISP_BASE_ADDR+0x5E20UL)
+#define ISP_POSTCDN_THRV (ISP_BASE_ADDR+0x5E24UL)
+#define ISP_POSTCDN_RSEGU01 (ISP_BASE_ADDR+0x5E28UL)
+#define ISP_POSTCDN_RSEGU23 (ISP_BASE_ADDR+0x5E2CUL)
+#define ISP_POSTCDN_RSEGU45 (ISP_BASE_ADDR+0x5E30UL)
+#define ISP_POSTCDN_RSEGU6 (ISP_BASE_ADDR+0x5E34UL)
+#define ISP_POSTCDN_RSEGV01 (ISP_BASE_ADDR+0x5E38UL)
+#define ISP_POSTCDN_RSEGV23 (ISP_BASE_ADDR+0x5E3CUL)
+#define ISP_POSTCDN_RSEGV45 (ISP_BASE_ADDR+0x5E40UL)
+#define ISP_POSTCDN_RSEGV6 (ISP_BASE_ADDR+0x5E44UL)
+#define ISP_POSTCDN_R_DISTW0 (ISP_BASE_ADDR+0x5E48UL)
+#define ISP_POSTCDN_START_ROW_MOD4 (ISP_BASE_ADDR+0x5E84UL)
+
+/*isp sub block: ygamma*/
+#define ISP_YGAMMA_STATUS (ISP_BASE_ADDR+0x6000UL)
+#define ISP_YGAMMA_PARAM (ISP_BASE_ADDR+0x6014UL)
+
+/*isp sub block: ydelay*/
+#define ISP_YDELAY_STATUS (ISP_BASE_ADDR+0x6100UL)
+#define ISP_YDELAY_PARAM (ISP_BASE_ADDR+0x6114UL)
+
+/*isp sub block: iircnr*/
+#define ISP_IIRCNR_STATUS0 (ISP_BASE_ADDR+0x6400UL)
+#define ISP_IIRCNR_STATUS1 (ISP_BASE_ADDR+0x6404UL)
+#define ISP_IIRCNR_PARAM (ISP_BASE_ADDR+0x6414UL)
+#define ISP_IIRCNR_PARAM1 (ISP_BASE_ADDR+0x6418UL)
+#define ISP_IIRCNR_PARAM2 (ISP_BASE_ADDR+0x641CUL)
+#define ISP_IIRCNR_PARAM3 (ISP_BASE_ADDR+0x6420UL)
+#define ISP_IIRCNR_PARAM4 (ISP_BASE_ADDR+0x6424UL)
+#define ISP_IIRCNR_PARAM5 (ISP_BASE_ADDR+0x6428UL)
+#define ISP_IIRCNR_PARAM6 (ISP_BASE_ADDR+0x642CUL)
+#define ISP_IIRCNR_PARAM7 (ISP_BASE_ADDR+0x6430UL)
+#define ISP_IIRCNR_PARAM8 (ISP_BASE_ADDR+0x6434UL)
+#define ISP_IIRCNR_PARAM9 (ISP_BASE_ADDR+0x6438UL)
+#define ISP_YRANDOM_PARAM0 (ISP_BASE_ADDR+0x643CUL)
+#define ISP_YRANDOM_PARAM1 (ISP_BASE_ADDR+0x6440UL)
+#define ISP_YRANDOM_PARAM2 (ISP_BASE_ADDR+0x6444UL)
+#define ISP_YRANDOM_STATUS0 (ISP_BASE_ADDR+0x6448UL)
+#define ISP_YRANDOM_STATUS1 (ISP_BASE_ADDR+0x644CUL)
+#define ISP_YRANDOM_STATUS2 (ISP_BASE_ADDR+0x6450UL)
+
+#define ISP_AXI_MASTER (ISP_BASE_ADDR+0x2000UL)
+#define ISP_AXI_MASTER_STOP (ISP_BASE_ADDR+0X2054UL)
+#define ISP_REG_MAX_SIZE SPRD_ISP_SIZE
+
+/*pingpang buffer*/
+#define ISP_3D_LUT_BUF0_CH0 (ISP_BASE_ADDR+0x17000UL)
+#define ISP_HSV_BUF0_CH0 (ISP_BASE_ADDR+0x18000UL)
+#define ISP_VST_BUF0_CH0 (ISP_BASE_ADDR+0x19000UL)
+#define ISP_IVST_BUF0_CH0 (ISP_BASE_ADDR+0x1A000UL)
+#define ISP_FGAMMA_R_BUF0_CH0 (ISP_BASE_ADDR+0x1B000UL)
+#define ISP_FGAMMA_G_BUF0_CH0 (ISP_BASE_ADDR+0x1C000UL)
+#define ISP_FGAMMA_B_BUF0_CH0 (ISP_BASE_ADDR+0x1D000UL)
+#define ISP_YGAMMA_BUF0_CH0 (ISP_BASE_ADDR+0x1E000UL)
+#define ISP_NLM_BUF0_CH0 (ISP_BASE_ADDR+0x1F000UL)
+#define ISP_3D_LUT_BUF1_CH0 (ISP_BASE_ADDR+0x20000UL)
+#define ISP_HSV_BUF1_CH0 (ISP_BASE_ADDR+0x21000UL)
+#define ISP_VST_BUF1_CH0 (ISP_BASE_ADDR+0x22000UL)
+#define ISP_IVST_BUF1_CH0 (ISP_BASE_ADDR+0x23000UL)
+#define ISP_FGAMMA_R_BUF1_CH0 (ISP_BASE_ADDR+0x24000UL)
+#define ISP_FGAMMA_G_BUF1_CH0 (ISP_BASE_ADDR+0x25000UL)
+#define ISP_FGAMMA_B_BUF1_CH0 (ISP_BASE_ADDR+0x26000UL)
+#define ISP_YGAMMA_BUF1_CH0 (ISP_BASE_ADDR+0x27000UL)
+#define ISP_NLM_BUF1_CH0 (ISP_BASE_ADDR+0x28000UL)
+#define ISP_LEN_BUF0_CH0 (ISP_BASE_ADDR+0x29000UL)
+#define ISP_LEN_BUF1_CH0 (ISP_BASE_ADDR+0x2b000UL)
+
+#define ISP_AHB_BASE SPRD_MMAHB_BASE
+#define ISP_MODULE_EB (ISP_AHB_BASE+0x0000UL)
+#define ISP_MODULE_RESET (ISP_AHB_BASE+0x0004UL)
+#define ISP_CORE_CLK_EB (ISP_AHB_BASE+0x0008UL)
+
+/*isp v memory1: awbm*/
+#define ISP_RAW_AWBM_OUTPUT (ISP_BASE_ADDR+0x10000)
+/*#define ISP_RAW_AWBM_ITEM 256*/
+
+/*isp v memory2: aem*/
+#define ISP_RAW_AEM_OUTPUT (ISP_BASE_ADDR+0x12000)
+/*#define ISP_RAW_AEM_ITEM 1024*/
+
+/*isp v memory3: yiq_aem*/
+#define ISP_YIQ_AEM_OUTPUT (ISP_BASE_ADDR+0x14000)
+/*#define ISP_YIQ_AEM_ITEM 1024*/
+
+/*isp v memory11: 3D_LUT0*/
+#define ISP_3D_LUT0_OUTPUT (ISP_BASE_ADDR+0x17000)
+/*#define ISP_3D_LUT0_ITEM 729*/
+
+/*isp v memory12: HSV BUF0*/
+#define ISP_HSV_BUF0_OUTPUT (ISP_BASE_ADDR+0x18000)
+/*#define ISP_HSV_ITEM 361*/
+
+/*isp v memory20: 3D_LUT1*/
+#define ISP_3D_LUT1_OUTPUT (ISP_BASE_ADDR+0x20000)
+/*#define ISP_3D_LUT1_ITEM 729*/
+
+/*isp v memory21: HSV BUF1*/
+#define ISP_HSV_BUF1_OUTPUT (ISP_BASE_ADDR+0x21000)
+/*#define ISP_HSV_ITEM 361*/
+
+/*irq line number in system*/
+#define ISP_IRQ IRQ_ISP_INT
+
+#define ISP_RST_LOG_BIT BIT_2
+#define ISP_RST_CFG_BIT BIT_3
+
+#define ISP_IRQ_HW_MASK (0xFFFFFFFF)
+#define ISP_IRQ_NUM (32)
+#define ISP_REG_BUF_SIZE (4 * 1024)
+#define ISP_RAW_AE_BUF_SIZE (1024 * 4 * 3)
+#define ISP_FRGB_GAMMA_BUF_SIZE (129 * 4)
+#define ISP_YUV_YGAMMA_BUF_SIZE (129 * 4)
+#define ISP_RAW_AWB_BUF_SIZE (256 * 4 * 9)
+#define ISP_BING4AWB_SIZE (640 * 480 * 2)
+#define ISP_YIQ_ANTIFLICKER_SIZE (3120 * 4 * 61)
+#define ISP_YIQ_AEM_BUF_SIZE (1024 * 4)
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_cfg_param.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_cfg_param.c
new file mode 100644
index 00000000..17fb3198
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_cfg_param.c
@@ -0,0 +1,131 @@
+/*
+ * 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_block.h"
+
+typedef int32_t (*isp_cfg_fun_ptr)(struct isp_io_param *isp_param);
+
+struct isp_cfg_fun {
+ uint32_t sub_block;
+ isp_cfg_fun_ptr cfg_fun;
+};
+
+static struct isp_cfg_fun isp_cfg_fun_tab[] = {
+ {ISP_BLOCK_PRE_GLB_GAIN, isp_k_cfg_pgg},
+ {ISP_BLOCK_BLC, isp_k_cfg_blc},
+ {ISP_BLOCK_RGB_GAIN, isp_k_cfg_rgb_gain},
+ {ISP_BLOCK_PRE_WAVELET, isp_k_cfg_pwd},
+ {ISP_BLOCK_NLC, isp_k_cfg_nlc},
+ /*{ISP_BLOCK_2D_LSC, isp_k_cfg_2d_lsc},*/
+ {ISP_BLOCK_1D_LSC, isp_k_cfg_1d_lsc},
+ /*{ISP_BLOCK_BINNING4AWB, isp_k_cfg_binning},*/
+ /*{ISP_BLOCK_AWB, isp_k_cfg_awb},*/
+ /*{ISP_BLOCK_RAW_AEM, isp_k_cfg_raw_aem},*/
+ {ISP_BLOCK_BPC, isp_k_cfg_bpc},
+ {ISP_BLOCK_BDN, isp_k_cfg_bdn},
+ {ISP_BLOCK_GRGB, isp_k_cfg_grgb},
+ {ISP_BLOCK_RGB_GAIN2, isp_k_cfg_rgb_gain2},
+ {ISP_BLOCK_NLM, isp_k_cfg_nlm},
+ {ISP_BLOCK_CFA, isp_k_cfg_cfa},
+ {ISP_BLOCK_CMC, isp_k_cfg_cmc10},
+ /*{ISP_BLOCK_GAMMA, isp_k_cfg_gamma},*/
+ {ISP_BLOCK_CMC8, isp_k_cfg_cmc8},
+ /*{ISP_BLOCK_CT, isp_k_cfg_ct},*/
+ {ISP_BLOCK_CCE, isp_k_cfg_cce},
+ {ISP_BLOCK_HSV, isp_k_cfg_hsv},
+ {ISP_BLOCK_CSC, isp_k_cfg_csc},
+ {ISP_BLOCK_PRE_CDN_RGB, isp_k_cfg_pre_cdn_rgb},
+ {ISP_BLOCK_POSTERIZE, isp_k_cfg_posterize},
+ {ISP_BLOCK_AFM_V1, isp_k_cfg_rgb_afm},
+ /*{ISP_BLOCK_YIQ_AEM, isp_k_cfg_yiq_aem},*/
+ /*{ISP_BLOCK_ANTI_FLICKER, isp_k_cfg_anti_flicker},*/
+ {ISP_BLOCK_YIQ_AFM, isp_k_cfg_yiq_afm},
+ {ISP_BLOCK_YUV_PRECDN, isp_k_cfg_yuv_precdn},
+ {ISP_BLOCK_PRE_FILTER, isp_k_cfg_prefilter},
+ {ISP_BLOCK_BRIGHTNESS, isp_k_cfg_brightness},
+ {ISP_BLOCK_CONTRAST, isp_k_cfg_contrast},
+ {ISP_BLOCK_HIST, isp_k_cfg_hist},
+ {ISP_BLOCK_HIST2, isp_k_cfg_hist2},
+ {ISP_BLOCK_ACA, isp_k_cfg_aca},
+ {ISP_BLOCK_YUV_CDN, isp_k_cfg_yuv_cdn},
+ {ISP_BLOCK_EDGE, isp_k_cfg_edge},
+ {ISP_BLOCK_CSS, isp_k_cfg_css},
+ {ISP_BLOCK_CSA, isp_k_cfg_csa},
+ {ISP_BLOCK_HUE, isp_k_cfg_hue},
+ {ISP_BLOCK_POST_CDN, isp_k_cfg_post_cdn},
+ {ISP_BLOCK_EMBOSS, isp_k_cfg_emboss},
+ /*{ISP_BLOCK_YGAMMA, isp_k_cfg_ygamma},*/
+ {ISP_BLOCK_YDELAY, isp_k_cfg_ydelay},
+ {ISP_BLOCK_IIRCNR, isp_k_cfg_iircnr},
+ {ISP_BLOCK_FETCH, isp_k_cfg_fetch},
+ {ISP_BLOCK_STORE, isp_k_cfg_store},
+ {ISP_BLOCK_DISPATCH, isp_k_cfg_dispatch},
+ {ISP_BLOCK_ARBITER_V1, isp_k_cfg_arbiter},
+ {ISP_BLOCK_RAW_SIZER, isp_k_cfg_raw_sizer},
+ {ISP_BLOCK_COMMON_V1, isp_k_cfg_common},
+};
+
+int32_t isp_cfg_param(void *param, struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t i = 0, cnt = 0;
+ isp_cfg_fun_ptr cfg_fun_ptr = NULL;
+ struct isp_io_param isp_param = {0, 0, 0, NULL};
+
+ if (!param) {
+ printk("isp_cfg_param: param is null error.\n");
+ return -1;
+ }
+
+ ret = copy_from_user((void *)&isp_param, (void *)param, sizeof(isp_param));
+ if ( 0 != ret) {
+ printk("isp_cfg_param: copy error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (ISP_BLOCK_ANTI_FLICKER == isp_param.sub_block) {
+ ret = isp_k_cfg_anti_flicker(&isp_param, isp_private);
+ } else if (ISP_BLOCK_2D_LSC == isp_param.sub_block) {
+ ret = isp_k_cfg_2d_lsc(&isp_param, isp_private);
+ } else if (ISP_BLOCK_RAW_AEM == isp_param.sub_block) {
+ ret = isp_k_cfg_raw_aem(&isp_param, isp_private);
+ } else if (ISP_BLOCK_YIQ_AEM == isp_param.sub_block) {
+ ret = isp_k_cfg_yiq_aem(&isp_param, isp_private);
+ } else if (ISP_BLOCK_GAMMA == isp_param.sub_block) {
+ ret = isp_k_cfg_gamma(&isp_param, isp_private);
+ } else if (ISP_BLOCK_CT == isp_param.sub_block) {
+ ret = isp_k_cfg_ct(&isp_param, isp_private);
+ } else if (ISP_BLOCK_YGAMMA == isp_param.sub_block) {
+ ret = isp_k_cfg_ygamma(&isp_param, isp_private);
+ } else if (ISP_BLOCK_AWB == isp_param.sub_block) {
+ ret = isp_k_cfg_awb(&isp_param, isp_private);
+ } else if(ISP_BLOCK_BINNING4AWB == isp_param.sub_block){
+ ret = isp_k_cfg_binning(&isp_param, isp_private);
+ } else {
+ cnt = sizeof(isp_cfg_fun_tab) / sizeof(isp_cfg_fun_tab[0]);
+ for (i = 0; i < cnt; i++) {
+ if (isp_param.sub_block == isp_cfg_fun_tab[i].sub_block) {
+ cfg_fun_ptr = isp_cfg_fun_tab[i].cfg_fun;
+ break;
+ }
+ }
+
+ if (NULL != cfg_fun_ptr)
+ ret = cfg_fun_ptr(&isp_param);
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_1d_lsc.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_1d_lsc.c
new file mode 100644
index 00000000..3daa3ef5
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_1d_lsc.c
@@ -0,0 +1,146 @@
+/*
+ * 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"
+
+static int32_t isp_k_1d_lsc_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_1d_lsc_info lnc_info;
+
+ ret = copy_from_user((void *)&lnc_info, param->property_param, sizeof(lnc_info));
+ if (0 != ret) {
+ printk("isp_k_1d_lsc_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_1D_LNC_PARAM, BIT_0, lnc_info.bypass);
+
+ val = (lnc_info.gain_max_thr & 0x1FFF) << 1;
+ REG_MWR(ISP_1D_LNC_PARAM, 0x3FFE, val);
+
+ val = ((lnc_info.center_r0c0_col_x & 0x1FFF) << 12) | (lnc_info.center_r0c0_row_y & 0xFFF);
+ REG_WR(ISP_1D_LNC_PARAM1, val);
+ val = ((lnc_info.center_r0c1_col_x & 0x1FFF) << 12) | (lnc_info.center_r0c1_row_y & 0xFFF);
+ REG_WR(ISP_1D_LNC_PARAM2, val);
+ val = ((lnc_info.center_r1c0_col_x & 0x1FFF) << 12) | (lnc_info.center_r1c0_row_y & 0xFFF);
+ REG_WR(ISP_1D_LNC_PARAM3, val);
+ val = ((lnc_info.center_r1c1_col_x & 0x1FFF) << 12) | (lnc_info.center_r1c1_row_y & 0xFFF);
+ REG_WR(ISP_1D_LNC_PARAM4, val);
+
+ val = lnc_info.delta_square_r0c0_x & 0x3FFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM5, val);
+ val = lnc_info.delta_square_r0c1_x & 0x3FFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM7, val);
+ val = lnc_info.delta_square_r1c0_x & 0x3FFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM9, val);
+ val = lnc_info.delta_square_r1c1_x & 0x3FFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM11, val);
+ val = lnc_info.delta_square_r0c0_y & 0xFFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM6, val);
+ val = lnc_info.delta_square_r0c1_y & 0xFFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM8, val);
+ val = lnc_info.delta_square_r1c0_y & 0xFFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM10, val);
+ val = lnc_info.delta_square_r1c1_y & 0xFFFFFF;
+ REG_WR(ISP_1D_LNC_PARAM12, val);
+
+ val = ((lnc_info.coef_r0c0_p1 & 0xFFFF) << 11) | (lnc_info.coef_r0c0_p2 & 0x7FF);
+ REG_WR(ISP_1D_LNC_PARAM13, val);
+ val = ((lnc_info.coef_r0c1_p1 & 0xFFFF) << 11) | (lnc_info.coef_r0c1_p2 & 0x7FF);
+ REG_WR(ISP_1D_LNC_PARAM14, val);
+ val = ((lnc_info.coef_r1c0_p1 & 0xFFFF) << 11) | (lnc_info.coef_r1c0_p2 & 0x7FF);
+ REG_WR(ISP_1D_LNC_PARAM15, val);
+ val = ((lnc_info.coef_r1c1_p1 & 0xFFFF) << 11) | (lnc_info.coef_r1c1_p2 & 0x7FF);
+ REG_WR(ISP_1D_LNC_PARAM16, val);
+
+ val = ((lnc_info.start_pos.x & 0x1FFF) << 12) | (lnc_info.start_pos.y & 0xFFF);
+ REG_WR(ISP_1D_LNC_PARAM18, val);
+
+ return ret;
+}
+
+static int32_t isp_k_1d_lsc_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size;
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
+ if (0 != ret) {
+ printk("isp_k_1d_lsc_slice_size: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.width & 0x1FFF) << 12) | (size.height & 0xFFF);
+
+ REG_WR(ISP_1D_LNC_PARAM17, val);
+
+ return ret;
+}
+
+static int32_t isp_k_1d_lsc_pos(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct img_offset pos;
+
+ ret = copy_from_user((void *)&pos, param->property_param, sizeof(struct img_offset));
+ if (0 != ret) {
+ printk("isp_k_1d_lsc_pos: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((pos.x & 0x1FFF) << 12) | (pos.y & 0xFFF);
+
+ REG_WR(ISP_1D_LNC_PARAM18, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_1d_lsc(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_1d_lsc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_1d_lsc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_1D_LSC_BLOCK:
+ ret = isp_k_1d_lsc_block(param);
+ break;
+ case ISP_PRO_1D_LSC_SLICE_SIZE:
+ ret = isp_k_1d_lsc_slice_size(param);
+ break;
+ case ISP_PRO_1D_LSC_POS:
+ ret = isp_k_1d_lsc_pos(param);
+ break;
+ default:
+ printk("isp_k_cfg_1d_lsc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_2d_lsc.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_2d_lsc.c
new file mode 100644
index 00000000..b0c4bd74
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_2d_lsc.c
@@ -0,0 +1,537 @@
+/*
+ * 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 <asm/cacheflush.h>
+#include <linux/delay.h>
+#include "isp_reg.h"
+#include "isp_drv.h"
+
+
+#define ISP_LSC_TIME_OUT_MAX 5
+#define ISP_LSC_BUF0 0
+#define ISP_LSC_BUF1 1
+
+#if 0
+#define CLIP(input,top, bottom) {if (input>top) input = top; if (input < bottom) input = bottom;}
+#define TABLE_LEN_128 128
+#define TABLE_LEN_96 96
+
+typedef struct lnc_bicubic_weight_t_64_tag
+{
+ int16_t w0;
+ int16_t w1;
+ int16_t w2;
+ int16_t w3;
+}LNC_BICUBIC_WEIGHT_TABLE_T;
+////////10bit precision//////////////////////////////////////
+static LNC_BICUBIC_WEIGHT_TABLE_T lnc_bicubic_weight_t_96_simple[] =
+{
+ {0, 1024, 0},
+ {-5,1024, 6},
+ {-10,1023, 12},
+ {-15,1022, 18},
+ {-20,1020, 25},
+ {-24,1017, 32},
+ {-28,1014, 40},
+ {-32,1011, 48},
+ {-36,1007, 56},
+ {-39,1003, 65},
+ {-43,998, 74},
+ {-46,993, 83},
+ {-49,987, 93},
+ {-52,981, 103},
+ {-54,974, 113},
+ {-57,967, 124},
+ {-59,960, 135},
+ {-61,952, 146},
+ {-63,944, 158},
+ {-65,936, 170},
+ {-67,927, 182},
+ {-68,918, 194},
+ {-70,908, 206},
+ {-71,898, 219},
+ {-72,888, 232},
+ {-73,878, 245},
+ {-74,867, 258},
+ {-74,856, 272},
+ {-75,844, 285},
+ {-75,833, 299},
+ {-76,821, 313},
+ {-76,809, 327},
+ {-76,796, 341},
+ {-76,784, 356},
+ {-76,771, 370},
+ {-75,758, 384},
+ {-75,745, 399},
+ {-75,732, 414},
+ {-74,718, 428},
+ {-73,704, 443},
+ {-73,691, 458},
+ {-72,677, 473},
+ {-71,663, 487},
+ {-70,648, 502},
+ {-69,634, 517},
+ {-68,620, 532},
+ {-67,605, 547},
+ {-65,591, 561},
+ {-64,576, 576},
+};
+
+static LNC_BICUBIC_WEIGHT_TABLE_T lnc_bicubic_weight_t_128_simple[] =
+{
+ {0, 1024, 0},
+ {-4, 1024, 4},
+ {-8, 1023, 8},
+ {-11, 1023, 13},
+ {-15, 1022, 18},
+ {-18, 1020, 23},
+ {-22, 1019, 28},
+ {-25, 1017, 34},
+ {-28, 1014, 40},
+ {-31, 1012, 46},
+ {-34, 1009, 52},
+ {-37, 1006, 58},
+ {-39, 1003, 65},
+ {-42, 999, 72},
+ {-44, 995, 78},
+ {-47, 991, 86},
+ {-49, 987, 93},
+ {-51, 982, 101},
+ {-53, 978, 108},
+ {-55, 973, 116},
+ {-57, 967, 124},
+ {-59, 962, 132},
+ {-60, 956, 141},
+ {-62, 950, 149},
+ {-63, 944, 158},
+ {-65, 938, 167},
+ {-66, 931, 176},
+ {-67, 925, 185},
+ {-68, 918, 194},
+ {-69, 910, 203},
+ {-70, 903, 213},
+ {-71, 896, 222},
+ {-72, 888, 232},
+ {-73, 880, 242},
+ {-73, 872, 252},
+ {-74, 864, 262},
+ {-74, 856, 272},
+ {-75, 847, 282},
+ {-75, 839, 292},
+ {-75, 830, 303},
+ {-76, 821, 313},
+ {-76, 812, 324},
+ {-76, 803, 334},
+ {-76, 793, 345},
+ {-76, 784, 356},
+ {-76, 774, 366},
+ {-76, 765, 377},
+ {-75, 755, 388},
+ {-75, 745, 399},
+ {-75, 735, 410},
+ {-74, 725, 421},
+ {-74, 715, 432},
+ {-73, 704, 443},
+ {-73, 694, 454},
+ {-72, 684, 465},
+ {-72, 673, 476},
+ {-71, 663, 487},
+ {-70, 652, 498},
+ {-69, 641, 510},
+ {-69, 631, 521},
+ {-68, 620, 532},
+ {-67, 609, 543},
+ {-66, 598, 554},
+ {-65, 587, 565},
+ {-64, 576, 576},
+};
+
+static uint16_t ISP_Cubic1D(uint16_t a, uint16_t b, uint16_t c, uint16_t d, uint16_t u, uint16_t box)
+{
+ int32_t out_value;
+ uint16_t out_value_uint16_t;
+ int16_t w0, w1, w2, w3;
+ uint32_t out_value_tmp;
+ int16_t sub_tmp0;
+ int16_t sub_tmp1;
+ int16_t sub_tmp2;
+
+ if(box ==96)
+ {
+ //use simple table
+ if ( u < (TABLE_LEN_96/2 + 1) )
+ {
+ w0 = lnc_bicubic_weight_t_96_simple[u].w0 ;
+ w1 = lnc_bicubic_weight_t_96_simple[u].w1 ;
+ w2 = lnc_bicubic_weight_t_96_simple[u].w2 ;
+
+ sub_tmp0 = a-d;
+ sub_tmp1 = b-d;
+ sub_tmp2 = c-d;
+ out_value_tmp = ((uint32_t)d)<<10;
+ out_value = out_value_tmp + sub_tmp0 * w0 + sub_tmp1 * w1 + sub_tmp2 * w2;
+ }
+ else
+ {
+ w1 = lnc_bicubic_weight_t_96_simple[TABLE_LEN_96 - u].w2 ;
+ w2 = lnc_bicubic_weight_t_96_simple[TABLE_LEN_96 - u].w1 ;
+ w3 = lnc_bicubic_weight_t_96_simple[TABLE_LEN_96 - u].w0 ;
+
+ sub_tmp0 = b-a;
+ sub_tmp1 = c-a;
+ sub_tmp2 = d-a;
+ out_value_tmp = ((uint32_t)a)<<10;
+ out_value = out_value_tmp + sub_tmp0 * w1 + sub_tmp1 * w2 + sub_tmp2 * w3;
+ }
+
+ }
+ else
+ {
+ u = u * (TABLE_LEN_128 / box);
+
+ //use simple table
+ if ( u < (TABLE_LEN_128/2 + 1) )
+ {
+ w0 = lnc_bicubic_weight_t_128_simple[u].w0 ;
+ w1 = lnc_bicubic_weight_t_128_simple[u].w1 ;
+ w2 = lnc_bicubic_weight_t_128_simple[u].w2 ;
+
+ sub_tmp0 = a-d;
+ sub_tmp1 = b-d;
+ sub_tmp2 = c-d;
+ out_value_tmp = ((uint32_t)d)<<10;
+ out_value = out_value_tmp + sub_tmp0 * w0 + sub_tmp1 * w1 + sub_tmp2 * w2;
+ }
+ else
+ {
+ w1 = lnc_bicubic_weight_t_128_simple[TABLE_LEN_128 - u].w2 ;
+ w2 = lnc_bicubic_weight_t_128_simple[TABLE_LEN_128 - u].w1 ;
+ w3 = lnc_bicubic_weight_t_128_simple[TABLE_LEN_128 - u].w0 ;
+
+ sub_tmp0 = b-a;
+ sub_tmp1 = c-a;
+ sub_tmp2 = d-a;
+ out_value_tmp = ((uint32_t)a)<<10;
+ out_value = out_value_tmp + sub_tmp0 * w1 + sub_tmp1 * w2 + sub_tmp2 * w3;
+ }
+ }
+
+ //CLIP(out_value, 4095*1024*2, 1024*1024); // for LSC gain, 1024 = 1.0, 4095 = 4.0 ; 4095*2 is for boundary extension.
+ CLIP(out_value, 16383*1024, 1024*1024); // for LSC gain, 1024 = 1.0, 16383 = 16.0 ; 16383 is for boundary extension, 14 bit parameter is used.
+
+ out_value_uint16_t = (uint16_t)((out_value + 512) >> 10);
+
+ return out_value_uint16_t;
+}
+
+
+static int32_t ISP_GenerateQValues(uint32_t word_endian, uint32_t q_val[][5], unsigned long param_address, uint16_t grid_w, uint16_t grid_num, uint16_t u)
+{
+ uint8_t i;
+ uint16_t A0, B0, C0, D0;
+ uint16_t A1, B1, C1, D1;
+ uint32_t *addr = (uint32_t *)param_address;
+
+ if (param_address == 0x0 || grid_num == 0x0) {
+ printk("ISP_GenerateQValues param_address error addr=0x%lx grid_num=%d \n",param_address, grid_num);
+ return -1;
+ }
+
+ //printk("ISP_GenerateQValues:addr=%x grid_w=%d grid_num=%d u=%d \n",param_address,grid_w,grid_num,u);
+ #if 0
+ for (i = 0; i < 5; i++) {
+ A0 = (uint16_t)*(addr + i * 2) & 0xFFFF;
+ B0 = (uint16_t)*(addr + i * 2 + grid_w * 2) & 0xFFFF;
+ C0 = (uint16_t)*(addr + i * 2 + grid_w * 2 * 2) & 0xFFFF;
+ D0 = (uint16_t)*(addr + i * 2 + grid_w * 2 * 3) & 0xFFFF;
+ A1 = (uint16_t)(*(addr + i * 2) >> 16);
+ B1 = (uint16_t)(*(addr + i * 2 + grid_w * 2) >> 16);
+ C1 = (uint16_t)(*(addr + i * 2 + grid_w * 2 * 2) >> 16);
+ D1 = (uint16_t)(*(addr + i * 2 + grid_w * 2 * 3) >> 16);
+ q_val[0][i] = ISP_Cubic1D(A0, B0, C0, D0, u, grid_num);
+ q_val[1][i] = ISP_Cubic1D(A1, B1, C1, D1, u, grid_num);
+ }
+ #endif
+ #if 1
+ for (i = 0; i < 5; i++) {
+ if (1 == word_endian) { // ABCD = 1 word
+ A0 = *(addr + i * 2) >> 16; // AB
+ B0 = *(addr + i * 2 + grid_w * 2) >> 16; // AB
+ C0 = *(addr + i * 2 + grid_w * 2 * 2) >> 16; // AB
+ D0 = *(addr + i * 2 + grid_w * 2 * 3) >> 16; // AB
+ A1 = *(addr + i * 2) & 0xFFFF; // CD
+ B1 = *(addr + i * 2 + grid_w * 2) & 0xFFFF; // CD
+ C1 = *(addr + i * 2 + grid_w * 2 * 2) & 0xFFFF;// CD
+ D1 = *(addr + i * 2 + grid_w * 2 * 3) & 0xFFFF;// CD
+ } else if (2 == word_endian) { // CDAB = 1 word
+ A0 = *(addr + i * 2) & 0xFFFF;
+ B0 = *(addr + i * 2 + grid_w * 2) & 0xFFFF;
+ C0 = *(addr + i * 2 + grid_w * 2 * 2) & 0xFFFF;
+ D0 = *(addr + i * 2 + grid_w * 2 * 3) & 0xFFFF;
+ A1 = *(addr + i * 2) >> 16;
+ B1 = *(addr + i * 2 + grid_w * 2) >> 16;
+ C1 = *(addr + i * 2 + grid_w * 2 * 2) >> 16;
+ D1 = *(addr + i * 2 + grid_w * 2 * 3) >> 16;
+ } else if (0 == word_endian) { // DCBA = 1 word
+ A0 = ((*(addr + i * 2) << 8) & 0x0000FF00) | ((*(addr + i * 2) >> 8) & 0x000000FF);
+ B0 = ((*(addr + i * 2 + grid_w * 2) << 8) & 0x0000FF00) | ((*(addr + i * 2 + grid_w * 2) >> 8) & 0x000000FF);
+ C0 = ((*(addr + i * 2 + grid_w * 2 * 2) << 8) & 0x0000FF00) | ((*(addr + i * 2 + grid_w * 2 * 2) >> 8) & 0x000000FF);
+ D0 = ((*(addr + i * 2 + grid_w * 2 * 3) << 8) & 0x0000FF00) | ((*(addr + i * 2 + grid_w * 2 * 3) >> 8) & 0x000000FF);
+ A1 = ((*(addr + i * 2) << 8) & 0xFF000000) | ((*(addr + i * 2) >> 8) & 0x00FF0000);
+ B1 = ((*(addr + i * 2 + grid_w * 2) << 8) & 0xFF000000) | ((*(addr + i * 2 + grid_w * 2) >> 8) & 0x00FF0000);
+ C1 = ((*(addr + i * 2 + grid_w * 2 * 2) << 8) & 0xFF000000) | ((*(addr + i * 2 + grid_w * 2 * 2) >> 8) & 0x00FF0000);
+ D1 = ((*(addr + i * 2 + grid_w * 2 * 3) << 8) & 0xFF000000) | ((*(addr + i * 2 + grid_w * 2 * 3) >> 8) & 0x00FF0000);
+ } else if (3 == word_endian) { // BADC = 1 word
+ A0 = ((*(addr + i * 2) << 8) & 0xFF000000) | ((*(addr + i * 2) >> 8) & 0x00FF0000);
+ B0 = ((*(addr + i * 2 + grid_w * 2) << 8) & 0xFF000000) | ((*(addr + i * 2 + grid_w * 2) >> 8) & 0x00FF0000);
+ C0 = ((*(addr + i * 2 + grid_w * 2 * 2) << 8) & 0xFF000000) | ((*(addr + i * 2 + grid_w * 2 * 2) >> 8) & 0x00FF0000);
+ D0 = ((*(addr + i * 2 + grid_w * 2 * 3) << 8) & 0xFF000000) | ((*(addr + i * 2 + grid_w * 2 * 3) >> 8) & 0x00FF0000);
+ A1 = ((*(addr + i * 2) << 8) & 0x0000FF00) | ((*(addr + i * 2) >> 8) & 0x000000FF);
+ B1 = ((*(addr + i * 2 + grid_w * 2) << 8) & 0x0000FF00) | ((*(addr + i * 2 + grid_w * 2) >> 8) & 0x000000FF);
+ C1 = ((*(addr + i * 2 + grid_w * 2 * 2) << 8) & 0x0000FF00) | ((*(addr + i * 2 + grid_w * 2 * 2) >> 8) & 0x000000FF);
+ D1 = ((*(addr + i * 2 + grid_w * 2 * 3) << 8) & 0x0000FF00) | ((*(addr + i * 2 + grid_w * 2 * 3) >> 8) & 0x000000FF);
+ }
+ //printk("ISP_GenerateQValues: A0=%x B0=%x C0=%x D0=%x A1=%x B1=%x C1=%x D1=%x \n",A0,B0,C0,D0,A1,B1,C1,D1);
+ q_val[0][i] = ISP_Cubic1D(A0, B0, C0, D0, u, grid_num);
+ q_val[1][i] = ISP_Cubic1D(A1, B1, C1, D1, u, grid_num);
+ //printk("ISP_GenerateQValues: q_val[0][%d] = %d q_val[1][%d] = %d \n",i,q_val[0][i],i ,q_val[1][i] );
+ }
+ #endif
+
+ return 0;
+}
+#endif
+
+static int32_t isp_k_2d_lsc_param_load(struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t time_out_cnt = 0;
+ uint32_t addr = 0, reg_value = 0;
+
+ if (ISP_LSC_BUF0 == isp_private->lsc_load_buf_id) {
+ isp_private->lsc_load_buf_id = ISP_LSC_BUF1;
+ } else {
+ isp_private->lsc_load_buf_id = ISP_LSC_BUF0;
+ }
+ REG_MWR(ISP_LENS_LOAD_BUF, BIT_0, isp_private->lsc_load_buf_id);
+ REG_WR(ISP_LENS_PARAM_ADDR, isp_private->lsc_buf_phys_addr);
+ REG_OWR(ISP_LENS_LOAD_EB, BIT_0);
+ REG_MWR(ISP_LENS_PARAM, BIT_1, isp_private->lsc_load_buf_id << 1);
+ isp_private->lsc_update_buf_id = isp_private->lsc_load_buf_id;
+
+ reg_value = REG_RD(ISP_INT_RAW0);
+
+ while ((0x00 == (reg_value & ISP_INT_EVT_LSC_LOAD))
+ && (time_out_cnt < ISP_LSC_TIME_OUT_MAX)) {
+ msleep(1);
+ reg_value = REG_RD(ISP_INT_RAW0);
+ time_out_cnt++;
+ }
+ if (time_out_cnt >= ISP_LSC_TIME_OUT_MAX) {
+ ret = -1;
+ printk("isp_k_2d_lsc_param_load: lsc load time out error.\n");
+ }
+ REG_OWR(ISP_INT_CLR0, ISP_INT_EVT_LSC_LOAD);
+
+ return ret;
+}
+
+static int32_t isp_k_2d_lsc_block(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ //uint32_t qvalue_addr = ISP_LEN_BUF0_CH0;
+ struct isp_dev_2d_lsc_info lens_info;
+
+ memset(&lens_info, 0x00, sizeof(lens_info));
+
+ ret = copy_from_user((void *)&lens_info, param->property_param, sizeof(lens_info));
+ if (0 != ret) {
+ printk("isp_k_2d_lsc_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((lens_info.offset_y & 0xFFFF) << 16) | (lens_info.offset_x & 0xFFFF);
+ REG_WR(ISP_LENS_SLICE_POS, val);
+
+ val = lens_info.grid_pitch & 0x1FF;
+ REG_MWR(ISP_LENS_GRID_PITCH, 0x1FF, val);
+
+ val = (lens_info.grid_width & 0xFF) << 16;
+ REG_MWR(ISP_LENS_GRID_PITCH, 0xFF0000, val);
+
+ val = ((lens_info.grid_num_t & 0xFFFF) << 16) | ((lens_info.grid_y_num & 0xFF) << 8) | (lens_info.grid_x_num & 0xFF);
+ REG_WR(ISP_LENS_GRID_SIZE, val);
+
+ REG_MWR(ISP_LENS_LOAD_BUF, BIT_1, lens_info.load_chn_sel << 1);
+
+ REG_MWR(ISP_LENS_MISC, (BIT_1 | BIT_0), (lens_info.endian & 0x03));
+
+ val = ((lens_info.slice_size.height & 0xFFFF) << 16) | (lens_info.slice_size.width & 0xFFFF);
+ REG_WR(ISP_LENS_SLICE_SIZE, val);
+
+ val = ((lens_info.relative_y & 0xFF) << 8) | (lens_info.relative_x & 0xFF);
+ REG_WR(ISP_LENS_INIT_COOR, val);
+
+ /*ret = isp_k_2d_lsc_param_load(&src_buf, isp_private, &qvalue_addr);
+ REG_WR(ISP_LENS_PARAM_ADDR, qvalue_addr);
+ printk("isp_k_2d_lsc_block:qvalue_addr=%x grid_x_num=%d grid_width=%d relative_y=%d \n",qvalue_addr,(lens_info.grid_x_num & 0xFF),(lens_info.grid_width & 0xFF), (lens_info.relative_y & 0xFF)>>1);
+
+ ISP_GenerateQValues(1, lens_info.q_value, qvalue_addr, ((uint16_t)lens_info.grid_x_num & 0xFF) + 2,(lens_info.grid_width & 0xFF), (lens_info.relative_y & 0xFF)>>1);
+ */
+
+ ret = isp_k_2d_lsc_param_load(isp_private);
+ if (0 != ret) {
+ printk("isp_k_2d_lsc_block: lsc load para error, ret=0x%x\n", (uint32_t)ret);
+ REG_MWR(ISP_LENS_PARAM, BIT_0, ISP_BYPASS_EB);
+ return -1;
+ }
+
+ for (i = 0; i < 5; i++) {
+ val = ((lens_info.q_value[0][i] & 0x3FFF) << 16) | (lens_info.q_value[1][i] & 0x3FFF);
+ REG_WR(ISP_LENS_Q0_VALUE + i * 4, val);
+ }
+
+ REG_MWR(ISP_LENS_PARAM, BIT_0, lens_info.bypass);
+
+ return ret;
+
+}
+
+static int32_t isp_k_2d_lsc_param_update(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ REG_MWR(ISP_LENS_PARAM, BIT_1, isp_private->lsc_update_buf_id << 1);
+
+ return ret;
+}
+
+static int32_t isp_k_2d_lsc_pos(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_offset offset = {0, 0};
+
+ ret = copy_from_user((void *)&offset, param->property_param, sizeof(offset));
+ if (0 != ret) {
+ printk("isp_k_lens_pos: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((offset.y & 0xFFFF) << 16) | (offset.x & 0xFFFF);
+
+ REG_WR(ISP_LENS_SLICE_POS, val);
+
+ return ret;
+}
+
+static int32_t isp_k_2d_lsc_grid_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t grid_total = 0;
+ struct isp_img_size size = {0, 0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(size));
+ if (0 != ret) {
+ printk("isp_k_2d_lsc_grid_size: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ grid_total = (size.height + 2) * (size.width + 2);
+ val = ((grid_total & 0xFFFF) << 16) | ((size.height & 0xFF) << 8) | (size.width & 0xFF);
+ REG_WR(ISP_LENS_GRID_SIZE, val);
+
+ return ret;
+}
+
+static int32_t isp_k_2d_lsc_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size = {0, 0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(size));
+ if (0 != ret) {
+ printk("isp_k_2d_lsc_slice_size: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height & 0xFFFF) << 16) | (size.width & 0xFFFF);
+
+ REG_WR(ISP_LENS_SLICE_SIZE, val);
+
+ return ret;
+}
+
+static int32_t isp_k_2d_lsc_transaddr(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ struct isp_lsc_addr lsc_addr;
+
+ ret = copy_from_user((void *)&lsc_addr, param->property_param, sizeof(struct isp_lsc_addr));
+
+ isp_private->lsc_buf_phys_addr = lsc_addr.phys_addr;
+
+ printk("lsc phys addr 0x%x,\n",isp_private->lsc_buf_phys_addr);
+ return ret;
+}
+
+int32_t isp_k_cfg_2d_lsc(struct isp_io_param *param, struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_2d_lsc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_2d_lsc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_2D_LSC_BLOCK:
+ ret = isp_k_2d_lsc_block(param, isp_private);
+ break;
+ case ISP_PRO_2D_LSC_PARAM_UPDATE:
+ ret = isp_k_2d_lsc_param_update(param, isp_private);
+ break;
+ case ISP_PRO_2D_LSC_POS:
+ ret = isp_k_2d_lsc_pos(param);
+ break;
+ case ISP_PRO_2D_LSC_GRID_SIZE:
+ ret = isp_k_2d_lsc_grid_size(param);
+ break;
+ case ISP_PRO_2D_LSC_SLICE_SIZE:
+ ret = isp_k_2d_lsc_slice_size(param);
+ break;
+ case ISP_PRO_2D_LSC_TRANSADDR:
+ ret = isp_k_2d_lsc_transaddr(param, isp_private);
+ break;
+ default:
+ printk("isp_k_cfg_2d_lsc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_aca.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_aca.c
new file mode 100644
index 00000000..0d784c73
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_aca.c
@@ -0,0 +1,78 @@
+/*
+ * 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"
+
+static int32_t isp_k_aca_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_autocont_info_v1 autocont_info;
+ uint32_t val = 0;
+
+ memset(&autocont_info, 0x00, sizeof(autocont_info));
+
+ ret = copy_from_user((void *)&autocont_info, param->property_param, sizeof(autocont_info));
+ if (0 != ret) {
+ printk("isp_k_aca_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((autocont_info.out_max & 0xFF) << 24)
+ | ((autocont_info.out_min & 0xFF) << 16)
+ | ((autocont_info.in_max & 0xFF) << 8)
+ | (autocont_info.in_min & 0xFF);
+
+ REG_WR(ISP_AUTOCONT_MAX_MIN, val);
+
+ if (autocont_info.mode) {
+ REG_OWR(ISP_AUTOCONT_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_AUTOCONT_PARAM, BIT_1, 0);
+ }
+
+ if (autocont_info.bypass) {
+ REG_OWR(ISP_AUTOCONT_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_AUTOCONT_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_aca(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_aca: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_aca: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_ACA_BLOCK:
+ ret = isp_k_aca_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_aca: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_anti_flicker.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_anti_flicker.c
new file mode 100755
index 00000000..e1f29d71
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_anti_flicker.c
@@ -0,0 +1,150 @@
+/*
+ * 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 <asm/cacheflush.h>
+#include "isp_reg.h"
+#include "isp_drv.h"
+
+static int32_t isp_k_afl_param_update(struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t addr = 0;
+#ifndef CONFIG_64BIT
+ void *buf_ptr = (void *)isp_private->yiq_antiflicker_buf_addr;
+#endif
+ uint32_t buf_len = isp_private->yiq_antiflicker_len;
+
+ if((0x00 != isp_private->yiq_antiflicker_buf_addr) && (0x00 != isp_private->yiq_antiflicker_len)) {
+
+#ifndef CONFIG_64BIT
+ dmac_flush_range(buf_ptr, buf_ptr + buf_len);
+ outer_flush_range(__pa(buf_ptr), __pa(buf_ptr) + buf_len);
+#endif
+ addr = (uint32_t)__pa(isp_private->yiq_antiflicker_buf_addr);
+
+ REG_WR(ISP_ANTI_FLICKER_DDR_INIT_ADDR, addr);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_afl_statistic(struct isp_io_param *param, struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ int32_t i = 0;
+ int32_t *addr = NULL;
+ if((0x00 != isp_private->yiq_antiflicker_buf_addr) && (0x00 != param->property_param) \
+ && (0x00 != isp_private->yiq_antiflicker_len) ) {
+
+ ret = copy_to_user(param->property_param, isp_private->yiq_antiflicker_buf_addr, isp_private->yiq_antiflicker_len);
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_afl_statistic: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ }
+}
+
+static int32_t isp_k_afl_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
+ if (0 != ret) {
+ printk("isp_k_afl_bypass: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (bypass) {
+ REG_OWR(ISP_ANTI_FLICKER_PARAM0, BIT_0);
+ } else {
+ REG_MWR(ISP_ANTI_FLICKER_PARAM0, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+
+static int32_t isp_k_anti_flicker_block(struct isp_io_param *param, struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ struct isp_dev_anti_flicker_info_v1 afl_info;
+
+ memset(&afl_info, 0x00, sizeof(afl_info));
+
+ ret = copy_from_user((void *)&afl_info, param->property_param, sizeof(afl_info));
+ if (0 != ret) {
+ printk("isp_k_anti_flicker_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_ANTI_FLICKER_PARAM0, BIT_0, afl_info.bypass);
+
+ REG_MWR(ISP_ANTI_FLICKER_PARAM0, BIT_1, afl_info.mode << 1);
+
+ REG_MWR(ISP_ANTI_FLICKER_PARAM0, 0xF << 2, afl_info.skip_frame_num << 2);
+
+ REG_MWR(ISP_ANTI_FLICKER_PARAM1, 0xF , afl_info.line_step);
+
+ REG_MWR(ISP_ANTI_FLICKER_PARAM1, 0xFF << 8, afl_info.frame_num << 8);
+
+ REG_MWR(ISP_ANTI_FLICKER_PARAM1, 0xFFFF << 16, afl_info.vheight << 16);
+
+ REG_MWR(ISP_ANTI_FLICKER_COL_POS, 0xFFFF , afl_info.start_col);
+
+ REG_MWR(ISP_ANTI_FLICKER_COL_POS, 0xFFFF << 16, afl_info.end_col << 16);
+
+ //config afl DDR initial address
+ isp_k_afl_param_update(isp_private);
+
+ //REG_WR(ISP_ANTI_FLICKER_DDR_INIT_ADDR, afl_info.addr);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_anti_flicker(struct isp_io_param *param, struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_anti_flicker: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_anti_flicker: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_ANTI_FLICKER_BLOCK:
+ ret = isp_k_anti_flicker_block(param, isp_private);
+ break;
+ case ISP_PRO_ANTI_FLICKER_STATISTIC:
+ ret = isp_k_afl_statistic(param, isp_private);
+ break;
+ case ISP_PRO_ANTI_FLICKER_BYPASS:
+ ret = isp_k_afl_bypass(param);
+ break;
+ default:
+ printk("isp_k_cfg_anti_flicker: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_arbiter.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_arbiter.c
new file mode 100644
index 00000000..4031b04e
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_arbiter.c
@@ -0,0 +1,177 @@
+/*
+ * 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"
+
+static int32_t isp_k_arbiter_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_arbiter_info_v1 arbiter_info;
+ uint32_t val = 0;
+
+ memset(&arbiter_info, 0x00, sizeof(arbiter_info));
+
+ ret = copy_from_user((void *)&arbiter_info, param->property_param, sizeof(arbiter_info));
+ if (0 != ret) {
+ printk("isp_k_arbiter_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((arbiter_info.endian_ch0.bpc_endian & 0x3) << 8) | ((arbiter_info.endian_ch0.lens_endian & 0x3) << 6)
+ | ((arbiter_info.endian_ch0.store_endian & 0x3) << 4) | ((arbiter_info.endian_ch0.fetch_bit_reorder & 0x1) << 2)
+ | (arbiter_info.endian_ch0.fetch_endian & 0x3);
+ REG_WR(ISP_ARBITER_ENDIAN_CH0, val);
+
+ val = ((arbiter_info.endian_ch1.bpc_endian & 0x3) << 8) | ((arbiter_info.endian_ch1.lens_endian & 0x3) << 6)
+ | ((arbiter_info.endian_ch1.store_endian & 0x3) << 4) | ((arbiter_info.endian_ch1.fetch_bit_reorder & 0x1) << 2)
+ | (arbiter_info.endian_ch1.fetch_endian & 0x3);
+ REG_WR(ISP_ARBITER_ENDIAN_CH1, val);
+
+ val = (arbiter_info.para.pause_cycle & 0xFF) | ((arbiter_info.para.reset & 0x1) << 8);
+ REG_WR(ISP_ARBITER_PARAM, val);
+
+ return ret;
+}
+
+static int32_t isp_k_arbiter_wr_status(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t status = 0;
+
+ status = REG_RD(ISP_PRO_ARBITER_WR_STATUS);
+
+ ret = copy_to_user(param->property_param, (void*)&status, sizeof(status));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_arbiter_wr_status: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_arbiter_rd_status(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t status = 0;
+
+ status = REG_RD(ISP_PRO_ARBITER_RD_STATUS);
+
+ ret = copy_to_user(param->property_param, (void*)&status, sizeof(status));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_arbiter_rd_status: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_arbiter_endian_ch0(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct arbiter_endian_v1 endian = {0};
+
+ ret = copy_from_user((void *)&endian, param->property_param, sizeof(endian));
+ if (0 != ret) {
+ printk("isp_k_arbiter_endian_ch0: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((endian.bpc_endian & 0x3) << 8) | ((endian.lens_endian & 0x3) << 6) | ((endian.store_endian & 0x3) << 4)
+ | ((endian.fetch_bit_reorder & 0x1) << 2) | (endian.fetch_endian & 0x3);
+ REG_WR(ISP_ARBITER_ENDIAN_CH0, val);
+
+ return ret;
+}
+
+static int32_t isp_k_arbiter_endian_ch1(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct arbiter_endian_v1 endian = {0};
+
+ ret = copy_from_user((void *)&endian, param->property_param, sizeof(endian));
+ if (0 != ret) {
+ printk("isp_k_arbiter_endian_ch1: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((endian.bpc_endian & 0x3) << 8) | ((endian.lens_endian & 0x3) << 6) | ((endian.store_endian & 0x3) << 4)
+ | ((endian.fetch_bit_reorder & 0x1) << 2) | (endian.fetch_endian & 0x3);
+ REG_WR(ISP_ARBITER_ENDIAN_CH1, val);
+
+ return ret;
+}
+
+static int32_t isp_k_arbiter_param(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct arbiter_param_v1 para = {0};
+
+ ret = copy_from_user((void *)&para, param->property_param, sizeof(para));
+ if (0 != ret) {
+ printk("isp_k_arbiter_param: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (para.pause_cycle & 0xFF) | ((para.reset & 0x1) << 8);
+ REG_WR(ISP_ARBITER_PARAM, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_arbiter(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_arbiter: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_arbiter: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_ARBITER_BLOCK:
+ ret = isp_k_arbiter_block(param);
+ break;
+ case ISP_PRO_ARBITER_WR_STATUS:
+ ret = isp_k_arbiter_wr_status(param);
+ break;
+ case ISP_PRO_ARBITER_RD_STATUS:
+ ret = isp_k_arbiter_rd_status(param);
+ break;
+ case ISP_PRO_ARBITER_PARAM:
+ ret = isp_k_arbiter_param(param);
+ break;
+ case ISP_PRO_ARBITER_ENDIAN_CH0:
+ ret = isp_k_arbiter_endian_ch0(param);
+ break;
+ case ISP_PRO_ARBITER_ENDIAN_CH1:
+ ret = isp_k_arbiter_endian_ch1(param);
+ break;
+ default:
+ printk("isp_k_cfg_arbiter: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_awb.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_awb.c
new file mode 100644
index 00000000..0c33d355
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_awb.c
@@ -0,0 +1,192 @@
+/*
+ * 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"
+
+static int32_t isp_k_awb_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ struct isp_dev_awb_info_v1 awb_info;
+
+ memset(&awb_info, 0x00, sizeof(awb_info));
+
+ ret = copy_from_user((void *)&awb_info, param->property_param, sizeof(awb_info));
+ if (0 != ret) {
+ printk("isp_k_awbm_bypass: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ //printk("isp_k_awb_block: %d %d %d %d \n",awb_info.slice_size.width,awb_info.slice_size.height,awb_info.block_size.width,awb_info.block_size.height);
+ //printk("isp_k_awb_block: gain r=%d gr=%d b=%d \n",awb_info.gain.r,awb_info.gain.gr,awb_info.gain.b);
+ //printk("isp_k_awb_block: offset r=%d gr=%d b=%d \n",awb_info.gain_offset.r,awb_info.gain_offset.gr,awb_info.gain_offset.b);
+ /*AWBM*/
+
+ REG_MWR(ISP_AWBM_PARAM, BIT_0, awb_info.awbm_bypass);
+
+ REG_MWR(ISP_AWBM_PARAM, BIT_1, awb_info.mode << 1);
+
+ val = (awb_info.skip_num & 0x0F) << 2;
+ REG_MWR(ISP_AWBM_PARAM, (BIT_5 | BIT_4 | BIT_3 | BIT_2), val);
+
+ val = ((awb_info.block_offset.y & 0xFFFF) << 16) | (awb_info.block_offset.x & 0xFFFF);
+ REG_WR(ISP_AWBM_BLOCK_OFFSET, val);
+
+ val = ((awb_info.block_size.height & 0x1FF) << 9) | (awb_info.block_size.width & 0x1FF);
+ REG_MWR(ISP_AWBM_BLOCK_SIZE, 0x1FFFF, val);
+
+ val = (awb_info.shift & 0x1F) << 18;
+ REG_MWR(ISP_AWBM_BLOCK_SIZE, (0x1F << 18), val);
+
+ REG_MWR(ISP_AWBM_PARAM, BIT_8, awb_info.thr_bypass << 8);
+
+ for (i = 0; i < 5; i++) {
+ val = ((awb_info.rect_pos.start_x[i] & 0x3FF) << 16) | (awb_info.rect_pos.start_y[i] & 0x3FF);
+ REG_WR(ISP_AWBM_WR_0_S + i * 8, val);
+ val = ((awb_info.rect_pos.end_x[i] & 0x3FF) << 16) | (awb_info.rect_pos.end_y[i] & 0x3FF);
+ REG_WR(ISP_AWBM_WR_0_E + i * 8, val);
+ }
+
+ for (i = 0; i < 5; i++) {
+ val = ((awb_info.circle_pos.x[i] & 0x3FF) << 18) | ((awb_info.circle_pos.y[i] & 0x3FF) << 8) | (awb_info.circle_pos.r[i] & 0xFF);
+ REG_WR(ISP_AWBM_NW_0_XYR + i * 4, val);
+ }
+
+ for (i = 0; i < 5; i++) {
+ val = ((awb_info.clctor_pos.start_x[i] & 0x3FF) << 16) | (awb_info.clctor_pos.start_y[i] & 0x3FF);
+ REG_WR(ISP_AWBM_CLCTOR_0_S + i * 8, val);
+ val = ((awb_info.clctor_pos.end_x[i] & 0x3FF) << 16) | (awb_info.clctor_pos.end_y[i] & 0x3FF);
+ REG_WR(ISP_AWBM_CLCTOR_0_E + i * 8, val);
+ }
+
+ val = ((awb_info.thr.g_low & 0x3FF) << 20) | ((awb_info.thr.r_high & 0x3FF) << 10) | (awb_info.thr.r_low & 0x3FF);
+ REG_WR(ISP_AWBM_THR_VALUE1, val);
+ val = ((awb_info.thr.b_high & 0x3FF) << 20) | ((awb_info.thr.b_low & 0x3FF) << 10) | (awb_info.thr.g_high & 0x3FF);
+ REG_WR(ISP_AWBM_THR_VALUE2, val);
+
+// val = ((awb_info.slice_size.height & 0xFFFF) << 16) | (awb_info.slice_size.width & 0xFFFF);
+// REG_WR(ISP_AEM_SLICE_SIZE, val);
+
+ REG_MWR(ISP_AWBM_PARAM, BIT_6, awb_info.skip_num_clear << 6);
+
+ REG_WR(ISP_AWBM_MEM_ADDR, awb_info.mem_addr);
+
+ /*AWBC*/
+
+ REG_MWR(ISP_AWBC_PARAM, BIT_0, awb_info.awbc_bypass);
+
+ REG_MWR(ISP_AWBC_PARAM, BIT_1, awb_info.alpha_bypass << 1);
+
+ val = (awb_info.alpha_value & 0x3FF) << 4;
+ REG_MWR(ISP_AWBC_PARAM, 0x3FF0, val);
+
+ REG_MWR(ISP_AWBC_PARAM, BIT_3, awb_info.buf_sel << 3);
+
+ val = ((awb_info.gain.b & 0x3FFF) << 16) | (awb_info.gain.r & 0x3FFF);
+ REG_WR(ISP_AWBC_GAIN0, val);
+ val = ((awb_info.gain.gb & 0x3FFF) << 16) | (awb_info.gain.gr & 0x3FFF);
+ REG_WR(ISP_AWBC_GAIN1, val);
+
+ val = ((awb_info.thrd.b & 0x3FF) << 20) | ((awb_info.thrd.g & 0x3FF) << 10) | (awb_info.thrd.r & 0x3FF);
+ REG_WR(ISP_AWBC_THRD, val);
+
+ val = ((awb_info.gain_offset.b & 0xFFFF) << 16) | (awb_info.gain_offset.r & 0xFFFF);
+ REG_WR(ISP_AWBC_OFFSET0, val);
+ val = ((awb_info.gain_offset.gb & 0xFFFF) << 16) | (awb_info.gain_offset.gr & 0xFFFF);
+ REG_WR(ISP_AWBC_OFFSET1, val);
+
+ val = ((awb_info.gain_buff.b & 0x3FFF) << 16) | (awb_info.gain_buff.r & 0x3FFF);
+ REG_WR(ISP_AWBC_GAIN0_BUF, val);
+ val = ((awb_info.gain_buff.gb & 0x3FFF) << 16) | (awb_info.gain_buff.gr & 0x3FFF);
+ REG_WR(ISP_AWBC_GAIN1_BUF, val);
+
+ val = ((awb_info.gain_offset_buff.b & 0xFFFF) << 16) | (awb_info.gain_offset_buff.r & 0xFFFF);
+ REG_WR(ISP_AWBC_OFFSET0_BUF, val);
+ val = ((awb_info.gain_offset_buff.gb & 0xFFFF) << 16) | (awb_info.gain_offset_buff.gr & 0xFFFF);
+ REG_WR(ISP_AWBC_OFFSET1_BUF, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_awb_statistics(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0, i = 0;
+ unsigned long addr = 0;
+ struct isp_raw_awbm_statistics *awbm_statistics = NULL;
+
+ awbm_statistics = (struct isp_raw_awbm_statistics *)isp_private->raw_awbm_buf_addr;
+ if (!awbm_statistics) {
+ ret = -1;
+ printk("isp_k_raw_awb_statistics: alloc memory error.\n");
+ return -1;
+ }
+
+ addr = ISP_RAW_AWBM_OUTPUT;
+
+ for (i = 0x00; i < ISP_RAW_AWBM_ITEM; i++) {
+ (awbm_statistics + i)->num4 = REG_RD(addr) >> 16;
+ (awbm_statistics + i)->num_t = REG_RD(addr) & 0xffff;
+ (awbm_statistics + i)->num2 = REG_RD(addr + 4) >> 16;
+ (awbm_statistics + i)->num3 = REG_RD(addr + 4) & 0xffff;
+ (awbm_statistics + i)->num0 = REG_RD(addr + 8) >> 16;
+ (awbm_statistics + i)->num1 = REG_RD(addr + 8) & 0xffff;
+ (awbm_statistics + i)->block_b = REG_RD(addr + 12);
+ (awbm_statistics + i)->block_g = REG_RD(addr + 16);
+ (awbm_statistics + i)->block_r = REG_RD(addr + 20);
+ addr += 32;
+ }
+
+ ret = copy_to_user(param->property_param, (void*)awbm_statistics, sizeof(struct isp_raw_awbm_statistics) * ISP_RAW_AWBM_ITEM);
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_raw_awb_statistics: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_awb(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_awb: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_awb: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_AWB_BLOCK:
+ ret = isp_k_awb_block(param);
+ break;
+ case ISP_PRO_AWBM_STATISTICS:
+ ret = isp_k_raw_awb_statistics(param, isp_private);
+ break;
+ default:
+ printk("isp_k_cfg_awb: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_bdn.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_bdn.c
new file mode 100644
index 00000000..9589b8c3
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_bdn.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"
+
+static int32_t isp_k_bdn_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ uint32_t j = 0;
+ struct isp_dev_bdn_info_v1 bdn_info;
+
+ memset(&bdn_info, 0x00, sizeof(bdn_info));
+
+ ret = copy_from_user((void *)&bdn_info, param->property_param, sizeof(bdn_info));
+ if (0 != ret) {
+ printk("isp_k_bdn_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_BDN_PARAM, BIT_1, bdn_info.radial_bypass << 1);
+
+ REG_MWR(ISP_BDN_PARAM, 0x7F0, bdn_info.addback << 4);
+
+ for (i = 0; i < 10; i++) {
+ REG_WR(ISP_BDN_DISWEI0_0 + 40 * i, bdn_info.dis[i][0]);
+
+ REG_WR(ISP_BDN_DISWEI0_1 + 40 * i, bdn_info.dis[i][1]);
+ }
+
+ for (i = 0; i < 10; i++) {
+ for (j = 0; j < 7; j++) {
+ REG_WR(ISP_BDN_RANWEI0_0 + i * 40 + j * 4, bdn_info.ran[i][j]);
+ }
+
+ REG_WR(ISP_BDN_RANWEI0_7 + i * 40, bdn_info.ran[i][7]);
+ }
+
+ val = ((bdn_info.offset_x & 0x1FFF) << 12) | (bdn_info.offset_y & 0xFFF);
+ REG_WR(ISP_BDN_1DLNC_CENTER, val);
+
+ val = bdn_info.squ_x2 & 0x3FFFFFF;
+ REG_WR(ISP_BDN_1DLNC_SQUARE_X, val);
+ val = bdn_info.squ_y2 & 0xFFFFFF;
+ REG_WR(ISP_BDN_1DLNC_SQUARE_Y, val);
+
+ val = ((bdn_info.coef2 & 0xFFFF) << 11) | (bdn_info.coef & 0x7FF);
+ REG_WR(ISP_BDN_1DLNC_P, val);
+
+ val = ((bdn_info.start_pos_x & 0x1FFF) << 12) | (bdn_info.start_pos_y & 0xFFF);
+ REG_WR(ISP_BDN_1DLNC_POS, val);
+
+ REG_WR(ISP_BDN_1DLNC_OFFSET, bdn_info.offset & 0x3FFFFFF);
+
+ REG_MWR(ISP_BDN_PARAM, BIT_0, bdn_info.bypass);
+
+ return ret;
+
+}
+
+static int32_t isp_k_bdn_1d_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size size = {0, 0};
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
+ if (0 != ret) {
+ printk("isp_k_bdn_1d_slice_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.width & 0x1FFF) << 12) | (size.height & 0xFFF);
+ REG_WR(ISP_BDN_1DLNC_SIZE, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_bdn(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_bdn: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_bdn: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_BDN_BLOCK:
+ ret = isp_k_bdn_block(param);
+ break;
+ case ISP_PRO_BDN_SLICE_SIZE:
+ ret = isp_k_bdn_1d_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_bdn: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_binning4awb.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_binning4awb.c
new file mode 100755
index 00000000..e64be9c4
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_binning4awb.c
@@ -0,0 +1,249 @@
+/*
+ * 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 <asm/cacheflush.h>
+#include "isp_reg.h"
+#include "isp_drv.h"
+
+static int32_t isp_k_binging_param_update(struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ /*config buf_id 0 as default*/
+ isp_private->b4awb_buf[0].buf_flag = 1;
+ REG_WR(ISP_BINNING_MEM_ADDR, isp_private->b4awb_buf[0].buf_phys_addr);
+
+ return ret;
+}
+
+static int32_t isp_k_binning_block(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_binning4awb_info_v1 binning_info;
+
+ ret = copy_from_user((void *)&binning_info, param->property_param, sizeof(binning_info));
+ if (0 != ret) {
+ printk("isp_k_binning_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (isp_private->b4awb_buf[0].buf_phys_addr == 0 || isp_private->b4awb_buf[1].buf_phys_addr == 0) {
+ REG_MWR(ISP_BINNING_PARAM, BIT_0, 0x1);
+ return ret;
+ }
+
+ isp_k_binging_param_update(isp_private);
+
+ val = (binning_info.burst_mode & 0x3) << 2;
+ REG_MWR(ISP_BINNING_PARAM, 0xC, val);
+
+ val = (binning_info.endian & 0x1) << 1;
+ REG_MWR(ISP_BINNING_PARAM, BIT_1, val);
+
+ val = (binning_info.mem_fifo_clr & 0x1) << 7;
+ REG_MWR(ISP_BINNING_PARAM, 0x80, val);
+
+ val = ((binning_info.hx & 0x7) << 4) | ((binning_info.vx & 0x7) << 8);
+ REG_MWR(ISP_BINNING_PARAM, 0x770, val);
+
+ REG_WR(ISP_BINNING_PITCH, binning_info.pitch);
+
+ REG_MWR(ISP_BINNING_PARAM, BIT_0, binning_info.bypass);
+
+ return ret;
+
+}
+
+static int32_t isp_k_binging_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(uint32_t));
+ if (0 != ret) {
+ printk("isp_k_binning_scaling_ratio: copy_from_user error, ret = 0x%x\n",(uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_BINNING_PARAM, BIT_0, bypass);
+
+ return ret;
+}
+
+static int32_t isp_k_binging_endian(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t endian = 0;
+ ret = copy_from_user((void *)&endian, param->property_param, sizeof(uint32_t));
+ if (0 != ret) {
+ printk("isp_k_binning_scaling_ratio: copy_from_user error, ret = 0x%x\n",(uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_BINNING_PARAM, BIT_1, endian << 1);
+
+ return ret;
+}
+
+static int32_t isp_k_binning_scaling_ratio(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_scaling_ratio scaling_ratio;
+ ret = copy_from_user((void *)&scaling_ratio, param->property_param, sizeof(struct isp_scaling_ratio));
+ if (0 != ret) {
+ printk("isp_k_binning_scaling_ratio: copy_from_user error, ret = 0x%x\n",(uint32_t)ret);
+ return -1;
+ }
+
+ val = ((scaling_ratio.vertical & 0x7)<< 8)| ((scaling_ratio.horizontal & 0x7) << 4);
+ REG_MWR(ISP_BINNING_PARAM, 0x770, val);
+
+ return ret;
+}
+
+static int32_t isp_k_binning_get_scaling_ratio(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_scaling_ratio scaling_ratio;
+
+ val = REG_RD(ISP_BINNING_PARAM);
+
+ scaling_ratio.vertical= (val >> 8) & 0x7;
+ scaling_ratio.horizontal = (val >> 4) & 0x7;
+
+ ret = copy_to_user(param->property_param, (void *)&scaling_ratio, sizeof(struct isp_scaling_ratio));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_binning_get_scaling_ratio: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_binging_mem_addr(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t addr = 0;
+
+ ret = copy_from_user((void *)&addr, param->property_param, sizeof(uint32_t));
+ if (0 != ret) {
+ printk("isp_k_binning_scaling_ratio: copy_from_user error, ret = 0x%x\n",(uint32_t)ret);
+ return -1;
+ }
+
+ REG_WR(ISP_BINNING_MEM_ADDR, addr);
+
+ return ret;
+}
+
+static int32_t isp_k_binning_statistics_buf(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t buf_id = 0;
+
+ if (isp_private->b4awb_buf[0].buf_flag == 0) {
+ buf_id = isp_private->b4awb_buf[0].buf_id;
+ } else if (isp_private->b4awb_buf[1].buf_flag == 0) {
+ buf_id = isp_private->b4awb_buf[1].buf_id;
+ }
+
+ ret = copy_to_user(param->property_param, (void*)&buf_id, sizeof(uint32_t));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_binning_statistics_buf: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_binning_buffaddr(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ int32_t i = 0;
+ unsigned long phys_addr[2];
+ struct isp_b4awb_phys phy_addr;
+
+ ret = copy_from_user((void *)&phy_addr, param->property_param, sizeof(struct isp_b4awb_phys));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_binning_buffaddr: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ phys_addr[0] = phy_addr.phys0;
+ phys_addr[1] = phy_addr.phys1;
+
+ for (i = 0; i < ISP_BING4AWB_NUM; i++) {
+ isp_private->b4awb_buf[i].buf_id = i;
+ isp_private->b4awb_buf[i].buf_flag = 0;
+ isp_private->b4awb_buf[i].buf_phys_addr = phys_addr[i];
+ }
+
+ printk("phys_addr 0x%lx, 0x%lx\n",phys_addr[0], phys_addr[1]);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_binning(struct isp_io_param *param, struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_binning: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_binning: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_BINNING4AWB_BLOCK:
+ ret = isp_k_binning_block(param, isp_private);
+ break;
+ case ISP_PRO_BINNING4AWB_BYPASS:
+ ret = isp_k_binging_bypass(param);
+ break;
+ case ISP_PRO_BINNING4AWB_SCALING_RATIO:
+ ret = isp_k_binning_scaling_ratio(param);
+ break;
+ case ISP_PRO_BINNING4AWB_GET_SCALING_RATIO:
+ ret = isp_k_binning_get_scaling_ratio(param);
+ break;
+ case ISP_PRO_BINNING4AWB_MEM_ADDR:
+ ret = isp_k_binging_mem_addr(param);
+ break;
+ case ISP_PRO_BINNING4AWB_STATISTICS_BUF:
+ ret = isp_k_binning_statistics_buf(param, isp_private);
+ break;
+ case ISP_PRO_BINNING4AWB_TRANSADDR:
+ ret = isp_k_binning_buffaddr(param, isp_private);
+ break;
+ case ISP_PRO_BINNING4AWB_ENDIAN:
+ ret = isp_k_binging_endian(param);
+ break;
+ default:
+ printk("isp_k_cfg_binning: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_blc.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_blc.c
new file mode 100644
index 00000000..af18c2a7
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_blc.c
@@ -0,0 +1,66 @@
+/*
+ * 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"
+
+static int32_t isp_k_blc_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_blc_info blc_info;
+
+ ret = copy_from_user((void *)&blc_info, param->property_param, sizeof(blc_info));
+ if (0 != ret) {
+ printk("isp_k_blc_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((blc_info.b & 0x3FF) << 10) | (blc_info.r & 0x3FF);
+ REG_WR(ISP_BLC_B_PARAM_R_B, val);
+ val = ((blc_info.gb & 0x3FF) << 10) | (blc_info.gr & 0x3FF);
+ REG_WR(ISP_BLC_B_PARAM_G, val);
+
+ REG_MWR(ISP_BLC_PARAM, BIT_0, blc_info.bypass);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_blc(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_blc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_blc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_BLC_BLOCK:
+ ret = isp_k_blc_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_blc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_bpc.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_bpc.c
new file mode 100644
index 00000000..29248946
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_bpc.c
@@ -0,0 +1,101 @@
+/*
+ * 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"
+
+static int32_t isp_k_bpc_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ struct isp_dev_bpc_info_v1 bpc_info;
+
+ memset(&bpc_info, 0x00, sizeof(bpc_info));
+
+ ret = copy_from_user((void *)&bpc_info, param->property_param, sizeof(bpc_info));
+ if (0 != ret) {
+ printk("isp_k_bpc_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_BPC_PARAM, BIT_0, bpc_info.bypass);
+
+ REG_MWR(ISP_BPC_PARAM, BIT_1, bpc_info.pvd_bypass << 1);
+
+ REG_MWR(ISP_BPC_PARAM, BIT_4 | BIT_5, bpc_info.bpc_mode << 4);
+
+ REG_MWR(ISP_BPC_PARAM, BIT_10 | BIT_9 | BIT_8, bpc_info.mask_mode << 8);
+
+ val = ((bpc_info.kmax & 0x7) << 20) | ((bpc_info.kmin & 0x7) << 16);
+ REG_MWR(ISP_BPC_PARAM, 0x770000, val);
+
+ REG_MWR(ISP_BPC_NEW_OLD_SEL, BIT_0, bpc_info.new_old_sel);
+
+ REG_MWR(ISP_BPC_NEW_OLD_SEL, BIT_1, bpc_info.map_done_sel << 1);
+
+ val = ((bpc_info.safe_factor & 0x1F) << 4) | (bpc_info.flat_factor & 0x7);
+ REG_WR(ISP_BPC_FACTOR, val);
+
+ val = ((bpc_info.dead_coeff & 0x7) << 4) | (bpc_info.spike_coeff & 0x7);
+ REG_WR(ISP_BPC_COEFF, val);
+
+ for (i = 0; i < 8; i++) {
+ val = ((bpc_info.lut_level[i] & 0x3FF) << 20) | ((bpc_info.slope_k[i] & 0x3FF) << 10) | (bpc_info.intercept_b[i] & 0x3FF);
+ REG_WR(ISP_BPC_LUTWORD0 + i * 4, val);
+ }
+
+ REG_MWR(ISP_BPC_CFG, BIT_10 | BIT_9 | BIT_8, bpc_info.delta << 8);
+
+ REG_MWR(ISP_BPC_CFG, BIT_7, bpc_info.bpc_map_fifo_clr << 7);
+
+ REG_MWR(ISP_BPC_CFG, BIT_6 | BIT_5 | BIT_4, bpc_info.ktimes << 4);
+
+ REG_MWR(ISP_BPC_CFG, 0x7, bpc_info.cntr_threshold);
+
+ REG_MWR(ISP_BPC_CFG, BIT_3, bpc_info.bad_map_hw_fifo_clr_en << 3);
+
+ REG_WR(ISP_BPC_MAP_ADDR, bpc_info.bpc_map_addr_new);
+
+ REG_MWR(ISP_BPC_CFG, 0xFFFF0000, bpc_info.bad_pixel_num << 16);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_bpc(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_bpc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_bpc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_BPC_BLOCK:
+ ret = isp_k_bpc_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_bpc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_brightness.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_brightness.c
new file mode 100644
index 00000000..4c649621
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_brightness.c
@@ -0,0 +1,67 @@
+/*
+ * 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"
+
+static int32_t isp_k_brightness_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_brightness_info brightness_info;
+
+ memset(&brightness_info, 0x00, sizeof(brightness_info));
+
+ ret = copy_from_user((void *)&brightness_info, param->property_param, sizeof(brightness_info));
+ if (0 != ret) {
+ printk("isp_k_brightness_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_BRIGHT_PARAM, 0x1FE, ((brightness_info.factor & 0xFF) << 1));
+
+ if (brightness_info.bypass) {
+ REG_OWR(ISP_BRIGHT_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_BRIGHT_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_brightness(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_brightness: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_brightness: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_BRIGHT_BLOCK:
+ ret = isp_k_brightness_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_brightness: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_capability.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_capability.c
new file mode 100644
index 00000000..7b9a7640
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_capability.c
@@ -0,0 +1,202 @@
+/*
+ * 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"
+
+#if defined(CONFIG_ARCH_SCX35LT8)
+#define ISP_MAX_WIDTH 4416
+#define ISP_MAX_HEIGHT 3168
+#define ISP_MAX_SLICE_WIDTH 4416
+#define ISP_MAX_SLICE_HEIGHT 3168
+#else
+#define ISP_MAX_WIDTH 3280
+#define ISP_MAX_HEIGHT 2464
+#define ISP_MAX_SLICE_WIDTH 3280
+#define ISP_MAX_SLICE_HEIGHT 2464
+#endif
+#define ISP_AWB_WIN_UNIT 32
+#define ISP_AWB_DEFAULT_GAIN 0x400
+#define ISP_AF_MAX_WIN_NUM 9
+
+static int32_t isp_k_capability_chip_id(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ uint32_t chip_id = 0;
+
+ chip_id = ISP_CHIP_ID_TSHARK2;
+
+ ret = copy_to_user(param->property_param, (void*)&chip_id, sizeof(chip_id));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_capability_chip_id: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_capability_single_size(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size size = {0, 0};
+
+ size.width = ISP_MAX_WIDTH;
+ size.height = ISP_MAX_HEIGHT;
+
+ ret = copy_to_user(param->property_param, (void*)&size, sizeof(size));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_capability_single_size: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_capability_continue_size(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size size = {0, 0};
+
+ size.width = ISP_MAX_SLICE_WIDTH;
+ size.height = ISP_MAX_SLICE_HEIGHT;
+
+ ret = copy_to_user(param->property_param, (void*)&size, sizeof(size));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_capability_continue_size: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_capability_awb_win(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size size = {0, 0};
+
+ size.width = ISP_AWB_WIN_UNIT;
+ size.height = ISP_AWB_WIN_UNIT;
+
+ ret = copy_to_user(param->property_param, (void*)&size, sizeof(size));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_capability_awb_win: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_capability_awb_default_gain(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ uint32_t gain = 0;
+
+ gain = ISP_AWB_DEFAULT_GAIN;
+
+ ret = copy_to_user(param->property_param, (void*)&gain, sizeof(gain));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_capability_awb_default_gain: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_capability_af_max_win_num(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ uint32_t win_num = 0;
+
+ win_num = ISP_AF_MAX_WIN_NUM;
+
+ ret = copy_to_user(param->property_param, (void*)&win_num, sizeof(win_num));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_capability_af_max_win_num: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_capability_time(struct isp_capability *param)
+{
+ int32_t ret = 0;
+ struct isp_time time;
+ struct timespec ts;
+
+ ktime_get_ts(&ts);
+ time.sec = ts.tv_sec;
+ time.usec = ts.tv_nsec / NSEC_PER_USEC;
+
+ ret = copy_to_user(param->property_param, (void*)&time, sizeof(time));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_capability_time: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+int32_t isp_capability(void *param)
+{
+ int32_t ret = 0;
+ struct isp_capability cap_param = {0, 0, NULL};
+
+ if (!param) {
+ printk("isp_capability: param is null error.\n");
+ return -1;
+ }
+
+ ret = copy_from_user((void *)&cap_param, (void*)param, sizeof(cap_param));
+ if ( 0 != ret) {
+ printk("isp_capability: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (NULL == cap_param.property_param) {
+ printk("isp_capability: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(cap_param.index) {
+ case ISP_CAPABILITY_CHIP_ID:
+ ret = isp_k_capability_chip_id(&cap_param);
+ break;
+ case ISP_CAPABILITY_SINGLE_SIZE:
+ ret = isp_k_capability_single_size(&cap_param);
+ break;
+ case ISP_CAPABILITY_CONTINE_SIZE:
+ ret = isp_k_capability_continue_size(&cap_param);
+ break;
+ case ISP_CAPABILITY_AWB_WIN:
+ ret = isp_k_capability_awb_win(&cap_param);
+ break;
+ case ISP_CAPABILITY_AWB_DEFAULT_GAIN:
+ ret = isp_k_capability_awb_default_gain(&cap_param);
+ break;
+ case ISP_CAPABILITY_AF_MAX_WIN_NUM:
+ ret = isp_k_capability_af_max_win_num(&cap_param);
+ break;
+ case ISP_CAPABILITY_TIME:
+ ret = isp_k_capability_time(&cap_param);
+ break;
+ default:
+ printk("isp_capability: fail cmd id:%d, not supported.\n", cap_param.index);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cce.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cce.c
new file mode 100644
index 00000000..06a84ab9
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cce.c
@@ -0,0 +1,147 @@
+/*
+ * 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"
+
+static int32_t isp_k_cce_block_uv(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_cce_uvd_info cce_uvd_info;
+
+ memset(&cce_uvd_info, 0x00, sizeof(cce_uvd_info));
+
+ ret = copy_from_user((void *)&cce_uvd_info, param->property_param, sizeof(cce_uvd_info));
+ if (0 != ret) {
+ printk("isp_k_cce_block_uv: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (cce_uvd_info.lum_th_h_len & 0xF)
+ | ((cce_uvd_info.lum_th_h & 0xFF) << 8)
+ | ((cce_uvd_info.lum_th_l_len & 0xF) << 16)
+ | ((cce_uvd_info.lum_th_l & 0xFF) << 24);
+ REG_WR(ISP_CCE_UVD_PARAM0, val);
+
+ val = (cce_uvd_info.chroma_min_h & 0xFF)
+ | ((cce_uvd_info.chroma_min_l & 0xFF) << 8)
+ | ((cce_uvd_info.chroma_max_h & 0xFF) << 16)
+ | ((cce_uvd_info.chroma_max_l & 0xFF) << 24);
+ REG_WR(ISP_CCE_UVD_PARAM1, val);
+
+ val = (cce_uvd_info.u_th1_h & 0xFF)
+ | ((cce_uvd_info.u_th1_l & 0xFF) << 8)
+ | ((cce_uvd_info.u_th0_h & 0xFF) << 16)
+ | ((cce_uvd_info.u_th0_l & 0xFF) << 24);
+ REG_WR(ISP_CCE_UVD_PARAM2, val);
+
+ val = (cce_uvd_info.v_th1_h & 0xFF)
+ | ((cce_uvd_info.v_th1_l & 0xFF) << 8)
+ | ((cce_uvd_info.v_th0_h & 0xFF) << 16)
+ | ((cce_uvd_info.v_th0_l & 0xFF) << 24);
+ REG_WR(ISP_CCE_UVD_PARAM3, val);
+
+ val = (cce_uvd_info.ratio[7] & 0xF)
+ | ((cce_uvd_info.ratio[6] & 0xF) << 4)
+ | ((cce_uvd_info.ratio[5] & 0xF) << 8)
+ | ((cce_uvd_info.ratio[4] & 0xF) << 12)
+ | ((cce_uvd_info.ratio[3] & 0xF) << 16)
+ | ((cce_uvd_info.ratio[2] & 0xF) << 20)
+ | ((cce_uvd_info.ratio[1] & 0xF) << 24)
+ | ((cce_uvd_info.ratio[0] & 0xF) << 28);
+ REG_WR(ISP_CCE_UVD_PARAM4, val);
+
+ val = (cce_uvd_info.base & 0xF)
+ | ((cce_uvd_info.ratio[8] & 0xF) << 8);
+ REG_WR(ISP_CCE_UVD_PARAM5, val);
+
+ REG_MWR(ISP_CCE_PARAM, BIT_0, cce_uvd_info.uvdiv_bypass);
+
+ return ret;
+}
+
+static int32_t isp_k_cce_block_matrix(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t val1 = 0;
+ struct isp_dev_cce_info_v1 cce_info;
+
+ memset(&cce_info, 0x00, sizeof(cce_info));
+
+ ret = copy_from_user((void *)&cce_info, param->property_param, sizeof(cce_info));
+ if (0 != ret) {
+ printk("isp_k_cce_block_matrix: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((cce_info.matrix[1] & 0x7FF) << 11) | (cce_info.matrix[0] & 0x7FF);
+ val1 = ((cce_info.matrix[3] & 0x7FF) << 11) | (cce_info.matrix[2] & 0x7FF);
+ if ((0 == val)
+ || (0 == val1)) {
+ printk("isp_k_cce_block_matrix: copy error, 0x%x, 0x%x, 0x%x, 0x%x\n", cce_info.matrix[0], cce_info.matrix[1], cce_info.matrix[2], cce_info.matrix[3]);
+ return ret;
+ }
+
+ REG_MWR(ISP_CCE_PARAM, BIT_1, cce_info.mode << 1);
+
+ val = ((cce_info.matrix[1] & 0x7FF) << 11) | (cce_info.matrix[0] & 0x7FF);
+ REG_WR(ISP_CCE_MATRIX0, val);
+ val = ((cce_info.matrix[3] & 0x7FF) << 11) | (cce_info.matrix[2] & 0x7FF);
+ REG_WR(ISP_CCE_MATRIX1, val);
+ val = ((cce_info.matrix[5] & 0x7FF) << 11) | (cce_info.matrix[4] & 0x7FF);
+ REG_WR(ISP_CCE_MATRIX2, val);
+ val = ((cce_info.matrix[7] & 0x7FF) << 11) | (cce_info.matrix[6] & 0x7FF);
+ REG_WR(ISP_CCE_MATRIX3, val);
+ val = cce_info.matrix[8] & 0x7FF;
+ REG_WR(ISP_CCE_MATRIX4, val);
+
+ val = (cce_info.y_offset & 0x1FF) | ((cce_info.u_offset & 0x1FF) << 9)
+ | ((cce_info.v_offset & 0x1FF) << 18);
+ REG_WR(ISP_CCE_SHIFT, (val & 0x7FFFFFF));
+
+ return ret;
+}
+
+int32_t isp_k_cfg_cce(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_cce: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_cce: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CCE_BLOCK_MATRIX:
+ ret = isp_k_cce_block_matrix(param);
+ break;
+ case ISP_PRO_CCE_BLOCK_UV:
+ ret = isp_k_cce_block_uv(param);
+ break;
+ default:
+ printk("isp_k_cfg_cce: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cdn.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cdn.c
new file mode 100644
index 00000000..e8b8e716
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cdn.c
@@ -0,0 +1,109 @@
+/*
+ * 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"
+
+static int32_t isp_k_yuv_cdn_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_yuv_cdn_info cdn_info;
+ uint32_t val = 0;
+ uint32_t i = 0;
+
+ memset(&cdn_info, 0x00, sizeof(cdn_info));
+
+ ret = copy_from_user((void *)&cdn_info, param->property_param, sizeof(cdn_info));
+ if (0 != ret) {
+ printk("isp_k_yuv_cdn_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (cdn_info.median_writeback_en) {
+ REG_OWR(ISP_CDN_PARAM, BIT_2);
+ } else {
+ REG_MWR(ISP_CDN_PARAM, BIT_2, 0);
+ }
+
+ REG_MWR(ISP_CDN_PARAM, 0x38, cdn_info.median_mode << 3);
+
+ REG_MWR(ISP_CDN_PARAM, BIT_7 | BIT_6, cdn_info.gaussian_mode << 6);
+
+ REG_MWR(ISP_CDN_PARAM, 0x3FFF00, cdn_info.median_thr << 8);
+
+ val = (cdn_info.median_thru0 & 0x7F) | ((cdn_info.median_thru1 & 0xFF) << 8)
+ | ((cdn_info.median_thrv0 & 0x7F) << 16) | ((cdn_info.median_thrv1 & 0xFF) << 24);
+ REG_WR(ISP_CDN_THRUV, val);
+
+ for (i = 0; i < 7; i++) {
+ val = (cdn_info.rangewu[i*4] & 0x3F) | ((cdn_info.rangewu[i*4+1] & 0x3F) << 8)
+ | ((cdn_info.rangewu[i*4+2] & 0x3F) << 16) | ((cdn_info.rangewu[i*4+3] & 0x3F) << 24);
+ REG_WR(ISP_CDN_U_RANWEI_0 + i * 4, val);
+ }
+
+ val = (cdn_info.rangewu[28] & 0x3F) | ((cdn_info.rangewu[29] & 0x3F) << 8)
+ | ((cdn_info.rangewu[30] & 0x3F) << 16);
+ REG_WR(ISP_CDN_U_RANWEI_7, val);
+
+ for (i = 0; i < 7; i++) {
+ val = (cdn_info.rangewv[i*4] & 0x3F) | ((cdn_info.rangewv[i*4+1] & 0x3F) << 8)
+ | ((cdn_info.rangewv[i*4+2] & 0x3F) << 16) | ((cdn_info.rangewv[i*4+3] & 0x3F) << 24);
+ REG_WR(ISP_CDN_V_RANWEI_0 + i * 4, val);
+ }
+
+ val = (cdn_info.rangewv[28] & 0x3F) | ((cdn_info.rangewv[29] & 0x3F) << 8)
+ | ((cdn_info.rangewv[30] & 0x3F) << 16);
+ REG_WR(ISP_CDN_V_RANWEI_7, val);
+
+ if (cdn_info.filter_bypass) {
+ REG_OWR(ISP_CDN_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_CDN_PARAM, BIT_1, 0);
+ }
+
+ if (cdn_info.bypass) {
+ REG_OWR(ISP_CDN_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_CDN_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_yuv_cdn(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_yuv_cdn: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_yuv_cdn: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_YUV_CDN_BLOCK:
+ ret = isp_k_yuv_cdn_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_yuv_cdn: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cfa.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cfa.c
new file mode 100644
index 00000000..ceeed46a
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cfa.c
@@ -0,0 +1,90 @@
+/*
+ * 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"
+
+static int32_t isp_k_cfa_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_cfa_info_v1 cfa_info;
+
+ memset(&cfa_info, 0x00, sizeof(cfa_info));
+
+ ret = copy_from_user((void *)&cfa_info, param->property_param, sizeof(cfa_info));
+ if (0 != ret) {
+ printk("isp_k_cfa_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_CFAE_EE_CFG0, BIT_0, cfa_info.bypass);
+
+ REG_MWR(ISP_CFAE_EE_CFG0, 0xF<<28, cfa_info.grid_gain << 28);
+
+ REG_MWR(ISP_CFAE_EE_CFG0, 0x3<<24, cfa_info.avg_mode << 24);
+
+ REG_MWR(ISP_CFAE_EE_CFG0, 0xFFF<<12, cfa_info.gbuf_addr_max << 12);
+
+ REG_MWR(ISP_CFAE_EE_CFG0, BIT_1, cfa_info.ee_bypass << 1);
+
+ REG_MWR(ISP_CFAE_EE_CFG0, 0x3F<<4, cfa_info.doee_base << 4);
+
+ REG_MWR(ISP_CFAE_EE_CFG1, 0xF<<16, cfa_info.inter_chl_gain << 16);
+
+ val = (cfa_info.cfa_uni_dir_intplt_tr & 0xFFFF) | ((cfa_info.cfai_ee_uni_dir_tr & 0xFFFF) << 16);
+ REG_WR(ISP_CFAE_THRD_0,val);
+ val = (cfa_info.cfai_ee_edge_tr & 0xFFF) | ((cfa_info.cfai_ee_diagonal_tr & 0xFFF) << 16);
+ REG_WR(ISP_CFAE_THRD_1,val);
+ val =(cfa_info.cfai_ee_grid_tr & 0xFFF) | ((cfa_info.cfai_doee_clip_tr & 0x3F) << 12)
+ | ((cfa_info.cfai_ee_saturation_level & 0x3FF) << 22);
+ REG_WR(ISP_CFAE_THRD_2,val);
+ val = (cfa_info.plt_diff_tr & 0xFFFF) | ((cfa_info.grid_min_tr & 0xFFFF) << 16);
+ REG_WR(ISP_CFAE_THRD_3,val);
+ val = (cfa_info.strength_tr_neg & 0xFFFF) | ((cfa_info.strength_tr_pos & 0xFFFF) << 16);
+ REG_WR(ISP_CFAE_THRD_4,val);
+ REG_MWR(ISP_CFAE_EE_CFG1, 0x3F, cfa_info.ee_strength_neg);
+ REG_MWR(ISP_CFAE_EE_CFG1, 0x3F << 8, cfa_info.ee_strength_pos << 8);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_cfa(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_cfa: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_cfa: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CFA_BLOCK:
+ ret = isp_k_cfa_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_cfa: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cmc10.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cmc10.c
new file mode 100644
index 00000000..8c127c9a
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cmc10.c
@@ -0,0 +1,93 @@
+/*
+ * 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"
+
+static int32_t isp_k_cmc10_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_cmc10_info cmc10_info;
+
+ memset(&cmc10_info, 0x00, sizeof(cmc10_info));
+
+ ret = copy_from_user((void *)&cmc10_info, param->property_param, sizeof(cmc10_info));
+ if (0 != ret) {
+ printk("isp_k_cmc10_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_CMC10_PARAM, BIT_0, cmc10_info.bypass);
+
+ REG_MWR(ISP_CMC10_PARAM, BIT_3, cmc10_info.buf_sel << 3);
+
+ REG_MWR(ISP_CMC10_PARAM, 0x3FF << 4, cmc10_info.alpha << 4);
+
+ REG_MWR(ISP_CMC10_PARAM, BIT_1, cmc10_info.alpha_bypass << 1);
+
+ val = ((cmc10_info.matrix.val[1] & 0x3FFF) << 14) | (cmc10_info.matrix.val[0] & 0x3FFF);
+ REG_WR(ISP_CMC10_MATRIX0, val);
+ val = ((cmc10_info.matrix.val[3] & 0x3FFF) << 14) | (cmc10_info.matrix.val[2] & 0x3FFF);
+ REG_WR((ISP_CMC10_MATRIX0 + 4), val);
+ val = ((cmc10_info.matrix.val[5] & 0x3FFF) << 14) | (cmc10_info.matrix.val[4] & 0x3FFF);
+ REG_WR((ISP_CMC10_MATRIX0 + 8), val);
+ val = ((cmc10_info.matrix.val[7] & 0x3FFF) << 14) | (cmc10_info.matrix.val[6] & 0x3FFF);
+ REG_WR((ISP_CMC10_MATRIX0 + 12), val);
+ val = cmc10_info.matrix.val[8] & 0x3FFF;
+ REG_WR((ISP_CMC10_MATRIX0 + 16), val);
+
+ val = ((cmc10_info.matrix_buf.val[1] & 0x3FFF) << 14) | (cmc10_info.matrix_buf.val[0] & 0x3FFF);
+ REG_WR(ISP_CMC10_MATRIX0_BUF, val);
+ val = ((cmc10_info.matrix_buf.val[3] & 0x3FFF) << 14) | (cmc10_info.matrix_buf.val[2] & 0x3FFF);
+ REG_WR((ISP_CMC10_MATRIX0_BUF + 4), val);
+ val = ((cmc10_info.matrix_buf.val[5] & 0x3FFF) << 14) | (cmc10_info.matrix_buf.val[4] & 0x3FFF);
+ REG_WR((ISP_CMC10_MATRIX0_BUF + 8), val);
+ val = ((cmc10_info.matrix_buf.val[7] & 0x3FFF) << 14) | (cmc10_info.matrix_buf.val[6] & 0x3FFF);
+ REG_WR((ISP_CMC10_MATRIX0_BUF + 12), val);
+ val = cmc10_info.matrix_buf.val[8] & 0x3FFF;
+ REG_WR((ISP_CMC10_MATRIX0_BUF + 16), val);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_cmc10(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_cmc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_cmc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CMC_BLOCK:
+ ret = isp_k_cmc10_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_cmc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cmc8.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cmc8.c
new file mode 100644
index 00000000..35121772
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_cmc8.c
@@ -0,0 +1,92 @@
+/*
+ * 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"
+
+static int32_t isp_k_cmc8_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_cmc8_info_v1 cmc8_info;
+
+ memset(&cmc8_info, 0x00, sizeof(cmc8_info));
+
+ ret = copy_from_user((void *)&cmc8_info, param->property_param, sizeof(cmc8_info));
+ if (0 != ret) {
+ printk("isp_k_cmc8_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_CMC8_PARAM, BIT_0, cmc8_info.bypass);
+
+ REG_MWR(ISP_CMC8_PARAM, BIT_3, cmc8_info.buf_sel << 3);
+
+ REG_MWR(ISP_CMC8_PARAM, 0x3FF << 4, cmc8_info.alpha << 4);
+
+ REG_MWR(ISP_CMC8_PARAM, BIT_1, cmc8_info.alpha_bypass << 1);
+
+ val = ((cmc8_info.matrix.val[1] & 0x3FFF) << 14) | (cmc8_info.matrix.val[0] & 0x3FFF);
+ REG_WR(ISP_CMC8_MATRIX0, val);
+ val = ((cmc8_info.matrix.val[3] & 0x3FFF) << 14) | (cmc8_info.matrix.val[2] & 0x3FFF);
+ REG_WR((ISP_CMC8_MATRIX0 + 4), val);
+ val = ((cmc8_info.matrix.val[5] & 0x3FFF) << 14) | (cmc8_info.matrix.val[4] & 0x3FFF);
+ REG_WR((ISP_CMC8_MATRIX0 + 8), val);
+ val = ((cmc8_info.matrix.val[7] & 0x3FFF) << 14) | (cmc8_info.matrix.val[6] & 0x3FFF);
+ REG_WR((ISP_CMC8_MATRIX0 + 12), val);
+ val = cmc8_info.matrix.val[8] & 0x3FFF;
+ REG_WR((ISP_CMC8_MATRIX0 + 16), val);
+
+ val = ((cmc8_info.matrix_buf.val[1] & 0x3FFF) << 14) | (cmc8_info.matrix_buf.val[0] & 0x3FFF);
+ REG_WR(ISP_CMC8_MATRIX0_BUF, val);
+ val = ((cmc8_info.matrix_buf.val[3] & 0x3FFF) << 14) | (cmc8_info.matrix_buf.val[2] & 0x3FFF);
+ REG_WR((ISP_CMC8_MATRIX0_BUF + 4), val);
+ val = ((cmc8_info.matrix_buf.val[5] & 0x3FFF) << 14) | (cmc8_info.matrix_buf.val[4] & 0x3FFF);
+ REG_WR((ISP_CMC8_MATRIX0_BUF + 8), val);
+ val = ((cmc8_info.matrix_buf.val[7] & 0x3FFF) << 14) | (cmc8_info.matrix_buf.val[6] & 0x3FFF);
+ REG_WR((ISP_CMC8_MATRIX0_BUF + 12), val);
+ val = cmc8_info.matrix_buf.val[8] & 0x3FFF;
+ REG_WR((ISP_CMC8_MATRIX0_BUF + 16), val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_cmc8(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_cmc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_cmc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CMC8_BLOCK:
+ ret = isp_k_cmc8_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_cmc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_common.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_common.c
new file mode 100644
index 00000000..677838d4
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_common.c
@@ -0,0 +1,533 @@
+/*
+ * 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"
+
+static int32_t isp_k_common_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_common_info_v1 common_info;
+
+ memset(&common_info, 0x00, sizeof(common_info));
+
+ ret = copy_from_user((void *)&common_info, param->property_param, sizeof(common_info));
+ if (0 != ret) {
+ printk("isp_k_common_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3, common_info.fetch_sel_0);
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 4, common_info.sizer_sel_0 << 4);
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 16, common_info.store_sel_0 << 16);
+ REG_MWR(ISP_COMMON_CTRL_CH1, 3, common_info.fetch_sel_1);
+ REG_MWR(ISP_COMMON_CTRL_CH1, 3 << 4, common_info.sizer_sel_1 << 4);
+ REG_MWR(ISP_COMMON_CTRL_CH1, 3 << 16, common_info.store_sel_1 << 16);
+ REG_MWR(ISP_COMMON_SPACE_SEL, 3 , common_info.fetch_color_format) ;
+ REG_MWR(ISP_COMMON_SPACE_SEL, 3 << 2, common_info.store_color_format << 2) ;
+ REG_MWR(ISP_COMMON_CTRL_AWBM, BIT_0 , common_info.awbm_pos) ;
+ REG_MWR(ISP_COMMON_3A_CTRL0, 3, common_info.y_afm_pos_0);
+ REG_MWR(ISP_COMMON_3A_CTRL0, 3 << 4, common_info.y_aem_pos_0 << 4);
+ REG_MWR(ISP_COMMON_3A_CTRL1, 3, common_info.y_afm_pos_1);
+ REG_MWR(ISP_COMMON_3A_CTRL1, 3 << 4, common_info.y_aem_pos_1 << 4);
+ REG_WR(ISP_COMMON_LBUF_OFFSET0, ((common_info.lbuf_off.cfae_lbuf_offset & 0xFFFF) << 16 ) | (common_info.lbuf_off.comm_lbuf_offset & 0xFFFF));
+ REG_WR(ISP_COMMON_LBUF_OFFSET1, ((common_info.lbuf_off.ydly_lbuf_offset& 0xFFFF) << 16 ) | (common_info.lbuf_off.awbm_lbuf_offset & 0xFFFF));
+
+ return ret;
+}
+
+static int32_t isp_k_common_version(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t version = 0;
+
+ version = REG_RD(ISP_COMMON_VERSION);
+
+ ret = copy_to_user(param->property_param, (void*)&version, sizeof(version));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_common_version: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_common_status0(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t status = 0;
+
+ status = REG_RD(ISP_COMMON_STATUS0);
+
+ ret = copy_to_user(param->property_param, (void*)&status, sizeof(status));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_common_status0: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_common_status1(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t status = 0;
+
+ status = REG_RD(ISP_COMMON_STATUS1);
+
+ ret = copy_to_user(param->property_param, (void*)&status, sizeof(status));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_common_status1: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel0_fetch_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t fetch_sel = 0;
+
+ ret = copy_from_user((void *)&fetch_sel, param->property_param, sizeof(fetch_sel));
+ if (0 != ret) {
+ printk("isp_k_channel0_fetch_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3, fetch_sel);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel0_sizer_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t sizer_sel = 0;
+
+ ret = copy_from_user((void *)&sizer_sel, param->property_param, sizeof(sizer_sel));
+ if (0 != ret) {
+ printk("isp_k_channel0_sizer_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 4, sizer_sel << 4);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel0_store_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t store_sel = 0;
+
+ ret = copy_from_user((void *)&store_sel, param->property_param, sizeof(store_sel));
+ if (0 != ret) {
+ printk("isp_k_common_channel0_store_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_CTRL_CH0, 3 << 16, store_sel << 16);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel1_fetch_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t fetch_sel = 0;
+
+ ret = copy_from_user((void *)&fetch_sel, param->property_param, sizeof(fetch_sel));
+ if (0 != ret) {
+ printk("isp_k_channel1_fetch_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_CTRL_CH1, 3, fetch_sel);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel1_sizer_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t sizer_sel = 0;
+
+ ret = copy_from_user((void *)&sizer_sel, param->property_param, sizeof(sizer_sel));
+ if (0 != ret) {
+ printk("isp_k_common_channel1_sizer_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_CTRL_CH1, 3 << 4, sizer_sel << 4);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel1_store_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t store_sel = 0;
+
+ ret = copy_from_user((void *)&store_sel, param->property_param, sizeof(store_sel));
+ if (0 != ret) {
+ printk("isp_k_common_channel1_store_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_CTRL_CH1, 3 << 16, store_sel << 16);
+
+ return ret;
+}
+
+static int32_t isp_k_common_fetch_color_space_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t color_space = 0;
+
+ ret = copy_from_user((void *)&color_space, param->property_param, sizeof(color_space));
+ if (0 != ret) {
+ printk("isp_k_common_fetch_color_space_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_SPACE_SEL, 3 , color_space) ;
+
+ return ret;
+}
+
+static int32_t isp_k_common_store_color_space_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t color_space = 0;
+
+ ret = copy_from_user((void *)&color_space, param->property_param, sizeof(color_space));
+ if (0 != ret) {
+ printk("isp_k_common_store_color_space_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_SPACE_SEL, 3 << 2, color_space << 2) ;
+
+ return ret;
+}
+
+static int32_t isp_k_common_awbm_pos_sel(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t awbm_pos = 0;
+
+ ret = copy_from_user((void *)&awbm_pos, param->property_param, sizeof(awbm_pos));
+ if (0 != ret) {
+ printk("isp_k_common_awbm_pos_sel: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_CTRL_AWBM, BIT_0 , awbm_pos) ;
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel0_y_afm_pos(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t position = 0;
+
+ ret = copy_from_user((void *)&position, param->property_param, sizeof(position));
+ if (0 != ret) {
+ printk("isp_k_common_channel0_y_afm_pos: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_3A_CTRL0, 3, position);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel0_y_aem_pos(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t position = 0;
+
+ ret = copy_from_user((void *)&position, param->property_param, sizeof(position));
+ if (0 != ret) {
+ printk("isp_k_common_channel0_y_aem_pos: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_3A_CTRL0, 3 << 4, position << 4);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel1_y_afm_pos(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t position = 0;
+
+ ret = copy_from_user((void *)&position, param->property_param, sizeof(position));
+ if (0 != ret) {
+ printk("isp_k_common_channel1_y_afm_pos: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_3A_CTRL1, 3, position);
+
+ return ret;
+}
+
+static int32_t isp_k_common_channel1_y_aem_pos(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t position = 0;
+
+ ret = copy_from_user((void *)&position, param->property_param, sizeof(position));
+ if (0 != ret) {
+ printk("isp_k_common_channel1_y_aem_pos: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_3A_CTRL1, 3 << 4, position << 4);
+
+ return ret;
+}
+
+static int32_t isp_k_common_lbuf_offset(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_common_lbuf_param_v1 lbuf_off;
+
+ memset(&lbuf_off, 0x00, sizeof(lbuf_off));
+ ret = copy_from_user((void *)&lbuf_off, param->property_param, sizeof(lbuf_off));
+ if (0 != ret) {
+ printk("isp_k_common_lbuf_offset: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_WR(ISP_COMMON_LBUF_OFFSET0, ((lbuf_off.cfae_lbuf_offset & 0xFFFF) << 16 ) | (lbuf_off.comm_lbuf_offset & 0xFFFF));
+ REG_WR(ISP_COMMON_LBUF_OFFSET1, ((lbuf_off.ydly_lbuf_offset& 0xFFFF) << 16 ) | (lbuf_off.awbm_lbuf_offset & 0xFFFF));
+
+ return ret;
+}
+
+static int32_t isp_k_all_shadow_ctrl(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t auto_shadow = 0;
+
+ ret = copy_from_user((void *)&auto_shadow, param->property_param, sizeof(auto_shadow));
+ if (0 != ret) {
+ printk("isp_k_all_shadow_ctrl: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_SHADOW_CTRL_CH0, 1 << 16, auto_shadow << 16);
+
+ return ret;
+}
+
+static int32_t isp_k_awbm_shadow_ctrl(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t shadow_done = 0;
+
+ ret = copy_from_user((void *)&shadow_done, param->property_param, sizeof(shadow_done));
+ if (0 != ret) {
+ printk("isp_k_awbm_shadow_ctrl: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_SHADOW_CTRL_CH0, 1 << 17, shadow_done << 17);
+
+ return ret;
+}
+
+static int32_t isp_k_ae_shadow_ctrl(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t shadow_done = 0;
+
+ ret = copy_from_user((void *)&shadow_done, param->property_param, sizeof(shadow_done));
+ if (0 != ret) {
+ printk("isp_k_ae_shadow_ctrl: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_SHADOW_CTRL_CH0, 1 << 18, shadow_done << 18);
+
+ return ret;
+}
+
+static int32_t isp_k_af_shadow_ctrl(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t shadow_done = 0;
+
+ ret = copy_from_user((void *)&shadow_done, param->property_param, sizeof(shadow_done));
+ if (0 != ret) {
+ printk("isp_k_af_shadow_ctrl: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_SHADOW_CTRL_CH0, 1 << 19, shadow_done << 19);
+
+ return ret;
+}
+
+static int32_t isp_k_afl_shadow_ctrl(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t shadow_done = 0;
+
+ ret = copy_from_user((void *)&shadow_done, param->property_param, sizeof(shadow_done));
+ if (0 != ret) {
+ printk("isp_k_afl_shadow_ctrl: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_SHADOW_CTRL_CH0, 1 << 20, shadow_done << 20);
+
+ return ret;
+}
+
+static int32_t isp_k_comm_shadow_ctrl(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t shadow_done = 0;
+
+ ret = copy_from_user((void *)&shadow_done, param->property_param, sizeof(shadow_done));
+ if (0 != ret) {
+ printk("isp_k_comm_shadow_ctrl: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_SHADOW_CTRL_CH0, 1 << 21, shadow_done << 21);
+
+ return ret;
+}
+
+static int32_t isp_k_3a_shadow_ctrl(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t enable = 0;
+
+ ret = copy_from_user((void *)&enable, param->property_param, sizeof(enable));
+ if (0 != ret) {
+ printk("isp_k_3a_shadow_ctrl: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_COMMON_RESERVED0, 1 << 2, enable << 2);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_common(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_common: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_common: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_COMMON_BLOCK:
+ ret = isp_k_common_block(param);
+ break;
+ case ISP_PRO_COMMON_VERSION:
+ ret = isp_k_common_version(param);
+ break;
+ case ISP_PRO_COMMON_STATUS0:
+ ret = isp_k_common_status0(param);
+ break;
+ case ISP_PRO_COMMON_STATUS1:
+ ret = isp_k_common_status1(param);
+ break;
+ case ISP_PRO_COMMON_CH0_FETCH_SEL:
+ ret = isp_k_common_channel0_fetch_sel(param);
+ break;
+ case ISP_PRO_COMMON_CH0_SIZER_SEL:
+ ret = isp_k_common_channel0_sizer_sel(param);
+ break;
+ case ISP_PRO_COMMON_CH0_STORE_SEL:
+ ret = isp_k_common_channel0_store_sel(param);
+ break;
+ case ISP_PRO_COMMON_CH1_FETCH_SEL:
+ ret = isp_k_common_channel1_fetch_sel(param);
+ break;
+ case ISP_PRO_COMMON_CH1_SIZER_SEL:
+ ret = isp_k_common_channel1_sizer_sel(param);
+ break;
+ case ISP_PRO_COMMON_CH1_STORE_SEL:
+ ret = isp_k_common_channel1_store_sel(param);
+ break;
+ case ISP_PRO_COMMON_FETCH_COLOR_SPACE_SEL:
+ ret = isp_k_common_fetch_color_space_sel(param);
+ break;
+ case ISP_PRO_COMMON_STORE_COLOR_SPACE_SEL:
+ ret = isp_k_common_store_color_space_sel(param);
+ break;
+ case ISP_PRO_COMMON_AWBM_POS_SEL:
+ ret = isp_k_common_awbm_pos_sel(param);
+ break;
+ case ISP_PRO_COMMON_CH0_AEM2_POS:
+ ret = isp_k_common_channel0_y_aem_pos(param);
+ break;
+ case ISP_PRO_COMMON_CH0_Y_AFM_POS:
+ ret = isp_k_common_channel0_y_afm_pos(param);
+ break;
+ case ISP_PRO_COMMON_CH1_AEM2_POS:
+ ret = isp_k_common_channel1_y_aem_pos(param);
+ break;
+ case ISP_PRO_COMMON_CH1_Y_AFM_POS:
+ ret = isp_k_common_channel1_y_afm_pos(param);
+ break;
+ case ISP_PRO_COMMON_LBUF_OFFSET:
+ ret = isp_k_common_lbuf_offset(param);
+ break;
+ case ISP_PRO_COMMON_SHADOW_ALL_CTRL:
+ ret = isp_k_all_shadow_ctrl(param);
+ break;
+ case ISP_PRO_COMMON_AWBM_SHADOW:
+ ret = isp_k_awbm_shadow_ctrl(param);
+ break;
+ case ISP_PRO_COMMON_AE_SHADOW:
+ ret = isp_k_ae_shadow_ctrl(param);
+ break;
+ case ISP_PRO_COMMON_AF_SHADOW:
+ ret = isp_k_af_shadow_ctrl(param);
+ break;
+ case ISP_PRO_COMMON_AFL_SHADOW:
+ ret = isp_k_afl_shadow_ctrl(param);
+ break;
+ case ISP_PRO_COMMON_COMM_SHADOW:
+ ret = isp_k_comm_shadow_ctrl(param);
+ break;
+ case ISP_PRO_COMMON_3A_SINGLE_FRAME_CTRL:
+ ret = isp_k_3a_shadow_ctrl(param);
+ break;
+ default:
+ printk("isp_k_cfg_common: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_contrast.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_contrast.c
new file mode 100644
index 00000000..36f7750d
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_contrast.c
@@ -0,0 +1,67 @@
+/*
+ * 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"
+
+static int32_t isp_k_contrast_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_contrast_info contrast_info;
+
+ memset(&contrast_info, 0x00, sizeof(contrast_info));
+
+ ret = copy_from_user((void *)&contrast_info, param->property_param, sizeof(contrast_info));
+ if (0 != ret) {
+ printk("isp_k_contrast_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_CONTRAST_PARAM, 0x1FE, (contrast_info.factor << 1));
+
+ if (contrast_info.bypass) {
+ REG_OWR(ISP_CONTRAST_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_CONTRAST_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_contrast(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_contrast: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_contrast: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CONTRAST_BLOCK:
+ ret = isp_k_contrast_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_contrast: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_csa.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_csa.c
new file mode 100644
index 00000000..1aa7ef49
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_csa.c
@@ -0,0 +1,68 @@
+/*
+ * 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"
+
+static int32_t isp_k_csa_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_csa_info_v1 csa_info;
+ uint32_t val = 0;
+
+ memset(&csa_info, 0x00, sizeof(csa_info));
+
+ ret = copy_from_user((void *)&csa_info, param->property_param, sizeof(csa_info));
+ if (0 != ret) {
+ printk("isp_k_csa_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((csa_info.factor_v & 0xFF) << 8) | ((csa_info.factor_u & 0xFF) << 16);
+ REG_MWR(ISP_CSA_PARAM, 0xFFFF00, val);
+
+ if (csa_info.bypass) {
+ REG_OWR(ISP_CSA_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_CSA_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_csa(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_csa: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_csa: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CSA_BLOCK:
+ ret = isp_k_csa_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_csa: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_csc.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_csc.c
new file mode 100644
index 00000000..7612b698
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_csc.c
@@ -0,0 +1,114 @@
+/*
+ * 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"
+
+static int32_t isp_k_csc_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_csc_info csc_info;
+
+ memset(&csc_info, 0x00, sizeof(csc_info));
+
+ ret = copy_from_user((void *)&csc_info, param->property_param, sizeof(csc_info));
+ if (0 != ret) {
+ printk("isp_k_csc_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_CSC_CTRL, BIT_0, csc_info.bypass);
+
+ val = (csc_info.red_centre_x & 0x1FFF) | ((csc_info.red_centre_y & 0xFFF) << 16);
+ REG_WR(ISP_CSC_RCC, val);
+
+ val = (csc_info.blue_centre_x & 0x1FFF) | ((csc_info.blue_centre_y & 0xFFF) << 16);
+ REG_WR(ISP_CSC_BCC, val);
+
+ REG_WR(ISP_CSC_REDTHR, csc_info.red_threshold & 0x3FFFFFF);
+
+ REG_WR(ISP_CSC_BLUETHR, (csc_info.blue_threshold & 0x3FFFFFF));
+
+ val = (csc_info.red_p1_param & 0x1FFF) | ((csc_info.red_p2_param & 0x7FF) << 16);
+ REG_WR(ISP_CSC_REDPOLY, val);
+
+ val = (csc_info.blue_p1_param & 0x1FFF) | ((csc_info.blue_p2_param & 0x7FF) << 16);
+ REG_WR(ISP_CSC_BLUEPOLY, val);
+
+ REG_WR(ISP_CSC_MAXGAIN, (csc_info.max_gain_thr & 0x1FFF));
+
+ val = (csc_info.start_pos.x & 0xFFF) | ((csc_info.start_pos.y & 0x1FFF) << 12);
+ REG_WR(ISP_CSC_START_ROW_COL, val );
+
+ val = csc_info.red_x2_init;
+ REG_WR( ISP_CSC_REDX2INIT, (val & 0x3FFFFFF));
+ val = csc_info.red_y2_init;
+ REG_WR( ISP_CSC_REDY2INIT, (val & 0x3FFFFFF));
+
+ val = csc_info.blue_x2_init;
+ REG_WR( ISP_CSC_BLUEX2INIT, (val & 0x3FFFFFF));
+ val = csc_info.blue_y2_init;
+ REG_WR( ISP_CSC_BLUEY2INIT, (val & 0x3FFFFFF));
+
+ return ret;
+
+}
+
+static int32_t isp_k_csc_pic_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size pic_size = {0, 0};
+
+ ret = copy_from_user((void *)&pic_size, param->property_param, sizeof(pic_size));
+ if (0 != ret) {
+ printk("isp_k_csc_pic_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ val = (pic_size.width& 0x1FFF) | ((pic_size.height& 0xFFF) << 16);
+ REG_WR(ISP_CSC_PICSIZE, val );
+
+ return ret;
+}
+
+int32_t isp_k_cfg_csc(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_csc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_csc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CSC_BLOCK:
+ ret = isp_k_csc_block(param);
+ break;
+ case ISP_PRO_CSC_PIC_SIZE:
+ ret = isp_k_csc_pic_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_csc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_css.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_css.c
new file mode 100644
index 00000000..2147bd53
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_css.c
@@ -0,0 +1,112 @@
+/*
+ * 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"
+
+static int32_t isp_k_css_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_css_info_v1 css_info;
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&css_info, param->property_param, sizeof(css_info));
+ if (0 != ret) {
+ printk("isp_k_css_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (css_info.lh_chrom_th & 0x1F) << 24;
+ REG_MWR(ISP_CSS_PARAM, 0x1F000000, val);
+
+ val = ((css_info.chrom_lower_th[0] & 0x1F) << 16) | ((css_info.chrom_lower_th[1] & 0x1F) << 8)
+ | (css_info.chrom_lower_th[2] & 0x1F);
+ REG_MWR(ISP_CSS_CHROM_L_TH_0, 0x1F1F1F, val);
+
+ val = ((css_info.chrom_lower_th[3] & 0x1F) << 24) | ((css_info.chrom_lower_th[4] & 0x1F) << 16)
+ | ((css_info.chrom_lower_th[5] & 0x1F) << 8) | (css_info.chrom_lower_th[6] & 0x1F);
+ REG_WR(ISP_CSS_CHROM_L_TH_1, val);
+
+ val = ((css_info.chrom_high_th[0] & 0x1F) << 16) | ((css_info.chrom_high_th[1] & 0x1F) << 8)
+ | (css_info.chrom_high_th[2] & 0x1F);
+ REG_WR(ISP_CSS_CHROM_H_TH_0, val);
+
+ val = ((css_info.chrom_high_th[3] & 0x1F) << 24) | ((css_info.chrom_high_th[4] & 0x1F) << 16)
+ | ((css_info.chrom_high_th[5] & 0x1F) << 8) | (css_info.chrom_high_th[6] & 0x1F);
+ REG_WR(ISP_CSS_CHROM_H_TH_1, val);
+
+ val = ((css_info.lum_low_shift & 0x7) << 16) | ((css_info.lum_hig_shift & 0x7) << 8);
+ REG_MWR(ISP_CSS_PARAM, 0x70700, val);
+
+ val = (css_info.lh_ratio[7] & 0xF) | ((css_info.lh_ratio[6] & 0xF) << 4)
+ | ((css_info.lh_ratio[5] & 0xF) << 8) | ((css_info.lh_ratio[4] & 0xF) << 12)
+ | ((css_info.lh_ratio[3] & 0xF) << 16) | ((css_info.lh_ratio[2] & 0xF) << 20)
+ | ((css_info.lh_ratio[1] & 0xF) << 24) | ((css_info.lh_ratio[0] & 0xF) << 28);
+ REG_WR(ISP_CSS_LH_RATIO, val);
+
+ val = (css_info.ratio[7] & 0xF) | ((css_info.ratio[6] & 0xF) << 4)
+ | ((css_info.ratio[5] & 0xF) << 8) | ((css_info.ratio[4] & 0xF) << 12)
+ | ((css_info.ratio[3] & 0xF) << 16) | ((css_info.ratio[2] & 0xF) << 20)
+ | ((css_info.ratio[1] & 0xF) << 24) | ((css_info.ratio[0] & 0xF) << 28);
+ REG_WR(ISP_CSS_RATIO, val);
+
+ val = (css_info.lum_hh_th & 0xFF) | ((css_info.lum_hig_th & 0xFF) << 8)
+ | ((css_info.lum_ll_th & 0xFF) << 16) | ((css_info.lum_low_th & 0xFF) << 24);
+ REG_WR(ISP_CSS_THRD0, val);
+
+ val = (css_info.v_th_0_h & 0xFF) | ((css_info.v_th_0_l & 0xFF) << 8)
+ | ((css_info.u_th_0_h & 0xFF) << 16) | ((css_info.u_th_0_l & 0xFF) << 24);
+ REG_WR(ISP_CSS_EX_TH_0, val);
+
+ val = (css_info.v_th_1_h & 0xFF) | ((css_info.v_th_1_l & 0xFF) << 8)
+ | ((css_info.u_th_1_h & 0xFF) << 16) | ((css_info.u_th_1_l & 0xFF) << 24);
+ REG_WR(ISP_CSS_EX_TH_1, val);
+
+ REG_MWR(ISP_CSS_CHROM_L_TH_0, 0x1F000000, css_info.cutoff_th << 24);
+
+ if (css_info.bypass) {
+ REG_OWR(ISP_CSS_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_CSS_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_css(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_css: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_css: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CSS_BLOCK:
+ ret = isp_k_css_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_css: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_ct.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_ct.c
new file mode 100644
index 00000000..2d723636
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_ct.c
@@ -0,0 +1,98 @@
+/*
+ * 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_3D_LUT_BUF0 0
+#define ISP_3D_LUT_BUF1 1
+
+static int32_t isp_k_ct_block(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t buf_size = 0;
+ unsigned long dst_buf = 0;
+ struct isp_dev_ct_info ct_info;
+ void *data_ptr = NULL;
+
+ buf_size = ISP_3D_LUT_ITEM * 4;
+ memset(&ct_info, 0x00, sizeof(ct_info));
+
+ ret = copy_from_user((void *)&ct_info, param->property_param, sizeof(ct_info));
+ if (0 != ret) {
+ printk("isp_k_ct_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+#ifdef CONFIG_64BIT
+ data_ptr = (void*)(((unsigned long)ct_info.data_ptr[1] << 32) | ct_info.data_ptr[0]);
+#else
+ data_ptr = (void*)(ct_info.data_ptr[0]);
+#endif
+
+ if (NULL == data_ptr || ct_info.size > buf_size) {
+ printk("isp_k_ct_block: memory error: %p %x.\n",
+ data_ptr, ct_info.size);
+ }
+
+ if (ISP_3D_LUT_BUF0 == isp_private->ct_load_buf_id) {
+ dst_buf = ISP_3D_LUT1_OUTPUT;
+ isp_private->ct_load_buf_id = ISP_3D_LUT_BUF1;
+ } else {
+ dst_buf = ISP_3D_LUT0_OUTPUT;
+ isp_private->ct_load_buf_id = ISP_3D_LUT_BUF0;
+ }
+
+ ret = copy_from_user((void *)dst_buf, data_ptr, ct_info.size);
+ if (0 != ret) {
+ printk("isp_k_ct_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_CT_PARAM, BIT_1, (isp_private->ct_load_buf_id << 1));
+
+ REG_MWR(ISP_CT_PARAM, BIT_0, ct_info.bypass);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_ct(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_ct: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_ct: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_CT_BLOCK:
+ ret = isp_k_ct_block(param, isp_private);
+ break;
+ default:
+ printk("isp_k_cfg_ct: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_dispatch.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_dispatch.c
new file mode 100644
index 00000000..6bc5dde5
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_dispatch.c
@@ -0,0 +1,143 @@
+/*
+ * 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"
+
+static int32_t isp_k_dispatch_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_dispatch_info_v1 dispatch_info;
+
+ memset(&dispatch_info, 0x00, sizeof(dispatch_info));
+
+ ret = copy_from_user((void *)&dispatch_info, param->property_param, sizeof(dispatch_info));
+ if (0 != ret) {
+ printk("isp_k_dispatch_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_WR(ISP_DISPATCH_CH0_BAYER, dispatch_info.bayer_ch0 & 0x3);
+ REG_WR(ISP_DISPATCH_CH1_BAYER, dispatch_info.bayer_ch1 & 0x3);
+
+ return ret;
+}
+
+static int32_t isp_k_dispatch_ch0_bayer(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&val, param->property_param, sizeof(uint32_t));
+ if (0 != ret) {
+ printk("isp_k_dispatch_ch0_bayer: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_WR(ISP_DISPATCH_CH0_BAYER, val & 0x3);
+
+ return ret;
+}
+
+static int32_t isp_k_dispatch_ch1_bayer(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&val, param->property_param, sizeof(uint32_t));
+ if (0 != ret) {
+ printk("isp_k_dispatch_ch1_bayer: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_WR(ISP_DISPATCH_CH1_BAYER, val & 0x3);
+
+ return ret;
+}
+
+static int32_t isp_k_dispatch_ch0_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size = {0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(size));
+ if (0 != ret) {
+ printk("isp_k_dispatch_ch0_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height & 0xFFFF) << 16) | (size.width & 0xFFFF);
+ REG_WR(ISP_DISPATCH_CH0_SIZE, val);
+
+ return ret;
+}
+
+static int32_t isp_k_dispatch_ch1_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size = {0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(size));
+ if (0 != ret) {
+ printk("isp_k_dispatch_ch1_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height & 0xFFFF) << 16) | (size.width & 0xFFFF);
+ REG_WR(ISP_DISPATCH_CH1_SIZE, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_dispatch(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_dispatch: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_dispatch: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_DISPATCH_BLOCK:
+ ret = isp_k_dispatch_block(param);
+ break;
+ case ISP_PRO_DISPATCH_CH0_BAYER:
+ ret = isp_k_dispatch_ch0_bayer(param);
+ break;
+ case ISP_PRO_DISPATCH_CH1_BAYER:
+ ret = isp_k_dispatch_ch1_bayer(param);
+ break;
+ case ISP_PRO_DISPATCH_CH0_SIZE:
+ ret = isp_k_dispatch_ch0_size(param);
+ break;
+ case ISP_PRO_DISPATCH_CH1_SIZE:
+ ret = isp_k_dispatch_ch1_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_dispatch: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_edge.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_edge.c
new file mode 100644
index 00000000..3d19be00
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_edge.c
@@ -0,0 +1,126 @@
+/*
+ * 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"
+
+static int32_t isp_k_edge_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_edge_info_v1 edge_info;
+ uint32_t val = 0;
+
+ memset(&edge_info, 0x00, sizeof(edge_info));
+
+ ret = copy_from_user((void *)&edge_info, param->property_param, sizeof(edge_info));
+ if (0 != ret) {
+ printk("isp_k_edge_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_EE_CFG0, BIT_29 | BIT_28, edge_info.mode << 28);
+
+ val = (edge_info.ee_str_m_n & 0x7F) | ((edge_info.ee_str_m_p & 0x7F) << 7)
+ | ((edge_info.ee_str_d_n & 0x7F) << 14) | ((edge_info.ee_str_d_p & 0x7F) << 21);
+ REG_MWR(ISP_EE_CFG0, 0xFFFFFFF, val);
+
+ val = ((edge_info.ee_incr_d_p & 0xFF) << 8) | (edge_info.ee_incr_d_n & 0xFF);
+ REG_MWR(ISP_EE_CFG1, 0xFFFF, val);
+
+ val = ((edge_info.ee_thr_d_n & 0xFF) << 16) | ((edge_info.ee_thr_d_p & 0xFF) << 24);
+ REG_MWR(ISP_EE_CFG1, 0xFFFF0000, val);
+
+ val = (edge_info.ee_flat_thr_1 & 0xFF) | ((edge_info.ee_flat_thr_2 & 0xFF) << 8);
+ REG_MWR(ISP_EE_CFG2, 0xFFFF, val);
+
+ val = ((edge_info.ee_incr_m_n & 0xFF) << 16) | ((edge_info.ee_incr_m_p & 0xFF) << 24);
+ REG_MWR(ISP_EE_CFG2, 0xFFFF0000, val);
+
+ val = (edge_info.ee_txt_thr_1 & 0xFF) | ((edge_info.ee_txt_thr_2 & 0xFF) << 8)
+ | ((edge_info.ee_txt_thr_3 & 0xFF) << 16);
+ REG_WR(ISP_EE_CFG3, val);
+
+ val = ((edge_info.ee_corner_cor & 0x1) << 28) | ((edge_info.ee_corner_th_p & 0x1F) << 23)
+ | ((edge_info.ee_corner_th_n & 0x1F) << 18) | ((edge_info.ee_corner_gain_p & 0x7F) << 11)
+ | ((edge_info.ee_corner_gain_n & 0x7F) << 4) | ((edge_info.ee_corner_sm_p & 0x3) << 2)
+ | (edge_info.ee_corner_sm_n & 0x3);
+ REG_WR(ISP_EE_CFG4, val);
+
+ val = ((edge_info.ee_edge_smooth_mode & 0x3) << 26) | ((edge_info.ee_flat_smooth_mode & 0x3) << 24)
+ | ((edge_info.ee_smooth_thr & 0xFF) << 8) | (edge_info.ee_smooth_strength & 0xFF);
+ REG_MWR(ISP_EE_CFG5, 0xF00FFFF, val);
+
+ val = (edge_info.sigma & 0xFF) << 16;
+ REG_MWR(ISP_EE_CFG5, 0xFF0000, val);
+
+ val = ((edge_info.ee_str_b_p & 0xFF) << 24) | ((edge_info.ee_str_b_n & 0xFF) << 16)
+ | ((edge_info.ee_incr_b_p & 0xFF) << 8) | (edge_info.ee_incr_b_n & 0xFF);
+ REG_WR(ISP_EE_CFG6, val);
+
+ val = ((edge_info.ratio[1] & 0xFF) << 8) | (edge_info.ratio[0] & 0xFF);
+ REG_MWR(ISP_EE_CFG7, 0xFFFF, val);
+
+ val = (edge_info.ee_clip_after_smooth_en & 0x1) << 25;
+ REG_MWR(ISP_EE_CFG7, BIT_25, val);
+
+ val = ((edge_info.ipd_bypass & 0x1) << 24) | ((edge_info.ipd_flat_thr & 0xFF) << 16);
+ REG_MWR(ISP_EE_CFG7, 0x1FF0000, val);
+
+ val = (edge_info.ee_t1_cfg & 0x3FF) | ((edge_info.ee_t2_cfg & 0x3FF) << 10)
+ | ((edge_info.ee_t3_cfg & 0x3FF) << 20);
+ REG_WR(ISP_EE_ADP_CFG0, val);
+
+ val = (edge_info.ee_t4_cfg & 0x3FF) | ((edge_info.ee_cv_clip_n & 0xFF) << 16)
+ | ((edge_info.ee_cv_clip_p & 0xFF) << 24);
+ REG_WR(ISP_EE_ADP_CFG1, val);
+
+ val = (edge_info.ee_r1_cfg & 0xFF) | ((edge_info.ee_r2_cfg & 0xFF) << 8)
+ | ((edge_info.ee_r3_cfg & 0xFF) << 16);
+ REG_WR(ISP_EE_ADP_CFG2, val);
+
+
+ if (edge_info.bypass) {
+ REG_OWR(ISP_EE_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_EE_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_edge(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_edge: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_edge: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_EDGE_BLOCK:
+ ret = isp_k_edge_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_edge: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_emboss.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_emboss.c
new file mode 100644
index 00000000..27319afc
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_emboss.c
@@ -0,0 +1,74 @@
+/*
+ * 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"
+
+static int32_t isp_k_emboss_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_emboss_info_v1 emboss_info;
+
+ memset(&emboss_info, 0x00, sizeof(emboss_info));
+
+ ret = copy_from_user((void *)&emboss_info, param->property_param, sizeof(emboss_info));
+ if (0 != ret) {
+ printk("isp_k_emboss_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_EMBOSS_Y_PARAM, 0x7E, (emboss_info.y_step & 0x3F) << 1);
+
+ if (emboss_info.y_bypass) {
+ REG_OWR(ISP_EMBOSS_Y_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_EMBOSS_Y_PARAM, BIT_0, 0);
+ }
+
+ REG_MWR(ISP_EMBOSS_UV_PARAM, 0x7E, (emboss_info.uv_step & 0x3F) << 1);
+
+ if (emboss_info.uv_bypass) {
+ REG_OWR(ISP_EMBOSS_UV_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_EMBOSS_UV_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_emboss(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_emboss: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_emboss: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_EMBOSS_BLOCK:
+ ret = isp_k_emboss_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_emboss: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_fetch.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_fetch.c
new file mode 100644
index 00000000..721afc21
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_fetch.c
@@ -0,0 +1,126 @@
+/*
+ * 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"
+
+static int32_t isp_k_fetch_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_fetch_info_v1 fetch_info;
+
+ memset(&fetch_info, 0x00, sizeof(fetch_info));
+
+ ret = copy_from_user((void *)&fetch_info, param->property_param, sizeof(fetch_info));
+ if (0 != ret) {
+ printk("isp_k_fetch_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (fetch_info.substract) {
+ REG_OWR(ISP_FETCH_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_FETCH_PARAM, BIT_1, 0);
+ }
+
+ REG_MWR(ISP_FETCH_PARAM, 0xF0, (fetch_info.color_format << 4));
+
+ REG_WR(ISP_FETCH_SLICE_Y_ADDR, fetch_info.addr.chn0);
+ REG_WR(ISP_FETCH_SLICE_Y_PITCH, fetch_info.pitch.chn0);
+ REG_WR(ISP_FETCH_SLICE_U_ADDR, fetch_info.addr.chn1);
+ REG_WR(ISP_FETCH_SLICE_U_PITCH, fetch_info.pitch.chn1);
+ REG_WR(ISP_FETCH_SLICE_V_ADDR, fetch_info.addr.chn2);
+ REG_WR(ISP_FETCH_SLICE_V_PITCH, fetch_info.pitch.chn2);
+ REG_WR(ISP_FETCH_MIPI_WORD_INFO, (fetch_info.mipi_word_num & 0xFFFF));
+ REG_WR(ISP_FETCH_MIPI_BYTE_INFO, (fetch_info.mipi_byte_rel_pos & 0x0F));
+
+ if (fetch_info.bypass) {
+ REG_OWR(ISP_FETCH_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_FETCH_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_fetch_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t size = 0;
+ struct isp_img_size slice_size = {0, 0};
+
+ ret = copy_from_user((void *)&slice_size, param->property_param, sizeof(struct isp_img_size));
+ if (0 != ret) {
+ printk("isp_k_fetch_slice_size: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ size = ((slice_size.height & 0xFFFF) << 16) | (slice_size.width & 0xFFFF);
+
+ REG_WR(ISP_FETCH_SLICE_SIZE, size);
+
+ return ret;
+}
+
+static int32_t isp_k_fetch_start_isp(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t fetch_start = 0;
+
+ ret = copy_from_user((void *)&fetch_start, param->property_param, sizeof(uint32_t));
+ if (0 != ret) {
+ printk("isp_k_fetch_start_isp: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (fetch_start) {
+ REG_OWR(ISP_FETCH_START, BIT_0);
+ } else {
+ REG_MWR(ISP_FETCH_START, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_fetch(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_fetch: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_fetch: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_FETCH_BLOCK:
+ ret = isp_k_fetch_block(param);
+ break;
+ case ISP_PRO_FETCH_SLICE_SIZE:
+ ret = isp_k_fetch_slice_size(param);
+ break;
+ case ISP_PRO_FETCH_START_ISP:
+ ret = isp_k_fetch_start_isp(param);
+ break;
+ default:
+ printk("isp_k_cfg_fetch: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_gamma.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_gamma.c
new file mode 100644
index 00000000..5ba65f66
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_gamma.c
@@ -0,0 +1,131 @@
+/*
+ * 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/vmalloc.h>
+#include <linux/sprd_mm.h>
+#include <video/sprd_isp.h>
+#include "isp_reg.h"
+#include "isp_drv.h"
+
+#define ISP_FRGB_GAMC_BUF0 0
+#define ISP_FRGB_GAMC_BUF1 1
+
+static int32_t isp_k_pingpang_frgb_gamc(struct coordinate_xy *nodes,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t i, j;
+ uint32_t val = 0;
+ unsigned long r_buf_addr;
+ unsigned long g_buf_addr;
+ unsigned long b_buf_addr;
+ struct coordinate_xy *p_nodes = NULL;
+
+ if (!nodes) {
+ ret = -1;
+ printk("isp_k_pingpang_frgb_gamc: node is null error .\n");
+ return ret;
+ }
+
+ p_nodes = nodes;
+
+ if (ISP_FRGB_GAMC_BUF0 == isp_private->full_gamma_buf_id) {
+ r_buf_addr = ISP_FGAMMA_R_BUF1_CH0;
+ g_buf_addr = ISP_FGAMMA_G_BUF1_CH0;
+ b_buf_addr = ISP_FGAMMA_B_BUF1_CH0;
+ isp_private->full_gamma_buf_id = ISP_FRGB_GAMC_BUF1;
+ } else {
+ r_buf_addr = ISP_FGAMMA_R_BUF0_CH0;
+ g_buf_addr = ISP_FGAMMA_G_BUF0_CH0;
+ b_buf_addr = ISP_FGAMMA_B_BUF0_CH0;
+ isp_private->full_gamma_buf_id = ISP_FRGB_GAMC_BUF0;
+ }
+
+ for(i = 0,j = 0;i < ISP_PINGPANG_FRGB_GAMC_NUM;i++,j+=4) {
+ REG_WR(r_buf_addr + j, p_nodes[i].node_y & 0xff);
+ REG_WR(g_buf_addr + j, p_nodes[i].node_y & 0xff);
+ REG_WR(b_buf_addr + j, p_nodes[i].node_y & 0xff);
+ }
+
+ val = ((isp_private->full_gamma_buf_id & 0x1 ) << 1) | ((isp_private->full_gamma_buf_id & 0x1) << 2) | ((isp_private->full_gamma_buf_id & 0x1 ) << 3);
+ REG_MWR(ISP_GAMMA_PARAM, 0x0000000E, val);
+
+ return ret;
+}
+
+static int32_t isp_k_gamma_block(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t bypass;
+ struct isp_dev_gamma_info_v1 *param_p= (struct isp_dev_gamma_info_v1 *)param->property_param;
+ struct coordinate_xy *nodes = NULL;
+
+ nodes = (struct coordinate_xy *)isp_private->full_gamma_buf_addr;
+ if (!nodes) {
+ ret = -1;
+ printk("isp_k_gamma_block: alloc memory error.\n");
+ return -1;
+ }
+
+ ret = copy_from_user((void *)&bypass, (void *)&param_p->bypass, sizeof(uint32_t));
+ if (0 != ret) {
+ printk("isp_k_gamma_block: copy bypass error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ ret = copy_from_user((void *)nodes, (void *)param_p->nodes, ISP_FRGB_GAMMA_BUF_SIZE);
+ if (0 != ret) {
+ printk("isp_k_gamma_block: copy nodes error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ ret = isp_k_pingpang_frgb_gamc(nodes, isp_private);
+ if (0 != ret) {
+ printk("isp_k_gamma_block: pingpang error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_GAMMA_PARAM, BIT_0, bypass);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_gamma(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_gamma: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_gamma: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_GAMMA_BLOCK:
+ ret = isp_k_gamma_block(param, isp_private);
+ break;
+ default:
+ printk("isp_k_cfg_gamma: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_grgb.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_grgb.c
new file mode 100644
index 00000000..6bf40d2a
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_grgb.c
@@ -0,0 +1,70 @@
+/*
+ * 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"
+
+static int32_t isp_k_grgb_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_grgb_info_v1 grgb_info;
+
+ memset(&grgb_info, 0x00, sizeof(grgb_info));
+
+ ret = copy_from_user((void *)&grgb_info, param->property_param, sizeof(grgb_info));
+ if (0 != ret) {
+ printk("isp_k_grgb_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_GRGB_PARAM, BIT_0, grgb_info.bypass);
+
+ val = ((grgb_info.diff & 0x3FF) << 7) | ((grgb_info.edge & 0x3F) << 1);
+ REG_MWR(ISP_GRGB_PARAM, 0x1FFFE, val);
+ val = grgb_info.grid & 0xFFF;
+ REG_MWR(ISP_GRGB_GRID, 0xFFF, val);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_grgb(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_grgb: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_grgb: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_GRGB_BLOCK:
+ ret = isp_k_grgb_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_grgb: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hist.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hist.c
new file mode 100644
index 00000000..dabdd420
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hist.c
@@ -0,0 +1,131 @@
+/*
+ * 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"
+
+static int32_t isp_k_hist_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_hist_info_v1 hist_info;
+ uint32_t val = 0;
+
+ memset(&hist_info, 0x00, sizeof(hist_info));
+
+ ret = copy_from_user((void *)&hist_info, param->property_param, sizeof(hist_info));
+ if (0 != ret) {
+ printk("isp_k_hist_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (hist_info.buf_rst_en) {
+ REG_OWR(ISP_HIST_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_HIST_PARAM, BIT_1, 0);
+ }
+
+ if (hist_info.pof_rst_en) {
+ REG_OWR(ISP_HIST_PARAM, BIT_9);
+ } else {
+ REG_MWR(ISP_HIST_PARAM, BIT_9, 0);
+ }
+
+ if (hist_info.skip_num_clr) {
+ REG_OWR(ISP_HIST_PARAM, BIT_8);
+ } else {
+ REG_MWR(ISP_HIST_PARAM, BIT_8, 0);
+ }
+
+ REG_MWR(ISP_HIST_PARAM, 0xF0, hist_info.skip_num << 4);
+
+ if (hist_info.mode) {
+ REG_OWR(ISP_HIST_PARAM, BIT_3);
+ } else {
+ REG_MWR(ISP_HIST_PARAM, BIT_3, 0);
+ }
+
+ val = ((hist_info.high_ratio & 0xFFFF) << 16)
+ | (hist_info.low_ratio & 0xFFFF);
+
+ REG_WR(ISP_HIST_RATIO, val);
+
+ val = (hist_info.dif_adj & 0xFF) | ((hist_info.small_adj & 0xFF) << 8)
+ | ((hist_info.big_adj & 0xFF) << 16);
+
+ REG_WR(ISP_HIST_ADJUST, val);
+
+ if (hist_info.off) {
+ REG_OWR(ISP_HIST_PARAM, BIT_2);
+ } else {
+ REG_MWR(ISP_HIST_PARAM, BIT_2, 0);
+ }
+
+ if (hist_info.bypass) {
+ REG_OWR(ISP_HIST_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_HIST_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_hist_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size = {0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(size));
+ if (0 != ret) {
+ printk("isp_k_hist_slice_size: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height & 0xFFFF) << 16)
+ | (size.width & 0xFFFF);
+
+ REG_WR(ISP_HIST_SLICE_SIZE, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_hist(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_hist: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_hist: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_HIST_BLOCK:
+ ret = isp_k_hist_block(param);
+ break;
+ case ISP_PRO_HIST_SLICE_SIZE:
+ ret = isp_k_hist_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_hist: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hist2.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hist2.c
new file mode 100644
index 00000000..2ee88107
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hist2.c
@@ -0,0 +1,94 @@
+/*
+ * 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"
+
+static int32_t isp_k_hist2_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_hist2_info_v1 hist2_info;
+ uint32_t val = 0;
+ uint32_t i = 0;
+
+ memset(&hist2_info, 0x00, sizeof(hist2_info));
+
+ ret = copy_from_user((void *)&hist2_info, param->property_param, sizeof(hist2_info));
+ if (0 != ret) {
+ printk("isp_k_hist2_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (hist2_info.skip_num_clr) {
+ REG_OWR(ISP_HIST2_PARAM, BIT_8);
+ } else {
+ REG_MWR(ISP_HIST2_PARAM, BIT_8, 0);
+ }
+
+ REG_MWR(ISP_HIST2_PARAM, 0xF0, hist2_info.skip_num << 4);
+
+ if (hist2_info.mode) {
+ REG_OWR(ISP_HIST2_PARAM, BIT_3);
+ } else {
+ REG_MWR(ISP_HIST2_PARAM, BIT_3, 0);
+ }
+
+ for (i = 0; i < 4; i++) {
+ val = (hist2_info.hist_roi_y_s[i] & 0xFFFF) | ((hist2_info.hist_roi_x_s[i] & 0xFFFF) << 16);
+ REG_WR(ISP_HIST2_ROI_S0 + i * 8, val);
+
+ val = (hist2_info.hist_roi_y_e[i] & 0xFFFF) | ((hist2_info.hist_roi_x_e[i] & 0xFFFF) << 16);
+ REG_WR(ISP_HIST2_ROI_E0 + i * 8, val);
+ }
+
+ if (hist2_info.en) {
+ REG_OWR(ISP_HIST2_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_HIST2_PARAM, BIT_1, 0);
+ }
+
+ if (hist2_info.bypass) {
+ REG_OWR(ISP_HIST2_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_HIST2_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_hist2(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_hist2: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_hist2: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_HIST2_BLOCK:
+ ret = isp_k_hist2_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_hist2: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hsv.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hsv.c
new file mode 100644
index 00000000..5083242b
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hsv.c
@@ -0,0 +1,95 @@
+/*
+ * 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"
+
+static int32_t isp_k_hsv_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ int32_t buf_size = 0;
+ unsigned long dst_addr = 0;
+ struct isp_dev_hsv_info_v1 hsv_info;
+ void *data_ptr = NULL;
+
+ memset(&hsv_info, 0x00, sizeof(hsv_info));
+
+ ret = copy_from_user((void *)&hsv_info, param->property_param, sizeof(hsv_info));
+ if (0 != ret) {
+ printk("isp_k_hsv_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+#ifdef CONFIG_64BIT
+ data_ptr = (void*)(((unsigned long)hsv_info.data_ptr[1] << 32) | hsv_info.data_ptr[0]);
+#else
+ data_ptr = (void*)(hsv_info.data_ptr[0]);
+#endif
+
+ buf_size = ISP_HSV_ITEM * 4;
+ if (NULL == data_ptr || hsv_info.size > buf_size) {
+ printk("isp_k_hsv_block : memory error %p %x \n",
+ data_ptr, hsv_info.size);
+ return -1;
+ }
+
+ if (hsv_info.buf_sel << 1 & BIT_1) {
+ dst_addr = ISP_HSV_BUF1_OUTPUT;
+ } else {
+ dst_addr = ISP_HSV_BUF0_OUTPUT;
+ }
+
+ ret = copy_from_user((void *)dst_addr, data_ptr, hsv_info.size);
+ if (0 != ret) {
+ printk("isp_k_hsv_block: copy error 0x%x \n",(uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_HSV_PARAM, BIT_1, hsv_info.buf_sel << 1);
+
+ REG_MWR(ISP_HSV_PARAM, BIT_0, hsv_info.bypass);
+
+ return ret;
+
+}
+
+
+int32_t isp_k_cfg_hsv(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_hsv: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_hsv: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_HSV_BLOCK:
+ ret = isp_k_hsv_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_hsv: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hua.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hua.c
new file mode 100644
index 00000000..f4570330
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_hua.c
@@ -0,0 +1,68 @@
+/*
+ * 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"
+
+static int32_t isp_k_hue_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_hue_info_v1 hua_info;
+
+ memset(&hua_info, 0x00, sizeof(hua_info));
+
+ ret = copy_from_user((void *)&hua_info, param->property_param, sizeof(hua_info));
+ if (0 != ret) {
+ printk("isp_k_hue_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_HUA_PARAM, 0x1FF0, hua_info.theta << 4);
+
+ if (hua_info.bypass) {
+ REG_OWR(ISP_HUA_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_HUA_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+
+int32_t isp_k_cfg_hue(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_hue: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_hue: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_HUE_BLOCK:
+ ret = isp_k_hue_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_hue: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_iircnr.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_iircnr.c
new file mode 100644
index 00000000..6c6e0591
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_iircnr.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"
+
+static int32_t isp_k_iircnr_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_iircnr_info_v1 iircnr_info;
+ uint32_t val = 0;
+
+ memset(&iircnr_info, 0x00, sizeof(iircnr_info));
+
+ ret = copy_from_user((void *)&iircnr_info, param->property_param, sizeof(iircnr_info));
+ if (0 != ret) {
+ printk("isp_k_iircnr_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (iircnr_info.mode) {
+ REG_OWR(ISP_IIRCNR_PARAM1, BIT_0);
+ } else {
+ REG_MWR(ISP_IIRCNR_PARAM1, BIT_0, 0);
+ }
+
+ val = ((iircnr_info.y_th & 0xFF) << 12) | ((iircnr_info.uv_th & 0x7FF) << 1);
+ REG_MWR(ISP_IIRCNR_PARAM1, 0xFFFFE, val);
+
+ val = ((iircnr_info.uv_pg_th & 0x3FFF) << 10) | (iircnr_info.uv_dist & 0x3FF);
+ REG_WR(ISP_IIRCNR_PARAM2, val);
+
+ val = ((iircnr_info.uv_low_thr2 & 0x1FFFF) << 14) | (iircnr_info.uv_low_thr1 & 0x3FFF);
+ REG_WR(ISP_IIRCNR_PARAM3, val);
+
+ val = iircnr_info.uv_s_th & 0xFF;
+ REG_MWR(ISP_IIRCNR_PARAM6, 0xFF, val);
+
+ val = (iircnr_info.alpha_low_v & 0x3FFF) | ((iircnr_info.alpha_low_u & 0x3FFF) << 14);
+ REG_WR(ISP_IIRCNR_PARAM7, val);
+
+ val = iircnr_info.uv_high_thr2 & 0x1FFFF;
+ REG_WR(ISP_IIRCNR_PARAM9, val);
+
+ val = iircnr_info.ymd_u & 0x3FFFFFFF;
+ REG_WR(ISP_IIRCNR_PARAM4, val);
+
+ val = iircnr_info.ymd_v & 0x3FFFFFFF;
+ REG_WR(ISP_IIRCNR_PARAM5, val);
+
+ REG_MWR(ISP_IIRCNR_PARAM6, 0xFF00, iircnr_info.slope << 8);
+ REG_WR(ISP_IIRCNR_PARAM8, iircnr_info.factor & 0x1FFFFFF);
+
+
+ if (iircnr_info.bypass) {
+ REG_OWR(ISP_IIRCNR_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_IIRCNR_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_yrandom_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_yrandom_info_v1 yrandom_info;
+ uint32_t val = 0;
+
+ memset(&yrandom_info, 0x00, sizeof(yrandom_info));
+
+ ret = copy_from_user((void *)&yrandom_info, param->property_param, sizeof(yrandom_info));
+ if (0 != ret) {
+ printk("isp_k_yrandom_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_YRANDOM_PARAM0, 0xFFFFFF00, yrandom_info.seed << 8);
+ REG_MWR(ISP_YRANDOM_PARAM0, BIT_2, yrandom_info.mode << 2);
+ REG_MWR(ISP_YRANDOM_PARAM0, BIT_0, yrandom_info.init);
+ REG_MWR(ISP_YRANDOM_PARAM1, 0x7FF0000, yrandom_info.offset << 16);
+ REG_MWR(ISP_YRANDOM_PARAM1, 0xF, yrandom_info.shift);
+
+ val = (yrandom_info.takeBit[0] & 0xF) | ((yrandom_info.takeBit[1] & 0xF) << 4)
+ | ((yrandom_info.takeBit[2] & 0xF) << 8) | ((yrandom_info.takeBit[3] & 0xF) << 12)
+ | ((yrandom_info.takeBit[4] & 0xF) << 16) | ((yrandom_info.takeBit[5] & 0xF) << 20)
+ | ((yrandom_info.takeBit[6] & 0xF) << 24) | ((yrandom_info.takeBit[7] & 0xF) << 28);
+ REG_WR(ISP_YRANDOM_PARAM2, val);
+
+ REG_MWR(ISP_YRANDOM_PARAM0, BIT_0, yrandom_info.bypass);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_iircnr(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_iircnr: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_iircnr: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_IIRCNR_BLOCK:
+ ret = isp_k_iircnr_block(param);
+ break;
+ case ISP_PRO_YRANDOM_BLOCK:
+ ret = isp_k_yrandom_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_iircnr: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_isr.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_isr.c
new file mode 100644
index 00000000..d493e086
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_isr.c
@@ -0,0 +1,102 @@
+/*
+ * 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 <linux/delay.h>
+#include "isp_reg.h"
+#include "isp_drv.h"
+
+#define ISP_TIME_OUT_MAX (500)
+
+int32_t isp_get_int_num(struct isp_node *node)
+{
+
+ node->irq_val1 = REG_RD(ISP_INT_INT0);
+ node->irq_val2 = REG_RD(ISP_INT_INT1);
+ node->irq_val3 = REG_RD(ISP_INT_INT2);
+
+ if ((0 == node->irq_val1)
+ && (0 == node->irq_val2)
+ && (0 == node->irq_val3)) {
+ printk("isp_get_int_num: int error.\n");
+ return -1;
+ }
+
+ REG_WR(ISP_INT_CLR0, ISP_IRQ_HW_MASK);
+ REG_WR(ISP_INT_CLR1, ISP_IRQ_HW_MASK);
+ REG_WR(ISP_INT_CLR2, ISP_IRQ_HW_MASK);
+
+ return 0;
+}
+
+void isp_clr_int(void)
+{
+ REG_WR(ISP_INT_CLR0, ISP_IRQ_HW_MASK);
+ REG_WR(ISP_INT_CLR1, ISP_IRQ_HW_MASK);
+ REG_WR(ISP_INT_CLR2, ISP_IRQ_HW_MASK);
+}
+
+void isp_en_irq(uint32_t irq_mode)
+{
+ REG_WR(ISP_INT_CLR0, ISP_IRQ_HW_MASK);
+ REG_WR(ISP_INT_CLR1, ISP_IRQ_HW_MASK);
+ REG_WR(ISP_INT_CLR2, ISP_IRQ_HW_MASK);
+
+ switch(irq_mode) {
+ case ISP_INT_VIDEO_MODE:
+ REG_WR(ISP_INT_EN0, ISP_INT_DCAMERA_SOF | ISP_INT_AEM_DONE | ISP_INT_AFM_RGB_DONE | ISP_INT_AFL_DONE | ISP_INT_AEM2_DONE \
+ | ISP_INT_BINNING_DONE);
+ REG_WR(ISP_INT_EN1, 0);
+ REG_WR(ISP_INT_EN2, 0);
+ break;
+ case ISP_INT_CAPTURE_MODE:
+ REG_WR(ISP_INT_EN0, ISP_INT_STORE_DONE);
+ REG_WR(ISP_INT_EN1, 0);
+ REG_WR(ISP_INT_EN2, 0);
+ break;
+ case ISP_INT_CLEAR_MODE:
+ REG_WR(ISP_INT_EN0, 0);
+ REG_WR(ISP_INT_EN1, 0);
+ REG_WR(ISP_INT_EN2, 0);
+ break;
+ default:
+ printk("isp_en_irq: irq_mode error.\n");
+ break;
+ }
+}
+
+int32_t isp_axi_bus_waiting(void)
+{
+ int32_t ret = 0;
+ uint32_t reg_value = 0;
+ uint32_t time_out_cnt = 0;
+
+ REG_OWR(ISP_AXI_ITI2AXIM_CTRL, BIT_18);
+
+ reg_value = REG_RD(ISP_INT_STATUS);
+ while ((0x00 == (reg_value & BIT_3))
+ && (time_out_cnt < ISP_TIME_OUT_MAX)) {
+ time_out_cnt++;
+ udelay(50);
+ reg_value = REG_RD(ISP_INT_STATUS);
+ }
+
+ if (time_out_cnt >= ISP_TIME_OUT_MAX) {
+ ret = -1;
+ printk("isp_axi_bus_waiting: time out.\n");
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_nlc.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_nlc.c
new file mode 100755
index 00000000..1be70137
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_nlc.c
@@ -0,0 +1,83 @@
+/*
+ * 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"
+
+static int32_t isp_k_nlc_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ struct isp_dev_nlc_info_v1 nlc_info;
+
+ memset(&nlc_info, 0x00, sizeof(nlc_info));
+
+ ret = copy_from_user((void *)&nlc_info, param->property_param, sizeof(nlc_info));
+ if (0 != ret) {
+ printk("isp_k_nlc_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ for (i = 0; i < 9; i++) {
+ val = ((nlc_info.node.r_node[i*3] & 0x3FF) << 20) | ((nlc_info.node.r_node[i*3+1] & 0x3FF) << 10) | (nlc_info.node.r_node[i*3+2] & 0x3FF);
+ REG_WR(ISP_NLC_PARA_R0 + i * 4, val);
+ val = ((nlc_info.node.g_node[i*3] & 0x3FF) << 20) | ((nlc_info.node.g_node[i*3+1] & 0x3FF) << 10) | (nlc_info.node.g_node[i*3+2] & 0x3FF);
+ REG_WR(ISP_NLC_PARA_G0 + i * 4, val);
+ val = ((nlc_info.node.b_node[i*3] & 0x3FF) << 20) | ((nlc_info.node.b_node[i*3+1] & 0x3FF) << 10) | (nlc_info.node.b_node[i*3+2] & 0x3FF);
+ REG_WR(ISP_NLC_PARA_B0 + i * 4, val);
+ val = ((nlc_info.node.l_node[i*3] & 0x3FF) << 20) | ((nlc_info.node.l_node[i*3+1] & 0x3FF) << 10) | (nlc_info.node.l_node[i*3+2] & 0x3FF);
+ REG_WR(ISP_NLC_PARA_L0 + i * 4, val);
+ }
+
+ val = ((nlc_info.node.r_node[27] & 0x3FF) << 20) | ((nlc_info.node.r_node[28] & 0x3FF) << 10);
+ REG_WR(ISP_NLC_PARA_R9, val);
+ val = ((nlc_info.node.g_node[27] & 0x3FF) << 20) | ((nlc_info.node.g_node[28] & 0x3FF) << 10);
+ REG_WR(ISP_NLC_PARA_G9, val);
+ val = ((nlc_info.node.b_node[27] & 0x3FF) << 20) | ((nlc_info.node.b_node[28] & 0x3FF) << 10);
+ REG_WR(ISP_NLC_PARA_B9, val);
+
+ REG_MWR(ISP_NLC_PARA, BIT_0, nlc_info.bypass);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_nlc(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_nlc: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_nlc: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_NLC_BLOCK:
+ ret = isp_k_nlc_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_nlc: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_nlm.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_nlm.c
new file mode 100644
index 00000000..4cf73b08
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_nlm.c
@@ -0,0 +1,250 @@
+/*
+ * 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 <linux/vmalloc.h>
+#include "isp_reg.h"
+
+static int32_t isp_k_vst_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_vst_info_v1 vst_info;
+
+ ret = copy_from_user((void *)&vst_info, param->property_param, sizeof(vst_info));
+ if (0 != ret) {
+ printk("isp_k_vst_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_VST_PARA, BIT_0, vst_info.bypass);
+
+ REG_MWR(ISP_VST_PARA, BIT_1, vst_info.buf_sel << 1);
+
+ return ret;
+
+}
+
+static int32_t isp_k_nlm_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ struct isp_dev_nlm_info_v1 nlm_info;
+ uint32_t *buff0 = NULL;
+ uint32_t *buff1 = NULL;
+ uint32_t *buff2 = NULL;
+ unsigned long buf_addr = 0;
+ void *vst_addr = NULL;
+ void *ivst_addr = NULL;
+ void *nlm_addr = NULL;
+
+ ret = copy_from_user((void *)&nlm_info, param->property_param, sizeof(nlm_info));
+ if (0 != ret) {
+ printk("isp_k_nlm_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ buff0 = vzalloc(nlm_info.vst_len);
+ if (NULL == buff0) {
+ printk("isp_k_nlm_block:vst kmalloc error\n");
+ return -1;
+ }
+
+ buff1 = vzalloc(nlm_info.ivst_len);
+ if (NULL == buff1) {
+ printk("isp_k_nlm_block:ivst kmalloc error\n");
+ vfree(buff0);
+ return -1;
+ }
+
+ buff2 = vzalloc(nlm_info.nlm_len);
+ if (NULL == buff2) {
+ printk("isp_k_nlm_block:nlm kmalloc error\n");
+ vfree(buff0);
+ vfree(buff1);
+ return -1;
+ }
+
+#ifdef CONFIG_64BIT
+ vst_addr = (void*)(((unsigned long)nlm_info.vst_addr[1] << 32) | nlm_info.vst_addr[0]);
+#else
+ vst_addr = (void*)(nlm_info.vst_addr[0]);
+#endif
+ ret = copy_from_user((void *)buff0, vst_addr, nlm_info.vst_len);
+ if (0 != ret) {
+ printk("isp_k_nlm_block: vst copy error, ret=0x%x\n", (uint32_t)ret);
+ vfree(buff0);
+ vfree(buff1);
+ vfree(buff2);
+ return -1;
+ }
+
+#ifdef CONFIG_64BIT
+ ivst_addr = (void*)(((unsigned long)nlm_info.ivst_addr[1] << 32) | nlm_info.ivst_addr[0]);
+#else
+ ivst_addr = (void*)(nlm_info.ivst_addr[0]);
+#endif
+ ret = copy_from_user((void *)buff1, ivst_addr, nlm_info.ivst_len);
+ if (0 != ret) {
+ printk("isp_k_nlm_block: ivst copy error, ret=0x%x\n", (uint32_t)ret);
+ vfree(buff0);
+ vfree(buff1);
+ vfree(buff2);
+ return -1;
+ }
+
+#ifdef CONFIG_64BIT
+ nlm_addr = (void*)(((unsigned long)nlm_info.nlm_addr[1] << 32) | nlm_info.nlm_addr[0]);
+#else
+ nlm_addr = (void*)(nlm_info.nlm_addr[0]);
+#endif
+ ret = copy_from_user((void *)buff2, nlm_addr, nlm_info.nlm_len);
+ if (0 != ret) {
+ printk("isp_k_nlm_block: nlm copy error, ret=0x%x\n", (uint32_t)ret);
+ vfree(buff0);
+ vfree(buff1);
+ vfree(buff2);
+ return -1;
+ }
+
+ REG_MWR(ISP_NLM_PARA, BIT_1, nlm_info.imp_opt_bypass << 1);
+ REG_MWR(ISP_NLM_PARA, BIT_2, nlm_info.flat_opt_bypass << 2);
+ REG_MWR(ISP_NLM_PARA, BIT_3, nlm_info.flat_thr_bypass << 3);
+ REG_MWR(ISP_NLM_PARA, BIT_4, nlm_info.direction_mode_bypass << 4);
+
+ REG_MWR(ISP_NLM_PARA, BIT_31, nlm_info.buf_sel<<31);
+
+ for (i = 0; i < 5; i++) {
+ val = (nlm_info.thresh[i] & 0x3FFF) | ((nlm_info.cnt[i] & 0x1F) << 16)
+ | ((nlm_info.strength[i] & 0xFF) << 24);
+ REG_WR(ISP_NLM_FLAT_PARA_0 + i * 4, val);
+ }
+
+ REG_MWR(ISP_NLM_STERNGTH, 0x7F, nlm_info.streng_th);
+
+ REG_MWR(ISP_NLM_STERNGTH, 0xFF00, nlm_info.texture_dec << 8);
+
+ //REG_WR(ISP_NLM_IS_FLAT, nlm_info.is_flat & 0xFF);
+
+ REG_MWR(ISP_NLM_ADD_BACK, 0x7F, nlm_info.addback);
+
+ REG_MWR(ISP_NLM_ADD_BACK, BIT_7, nlm_info.opt_mode << 7);
+
+ REG_MWR(ISP_NLM_DIRECTION_0, BIT_17 | BIT_16, nlm_info.dist_mode << 16);
+
+ val = ((nlm_info.w_shift[0] & 0x3) << 4) | ((nlm_info.w_shift[1] & 0x3) << 6) | ((nlm_info.w_shift[2] & 0x3) << 8);
+ REG_MWR(ISP_NLM_DIRECTION_0, 0x3F0, val);
+
+ REG_MWR(ISP_NLM_DIRECTION_0, 0x7, nlm_info.cnt_th);
+
+ REG_MWR(ISP_NLM_DIRECTION_1, 0xFFFF0000, nlm_info.tdist_min_th << 16);
+
+ REG_MWR(ISP_NLM_DIRECTION_1, 0xFFFF, nlm_info.diff_th);
+
+ for (i = 0; i < 24; i++) {
+ val = (nlm_info.lut_w[i*3+0] & 0x3FF) | ((nlm_info.lut_w[i*3+1] & 0x3FF) << 10)
+ | ((nlm_info.lut_w[i*3+2] & 0x3FF) << 20);
+ REG_WR(ISP_NLM_LUT_W_0 + i * 4, val);
+ }
+
+ if(nlm_info.buf_sel) {
+ buf_addr = ISP_NLM_BUF1_CH0;
+ memcpy((void *)buf_addr, buff2, ISP_VST_IVST_NUM * sizeof(uint32_t));
+ } else {
+ buf_addr = ISP_NLM_BUF0_CH0;
+ memcpy((void *)buf_addr, buff2, ISP_VST_IVST_NUM * sizeof(uint32_t));
+ }
+
+ if (nlm_info.buf_sel ) {
+ buf_addr = ISP_VST_BUF1_CH0;
+ memcpy((void *)buf_addr, buff0, ISP_VST_IVST_NUM * sizeof(uint32_t));
+ } else {
+ buf_addr = ISP_VST_BUF0_CH0;
+ memcpy((void *)buf_addr, buff0, ISP_VST_IVST_NUM * sizeof(uint32_t));
+ }
+
+ if (nlm_info.buf_sel ) {
+ buf_addr = ISP_IVST_BUF1_CH0;
+ memcpy((void *)buf_addr, buff1, ISP_VST_IVST_NUM * sizeof(uint32_t));
+ } else {
+ buf_addr = ISP_IVST_BUF0_CH0;
+ memcpy((void *)buf_addr, buff1, ISP_VST_IVST_NUM * sizeof(uint32_t));
+ }
+
+ /*vst ivst follow nlm*/
+ REG_MWR(ISP_VST_PARA, BIT_1, nlm_info.buf_sel << 1);
+ REG_MWR(ISP_IVST_PARA, BIT_1, nlm_info.buf_sel << 1);
+
+ REG_MWR(ISP_NLM_PARA, BIT_0, nlm_info.bypass);
+ REG_MWR(ISP_IVST_PARA, BIT_0, nlm_info.bypass);
+ REG_MWR(ISP_VST_PARA, BIT_0, nlm_info.bypass);
+
+ vfree(buff0);
+ vfree(buff1);
+ vfree(buff2);
+ return ret;
+}
+
+static int32_t isp_k_ivst_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ struct isp_dev_ivst_info_v1 ivst_info;
+
+ ret = copy_from_user((void *)&ivst_info, param->property_param, sizeof(ivst_info));
+ if (0 != ret) {
+ printk("isp_k_ivst_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_IVST_PARA, BIT_0, ivst_info.bypass);
+
+ REG_MWR(ISP_IVST_PARA, BIT_1, ivst_info.buf_sel << 1);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_nlm(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_nlm: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_nlm: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_VST_BLOCK:
+ ret = isp_k_vst_block(param);
+ break;
+ case ISP_PRO_NLM_BLOCK:
+ ret = isp_k_nlm_block(param);;
+ break;
+ case ISP_PRO_IVST_BLOCK:
+ ret = isp_k_ivst_block(param);;
+ break;
+ default:
+ printk("isp_k_cfg_nlm: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pgg.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pgg.c
new file mode 100644
index 00000000..8cdd023d
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pgg.c
@@ -0,0 +1,67 @@
+/*
+ * 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"
+
+static int32_t isp_k_pgg_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_pre_glb_gain_info pgg_info;
+
+ memset(&pgg_info, 0x00, sizeof(pgg_info));
+
+ ret = copy_from_user((void *)&pgg_info, param->property_param, sizeof(pgg_info));
+ if (0 != ret) {
+ printk("isp_k_pgg_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_PGG_PARAM, 0xFFFF00, (pgg_info.gain << 8));
+
+ if (pgg_info.bypass) {
+ REG_OWR(ISP_PGG_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_PGG_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_pgg(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_pgg: param is null error.\n");
+ return -1;
+ }
+
+ if (!param->property_param) {
+ printk("isp_k_cfg_pgg: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_PRE_GLB_GAIN_BLOCK:
+ ret = isp_k_pgg_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_pgg: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_post_cdn.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_post_cdn.c
new file mode 100644
index 00000000..8ad8c679
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_post_cdn.c
@@ -0,0 +1,128 @@
+/*
+ * 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"
+
+static int32_t isp_k_post_cdn_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_post_cdn_info post_cdn_info;
+ uint32_t val = 0;
+ uint32_t i = 0;
+
+ memset(&post_cdn_info, 0x00, sizeof(post_cdn_info));
+
+ ret = copy_from_user((void *)&post_cdn_info, param->property_param, sizeof(post_cdn_info));
+ if (0 != ret) {
+ printk("isp_k_post_cdn_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+
+ REG_WR(ISP_POSTCDN_ADPT_THR, post_cdn_info.adapt_med_thr & 0x3FFF);
+
+ REG_MWR(ISP_POSTCDN_COMMON_CTRL, 0xE0, post_cdn_info.median_mode << 5);
+
+ if (post_cdn_info.uvjoint) {
+ REG_OWR(ISP_POSTCDN_COMMON_CTRL, BIT_4);
+ } else {
+ REG_MWR(ISP_POSTCDN_COMMON_CTRL, BIT_4, 0);
+ }
+
+ if (post_cdn_info.writeback_en) {
+ REG_OWR(ISP_POSTCDN_COMMON_CTRL, BIT_3);
+ } else {
+ REG_MWR(ISP_POSTCDN_COMMON_CTRL, BIT_3, 0);
+ }
+
+ if (post_cdn_info.mode) {
+ REG_OWR(ISP_POSTCDN_COMMON_CTRL, BIT_2);
+ } else {
+ REG_MWR(ISP_POSTCDN_COMMON_CTRL, BIT_2, 0);
+ }
+
+ val = (post_cdn_info.uvthr0 & 0x1FF) | ((post_cdn_info.uvthr1 & 0x1FF) << 16);
+ REG_WR(ISP_POSTCDN_UVTHR, val);
+ val = (post_cdn_info.thru0 & 0xFF) | ((post_cdn_info.thru1 & 0xFF) << 16);
+ REG_WR(ISP_POSTCDN_THRU, val);
+ val = (post_cdn_info.thrv0 & 0xFF) | ((post_cdn_info.thrv1 & 0xFF) << 16);
+ REG_WR(ISP_POSTCDN_THRV, val);
+
+ for (i = 0; i < 3; i++) {
+ val = (post_cdn_info.r_segu[0][i*2] & 0xFF) | ((post_cdn_info.r_segu[1][i*2] & 0x7) << 8)
+ | ((post_cdn_info.r_segu[0][i*2+1] & 0xFF) << 16) | ((post_cdn_info.r_segu[1][i*2+1] & 0x7) << 24);
+ REG_WR(ISP_POSTCDN_RSEGU01 + i * 4, val);
+ }
+ val = (post_cdn_info.r_segu[0][6] & 0xFF) | ((post_cdn_info.r_segu[1][6] & 0x7) << 8);
+ REG_WR(ISP_POSTCDN_RSEGU6, val);
+ for (i = 0; i < 3; i++) {
+ val = (post_cdn_info.r_segv[0][i*2] & 0xFF) | ((post_cdn_info.r_segv[1][i*2] & 0x7) << 8)
+ | ((post_cdn_info.r_segv[0][i*2+1] & 0xFF) << 16) | ((post_cdn_info.r_segv[1][i*2+1] & 0x7) << 24);
+ REG_WR(ISP_POSTCDN_RSEGV01 + i * 4, val);
+ }
+ val = (post_cdn_info.r_segv[0][6] & 0xFF) | ((post_cdn_info.r_segv[1][6] & 0x7) << 8);
+ REG_WR(ISP_POSTCDN_RSEGV6, val);
+
+
+ for (i = 0; i < 15; i++) {
+ val = (post_cdn_info.r_distw[i][0] & 0x7) | ((post_cdn_info.r_distw[i][1] & 0x7) << 3)
+ | ((post_cdn_info.r_distw[i][2] & 0x7) << 6) | ((post_cdn_info.r_distw[i][3] & 0x7) << 9)
+ | ((post_cdn_info.r_distw[i][4] & 0x7) << 12);
+ REG_WR(ISP_POSTCDN_R_DISTW0 + i * 4, val);
+ }
+
+ REG_WR(ISP_POSTCDN_START_ROW_MOD4, post_cdn_info.start_row_mod4 & 0x3);
+
+ if (post_cdn_info.downsample_bypass) {
+ REG_OWR(ISP_POSTCDN_COMMON_CTRL, BIT_1);
+ } else {
+ REG_MWR(ISP_POSTCDN_COMMON_CTRL, BIT_1, 0);
+ }
+
+ if (post_cdn_info.bypass) {
+ REG_OWR(ISP_POSTCDN_COMMON_CTRL, BIT_0);
+ } else {
+ REG_MWR(ISP_POSTCDN_COMMON_CTRL, BIT_0, 0);
+ }
+
+
+ return ret;
+}
+
+int32_t isp_k_cfg_post_cdn(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_post_cdn: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_post_cdn: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_POST_CDN_BLOCK:
+ ret = isp_k_post_cdn_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_post_cdn: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pre_cdn.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pre_cdn.c
new file mode 100644
index 00000000..f4be5578
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pre_cdn.c
@@ -0,0 +1,135 @@
+/*
+ * 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"
+
+static int32_t isp_k_yuv_precdn_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_yuv_precdn_info pre_cdn_info;
+ uint32_t val = 0;
+ uint32_t i = 0;
+
+ memset(&pre_cdn_info, 0x00, sizeof(pre_cdn_info));
+
+ ret = copy_from_user((void *)&pre_cdn_info, param->property_param, sizeof(pre_cdn_info));
+ if (0 != ret) {
+ printk("isp_k_yuv_precdn_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (pre_cdn_info.mode) {
+ REG_OWR(ISP_PRECDN_PARAM, BIT_4);
+ } else {
+ REG_MWR(ISP_PRECDN_PARAM, BIT_4, 0);
+ }
+
+ if (pre_cdn_info.median_writeback_en) {
+ REG_OWR(ISP_PRECDN_PARAM, BIT_8);
+ } else {
+ REG_MWR(ISP_PRECDN_PARAM, BIT_8, 0);
+ }
+
+ REG_MWR(ISP_PRECDN_PARAM, BIT_13 | BIT_12, pre_cdn_info.median_mode << 12);
+
+ if (pre_cdn_info.uv_joint) {
+ REG_OWR(ISP_PRECDN_PARAM, BIT_20);
+ } else {
+ REG_MWR(ISP_PRECDN_PARAM, BIT_20, 0);
+ }
+
+ REG_MWR(ISP_PRECDN_PARAM, BIT_17 | BIT_16, pre_cdn_info.den_stren << 16);
+
+ val = (pre_cdn_info.median_thr_u[0] & 0x7F) | ((pre_cdn_info.median_thr_u[1] & 0xFF) << 8)
+ | ((pre_cdn_info.median_thr_v[0] & 0x7F) << 16) | ((pre_cdn_info.median_thr_v[1] & 0xFF) << 24);
+ REG_WR(ISP_PRECDN_MEDIAN_THRUV01, val);
+
+ val = (pre_cdn_info.median_thr & 0x1FF) | ((pre_cdn_info.uv_thr & 0xFF) << 16)
+ | ((pre_cdn_info.y_thr & 0xFF) << 24);
+ REG_WR(ISP_PRECDN_THRYUV, val);
+
+ for (i = 0; i < 3; i++) {
+ val = (pre_cdn_info.r_segu[0][i*2] & 0xFF) | ((pre_cdn_info.r_segu[1][i*2] & 0x7) << 8)
+ | ((pre_cdn_info.r_segu[0][i*2+1] & 0xFF) << 16) | ((pre_cdn_info.r_segu[1][i*2+1] & 0x7) << 24);
+ REG_WR(ISP_PRECDN_SEGU_0 + i * 4, val);
+ }
+
+ val = (pre_cdn_info.r_segu[0][6] & 0xFF) | ((pre_cdn_info.r_segu[1][6] & 0x7) << 8);
+ REG_WR(ISP_PRECDN_SEGU_3, val);
+
+ for (i = 0; i < 3; i++) {
+ val = (pre_cdn_info.r_segv[0][i*2] & 0xFF) | ((pre_cdn_info.r_segv[1][i*2] & 0x7) << 8)
+ | ((pre_cdn_info.r_segv[0][i*2+1] & 0xFF) << 16) | ((pre_cdn_info.r_segv[1][i*2+1] & 0x7) << 24);
+ REG_WR(ISP_PRECDN_SEGV_0 + i * 4, val);
+ }
+
+ val = (pre_cdn_info.r_segv[0][6] & 0xFF) | ((pre_cdn_info.r_segv[1][6] & 0x7) << 8);
+ REG_WR(ISP_PRECDN_SEGV_3, val);
+
+ for (i = 0; i < 3; i++) {
+ val = (pre_cdn_info.r_segy[0][i*2] & 0xFF) | ((pre_cdn_info.r_segy[1][i*2] & 0x7) << 8)
+ | ((pre_cdn_info.r_segy[0][i*2+1] & 0xFF) << 16) | ((pre_cdn_info.r_segy[1][i*2+1] & 0x7) << 24);
+ REG_WR(ISP_PRECDN_SEGY_0 + i * 4, val);
+ }
+
+ val = (pre_cdn_info.r_segy[0][6] & 0xFF) | ((pre_cdn_info.r_segy[1][6] & 0x7) << 8);
+ REG_WR(ISP_PRECDN_SEGY_3, val);
+
+ for (i = 0; i < 3; i++) {
+ val = (pre_cdn_info.r_distw[i*8] & 0x7) | ((pre_cdn_info.r_distw[i*8+1] & 0x7) << 4)
+ | ((pre_cdn_info.r_distw[i*8+2] & 0x7) << 8) | ((pre_cdn_info.r_distw[i*8+3] & 0x7) << 12)
+ | ((pre_cdn_info.r_distw[i*8+4] & 0x7) << 16) | ((pre_cdn_info.r_distw[i*8+5] & 0x7) << 20)
+ | ((pre_cdn_info.r_distw[i*8+6] & 0x7) << 24) | ((pre_cdn_info.r_distw[i*8+7] & 0x7) << 28);
+ REG_WR(ISP_PRECDN_DISTW0 + i * 4, val);
+ }
+
+ val = pre_cdn_info.r_distw[24] & 0x7;
+ REG_WR(ISP_PRECDN_DISTW3, val);
+
+ if (pre_cdn_info.bypass) {
+ REG_OWR(ISP_PRECDN_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_PRECDN_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_yuv_precdn(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_yuv_precdn: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_yuv_precdn: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_YUV_PRECDN_BLOCK:
+ ret = isp_k_yuv_precdn_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_yuv_precdn: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pre_cdn_rgb.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pre_cdn_rgb.c
new file mode 100644
index 00000000..d5bde126
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pre_cdn_rgb.c
@@ -0,0 +1,73 @@
+/*
+ * 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"
+
+static int32_t isp_k_pre_cdn_rgb_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_pre_cdn_rgb_info pcr_info;
+
+ memset(&pcr_info, 0x00, sizeof(pcr_info));
+
+ ret = copy_from_user((void *)&pcr_info, param->property_param, sizeof(pcr_info));
+ if (0 != ret) {
+ printk("isp_k_pre_cdn_rgb_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_PRECNRNEW_CFG, BIT_0, pcr_info.bypass);
+
+ REG_MWR(ISP_PRECNRNEW_CFG, 0x3 << 1, pcr_info.median_mode << 1);
+
+ val = pcr_info.median_thr & 0xFFFF;
+ REG_WR(ISP_PRECNRNEW_MEDIAN_THR, val);
+ val = (pcr_info.thru0 & 0xFFFF) | ((pcr_info.thru1 & 0xFFFF) << 16);
+ REG_WR(ISP_PRECNRNEW_THRU, val);
+ val = (pcr_info.thrv0 & 0xFFFF) | ((pcr_info.thrv1 & 0xFFFF) << 16);
+ REG_WR(ISP_PRECNRNEW_THRV, val);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_pre_cdn_rgb(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_pre_cdn_rgb: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_pre_cdn_rgb: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_PRE_CDN_RGB_BLOCK:
+ ret = isp_k_pre_cdn_rgb_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_pre_cdn_rgb: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_prefilter.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_prefilter.c
new file mode 100644
index 00000000..ea25ccf1
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_prefilter.c
@@ -0,0 +1,73 @@
+/*
+ * 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"
+
+static int32_t isp_k_prefilter_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_prefilter_info_v1 prefilter_info;
+
+ memset(&prefilter_info, 0x00, sizeof(prefilter_info));
+
+ ret = copy_from_user((void *)&prefilter_info, param->property_param, sizeof(prefilter_info));
+ if (0 != ret) {
+ printk("isp_k_prefilter_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (prefilter_info.writeback) {
+ REG_OWR(ISP_PREF_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_PREF_PARAM, BIT_1, 0);
+ }
+
+ REG_WR(ISP_PREF_THRD, prefilter_info.thrd & 0xFF);
+
+ if (prefilter_info.bypass) {
+ REG_OWR(ISP_PREF_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_PREF_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_prefilter(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_prefilter: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_prefilter: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_PREF_BLOCK:
+ ret = isp_k_prefilter_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_prefilter: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pstrz.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pstrz.c
new file mode 100644
index 00000000..0db4e234
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pstrz.c
@@ -0,0 +1,71 @@
+/*
+ * 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"
+
+static int32_t isp_k_posterize_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ struct isp_dev_posterize_info pstrz_info;
+
+ memset(&pstrz_info, 0x00, sizeof(pstrz_info));
+
+ ret = copy_from_user((void *)&pstrz_info, param->property_param, sizeof(pstrz_info));
+ if (0 != ret) {
+ printk("isp_k_posterize_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_PSTRZ_PARAM, BIT_0, pstrz_info.bypass);
+
+ for (i = 0; i < 8; i++) {
+ val = (pstrz_info.posterize_level_out[i] & 0xFF) | ((pstrz_info.posterize_level_top[i] & 0xFF) << 8)
+ | ((pstrz_info.posterize_level_bottom[i] & 0xFF) << 16);
+ REG_WR(ISP_PSTRZ_LEVEL0 + i * 4, val);
+ }
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_posterize(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_posterize: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_posterize: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_POSTERIZE_BLOCK:
+ ret = isp_k_posterize_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_posterize: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pwd.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pwd.c
new file mode 100644
index 00000000..c7bc4ca4
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_pwd.c
@@ -0,0 +1,123 @@
+/*
+ * 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"
+
+static int32_t isp_k_pwd_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_pre_wavelet_info_v1 pwd_info;
+
+ memset(&pwd_info, 0x00, sizeof(pwd_info));
+
+ ret = copy_from_user((void *)&pwd_info, param->property_param, sizeof(pwd_info));
+ if (0 != ret) {
+ printk("isp_k_pwd_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((pwd_info.gain_thrs0 & 0x7FF) << 6) | ((pwd_info.gain_thrs1 & 0x7FF) << 17);
+ REG_MWR(ISP_PWD_PARAM, 0x0FFFFFC0, val);
+
+ val = (pwd_info.bitshift0 & 0x7) | ((pwd_info.bitshift1 & 0xFF) << 3);
+ REG_MWR(ISP_PWD_PARAM1, 0x7FF, val);
+
+ val = (pwd_info.offset & 0xFF) << 11;
+ REG_MWR(ISP_PWD_PARAM1, 0x7F800, val);
+
+ val = (pwd_info.nsr_slope & 0x3FF) << 4;
+ REG_MWR(ISP_PWD_PARAM2, 0x3FF0, val);
+
+ val = pwd_info.lum_ratio & 0xF;
+ REG_MWR(ISP_PWD_PARAM2, 0xF, val);
+
+ val = ((pwd_info.center_pos_x & 0x1FFF) << 12) | (pwd_info.center_pos_y & 0xFFF);
+ REG_WR(ISP_PWD_PARAM3, val);
+
+ val = pwd_info.delta_x2 & 0x3FFFFFF;
+ REG_WR(ISP_PWD_PARAM4, val);
+ val = pwd_info.delta_y2 & 0xFFFFFF;
+ REG_WR(ISP_PWD_PARAM5, val);
+
+ val = pwd_info.r2_thr & 0x3FFFFFF;
+ REG_WR(ISP_PWD_PARAM6, val);
+
+ val = ((pwd_info.p_param1 & 0x3FFF) << 12) | (pwd_info.p_param2 & 0xFFF);
+ REG_WR(ISP_PWD_PARAM7, val);
+
+ val = (pwd_info.addback & 0x7F) << 13;
+ REG_MWR(ISP_PWD_PARAM8, 0xFE000, val);
+
+ val = pwd_info.gain_max_thr & 0x1FFF;
+ REG_MWR(ISP_PWD_PARAM8, 0x1FFF, val);
+
+ val = ((pwd_info.pos_x & 0x1FFF) << 12) | (pwd_info.pos_y & 0xFFF);
+ REG_WR(ISP_PWD_PARAM10, val);
+
+ REG_MWR(ISP_PWD_PARAM, BIT_1, pwd_info.radial_bypass << 1);
+ REG_MWR(ISP_PWD_PARAM, BIT_0, pwd_info.bypass);
+
+ return ret;
+}
+
+static int32_t isp_k_pwd_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size = {0, 0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
+ if (0 != ret) {
+ printk("isp_k_pwd_slice_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.width & 0x1FFF) << 12) | (size.height & 0xFFF);
+ REG_WR(ISP_PWD_PARAM9, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_pwd(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_pwd: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_pwd: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_PWD_BLOCK:
+ ret = isp_k_pwd_block(param);
+ break;
+ case ISP_PRO_PWD_SLICE_SIZE:
+ ret = isp_k_pwd_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_pwd: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_raw_aem.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_raw_aem.c
new file mode 100644
index 00000000..5e4509d5
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_raw_aem.c
@@ -0,0 +1,255 @@
+/*
+ * 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"
+
+static int32_t isp_k_raw_aem_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_raw_aem_info aem_info;
+
+ memset(&aem_info, 0x00, sizeof(aem_info));
+
+ ret = copy_from_user((void *)&aem_info, param->property_param, sizeof(aem_info));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_AEM_PARAM, BIT_0, aem_info.bypass);
+
+ val = (aem_info.shift & 0x1F) << 18;
+ if(0 != val) {
+ printk("isp_k_raw_aem_block: shift error, 0x%x\n", val);
+ }
+ REG_MWR(ISP_AEM_BLK_SIZE, 0x7C0000, 0);
+
+ REG_MWR(ISP_AEM_PARAM, BIT_1, aem_info.mode << 1);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_bypass: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_AEM_PARAM, BIT_0, bypass);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_mode(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t mode = 0;
+
+ ret = copy_from_user((void *)&mode, param->property_param, sizeof(mode));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_mode: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_AEM_PARAM, BIT_1, mode << 1);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_statistics(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0, i = 0;
+ uint32_t val0 = 0, val1 = 0;
+ unsigned long addr = 0;
+ struct isp_raw_aem_statistics *aem_statistics = NULL;
+
+ aem_statistics = (struct isp_raw_aem_statistics *)isp_private->raw_aem_buf_addr;
+ if (!aem_statistics) {
+ ret = -1;
+ printk("isp_k_raw_aem_statistics: alloc memory error.\n");
+ return -1;
+ }
+
+ addr = ISP_RAW_AEM_OUTPUT;
+ for (i = 0x00; i < ISP_RAW_AEM_ITEM; i++) {
+ val0 = REG_RD(addr);
+ val1 = REG_RD(addr + 4);
+ aem_statistics->r[i]= (val1 >> 11) & 0x1fffff;
+ aem_statistics->g[i]= val0 & 0x3fffff;
+ aem_statistics->b[i]= ((val1 & 0x7ff) << 10) | ((val0 >> 22) & 0x3ff);
+ addr += 8;
+ }
+
+ ret = copy_to_user(param->property_param, (void*)aem_statistics, sizeof(struct isp_raw_aem_statistics));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_raw_aem_statistics: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_skip_num(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t skip_num;
+
+ ret = copy_from_user((void *)&skip_num, param->property_param, sizeof(skip_num));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_skip_num: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (skip_num & 0xF) << 4;
+ REG_MWR(ISP_AEM_PARAM, 0xF0, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_shift(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t shift = 0;
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&shift, param->property_param, sizeof(shift));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_shift: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (shift & 0x1F) << 18;
+ if(0 != val) {
+ printk("isp_k_raw_aem_shift: shift error, 0x%x\n", val);
+ }
+ REG_MWR(ISP_AEM_BLK_SIZE, 0x7C0000, 0);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_offset(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct img_offset offset;
+
+ ret = copy_from_user((void *)&offset, param->property_param, sizeof(struct img_offset));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_offset: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((offset.y & 0xFFFF) << 16) | (offset.x & 0xFFFF);
+ REG_WR(ISP_AEM_OFFSET, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_blk_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size size;
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_blk_size: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height & 0x1FF) << 9) | (size.width & 0x1FF);
+ REG_MWR(ISP_AEM_BLK_SIZE, 0x3FFFF, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_aem_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size size;
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_slice_size: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height & 0xFFFF) << 16) | (size.width & 0xFFFF);
+ REG_WR(ISP_AEM_SLICE_SIZE, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_raw_aem(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_raw_aem: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_raw_aem: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_RAW_AEM_BLOCK:
+ ret = isp_k_raw_aem_block(param);
+ break;
+ case ISP_PRO_RAW_AEM_BYPASS:
+ ret = isp_k_raw_aem_bypass(param);
+ break;
+ case ISP_PRO_RAW_AEM_MODE:
+ ret = isp_k_raw_aem_mode(param);
+ break;
+ case ISP_PRO_RAW_AEM_STATISTICS:
+ ret = isp_k_raw_aem_statistics(param, isp_private);
+ break;
+ case ISP_PRO_RAW_AEM_SKIP_NUM:
+ ret = isp_k_raw_aem_skip_num(param);
+ break;
+ case ISP_PRO_RAW_AEM_SHIFT:
+ ret = isp_k_raw_aem_shift(param);
+ break;
+ case ISP_PRO_RAW_AEM_OFFSET:
+ ret = isp_k_raw_aem_offset(param);
+ break;
+ case ISP_PRO_RAW_AEM_BLK_SIZE:
+ ret = isp_k_raw_aem_blk_size(param);
+ break;
+ case ISP_PRO_RAW_AEM_SLICE_SIZE:
+ ret = isp_k_raw_aem_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_raw_aem: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_raw_afm.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_raw_afm.c
new file mode 100644
index 00000000..b3f97c3f
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_raw_afm.c
@@ -0,0 +1,497 @@
+/*
+ * 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"
+
+#define ISP_AFM_WIN_NUM_V1 25
+static int32_t isp_k_raw_afm_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ int max_num = ISP_AFM_WIN_NUM_V1;
+ struct isp_dev_rgb_afm_info_v1 rafm_info;
+
+ memset(&rafm_info, 0x00, sizeof(rafm_info));
+
+ ret = copy_from_user((void *)&rafm_info, param->property_param, sizeof(rafm_info));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_0, rafm_info.bypass);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_1, rafm_info.mode << 1);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, 0xF<<2, (rafm_info.skip_num << 2));
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_6, rafm_info.skip_num_clear << 6);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_7, rafm_info.spsmd_rtgbot_enable << 7);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_8, rafm_info.spsmd_diagonal_enable << 8);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_9, rafm_info.spsmd_cal_mode << 9);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_10, rafm_info.af_sel_filter1 << 10);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_11, rafm_info.af_sel_filter2 << 11);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_12, rafm_info.sobel_type << 12);
+
+ REG_MWR(ISP_RGB_AFM_PARAM, (BIT_13)|(BIT_14), rafm_info.spsmd_type << 13);
+
+ val = ((rafm_info.sobel_threshold_max << 16) & 0xffff0000)
+ | (rafm_info.sobel_threshold_min & 0xffff);
+ REG_WR(ISP_RGB_AFM_SOBEL_THRESHOLD, val);
+
+ REG_WR(ISP_RGB_AFM_SPSMD_THRESHOLD_MIN, rafm_info.spsmd_threshold_min);
+ REG_WR(ISP_RGB_AFM_SPSMD_THRESHOLD_MAX, rafm_info.spsmd_threshold_max);
+
+ for (i = 0; i < max_num; i++) {
+ val = ((rafm_info.coord[i].start_y <<16) & 0xffff0000)
+ | (rafm_info.coord[i].start_x & 0xffff);
+ REG_WR((ISP_RGB_AFM_WIN_RANGE0 + 4*2*i), val);
+
+ val = ((rafm_info.coord[i].end_y <<16) & 0xffff0000)
+ | (rafm_info.coord[i].end_x & 0xffff);
+ REG_WR((ISP_RGB_AFM_WIN_RANGE0 + 4*(2*i+1)), val);
+ }
+
+ return ret;
+
+}
+
+static int32_t isp_k_raw_afm_frame_range(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size frame_size = {0, 0};
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&frame_size, param->property_param, sizeof(frame_size));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_frame_range: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (frame_size.height & 0xFFFF) | ((frame_size.width & 0xFFFF) << 16);
+ REG_WR(ISP_RGB_AFM_FRAME_RANGE, val);
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_type1_statistic(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ int i = 0;
+ int max_item = ISP_AFM_WIN_NUM_V1;
+ struct isp_raw_afm_statistic item;
+
+ memset(&item, 0, sizeof(struct isp_raw_afm_statistic));
+ for (i = 0; i < max_item; i++) {
+ item.val[i] = REG_RD((ISP_RGB_AFM_TYPE1_VAL00 + 4*i));
+ }
+ ret = copy_to_user(param->property_param, (void*)&item, sizeof(item));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_raw_afm_statistic: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_type2_statistic(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ int i = 0;
+ int max_item = ISP_AFM_WIN_NUM_V1;
+ struct isp_raw_afm_statistic item;
+
+ memset(&item, 0, sizeof(struct isp_raw_afm_statistic));
+ for (i = 0; i < max_item; i++) {
+ item.val[i] = REG_RD((ISP_RGB_AFM_TYPE2_VAL00 + 4*i));
+ }
+ ret = copy_to_user(param->property_param, (void*)&item, sizeof(item));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_raw_afm_statistic: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_bypass: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (bypass) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_mode(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t mode = 0;
+
+ ret = copy_from_user((void *)&mode, param->property_param, sizeof(mode));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_mode: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (mode) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_1, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_skip_num(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t skip_num = 0;
+
+ ret = copy_from_user((void *)&skip_num, param->property_param, sizeof(skip_num));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_skip_num: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_RGB_AFM_PARAM, 0xF<<2, (skip_num <<2));
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_skip_num_clr(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t is_clear = 0;
+
+ ret = copy_from_user((void *)&is_clear, param->property_param, sizeof(is_clear));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_skip_num_clr: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (is_clear) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_6);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_6, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_spsmd_rtgbot_enable(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t is_enable = 0;
+
+ ret = copy_from_user((void *)&is_enable, param->property_param, sizeof(is_enable));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_spsmd_rtgbot_enable: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (is_enable) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_7);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_7, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_spsmd_diagonal_enable(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t is_enable = 0;
+
+ ret = copy_from_user((void *)&is_enable, param->property_param, sizeof(is_enable));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_spsmd_diagonal_enable: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (is_enable) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_8);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_8, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_spsmd_cal_mode(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t cal_mode = 0;
+
+ ret = copy_from_user((void *)&cal_mode, param->property_param, sizeof(cal_mode));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_spsmd_cal_mode: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ if (cal_mode) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_9);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_9, 0);
+ }
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_sel_filter1(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t af_sel_filter = 0;
+
+ ret = copy_from_user((void *)&af_sel_filter, param->property_param, sizeof(af_sel_filter));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_sel_filter1: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ if (af_sel_filter) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_10);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_10, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_sel_filter2(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t af_sel_filter = 0;
+
+ ret = copy_from_user((void *)&af_sel_filter, param->property_param, sizeof(af_sel_filter));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_sel_filter2: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ if (af_sel_filter) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_11);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_11, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_sobel_type(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t sobel_type = 0;
+
+ ret = copy_from_user((void *)&sobel_type, param->property_param, sizeof(sobel_type));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_sel_filter2: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (sobel_type) {
+ REG_OWR(ISP_RGB_AFM_PARAM, BIT_12);
+ } else {
+ REG_MWR(ISP_RGB_AFM_PARAM, BIT_12, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_spsmd_type(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t spsmd_type = 0;
+
+ ret = copy_from_user((void *)&spsmd_type, param->property_param, sizeof(spsmd_type));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_sel_filter2: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_RGB_AFM_PARAM, (BIT_13)|(BIT_14), spsmd_type<<13);
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_sobel_threshold(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct sobel_thrd sobel_threshold = {0, 0};
+
+ ret = copy_from_user((void *)&sobel_threshold, param->property_param, sizeof(sobel_threshold));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_sel_filter2: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ val = ((sobel_threshold.max<<16) & 0xffff0000)
+ | (sobel_threshold.min & 0xffff);
+ REG_WR(ISP_RGB_AFM_SOBEL_THRESHOLD, val);
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_spsmd_threshold(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct spsmd_thrd spsmd_threshold = {0, 0};
+
+ ret = copy_from_user((void *)&spsmd_threshold, param->property_param, sizeof(spsmd_threshold));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_spsmd_threshold: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+ REG_WR(ISP_RGB_AFM_SPSMD_THRESHOLD_MIN, spsmd_threshold.min);
+ REG_WR(ISP_RGB_AFM_SPSMD_THRESHOLD_MAX, spsmd_threshold.max);
+ return ret;
+}
+
+static int32_t isp_k_raw_afm_win(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ int i = 0;
+ int max_num = ISP_AFM_WIN_NUM_V1;
+ struct isp_coord coord[ISP_AFM_WIN_NUM_V1];
+ uint32_t val = 0;
+
+
+ memset(coord, 0, sizeof(coord));
+ ret = copy_from_user((void *)&coord, param->property_param, sizeof(coord));
+ if (0 != ret) {
+ printk("isp_k_raw_afm_win: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ for (i = 0; i < max_num; i++) {
+ val = ((coord[i].start_y <<16) & 0xffff0000)
+ | (coord[i].start_x & 0xffff);
+ REG_WR((ISP_RGB_AFM_WIN_RANGE0 + 4*2*i), val);
+
+ val = ((coord[i].end_y <<16) & 0xffff0000)
+ | (coord[i].end_x & 0xffff);
+ REG_WR((ISP_RGB_AFM_WIN_RANGE0 + 4*(2*i+1)), val);
+ }
+
+ return ret;
+}
+
+
+static int32_t isp_k_raw_afm_win_num(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t num = ISP_AFM_WIN_NUM_V1;
+
+ ret = copy_to_user(param->property_param, (void*)&num, sizeof(num));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_raw_afm_win_num: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_rgb_afm(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_afm: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_afm: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_RGB_AFM_BLOCK:
+ ret = isp_k_raw_afm_block(param);
+ break;
+ case ISP_PRO_RGB_AFM_FRAME_SIZE:
+ ret = isp_k_raw_afm_frame_range(param);
+ break;
+ case ISP_PRO_RGB_AFM_TYPE1_STATISTIC:
+ ret = isp_k_raw_afm_type1_statistic(param);
+ break;
+ case ISP_PRO_RGB_AFM_TYPE2_STATISTIC:
+ ret = isp_k_raw_afm_type2_statistic(param);
+ break;
+ case ISP_PRO_RGB_AFM_BYPASS:
+ ret = isp_k_raw_afm_bypass(param);
+ break;
+ case ISP_PRO_RGB_AFM_MODE:
+ ret = isp_k_raw_afm_mode(param);
+ break;
+ case ISP_PRO_RGB_AFM_SKIP_NUM:
+ ret = isp_k_raw_afm_skip_num(param);
+ break;
+ case ISP_PRO_RGB_AFM_SKIP_NUM_CLR:
+ ret = isp_k_raw_afm_skip_num_clr(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_RTGBOT_ENABLE:
+ ret = isp_k_raw_afm_spsmd_rtgbot_enable(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_DIAGONAL_ENABLE:
+ ret = isp_k_raw_afm_spsmd_diagonal_enable(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_CAL_MOD:
+ ret = isp_k_raw_afm_spsmd_cal_mode(param);
+ break;
+ case ISP_PRO_RGB_AFM_SEL_FILTER1:
+ ret = isp_k_raw_afm_sel_filter1(param);
+ break;
+ case ISP_PRO_RGB_AFM_SEL_FILTER2:
+ ret = isp_k_raw_afm_sel_filter2(param);
+ break;
+ case ISP_PRO_RGB_AFM_SOBEL_TYPE:
+ ret = isp_k_raw_afm_sobel_type(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_TYPE:
+ ret = isp_k_raw_afm_spsmd_type(param);
+ break;
+ case ISP_PRO_RGB_AFM_SOBEL_THRESHOLD:
+ ret = isp_k_raw_afm_sobel_threshold(param);
+ break;
+ case ISP_PRO_RGB_AFM_SPSMD_THRESHOLD:
+ ret = isp_k_raw_afm_spsmd_threshold(param);
+ break;
+ case ISP_PRO_RGB_AFM_WIN:
+ ret = isp_k_raw_afm_win(param);
+ break;
+ case ISP_PRO_RGB_AFM_WIN_NUM:
+ ret = isp_k_raw_afm_win_num(param);
+ break;
+ default:
+ printk("isp_k_cfg_afm: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_raw_sizer.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_raw_sizer.c
new file mode 100644
index 00000000..9525d9e8
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_raw_sizer.c
@@ -0,0 +1,369 @@
+/*
+ * 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"
+
+static int32_t isp_k_raw_sizer_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_bypass: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (bypass) {
+ REG_OWR(ISP_RAW_SIZER_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_RAW_SIZER_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_sizer_bpc_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_bpc_bypass: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (bypass) {
+ REG_OWR(ISP_RAW_SIZER_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_RAW_SIZER_PARAM, BIT_1, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_sizer_crop_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_crop_bypass: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (bypass) {
+ REG_OWR(ISP_RAW_SIZER_PARAM, BIT_2);
+ } else {
+ REG_MWR(ISP_RAW_SIZER_PARAM, BIT_2, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_raw_sizer_crop_src_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size src_size;
+
+ ret = copy_from_user((void *)&src_size, param->property_param, sizeof(src_size));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_crop_src_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (src_size.height & 0xFFFF)
+ | ((src_size.width & 0xFFFF) << 16);
+ REG_WR(ISP_RAW_SIZER_CROP_SRC, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_sizer_crop_dest_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size dest_size;
+
+ ret = copy_from_user((void *)&dest_size, param->property_param, sizeof(dest_size));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_crop_dest_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (dest_size.height & 0xFFFF)
+ | ((dest_size.width & 0xFFFF) << 16);
+ REG_WR(ISP_RAW_SIZER_CROP_DST, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_sizer_crop_start(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_offset crop_start;
+
+ ret = copy_from_user((void *)&crop_start, param->property_param, sizeof(crop_start));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_crop_start: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (crop_start.y& 0xFFFF)
+ | ((crop_start.x & 0xFFFF) << 16);
+ REG_WR(ISP_RAW_SIZER_CROP_START, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_sizer_dest_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size dest_size;
+
+ ret = copy_from_user((void *)&dest_size, param->property_param, sizeof(dest_size));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_dest_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (dest_size.height & 0xFFFF)
+ | ((dest_size.width & 0xFFFF) << 16);
+ REG_WR(ISP_RAW_SIZER_DST, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_sizer_bpc_shift_flactor(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t shift = 0;
+
+ ret = copy_from_user((void *)&shift, param->property_param, sizeof(shift));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_bpc_shift_flactor: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_RAW_SIZER_BPC, 0x7, shift);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_sizer_bpc_multi_flactor(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t mult_flactor = 0;
+
+ ret = copy_from_user((void *)&mult_flactor, param->property_param, sizeof(mult_flactor));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_bpc_multi_flactor: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_RAW_SIZER_BPC, (0x7 << 4), (mult_flactor << 4));
+
+ return ret;
+}
+
+static int32_t isp_k_raw_sizer_bpc_min_diff(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t min_diff = 0;
+
+ ret = copy_from_user((void *)&min_diff, param->property_param, sizeof(min_diff));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_bpc_multi_flactor: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_RAW_SIZER_BPC, (0xFF << 8), (min_diff << 8));
+
+ return ret;
+}
+
+static int32_t isp_k_raw_sizer_hcoeff(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t coeff[64] ;
+ uint32_t i = 0 ;
+ uint32_t val = 0 ;
+
+ memset(&coeff, 0, sizeof(coeff));
+ ret = copy_from_user((void *)&coeff, param->property_param, sizeof(coeff));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_hcoeff: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ for (i = 0; i < 21; i++) {
+ val = (coeff[i * 3] & 0x1FF)
+ | ((coeff[i * 3 + 1] & 0x1FF) << 9)
+ | ((coeff[i * 3 + 2] & 0x1FF) << 18);
+ REG_WR(ISP_RAW_SIZER_HCOEFF0 + i * 4, val);
+ }
+ val = (coeff[i * 3] & 0x1FF);
+ REG_WR( ISP_RAW_SIZER_HCOEFF0 + i * 4, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_sizer_vcoeff(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t coeff[32] ;
+ uint32_t i = 0 ;
+ uint32_t val = 0 ;
+
+ memset(&coeff, 0, sizeof(coeff));
+ ret = copy_from_user((void *)&coeff, param->property_param, sizeof(coeff));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_vcoeff: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ for (i = 0; i < 10; i++) {
+ val = (coeff[i * 3] & 0x1FF)
+ | ((coeff[i * 3 + 1] & 0x1FF) << 9)
+ | ((coeff[i * 3 + 2] & 0x1FF) << 18);
+ REG_WR(ISP_RAW_SIZER_VCOEFF0 + i * 4, val);
+ }
+ val = (coeff[i * 3] & 0x1FF)
+ | ((coeff[i * 3 + 1] & 0x1FF) << 9);
+ REG_WR( ISP_RAW_SIZER_VCOEFF0 + i * 4, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_sizer_h_init_para(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_raw_sizer_init_para init_para;
+ uint32_t val = 0 ;
+
+ ret = copy_from_user((void *)&init_para, param->property_param, sizeof(init_para));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_h_init_para: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (init_para.residual_half_wd & 0xFFFF) | ((init_para.half_dst_wd_remain & 0xFFFF) << 16);
+ REG_WR(ISP_RAW_SIZER_INIT_HOR0, val);
+
+ val = (init_para.adv_a_init_residual & 0xFFFF) | ((init_para.adv_b_init_residual & 0xFFFF) << 16);
+ REG_WR(ISP_RAW_SIZER_INIT_HOR1, val);
+
+ val = (init_para.offset_base_incr & 0xFF) | ((init_para.offset_incr_init_a & 0xFF) << 8)
+ | ((init_para.offset_incr_init_b & 0xFF) << 16);
+ REG_WR( ISP_RAW_SIZER_INIT_HOR2, val);
+
+ return ret;
+}
+
+static int32_t isp_k_raw_sizer_v_init_para(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_raw_sizer_init_para init_para;
+ uint32_t val = 0 ;
+
+ ret = copy_from_user((void *)&init_para, param->property_param, sizeof(init_para));
+ if (0 != ret) {
+ printk("isp_k_raw_sizer_v_init_para: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (init_para.residual_half_wd & 0xFFFF) | ((init_para.half_dst_wd_remain & 0xFFFF) << 16);
+ REG_WR(ISP_RAW_SIZER_INIT_VER0, val);
+
+ val = (init_para.adv_a_init_residual & 0xFFFF) | ((init_para.adv_b_init_residual & 0xFFFF) << 16);
+ REG_WR(ISP_RAW_SIZER_INIT_VER1, val);
+
+ val = (init_para.offset_base_incr & 0xFF) | ((init_para.offset_incr_init_a & 0xFF) << 8)
+ | ((init_para.offset_incr_init_b & 0xFF) << 16);
+ REG_WR( ISP_RAW_SIZER_INIT_VER2, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_raw_sizer(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_raw_sizer: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_raw_sizer: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_RAW_SIZER_BYPASS:
+ ret = isp_k_raw_sizer_bypass(param);
+ break;
+ case ISP_PRO_RAW_SIZER_BPC_BYPASS:
+ ret = isp_k_raw_sizer_bpc_bypass(param);
+ break;
+ case ISP_PRO_RAW_SIZER_CROP_BYPASS:
+ ret = isp_k_raw_sizer_crop_bypass(param);
+ break;
+ case ISP_PRO_RAW_SIZER_CROP_SRC:
+ ret = isp_k_raw_sizer_crop_src_size(param);
+ break;
+ case ISP_PRO_RAW_SIZER_CROP_DST:
+ ret = isp_k_raw_sizer_crop_dest_size(param);
+ break;
+ case ISP_PRO_RAW_SIZER_CROP_START:
+ ret = isp_k_raw_sizer_crop_start(param);
+ break;
+ case ISP_PRO_RAW_SIZER_DST:
+ ret = isp_k_raw_sizer_dest_size(param);
+ break;
+ case ISP_PRO_RAW_SIZER_BPC_MULTI:
+ ret = isp_k_raw_sizer_bpc_multi_flactor(param);
+ break;
+ case ISP_PRO_RAW_SIZER_BPC_SHIFT:
+ ret = isp_k_raw_sizer_bpc_shift_flactor(param);
+ break;
+ case ISP_PRO_RAW_SIZER_BPC_MIN_DIFF:
+ ret = isp_k_raw_sizer_bpc_min_diff(param);
+ break;
+ case ISP_PRO_RAW_SIZER_HCOEFF:
+ ret = isp_k_raw_sizer_hcoeff(param);
+ break;
+ case ISP_PRO_RAW_SIZER_VCOEFF:
+ ret = isp_k_raw_sizer_vcoeff(param);
+ break;
+ case ISP_PRO_RAW_SIZER_H_INIT_PARA:
+ ret = isp_k_raw_sizer_h_init_para(param);
+ break;
+ case ISP_PRO_RAW_SIZER_V_INIT_PARA:
+ ret = isp_k_raw_sizer_v_init_para(param);
+ break;
+ default:
+ printk("isp_k_cfg_raw_sizer: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_rgb_gain.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_rgb_gain.c
new file mode 100644
index 00000000..5cc2c554
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_rgb_gain.c
@@ -0,0 +1,69 @@
+/*
+ * 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"
+
+static int32_t isp_k_rgb_gain_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_rgb_gain_info_v1 gain_info;
+
+ ret = copy_from_user((void *)&gain_info, param->property_param, sizeof(gain_info));
+ if (0 != ret) {
+ printk("isp_k_rgb_gain_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (gain_info.global_gain & 0xFFFF) << 16;
+ REG_MWR(ISP_RGBG_PARAM, 0xFFFF0000, val);
+
+ val = ((gain_info.r_gain & 0xFFFF) << 16) | (gain_info.b_gain & 0xFFFF);
+ REG_WR(ISP_RGBG_RB, val);
+ val = gain_info.g_gain & 0xFFFF;
+ REG_WR(ISP_RGBG_G, val);
+
+ REG_MWR(ISP_RGBG_PARAM, BIT_0, gain_info.bypass);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_rgb_gain(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_rgb_gain: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_rgb_gain: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_RGB_GAIN_BLOCK:
+ ret = isp_k_rgb_gain_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_rgb_gain: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_rgb_gain2.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_rgb_gain2.c
new file mode 100644
index 00000000..425ac6b1
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_rgb_gain2.c
@@ -0,0 +1,69 @@
+/*
+ * 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"
+
+static int32_t isp_k_rgb_gain2_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_rgb_gain2_info gain_info;
+
+ ret = copy_from_user((void *)&gain_info, param->property_param, sizeof(gain_info));
+ if (0 != ret) {
+ printk("isp_k_rgb_gain2_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (gain_info.r_gain & 0xFFF) << 16;
+ REG_MWR(ISP_RGBG2_PARAM, 0xFFF0000, val);
+ val = ((gain_info.b_gain & 0xFFF) << 16) | (gain_info.g_gain & 0xFFF);
+ REG_WR(ISP_RGBG2_GAIN, val);
+
+ val = ((gain_info.r_offset & 0x3FF) << 20) | ((gain_info.g_offset & 0x3FF) << 10) | (gain_info.b_offset & 0x3FF);
+ REG_WR(ISP_RGBG2_OFFSET, val);
+
+ REG_MWR(ISP_RGBG2_PARAM, BIT_0, gain_info.bypass);
+
+ return ret;
+
+}
+
+int32_t isp_k_cfg_rgb_gain2(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_rgb_gain2: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_rgb_gain2: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_RGB_GAIN2_BLOCK:
+ ret = isp_k_rgb_gain2_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_rgb_gain2: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_store.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_store.c
new file mode 100644
index 00000000..2ae73bec
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_store.c
@@ -0,0 +1,101 @@
+/*
+ * 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"
+
+static int32_t isp_k_store_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_store_info_v1 store_info;
+
+ memset(&store_info, 0x00, sizeof(store_info));
+
+ ret = copy_from_user((void *)&store_info, param->property_param, sizeof(store_info));
+ if (0 != ret) {
+ printk("isp_k_store_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (store_info.substract) {
+ REG_OWR(ISP_STORE_PARAM, BIT_1);
+ } else {
+ REG_MWR(ISP_STORE_PARAM, BIT_1, 0);
+ }
+
+ REG_MWR(ISP_STORE_PARAM, 0xF0, (store_info.color_format << 4));
+
+ REG_WR(ISP_STORE_Y_ADDR, store_info.addr.chn0);
+ REG_WR(ISP_STORE_Y_PITCH, store_info.pitch.chn0);
+ REG_WR(ISP_STORE_U_ADDR, store_info.addr.chn1);
+ REG_WR(ISP_STORE_U_PITCH, store_info.pitch.chn1);
+ REG_WR(ISP_STORE_V_ADDR, store_info.addr.chn2);
+ REG_WR(ISP_STORE_V_PITCH, store_info.pitch.chn2);
+
+ if (store_info.bypass) {
+ REG_OWR(ISP_STORE_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_STORE_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_store_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size size = {0, 0};
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(size));
+ if (0 != ret) {
+ printk("isp_k_store_slice_size: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height& 0xFFFF) << 16) | (size.width & 0xFFFF);
+ REG_WR(ISP_STORE_SLICE_SIZE, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_store(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_store: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_store: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_STORE_BLOCK:
+ ret = isp_k_store_block(param);
+ break;
+ case ISP_PRO_STORE_SLICE_SIZE:
+ ret = isp_k_store_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_store: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_y_delay.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_y_delay.c
new file mode 100644
index 00000000..b735c790
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_y_delay.c
@@ -0,0 +1,63 @@
+/*
+ * 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"
+
+static int32_t isp_k_ydelay_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_dev_ydelay_info ydelay_info;
+
+ ret = copy_from_user((void *)&ydelay_info, param->property_param, sizeof(ydelay_info));
+ if (0 != ret) {
+ printk("isp_k_ydelay_block: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ if (ydelay_info.bypass) {
+ REG_OWR(ISP_YDELAY_PARAM, BIT_0);
+ } else {
+ REG_MWR(ISP_YDELAY_PARAM, BIT_0, 0);
+ }
+
+ return ret;
+}
+
+int32_t isp_k_cfg_ydelay(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_ydelay: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_ydelay: property_param is null error.\n");
+ return -1;
+ }
+
+ switch(param->property) {
+ case ISP_PRO_YDELAY_BLOCK:
+ ret = isp_k_ydelay_block(param);
+ break;
+ default:
+ printk("isp_k_cfg_ydelay: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
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;
+}
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_yiq_aem.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_yiq_aem.c
new file mode 100755
index 00000000..eb23d899
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_yiq_aem.c
@@ -0,0 +1,256 @@
+/*
+ * 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"
+
+static int32_t isp_k_yiq_aem_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_dev_yiq_aem_info_v1 yaem_info;
+
+ memset(&yaem_info, 0x00, sizeof(yaem_info));
+
+ ret = copy_from_user((void *)&yaem_info, param->property_param, sizeof(yaem_info));
+ if (0 != ret) {
+ printk("isp_k_yiq_aem_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_YIQ_AEM_PARAM, BIT_7, yaem_info.ygamma_bypass << 7);
+
+ val = ((yaem_info.gamma_xnode[0] & 0xFF)<<24) | ((yaem_info.gamma_xnode[1] & 0xFF)<<16)
+ | ((yaem_info.gamma_xnode[2] & 0xFF)<<8) | (yaem_info.gamma_xnode[3] & 0xFF);
+ REG_WR(ISP_YIQ_YGAMMA_NODE_X0 , val);
+ val = ((yaem_info.gamma_xnode[4] & 0xFF)<<24) | ((yaem_info.gamma_xnode[5] & 0xFF)<<16)
+ | ((yaem_info.gamma_xnode[6] & 0xFF)<<8) | (yaem_info.gamma_xnode[7] & 0xFF);
+ REG_WR(ISP_YIQ_YGAMMA_NODE_X1 , val);
+
+ val = ((yaem_info.gamma_ynode[0] & 0xFF)<<24) | ((yaem_info.gamma_ynode[1] & 0xFF)<<16)
+ | ((yaem_info.gamma_ynode[2] & 0xFF)<<8) | (yaem_info.gamma_ynode[3] & 0xFF);
+ REG_WR( ISP_YIQ_YGAMMA_NODE_Y0 , val);
+ val = ((yaem_info.gamma_ynode[4] & 0xFF)<<24) | ((yaem_info.gamma_ynode[5] & 0xFF)<<16)
+ | ((yaem_info.gamma_ynode[6] & 0xFF)<<8) | (yaem_info.gamma_ynode[7] & 0xFF);
+ REG_WR(ISP_YIQ_YGAMMA_NODE_Y1 , val);
+ val = ((yaem_info.gamma_ynode[8] & 0xFF)<<24) | ((yaem_info.gamma_ynode[9] & 0xFF)<<16);
+ REG_WR(ISP_YIQ_YGAMMA_NODE_Y2 , val);
+
+ val = ((yaem_info.gamma_node_idx[1]&0x7) << 24) | ((yaem_info.gamma_node_idx[2]&0x7) << 21) |
+ ((yaem_info.gamma_node_idx[3]&0x7) << 18) | ((yaem_info.gamma_node_idx[4]&0x7) << 15) |
+ ((yaem_info.gamma_node_idx[5]&0x7) << 12) | ((yaem_info.gamma_node_idx[6]&0x7) << 9) |
+ ((yaem_info.gamma_node_idx[7]&0x7) << 6) | ((yaem_info.gamma_node_idx[8]&0x7) << 3) |
+ (yaem_info.gamma_node_idx[9]&0x7);
+ REG_WR( ISP_YIQ_YGAMMA_NODE_IDX, val);
+
+ REG_MWR(ISP_YIQ_AEM_PARAM, BIT_0, yaem_info.aem_bypass);
+
+ REG_MWR(ISP_YIQ_AEM_PARAM, BIT_1, yaem_info.aem_mode << 1);
+
+ REG_MWR(ISP_YIQ_AEM_PARAM, 0xF << 2, yaem_info.aem_skip_num << 2);
+
+ val = (yaem_info.offset_x & 0xFFFF) | ((yaem_info.offset_y & 0xFFFF) << 16);
+ REG_WR( ISP_YIQ_AEM_OFFSET, val);
+
+ val = (yaem_info.width& 0x1FF) | ((yaem_info.height& 0x1FF) << 9);
+ REG_WR( ISP_YIQ_AEM_BLK_SIZE, val);
+
+ return ret;
+
+}
+
+static int32_t isp_k_yiq_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size slice_size= {0, 0};
+
+ ret = copy_from_user((void *)&slice_size, param->property_param, sizeof(slice_size));
+ if (0 != ret) {
+ printk("isp_k_ae_skip_num: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (slice_size.width& 0xFFFF) | ((slice_size.height& 0xFFFF) << 16);
+ REG_WR( ISP_YIQ_AEM_SLICE_SIZE, val);
+
+
+ return ret;
+}
+
+static int32_t isp_k_yiq_aem_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_bypass: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_YIQ_AEM_PARAM, BIT_0, bypass);
+ return ret;
+}
+
+static int32_t isp_k_yiq_aem_ygamma_bypass(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t bypass = 0;
+
+ ret = copy_from_user((void *)&bypass, param->property_param, sizeof(bypass));
+ if (0 != ret) {
+ printk("isp_k_raw_aem_bypass: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_YIQ_AEM_PARAM, BIT_7, bypass << 7);
+ return ret;
+}
+
+static int32_t isp_k_yiq_aem_statistics(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0, i = 0;
+ uint32_t val = 0;
+ unsigned long addr = 0;
+ struct isp_aem_statistics *yiq_aem_statistics = NULL;
+
+ yiq_aem_statistics = (struct isp_aem_statistics *)isp_private->yiq_aem_buf_addr;
+ if (!yiq_aem_statistics) {
+ ret = -1;
+ printk("isp_k_yiq_aem_statistics: alloc memory error.\n");
+ return -1;
+ }
+
+ addr = ISP_YIQ_AEM_OUTPUT;
+ for (i = 0x00; i < ISP_YIQ_AEM_ITEM; i++) {
+ val = REG_RD(addr);
+ yiq_aem_statistics->val[i]= val & 0x3fffff;
+ addr += 4;
+ }
+
+ ret = copy_to_user(param->property_param, (void*)yiq_aem_statistics, sizeof(struct isp_aem_statistics));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_yiq_aem_statistics: copy error, ret=0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_yiq_aem_skip_num(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t skip_num;
+
+ ret = copy_from_user((void *)&skip_num, param->property_param, sizeof(skip_num));
+ if (0 != ret) {
+ printk("isp_k_yiq_aem_skip_num: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (skip_num & 0xF) << 2;
+ REG_MWR(ISP_YIQ_AEM_PARAM, 0x3C, val);
+
+ return ret;
+}
+
+static int32_t isp_k_yiq_aem_offset(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct img_offset offset;
+
+ ret = copy_from_user((void *)&offset, param->property_param, sizeof(struct img_offset));
+ if (0 != ret) {
+ printk("isp_k_yiq_aem_offset: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((offset.y & 0xFFFF) << 16) | (offset.x & 0xFFFF);
+ REG_WR(ISP_YIQ_AEM_OFFSET, val);
+
+ return ret;
+}
+
+static int32_t isp_k_yiq_aem_blk_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ struct isp_img_size size;
+ uint32_t val = 0;
+
+ ret = copy_from_user((void *)&size, param->property_param, sizeof(struct isp_img_size));
+ if (0 != ret) {
+ printk("isp_k_yiq_aem_blk_size: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = ((size.height & 0x1FF) << 9) | (size.width & 0x1FF);
+ REG_MWR(ISP_YIQ_AEM_BLK_SIZE, 0x3FFFF, val);
+
+ return ret;
+}
+
+int32_t isp_k_cfg_yiq_aem(struct isp_io_param *param,
+ struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_yiq: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_yiq: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_YIQ_AEM_BLOCK:
+ ret = isp_k_yiq_aem_block(param);
+ break;
+ case ISP_PRO_YIQ_AEM_YGAMMA_BYPASS:
+ ret = isp_k_yiq_aem_ygamma_bypass(param);
+ break;
+ case ISP_PRO_YIQ_AEM_BYPASS:
+ ret = isp_k_yiq_aem_bypass(param);
+ break;
+ case ISP_PRO_YIQ_AEM_STATISTICS:
+ ret = isp_k_yiq_aem_statistics(param, isp_private);
+ break;
+ case ISP_PRO_YIQ_AEM_SKIP_NUM:
+ ret = isp_k_yiq_aem_skip_num(param);
+ break;
+ case ISP_PRO_YIQ_AEM_OFFSET:
+ ret = isp_k_yiq_aem_offset(param);
+ break;
+ case ISP_PRO_YIQ_AEM_BLK_SIZE:
+ ret = isp_k_yiq_aem_blk_size(param);
+ break;
+ case ISP_PRO_YIQ_AEM_SLICE_SIZE:
+ ret = isp_k_yiq_slice_size(param);
+ break;
+ default:
+ printk("isp_k_cfg_yiq: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
+
diff --git a/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_yiq_afm.c b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_yiq_afm.c
new file mode 100755
index 00000000..aca98933
--- /dev/null
+++ b/drivers/media/sprd_isp/isp2.0/tshark2/src/isp_k_yiq_afm.c
@@ -0,0 +1,193 @@
+/*
+ * 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"
+
+#define ISP_AFM_WIN_NUM_V1 25
+
+static int32_t isp_k_yiq_afm_block(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ uint32_t i = 0;
+ int max_num = ISP_AFM_WIN_NUM_V1;
+ struct isp_dev_yiq_afm_info_v1 afm_info;
+
+ memset(&afm_info, 0x00, sizeof(afm_info));
+
+ ret = copy_from_user((void *)&afm_info, param->property_param, sizeof(afm_info));
+ if (0 != ret) {
+ printk("isp_k_yiq_afm_block: copy error, ret=0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, BIT_6, afm_info.mode << 6);
+
+ REG_MWR(ISP_COMMON_3A_CTRL0, BIT_0, afm_info.source_pos);
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, 0x1F<<1, (afm_info.shift << 1));
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, 0xF<<7, (afm_info.skip_num << 7));
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, BIT_11, afm_info.skip_num_clear << 11);
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, 0x7<<13, (afm_info.format << 13));
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, BIT_16, afm_info.iir_bypass << 16);
+
+ for (i = 0; i < max_num; i++) {
+ val = ((afm_info.coord[i].start_y <<16) & 0xffff0000)
+ | (afm_info.coord[i].start_x & 0xffff);
+ REG_WR((ISP_YIQ_AFM_WIN_RANGE0 + 4*2*i), val);
+
+ val = ((afm_info.coord[i].end_y <<16) & 0xffff0000)
+ | (afm_info.coord[i].end_x & 0xffff);
+ REG_WR((ISP_YIQ_AFM_WIN_RANGE0 + 4*(2*i+1)), val);
+ }
+
+ for (i = 0; i < 10; i+= 2) {
+ val = (afm_info.IIR_c[i] & 0xFFF) | ((afm_info.IIR_c[i + 1] & 0xFFF) << 16);
+ REG_WR(ISP_YIQ_AFM_COEF0_1 + (i / 2) * 4, val);
+ }
+ val = afm_info.IIR_c[10] & 0xFFF;
+ REG_WR(ISP_YIQ_AFM_COEF10, val);
+
+ REG_MWR(ISP_YIQ_AFM_PARAM, BIT_0, afm_info.bypass);
+
+ return ret;
+
+}
+
+static int32_t isp_k_yiq_afm_statistic(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ int i = 0;
+ int max_item = ISP_AFM_WIN_NUM_V1*4;
+ struct isp_yiq_afm_statistic item;
+
+ memset(&item, 0, sizeof(struct isp_yiq_afm_statistic));
+ for (i = 0; i < max_item; i++) {
+ item.val[i] = REG_RD((ISP_YIQ_AFM_LAPLACE0 + 4*i));
+ }
+ ret = copy_to_user(param->property_param, (void*)&item, sizeof(item));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_yiq_afm_statistic: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_yiq_afm_slice_size(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t val = 0;
+ struct isp_img_size slice_size= {0, 0};
+
+ ret = copy_from_user((void *)&slice_size, param->property_param, sizeof(slice_size));
+ if (0 != ret) {
+ printk("isp_k_ae_skip_num: copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ val = (slice_size.width& 0xFFFF) | ((slice_size.height& 0xFFFF) << 16);
+ REG_WR( ISP_YIQ_AFM_SLICE_SIZE, val);
+
+
+ return ret;
+}
+
+static int32_t isp_k_yiq_afm_win(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ int i = 0;
+ int max_num = ISP_AFM_WIN_NUM_V1;
+ struct isp_coord coord[ISP_AFM_WIN_NUM_V1];
+ uint32_t val = 0;
+
+
+ memset(coord, 0, sizeof(coord));
+ ret = copy_from_user((void *)&coord, param->property_param, sizeof(coord));
+ if (0 != ret) {
+ printk("isp_k_yiq_afm_win: read copy_from_user error, ret = 0x%x\n", (uint32_t)ret);
+ return -1;
+ }
+
+ for (i = 0; i < max_num; i++) {
+ val = ((coord[i].start_y <<16) & 0xffff0000)
+ | (coord[i].start_x & 0xffff);
+ REG_WR((ISP_YIQ_AFM_WIN_RANGE0 + 4*2*i), val);
+
+ val = ((coord[i].end_y <<16) & 0xffff0000)
+ | (coord[i].end_x & 0xffff);
+ REG_WR((ISP_YIQ_AFM_WIN_RANGE0 + 4*(2*i+1)), val);
+ }
+
+ return ret;
+}
+
+static int32_t isp_k_yiq_afm_win_num(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+ uint32_t num = ISP_AFM_WIN_NUM_V1;
+
+ ret = copy_to_user(param->property_param, (void*)&num, sizeof(num));
+ if (0 != ret) {
+ ret = -1;
+ printk("isp_k_yiq_afm_win_num: copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ }
+
+ return ret;
+}
+
+
+int32_t isp_k_cfg_yiq_afm(struct isp_io_param *param)
+{
+ int32_t ret = 0;
+
+ if (!param) {
+ printk("isp_k_cfg_afm: param is null error.\n");
+ return -1;
+ }
+
+ if (NULL == param->property_param) {
+ printk("isp_k_cfg_afm: property_param is null error.\n");
+ return -1;
+ }
+
+ switch (param->property) {
+ case ISP_PRO_YIQ_AFM_BLOCK:
+ ret = isp_k_yiq_afm_block(param);
+ break;
+ case ISP_PRO_YIQ_AFM_SLICE_SIZE:
+ ret = isp_k_yiq_afm_slice_size(param);
+ break;
+ case ISP_PRO_YIQ_AFM_STATISTIC:
+ ret = isp_k_yiq_afm_statistic(param);
+ break;
+ case ISP_PRO_YIQ_AFM_WIN_NUM:
+ ret = isp_k_yiq_afm_win_num(param);
+ break;
+ case ISP_PRO_YIQ_AFM_WIN:
+ ret = isp_k_yiq_afm_win(param);
+ break;
+ default:
+ printk("isp_k_cfg_yiq_afm: fail cmd id:%d, not supported.\n", param->property);
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/media/sprd_isp/isp_drv.c b/drivers/media/sprd_isp/isp_drv.c
new file mode 100644
index 00000000..f2d567ce
--- /dev/null
+++ b/drivers/media/sprd_isp/isp_drv.c
@@ -0,0 +1,1800 @@
+/*
+ * 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/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/poll.h>
+#include <linux/mm.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/miscdevice.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/vmalloc.h>
+//#include <mach/sci.h>
+#include <soc/sprd/sci.h>
+//#include <mach/hardware.h>
+#ifndef CONFIG_64BIT
+#include <soc/sprd/hardware.h>
+#endif
+#include <asm/cacheflush.h>
+#include <video/sprd_isp.h>
+#include "parse_hwinfo.h"
+#include "compat_isp_drv.h"
+#include "isp_drv.h"
+#include "isp_reg.h"
+
+#define ISP_MINOR MISC_DYNAMIC_MINOR
+
+static struct isp_k_private *s_isp_private;
+
+static int isp_wr_addr(struct isp_reg_bits *ptr);
+
+static int32_t isp_block_buf_alloc(struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ uint32_t buf_len = 0;
+
+ buf_len = ISP_REG_BUF_SIZE + ISP_RAW_AE_BUF_SIZE + ISP_FRGB_GAMMA_BUF_SIZE + ISP_YUV_YGAMMA_BUF_SIZE + ISP_RAW_AWB_BUF_SIZE + ISP_YIQ_AEM_BUF_SIZE;
+
+ isp_private->block_buf_addr = (unsigned long)vzalloc(buf_len);
+ if (0 == isp_private->block_buf_addr) {
+ ret = -1;
+ printk("isp_block_buf_alloc: no memory error.\n");
+ } else {
+ isp_private->block_buf_len = buf_len;
+ isp_private->reg_buf_addr = isp_private->block_buf_addr;
+ isp_private->reg_buf_len = ISP_REG_BUF_SIZE;
+ isp_private->raw_aem_buf_addr = isp_private->reg_buf_addr + isp_private->reg_buf_len;
+ isp_private->raw_aem_buf_len = ISP_RAW_AE_BUF_SIZE;
+ isp_private->full_gamma_buf_addr = isp_private->raw_aem_buf_addr + isp_private->raw_aem_buf_len;
+ isp_private->full_gamma_buf_len = ISP_FRGB_GAMMA_BUF_SIZE;
+ isp_private->yuv_ygamma_buf_addr = isp_private->full_gamma_buf_addr + isp_private->full_gamma_buf_len;
+ isp_private->yuv_ygamma_buf_len = ISP_YUV_YGAMMA_BUF_SIZE;
+ isp_private->raw_awbm_buf_addr = isp_private->yuv_ygamma_buf_addr + isp_private->yuv_ygamma_buf_len;
+ isp_private->raw_awbm_buf_len = ISP_RAW_AWB_BUF_SIZE;
+ isp_private->yiq_aem_buf_addr = isp_private->raw_awbm_buf_addr + isp_private->raw_awbm_buf_len;
+ isp_private->yiq_aem_buf_len = ISP_YIQ_AEM_BUF_SIZE;
+ }
+
+ return ret;
+}
+
+static int32_t isp_block_buf_free(struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if ((0x00 != isp_private->block_buf_addr)
+ && (0x00 != isp_private->block_buf_len)) {
+ vfree((void *)isp_private->block_buf_addr);
+ isp_private->block_buf_addr = 0x00;
+ isp_private->block_buf_len = 0x00;
+ isp_private->reg_buf_addr = 0x00;
+ isp_private->reg_buf_len = 0x00;
+ isp_private->raw_aem_buf_addr = 0x00;
+ isp_private->raw_aem_buf_len = 0x00;
+ isp_private->full_gamma_buf_addr = 0x00;
+ isp_private->full_gamma_buf_len = 0x00;
+ isp_private->yuv_ygamma_buf_addr = 0x00;
+ isp_private->yuv_ygamma_buf_len = 0x00;
+ isp_private->raw_awbm_buf_addr = 0x00;
+ isp_private->raw_awbm_buf_len = 0x00;
+ }
+
+ return ret;
+}
+
+static int32_t isp_yiq_antiflicker_buf_free(struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+
+ if ((0x00 != isp_private->yiq_antiflicker_buf_addr)
+ && (0x00 != isp_private->yiq_antiflicker_order)) {
+ free_pages(isp_private->yiq_antiflicker_buf_addr, isp_private->yiq_antiflicker_order);
+ isp_private->yiq_antiflicker_buf_addr = 0x00;
+ isp_private->yiq_antiflicker_len = 0x00;
+ isp_private->yiq_antiflicker_order = 0x00;
+ }
+
+ return ret;
+
+}
+
+static int32_t isp_yiq_antiflicker_buf_alloc(struct isp_k_private *isp_private, uint32_t len)
+{
+ int32_t ret = 0x00;
+#ifndef CONFIG_64BIT
+ uint32_t buf = 0x00;
+ void *ptr = NULL;
+#endif
+
+ if (0x00 < len) {
+ isp_private->yiq_antiflicker_len = len;
+ isp_private->yiq_antiflicker_order = get_order(len);
+ isp_private->yiq_antiflicker_buf_addr = (unsigned long)__get_free_pages(GFP_KERNEL | __GFP_COMP, isp_private->yiq_antiflicker_order);
+ if (NULL == (void*)isp_private->yiq_antiflicker_buf_addr) {
+ printk("isp_yiq_antiflicker_buf_alloc: memory error, addr:0x%lx, len:0x%x, order:0x%x.\n",
+ isp_private->yiq_antiflicker_buf_addr,
+ isp_private->yiq_antiflicker_len,
+ isp_private->yiq_antiflicker_order);
+ return -1;
+ }
+#ifndef CONFIG_64BIT
+ ptr = (void*)isp_private->yiq_antiflicker_buf_addr;
+ buf = virt_to_phys((volatile void *)isp_private->yiq_antiflicker_buf_addr);
+
+ dmac_flush_range(ptr, ptr + len);
+ outer_flush_range(__pa(ptr), __pa(ptr) + len);
+#endif
+ }
+
+ return ret;
+
+}
+
+static int32_t isp_b4awb_switch_buf(struct isp_k_private *isp_private)
+{
+ int32_t ret = 0;
+ int32_t i = 0;
+
+ /*first bypass b4awb*/
+ REG_MWR(ISP_BINNING_PARAM, BIT_0, 0x1);
+
+ /*switch buf*/
+ if (isp_private->b4awb_buf[0].buf_flag == 1) {
+ isp_private->b4awb_buf[1].buf_flag = 1;
+ REG_WR(ISP_BINNING_MEM_ADDR, isp_private->b4awb_buf[1].buf_phys_addr);
+ isp_private->b4awb_buf[0].buf_flag = 0;
+ } else if (isp_private->b4awb_buf[1].buf_flag == 1) {
+ isp_private->b4awb_buf[0].buf_flag = 1;
+ REG_WR(ISP_BINNING_MEM_ADDR, isp_private->b4awb_buf[0].buf_phys_addr);
+ isp_private->b4awb_buf[1].buf_flag = 0;
+ }
+
+ /*enable b4awb*/
+ REG_MWR(ISP_BINNING_PARAM, BIT_0, 0x0);
+
+ return ret;
+}
+
+static void isp_read_reg(struct isp_reg_bits *reg_bits_ptr, uint32_t counts)
+{
+ uint32_t i = 0;
+ unsigned long reg_val = 0, reg_addr = 0;
+
+ for (i = 0; i < counts; i++) {
+ reg_addr = ISP_BASE_ADDR + reg_bits_ptr[i].reg_addr;
+ reg_val = REG_RD(reg_addr);
+ reg_bits_ptr[i].reg_value = reg_val;
+ }
+}
+
+static void isp_write_reg(struct isp_reg_bits *reg_bits_ptr, uint32_t counts)
+{
+ uint32_t i = 0;
+ unsigned long reg_val = 0, reg_addr = 0;
+
+ for (i = 0; i < counts; i++) {
+ reg_addr = reg_bits_ptr[i].reg_addr + ISP_BASE_ADDR;
+ reg_val = reg_bits_ptr[i].reg_value;
+ REG_WR(reg_addr, reg_val);
+ }
+}
+
+static int32_t isp_queue_init(struct isp_queue *queue)
+{
+ if (NULL == queue) {
+ printk("isp_queue_init: queue is null error.\n");
+ return -1;
+ }
+
+ memset(queue, 0x00, sizeof(*queue));
+ queue->write = &queue->node[0];
+ queue->read = &queue->node[0];
+
+ return 0;
+}
+
+static int32_t isp_queue_write(struct isp_queue *queue, struct isp_node *node)
+{
+ struct isp_node *ori_node = NULL;
+
+ if (NULL == queue || NULL == node) {
+ printk("isp_queue_write: queue or node is null error %p %p\n",
+ queue, node);
+ return -1;
+ }
+
+ ori_node = queue->write;
+
+ *queue->write++ = *node;
+ if (queue->write > &queue->node[ISP_QUEUE_LENGTH-1])
+ queue->write = &queue->node[0];
+
+ if (queue->write == queue->read)
+ queue->write = ori_node;
+
+ return 0;
+}
+
+static int32_t isp_queue_read(struct isp_queue *queue, struct isp_node *node)
+{
+ if (NULL == queue || NULL == node) {
+ printk("isp_queue_read: queue or node is null error %p %p\n",
+ queue, node);
+ return -1;
+ }
+
+ if (queue->read != queue->write) {
+ *node = *queue->read++;
+ if (queue->read > &queue->node[ISP_QUEUE_LENGTH-1])
+ queue->read = &queue->node[0];
+ }
+
+ return 0;
+}
+
+static int32_t isp_set_clk(struct isp_k_file *file, enum isp_clk_sel clk_sel)
+{
+ int32_t ret = 0;
+ char *parent = "clk_256m";
+ struct clk *clk_parent = NULL;
+ struct isp_k_private *isp_private = NULL;
+
+ if (!file) {
+ printk("isp_set_clk: file is null error.\n");
+ return -1;
+ }
+
+ isp_private = file->isp_private;
+ if (!isp_private) {
+ printk("isp_set_clk: isp_private is null error.\n");
+ return -1;
+ }
+
+ switch (clk_sel) {
+ case ISP_CLK_480M:
+ parent = "clk_usbpll";
+ break;
+ case ISP_CLK_384M:
+ parent = "clk_384m";
+ break;
+ case ISP_CLK_312M:
+ parent = "clk_312m";
+ break;
+ case ISP_CLK_256M:
+ parent = "clk_256m";
+ break;
+ case ISP_CLK_128M:
+ parent = "clk_128m";
+ break;
+ case ISP_CLK_48M:
+ parent = "clk_48m";
+ break;
+ case ISP_CLK_76M8:
+ parent = "clk_76p8m";
+ break;
+ case ISP_CLK_NONE:
+ printk("isp_set_clk: close clock %d\n", (int)clk_get_rate(isp_private->clock));
+ if (isp_private->clock) {
+ clk_disable(isp_private->clock);
+ clk_put(isp_private->clock);
+ isp_private->clock = NULL;
+ }
+ return 0;
+ default:
+ parent = "clk_128m";
+ break;
+ }
+
+ if (NULL == isp_private->clock) {
+ isp_private->clock = parse_clk(isp_private->dn, "clk_isp");
+ if (IS_ERR(isp_private->clock)) {
+ printk("isp_set_clk: parse_clk error.\n");
+ return -1;
+ }
+ } else {
+ clk_disable(isp_private->clock);
+ }
+
+ clk_parent = clk_get(NULL, parent);
+ if (IS_ERR(clk_parent)) {
+ printk("isp_set_clk: clk_get error %d\n", (int)clk_parent);
+ return -1;
+ }
+
+ ret = clk_set_parent(isp_private->clock, clk_parent);
+ if(ret){
+ printk("isp_set_clk: clk_set_parent error.\n");
+ }
+
+ ret = clk_enable(isp_private->clock);
+ if (ret) {
+ printk("isp_set_clk: clk_enable error.\n");
+ return -1;
+ }
+
+ return ret;
+}
+
+static int32_t isp_module_rst(struct isp_k_file *file)
+{
+ int32_t ret = 0;
+ struct isp_k_private *isp_private = NULL;
+
+ if (!file) {
+ printk("isp_module_rst: file is null error.\n");
+ return -1;
+ }
+
+ isp_private = file->isp_private;
+ if (!isp_private) {
+ printk("isp_module_rst: isp_private is null error.\n");
+ return -1;
+ }
+
+ if (0x00 != atomic_read(&isp_private->users)) {
+ ret = isp_axi_bus_waiting();
+
+ isp_clr_int();
+
+ sci_glb_set(ISP_MODULE_RESET, ISP_RST_LOG_BIT);
+ sci_glb_set(ISP_MODULE_RESET, ISP_RST_CFG_BIT);
+ sci_glb_set(ISP_MODULE_RESET, ISP_RST_LOG_BIT);
+ sci_glb_set(ISP_MODULE_RESET, ISP_RST_CFG_BIT);
+ sci_glb_set(ISP_MODULE_RESET, ISP_RST_LOG_BIT);
+ sci_glb_set(ISP_MODULE_RESET, ISP_RST_CFG_BIT);
+
+ sci_glb_clr(ISP_MODULE_RESET, ISP_RST_CFG_BIT);
+ sci_glb_clr(ISP_MODULE_RESET, ISP_RST_LOG_BIT);
+ }
+
+ return ret;
+}
+
+static int32_t isp_module_eb(struct isp_k_file *file)
+{
+ int32_t ret = 0;
+ struct isp_k_private *isp_private = NULL;
+
+ if (!file) {
+ printk("isp_module_eb: file is null error.\n");
+ return -1;
+ }
+
+ isp_private = file->isp_private;
+ if (!isp_private) {
+ printk("isp_module_eb: isp_private is null error.\n");
+ return -1;
+ }
+
+ if (0x01 == atomic_inc_return(&isp_private->users)) {
+
+ ret = clk_mm_i_eb(isp_private->dn, 1);
+ if (unlikely(0 != ret)) {
+ ret = -1;
+ printk("isp_module_eb: clk_mm_i_eb error.\n");
+ }
+
+ #if defined(CONFIG_MACH_SP7720EA)
+ ret = isp_set_clk(file, ISP_CLK_256M);
+ #elif defined(CONFIG_ARCH_SCX35LT8)
+ ret = isp_set_clk(file, ISP_CLK_480M);
+ #else
+ ret = isp_set_clk(file, ISP_CLK_312M);
+ #endif
+ if (unlikely(0 != ret)) {
+ ret = -1;
+ printk("isp_module_eb: isp_set_clk error.\n");
+ }
+ }
+
+ return ret;
+}
+
+static int32_t isp_module_dis(struct isp_k_file *file)
+{
+ int32_t ret = 0;
+ struct isp_k_private *isp_private = NULL;
+
+ if (!file) {
+ printk("isp_module_dis: file is null error.\n");
+ return -1;
+ }
+
+ isp_private = file->isp_private;
+ if (!isp_private) {
+ printk("isp_module_dis: isp_private is null error.\n");
+ return -1;
+ }
+
+ if (0x00 == atomic_dec_return(&isp_private->users)) {
+
+ ret = isp_set_clk(file, ISP_CLK_NONE);
+ if (unlikely(0 != ret)) {
+ ret = -1;
+ printk("isp_module_dis: isp_set_clk error.\n");
+ }
+
+ ret = clk_mm_i_eb(isp_private->dn, 0);
+ if (unlikely(0 != ret)) {
+ ret = -1;
+ printk("isp_module_dis: close clk_mm_i error.\n");
+ }
+ }
+
+ return ret;
+}
+
+static irqreturn_t isp_isr(int irq, void *dev_id)
+{
+ int32_t ret = 0;
+ unsigned long flag = 0;
+ uint32_t val = 0;
+ struct isp_node node;
+ struct isp_k_file *fd = NULL;
+ struct isp_drv_private *drv_private = NULL;
+ struct timespec ts;
+
+ if (!dev_id) {
+ printk("isp_isr: dev_id is null error.\n");
+ return IRQ_NONE;
+ }
+
+ fd = (struct isp_k_file *)dev_id;
+ drv_private = (struct isp_drv_private *)&fd->drv_private;
+
+ if (!drv_private) {
+ printk("isp_isr: drv_private is null error.\n");
+ return IRQ_NONE;
+ }
+
+ spin_lock_irqsave(&drv_private->isr_lock, flag);
+ memset(&node, 0x00, sizeof(node));
+ ret = isp_get_int_num(&node);
+
+ /*B4AWB INT*/
+ /*if (node.irq_val1 & BIT_18) {
+ isp_b4awb_switch_buf(fd->isp_private);
+ }*/
+
+ ktime_get_ts(&ts);
+ node.time.sec = ts.tv_sec;
+ node.time.usec = ts.tv_nsec / NSEC_PER_USEC;
+ isp_queue_write((struct isp_queue *)&drv_private->queue, (struct isp_node *)&node);
+ spin_unlock_irqrestore(&drv_private->isr_lock, flag);
+
+ up(&drv_private->isr_done_lock);
+
+ if (ret) {
+ return IRQ_NONE;
+ } else {
+ return IRQ_HANDLED;
+ }
+}
+
+static int32_t isp_register_irq(struct isp_k_file *file)
+{
+ int32_t ret = 0;
+
+ ret = request_irq(ISP_IRQ, isp_isr, IRQF_SHARED, "ISP", (void *)file);
+
+ return ret;
+}
+
+static void isp_unregister_irq(struct isp_k_file *file)
+{
+ free_irq (ISP_IRQ, (void *)file);
+}
+
+static int isp_open (struct inode *node, struct file *file)
+{
+ int ret = 0;
+ struct isp_k_private *isp_private = s_isp_private;//platform_get_drvdata(rot_get_platform_device())
+ struct isp_k_file *fd = NULL;
+
+ if (!file) {
+ ret = -EINVAL;
+ printk("isp_open: file is null error.\n");
+ return ret;
+ }
+
+ if (!isp_private) {
+ ret = -EFAULT;
+ printk("isp_open: isp_private is null, error.\n");
+ return ret;
+ }
+
+ down(&isp_private->device_lock);
+
+ fd = vzalloc(sizeof(*fd));
+ if (!fd) {
+ ret = -ENOMEM;
+ up(&isp_private->device_lock);
+ printk("isp_open: no memory for fd, error.\n");
+ return ret;
+ }
+
+ fd->isp_private = isp_private;
+
+ spin_lock_init(&fd->drv_private.isr_lock);
+ sema_init(&fd->drv_private.isr_done_lock, 0);
+ ret = isp_queue_init(&(fd->drv_private.queue));
+ if (unlikely(0 != ret)) {
+ ret = -EFAULT;
+ vfree(fd);
+ up(&isp_private->device_lock);
+ printk("isp_open: isp_queue_init error.\n");
+ return ret;
+ }
+
+ ret = isp_module_eb(fd);
+ if (unlikely(0 != ret)) {
+ ret = -EIO;
+ printk("isp_open: isp_module_eb error.\n");
+ goto open_exit;
+ }
+
+ ret = isp_module_rst(fd);
+ if (unlikely(0 != ret)) {
+ ret = -EIO;
+ isp_module_dis(fd);
+ printk("isp_open: isp_module_rst error.\n");
+ goto open_exit;
+ }
+
+ ret = isp_register_irq(fd);
+ if (unlikely(0 != ret)) {
+ ret = -EIO;
+ isp_module_dis(fd);
+ printk("isp_open: isp_register_irq error.\n");
+ goto open_exit;
+ }
+
+ file->private_data = fd;
+
+ printk("isp_open: success.\n");
+
+ return ret;
+
+open_exit:
+ vfree(fd);
+ fd = NULL;
+
+ file->private_data = NULL;
+
+ up(&isp_private->device_lock);
+
+ return ret;
+}
+
+static int isp_release (struct inode *node, struct file *file)
+{
+ int ret = 0;
+ struct isp_k_private *isp_private = NULL;
+ struct isp_k_file *fd = NULL;
+
+ if (!file) {
+ ret = -EINVAL;
+ printk("isp_release: file is null error.\n");
+ return ret;
+ }
+
+ fd = file->private_data;
+ if (!fd) {
+ ret = -EFAULT;
+ printk("isp_release: fd is null error.\n");
+ return ret;
+ }
+
+ isp_private = fd->isp_private;
+ if (!isp_private) {
+ printk("isp_release: isp_private is null error.\n");
+ goto fd_free;
+ }
+
+ down(&isp_private->ioctl_lock);
+
+ isp_unregister_irq(fd);
+
+ ret = isp_module_dis(fd);
+
+ up(&isp_private->ioctl_lock);
+
+fd_free:
+ vfree(fd);
+ fd = NULL;
+
+ file->private_data = NULL;
+
+ if (isp_private)
+ up(&isp_private->device_lock);
+
+ printk("isp_release: success.\n");
+
+ return 0;
+}
+
+static long isp_ioctl( struct file *file, unsigned int cmd, unsigned long param)
+{
+ long ret = 0;
+ struct isp_irq irq_param;
+ struct isp_node node;
+ struct isp_reg_param reg_param = {0, 0};
+ struct isp_reg_bits *reg_bits_ptr = NULL;
+ struct isp_k_private *isp_private = NULL;
+ struct isp_drv_private *drv_private = NULL;
+ struct isp_k_file *fd = NULL;
+
+ if (!file) {
+ ret = -EINVAL;
+ printk("isp_ioctl: file is null error.\n");
+ return ret;
+ }
+
+ fd = file->private_data;
+ if (!fd) {
+ ret = - EFAULT;
+ printk("isp_ioctl: private_data is null error.\n");
+ return ret;
+ }
+
+ isp_private = fd->isp_private;
+ if (!isp_private) {
+ ret = -EFAULT;
+ printk("isp_ioctl: isp_private is null error.\n");
+ return ret;
+ }
+
+ drv_private = &fd->drv_private;
+
+ switch (cmd) {
+ case ISP_IO_IRQ:
+ {
+ ret = down_interruptible(&fd->drv_private.isr_done_lock);
+ if (ret) {
+ memset(&irq_param, 0, sizeof(irq_param));
+ irq_param.ret_val = ret;
+ ret = copy_to_user ((void *)param, (void *)&irq_param, sizeof(irq_param));
+ if ( 0 != ret) {
+ printk("isp_ioctl: irq: copy_to_user error ret = %d\n", (uint32_t)ret);
+ }
+ ret = -ERESTARTSYS;
+ return ret;
+ }
+
+ ret = isp_queue_read(&drv_private->queue, &node);
+ if (0 != ret) {
+ ret = -EFAULT;
+ printk("isp_ioctl: isp_queue_read error, ret = 0x%x\n", (uint32_t)ret);
+ return ret;
+ }
+
+ memset(&irq_param, 0, sizeof(irq_param));
+ irq_param.irq_val0 = node.irq_val0;
+ irq_param.irq_val1 = node.irq_val1;
+ irq_param.irq_val2 = node.irq_val2;
+ irq_param.irq_val3 = node.irq_val3;
+ irq_param.reserved = node.reserved;
+ irq_param.time = node.time;
+ ret = copy_to_user ((void *)param, (void *)&irq_param, sizeof(irq_param));
+ if (0 != ret) {
+ ret = -EFAULT;
+ printk("isp_k: ioctl irq: copy_to_user error, ret = 0x%x", (uint32_t)ret);
+ }
+ break;
+ }
+
+ case ISP_IO_READ:
+ {
+ uint32_t buf_size = 0;
+
+ down(&isp_private->ioctl_lock);
+
+ ret = copy_from_user((void *)&reg_param, (void *)param, sizeof(struct isp_reg_param));
+ if ( 0 != ret) {
+ ret = -EFAULT;
+ printk("isp_ioctl: read copy_from_user 0 error, ret = 0x%x\n", (uint32_t)ret);
+ goto io_read_exit;
+ }
+
+ buf_size = reg_param.counts * sizeof(struct isp_reg_bits);
+ if (buf_size > isp_private->reg_buf_len) {
+ ret = -EFAULT;
+ printk("isp_ioctl: read buf len error.\n");
+ goto io_read_exit;
+ }
+
+ reg_bits_ptr = (struct isp_reg_bits *)isp_private->reg_buf_addr;
+ ret = copy_from_user((void *)reg_bits_ptr, (void *)reg_param.reg_param, buf_size);
+ if ( 0 != ret) {
+ ret = -EFAULT;
+ printk("isp_ioctl: read copy_from_user 1 error, ret = 0x%x\n", (uint32_t)ret);
+ goto io_read_exit;
+ }
+
+ isp_read_reg(reg_bits_ptr, reg_param.counts);
+
+ ret = copy_to_user((void *)reg_param.reg_param, (void *)reg_bits_ptr, buf_size);
+ if ( 0 != ret) {
+ ret = -EFAULT;
+ printk("isp_ioctl: read copy_to_user error, ret = 0x%x\n", (uint32_t)ret);
+ goto io_read_exit;
+ }
+
+ io_read_exit:
+ if (reg_bits_ptr) {
+ memset((void *)isp_private->reg_buf_addr, 0x00, buf_size);
+ reg_bits_ptr = NULL;
+ }
+
+ up(&isp_private->ioctl_lock);
+
+ break;
+ }
+
+ case ISP_IO_WRITE:
+ {
+ uint32_t buf_size = 0;
+
+ down(&isp_private->ioctl_lock);
+
+ ret = copy_from_user((void *)&reg_param, (void *)param, sizeof(struct isp_reg_param));
+ if ( 0 != ret) {
+ printk("isp_ioctl: write copy_from_user 0 error, ret = 0x%x\n", (uint32_t)ret);
+ ret = -EFAULT;
+ goto io_write_exit;
+ }
+
+ buf_size = reg_param.counts * sizeof(struct isp_reg_bits);
+ if (buf_size > isp_private->reg_buf_len) {
+ ret = -EFAULT;
+ printk("isp_ioctl: write buf len error.\n");
+ goto io_write_exit;
+ }
+
+ reg_bits_ptr = (struct isp_reg_bits *)isp_private->reg_buf_addr;
+ ret = copy_from_user((void *)reg_bits_ptr, (void *)reg_param.reg_param, buf_size);
+ if ( 0 != ret) {
+ ret = -EFAULT;
+ printk("isp_ioctl: write copy_from_user 1 error, ret = 0x%x\n", (uint32_t)ret);
+ goto io_write_exit;
+ }
+
+ isp_write_reg(reg_bits_ptr, reg_param.counts);
+
+ io_write_exit:
+ if (reg_bits_ptr) {
+ memset((void *)isp_private->reg_buf_addr, 0x00, buf_size);
+ reg_bits_ptr = NULL;
+ }
+
+ up(&isp_private->ioctl_lock);
+
+ break;
+ }
+
+ case ISP_IO_RST:
+ {
+ down(&isp_private->ioctl_lock);
+
+ ret = isp_module_rst(fd);
+ if (ret) {
+ ret = -EFAULT;
+ printk("isp_ioctl: restet error.\n");
+ }
+
+ up(&isp_private->ioctl_lock);
+
+ break;
+ }
+
+ case ISP_IO_STOP:
+ {
+ unsigned long flag = 0;
+ struct isp_node node;
+
+ down(&isp_private->ioctl_lock);
+
+ isp_en_irq(ISP_INT_CLEAR_MODE);
+
+ spin_lock_irqsave(&drv_private->isr_lock,flag);
+ memset(&node, 0x00, sizeof(node));
+ node.reserved = ISP_INT_EVT_STOP;
+ isp_queue_write((struct isp_queue *)&drv_private->queue, (struct isp_node *)&node);
+ spin_unlock_irqrestore(&drv_private->isr_lock, flag);
+
+ up(&fd->drv_private.isr_done_lock);
+
+ up(&isp_private->ioctl_lock);
+
+ break;
+ }
+
+ case ISP_IO_INT:
+ {
+ struct isp_interrupt int_param;
+
+ down(&isp_private->ioctl_lock);
+
+ ret = copy_from_user((void *)&int_param, (void *)param, sizeof(int_param));
+ if (ret) {
+ ret = -EFAULT;
+ printk("isp_ioctl: int copy_from_user error, ret = %d\n", (uint32_t)ret);
+ }
+
+ if (0 == ret)
+ isp_en_irq(int_param.int_mode);
+
+ up(&isp_private->ioctl_lock);
+
+ break;
+ }
+
+ case ISP_IO_CFG_PARAM:
+ down(&isp_private->ioctl_lock);
+ ret = isp_cfg_param((void *)param, isp_private);
+ up(&isp_private->ioctl_lock);
+ break;
+
+ case ISP_IO_CAPABILITY:
+ ret = isp_capability((void *)param);
+ break;
+
+ case ISP_REG_READ:
+ {
+ int ret;
+ int num;
+ int i;
+ int ISP_REG_NUM = 20467;
+
+ struct isp_reg_bits *ptr = (struct isp_reg_bits *)vmalloc(ISP_REG_NUM * sizeof(struct isp_reg_bits));
+
+ if (NULL == ptr) {
+ printk("isp_ioctl:REG_READ: kmalloc error\n");
+ return -ENOMEM;
+ }
+ memset(ptr, 0, ISP_REG_NUM * sizeof(struct isp_reg_bits));
+
+ num = isp_wr_addr(ptr);
+
+ isp_read_reg(ptr, num);
+
+ ret = copy_to_user((void *)param, (void *)ptr, ISP_REG_NUM * sizeof(struct isp_reg_bits));
+ if ( 0 != ret) {
+ printk("isp_ioctl: REG_READ: copy_to_user error ret = %d\n", (uint32_t)ret);
+ vfree(ptr);
+ return ret;
+ }
+ vfree(ptr);
+ break;
+ }
+
+ default:
+ printk("isp_ioctl: cmd is unsupported, cmd = %x\n", (int32_t)cmd);
+ return -EFAULT;
+ }
+
+ return ret;
+}
+
+static struct file_operations isp_fops = {
+ .owner = THIS_MODULE,
+ .open = isp_open,
+ .unlocked_ioctl = isp_ioctl,
+ .compat_ioctl = compat_isp_ioctl,
+ .release = isp_release,
+};
+
+static struct miscdevice isp_dev = {
+ .minor = ISP_MINOR,
+ .name = "sprd_isp",
+ .fops = &isp_fops,
+};
+
+static int isp_probe(struct platform_device *pdev)
+{
+ int ret = 0;
+ struct isp_k_private *isp_private = NULL;
+
+ isp_private = devm_kzalloc(&pdev->dev, sizeof(*isp_private), GFP_KERNEL);
+ if (!isp_private) {
+ printk("isp_probe: isp_private is null error.\n");
+ return -ENOMEM;
+ }
+
+ atomic_set(&isp_private->users, 0);
+ isp_private->dn = pdev->dev.of_node;
+ isp_private->clock = NULL;
+ sema_init(&isp_private->device_lock, 1);
+ sema_init(&isp_private->ioctl_lock, 1);
+ ret = isp_block_buf_alloc(isp_private);
+ if (ret) {
+ ret = -ENOMEM;
+ devm_kfree(&pdev->dev, isp_private);
+ printk("isp_probe: no memory for isp_private, error.\n");
+ return ret;
+ }
+
+ platform_set_drvdata(pdev, isp_private);
+
+ s_isp_private = isp_private;
+
+ ret = isp_yiq_antiflicker_buf_alloc(isp_private, ISP_YIQ_ANTIFLICKER_SIZE);
+ if (ret) {
+ ret = -ENOMEM;
+ isp_block_buf_free(isp_private);
+ devm_kfree(&pdev->dev, isp_private);
+ platform_set_drvdata(pdev, NULL);
+ printk("isp_probe: no memory for isp lsc buf alloc, error.\n");
+ return ret;
+ }
+
+ ret = misc_register(&isp_dev);
+ if (ret) {
+ ret = -EACCES;
+ isp_yiq_antiflicker_buf_free(isp_private);
+ isp_block_buf_free(isp_private);
+ devm_kfree(&pdev->dev, isp_private);
+ platform_set_drvdata(pdev, NULL);
+ printk("isp_probe: misc_register error.\n");
+ }
+
+ parse_baseaddress(pdev->dev.of_node);
+ printk("isp_probe: success.\n");
+
+ return ret;
+}
+
+static int isp_remove(struct platform_device *dev)
+{
+ struct isp_k_private *isp_private = NULL;
+
+ isp_private = platform_get_drvdata(dev);
+
+ if (isp_private) {
+ isp_yiq_antiflicker_buf_free(isp_private);
+ isp_block_buf_free(isp_private);
+ devm_kfree(&dev->dev, isp_private);
+ platform_set_drvdata(dev, NULL);
+ } else {
+ printk("isp_remove: isp_private is null error.\n");
+ }
+
+ misc_deregister(&isp_dev);
+
+ printk("isp_remove: success.\n");
+
+ return 0;
+}
+
+static const struct of_device_id of_match_table_isp[] = {
+ { .compatible = "sprd,sprd_isp", },
+ { },
+};
+
+static struct platform_driver isp_driver = {
+ .probe = isp_probe,
+ .remove = isp_remove,
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "sprd_isp",
+ .of_match_table = of_match_ptr(of_match_table_isp),
+ },
+};
+
+static int __init isp_init(void)
+{
+ printk ("isp_init: success.\n");
+
+ if (platform_driver_register(&isp_driver)) {
+ printk ("isp_init: platform_driver_register error.\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static void __exit isp_exit(void)
+{
+ printk ("isp_exit: success.\n");
+
+ platform_driver_unregister(&isp_driver);
+}
+
+static int isp_wr_addr(struct isp_reg_bits *ptr)
+{
+ int i;
+ int sum = 0;
+
+ if(NULL == ptr){
+ printk("isp_wr_addr: ptr\n");
+ return -1;
+ }
+
+ struct isp_reg_bits *ptr_reg = ptr;
+
+ ptr_reg -> reg_addr = 0x0000; /* Interrupt part*/
+ sum++;
+
+ for (i = 0; i < 17; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0014 + i * 0x4;
+ sum++;
+ }
+
+ for (i = 0; i < 4; i++) /*Fetch*/
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0100 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0114 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 10; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0120 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 4; i++) /* store*/
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0200 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 10; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0214 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 12; i++) /* dispatch */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0300 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* arbiter */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0400 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 4; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0414 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* axi */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0500 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0514 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* raw sizer */
+ ptr_reg -> reg_addr = 0x0600;
+ sum++;
+
+ for(i = 0; i < 45; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0614 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 3; i++) /* common */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0700 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 16; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x0714 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* global gain */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1000 + i * 0x14;
+ sum++;
+ }
+
+ ptr_reg++; /* BLC */
+ ptr_reg -> reg_addr = 0x1100;
+ sum++;
+
+ for(i = 0; i < 3; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1114 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* RGBG */
+ ptr_reg -> reg_addr = 0x1200;
+ sum++;
+
+ for(i = 0; i < 3; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1214 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* PWD */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1300 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 11; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1314 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* NLC */
+ ptr_reg -> reg_addr = 0x1400;
+ sum++;
+
+ for(i = 0; (ptr_reg->reg_addr) < 0x14b0; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1414 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* lens shading calibration */
+ ptr_reg -> reg_addr = 0x1500;
+ sum++;
+
+ for(i = 0; i < 15; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1514 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* binning */
+ ptr_reg -> reg_addr = 0x1600;
+ sum++;
+
+ for(i = 0; i < 3; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1614 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* AWBM */
+ ptr_reg -> reg_addr = 0x1700;
+ sum++;
+
+ for(i = 0; i < 34; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1714 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x17A0 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* AWBC */
+ ptr_reg -> reg_addr = 0x1800;
+ sum++;
+
+ for(i = 0; i < 14; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1814 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* AEM */
+ ptr_reg -> reg_addr = 0x1900;
+ sum++;
+
+ for(i = 0; i < 4; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1914 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* BPC */
+ ptr_reg -> reg_addr = 0x1A00;
+ sum++;
+
+ for(i = 0; i < 14; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1A14 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* GRGB */
+ ptr_reg -> reg_addr = 0x1B00;
+ sum++;
+
+ for(i = 0; i < 2; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1B14 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* BDN */
+ ptr_reg -> reg_addr = 0x1C00;
+ sum++;
+
+ for(i = 0; i < 101; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1C14 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 7; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1DA8 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* RGBG2 */
+ ptr_reg -> reg_addr = 0x1E00;
+ sum++;
+
+ for(i = 0; i < 3; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1E14 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* 1d lnc */
+ ptr_reg -> reg_addr = 0x1F00;
+ sum++;
+
+ for(i = 0; i < 19; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1F14 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* NLM VST IVST */
+ ptr_reg -> reg_addr = 0x2014;
+ sum++;
+
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x2214;
+ sum++;
+
+ for(i = 0; i < 3; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x2100 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 35; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x2114 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* CFA: clolor filter array */
+ ptr_reg -> reg_addr = 0x3000;
+ sum++;
+
+ for(i = 0; i < 7; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3014 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* CMC */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3100 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 5; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3114 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 5; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x312C + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* GAMMA */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3300 + i * 0x14;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* Color matrix correction for 8 bits */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3500 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 16; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3514 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* CT: Color transformation */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3600 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3614;
+ sum++;
+
+ for(i = 0; i < 2; i++) /* CCE: clolor conversion enhancement */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3700 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 13; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3714 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* HSV */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3800 + i * 0x14;
+ sum++;
+ }
+
+ ptr_reg++; /* Radial CSC */
+ ptr_reg -> reg_addr = 0x3900;
+ sum++;
+
+ for(i = 0; i < 14; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3914 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* ISP_PRECNRNEW */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3A00 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 4; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3A14 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* ISP_PSTRZ */
+ ptr_reg -> reg_addr = 0x3B00;
+ sum++;
+
+ for(i = 0; i < 9; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3B14 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* AFM: auto focus monitor */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3C00 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 105; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x3C14 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* YIQ AEM */
+ ptr_reg -> reg_addr = 0x4100;
+ sum++;
+
+ for(i = 0; i < 10; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x4114 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* ANTI FLICKER */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x4200 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 4; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x4214 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* YIQ AFM */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x4300 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 158; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x4314 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* Pre-CDN */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5000 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 19; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5014 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* Pre-Filter */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5100 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5114 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* Brightness */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5300 + i * 0x14;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* Contrast */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5400 + i * 0x14;
+ sum++;
+ }
+
+ ptr_reg++; /* HIST: histogram */
+ ptr_reg -> reg_addr = 0x5500;
+ sum++;
+
+ for(i = 0; i < 5; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5514 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* HIST2 */
+ ptr_reg -> reg_addr = 0x5600;
+ sum++;
+
+ for(i = 0; i < 9; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5614 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* AUTOCONT: auto contrat adjustment */
+ ptr_reg -> reg_addr = 0x5700;
+ sum++;
+
+ for(i = 0; i < 2; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5714 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* cdn */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5800 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 18; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5814 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++; /* edge */
+ ptr_reg -> reg_addr = 0x5900;
+ sum++;
+
+ for(i = 0; i < 12; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5914 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* emboss */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5A00 + i * 0x14;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5A00 + i * 0x14;
+ sum++;
+ }
+
+ ptr_reg++; /* CSS */
+ ptr_reg -> reg_addr = 0x5B00;
+ sum++;
+
+ for(i = 0; i < 10; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5B14 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* csa */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5C00 + i * 0x14;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* hua */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5D00 + i * 0x14;
+ sum++;
+ }
+
+ ptr_reg++; /* post-cdn */
+ ptr_reg -> reg_addr = 0x5E00;
+ sum++;
+
+ for(i = 0; i < 29; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5E14 + i * 0x4;
+ sum++;
+ }
+
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x5F14;
+ sum++;
+
+ for(i = 0; i < 2; i++) /* ygamma */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x6000 + i * 0x14;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* ydelay */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x6100 + i * 0x14;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++) /* iircnr */
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x6400 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 16; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x6414 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 2; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x2000 + i * 0x54;
+ sum++;
+ }
+
+ for(i = 0; (ptr_reg->reg_addr) < 0x153fc; i++) // isp v memory1: awbm; isp v memory2:aem
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x10000 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; (ptr_reg->reg_addr) < 0x163fc; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x16000 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; (ptr_reg->reg_addr) < 0x17b60; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x17000 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; (ptr_reg->reg_addr) < 0x185a0; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x18000 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; (ptr_reg->reg_addr) < 0x1b200; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x19000 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 3; i++)
+ {
+ int addr_n;
+ int addr_base = 0x1c000 + i * 0x1000;
+ for(addr_n = 0; (ptr_reg->reg_addr) < (addr_base + 0x200); addr_n++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = addr_base + addr_n * 0x4;
+ sum++;
+ }
+ }
+
+ for(i = 0; (ptr_reg->reg_addr) < 0x20b60; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x1f000 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; (ptr_reg->reg_addr) < 0x215a0; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x21000 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; (ptr_reg->reg_addr) < 0x24200; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x22000 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; i < 3; i++)
+ {
+ int addr_n;
+ int addr_base = 0x25000 + i * 0x1000;
+ for(addr_n = 0; (ptr_reg->reg_addr) < (addr_base + 0x200); addr_n++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = addr_base + addr_n * 0x4;
+ sum++;
+ }
+ }
+
+ for(i = 0; (ptr_reg->reg_addr) < 0x2b2fc; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x28000 + i * 0x4;
+ sum++;
+ }
+
+ for(i = 0; (ptr_reg->reg_addr) < 0x2e2fc; i++)
+ {
+ ptr_reg++;
+ ptr_reg -> reg_addr = 0x2C000 + i * 0x4;
+ sum++;
+ }
+
+ return sum;
+}
+
+module_init(isp_init);
+module_exit(isp_exit);
+MODULE_DESCRIPTION("Isp Driver");
+MODULE_LICENSE("GPL");