Browse Source

Linux_SDK_V1.0.2

thead_admin 1 year ago
parent
commit
89ce56d72f
54 changed files with 1159 additions and 626 deletions
  1. 2 18
      vvcam/dw200/dw200_ioctl.c
  2. 6 0
      vvcam/isp/ic_dev.h
  3. 2 2
      vvcam/isp/isp_3dnr.c
  4. 2 2
      vvcam/isp/isp_3dnr2.c
  5. 1 19
      vvcam/isp/isp_dmsc2.c
  6. 5 5
      vvcam/isp/isp_hdr.c
  7. 55 59
      vvcam/isp/isp_ioctl.c
  8. 7 6
      vvcam/isp/isp_ioctl.h
  9. 9 9
      vvcam/isp/isp_irq_queue.c
  10. 2 2
      vvcam/isp/isp_irq_queue.h
  11. 8 8
      vvcam/isp/isp_miv1.c
  12. 48 38
      vvcam/isp/isp_miv2.c
  13. 30 16
      vvcam/isp/isp_rgbgamma.c
  14. 20 20
      vvcam/isp/isp_tdnr3.c
  15. 2 2
      vvcam/isp/isp_wdr.c
  16. 6 6
      vvcam/isp/isp_wdr3.c
  17. 6 6
      vvcam/isp/isp_wdr4.c
  18. 15 1
      vvcam/native/dw200/vvcam_dwe_driver.c
  19. 98 48
      vvcam/native/flash_led/flash_led_driver.c
  20. 5 1
      vvcam/native/flash_led/flash_led_driver.h
  21. 19 21
      vvcam/native/flash_led/flash_led_ioctl.c
  22. 10 0
      vvcam/native/flash_led/flash_led_ioctl.h
  23. 78 28
      vvcam/native/isp/vvcam_isp_driver_of.c
  24. 40 10
      vvcam/native/sensor/platform/platform_gen6_driver.c
  25. 8 0
      vvcam/native/sensor/sensor_common.h
  26. 37 6
      vvcam/native/sensor/sensor_ioctl.c
  27. 104 27
      vvcam/native/sensor/vvcam_sensor_driver.c
  28. 3 0
      vvcam/native/vi_pre/vi_pre.h
  29. 72 51
      vvcam/native/vi_pre/vi_pre_dma.c
  30. 5 29
      vvcam/native/vi_pre/vi_pre_driver_of.c
  31. 66 6
      vvcam/native/vi_pre/vi_pre_ioctl.c
  32. 63 6
      vvcam/native/vi_pre/vi_pre_ioctl.h
  33. 2 2
      vvcam/native/video/Makefile
  34. 8 1
      vvcam/native/video/subdev.c
  35. 74 4
      vvcam/native/video/video.c
  36. 4 0
      vvcam/native/video/video.h
  37. 8 1
      vvcam/native/video/video_hw_info.c
  38. 10 0
      vvcam/native/video/video_ioctl.h
  39. 8 2
      vvcam/native/video/video_kernel_defs.h
  40. 16 16
      vvcam_ry/isp/isp_3dnr.c
  41. 2 2
      vvcam_ry/isp/isp_3dnr2.c
  42. 7 7
      vvcam_ry/isp/isp_compand.c
  43. 11 11
      vvcam_ry/isp/isp_dmsc2.c
  44. 5 5
      vvcam_ry/isp/isp_gcmono.c
  45. 5 5
      vvcam_ry/isp/isp_hdr.c
  46. 14 21
      vvcam_ry/isp/isp_ioctl.c
  47. 6 5
      vvcam_ry/isp/isp_ioctl.h
  48. 17 16
      vvcam_ry/isp/isp_irq_queue.c
  49. 2 2
      vvcam_ry/isp/isp_irq_queue.h
  50. 28 26
      vvcam_ry/isp/isp_miv2.c
  51. 18 18
      vvcam_ry/isp/isp_tdnr3.c
  52. 7 7
      vvcam_ry/isp/isp_wdr.c
  53. 2 2
      vvcam_ry/isp/isp_wdr4.c
  54. 71 21
      vvcam_ry/native/isp/vvcam_isp_driver_of.c

+ 2 - 18
vvcam/dw200/dw200_ioctl.c

@@ -385,7 +385,9 @@ void visys_reset(void)
 {
 	u32 val = __raw_readl(visys_sw_rst);
     __raw_writel( val & ~BIT(31), visys_sw_rst);
+	udelay(1);
     __raw_writel(val, visys_sw_rst);
+	udelay(1);
 }
 
 int vse_reset(struct dw200_subdev *dev)
@@ -973,16 +975,6 @@ int vse_s_params(struct dw200_subdev *dev)
 	return 0;
 }
 
-void dw200_mutex_lock(struct dw200_subdev *dev)
-{
-	mutex_lock(dev->vvmutex);
-}
-
-void dw200_mutex_unlock(struct dw200_subdev *dev)
-{
-	mutex_unlock(dev->vvmutex);
-}
-
 long dw200_priv_ioctl(struct dw200_subdev *dev, unsigned int cmd, void *args)
 {
 	int ret = -1;
@@ -1106,14 +1098,6 @@ long dw200_priv_ioctl(struct dw200_subdev *dev, unsigned int cmd, void *args)
 			vse_mask_irq(dev, mask);
 			break;
 		}
-	case DW200IOC_LOCK:
-		dw_info("DW200IOC_LOCK\n");
-		dw200_mutex_lock(dev);
-		break;
-	case DW200IOC_UNLOCK:
-		dw_info("DW200IOC_UNLOCK\n");
-		dw200_mutex_unlock(dev);
-		break;
 	case DW200IOC_VISYS_RESET:
 		dw_info("DW200IOC_VISYS_RESET\n");
 		visys_reset();

+ 6 - 0
vvcam/isp/ic_dev.h

@@ -136,6 +136,7 @@ struct isp_digital_gain_cxt {
 	u16 gain_b;
 	u16 gain_gr;
 	u16 gain_gb;
+	bool changed;
 };
 
 struct isp_mi_data_path_context {
@@ -152,11 +153,13 @@ struct isp_mi_data_path_context {
 	bool vscale;
 	int pixelformat;
 	bool yuv_bit;
+	bool raw_is_big_endian;
 };
 
 struct isp_dummy_hblank_cxt {
 	u8 bp, fp, w, in_hsize;
 };
+
 enum MIV2_PATH_ID {
 	ISP_MI_PATH_MP = 0,
 	ISP_MI_PATH_SP,
@@ -916,6 +919,9 @@ struct isp_rgbgamma_data {
 
 struct isp_rgbgamma_context {
 	bool enable;
+	struct isp_rgbgamma_data *data;
+	bool data_changed;
+	bool changed;
 };
 
 struct isp_irq_data {

+ 2 - 2
vvcam/isp/isp_3dnr.c

@@ -208,7 +208,7 @@ int isp_s_3dnr(struct isp_ic_dev *dev)
 
 	u32 isp_denoise3d_strength, isp_denoise3d_motion, isp_denoise3d_delta_inv;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (dnr3->update_bin) {
 		dnr3_hw_init(dev);
 	}
@@ -308,7 +308,7 @@ int isp_u_3dnr(struct isp_ic_dev *dev, struct isp_3dnr_update *dnr3_update)
 #else
 	u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d_strength));
 	REG_SET_SLICE(regVal, DENOISE3D_STRENGTH, dev->dnr3.strength);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d_strength), regVal);

+ 2 - 2
vvcam/isp/isp_3dnr2.c

@@ -201,7 +201,7 @@ int isp_s_3dnr(struct isp_ic_dev *dev)
 	u32 isp_denoise3d_strength, isp_denoise3d_motion, isp_denoise3d_delta_inv;
 	u32 isp_denoise3d_ctrl;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (dnr3->update_bin) {
 		dnr3_hw_init(dev);
     }
@@ -287,7 +287,7 @@ int isp_u_3dnr(struct isp_ic_dev *dev, struct isp_3dnr_update *dnr3_update)
 
 	u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d_strength));
 	REG_SET_SLICE(regVal, DENOISE3D_STRENGTH, dev->dnr3.strength);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d_strength), regVal);

+ 1 - 19
vvcam/isp/isp_dmsc2.c

@@ -65,7 +65,6 @@ int isp_enable_dmsc(struct isp_ic_dev *dev)
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 	u32 isp_dmsc_size_ctrl =
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_size_ctrl));
-	pr_info("enter %s\n", __func__);
 	REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_BYPASS, 0U);
 	REG_SET_SLICE(isp_dmsc_size_ctrl, ISP_DMSC_IMAGE_H_SIZE,
 		      isp_read_reg(dev, REG_ADDR(isp_acq_h_size)));
@@ -81,7 +80,6 @@ int isp_disable_dmsc(struct isp_ic_dev *dev)
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 	isp_dmsc_ctrl = 0;	//clear fpga default bit 3 and 13 to keep the same value with cmodel.
 
-	pr_info("enter %s\n", __func__);
 	REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_BYPASS, 1U);
 
 	/*clear the reg default val to keep weith cmodel  */
@@ -103,7 +101,6 @@ int isp_disable_dmsc(struct isp_ic_dev *dev)
 int isp_set_dmsc_intp(struct isp_ic_dev *dev)
 {
 	u32 isp_dmsc_intp_thr = isp_read_reg(dev, REG_ADDR(isp_dmsc_intp_thr));
-	pr_info("enter %s\n", __func__);
 	REG_SET_SLICE(isp_dmsc_intp_thr, ISP_DMSC_INTERPLATION_DIR_THR_MAX,
 		      dev->demosaic.intp.intp_dir_thr_max);
 	REG_SET_SLICE(isp_dmsc_intp_thr, ISP_DMSC_INTERPLATION_DIR_THR_MIN,
@@ -114,7 +111,6 @@ int isp_set_dmsc_intp(struct isp_ic_dev *dev)
 
 int isp_set_dmsc_dmoi(struct isp_ic_dev *dev)
 {
-
 	struct isp_dmoi_context *pDemoire = &dev->demosaic.demoire;
 	u32 isp_dmsc_dmoi_ctrl =
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_dmoi_ctrl));
@@ -123,8 +119,6 @@ int isp_set_dmsc_dmoi(struct isp_ic_dev *dev)
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_dmoi_patn_thr));
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 
-	pr_info("enter %s\n", __func__);
-
 	if (!pDemoire->enable) {
 		REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_DEMOIRE_ENABLE, 0U);
 		isp_write_reg(dev, REG_ADDR(isp_dmsc_ctrl), isp_dmsc_ctrl);
@@ -172,7 +166,6 @@ int isp_set_dmsc_sharpen(struct isp_ic_dev *dev)
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_shap_ratio));
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 
-	pr_info("enter %s\n", __func__);
 
 	if (!pSharpen->enable) {
 		REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_SHARPEN_ENBALE, 0);
@@ -222,7 +215,6 @@ int isp_set_dmsc_gfilter(struct isp_ic_dev *dev)
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_shap_filt1));
 	u32 isp_dmsc_shap_filt2 =
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_shap_filt2));
-	pr_info("enter %s\n", __func__);
 
 	REG_SET_SLICE(isp_dmsc_shap_filt1, ISP_DMSC_HF_FILT_00,
 		      pgfilter->hf_filt_00);
@@ -261,7 +253,6 @@ int isp_set_dmsc_sharpen_line(struct isp_ic_dev *dev)
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_shap_line_ratio));
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 
-	pr_info("enter %s\n", __func__);
 
 	if (!sharpenLine->enable) {
 		REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_SHARPEN_LINE_ENABLE, 0);
@@ -299,8 +290,6 @@ int isp_set_dmsc_cac(struct isp_ic_dev *dev)
 	u32 val = 0;
 	u32 isp_dmsc_cac_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_cac_ctrl));
 
-	pr_info("enter %s\n", __func__);
-
 	if (!cac->enable) {
 		REG_SET_SLICE(isp_dmsc_cac_ctrl, MRV_CAC_CAC_EN, 0);
 		isp_write_reg(dev, REG_ADDR(isp_dmsc_cac_ctrl),
@@ -336,7 +325,6 @@ int isp_set_dmsc_depurple(struct isp_ic_dev *dev)
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_dpul_ctrl));
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 
-	pr_info("enter %s\n", __func__);
 	if (!depurple->enable) {
 		REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_DEPURPLE_ENABLE, 0U);
 		isp_write_reg(dev, REG_ADDR(isp_dmsc_ctrl), isp_dmsc_ctrl);
@@ -368,7 +356,6 @@ int isp_set_dmsc_skin(struct isp_ic_dev *dev)
 
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 
-	pr_info("enter %s\n", __func__);
 	if (!skin->enable) {
 		REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_SKIN_ENABLE, 0U);
 		isp_write_reg(dev, REG_ADDR(isp_dmsc_ctrl), isp_dmsc_ctrl);
@@ -406,7 +393,7 @@ int isp_s_dmsc(struct isp_ic_dev *dev)
 	isp_disable_dmsc(dev);
 
 	isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (!dev->demosaic.enable) {
 		isp_disable_dmsc(dev);
 		return 0;
@@ -418,12 +405,7 @@ int isp_s_dmsc(struct isp_ic_dev *dev)
 	isp_write_reg(dev, REG_ADDR(isp_dmsc_ctrl), isp_dmsc_ctrl);
 
 	isp_set_dmsc_intp(dev);
-	isp_set_dmsc_dmoi(dev);
-	isp_set_dmsc_skin(dev);
 	isp_enable_dmsc(dev);
-	isp_set_dmsc_depurple(dev);
-	isp_set_dmsc_sharpen_line(dev);
-	isp_set_dmsc_sharpen(dev);
 	isp_set_dmsc_gfilter(dev);
 
 	return 0;

+ 5 - 5
vvcam/isp/isp_hdr.c

@@ -68,7 +68,7 @@ int isp_s_hdr(struct isp_ic_dev *dev)
 	u32 val;
 	int i;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	val = 0;
 #if 0
@@ -181,7 +181,7 @@ int isp_s_hdr_wb(struct isp_ic_dev *dev)
 	u32 isp_stitching_ctrl =
 	    isp_read_reg(dev, REG_ADDR(isp_stitching_ctrl));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	REG_SET_SLICE(val, STITCHING_EXP0_AWB_GAIN_GR, hdr->gr);
 	REG_SET_SLICE(val, STITCHING_EXP0_AWB_GAIN_GB, hdr->gb);
 	isp_write_reg(dev, REG_ADDR(isp_stitching_exp0_awb_gain_g), val);
@@ -208,7 +208,7 @@ int isp_s_hdr_bls(struct isp_ic_dev *dev)
 	u32 val = 0;
 	int i;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	for (i = 0; i < 12; i++) {
 		val = 0;
@@ -228,7 +228,7 @@ int isp_enable_hdr(struct isp_ic_dev *dev)
 	u32 dpcl;
 	int val = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	addr = REG_ADDR(isp_stitching_ctrl);
 	isp_stitching_ctrl = isp_read_reg(dev, addr);
 	REG_SET_SLICE(val, STITCHING_FRAME_WIDTH, dev->ctx.acqWindow.width);
@@ -250,7 +250,7 @@ int isp_disable_hdr(struct isp_ic_dev *dev)
 {
 	u32 addr, isp_stitching_ctrl = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	addr = REG_ADDR(isp_stitching_ctrl);
 	isp_stitching_ctrl = isp_read_reg(dev, addr);
 	REG_SET_SLICE(isp_stitching_ctrl, STITCHING_COMBINE_ENABLE_BIT, 1);

+ 55 - 59
vvcam/isp/isp_ioctl.c

@@ -63,16 +63,7 @@
 #include <linux/regmap.h>
 #include <linux/of_reserved_mem.h>
 #endif
-
-#ifdef CONFIG_VSI_ISP_DEBUG
-#define isp_info(fmt, ...)	pr_info(fmt, ##__VA_ARGS__)
-#define isp_debug(fmt, ...)  pr_debug(fmt, ##__VA_ARGS__)
-#define isp_err(fmt, ...)  pr_err(fmt, ##__VA_ARGS__)
-#else
-#define isp_info(fmt, ...)
-#define isp_debug(fmt, ...)
-#define isp_err(fmt, ...)  pr_err(fmt, ##__VA_ARGS__)
-#endif
+#include "isp_ioctl.h"
 
 volatile MrvAllRegister_t *all_regs = NULL;
 
@@ -87,7 +78,7 @@ void isp_ic_set_hal(HalHandle_t hal)
 
 void isp_write_reg(struct isp_ic_dev *dev, u32 offset, u32 val)
 {
-	//pr_info("%s addr 0x%08x val 0x%08x\n", __func__, offset, val);
+	//isp_info("%s addr 0x%08x val 0x%08x\n", __func__, offset, val);
 	if (offset >= ISP_REG_SIZE)
 		return;
 	HalWriteReg(hal_handle, offset, val);
@@ -417,29 +408,34 @@ int isp_s_input(struct isp_ic_dev *dev)
 
 int isp_s_digital_gain(struct isp_ic_dev *dev)
 {
-	struct isp_digital_gain_cxt dgain = *(&dev->dgain);
-	u32 isp_dgain_rb = isp_read_reg(dev, REG_ADDR(isp_dgain_rb));
-	u32 isp_dgain_g = isp_read_reg(dev, REG_ADDR(isp_dgain_g));
-	u32 isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl));
-	if (!dgain.enable) {
-		isp_err("%s, Disable isp digital gain", __func__);
-		REG_SET_SLICE(isp_ctrl, MRV_ISP_DIGITAL_GAIN_EN, 0U);
-		isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl);
-		return 0;
-	}
+	if (dev->dgain.changed) {
+		u32 isp_dgain_rb = isp_read_reg(dev, REG_ADDR(isp_dgain_rb));
+		u32 isp_dgain_g = isp_read_reg(dev, REG_ADDR(isp_dgain_g));
+		u32 isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl));
+		if (!dev->dgain.enable) {
+			isp_err("%s, Disable isp digital gain", __func__);
+			REG_SET_SLICE(isp_ctrl, MRV_ISP_DIGITAL_GAIN_EN, 0U);
+			isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl);
+			return 0;
+		}
 
-	//isp_info("enter %s\n", __func__);
-	REG_SET_SLICE(isp_dgain_rb, ISP_DIGITAL_GAIN_R, dgain.gain_r);
-	REG_SET_SLICE(isp_dgain_rb, ISP_DIGITAL_GAIN_B, dgain.gain_b);
+		//isp_info("enter %s\n", __func__);
+		REG_SET_SLICE(isp_dgain_rb, ISP_DIGITAL_GAIN_R, dev->dgain.gain_r);
+		REG_SET_SLICE(isp_dgain_rb, ISP_DIGITAL_GAIN_B, dev->dgain.gain_b);
 
-	REG_SET_SLICE(isp_dgain_g, ISP_DIGITAL_GAIN_GR, dgain.gain_gr);
-	REG_SET_SLICE(isp_dgain_g, ISP_DIGITAL_GAIN_GB, dgain.gain_gb);
-	REG_SET_SLICE(isp_ctrl, MRV_ISP_DIGITAL_GAIN_EN, 1U);
+		REG_SET_SLICE(isp_dgain_g, ISP_DIGITAL_GAIN_GR, dev->dgain.gain_gr);
+		REG_SET_SLICE(isp_dgain_g, ISP_DIGITAL_GAIN_GB, dev->dgain.gain_gb);
+		REG_SET_SLICE(isp_ctrl, MRV_ISP_DIGITAL_GAIN_EN, 1U);
+
+		isp_write_reg(dev, REG_ADDR(isp_dgain_rb), isp_dgain_rb);
+		isp_write_reg(dev, REG_ADDR(isp_dgain_g), isp_dgain_g);
+		isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl);
+		//isp_info("exit %s\n", __func__);
+		dev->dgain.changed = false;
+	} else {
+		dev->dgain.changed = true;
+	}
 
-	isp_write_reg(dev, REG_ADDR(isp_dgain_rb), isp_dgain_rb);
-	isp_write_reg(dev, REG_ADDR(isp_dgain_g), isp_dgain_g);
-	isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl);
-	//isp_info("exit %s\n", __func__);
 	return 0;
 }
 
@@ -935,7 +931,8 @@ int isp_start_stream(struct isp_ic_dev *dev, u32 numFrames)
 	isp_imsc = isp_read_reg(dev, REG_ADDR(isp_imsc));
 	isp_imsc |=
 	    (MRV_ISP_IMSC_ISP_OFF_MASK | MRV_ISP_IMSC_FRAME_MASK |
-	     MRV_ISP_IMSC_FRAME_IN_MASK | MRV_ISP_IMSC_PIC_SIZE_ERR_MASK | MRV_ISP_IMSC_FLASH_ON_MASK);
+	     MRV_ISP_IMSC_FRAME_IN_MASK | MRV_ISP_IMSC_PIC_SIZE_ERR_MASK | MRV_ISP_IMSC_FLASH_ON_MASK |
+		 MRV_ISP_IMSC_DATA_LOSS_MASK);
 	/* isp_imsc |= (MRV_ISP_IMSC_FRAME_MASK | MRV_ISP_IMSC_DATA_LOSS_MASK | MRV_ISP_IMSC_FRAME_IN_MASK); */
 	isp_write_reg(dev, REG_ADDR(isp_icr), 0xFFFFFFFF);
 	isp_write_reg(dev, REG_ADDR(isp_imsc), isp_imsc);
@@ -1191,7 +1188,7 @@ int isp_ioc_read_mis(struct isp_ic_dev *dev, void __user *args)
 {
 	isp_mis_list_t* pCList = &dev->circle_list;
 	isp_mis_t mis_data;
-	u32 ary[2];
+	u64 ary[2];
 	int ret = -1;
 	ret = isp_irq_read_circle_queue(&mis_data, pCList);
 	if (ret < 0) {
@@ -1331,9 +1328,9 @@ int isp_s_hdrexp(struct isp_ic_dev *dev)
 	u32 isp_hdr_exp_conf = isp_read_reg(dev, REG_ADDR(isp_hdr_exp_conf));
 	u32 isp_stitching_imsc = isp_read_reg(dev, REG_ADDR(isp_stitching_imsc));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (!dev->hdrexp.enable) {
-        pr_info("%s, hdr disabled\n",__func__);
+        isp_info("%s, hdr disabled\n",__func__);
 		REG_SET_SLICE(isp_hdr_exp_conf, MRV_HDR_EXP_START, 0);
 		isp_write_reg(dev, REG_ADDR(isp_hdr_exp_conf), isp_hdr_exp_conf);
 		isp_write_reg(dev, REG_ADDR(isp_stitching_imsc), isp_stitching_imsc & ~0x38);
@@ -1375,7 +1372,7 @@ int isp_g_hdrexpmean(struct isp_ic_dev *dev, u8 * mean)
 {
 	int i = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (!dev || !mean)
 		return -EINVAL;
 	for (; i < 75; i++) {
@@ -1483,9 +1480,9 @@ int isp_s_hdrhist(struct isp_ic_dev *dev)
 	u32 isp_hdr_hist_prop = isp_read_reg(dev, REG_ADDR(isp_hdr_hist_prop));
 	u32 isp_stitching_imsc = isp_read_reg(dev, REG_ADDR(isp_stitching_imsc));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (!dev->hdrhist.enable) {
-		pr_info("%s, hdr disable\n", __func__);
+		isp_info("%s, hdr disable\n", __func__);
 		REG_SET_SLICE(isp_hdr_hist_prop, MRV_HIST_MODE, MRV_HIST_MODE_NONE);
 		isp_write_reg(dev, REG_ADDR(isp_hdr_hist_prop), isp_hdr_hist_prop);
 		isp_write_reg(dev, REG_ADDR(isp_stitching_imsc),
@@ -1533,7 +1530,7 @@ int isp_g_hdrhistmean(struct isp_ic_dev *dev, u32 * mean)
 {
 	int i = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (!dev || !mean)
 		return -EINVAL;
 
@@ -1547,7 +1544,7 @@ int isp_g_hdrhistmean(struct isp_ic_dev *dev, u32 * mean)
 int isp_s_hist64(struct isp_ic_dev *dev)
 {
 #ifndef ISP_HIST64
-	//pr_err("Not supported hist64 module\n");
+	//isp_err("Not supported hist64 module\n");
 	return -1;
 #else
 	struct isp_hist64_context *hist64 = &dev->hist64;
@@ -1625,7 +1622,7 @@ int isp_s_hist64(struct isp_ic_dev *dev)
 int isp_g_hist64mean(struct isp_ic_dev *dev, u32 *mean)
 {
 #ifndef ISP_HIST64
-	//pr_err("Not supported hist64 module\n");
+	//isp_err("Not supported hist64 module\n");
 	return -1;
 #else
 	int i = 0;
@@ -1647,7 +1644,7 @@ int isp_g_hist64mean(struct isp_ic_dev *dev, u32 *mean)
 int isp_g_hist64_vstart_status(struct isp_ic_dev *dev, u32 *status)
 {
 #ifndef ISP_HIST64
-	//pr_err("Not supported hist64 module\n");
+	//isp_err("Not supported hist64 module\n");
 	return -1;
 #else
 
@@ -1664,7 +1661,7 @@ int isp_g_hist64_vstart_status(struct isp_ic_dev *dev, u32 *status)
 int isp_update_hist64(struct isp_ic_dev *dev)
 {
 #ifndef ISP_HIST64
-	//pr_err("Not supported hist64\n");
+	//isp_err("Not supported hist64\n");
 	return -1;
 #else
 	struct isp_hist64_context* hist64 =&dev->hist64;
@@ -2175,7 +2172,6 @@ int isp_s_afm(struct isp_ic_dev *dev)
 	u32 isp_afm_ctrl = isp_read_reg(dev, REG_ADDR(isp_afm_ctrl));
 	u32 isp_imsc = isp_read_reg(dev, REG_ADDR(isp_imsc));
 
-	isp_info("enter %s\n", __func__);
 
 	if (!afm->enable) {
 		REG_SET_SLICE(isp_afm_ctrl, MRV_AFM_AFM_EN, 0);
@@ -2202,27 +2198,26 @@ int isp_s_afm(struct isp_ic_dev *dev)
 	isp_imsc |= mask;
 	isp_write_reg(dev, REG_ADDR(isp_afm_ctrl), isp_afm_ctrl);
 	isp_write_reg(dev, REG_ADDR(isp_imsc), isp_imsc);
-	isp_info("exit %s\n", __func__);
+
 	return 0;
 }
 
 int isp_g_afm(struct isp_ic_dev *dev, struct isp_afm_result *afm)
 {
-	isp_debug("enter %s\n", __func__);
 	afm->sum_a = isp_read_reg(dev, REG_ADDR(isp_afm_sum_a));
 	afm->sum_b = isp_read_reg(dev, REG_ADDR(isp_afm_sum_b));
 	afm->sum_c = isp_read_reg(dev, REG_ADDR(isp_afm_sum_c));
 	afm->lum_a = isp_read_reg(dev, REG_ADDR(isp_afm_lum_a));
 	afm->lum_b = isp_read_reg(dev, REG_ADDR(isp_afm_lum_b));
 	afm->lum_c = isp_read_reg(dev, REG_ADDR(isp_afm_lum_c));
-	isp_debug("exit %s\n", __func__);
+
 	return 0;
 }
 
 int isp_s_exp2_inputsel(struct isp_ic_dev *dev)
 {
 #ifndef ISP_AEV2
-	pr_err("unsupported function: %s\n", __func__);
+	isp_err("unsupported function: %s\n", __func__);
 	return -EINVAL;
 #else
 	struct isp_exp2_context *exp2 = &dev->exp2;
@@ -2236,7 +2231,7 @@ int isp_s_exp2_inputsel(struct isp_ic_dev *dev)
 int isp_s_exp2_sizeratio(struct isp_ic_dev *dev, u32 h_size)
 {
 #ifndef ISP_AEV2
-	pr_err("unsupported function: %s\n", __func__);
+	isp_err("unsupported function: %s\n", __func__);
 	return -EINVAL;
 #else
 	u32 size_inv;
@@ -2838,17 +2833,17 @@ long isp_priv_ioctl(struct isp_ic_dev *dev, unsigned int cmd, void __user *args)
 	if (!dev) {
 		return ret;
 	}
-	/*pr_info("[%s:%d]cmd 0x%08x\n", __func__, __LINE__, cmd);*/
+	/*isp_info("[%s:%d]cmd 0x%08x\n", __func__, __LINE__, cmd);*/
 	switch (cmd) {
 	case ISPIOC_RESET:
 		if((ret = isp_mi_stop(dev)) != 0 )
 		{
-			pr_err("[%s:%d]stop mi error before resetting!\n", __func__, __LINE__);
+			isp_err("[%s:%d]stop mi error before resetting!\n", __func__, __LINE__);
 			break;
 		}
 		if((ret = isp_stop_stream(dev)) != 0)
 		{
-			pr_err("[%s:%d]stop isp stream before resetting!\n", __func__, __LINE__);
+			isp_err("[%s:%d]stop isp stream before resetting!\n", __func__, __LINE__);
 			break;
 		}
 		ret = isp_reset(dev);
@@ -3491,12 +3486,13 @@ long isp_priv_ioctl(struct isp_ic_dev *dev, unsigned int cmd, void __user *args)
 						 (data, args,
 						  sizeof(struct
 							 isp_rgbgamma_data)));
-				ret = isp_s_rgbgamma(dev, data);
-#ifdef __KERNEL__
-				kfree(data);
-#else
-				free(data);
-#endif
+				dev->rgbgamma.data = data;
+				ret = isp_s_rgbgamma(dev);
+//#ifdef __KERNEL__
+//				kfree(data);
+//#else
+//				free(data);
+//#endif
 			}
 			break;
 		}
@@ -3671,7 +3667,7 @@ long isp_priv_ioctl(struct isp_ic_dev *dev, unsigned int cmd, void __user *args)
     case ISPIOC_GET_FRAME_MASK_INFO_ADDR: {
         unsigned long addr;
         addr = dev->frame_mark_info_addr;
-        pr_info("ISPIOC_GET_FRAME_MASK_INFO_ADDR %lx\n", addr);
+        isp_info("ISPIOC_GET_FRAME_MASK_INFO_ADDR %lx\n", addr);
         viv_check_retval(copy_to_user(args, &addr, sizeof(addr)));
         ret = 0;
     }

+ 7 - 6
vvcam/isp/isp_ioctl.h

@@ -220,13 +220,14 @@ enum {
 
 #define CONFIG_VSI_ISP_DEBUG 1
 #ifdef CONFIG_VSI_ISP_DEBUG
-#define isp_info(fmt, ...)  pr_info(fmt, ##__VA_ARGS__)
-#define isp_debug(fmt, ...)  pr_debug(fmt, ##__VA_ARGS__)
-#define isp_err(fmt, ...)  pr_err(fmt, ##__VA_ARGS__)
+#define isp_info(fmt, ...) printk(KERN_DEBUG   pr_fmt(fmt), ##__VA_ARGS__)
+#define isp_debug(fmt, ...) printk(KERN_DEBUG   pr_fmt(fmt), ##__VA_ARGS__)
+#define isp_warn(fmt, ...) printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+#define isp_err(fmt, ...)  printk(KERN_ERR     pr_fmt(fmt), ##__VA_ARGS__)
 #else
 #define isp_info(fmt, ...)
 #define isp_debug(fmt, ...)
-#define isp_err(fmt, ...)  pr_err(fmt, ##__VA_ARGS__)
+#define isp_err(fmt, ...)  printk(KERN_ERR     pr_fmt(fmt), ##__VA_ARGS__)
 #endif
 
 #define ISP_REG_GAP 4
@@ -317,7 +318,7 @@ int isp_s_hdr_bls(struct isp_ic_dev *dev);
 int isp_enable_hdr(struct isp_ic_dev *dev);
 int isp_disable_hdr(struct isp_ic_dev *dev);
 #ifdef ISP_2DNR_V5
-int isp_tdnr_s_2dnr(struct isp_ic_dev *dev);	
+int isp_tdnr_s_2dnr(struct isp_ic_dev *dev);
 #else
 int isp_s_2dnr(struct isp_ic_dev *dev);
 #endif
@@ -348,7 +349,7 @@ int isp_disable_gcmono(struct isp_ic_dev *dev);
 int isp_s_gcmono(struct isp_ic_dev *dev, struct isp_gcmono_data *data);	/* set curve */
 int isp_enable_rgbgamma(struct isp_ic_dev *dev);
 int isp_disable_rgbgamma(struct isp_ic_dev *dev);
-int isp_s_rgbgamma(struct isp_ic_dev *dev, struct isp_rgbgamma_data *data);
+int isp_s_rgbgamma(struct isp_ic_dev *dev);
 
 u32 isp_read_mi_irq(struct isp_ic_dev *dev);
 void isp_reset_mi_irq(struct isp_ic_dev *dev, u32 icr);

+ 9 - 9
vvcam/isp/isp_irq_queue.c

@@ -79,6 +79,7 @@
 #include <stdbool.h>
 #endif
 #include "isp_irq_queue.h"
+#include "isp_ioctl.h"
 
   //enqueue
 int isp_irq_enqueue(isp_mis_t *new,isp_mis_t* head)
@@ -88,7 +89,6 @@ int isp_irq_enqueue(isp_mis_t *new,isp_mis_t* head)
 
 
     if (new == NULL || head == NULL) {
-        //printk("%s: input wrong parameter\n", __func__);
         return -1;
     }
     new_node->val = new->val;
@@ -141,7 +141,7 @@ int isp_irq_create_circle_queue(isp_mis_list_t* pCList, int number)
   int i;
   isp_mis_t* pMisNode;
   if (pCList == NULL || number <= 0) {
-      printk("%s: create circle queue failed\n", __func__);
+      isp_info("%s: create circle queue failed\n", __func__);
       return -1;
   }
 
@@ -152,12 +152,12 @@ int isp_irq_create_circle_queue(isp_mis_list_t* pCList, int number)
       pCList->pRead = pCList->pHead;
       pCList->pWrite = pCList->pHead;
   }
-  printk("%s:pHead %px\n", __func__, pCList->pHead);
+  isp_info("%s:pHead %px\n", __func__, pCList->pHead);
   for (i = 0; i < number - 1; i++) {
       pMisNode = (isp_mis_t*)kmalloc(sizeof(isp_mis_t), GFP_KERNEL);
       INIT_LIST_HEAD(&pMisNode->list);
       list_add_tail(&pMisNode->list, &pCList->pHead->list);
-      printk("%s:pMisNode %px\n", __func__, pMisNode);
+      isp_info("%s:pMisNode %px\n", __func__, pMisNode);
   }
 
 #endif
@@ -169,18 +169,18 @@ int isp_irq_destroy_circle_queue(isp_mis_list_t* pCList)
 #ifdef __KERNEL__
   isp_mis_t* pMisNode;
   if ((pCList == NULL) || (pCList->pHead == NULL) ) {
-      printk("%s: destroy circle queue failed. pClist %px\n", __func__, pCList);
+      isp_err("%s: destroy circle queue failed. pClist %px\n", __func__, pCList);
       return -1;
   }
 
   while(!list_empty(&pCList->pHead->list)) {
       pMisNode = list_first_entry(&pCList->pHead->list, isp_mis_t, list);
-      printk("%s:pMisNode %px\n", __func__, pMisNode);
+      isp_info("%s:pMisNode %px\n", __func__, pMisNode);
       list_del(&pMisNode->list);
       kfree(pMisNode);
       pMisNode = NULL;
   }
-  printk("%s:pHead %px\n", __func__, pCList->pHead);
+  isp_info("%s:pHead %px\n", __func__, pCList->pHead);
   kfree(pCList->pHead);
   pCList->pHead = NULL;
   pCList->pRead = NULL;
@@ -194,7 +194,7 @@ int isp_irq_read_circle_queue(isp_mis_t* data, isp_mis_list_t* pCList)
 #ifdef __KERNEL__
   //isp_mis_t* pReadEntry;
   if (pCList == NULL) {
-      printk("%s: can not read circle queue\n", __func__);
+      isp_err("%s: can not read circle queue\n", __func__);
       return -1;
   }
 
@@ -220,7 +220,7 @@ int isp_irq_write_circle_queue(isp_mis_t* data, isp_mis_list_t* pCList)
 #ifdef __KERNEL__
   isp_mis_t* pWriteEntry;
   if (pCList == NULL) {
-      printk("%s: can not read circle queue\n", __func__);
+      isp_err("%s: can not read circle queue\n", __func__);
       return -1;
   }
 

+ 2 - 2
vvcam/isp/isp_irq_queue.h

@@ -69,8 +69,8 @@
 } isp_src_t;
 
 typedef struct isp_mis_s {
-	unsigned int irq_src;
-	unsigned int val;
+	uint64_t irq_src;
+	uint64_t val;
 #ifdef __KERNEL__
   struct list_head list;
 #endif

+ 8 - 8
vvcam/isp/isp_miv1.c

@@ -88,7 +88,7 @@ static int getRawBit(u32 type, u32 *bit, u32 *len)
 		break;
 #endif
 	default:
-		pr_err("unsupport raw formt: %d\n", type);
+		isp_err("unsupport raw formt: %d\n", type);
 		return -1;
 	}
 	return 0;
@@ -104,7 +104,7 @@ int isp_ioc_start_dma_read(struct isp_ic_dev *dev, void __user *args)
 	u32 llength = 0, mcm_rd_fmt_bit = 0;
 	u32 mi_imsc = 0, mcm_fmt = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	viv_check_retval(copy_from_user(&dma, args, sizeof(dma)));
 
 	REG_SET_SLICE(mi_dma_ctrl, MRV_MI_DMA_BURST_LEN_LUM, dma.burst_y);
@@ -240,7 +240,7 @@ int isp_bppath_start(struct isp_ic_dev *dev)
 	u32 mi_imsc = isp_read_reg(dev, REG_ADDR(mi_imsc));
 	int i;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	bp_ctrl = 0;
 	lval = path->out_width;
 
@@ -336,7 +336,7 @@ int isp_mi_start(struct isp_ic_dev *dev)
 	int i;
 	u8 retry = 3;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	isp_write_reg(dev, REG_ADDR(mrsz_ctrl), 0);
 	isp_write_reg(dev, REG_ADDR(mrsz_ctrl_shd), 0);
@@ -432,7 +432,7 @@ int isp_mi_start(struct isp_ic_dev *dev)
 			}
 		}
 		if(retry == i) {
-			pr_info("%s: update mi_mp_y_pic_width error!\n", __func__);
+			isp_info("%s: update mi_mp_y_pic_width error!\n", __func__);
 		}
 
 		/* enable frame end irq for  main path */
@@ -541,7 +541,7 @@ int isp_mi_start(struct isp_ic_dev *dev)
 int isp_mi_stop(struct isp_ic_dev *dev)
 {
 	u32 mi_ctrl = 0, mi_init = 0;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	isp_write_reg(dev, REG_ADDR(mi_imsc), 0);
 
@@ -570,7 +570,7 @@ int isp_set_buffer(struct isp_ic_dev *dev, struct isp_buffer_context *buf)
 	u32 addr;
 
 	if (!dev || !buf) {
-		pr_err("NULL pointer %s\n", __func__);
+		isp_err("NULL pointer %s\n", __func__);
 		return -EINVAL;
 	}
 
@@ -597,7 +597,7 @@ int isp_set_buffer(struct isp_ic_dev *dev, struct isp_buffer_context *buf)
 int isp_set_bp_buffer(struct isp_ic_dev *dev, struct isp_bp_buffer_context *buf)
 {
 #ifndef ISP_MI_BP
-	pr_err("unsupported function: %s", __func__);
+	isp_err("unsupported function: %s", __func__);
 	return -EINVAL;
 #else
 	isp_write_reg(dev, REG_ADDR(mi_bp_r_base_ad_init),

+ 48 - 38
vvcam/isp/isp_miv2.c

@@ -93,7 +93,7 @@ static int getRawBit(u32 type, u32 *bit, u32 *len)
 		break;
 #endif
 	default:
-		pr_err("unsupport raw formt: %d\n", type);
+		isp_err("unsupport raw formt: %d\n", type);
 		return -1;
 	}
 	return 0;
@@ -190,7 +190,7 @@ static void set_raw_buffer(struct isp_ic_dev *dev, struct isp_buffer_context *bu
 			buf->addr_y = dev->pp_write.buf_addr;
 			buf->size_y = dev->pp_write.buf_size;
 		}
-	/*pr_info("%s path %d type %d addr %08x line_num = %d buf_addr = 0x%x, buf_size = %d\n",
+	/*isp_info("%s path %d type %d addr %08x line_num = %d buf_addr = 0x%x, buf_size = %d\n",
 		__func__, buf->path, buf->type, addr, line_num, buf->addr_y, buf->size_y);*/
 	if (isRaw(buf->type)) {
 		if (addr != 0) {
@@ -207,7 +207,7 @@ static void set_raw_buffer(struct isp_ic_dev *dev, struct isp_buffer_context *bu
 int isp_set_buffer(struct isp_ic_dev *dev, struct isp_buffer_context *buf)
 {
 	if (!dev || !buf) {
-		pr_err("NULL pointer %s\n", __func__);
+		isp_err("NULL pointer %s\n", __func__);
 		return -1;
 	}
 
@@ -317,16 +317,16 @@ int isp_ioc_cfg_dma(struct isp_ic_dev *dev, void __user *args)
 		REG_ADDR(isp_mi_pp_dma_y_pic_lval), 0, PP_DMA_START_MASK}};
 #endif
 	if (dev == NULL || args == NULL) {
-		pr_info("input wrong parameter %s\n", __func__);
+		isp_info("input wrong parameter %s\n", __func__);
 		return -1;
 	}
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	viv_check_retval(copy_from_user(&dma, args, sizeof(dma)));
 	id = dma.id;
 	if ( id > ISP_MI_DMA_ID_MAX){
-		pr_info("id config wrong %s\n", __func__);
+		isp_info("id config wrong %s\n", __func__);
 		return -1;
 	}
 	path_fmt = isp_read_reg(dev,  dma_path_ctx[id].fmt_addr);
@@ -466,11 +466,11 @@ int isp_ioc_start_dma_read(struct isp_ic_dev *dev, void __user *args)
 	 u32 mi_hdr_ret_ctrl;
 	 u32 rd_wr_str;
 	if (dev == NULL || args == NULL) {
-		pr_info("input wrong parameter %s\n", __func__);
+		isp_info("input wrong parameter %s\n", __func__);
 		return -1;
 	}
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	viv_check_retval(copy_from_user(&dma_path, args, sizeof(dma_path)));
 	if (dma_path == ISP_MI_DMA_PATH_MCM_PP) {
 #ifndef ISP_MI_PP_READ
@@ -661,7 +661,7 @@ struct miv2_path_address {
 static void disable_bus_timeo_intr(struct isp_ic_dev *dev, u32 bus_addr)
 {
 	u32 val;
-	pr_info("%s  bus timeo interrupt register addr 0x%08x\n", __func__, bus_addr);
+	isp_info("%s  bus timeo interrupt register addr 0x%08x\n", __func__, bus_addr);
 	val = isp_read_reg(dev, bus_addr);
 	REG_SET_SLICE(val, MP_BUS_TIMEO_INTERRUPT_DISABLE, 1);
 	isp_write_reg(dev, bus_addr, val);
@@ -669,11 +669,11 @@ static void disable_bus_timeo_intr(struct isp_ic_dev *dev, u32 bus_addr)
 
 static void set_qos(struct isp_ic_dev *dev)
 {
-	pr_info("isp %s enter\n", __func__);
+	isp_info("isp %s enter\n", __func__);
 
 	isp_write_reg(dev, 0x1308, MI_QOS);
 	isp_write_reg(dev, 0x130C, MI_QOS2);
-	pr_info("isp %s exit\n", __func__);
+	isp_info("isp %s exit\n", __func__);
 }
 
 static void set_data_path(int id, struct isp_mi_data_path_context *path,
@@ -702,6 +702,7 @@ static void set_data_path(int id, struct isp_mi_data_path_context *path,
 #else
 	//id 0 is mp path;id 1 is sp path;id 2 is sp2 path;
 	//id 3 is post process path write;
+
 	struct miv2_path_address  path_list[PATHNUM] = {
 		{
 			REG_ADDR(miv2_mp_bus_cfg), REG_ADDR(miv2_mp_bus_id), REG_ADDR(miv2_mp_bus_timeo), REG_ADDR(miv2_mp_ctrl),
@@ -789,7 +790,7 @@ static void set_data_path(int id, struct isp_mi_data_path_context *path,
 	if (path_list[id].format_conv_ctrl) {
 		conv_format_ctrl = isp_read_reg(dev, path_list[id].format_conv_ctrl);
 	}
-	pr_err("mi %s  id %d  fmt_bit[id].raw_bit 0x%08x miv2_ctrl 0x%08x ", __func__, id, path_list[id].raw_enable_bit, miv2_ctrl);
+	isp_info("mi %s  id %d  fmt_bit[id].raw_bit 0x%08x miv2_ctrl 0x%08x ", __func__, id, path_list[id].raw_enable_bit, miv2_ctrl);
 
 	path_ctrl = isp_read_reg(dev, path_list[id].path_ctrl_addr);
 	switch (path->out_mode) {
@@ -819,41 +820,49 @@ static void set_data_path(int id, struct isp_mi_data_path_context *path,
 	case IC_MI_DATAMODE_RAW10:
 		mi_set_slice(&format, fmt_bit[id].raw_bit, 1);
 		miv2_ctrl |= path_list[id].raw_enable_bit;
-
-		mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, 1);
+		mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, path->raw_is_big_endian);
+		//if (id == ISP_MI_PATH_PP) {
+		//	mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, 0); // RY PP READ didn't cfg raw_swap_bit(pp_rd_swap_y) = 0(default)
+		//} else {
+		//	mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, 1); // MP SP1 SP2 swap words
+		//}
+		
 		break;
 	case IC_MI_DATAMODE_RAW12:
 #ifdef ISP_MI_HDR
 		if (id >= ISP_MI_HDR_L && id <= ISP_MI_HDR_VS) {
 			mi_set_slice(&format, fmt_bit[id].raw_bit, 0);
 			path_ctrl |= path_list[id].raw_enable_bit;
-			//mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, 1);
+			//mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, 0);
 		}
 #endif
-		if (id <= ISP_MI_PATH_PP) {
-			mi_set_slice(&format, fmt_bit[id].raw_bit, 2);
-			miv2_ctrl |= path_list[id].raw_enable_bit;
-			mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, 1);
-		}
+		mi_set_slice(&format, fmt_bit[id].raw_bit, 2);
+		miv2_ctrl |= path_list[id].raw_enable_bit;
+		mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, path->raw_is_big_endian);
+		//if (id == ISP_MI_PATH_PP) {
+		//	mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, 0); // RY PP READ didn't cfg raw_swap_bit(pp_rd_swap_y) = 0(default)
+		//} else {
+		//	mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, 1); // MP SP1 SP2 swap words
+		//}
 		break;
 	case IC_MI_DATAMODE_RAW14:
 		mi_set_slice(&format, fmt_bit[id].raw_bit, 3);
 		miv2_ctrl |= path_list[id].raw_enable_bit;
 
-		mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, 1);
+		mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, path->raw_is_big_endian);
 		break;
 	case IC_MI_DATAMODE_RAW16:
 #ifdef ISP_MI_HDR
 		if (id >= ISP_MI_HDR_L && id <= ISP_MI_HDR_VS) {
 			mi_set_slice(&format, fmt_bit[id].raw_bit, 1);
 			path_ctrl |= path_list[id].raw_enable_bit;
-			//mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, 1);
+			//mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, path->raw_is_big_endian);
 		}
 #endif
 		if (id <= ISP_MI_PATH_PP) {
 			mi_set_slice(&format, fmt_bit[id].raw_bit, 4);
 			miv2_ctrl |= path_list[id].raw_enable_bit;
-			mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, 1);
+			mi_set_slice(&bus_cfg, path_list[id].wr_raw_swap_bit, path->raw_is_big_endian);
 		}
 		break;
 	case IC_MI_DATAMODE_RGB888:
@@ -863,7 +872,7 @@ static void set_data_path(int id, struct isp_mi_data_path_context *path,
 		miv2_ctrl |= path_list[id].ycbcr_enable_bit;
 		break;
 	default:
-		pr_err("mi %s unsupport format: %d", __func__, path->out_mode);
+		isp_err("mi %s unsupport format: %d", __func__, path->out_mode);
 		return;
 	}
 
@@ -972,7 +981,7 @@ static void set_data_path(int id, struct isp_mi_data_path_context *path,
 		// if (line_num != 0) {
 		// 	y_llength = y_llength & 0xff ? (y_llength & 0xffffff00 + 0x100):y_llength;
 		// }
-		pr_info("%s:line_num = %d y_llength = 0x%x\n", __func__, line_num, y_llength);
+		isp_info("%s:line_num = %d y_llength = 0x%x\n", __func__, line_num, y_llength);
 		isp_write_reg(dev, REG_ADDR(isp_mi_pp_y_llength), y_llength);
 		isp_write_reg(dev, path_list[id].raw_pic_size_addr, path->out_height * y_llength );
 #else
@@ -1014,7 +1023,7 @@ static void set_data_path(int id, struct isp_mi_data_path_context *path,
 	}
 #endif
 
-	pr_info("%s:path_ctrl 0x%08x\n", __func__, path_ctrl);
+	isp_info("%s:path_ctrl 0x%08x\n", __func__, path_ctrl);
 	acq_proc = isp_read_reg(dev, REG_ADDR(isp_acq_prop));
 	isp_write_reg(dev, REG_ADDR(isp_acq_prop),
 		      acq_proc & ~MRV_ISP_LATENCY_FIFO_SELECTION_MASK);
@@ -1074,7 +1083,7 @@ int isp_mi_start(struct isp_ic_dev *dev)
 	int i;
 	struct isp_mi_context mi = *(&dev->mi);
 	u32 imsc, miv2_mcm_bus_id;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	miv2_mcm_bus_id = isp_read_reg(dev, REG_ADDR(miv2_mcm_bus_id));
 	miv2_mcm_bus_id |= MCM_BUS_SW_EN_MASK;
@@ -1109,7 +1118,8 @@ int isp_mi_start(struct isp_ic_dev *dev)
 
 
 	//isp_write_reg(dev, REG_ADDR(miv2_imsc1), 0x7ffffff);
-	isp_write_reg(dev, REG_ADDR(miv2_imsc1), 0);
+	isp_write_reg(dev, REG_ADDR(miv2_imsc1), (MI_MP_BUS_TIMEO_MASK | MI_SP1_BUS_TIMEO_MASK | MI_SP2_BUS_TIMEO_MASK |
+		MI_MP_BUS_BUSERR_MASK | MI_SP1_BUS_BUSERR_MASK | MI_SP2_BUS_BUSERR_MASK));
 #ifdef ISP_MI_PP_WRITE
 	imsc = isp_read_reg(dev, REG_ADDR(miv2_imsc2));
     if (line_num == 0) {
@@ -1141,7 +1151,7 @@ int isp_mi_start(struct isp_ic_dev *dev)
 
 int isp_mi_stop(struct isp_ic_dev *dev)
 {
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 #ifdef ISP_MI_PP_WRITE
 	isp_write_reg(dev, REG_ADDR(miv2_imsc2), 0);
 #endif
@@ -1171,25 +1181,25 @@ int isp_set_bp_buffer(struct isp_ic_dev *dev, struct isp_bp_buffer_context *buf)
 int  isp_set_ppw_line_num(struct isp_ic_dev *dev)
 {
 	if (dev == NULL) {
-		pr_err("Wrong input %s\n", __func__);
+		isp_err("Wrong input %s\n", __func__);
 		return -1;
 	}
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	isp_write_reg(dev, REG_ADDR(mi_sp1_ppw_ycbcr_entry_line_num), dev->pp_write.entry_line_num);
-	pr_info("exit %s\n", __func__);
+	isp_info("exit %s\n", __func__);
 	return 0;
 }
 int  isp_get_ppw_pic_cnt(struct isp_ic_dev *dev, u16* pic_cnt)
 {
 
 	if (dev == NULL) {
-		pr_err("Wrong input %s\n", __func__);
+		isp_err("Wrong input %s\n", __func__);
 		return -1;
 	}
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	*pic_cnt = isp_read_reg(dev, REG_ADDR(mi_sp1_ppw_ycbcr_entry_pic_cnt));
-	pr_info("exit %s\n", __func__);
+	isp_info("exit %s\n", __func__);
 	return 0;
 }
 #endif
@@ -1200,13 +1210,13 @@ int  isp_cfg_pp_dma_line_entry(struct isp_ic_dev *dev)
 {
 	pp_dma_line_entry_t* pp_dam_line_entry = &dev->pp_dma_line_entry;
 	if (dev == NULL) {
-		pr_err("Wrong input %s\n", __func__);
+		isp_err("Wrong input %s\n", __func__);
 		return -1;
 	}
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	isp_write_reg(dev, REG_ADDR(mi_pp_dma_y_entry_line_num), pp_dam_line_entry->entry_line_num);
 	isp_write_reg(dev, REG_ADDR(mi_pp_dma_y_buf_line_num), pp_dam_line_entry->buf_line_num);
-	pr_info("exit %s\n", __func__);
+	isp_info("exit %s\n", __func__);
 	return 0;
 }
 #endif

+ 30 - 16
vvcam/isp/isp_rgbgamma.c

@@ -67,11 +67,15 @@ int isp_enable_rgbgamma(struct isp_ic_dev *dev)
 	pr_err("unsupported function %s\n", __func__);
 	return -1;
 #else
-
+	if (dev->rgbgamma.changed) {
 	u32 isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl));
 
 	REG_SET_SLICE(isp_ctrl, ISP_RGBGC_ENABLE, 1);
-	isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl);
+	isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl); 
+	dev->rgbgamma.changed = false;
+	} else {
+		dev->rgbgamma.changed = true;
+	}
 	dev->rgbgamma.enable = true;
 	return 0;
 #endif
@@ -83,11 +87,15 @@ int isp_disable_rgbgamma(struct isp_ic_dev *dev)
 	pr_err("unsupported function %s\n", __func__);
 	return -1;
 #else
-	u32 isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl));
-
-	REG_SET_SLICE(isp_ctrl, ISP_RGBGC_ENABLE, 0);
-	isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl);
-
+	if (dev->rgbgamma.changed) {
+		u32 isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl));
+
+		REG_SET_SLICE(isp_ctrl, ISP_RGBGC_ENABLE, 0);
+		isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl);
+		dev->rgbgamma.changed = false;
+	} else {
+		dev->rgbgamma.enable = true;
+	}
 	dev->rgbgamma.enable = false;
 	return 0;
 #endif
@@ -193,23 +201,29 @@ static int isp_s_rgbgammaWriteData(struct isp_ic_dev *dev,
 }
 #endif
 
-int isp_s_rgbgamma(struct isp_ic_dev *dev, struct isp_rgbgamma_data *data)
+int isp_s_rgbgamma(struct isp_ic_dev *dev)
 {
 #ifndef ISP_RGBGC
 	pr_err("unsupported function %s", __func__);
 	return -1;
 #else
 	u8 ret;
-	u32 isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl));
+	if (dev->rgbgamma.data_changed) {
+		u32 isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl));
 
-	REG_SET_SLICE(isp_ctrl, ISP_RGBGC_ENABLE, 0);
-	isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl);
+		//REG_SET_SLICE(isp_ctrl, ISP_RGBGC_ENABLE, 0);
+		//isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl);
 
-	isp_s_rgbgammapx(dev, data);
-	isp_s_rgbgammaWriteData(dev, data);
-	ret = 0;
-	if (dev->rgbgamma.enable) {
-		 ret = isp_enable_rgbgamma(dev);
+		isp_s_rgbgammapx(dev, dev->rgbgamma.data);
+		isp_s_rgbgammaWriteData(dev, dev->rgbgamma.data);
+		ret = 0;
+		if (dev->rgbgamma.enable) {
+			ret = isp_enable_rgbgamma(dev);
+		}
+		dev->rgbgamma.data_changed = false;
+		kfree(dev->rgbgamma.data);
+	} else {
+		dev->rgbgamma.data_changed = true;
 	}
     return ret;
 #endif

+ 20 - 20
vvcam/isp/isp_tdnr3.c

@@ -73,7 +73,7 @@ int isp_tdnr_cfg_gamma(struct isp_ic_dev *dev)
 	//const u8 tdnrRegGap = 8;
 	bit_width = 12;
 
-    //pr_info("enter %s\n", __func__);
+    //isp_info("enter %s\n", __func__);
 
 	for (i = 0; i < DENOISE3D_GAMMA_BIN - 3; i += 5)
 	{
@@ -117,7 +117,7 @@ int  isp_s_tdnr(struct isp_ic_dev *dev)
 	/* spacial */
 	u32 strength = tdnr->strength;
 
-    //pr_info("enter %s\n", __func__);
+    //isp_info("enter %s\n", __func__);
 	strength = MIN(MAX(strength, 0), 128);
 
 	isp_denoise3d2_ctrl = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
@@ -134,7 +134,7 @@ int  isp_s_tdnr(struct isp_ic_dev *dev)
 		isp_write_reg(dev, REG_ADDR(isp_denoise3d2_strength), strength);
 	} else {
 		isp_write_reg(dev, REG_ADDR(isp_denoise3d2_strength), 0);
-		if (dev->tdnr.frames == 2) 
+		if (dev->tdnr.frames == 2)
 			return 0 ;
 	}
 #endif
@@ -213,7 +213,7 @@ int isp_tdnr_set_strength(struct isp_ic_dev *dev)
 {
 	u32 isp_denoise3d2_strength;
 	struct isp_tdnr_context *tdnr = &dev->tdnr;
-	//pr_info("enter %s\n", __func__);
+	//isp_info("enter %s\n", __func__);
 
 	isp_denoise3d2_strength = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_strength));
 	REG_SET_SLICE(isp_denoise3d2_strength, DENOISE3D_V20_TNR_STRENGTH, tdnr->strength);
@@ -227,7 +227,7 @@ int isp_tdnr_set_motion(struct isp_ic_dev *dev)
 {
 	struct isp_tdnr_context *tdnr = &dev->tdnr;
 	u32 isp_denoise3d2_motion_inv;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	isp_denoise3d2_motion_inv = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_motion_inv));
 	REG_SET_SLICE(isp_denoise3d2_motion_inv, DENOISE3D_V20_MOTION_INV, tdnr->motion_inv_factor);
@@ -240,7 +240,7 @@ int isp_tdnr_enable(struct isp_ic_dev *dev)
 {
 	u32 regVal = 0;
 	u32 strength = dev->tdnr.strength;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
 	REG_SET_SLICE(regVal, DENOISE3D_V20_ENABLE, 1);
 	// REG_SET_SLICE(regVal, DENOISE3D_V20_REF_RESET, 1);
@@ -258,7 +258,7 @@ int isp_tdnr_disable(struct isp_ic_dev *dev)
 {
 	u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
 	// REG_SET_SLICE(regVal, DENOISE3D_V20_ENABLE, 0);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d2_ctrl), regVal);
@@ -273,7 +273,7 @@ int isp_tdnr_enable_tdnr(struct isp_ic_dev *dev)
 {
 	u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
 	REG_SET_SLICE(regVal, DENOISE3D_V20_TNR_ENABLE, 1);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d2_ctrl), regVal);
@@ -287,7 +287,7 @@ int isp_tdnr_disable_tdnr(struct isp_ic_dev *dev)
 {
 	u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
 	REG_SET_SLICE(regVal, DENOISE3D_V20_TNR_ENABLE, 0);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d2_ctrl), regVal);
@@ -300,7 +300,7 @@ int isp_tdnr_enable_2dnr(struct isp_ic_dev *dev)
 {
 	//u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	/*regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
 	REG_SET_SLICE(regVal, DENOISE3D_V20_NLM_ENABLE, 1);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d2_ctrl), regVal);*/
@@ -314,7 +314,7 @@ int isp_tdnr_disable_2dnr(struct isp_ic_dev *dev)
 {
 	//u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	/*regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
 	REG_SET_SLICE(regVal, DENOISE3D_V20_NLM_ENABLE, 0);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d2_ctrl), regVal);*/
@@ -327,7 +327,7 @@ int isp_tdnr_disable_2dnr(struct isp_ic_dev *dev)
 
 int isp_tdnr_g_stats(struct isp_ic_dev *dev, struct isp_tdnr_stats *stats)
 {
-	//pr_info("enter %s\n", __func__);
+	//isp_info("enter %s\n", __func__);
 	if (!dev || !stats) {
 		return -EINVAL;
 	}
@@ -344,7 +344,7 @@ int isp_tdnr_u_noise(struct isp_ic_dev *dev)
 {
 	u32 regVal = 0;
 	struct isp_tdnr_context *tdnr = &dev->tdnr;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	regVal = 0;
 	REG_SET_SLICE(regVal, DENOISE3D_V20_NOISE_LEVEL, tdnr->noise_level);
@@ -364,7 +364,7 @@ int isp_tdnr_u_thr(struct isp_ic_dev *dev)
 {
 	u32 regVal = 0;
 	struct isp_tdnr_context *tdnr = &dev->tdnr;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	regVal = 0;
 	REG_SET_SLICE(regVal, DENOISE3D_V20_THR_UPDATE, tdnr->update_factor);
@@ -388,7 +388,7 @@ int isp_tdnr_s_buf(struct isp_ic_dev *dev)
 	u32 miv2_imsc = isp_read_reg(dev, REG_ADDR(miv2_imsc));
 	u32 miv2_sp2_ctrl = isp_read_reg(dev, REG_ADDR(miv2_sp2_ctrl));
 	u32 isp_mi_sp2_raw2_ctrl = isp_read_reg(dev, REG_ADDR(isp_mi_sp2_raw2_ctrl));
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	/*
 
@@ -427,7 +427,7 @@ int isp_tdnr_s_buf(struct isp_ic_dev *dev)
 	in_height /= 2;
 	lval = (in_width); // RAW8 output
 	size = in_height * lval;
-	pr_info("%s 0x%08x\n", __func__, REG_ADDR(isp_mi_sp2_raw2_base_ad_init));
+	isp_info("%s 0x%08x\n", __func__, REG_ADDR(isp_mi_sp2_raw2_base_ad_init));
 	isp_write_reg(dev, REG_ADDR(isp_mi_sp2_raw2_base_ad_init), buf->pa_motion);
 	isp_write_reg(dev, REG_ADDR(isp_mi_sp2_raw2_size_init), size);
 	isp_write_reg(dev, REG_ADDR(isp_mi_sp2_raw2_offs_cnt_init), 0);
@@ -510,7 +510,7 @@ int isp_r_tdnr_refer(struct isp_ic_dev *dev)
 	u32 miv2_imsc = isp_read_reg(dev, REG_ADDR(miv2_imsc));
 	u32 miv2_sp2_ctrl = isp_read_reg(dev, REG_ADDR(miv2_sp2_ctrl));
 	u32 isp_mi_sp2_raw2_ctrl = isp_read_reg(dev, REG_ADDR(isp_mi_sp2_raw2_ctrl));
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	isp_write_reg(dev, REG_ADDR(miv2_sp2_dma_raw_pic_start_ad), buf->pa_refer);
 	isp_write_reg(dev, REG_ADDR(isp_mi_sp2_dma_raw2_pic_start_ad), buf->pa_motion);
 
@@ -543,7 +543,7 @@ int isp_r_tdnr_motion(struct isp_ic_dev *dev)
 	struct isp_tdnr_buffer* buf = &dev->tdnr.buf;
 	u32 miv2_ctrl = isp_read_reg(dev, REG_ADDR(miv2_ctrl));
 	u32 isp_mi_sp2_raw2_ctrl = isp_read_reg(dev, REG_ADDR(isp_mi_sp2_raw2_ctrl));
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	isp_write_reg(dev, REG_ADDR(isp_mi_sp2_dma_raw2_pic_start_ad), buf->pa_motion);
 
 	REG_SET_SLICE(miv2_ctrl, SP2_RAW2_RDMA_START, 1);
@@ -559,7 +559,7 @@ int isp_r_tdnr_motion(struct isp_ic_dev *dev)
 int isp_tdnr_s_2dnr(struct isp_ic_dev *dev)
 {
 #ifndef ISP_2DNR_V5
-	pr_info("unsupported function: %s\n", __func__);
+	isp_info("unsupported function: %s\n", __func__);
 	return -EINVAL;
 #else
 	struct isp_2dnr_context *dnr2 = &dev->dnr2;
@@ -636,7 +636,7 @@ int isp_tdnr_s_2dnr(struct isp_ic_dev *dev)
 	REG_SET_SLICE(value, DENOISE3D_V20_ENABLE, 1);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d2_ctrl),
 				value);
-	pr_debug("%s:write isp_denoise3d2_ctrl addr = 0x%08x, value = 0x%08x \n", __func__, REG_ADDR(isp_denoise3d2_ctrl), value);			
+	pr_debug("%s:write isp_denoise3d2_ctrl addr = 0x%08x, value = 0x%08x \n", __func__, REG_ADDR(isp_denoise3d2_ctrl), value);
 
 	pr_debug("exit %s\n", __func__);
 	return 0;

+ 2 - 2
vvcam/isp/isp_wdr.c

@@ -63,7 +63,7 @@ int isp_s_wdr(struct isp_ic_dev *dev)
 {
     isp_wdr_context_t* wdr = &dev->wdr;
 
-    pr_info(" enter %s\n", __func__);
+    isp_info(" enter %s\n", __func__);
 
     /*update wdr configuration  after frame end when isp enable*/
     if (!is_isp_enable(dev) || wdr->changed) {
@@ -81,7 +81,7 @@ int isp_s_wdr(struct isp_ic_dev *dev)
     } else {
         wdr->changed = true;
     }
-    pr_info(" %s wdr.changed %d \n", __func__, wdr->changed);
+    isp_info(" %s wdr.changed %d \n", __func__, wdr->changed);
    	return 0;
 }
 

+ 6 - 6
vvcam/isp/isp_wdr3.c

@@ -114,12 +114,12 @@ static void wdr3_hw_init(struct isp_ic_dev *dev)
 	bool reg_flag = false;
 	int i, pos;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	width = isp_read_reg(dev, REG_ADDR(isp_acq_h_size));
 	height = isp_read_reg(dev, REG_ADDR(isp_acq_v_size));
 
-	pr_info("wdr3 res: %d %d \n", width, height);
+	isp_info("wdr3 res: %d %d \n", width, height);
 	/* firware initilization */
 	slice_pixel_slope_merge = 128;
 	slice_pixel_base_merge = 0;
@@ -417,7 +417,7 @@ static void wdr3_hw_init(struct isp_ic_dev *dev)
 int isp_enable_wdr3(struct isp_ic_dev *dev)
 {
 #ifndef ISP_WDR_V3
-	pr_err("unsupported function: %s", __func__);
+	isp_err("unsupported function: %s", __func__);
 	return -EINVAL;
 #else
 	struct isp_wdr3_context *wdr3 = &dev->wdr3;
@@ -438,7 +438,7 @@ int isp_enable_wdr3(struct isp_ic_dev *dev)
 int isp_disable_wdr3(struct isp_ic_dev *dev)
 {
 #ifndef ISP_WDR_V3
-	pr_err("unsupported function: %s", __func__);
+	isp_err("unsupported function: %s", __func__);
 	return -EINVAL;
 #else
 	struct isp_wdr3_context *wdr3 = &dev->wdr3;
@@ -459,7 +459,7 @@ int isp_disable_wdr3(struct isp_ic_dev *dev)
 int isp_u_wdr3(struct isp_ic_dev *dev)
 {
 #ifndef ISP_WDR_V3
-	pr_err("unsupported function: %s", __func__);
+	isp_err("unsupported function: %s", __func__);
 	return -EINVAL;
 #else
 	wdr3_hw_init(dev);
@@ -471,7 +471,7 @@ int isp_s_wdr3(struct isp_ic_dev *dev)
 {
 
 #ifndef ISP_WDR_V3
-	pr_err("unsupported function: %s", __func__);
+	isp_err("unsupported function: %s", __func__);
 	return -EINVAL;
 #else
 	struct isp_wdr3_context *wdr3 = &dev->wdr3;

+ 6 - 6
vvcam/isp/isp_wdr4.c

@@ -272,12 +272,12 @@ static void wdr4_hw_init(struct isp_ic_dev *dev)
 	u32 slice_pixel_shift;
 	u32 slice_output_shift;// isp_wdr4_normalize_shift;
 	u32 isp_wdr4_shift;// isp_wdr4_gain_shift_bit;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	width = isp_read_reg(dev, REG_ADDR(isp_acq_h_size));
 	height = isp_read_reg(dev, REG_ADDR(isp_acq_v_size));
 
-	pr_info("isp_wdr4 res: %d %d \n", width, height);
+	isp_info("isp_wdr4 res: %d %d \n", width, height);
 	/* firware initilization */
 
     isp_wdr4_strength = 128;         // valid values: [0,128]; isp_wdr4 will merge original and enhanced image
@@ -429,7 +429,7 @@ static void wdr4_hw_init(struct isp_ic_dev *dev)
 int isp_enable_wdr4(struct isp_ic_dev *dev)
 {
 #ifndef ISP_WDR_V4
-	pr_err("unsupported function: %s", __func__);
+	isp_err("unsupported function: %s", __func__);
 	return -EINVAL;
 #else
 	int32_t isp_wdr4_ctrl;
@@ -449,7 +449,7 @@ int isp_enable_wdr4(struct isp_ic_dev *dev)
 int isp_disable_wdr4(struct isp_ic_dev *dev)
 {
 #ifndef ISP_WDR_V4
-	pr_err("unsupported function: %s", __func__);
+	isp_err("unsupported function: %s", __func__);
 	return -EINVAL;
 #else
 	struct isp_wdr4_context *wdr4 = &dev->wdr4;
@@ -465,7 +465,7 @@ int isp_disable_wdr4(struct isp_ic_dev *dev)
 int isp_u_wdr4(struct isp_ic_dev *dev)
 {
 #ifndef ISP_WDR_V4
-	pr_err("unsupported function: %s", __func__);
+	isp_err("unsupported function: %s", __func__);
 	return -EINVAL;
 #else
 	wdr4_hw_init(dev);
@@ -477,7 +477,7 @@ int isp_s_wdr4(struct isp_ic_dev *dev)
 {
 
 #ifndef ISP_WDR_V4
-	pr_err("unsupported function: %s", __func__);
+	isp_err("unsupported function: %s", __func__);
 	return -EINVAL;
 #else
 	struct isp_wdr4_context *wdr4 = &dev->wdr4;

+ 15 - 1
vvcam/native/dw200/vvcam_dwe_driver.c

@@ -97,6 +97,7 @@ struct vvcam_dwe_driver_dev
 	struct clk *hclk;
 	struct clk *vseclk;
 	struct clk *dweclk;
+	struct task_struct *locker;
 };
 
 struct vvcam_dwe_per_file_dev
@@ -231,6 +232,14 @@ static long vvcam_dwe_ioctl(struct file *file, unsigned int cmd, unsigned long a
 		case DW200IOC_RUNTIME_SUSPEND:
 			pm_runtime_put_sync(dev);
 			break;
+		case DW200IOC_LOCK:
+			mutex_lock(pdwe_dev->vvmutex);
+			pdriver_dev->locker = current;
+			break;
+		case DW200IOC_UNLOCK:
+			mutex_unlock(pdwe_dev->vvmutex);
+			pdriver_dev->locker = NULL;
+			break;
 	}
 	ret =  dw200_priv_ioctl(pdwe_dev, cmd ,(void *)arg);
 	return ret;
@@ -241,7 +250,12 @@ static int vvcam_dwe_release(struct inode * inode, struct file * file)
 	struct vvcam_dwe_per_file_dev *per_file = (struct vvcam_dwe_per_file_dev *)file->private_data;
 	struct dw200_subdev * pdw200;
 	pdw200 = (struct dw200_subdev *)per_file->private;
-	mutex_unlock(pdw200->vvmutex);
+	struct vvcam_dwe_driver_dev *pdriver_dev = per_file->pdriver_dev;
+	struct task_struct *owner =  (struct task_struct *)(atomic_long_read(&pdw200->vvmutex->owner) & ~0x07);
+	if (owner == pdriver_dev->locker && owner != NULL) {
+		printk("unlocked with owner=%p\n", owner);
+		mutex_unlock(pdw200->vvmutex);
+	}
 	/*destory circle queue*/
 	vivdw200_destroy_circle_queue(&(pdw200->dwe_circle_list));
 	vivdw200_destroy_circle_queue(&(pdw200->vse_circle_list));

+ 98 - 48
vvcam/native/flash_led/flash_led_driver.c

@@ -93,9 +93,67 @@ static unsigned int devise_register_index = 0;
 extern int get_ntc_temperature(int mv);
 
 
+static irqreturn_t touch_pin_isr(int irq, void *dev);
+static int flash_pin_init(struct flash_led_ctrl *dev);
+static int touch_pin_uinit(struct flash_led_ctrl *dev);
+
+int flash_led_switch(struct flash_led_ctrl *pflash_led_dev ,uint64_t frame_id)
+{
+
+    struct flash_led_dev *floodlight = &pflash_led_dev->floodlight;
+    struct flash_led_dev *projection = &pflash_led_dev->projection;
+    bool floodlight_on =false;
+    bool projection_on =false;
+    switch(pflash_led_dev->switch_mode)
+    {
+        case  PROJECTION_EVEN_FLOODLIGHT_ODD:
+                    if(frame_id%2)
+                        projection_on = true;
+                    else
+                        floodlight_on =true;
+                    break;
+        case  PROJECTION_ODD_FLOODLIGHT_EVEN:
+                    if(frame_id%2)
+                        floodlight_on = true;
+                    else
+                        projection_on =true;
+                    break;
+        case  PROJECTION_ALWAYS_ON:
+                     projection_on = true;
+                     break;
+        case  FLOODLIGHT_ALWAYS_ON:
+                    floodlight_on =true;
+                    break;
+        case  BOTH_OFF:
+                break;
+        default:
+            pr_warn("invald switch mode:%d\n",pflash_led_dev->switch_mode);
+            return -1;
+    }
+
+    if(projection->flash_led_func)
+    {
+        if(projection_on ==true && (pflash_led_dev->enable & PROJECTION_EN))
+            projection->flash_led_func->enable_channel(projection, 3);
+        else
+             projection->flash_led_func->disable_channel(projection, 3);
+
+    }
+
+    if(floodlight->flash_led_func)
+    {
+        if(floodlight_on == true &&  (pflash_led_dev->enable & FLOODLIGHT_EN))
+            floodlight->flash_led_func->enable_channel(floodlight, 3);
+        else
+            floodlight->flash_led_func->disable_channel(floodlight, 3);
+    }
+    return 0;
+}
+
 static int flash_led_open(struct inode * inode, struct file * file)
 {
     int ret = 0;
+    int irq = 0;
 	struct flash_led_driver_dev *pdriver_dev;
 	struct flash_led_ctrl *pflash_led_dev;
 
@@ -107,6 +165,11 @@ static int flash_led_open(struct inode * inode, struct file * file)
     struct flash_led_dev *floodlight = &pflash_led_dev->floodlight;
     struct flash_led_dev *projection = &pflash_led_dev->projection;
 
+    irq = gpio_to_irq(pflash_led_dev->touch_pin);
+    request_irq(irq, touch_pin_isr, IRQF_TRIGGER_FALLING,
+                "flash led touch pin",
+                pflash_led_dev);
+
     if (floodlight->flash_led_func != NULL) {
         ret = floodlight->flash_led_func->init(floodlight);
         if (ret != 0) {
@@ -121,35 +184,15 @@ static int flash_led_open(struct inode * inode, struct file * file)
 		    pr_err("%s, %d, projection init error\n", __func__, __LINE__);
             return ret;
         }
+
     }
 
 	return 0;
 };
 
-static long flash_led_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	long ret = 0;
-	struct flash_led_driver_dev *pdriver_dev;
-	struct flash_led_ctrl *pflash_led_dev;
-
-	pdriver_dev = file->private_data;
-	if (pdriver_dev == NULL)
-	{
-		pr_err("%s:file private is null point error\n", __func__);
-		return  -ENOMEM;
-	}
-	pflash_led_dev = (struct flash_led_ctrl*)pdriver_dev->private;
-
-	mutex_lock(&pdriver_dev->vvmutex);
-    ret = flash_led_priv_ioctl(pflash_led_dev, cmd, (void __user *)arg);
-	mutex_unlock(&pdriver_dev->vvmutex);
-
-	return ret;
-};
-
 static int flash_led_release(struct inode * inode, struct file * file)
 {
-
+    int irq = -1;
 	struct flash_led_driver_dev *pdriver_dev;
 	pdriver_dev = container_of(inode->i_cdev, struct flash_led_driver_dev, cdev);
     struct flash_led_ctrl *pflash_led_dev = (struct flash_led_ctrl*)pdriver_dev->private;
@@ -157,6 +200,9 @@ static int flash_led_release(struct inode * inode, struct file * file)
     struct flash_led_dev *floodlight = &pflash_led_dev->floodlight;
     struct flash_led_dev *projection = &pflash_led_dev->projection;
 
+    irq = gpio_to_irq(pflash_led_dev->touch_pin);
+    free_irq(irq, pflash_led_dev);
+
     pflash_led_dev->enable = 0;
 
     if (projection->flash_led_func != NULL) {
@@ -170,6 +216,27 @@ static int flash_led_release(struct inode * inode, struct file * file)
 	return 0;
 };
 
+static long flash_led_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+	long ret = 0;
+	struct flash_led_driver_dev *pdriver_dev;
+	struct flash_led_ctrl *pflash_led_dev;
+
+	pdriver_dev = file->private_data;
+	if (pdriver_dev == NULL)
+	{
+		pr_err("%s:file private is null point error\n", __func__);
+		return  -ENOMEM;
+	}
+	pflash_led_dev = (struct flash_led_ctrl*)pdriver_dev->private;
+
+	mutex_lock(&pdriver_dev->vvmutex);
+    ret = flash_led_priv_ioctl(pflash_led_dev, cmd, (void __user *)arg);
+	mutex_unlock(&pdriver_dev->vvmutex);
+
+	return ret;
+};
+
 struct file_operations flash_led_fops = {
 	.owner = THIS_MODULE,
 	.open = flash_led_open,
@@ -355,10 +422,14 @@ static void flash_led_interrupt_func(struct work_struct *work)
     struct flash_led_dev *floodlight = &pflash_led_dev->floodlight;
     struct flash_led_dev *projection = &pflash_led_dev->projection;
     frame_mark_t *frame_mark = pflash_led_dev->frame_mark;
+    uint64_t frame_irq_cnt;
 
     frame_mark->frame_irq_cnt += 1;
-    falling_time_us[frame_mark->frame_irq_cnt % 2] = get_us_time();
-    frame_mark->frame_time_us = falling_time_us[frame_mark->frame_irq_cnt % 2];
+    frame_irq_cnt = frame_mark->frame_irq_cnt;
+
+    frame_mark->frame_time_us =  get_us_time();
+    falling_time_us[frame_irq_cnt % 2] =  frame_mark->frame_time_us;
+
 
     if (!pflash_led_dev->enable) {
         if (projection->flash_led_func != NULL) {
@@ -370,15 +441,9 @@ static void flash_led_interrupt_func(struct work_struct *work)
         }
         return;
     }
+    flash_led_switch(pflash_led_dev,frame_irq_cnt);
+    if ((frame_irq_cnt % 2) == 0) {
 
-    if ((frame_mark->frame_irq_cnt % 2) == 0) {
-        if ((pflash_led_dev->enable & FLOODLIGHT_EN) && floodlight->flash_led_func != NULL) {
-            floodlight->flash_led_func->enable_channel(floodlight, 3);
-        }
-
-        if ((pflash_led_dev->enable & PROJECTION_EN) && projection->flash_led_func != NULL) {
-            projection->flash_led_func->disable_channel(projection, 3);
-        }
         if (!IS_ERR(pflash_led_dev->floodlight_adc)) {
             iio_read_channel_processed(pflash_led_dev->floodlight_adc,
                                            &frame_mark->floodlight_temperature);
@@ -386,13 +451,6 @@ static void flash_led_interrupt_func(struct work_struct *work)
         }
 
     } else {
-        if ((pflash_led_dev->enable & PROJECTION_EN) && projection->flash_led_func != NULL) {
-            projection->flash_led_func->enable_channel(projection, 3);
-        }
-
-        if ((pflash_led_dev->enable & FLOODLIGHT_EN) && floodlight->flash_led_func != NULL) {
-            floodlight->flash_led_func->disable_channel(floodlight, 3);
-        }
 
         if (!IS_ERR(pflash_led_dev->projection_adc)) {
             iio_read_channel_processed(pflash_led_dev->projection_adc,
@@ -413,15 +471,10 @@ static irqreturn_t touch_pin_isr(int irq, void *dev)
 
 static int flash_pin_init(struct flash_led_ctrl *dev)
 {
-    int irq = gpio_to_irq(dev->touch_pin);
     gpio_request(dev->touch_pin, "flash led touch pin");
 
     INIT_WORK(&dev->flash_led_work, flash_led_interrupt_func);
 
-    request_irq(irq, touch_pin_isr, IRQF_TRIGGER_FALLING,
-                "flash led touch pin",
-                dev);
-
     if (dev->floodlight_en_pin != -1) {
         gpio_request(dev->floodlight_en_pin, "floodlight enable pin");
         if (gpio_is_valid(dev->floodlight_en_pin)) {
@@ -441,9 +494,7 @@ static int flash_pin_init(struct flash_led_ctrl *dev)
 
 static int touch_pin_uinit(struct flash_led_ctrl *dev)
 {
-    int irq = gpio_to_irq(dev->touch_pin);
     dev->enable = 0;
-    free_irq(irq, dev);
     cancel_work_sync(&dev->flash_led_work);
     gpio_free(dev->touch_pin);
     return 0;
@@ -511,7 +562,7 @@ static int flash_led_probe(struct platform_device *pdev)
 
 	ret = flash_led_init(pflash_led_dev);
 	if (ret != 0) {
-		pr_err("%s:vvnative_flash_led_init error\n", __func__);
+		pr_warn("%s:vvnative_flash_led_init error\n", __func__);
 	}
 
 	if (devise_register_index == 0) {
@@ -576,7 +627,6 @@ static int flash_led_remove(struct platform_device *pdev)
 	pflash_led_dev = pdriver_dev->private;
 	flash_led_deinit(pflash_led_dev);
     touch_pin_uinit(pflash_led_dev);
-
     dma_free_coherent(&pdev->dev, sizeof(*pflash_led_dev->frame_mark), pflash_led_dev->frame_mark, pflash_led_dev->frame_mark_info_addr);
 
     if (!IS_ERR(pflash_led_dev->projection_adc)) {

+ 5 - 1
vvcam/native/flash_led/flash_led_driver.h

@@ -1,3 +1,6 @@
+/*
+ * @Description: 
+ */
 #ifndef _FLASH_LED_DRIVER_H_
 #define _FLASH_LED_DRIVER_H_
 
@@ -75,6 +78,7 @@ struct flash_led_ctrl {
     struct flash_led_dev projection;
     dma_addr_t frame_mark_info_addr;
     volatile frame_mark_t *frame_mark;
+    flash_led_switch_mod_t  switch_mode;
 };
 
 int flash_led_init(struct flash_led_ctrl *dev);
@@ -82,5 +86,5 @@ int flash_led_deinit(struct flash_led_ctrl *dev);
 long flash_led_priv_ioctl(struct flash_led_ctrl *dev, unsigned int cmd, void __user *args);
 int32_t flash_led_i2c_write(struct flash_led_dev *dev, uint32_t address, uint32_t data);
 int32_t flash_led_i2c_read(struct flash_led_dev *dev, uint32_t address, uint32_t *pdata);
-
+int flash_led_switch(struct flash_led_ctrl *pflash_led_dev ,uint64_t frame_id);
 #endif

+ 19 - 21
vvcam/native/flash_led/flash_led_ioctl.c

@@ -191,6 +191,9 @@ int32_t flash_led_i2c_write(struct flash_led_dev *dev, uint32_t address, uint32_
 	                         address,dev->flash_led_sccb_cfg.addr_byte,
 	                         data,dev->flash_led_sccb_cfg.data_byte);
 
+    if (ret != 0) {
+        printk("%s error\n", __func__);
+    }
 	return ret;
 }
 
@@ -289,6 +292,7 @@ long flash_led_priv_ioctl(struct flash_led_ctrl *dev, unsigned int cmd, void __u
             check_retval(copy_from_user(&flash_led, args, sizeof(flash_led)));
             frame_irq_cnt_clear(dev);
             dev->enable |= flash_led;
+            flash_led_switch(dev,0);
             ret = 0;
             break;
         case FLASH_LED_IOCTL_DISABLE:
@@ -311,6 +315,12 @@ long flash_led_priv_ioctl(struct flash_led_ctrl *dev, unsigned int cmd, void __u
             ret = 0;
         }
             break;
+        case FLASH_LED_IOCTL_SET_SWITCH_MODE: {
+            check_retval(copy_from_user(&dev->switch_mode,args, sizeof(dev->switch_mode)));
+            pr_info("FLASH_LED_IOCTL_SET_SWITCH_MODE 0x%lx\n", dev->switch_mode);
+            ret = 0;
+        }
+            break;
         default:
             printk("%s, %d, flash led cmd error, cmd %u\n", __func__, __LINE__, cmd);
             return -ENOTTY;
@@ -367,20 +377,24 @@ int flash_led_init(struct flash_led_ctrl *dev)
     floodlight->flash_led_sccb_cfg.slave_addr = dev->device_idx+1;
     projection->flash_led_sccb_cfg.slave_addr = dev->device_idx+2;
 
+    floodlight->flash_led_func = NULL;
+    projection->flash_led_func = NULL;
+
     if (floodlight->i2c_bus == UNDEFINED_IN_DTS && projection->i2c_bus == UNDEFINED_IN_DTS) {
-		pr_err("%s, %d, flash_led i2c bus invalid\n",__func__, __LINE__);
+		pr_warn("%s, %d, flash_led i2c bus invalid\n",__func__, __LINE__);
         return -1;
     }
 
-    floodlight->flash_led_func = NULL;
-    projection->flash_led_func = NULL;
-
+    dev->switch_mode = BOTH_OFF;
     if (floodlight->i2c_bus != UNDEFINED_IN_DTS) {
         floodlight->flash_led_func = floodlight_func;
+        dev->switch_mode = FLOODLIGHT_ALWAYS_ON;
     }
 
     if (projection->i2c_bus != UNDEFINED_IN_DTS) {
         projection->flash_led_func = projection_func;
+        dev->switch_mode = dev->switch_mode == FLOODLIGHT_ALWAYS_ON ?
+                                                PROJECTION_EVEN_FLOODLIGHT_ODD:PROJECTION_ALWAYS_ON;
     }
 
     if (floodlight->i2c_bus == projection->i2c_bus) {
@@ -412,23 +426,7 @@ int flash_led_init(struct flash_led_ctrl *dev)
         }
     }
 
-    if (floodlight->flash_led_func != NULL) {
-        ret = floodlight->flash_led_func->init(floodlight);
-        if (ret != 0) {
-		    pr_err("%s, %d, floodlight init error\n", __func__, __LINE__);
-            return ret;
-        }
-    }
-
-    if (projection->flash_led_func != NULL) {
-        ret = projection->flash_led_func->init(projection);
-        if (ret != 0) {
-		    pr_err("%s, %d, projection init error\n", __func__, __LINE__);
-            return ret;
-        }
-    }
-
-    printk("%s,%d, exit\n", __func__, __LINE__);
+    pr_info("%s,%d, exit\n", __func__, __LINE__);
 
 	return ret;
 }

+ 10 - 0
vvcam/native/flash_led/flash_led_ioctl.h

@@ -1,3 +1,4 @@
+
 #ifndef _FLASH_LED_IOCTL_H_
 #define _FLASH_LED_IOCTL_H_
 
@@ -15,6 +16,7 @@
 #define FLASH_LED_IOCTL_ENABLE              _IOWR(FLASH_LED_IOCTL_MAGIC, 8, int)
 #define FLASH_LED_IOCTL_DISABLE             _IOWR(FLASH_LED_IOCTL_MAGIC, 9, int)
 #define FLASH_LED_IOCTL_GET_FRAME_MASK_INFO_ADDR             _IOWR(FLASH_LED_IOCTL_MAGIC, 10, int)
+#define FLASH_LED_IOCTL_SET_SWITCH_MODE             _IOWR(FLASH_LED_IOCTL_MAGIC, 11, int)
 
 struct flash_led_sccb_cfg_s {
 	unsigned char slave_addr;
@@ -43,6 +45,14 @@ typedef enum {
     FLOODLIGHT_PROJECTION_EN = 3,
 } flash_led_enable_mask_t;
 
+typedef enum {
+    PROJECTION_EVEN_FLOODLIGHT_ODD =0,
+    PROJECTION_ODD_FLOODLIGHT_EVEN = 1,
+    PROJECTION_ALWAYS_ON = 2,
+    FLOODLIGHT_ALWAYS_ON = 3,
+    BOTH_OFF =4,
+} flash_led_switch_mod_t;
+
 typedef struct {
     flash_led_type_t type;
     unsigned int offset;

+ 78 - 28
vvcam/native/isp/vvcam_isp_driver_of.c

@@ -180,6 +180,22 @@ static void vvnative_isp_work(struct work_struct *work)
        pisp_dev->gamma_out.changed);
        isp_s_gamma_out(pisp_dev);
     }
+	if (pisp_dev->rgbgamma.data_changed) {
+      //pr_info("%s pisp_dev->rgbgamma.data_changed %d\n", __func__,
+       //pisp_dev->rgbgamma.data_changed);		
+	   isp_s_rgbgamma(pisp_dev);
+	}
+	if (pisp_dev->rgbgamma.changed) {
+		//pr_info("%s pisp_dev->rgbgamma.changed %d\n", __func__,pisp_dev->rgbgamma.changed);		
+		if (pisp_dev->rgbgamma.enable) {
+			isp_enable_rgbgamma(pisp_dev);
+		} else {
+			isp_disable_rgbgamma(pisp_dev);
+		}
+	}
+	if (pisp_dev->dgain.changed) {
+		isp_s_digital_gain(pisp_dev);
+	}
 
   }
 
@@ -189,7 +205,54 @@ static irqreturn_t vvcam_isp_irq(int irq, void *dev_id)
 {
     struct vvcam_isp_driver_dev *pdriver_dev ;
     struct isp_ic_dev * pisp_dev;
-    u32 isp_mis, mi_mis, mi_mis_addr, mi_icr_addr;
+    u64 isp_mis, mi_mis = 0;
+
+    pdriver_dev = (struct vvcam_isp_driver_dev *)dev_id;
+    pisp_dev = pdriver_dev->private;
+    isp_mis = isp_read_reg(pisp_dev, REG_ADDR(isp_mis));
+
+    if (isp_mis & MRV_ISP_MIS_FLASH_ON_MASK) {
+        mi_mis |= 0x4;
+    }
+
+    volatile frame_mark_t *frame_mark = pdriver_dev->frame_mark;
+    if (isp_mis & MRV_ISP_MIS_FRAME_IN_MASK) {
+        frame_mark->frame_time_us = get_us_time();
+        frame_mark->frame_irq_cnt += 1;
+    }
+
+    if (mi_mis) {
+        isp_mis_t mis_data;
+        mis_data.irq_src = SRC_MI_IRQ;
+        mis_data.val = mi_mis;
+        isp_irq_write_circle_queue(&mis_data, &pisp_dev->circle_list);
+    }
+
+    if (isp_mis) {
+        isp_mis_t mis_data;
+        mis_data.irq_src = SRC_ISP_IRQ;
+        mis_data.val = isp_mis;
+        pisp_dev->isp_mis = isp_mis;
+        isp_irq_write_circle_queue(&mis_data, &pisp_dev->circle_list);
+        isp_write_reg(pisp_dev, REG_ADDR(isp_icr), isp_mis);
+        if(isp_mis & MRV_ISP_MIS_ISP_OFF_MASK) {
+            isp_write_reg(pisp_dev, REG_ADDR(isp_imsc), isp_read_reg(pisp_dev, REG_ADDR(isp_imsc))&(~MRV_ISP_MIS_ISP_OFF_MASK));
+        }
+    }
+
+    if (isp_mis != 0 ||mi_mis != 0 ) {
+        schedule_work(&pdriver_dev->vvnative_wq);
+    } else {
+    return IRQ_HANDLED; // return IRQ_NONE;
+    }
+    return IRQ_HANDLED;
+}
+
+static irqreturn_t vvcam_mi_irq(int irq, void *dev_id)
+{
+    struct vvcam_isp_driver_dev *pdriver_dev ;
+    struct isp_ic_dev * pisp_dev;
+    u32 mi_mis, mi_mis_addr, mi_icr_addr;
 #ifdef ISP_MIV2
     u32 miv2_mis1, miv2_mis3;
 #endif
@@ -198,7 +261,6 @@ static irqreturn_t vvcam_isp_irq(int irq, void *dev_id)
 #endif
     pdriver_dev = (struct vvcam_isp_driver_dev *)dev_id;
     pisp_dev = pdriver_dev->private;
-    isp_mis = isp_read_reg(pisp_dev, REG_ADDR(isp_mis));
 
 #ifdef ISP_MIV2
     mi_icr_addr = REG_ADDR(miv2_icr);
@@ -229,15 +291,6 @@ static irqreturn_t vvcam_isp_irq(int irq, void *dev_id)
     /*pr_info("%s isp mis 0x%08x, mi mis 0x%08x\n", __func__,  \
         isp_mis, mi_mis);*/
 #endif
-    if (isp_mis & MRV_ISP_MIS_FLASH_ON_MASK) {
-        mi_mis |= 0x4;
-    }
-
-    volatile frame_mark_t *frame_mark = pdriver_dev->frame_mark;
-    if (isp_mis & MRV_ISP_MIS_FRAME_IN_MASK) {
-        frame_mark->frame_time_us = get_us_time();
-        frame_mark->frame_irq_cnt += 1;
-    }
 
     if (mi_mis) {
         isp_mis_t mis_data;
@@ -267,26 +320,15 @@ static irqreturn_t vvcam_isp_irq(int irq, void *dev_id)
         isp_write_reg(pisp_dev, REG_ADDR(miv2_icr2), miv2_mis2);
     }
 #endif
-    if (isp_mis) {
-        isp_mis_t mis_data;
-        mis_data.irq_src = SRC_ISP_IRQ;
-        mis_data.val = isp_mis;
-        pisp_dev->isp_mis = isp_mis;
-        isp_irq_write_circle_queue(&mis_data, &pisp_dev->circle_list);
-        isp_write_reg(pisp_dev, REG_ADDR(isp_icr), isp_mis);
-        if(isp_mis & MRV_ISP_MIS_ISP_OFF_MASK) {
-            isp_write_reg(pisp_dev, REG_ADDR(isp_imsc), isp_read_reg(pisp_dev, REG_ADDR(isp_imsc))&(~MRV_ISP_MIS_ISP_OFF_MASK));
-        }
-    }
 
 #if defined(ISP_MI_PP_READ) || defined (ISP_3DNR_V3) || defined (ISP_MI_PP_WRITE) ||  defined (ISP_MI_HDR)
-    if (isp_mis != 0 ||mi_mis != 0 || miv2_mis2 != 0) {
+    if (mi_mis != 0 || miv2_mis2 != 0) {
 #else
-    if (isp_mis != 0 ||mi_mis != 0 ) {
+    if (mi_mis != 0 ) {
 #endif
         schedule_work(&pdriver_dev->vvnative_wq);
     } else {
-    return IRQ_HANDLED; // return IRQ_NONE;
+        return IRQ_HANDLED;
     }
     return IRQ_HANDLED;
 }
@@ -410,7 +452,7 @@ static int vvcam_isp_release(struct inode * inode, struct file * file)
 	struct vvcam_isp_driver_dev *pdriver_dev;
 	struct isp_ic_dev *pisp_dev;
 	if ((inode == NULL) || (file == NULL) ) {
-		printk("%s: %dx\n", __func__, __LINE__);
+		pr_info("%s: %dx\n", __func__, __LINE__);
 		return 0;
 	}
 
@@ -421,6 +463,13 @@ static int vvcam_isp_release(struct inode * inode, struct file * file)
 	pr_info("enter %s\n", __func__);
 	isp_irq_destroy_circle_queue(&(pisp_dev->circle_list));
 
+    if (pisp_dev->ut_addr != NULL) {
+        #define UT_USED_SIZE 0x01000000
+        dma_free_coherent(dev, UT_USED_SIZE,
+                          pisp_dev->ut_addr, pisp_dev->ut_phy_addr);
+        pisp_dev->ut_addr = NULL;
+    }
+
 	ret = pm_runtime_put_sync(dev);
 	if (ret) {
 		pr_err("fail to suspen isp %s %d ret = %d\n", __func__, __LINE__, ret);
@@ -512,7 +561,7 @@ static int vvcam_isp_probe(struct platform_device *pdev)
         return -1;
     }
 
-    printk("isp_frame_mark_info_addr = 0x%lx\n", pisp_dev->frame_mark_info_addr);
+    pr_info("isp_frame_mark_info_addr = 0x%lx\n", pisp_dev->frame_mark_info_addr);
 
     memset(frame_mark, 0, sizeof(frame_mark_t));
     pdriver_dev->frame_mark = frame_mark;
@@ -545,7 +594,7 @@ static int vvcam_isp_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	ret = devm_request_irq(&pdev->dev, pdriver_dev->irq_num[1], vvcam_isp_irq,
+	ret = devm_request_irq(&pdev->dev, pdriver_dev->irq_num[1], vvcam_mi_irq,
 		IRQF_TRIGGER_RISING, "MI_IRQ", (char *)pdriver_dev);
 	if (ret) {
 		pr_err("%s[%d]:request irq error!\n", __func__, __LINE__);
@@ -658,6 +707,7 @@ static int vvcam_isp_remove(struct platform_device *pdev)
         #define UT_USED_SIZE 0x01000000
         dma_free_coherent(&pdev->dev, UT_USED_SIZE,
                           pisp_dev->ut_addr, pisp_dev->ut_phy_addr);
+        pisp_dev->ut_addr =NULL;
     }
 
 	free_irq(pdriver_dev->irq_num[0], pdriver_dev);

+ 40 - 10
vvcam/native/sensor/platform/platform_gen6_driver.c

@@ -66,6 +66,16 @@ int32_t sensor_reset(void *dev)
 	int ret = 0;
 	struct vvcam_sensor_dev *psensor_dev = (struct vvcam_sensor_dev *)dev;
 
+    if (gpio_is_valid(psensor_dev->rst_pin)) {
+		gpio_direction_output(psensor_dev->rst_pin, 0);
+    }
+
+    if (gpio_is_valid(psensor_dev->pdn_pin)) {
+		gpio_direction_output(psensor_dev->pdn_pin, 0);
+	}
+
+    udelay(10000);
+
 	if (gpio_is_valid(psensor_dev->rst_pin)) {
 		gpio_direction_output(psensor_dev->rst_pin, 1);
     }
@@ -90,7 +100,8 @@ int32_t sensor_get_clk(void *dev, uint32_t *pclk)
 
 int32_t sensor_set_power(void *dev, uint32_t power)
 {
-	int ret = 0, i = 0;
+	int ret = 0, i = 0, set_volt = 0;
+
 	struct vvcam_sensor_dev *psensor_dev = (struct vvcam_sensor_dev *)dev;
 	printk("sensor_set_power enter, power=%d\n", power);
 
@@ -100,19 +111,38 @@ int32_t sensor_set_power(void *dev, uint32_t power)
 	}
 
 	for (i = 0; i < psensor_dev->regulators.num; i++) {
-        if (gpio_is_valid(psensor_dev->rst_pin)) {
-            gpio_direction_output(psensor_dev->rst_pin, 0); // make sure reset is low before power up
-        }
-
-        if (gpio_is_valid(psensor_dev->pdn_pin)) {
-		    gpio_direction_output(psensor_dev->pdn_pin, 0);
-        }
-
+		if (gpio_is_valid(psensor_dev->rst_pin)) {
+			gpio_direction_output(psensor_dev->rst_pin, 0); // make sure reset is low before power up
+		}
+		if (gpio_is_valid(psensor_dev->pdn_pin)) {
+			gpio_direction_output(psensor_dev->pdn_pin, 0);
+		}
 		if (power == 1) {
+			if(psensor_dev->regulators.supply[i] == NULL) {
+				psensor_dev->regulators.supply[i] = devm_regulator_get(psensor_dev->dev, psensor_dev->regulators.name[i]);
+			}
+
+			if(psensor_dev->regulators.voltage[i] != 0) {
+				ret = regulator_set_voltage_tol(psensor_dev->regulators.supply[i], psensor_dev->regulators.voltage[i], 0);
+				if(ret != 0){
+					pr_err("fail to set voltage to %s\n", psensor_dev->regulators.name[i] );
+					return -1;
+				}
+				set_volt = regulator_get_voltage(psensor_dev->regulators.supply[i]);
+				pr_info("%s set regulator %s to %d uV\n",psensor_dev->sensor_name, psensor_dev->regulators.name[i], set_volt );
+			}
 			ret = regulator_enable(psensor_dev->regulators.supply[i]);
-			printk("regulator_enable ret=%d\n", ret);
 		} else if (power == 0) {
+			if (psensor_dev->regulators.supply[i] == NULL) {
+				pr_info("the supply already is null\n");
+				return 0;
+			}
+			pr_info("%s disable regulator %s \n",psensor_dev->sensor_name, psensor_dev->regulators.name[i] );
 			ret = regulator_disable(psensor_dev->regulators.supply[i]);
+			if (ret == 0) {
+				devm_regulator_put(psensor_dev->regulators.supply[i]);
+				psensor_dev->regulators.supply[i] = NULL;
+			}
 		} else {
 			return -1;
 		}

+ 8 - 0
vvcam/native/sensor/sensor_common.h

@@ -80,6 +80,7 @@ struct vvcam_sensor_driver_dev
 	dev_t devt;
 	struct class *class;
 	struct mutex vvmutex;
+    struct platform_device *pdev;
 	void *private;
 };
 
@@ -107,11 +108,13 @@ struct vvcam_sensor_function_s
 struct vvcam_sensor_regulators {
 	struct regulator *supply[VVCAM_SENSOR_MAX_REGULATORS];
 	const char *name[VVCAM_SENSOR_MAX_REGULATORS];
+	unsigned int voltage[VVCAM_SENSOR_MAX_REGULATORS];
 	unsigned int delay_us[VVCAM_SENSOR_MAX_REGULATORS];
 	int num;
 };
 
 struct vvcam_sensor_dev {
+	struct device* dev;
 	long phy_addr;
 	long reg_size;
 	void __iomem *base;
@@ -128,8 +131,13 @@ struct vvcam_sensor_dev {
     const char *sensor_name;
 	struct vvcam_sensor_regulators regulators;
 	int pdn_pin;
+	int pdn_pin_is_busy;
 	unsigned int pdn_delay_us;
 	int rst_pin;
+	int rst_pin_is_busy;
+
+    wait_queue_head_t err_wait;
+    int err_mask;
 };
 
 extern int32_t sensor_reset(void *dev);

+ 37 - 6
vvcam/native/sensor/sensor_ioctl.c

@@ -171,6 +171,7 @@ static int vvcam_i2c_read_reg(struct i2c_client *client,unsigned int slave_addre
 int32_t vvcam_sensor_i2c_write(struct vvcam_sensor_dev *dev, uint32_t address, uint32_t data)
 {
 	int32_t ret = 0;
+    int cnt = 10;
 	struct vvcam_sccb_data;
 
 	if((NULL == dev))
@@ -178,9 +179,23 @@ int32_t vvcam_sensor_i2c_write(struct vvcam_sensor_dev *dev, uint32_t address, u
 		return -1;
 	}
 
-	ret = vvcam_i2c_write_reg(dev->i2c_client,dev->sensor_sccb_cfg.slave_addr,
+
+    while(cnt > 0) {
+	    ret = vvcam_i2c_write_reg(dev->i2c_client,dev->sensor_sccb_cfg.slave_addr,
 	                         address,dev->sensor_sccb_cfg.addr_byte,
 	                         data,dev->sensor_sccb_cfg.data_byte);
+        if(ret == 0) {
+            break;
+        }
+        mdelay(10);
+        cnt--;
+    }
+
+    if (ret != 0) {
+        dev->err_mask = 1;
+        wake_up(&dev->err_wait);
+        pr_warn("warn: sensor %s i2c write failed\n", dev->sensor_name);
+    }
 
 	return ret;
 }
@@ -188,6 +203,7 @@ int32_t vvcam_sensor_i2c_write(struct vvcam_sensor_dev *dev, uint32_t address, u
 int32_t vvcam_sensor_i2c_read(struct vvcam_sensor_dev *dev, uint32_t address, uint32_t *pdata)
 {
 	int32_t ret = 0;
+    int cnt = 10;
 	struct vvcam_sccb_data;
 
 	if((NULL == dev))
@@ -195,9 +211,22 @@ int32_t vvcam_sensor_i2c_read(struct vvcam_sensor_dev *dev, uint32_t address, ui
 		return -1;
 	}
 
-	ret = vvcam_i2c_read_reg(dev->i2c_client,dev->sensor_sccb_cfg.slave_addr,
-	                         address, dev->sensor_sccb_cfg.addr_byte,
-	                         (unsigned char *)pdata, dev->sensor_sccb_cfg.data_byte);
+    while(cnt > 0) {
+	    ret = vvcam_i2c_read_reg(dev->i2c_client,dev->sensor_sccb_cfg.slave_addr,
+	            address, dev->sensor_sccb_cfg.addr_byte,
+	            (unsigned char *)pdata, dev->sensor_sccb_cfg.data_byte);
+        if(ret == 0) {
+            break;
+        }
+        mdelay(10);
+        cnt--;
+    }
+
+    if (ret != 0) {
+        dev->err_mask = 2;
+        wake_up(&dev->err_wait);
+        pr_warn("warn: sensor %s i2c read failed\n", dev->sensor_name);
+    }
 
 	return ret;
 }
@@ -235,7 +264,10 @@ static int32_t vvcam_sensor_i2c_write_array(struct vvcam_sensor_dev *dev, void _
 #endif
 
             if (ret != 0) {
-                printk("<0>""!!!!!!!write array error, sccb_data.addr: 0x%x, sccb_data.data: 0x%x\n", sccb_data.addr, sccb_data.data);
+                pr_err("sensor %s write array error, sccb_data.addr: 0x%x, sccb_data.data: 0x%x\n",\
+                        dev->sensor_name, sccb_data.addr, sccb_data.data);
+                dev->err_mask = 1;
+                wake_up(&dev->err_wait);
 			    return ret;
             }
 		}
@@ -317,7 +349,6 @@ long sensor_priv_ioctl(struct vvcam_sensor_dev *dev, unsigned int cmd, void __us
 		return ret;
 	}
 
-	//printk("-->%s: cmd = %d!\n", __func__,cmd);
 	switch (cmd)
 	{
 		case VVSENSORIOC_RESET:

+ 104 - 27
vvcam/native/sensor/vvcam_sensor_driver.c

@@ -65,6 +65,7 @@
 #include <linux/miscdevice.h>
 #include <linux/uaccess.h>
 #include <linux/regulator/consumer.h>
+#include <linux/poll.h>
 
 #include "vvsensor.h"
 #include "sensor_common.h"
@@ -80,13 +81,37 @@ static unsigned int devise_register_index = 0;
 
 static int vvcam_sensor_open(struct inode * inode, struct file * file)
 {
+
+    int ret = 0;
 	struct vvcam_sensor_driver_dev *pdriver_dev;
+	struct vvcam_sensor_dev * psensor_dev;
 
 	pdriver_dev = container_of(inode->i_cdev, struct vvcam_sensor_driver_dev, cdev);
 	file->private_data = pdriver_dev;
+	psensor_dev = pdriver_dev->private;
+    pr_debug("%s, enter: vvcam%d \n", __func__, psensor_dev->device_idx);
+
+    if (gpio_is_valid(psensor_dev->rst_pin) && !psensor_dev->rst_pin_is_busy) {
+        ret = devm_gpio_request(&pdriver_dev->pdev->dev, psensor_dev->rst_pin, "sensor_rst");
+		if (ret < 0) {
+			pr_err("%s:sensor_rst request failed\n", __func__);
+		} else {
+            psensor_dev->rst_pin_is_busy++;
+        }
+    }
 
+	if (gpio_is_valid(psensor_dev->pdn_pin) && !psensor_dev->pdn_pin_is_busy) {
+        ret = devm_gpio_request(&pdriver_dev->pdev->dev, psensor_dev->pdn_pin, "sensor_pdn");
+		if (ret < 0) {
+			pr_err("%s:sensor_pdn request failed\n", __func__);
+		} else {
+            psensor_dev->pdn_pin_is_busy++;
+        }
+    }
+
+    pr_debug("%s, exit: vvcam%d \n", __func__, psensor_dev->device_idx);
 	return 0;
-};
+}
 
 static long vvcam_sensor_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
@@ -101,31 +126,81 @@ static long vvcam_sensor_ioctl(struct file *file, unsigned int cmd, unsigned lon
 		return  -ENOMEM;
 	}
 	psensor_dev = pdriver_dev->private;
-	//pr_info("%s:pdriver_dev =0x%px\n", __func__,pdriver_dev);
-	//pr_info("%s:sensor[%d] psensor_dev =0x%px\n", __func__,psensor_dev->device_idx,psensor_dev);
+	pr_debug("%s:sensor[%d], cmd %x\n", __func__, psensor_dev->device_idx, cmd);
 
 	mutex_lock(&pdriver_dev->vvmutex);
 	ret = sensor_priv_ioctl(psensor_dev, cmd ,(void __user *)arg);
 	mutex_unlock(&pdriver_dev->vvmutex);
 
 	return ret;
-};
+}
 
 static int vvcam_sensor_release(struct inode * inode, struct file * file)
 {
-	return 0;
-};
+	struct vvcam_sensor_driver_dev *pdriver_dev;
+	struct vvcam_sensor_dev * psensor_dev;
+
+	pdriver_dev = container_of(inode->i_cdev, struct vvcam_sensor_driver_dev, cdev);
+
+    if (pdriver_dev == NULL) {
+		pr_err("%s:file private is null point error\n", __func__);
+		return  -ENOMEM;
+	}
+	psensor_dev = pdriver_dev->private;
+
+    pr_debug("%s, enter: vvcam%d \n", __func__, psensor_dev->device_idx);
+
+    psensor_dev->rst_pin_is_busy--;
+    psensor_dev->pdn_pin_is_busy--;
+
+    if (gpio_is_valid(psensor_dev->rst_pin) &&  psensor_dev->rst_pin_is_busy == 0) {
+        gpio_free(psensor_dev->rst_pin);
+    }
+
+	if (gpio_is_valid(psensor_dev->pdn_pin) && psensor_dev->pdn_pin_is_busy == 0) {
+        gpio_free(psensor_dev->pdn_pin);
+    }
+
+
+    pr_debug("%s, exit: vvcam%d \n", __func__, psensor_dev->device_idx);
+    return 0;// sensor_reset(psensor_dev);
+}
+
+static unsigned vvcam_sensor_poll(struct file *file, poll_table *wait)
+{
+	long ret = 0;
+    unsigned int mask = 0;
+	struct vvcam_sensor_driver_dev *pdriver_dev;
+	struct vvcam_sensor_dev * psensor_dev;
+
+	pdriver_dev = file->private_data;
+	if (pdriver_dev == NULL)
+	{
+		pr_err("%s:file private is null point error\n", __func__);
+		return  -ENOMEM;
+	}
+	psensor_dev = pdriver_dev->private;
+    poll_wait(file, &psensor_dev->err_wait, wait);
+
+    if (psensor_dev->err_mask) {
+        mask |= POLLIN | POLLRDNORM;
+        psensor_dev->err_mask = 0;
+    }
+
+    return mask;
+}
 
 struct file_operations vvcam_sensor_fops = {
 	.owner = THIS_MODULE,
 	.open = vvcam_sensor_open,
 	.release = vvcam_sensor_release,
 	.unlocked_ioctl = vvcam_sensor_ioctl,
+    .poll = vvcam_sensor_poll,
 };
 
 static int vvcam_sensor_of_parse(struct platform_device *pdev)
 {
-	int ret = 0, regulator_num = 0;
+	int ret = 0, regulator_num = 0, voltage_set_num = 0;
 	struct device_node *np = pdev->dev.of_node;
 	struct vvcam_sensor_driver_dev *pdriver_dev = platform_get_drvdata(pdev);
 	struct vvcam_sensor_dev * psensor_dev = pdriver_dev->private;
@@ -135,6 +210,8 @@ static int vvcam_sensor_of_parse(struct platform_device *pdev)
 		pr_err("%s:property sensor_name not defined for %s\n", __func__, pdev->name);
 		return ret;
 	}
+
+	psensor_dev->dev = &pdev->dev;
 	psensor_dev->regulators.num = of_property_count_strings(np, "sensor_regulators");
 	if (psensor_dev->regulators.num <= 0) {
 		pr_err("%s:property sensor_regulators not defined for %s\n", __func__, pdev->name);
@@ -146,6 +223,16 @@ static int vvcam_sensor_of_parse(struct platform_device *pdev)
 			pr_err("%s:fail to read property sensor_regulators\n", __func__);
 			return -1;
 		};
+
+		voltage_set_num = of_property_count_u32_elems(np, "sensor_regulator_voltage_uV");
+		if(voltage_set_num == psensor_dev->regulators.num){
+			ret = of_property_read_u32_array(np, "sensor_regulator_voltage_uV",
+					psensor_dev->regulators.voltage, psensor_dev->regulators.num);
+			if (ret != 0) {
+				pr_err("%s:fail to read property sensor_regulator_voltage_uV\n", __func__);
+				return -1;
+			}
+		}
 		ret = of_property_read_u32_array(np, "sensor_regulator_timing_us",
 				psensor_dev->regulators.delay_us, psensor_dev->regulators.num);
 		if (ret != 0) {
@@ -167,13 +254,7 @@ static int vvcam_sensor_of_parse(struct platform_device *pdev)
 	}
 
 	psensor_dev->pdn_pin = of_get_named_gpio(np, "sensor_pdn", 0);
-	if (psensor_dev->pdn_pin >= 0) {
-		ret = devm_gpio_request(&pdev->dev, psensor_dev->pdn_pin,
-					"sensor_pdn");
-		if (ret < 0) {
-			pr_err("%s:sensor_pdn request failed\n", __func__);
-		}
-	} else {
+	if (psensor_dev->pdn_pin < 0) {
 		pr_err("sensor_pdn not defined for %s\n", psensor_dev->sensor_name);
 	}
 
@@ -184,13 +265,7 @@ static int vvcam_sensor_of_parse(struct platform_device *pdev)
 	}
 
 	psensor_dev->rst_pin = of_get_named_gpio(np, "sensor_rst", 0);
-	if (psensor_dev->rst_pin >= 0) {
-		ret = devm_gpio_request(&pdev->dev, psensor_dev->rst_pin,
-					"sensor_rst");
-		if (ret < 0) {
-			pr_err("%s:sensor_rst request failed\n", __func__);
-		}
-	} else {
+	if (psensor_dev->rst_pin < 0) {
 		pr_err("sensor_rst not defined for %s\n", psensor_dev->sensor_name);
 	}
 
@@ -227,7 +302,7 @@ static int vvcam_sensor_probe(struct platform_device *pdev)
 	struct vvcam_sensor_dev * psensor_dev;
 	struct device_node *np = pdev->dev.of_node;
 
-	pr_info("enter %s\n", __func__);
+	pr_debug("enter %s\n", __func__);
 
 	pdev->id = of_alias_get_id(np, "vivcam");
 
@@ -254,8 +329,10 @@ static int vvcam_sensor_probe(struct platform_device *pdev)
 	memset(psensor_dev,0,sizeof(struct vvcam_sensor_dev ));
 	pr_info("%s:sensor[%d]: psensor_dev =0x%px\n", __func__,pdev->id,psensor_dev);
 	psensor_dev->device_idx = pdev->id;
+    init_waitqueue_head(&psensor_dev->err_wait);
 
 	pdriver_dev->private = psensor_dev;
+    pdriver_dev->pdev = pdev;
 	mutex_init(&pdriver_dev->vvmutex);
 	platform_set_drvdata(pdev, pdriver_dev);
 
@@ -320,7 +397,7 @@ static int vvcam_sensor_probe(struct platform_device *pdev)
     extern int sensor_create_capabilities_sysfs(struct platform_device *pdev);
     sensor_create_capabilities_sysfs(pdev);
 	devise_register_index++;
-	pr_info("exit %s\n", __func__);
+	pr_debug("exit %s\n", __func__);
 	return ret;
 }
 
@@ -329,7 +406,7 @@ static int vvcam_sensor_remove(struct platform_device *pdev)
 	struct vvcam_sensor_driver_dev *pdriver_dev;
 	struct vvcam_sensor_dev * psensor_dev;
 
-	pr_info("enter %s\n", __func__);
+	pr_debug("enter %s\n", __func__);
 	devise_register_index--;
 	pdriver_dev = platform_get_drvdata(pdev);
 
@@ -376,7 +453,7 @@ static struct platform_driver vvcam_sensor_driver = {
 
 static void vvcam_sensor_pdev_release(struct device *dev)
 {
-	pr_info("enter %s\n", __func__);
+	pr_debug("enter %s\n", __func__);
 }
 
 #if 0//def WITH_VVCAM
@@ -399,7 +476,7 @@ static int __init vvcam_sensor_init_module(void)
 {
 	int ret = 0;
 
-	pr_info("enter %s\n", __func__);
+	pr_debug("enter %s\n", __func__);
 
 #if 0//def WITH_VVCAM
 	ret = platform_device_register(&vvcam_sensor_pdev);
@@ -431,7 +508,7 @@ static int __init vvcam_sensor_init_module(void)
 
 static void __exit vvcam_sensor_exit_module(void)
 {
-	pr_info("enter %s\n", __func__);
+	pr_debug("enter %s\n", __func__);
 
 	platform_driver_unregister(&vvcam_sensor_driver);
 

+ 3 - 0
vvcam/native/vi_pre/vi_pre.h

@@ -333,10 +333,13 @@ struct vi_pre_dev {
 	struct mutex mutex;
 	void __iomem *reg_base;
 	unsigned long cnt; //used to cnt frame num or line num;
+    int update_frame_id;
+    int update_vc_id;
 	bool is_mframe_mode;
     struct clk *aclk;
     struct clk *pclk;
     struct clk *pixclk;
     struct platform_device *pdev;
 };
+
 #endif/*__VI_PRE_H__*/

+ 72 - 51
vvcam/native/vi_pre/vi_pre_dma.c

@@ -77,33 +77,6 @@ typedef struct {
    u32 dma_ctl51;
 } vi_dma_reg_t;
 
-typedef enum {
-    VI_PRE_RAW_6BIT,
-    VI_PRE_RAW_7BIT,
-    VI_PRE_RAW_8BIT,
-    VI_PRE_RAW_10BIT_16ALIGN,
-    VI_PRE_RAW_12BIT,
-    VI_PRE_RAW_10BIT,
-} vi_pre_data_width_t;
-
-typedef enum {
-    VI_PRE_M_FRAME,
-    VI_PRE_N_LANE,
-} vi_pre_dma_mode_t;
-
-typedef struct {
-    int vc_num;         //1~3
-    vi_pre_data_width_t width;
-    vi_pre_dma_mode_t mode;
-    u32 resolution_h;
-    u32 resolution_v;
-    u32 line_size; //Data size of one line, unit byte; Must be 256-byte aligned
-    u32 num;       //n line num, or m frame num(m frme max is 4)
-    u32 n_line_int;//only used for nline mode.(Generate an interrupt every time when n lines are completed). n_line_int <= num
-    u32 buf_size;
-    u8 *buf;
-} vi_pre_dma_cfg_t;
-
 static vi_dma_reg_t dma_reg = {
     .dma_ctl0 = 0x198,
     .dma_ctl1 = 0x19c,
@@ -405,8 +378,10 @@ static void dma_enable(struct vi_pre_dev *dev, int en)
 {
     if(en) {
         vi_pre_dma_write(dev, dma_reg.dma_ctl10, 1);
+        pr_info("%s, %d, dma start\n", __func__, __LINE__);
     } else {
         vi_pre_dma_write(dev, dma_reg.dma_ctl10, 0);
+        pr_info("%s, %d, dma stop\n", __func__, __LINE__);
     }
 }
 
@@ -448,15 +423,15 @@ static u16 nline_mode_period_cnt(struct vi_pre_dev *dev, int ch)
     }
 }
 
-static void mframe_mode_set_position(struct vi_pre_dev *dev, int ch, int f, int l)
+static void mframe_mode_set_position(struct vi_pre_dev *dev, int vc_ch, int f, int l)
 {
-    u32 reg = dma_reg.dma_ctl23 + ch / 2 * 4;
+    u32 reg = dma_reg.dma_ctl23 + vc_ch / 2 * 4;
     u32 reg_val = vi_pre_dma_read(dev, reg);
 
     f &= 3;
     l &= 0xfff;
 
-    if (ch % 2) {
+    if (vc_ch % 2) {
         reg_val &=~(0xffff << 16);
         reg_val |= (l << 16) | (f << 29);
     } else {
@@ -486,19 +461,14 @@ static void mframe_set_start_addr(struct vi_pre_dev *dev, int frame_id, int vc_c
 
 static u32 mframe_frame_done_flag(struct vi_pre_dev *dev)
 {
-    return vi_pre_dma_read(dev, dma_reg.dma_ctl43) & 0xfff;
+    return vi_pre_dma_read(dev, dma_reg.dma_ctl43);
 }
 
 static void mframe_frame_done_flag_clear(struct vi_pre_dev *dev, u32 mask)
 {
-
-     u32 reg_val  = vi_pre_dma_read(dev, dma_reg.dma_ctl43);
-     reg_val |= mask;
-
      vi_pre_dma_write(dev, dma_reg.dma_ctl43, mask);
 }
 
-
 static void dma_interrupt_set(struct vi_pre_dev *dev, u32 mask, int en)
 {
     u32 reg_val = vi_pre_dma_read(dev, dma_reg.dma_ctl44);
@@ -509,6 +479,7 @@ static void dma_interrupt_set(struct vi_pre_dev *dev, u32 mask, int en)
     }
 
     vi_pre_dma_write(dev, dma_reg.dma_ctl44, reg_val);
+    reg_val = vi_pre_dma_read(dev, dma_reg.dma_ctl44);
 }
 
 static u16 dma_interrupt_status(struct vi_pre_dev *dev)
@@ -532,10 +503,12 @@ static int vi_pre_mframe_config(struct vi_pre_dev *dev, vi_pre_dma_cfg_t *cfg)
     int j = 0;
 
     if (cfg->num > 4) {
+        printk("%s, %d, cfg frame num error!!!\n", __func__, __LINE__);
         return -1;
     }
 
     if (cfg->buf_size < cfg->line_size * cfg->resolution_v * cfg->num) {
+        printk("%s, %d, vipre buf size error!!!\n", __func__, __LINE__);
         return -1;
     }
 
@@ -607,7 +580,7 @@ static int dma_config(struct vi_pre_dev *pdriver_dev, vi_pre_dma_cfg_t *cfg)
     int ret = 0;
     set_dma_burst_length(pdriver_dev, 16);
     set_dma_data_width(pdriver_dev, cfg->width);
-    set_bit_mode(pdriver_dev, 1);
+    set_bit_mode(pdriver_dev, 0);
     set_dma_mode(pdriver_dev, cfg->mode);
     set_dma_resolution(pdriver_dev, cfg->resolution_h, cfg->resolution_v);
 
@@ -632,12 +605,41 @@ int vi_pre_dma_config(struct vi_pre_dev *pdriver_dev, void *arg)
     return dma_config(pdriver_dev, &cfg);
 }
 
-#define VIPRE_BUS_ERR (1 << 5)
-#define VIPRE_FIFO_OVER (1 << 4)
-#define VIPRE_IDLE_DONE (1 << 3)
-#define VIPRE_NMOVERFLOW (1 << 2)
-#define VIPRE_LINE_DONE (1 << 1)
-#define VIPRE_FRAME_DONE (1 << 0)
+int vi_pre_dma_mframe_set_buf(struct vi_pre_dev *pdriver_dev, void *arg)
+{
+    int j = 0;
+    vi_pre_mframe_cfg_t mframe_cfg;
+	check_retval(copy_from_user(&mframe_cfg, arg, sizeof(mframe_cfg)));
+    unsigned long buf_base = (unsigned long)mframe_cfg.buf_addr;
+
+    for (j = 0; j < mframe_cfg.vc_num; j++) {
+        mframe_set_start_addr(pdriver_dev, mframe_cfg.frame_id, j, buf_base);
+        buf_base += mframe_cfg.frame_size;
+    }
+
+    return 0;
+}
+
+int vi_pre_dma_get_mframe_done_id(struct vi_pre_dev *pdriver_dev, void *arg)
+{
+    vi_pre_update_frame_info_t info;
+
+    info.update_frame_id = pdriver_dev->update_frame_id;
+    info.update_vc_id = pdriver_dev->update_vc_id;
+	check_retval(copy_to_user(arg, &info,sizeof(info)));
+
+    return 0;
+}
+
+int vi_pre_dma_mframe_update_buf(struct vi_pre_dev *pdriver_dev, void *arg)
+{
+    vi_pre_mframe_update_t mframe;
+	check_retval(copy_from_user(&mframe, arg, sizeof(mframe)));
+    unsigned long buf_base = (unsigned long)mframe.buf_addr;
+    mframe_set_start_addr(pdriver_dev, mframe.frame_id, mframe.vc_id, buf_base);
+
+    return 0;
+}
 
 int vi_pre_dma_start(struct vi_pre_dev *pdriver_dev)
 {
@@ -671,6 +673,26 @@ int *vi_pre_event(void)
     return &vipre_event;
 }
 
+
+static int f_done_sta_to_frame_id(u32 sta)
+{
+#define FRAME_0_DONE (1 << 11)
+#define FRAME_1_DONE (1 << 10)
+#define FRAME_2_DONE (1 << 9)
+#define FRAME_3_DONE (1 << 8)
+        int f_id = 0;
+        if (sta & FRAME_0_DONE) {
+             f_id = 3;
+        } else if (sta & FRAME_1_DONE) {
+             f_id = 0;
+        } else if (sta & FRAME_2_DONE) {
+             f_id = 1;
+        } else if (sta & FRAME_3_DONE) {
+             f_id = 2;
+        }
+        return f_id;
+}
+
 void vi_pre_dma_interrupt_handler(struct vi_pre_dev *pdriver_dev)
 {
     u32 status = 0;
@@ -678,30 +700,29 @@ void vi_pre_dma_interrupt_handler(struct vi_pre_dev *pdriver_dev)
     unsigned long flags = 0;
     //int i = 0;
 
+    spin_lock_irqsave(&pdriver_dev->slock, flags);
     status = dma_interrupt_status(pdriver_dev);
-    //printk("<0>""vipre int sta %x\n", status );
     if (status & (1 << 4)) {
         printk("<0>""vipre err int sta 0x%x\n", status);
     }
+
     dma_clear_interrupt_status(pdriver_dev, status);
-    spin_lock_irqsave(&pdriver_dev->slock, flags);
     if (status & VIPRE_FRAME_DONE) {
         pdriver_dev->cnt++;
         if (pdriver_dev->cnt >= 4) {
             pdriver_dev->cnt = 0;
-            vipre_event = 1;
         }
+        vipre_event = 1;
         f_done_sta = mframe_frame_done_flag(pdriver_dev);
-        //printk("<0>""f_done_sta int sta 0x%x\n", f_done_sta);
         mframe_frame_done_flag_clear(pdriver_dev, f_done_sta);
-        //vi_pre_dma_stop(pdriver_dev);
-        /*TODO send event*/
-        //printk("frame done %x\n", f_done_sta);
+        pdriver_dev->update_frame_id = f_done_sta_to_frame_id(f_done_sta);
+        mframe_mode_set_position(pdriver_dev, 0, pdriver_dev->update_frame_id, 0);
+        pdriver_dev->update_vc_id = 0;
     } else if (status & VIPRE_LINE_DONE) {
         //u32 nline_done_sta =;
         //pdriver_dev->cnt++;
         //printk("line done %x\n", f_done_sta);
-        vipre_event = 1;
+        //vipre_event = 1;
     }
 
 #if 0

+ 5 - 29
vvcam/native/vi_pre/vi_pre_driver_of.c

@@ -100,7 +100,7 @@ static long vi_pre_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	long ret = 0;
 	struct vi_pre_dev *pdriver_dev;
 
-	pr_info("enter %s\n", __func__);
+	pr_debug("enter %s\n", __func__);
 	//printk("%s, %d, vipre_cmd %u\n", __func__, __LINE__, cmd);
 	pdriver_dev = file->private_data;
 	if (pdriver_dev == NULL) {
@@ -113,7 +113,7 @@ static long vi_pre_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	ret = vi_pre_priv_ioctl(pdriver_dev, cmd ,(void *)arg);
 	mutex_unlock(&pdriver_dev->mutex);
 
-	pr_info("exit %s\n", __func__);
+	pr_debug("exit %s\n", __func__);
 
 	return ret;
 };
@@ -160,23 +160,7 @@ static int vi_pre_mmap(struct file *pFile, struct vm_area_struct *vma)
 	return 0;
 };
 
-static DECLARE_WAIT_QUEUE_HEAD(vipre_waitq);
-static unsigned vi_pre_poll(struct file *file, poll_table *wait)
-{
-    extern int *vi_pre_event(void);
-    int *event = 0;
-    unsigned int mask = 0;
-    event = vi_pre_event();
-    poll_wait(file, &vipre_waitq, wait);
-
-    if (*event) {
-        mask |= POLLIN | POLLRDNORM;
-        *event = 0;
-    }
-
-    return mask;
-}
-
+extern unsigned vi_pre_poll(struct file *file, poll_table *wait);
 struct file_operations vi_pre_fops = {
 	.owner = THIS_MODULE,
 	.open = vi_pre_open,
@@ -186,16 +170,6 @@ struct file_operations vi_pre_fops = {
 	.poll = vi_pre_poll,
 };
 
-static irqreturn_t vi_pre_irq(int irq, void *dev_id)
-{
-    extern void vi_pre_dma_interrupt_handler(struct vi_pre_dev *pdriver_dev);
-	struct vi_pre_dev *pdriver_dev = dev_id;
-    vi_pre_dma_interrupt_handler(pdriver_dev);
-    wake_up_interruptible(&vipre_waitq);
-
-    return IRQ_HANDLED;
-}
-
 static int vi_pre_probe(struct platform_device *pdev)
 {
 	int ret = 0;
@@ -298,6 +272,7 @@ static int vi_pre_probe(struct platform_device *pdev)
     }
 
     spin_lock_init(&pdriver_dev->slock);
+    /*
     if (device_property_read_bool(dev, "vi_pre_irq_en")) {
         ret = devm_request_irq(dev, pdriver_dev->irq,
                                vi_pre_irq, IRQF_SHARED,
@@ -307,6 +282,7 @@ static int vi_pre_probe(struct platform_device *pdev)
             goto end;
         }
     }
+    */
 
     pm_runtime_enable(&pdev->dev);
     ret = vipre_runtime_resume(&pdev->dev);

+ 66 - 6
vvcam/native/vi_pre/vi_pre_ioctl.c

@@ -7,6 +7,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/poll.h>
 #include <linux/regmap.h>
 #include <linux/of_reserved_mem.h>
 #include <linux/io.h>
@@ -637,12 +638,6 @@ void vi_pre_interrupt_handler(struct vi_pre_dev *dev)
 }
 #endif
 
-typedef struct {
-    int glue_idx;
-    int h;
-    int v;
-} vipre_resolution_cfg_t;
-
 int vi_pre_set_resolution(struct vi_pre_dev *dev, void *arg)
 {
     u32 val = 0;
@@ -899,7 +894,57 @@ int vi_pre_disable_ipi(struct vi_pre_dev *dev, void *arg)
 extern int vi_pre_dma_config(struct vi_pre_dev *pdriver_dev, void *arg);
 extern int vi_pre_dma_start(struct vi_pre_dev *pdriver_dev);
 extern int vi_pre_dma_stop(struct vi_pre_dev *pdriver_dev);
+extern int vi_pre_dma_mframe_set_buf(struct vi_pre_dev *pdriver_dev, void *arg);
+extern int vi_pre_dma_get_mframe_done_id(struct vi_pre_dev *pdriver_dev, void *arg);
+extern int vi_pre_dma_mframe_update_buf(struct vi_pre_dev *pdriver_dev, void *arg);
+
+static DECLARE_WAIT_QUEUE_HEAD(vipre_waitq);
+static irqreturn_t vi_pre_irq(int irq, void *dev_id)
+{
+    extern void vi_pre_dma_interrupt_handler(struct vi_pre_dev *pdriver_dev);
+	struct vi_pre_dev *pdriver_dev = dev_id;
+    vi_pre_dma_interrupt_handler(pdriver_dev);
+    wake_up_interruptible(&vipre_waitq);
+
+    return IRQ_HANDLED;
+}
+
+unsigned vi_pre_poll(struct file *file, poll_table *wait)
+{
+    extern int *vi_pre_event(void);
+    int *event = 0;
+    unsigned int mask = 0;
+    event = vi_pre_event();
+    poll_wait(file, &vipre_waitq, wait);
+
+    if (*event) {
+        mask |= POLLIN | POLLRDNORM;
+        *event = 0;
+    }
+
+    return mask;
+}
+
+static int vi_pre_request_irq(struct vi_pre_dev *pdriver_dev, void *arg)
+{
+    int ret = 0;
+    struct device *dev = &pdriver_dev->pdev->dev;
+
+    ret = devm_request_irq(dev, pdriver_dev->irq,
+                               vi_pre_irq, IRQF_SHARED,
+                               dev_name(dev), pdriver_dev);
+    if (ret) {
+        dev_err(dev, "irq vipre failed\n");
+    }
 
+    return ret;
+}
+
+static int vi_pre_free_irq(struct vi_pre_dev *pdriver_dev, void *arg)
+{
+	int ret = free_irq(pdriver_dev->irq, pdriver_dev);
+    return ret;
+}
 
 unsigned int vi_pre_priv_ioctl(struct vi_pre_dev *dev, unsigned int cmd, void *args)
 {
@@ -975,6 +1020,21 @@ unsigned int vi_pre_priv_ioctl(struct vi_pre_dev *dev, unsigned int cmd, void *a
 	case VI_PRE_IOCTL_PRESS_INTERROR:
         ret = vi_pre_press_interror(dev, args);
 		break;
+	case VI_PRE_IOCTL_SET_MFRAME_BUF:
+        ret = vi_pre_dma_mframe_set_buf(dev, args);
+		break;
+	case VI_PRE_IOCTL_GET_MFRAME_DONE_ID:
+        ret = vi_pre_dma_get_mframe_done_id(dev, args);
+        break;
+	case VI_PRE_IOCTL_MFRAME_UPDATE_BUF:
+        ret = vi_pre_dma_mframe_update_buf(dev, args);
+        break;
+    case VI_PRE_IOCTL_REQUEST_IRQ:
+        ret = vi_pre_request_irq(dev, args);
+        break;
+    case VI_PRE_IOCTL_FREE_IRQ:
+        ret = vi_pre_free_irq(dev, args);
+        break;
 	default:
 		pr_err("unsupported command %d\n", cmd);
 		break;

+ 63 - 6
vvcam/native/vi_pre/vi_pre_ioctl.h

@@ -39,14 +39,19 @@ struct vi_pre_reg_t {
 #define VI_PRE_IOCTL_PRESS_INTERROR         _IOWR(VIPER_IOCTL_MAGIC, 19, int)
 #define VI_PRE_IOCTL_HDRPRO_ENABLE          _IOWR(VIPER_IOCTL_MAGIC, 20, int)
 #define VI_PRE_IOCTL_HDRPRO_DISABLE         _IOWR(VIPER_IOCTL_MAGIC, 21, int)
-#define VI_PRE_IOCTL_MAX                    _IOWR(VIPER_IOCTL_MAGIC, 22, int)
+#define VI_PRE_IOCTL_SET_MFRAME_BUF         _IOWR(VIPER_IOCTL_MAGIC, 22, int)
+#define VI_PRE_IOCTL_GET_MFRAME_DONE_ID     _IOWR(VIPER_IOCTL_MAGIC, 23, int)
+#define VI_PRE_IOCTL_MFRAME_UPDATE_BUF      _IOWR(VIPER_IOCTL_MAGIC, 24, int)
+#define VI_PRE_IOCTL_REQUEST_IRQ            _IOWR(VIPER_IOCTL_MAGIC, 25, int)
+#define VI_PRE_IOCTL_FREE_IRQ               _IOWR(VIPER_IOCTL_MAGIC, 26, int)
+#define VI_PRE_IOCTL_MAX                    _IOWR(VIPER_IOCTL_MAGIC, 27, int)
 
 typedef enum {
-    ipi_mode_nomal = 0,
-    ipi_mode_hdr_2_frame,
-    ipi_mode_hdr_3_frame,
-    ipi_mode_sony_dol_hdr_2_frame,
-    ipi_mode_sony_dol_hdr_3_frame,
+    IPI_MODE_NOMAL = 0,
+    IPI_MODE_HDR_2_FRAME,
+    IPI_MODE_HDR_3_FRAME,
+    IPI_MODE_SONY_DOL_HDR_2_FRAME,
+    IPI_MODE_SONY_DOL_HDR_3_FRAME,
 } ipi_mode_t;
 
 typedef struct {
@@ -156,6 +161,58 @@ struct hdrpro_resolution {
 	unsigned int height;
 };
 
+typedef enum {
+    VI_PRE_RAW_6BIT,
+    VI_PRE_RAW_7BIT,
+    VI_PRE_RAW_8BIT,
+    VI_PRE_RAW_10BIT_16ALIGN,
+    VI_PRE_RAW_12BIT,
+    VI_PRE_RAW_10BIT,
+} vi_pre_data_width_t;
+
+typedef enum {
+    VI_PRE_M_FRAME,
+    VI_PRE_N_LANE,
+} vi_pre_dma_mode_t;
+
+typedef struct {
+    int vc_num;         //1~3
+    vi_pre_data_width_t width;
+    vi_pre_dma_mode_t mode;
+    unsigned int resolution_h;
+    unsigned int resolution_v;
+    unsigned int line_size; //Data size of one line, unit byte; Must be 256-byte aligned
+    unsigned int num;       //n line num, or m frame num(m frme max is 4)
+    unsigned int n_line_int;//only used for nline mode.(Generate an interrupt every time when n lines are completed). n_line_int <= num
+    unsigned int buf_size;
+    unsigned char *buf;
+} vi_pre_dma_cfg_t;
+
+typedef struct {
+    int glue_idx;
+    int h;
+    int v;
+} vipre_resolution_cfg_t;
+
+typedef struct {
+    int frame_id;
+    int vc_num;
+    void *buf_addr;
+    int frame_size;
+} vi_pre_mframe_cfg_t;
+
+typedef struct {
+    int frame_id;
+    int vc_id;
+    void *buf_addr;
+    int frame_size;
+} vi_pre_mframe_update_t;
+
+typedef struct {
+    int update_frame_id;
+    int update_vc_id;
+} vi_pre_update_frame_info_t;
+
 extern unsigned int vi_pre_priv_ioctl(struct vi_pre_dev *dev, unsigned int cmd, void *args);
 
 #endif /* _VI_PRE_IOC_H_ */

+ 2 - 2
vvcam/native/video/Makefile

@@ -10,11 +10,11 @@ $(TARGET)-objs += video_hw_info.o
 $(TARGET)-objs += subdev.o
 
 EXTRA_CFLAGS += -I$(PWD)/../../common
-
+ccflags-$(CONFIG_DEBUG)  += -DDEBUG
 PWD :=$(shell pwd)
 
 all:
-	make   -C $(KERNEL) M=$(PWD)  modules
+	make   -C $(KERNEL) M=$(PWD) CONFIG_DEBUG=y  modules
 modules_install:
 	make -C $(KERNEL_SRC) M=$(SRC) modules_install
 clean:

+ 8 - 1
vvcam/native/video/subdev.c

@@ -80,7 +80,7 @@ static int sensor_press_dts(struct fwnode_handle *node, sub_dev_info_t *subdev)
     */
     int ret = 0;
 
-    uint32_t csi_idx, flash_led_idx;
+    uint32_t csi_idx, flash_led_idx, mode_idx;
 
     ret = fwnode_property_read_u32_array(node, "csi_idx", &csi_idx, 1);
     if(ret != 0) {
@@ -92,13 +92,20 @@ static int sensor_press_dts(struct fwnode_handle *node, sub_dev_info_t *subdev)
         flash_led_idx = -1;
     }
 
+    ret = fwnode_property_read_u32_array(node, "mode_idx", &mode_idx, 1);
+    if(ret != 0) {
+        mode_idx = -1;
+    }
+
 	video_info("flash_led idx is %u\n", flash_led_idx);
 
     subdev->param[0] = (char)csi_idx;
     subdev->param[1] = fwnode_property_read_bool(node, "skip_init");
     subdev->param[2] = (char)flash_led_idx;
+    subdev->param[3] = (char)mode_idx;
     video_info("subdev->param[0] is %d\n", subdev->param[0]);
     video_info("subdev->param[2] is %d\n", subdev->param[2]);
+    video_info("subdev->param[3] is %d\n", subdev->param[3]);
     subdev->param_size = 3;
     return 0;
 }

+ 74 - 4
vvcam/native/video/video.c

@@ -79,7 +79,7 @@ static int video_get_pipelines(struct video_drvdata *drvdata, void *__user args)
     pipline_t *cam_pip = drvdata->piplines;
 
     check_retval(copy_to_user(usr_pip, cam_pip, sizeof(pipline_t) * drvdata->pipline_num));
-	video_info("%s, %d, pipnmu: %d\n", __func__, __LINE__, drvdata->pipline_num);
+	video_info("%s, %d, pipeline nmu: %d\n", __func__, __LINE__, drvdata->pipline_num);
     return 0;
 }
 
@@ -93,7 +93,7 @@ static int video_set_path_type(struct video_drvdata *drvdata, void *__user args)
 {
 	pathtype_set_t pathtype_set;
 	check_retval(copy_from_user(&pathtype_set, args, sizeof(pathtype_set_t)));
-	video_info("VIDEO_SET_PATH_TYPE pipeline=%d sensor=%s path_type%d ", pathtype_set.pipeline_id , pathtype_set.sensor_name, pathtype_set.path_type);
+	video_info("VIDEO_SET_PATH_TYPE pipeline=%d sensor=%s path_type%d \n", pathtype_set.pipeline_id , pathtype_set.sensor_name, pathtype_set.path_type);
 	return 0;
 }
 
@@ -102,7 +102,56 @@ static int video_get_mem_pool_region_id(struct video_drvdata *drvdata, void *__u
 	check_retval(copy_to_user(args, &drvdata->vi_mem_pool_region_id, sizeof(int)));
 	return 0;
 }
+static long video_set_state(struct video_drvdata *drvdata,int *arg)
+{
+    int ops;
+    check_retval(copy_from_user(&ops,arg,sizeof(int)));
+    if(ops ==DEVICE_OPERATION_ACTIVE)
+    {
+        if(drvdata->actived == true)
+        {
+            dev_warn(drvdata->dev,"%s,can't ative,device already active by other process(%d)\n",__func__, current->tgid);
+            return (-EBUSY);
+        }else
+        {
+            drvdata->actived =true;
+            drvdata->actived_owner = current->tgid;
+            dev_dbg(drvdata->dev,"%s,actived by process %d\n",__func__,current->tgid);
+        }
+    }
+    else if(ops ==DEVICE_OPERATION_DEACTIVE)
+    {
+        if(drvdata->actived == false)
+        {
+            dev_warn(drvdata->dev,"%s,can't deative,device is not atived\n",__func__);
+            return (-EPERM);
+        }else
+        {
+            if(drvdata->actived_owner != current->tgid)
+            {
+                dev_warn(drvdata->dev,"%s,can't deative,device is active by other process(%d)\n",__func__, current->tgid);
+                return (-EPERM);
+            }
+            drvdata->actived =false;
+            drvdata->actived_owner = -1;
+            dev_dbg(drvdata->dev,"%s de-active",__func__);
+        }
+    }else
+    {
+        dev_warn(drvdata->dev,"%s,un-defined ops\n",__func__);
+        return (-EPERM);
+    }
+
+    return 0;
+}
 
+static long video_get_state(struct video_drvdata *drvdata,int *arg)
+{
+        int ops;
+        ops = drvdata->actived==true?DEVICE_OPERATION_ACTIVE:DEVICE_OPERATION_DEACTIVE;
+        check_retval(copy_to_user(arg, &ops, sizeof(int)));
+        return 0;
+}
 static long video_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 	long ret = 0;
@@ -128,9 +177,15 @@ static long video_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	case VIDEO_GET_MEM_POOL_REGION_ID:
 		ret = video_get_mem_pool_region_id(drvdata, (void *)arg);
 		break;
+    case VIDEO_SET_DEVICE_STATE:
+        ret = video_set_state(drvdata, (void *)arg);
+        break;
+    case VIDEO_GET_DEVICE_STATE:
+        ret = video_get_state(drvdata, (void *)arg);
+        break;
 	default:
 		ret = -EPERM;
-		video_err("%s: unsupported command %d", __func__, cmd);
+		video_err("%s: unsupported command %d\n", __func__, cmd);
 		break;
 	}
 	mutex_unlock(&drvdata->mutex);
@@ -139,7 +194,19 @@ static long video_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 static int video_release(struct inode * inode, struct file * file)
 {
-	return 0;
+    struct video_drvdata *drvdata;
+	drvdata = container_of(inode->i_cdev, struct video_drvdata, cdev);
+    mutex_lock(&drvdata->mutex);
+    if(drvdata->actived == true &&
+        drvdata->actived_owner == current->tgid)
+    {
+        drvdata->actived = false;
+        drvdata->actived_owner = -1;
+        dev_dbg(drvdata->dev,"%s de-active device\n",__func__);
+    }
+    mutex_unlock(&drvdata->mutex);
+
+    return 0;
 };
 
 static int video_mmap(struct file *pFile, struct vm_area_struct *vma)
@@ -265,6 +332,9 @@ static int video_probe(struct platform_device *pdev)
 	}
 
 	drvdata->device_idx = pdev->id;
+    drvdata->actived = false;
+    drvdata->actived_owner = -1;
+    drvdata->dev = &pdev->dev;
 	mutex_init(&drvdata->mutex);
 	platform_set_drvdata(pdev, drvdata);
 

+ 4 - 0
vvcam/native/video/video.h

@@ -1,3 +1,4 @@
+
 #ifndef _THEAD_VIDEO_H_
 #define _THEAD_VIDEO_H_
 
@@ -30,10 +31,13 @@ typedef struct {
 
 typedef struct video_drvdata {
 	struct cdev cdev;
+    struct device *dev;
 	dev_t devt;
 	struct class *class;
 	int device_idx;
 	struct mutex mutex;
+    bool actived;
+    pid_t actived_owner;
 	int pipline_num;
 	pipline_t piplines[20];
 	int vi_mem_pool_region_id;

+ 8 - 1
vvcam/native/video/video_hw_info.c

@@ -48,8 +48,12 @@ ENUM_DESC_MAPS_ADD(SENSOR_4K_RAW12_LINER)
 ENUM_DESC_MAPS_ADD(SENSOR_VGA_RAW10_LINER)
 ENUM_DESC_MAPS_ADD(SENSOR_1080P_RAW10_LINER)
 ENUM_DESC_MAPS_ADD(SENSOR_4K_RAW10_LINER)
+ENUM_DESC_MAPS_ADD(SENSOR_1296x972_RAW10_LINER)
 ENUM_DESC_MAPS_ADD(SENSOR_2592x1944_RAW10_LINER)
 ENUM_DESC_MAPS_ADD(SENSOR_1280x720_RAW10_LINER)
+ENUM_DESC_MAPS_ADD(SENSOR_1600x1200_RAW10_LINER)
+ENUM_DESC_MAPS_ADD(SENSOR_3280x2464_RAW10_LINER)
+ENUM_DESC_MAPS_ADD(SENSOR_1640x1232_RAW10_LINER)
 ENUM_DESC_MAPS_ADD(SENSOR_VGA_RAW12_HDR_2DOL)
 ENUM_DESC_MAPS_ADD(SENSOR_VGA_RAW12_HDR_3DOL)
 ENUM_DESC_MAPS_END
@@ -71,6 +75,9 @@ ENUM_DESC_MAPS_END
 
 /****vipre_path_type_e  string to enum map*/
 ENUM_DESC_MAPS_DECLATR(vipre)
+ENUM_DESC_MAPS_ADD(VIPRE_CSI0_DSP)
+ENUM_DESC_MAPS_ADD(VIPRE_CSI1_DSP)
+ENUM_DESC_MAPS_ADD(VIPRE_CSI2_DSP)
 ENUM_DESC_MAPS_ADD(VIPRE_CSI0_DDR)
 ENUM_DESC_MAPS_ADD(VIPRE_CSI1_DDR)
 ENUM_DESC_MAPS_ADD(VIPRE_CSI2_DDR)
@@ -133,7 +140,7 @@ int vedio_get_path_type(const char*subdev_name,const char* path_name)
     switch(ip_type)
     {
         case SENSOR:
-                return GET_ENUM_BY_DESC(sensor,path_name);
+                return 0;//GET_ENUM_BY_DESC(sensor,path_name);
         case VIPRE:
                 return GET_ENUM_BY_DESC(vipre,path_name);
         case ISP:

+ 10 - 0
vvcam/native/video/video_ioctl.h

@@ -1,3 +1,6 @@
+/*
+ * @Description: 
+ */
 /*
  * Copyright (C) 2021 Alibaba Group Holding Limited
  * Author: liuyitong <yitong.lyt@alibaba-inc.com>
@@ -17,6 +20,13 @@ enum {
     VIDEO_GET_DEV_PARAM,
     VIDEO_SET_PATH_TYPE,
     VIDEO_GET_MEM_POOL_REGION_ID,
+    VIDEO_SET_DEVICE_STATE,
+    VIDEO_GET_DEVICE_STATE,
 };
 
+
+enum {
+    DEVICE_OPERATION_ACTIVE,
+    DEVICE_OPERATION_DEACTIVE,
+};
 #endif /* _THEAD_VIDEO_IOCTL_H_*/

+ 8 - 2
vvcam/native/video/video_kernel_defs.h

@@ -16,14 +16,21 @@ typedef enum sensor_path_type{
     SENSOR_VGA_RAW10_LINER = 20,
     SENSOR_1080P_RAW10_LINER,
     SENSOR_4K_RAW10_LINER,
+    SENSOR_1296x972_RAW10_LINER,
     SENSOR_2592x1944_RAW10_LINER,
     SENSOR_1280x720_RAW10_LINER,
+    SENSOR_1600x1200_RAW10_LINER,
+    SENSOR_3280x2464_RAW10_LINER,
+    SENSOR_1640x1232_RAW10_LINER,
     SENSOR_VGA_RAW12_HDR_2DOL,
     SENSOR_VGA_RAW12_HDR_3DOL,
     SENSOR_PATH_MAX,
 } sensor_path_type_e;
 
 typedef enum vipre_path_type{
+    VIPRE_CSI0_DSP,
+    VIPRE_CSI1_DSP,
+    VIPRE_CSI2_DSP,
     VIPRE_CSI0_DDR,
     VIPRE_CSI1_DDR,
     VIPRE_CSI2_DDR,
@@ -37,7 +44,6 @@ typedef enum vipre_path_type{
     VIPRE_CSI1_LOW_COAST_HDR_ISP0,
     VIPRE_CSI2_LOW_COAST_HDR_ISP0,
     VIPRE_PATH_MAX,
-
 } vipre_path_type_e;
 
 typedef enum isp_path_type{
@@ -54,8 +60,8 @@ typedef enum isp_path_type{
 	ISP_MI_HDR_L,
 	ISP_MI_HDR_S,
 	ISP_MI_HDR_VS,
-	ISP_MI_MAX,
 #endif
+	ISP_MI_MAX,
 } isp_path_type_e;
 
 typedef enum ry_path_type{

+ 16 - 16
vvcam_ry/isp/isp_3dnr.c

@@ -189,7 +189,7 @@ int isp_u_3dnr_strength(struct isp_ic_dev *dev)
 
     isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl));
     REG_SET_SLICE(isp_ctrl, MRV_ISP_ISP_GEN_CFG_UPD, 1);
-    
+
     isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl);
 
 	return 0;
@@ -208,11 +208,11 @@ int isp_s_3dnr(struct isp_ic_dev *dev)
 
 	u32 isp_denoise3d_strength, isp_denoise3d_motion, isp_denoise3d_delta_inv;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (dnr3->update_bin) {
 		dnr3_hw_init(dev);
 	}
-  
+
 	isp_denoise3d_motion =
 	    isp_read_reg(dev, REG_ADDR(isp_denoise3d_motion));
         REG_SET_SLICE(isp_denoise3d_motion, DENOISE3D_MOTION_INV, dnr3->motion_factor);
@@ -232,7 +232,7 @@ int isp_s_3dnr(struct isp_ic_dev *dev)
 	    REG_SET_SLICE(isp_denoise3d_strength, DENOISE3D_STRENGTH, dnr3->strength);
 		isp_denoise3d_ctrl = isp_read_reg(dev, REG_ADDR(isp_denoise3d_ctrl));
 		REG_SET_SLICE(isp_denoise3d_ctrl, DENOISE3D_ENABLE, dnr3->enable);
-		
+
 		isp_write_reg(dev, REG_ADDR(isp_denoise3d_ctrl), isp_denoise3d_ctrl);
 
 	}
@@ -241,10 +241,10 @@ int isp_s_3dnr(struct isp_ic_dev *dev)
    isp_denoise3d_ctrl = isp_read_reg(dev, REG_ADDR(isp_denoise3d_ctrl));
    REG_SET_SLICE(isp_denoise3d_ctrl, DENOISE3D_ENABLE, dnr3->enable);
    isp_write_reg(dev, REG_ADDR(isp_denoise3d_ctrl), isp_denoise3d_ctrl);
-   
+
     u32 isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl));
     REG_SET_SLICE(isp_ctrl, MRV_ISP_ISP_GEN_CFG_UPD, 1);
-    
+
     isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl);
 #endif
 	return 0;
@@ -308,7 +308,7 @@ int isp_u_3dnr(struct isp_ic_dev *dev, struct isp_3dnr_update *dnr3_update)
 #else
 	u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d_strength));
 	REG_SET_SLICE(regVal, DENOISE3D_STRENGTH, dev->dnr3.strength);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d_strength), regVal);
@@ -353,7 +353,7 @@ int isp_u_3dnr(struct isp_ic_dev *dev, struct isp_3dnr_update *dnr3_update)
 #ifdef NR200
     u32 isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl));
     REG_SET_SLICE(isp_ctrl, MRV_ISP_ISP_GEN_CFG_UPD, 1);
-    
+
     isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl);
 #endif
 	return 0;
@@ -388,7 +388,7 @@ int isp_r_3dnr(struct isp_ic_dev *dev)
 	REG_SET_SLICE(miv2_ctrl, SP2_RAW_RDMA_PATH_ENABLE, 1);
 	REG_SET_SLICE(miv2_ctrl, SP2_RAW_PATH_ENABLE, 1);
 	isp_write_reg(dev, REG_ADDR(miv2_ctrl), miv2_ctrl);
-	
+
 
 #ifndef NR200
 	in_width = isp_read_reg(dev, REG_ADDR(isp_acq_h_size));
@@ -398,9 +398,9 @@ int isp_r_3dnr(struct isp_ic_dev *dev)
 	in_height = isp_read_reg(dev, REG_ADDR(isp_out_v_size));
 #endif
     lval = (in_width * 12 + 127)/ 128;
-		
+
     lval <<= 4;
-		
+
     size = in_height * lval;        //raw12 unaligned
 	//write reference frame config
 	isp_write_reg(dev, REG_ADDR(miv2_sp2_raw_base_ad_init), dev->dnr3.pa);
@@ -412,13 +412,13 @@ int isp_r_3dnr(struct isp_ic_dev *dev)
 	isp_write_reg(dev, REG_ADDR(miv2_sp2_raw_pic_size), size);
 
     miv2_sp2_bus_id = isp_read_reg(dev, REG_ADDR(miv2_sp2_bus_id));
-    
+
     REG_SET_SLICE(miv2_sp2_bus_id, SP2_WR_ID_EN, 1);
     REG_SET_SLICE(miv2_sp2_bus_id, SP2_RD_ID_EN, 1);
     REG_SET_SLICE(miv2_sp2_bus_id, SP2_RD_BURST_LEN, 2); //sp2 rd burst lenghth 16
     REG_SET_SLICE(miv2_sp2_bus_id, SP2_BUS_SW_EN, 1);
-    
-    isp_write_reg(dev, REG_ADDR(miv2_sp2_bus_id), miv2_sp2_bus_id); 
+
+    isp_write_reg(dev, REG_ADDR(miv2_sp2_bus_id), miv2_sp2_bus_id);
 
     miv2_sp2_fmt = isp_read_reg(dev, REG_ADDR(miv2_sp2_fmt));
     REG_SET_SLICE(miv2_sp2_fmt, SP2_WR_RAW_BIT, 2);    //raw12
@@ -427,8 +427,8 @@ int isp_r_3dnr(struct isp_ic_dev *dev)
     REG_SET_SLICE(miv2_sp2_fmt, SP2_RD_RAW_BIT, 2);   //raw12
     REG_SET_SLICE(miv2_sp2_fmt, SP2_RD_RAW_ALIGNED, 0); //unaligned
 
-	isp_write_reg(dev, REG_ADDR(miv2_sp2_fmt), miv2_sp2_fmt); 
-	
+	isp_write_reg(dev, REG_ADDR(miv2_sp2_fmt), miv2_sp2_fmt);
+
 	//read reference frame config
 	isp_write_reg(dev, REG_ADDR(miv2_sp2_dma_raw_pic_start_ad), dev->dnr3.pa);
 	isp_write_reg(dev, REG_ADDR(miv2_sp2_dma_raw_pic_width), in_width);

+ 2 - 2
vvcam_ry/isp/isp_3dnr2.c

@@ -201,7 +201,7 @@ int isp_s_3dnr(struct isp_ic_dev *dev)
 	u32 isp_denoise3d_strength, isp_denoise3d_motion, isp_denoise3d_delta_inv;
 	u32 isp_denoise3d_ctrl;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (dnr3->update_bin) {
 		dnr3_hw_init(dev);
     }
@@ -287,7 +287,7 @@ int isp_u_3dnr(struct isp_ic_dev *dev, struct isp_3dnr_update *dnr3_update)
 
 	u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d_strength));
 	REG_SET_SLICE(regVal, DENOISE3D_STRENGTH, dev->dnr3.strength);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d_strength), regVal);

+ 7 - 7
vvcam_ry/isp/isp_compand.c

@@ -72,7 +72,7 @@ int isp_s_comp(struct isp_ic_dev *dev)
 	uint32_t y_data;
 	u32 isp_compand_ctrl = isp_read_reg(dev, REG_ADDR(isp_compand_ctrl));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (comp->bls.enable) {
 		isp_write_reg(dev, REG_ADDR(isp_compand_bls_a_fixed), comp->bls.a << (20 - comp->bls.bit_width));
 		isp_write_reg(dev, REG_ADDR(isp_compand_bls_b_fixed), comp->bls.b << (20 - comp->bls.bit_width));
@@ -98,9 +98,9 @@ int isp_s_comp(struct isp_ic_dev *dev)
 			    ((comp->expand.px[ri * 6 + 5] + (20-comp->expand.in_bit)) << 25);
 			isp_write_reg(dev, REG_ADDR(isp_compand_expand_px_0) + ri * 4, valr);
 		}
-		valr = ( comp->expand.px[60] + (20-comp->expand.in_bit)) | 
-		       ((comp->expand.px[61] + (20-comp->expand.in_bit)) << 5) | 
-		       ((comp->expand.px[62] + (20-comp->expand.in_bit)) << 10) | 
+		valr = ( comp->expand.px[60] + (20-comp->expand.in_bit)) |
+		       ((comp->expand.px[61] + (20-comp->expand.in_bit)) << 5) |
+		       ((comp->expand.px[62] + (20-comp->expand.in_bit)) << 10) |
 		       ((comp->expand.px[63] + (20-comp->expand.in_bit)) << 15);
 		isp_write_reg(dev, REG_ADDR(isp_compand_expand_px_10), valr);
 
@@ -109,13 +109,13 @@ int isp_s_comp(struct isp_ic_dev *dev)
 			x_data = (comp->expand.x_data[ri] << (20 - comp->expand.in_bit));
 			isp_write_reg(dev, REG_ADDR(isp_compand_expand_x_write_data), x_data);
 		}
-		
+
 		isp_write_reg(dev, REG_ADDR(isp_compand_expand_y_addr), 0x0);
 		for (ri = 0; ri < 64; ri++) {
 			y_data = (comp->expand.y_data[ri] << (20 - comp->expand.out_bit));
 			isp_write_reg(dev, REG_ADDR(isp_compand_expand_y_write_data), y_data);
 		}
-	
+
 	}
 
 	if (comp->compress.enable && comp->compress.update_curve) {
@@ -136,7 +136,7 @@ int isp_s_comp(struct isp_ic_dev *dev)
 			x_data = (comp->compress.x_data[ri] << (20 - comp->compress.in_bit));
 			isp_write_reg(dev, REG_ADDR(isp_compand_compress_x_write_data), x_data);
 		}
-		
+
 		isp_write_reg(dev, REG_ADDR(isp_compand_compress_y_addr), 0x0);
 		for (ri = 0; ri < 64; ri++) {
 			y_data = (comp->compress.y_data[ri] << (20 - comp->compress.out_bit));

+ 11 - 11
vvcam_ry/isp/isp_dmsc2.c

@@ -65,7 +65,7 @@ int isp_enable_dmsc(struct isp_ic_dev *dev)
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 	u32 isp_dmsc_size_ctrl =
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_size_ctrl));
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_BYPASS, 0U);
 	REG_SET_SLICE(isp_dmsc_size_ctrl, ISP_DMSC_IMAGE_H_SIZE,
 		      isp_read_reg(dev, REG_ADDR(isp_acq_h_size)));
@@ -81,7 +81,7 @@ int isp_disable_dmsc(struct isp_ic_dev *dev)
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 	isp_dmsc_ctrl = 0;	//clear fpga default bit 3 and 13 to keep the same value with cmodel.
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_BYPASS, 1U);
 
 	/*clear the reg default val to keep weith cmodel  */
@@ -103,7 +103,7 @@ int isp_disable_dmsc(struct isp_ic_dev *dev)
 int isp_set_dmsc_intp(struct isp_ic_dev *dev)
 {
 	u32 isp_dmsc_intp_thr = isp_read_reg(dev, REG_ADDR(isp_dmsc_intp_thr));
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	REG_SET_SLICE(isp_dmsc_intp_thr, ISP_DMSC_INTERPLATION_DIR_THR_MAX,
 		      dev->demosaic.intp.intp_dir_thr_max);
 	REG_SET_SLICE(isp_dmsc_intp_thr, ISP_DMSC_INTERPLATION_DIR_THR_MIN,
@@ -123,7 +123,7 @@ int isp_set_dmsc_dmoi(struct isp_ic_dev *dev)
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_dmoi_patn_thr));
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	if (!pDemoire->enable) {
 		REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_DEMOIRE_ENABLE, 0U);
@@ -172,7 +172,7 @@ int isp_set_dmsc_sharpen(struct isp_ic_dev *dev)
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_shap_ratio));
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	if (!pSharpen->enable) {
 		REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_SHARPEN_ENBALE, 0);
@@ -222,7 +222,7 @@ int isp_set_dmsc_gfilter(struct isp_ic_dev *dev)
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_shap_filt1));
 	u32 isp_dmsc_shap_filt2 =
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_shap_filt2));
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	REG_SET_SLICE(isp_dmsc_shap_filt1, ISP_DMSC_HF_FILT_00,
 		      pgfilter->hf_filt_00);
@@ -261,7 +261,7 @@ int isp_set_dmsc_sharpen_line(struct isp_ic_dev *dev)
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_shap_line_ratio));
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	if (!sharpenLine->enable) {
 		REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_SHARPEN_LINE_ENABLE, 0);
@@ -299,7 +299,7 @@ int isp_set_dmsc_cac(struct isp_ic_dev *dev)
 	u32 val = 0;
 	u32 isp_dmsc_cac_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_cac_ctrl));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	if (!cac->enable) {
 		REG_SET_SLICE(isp_dmsc_cac_ctrl, MRV_CAC_CAC_EN, 0);
@@ -336,7 +336,7 @@ int isp_set_dmsc_depurple(struct isp_ic_dev *dev)
 	    isp_read_reg(dev, REG_ADDR(isp_dmsc_dpul_ctrl));
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (!depurple->enable) {
 		REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_DEPURPLE_ENABLE, 0U);
 		isp_write_reg(dev, REG_ADDR(isp_dmsc_ctrl), isp_dmsc_ctrl);
@@ -368,7 +368,7 @@ int isp_set_dmsc_skin(struct isp_ic_dev *dev)
 
 	u32 isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (!skin->enable) {
 		REG_SET_SLICE(isp_dmsc_ctrl, ISP_DEMOSAIC_SKIN_ENABLE, 0U);
 		isp_write_reg(dev, REG_ADDR(isp_dmsc_ctrl), isp_dmsc_ctrl);
@@ -406,7 +406,7 @@ int isp_s_dmsc(struct isp_ic_dev *dev)
 	isp_disable_dmsc(dev);
 
 	isp_dmsc_ctrl = isp_read_reg(dev, REG_ADDR(isp_dmsc_ctrl));
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (!dev->demosaic.enable) {
 		isp_disable_dmsc(dev);
 		return 0;

+ 5 - 5
vvcam_ry/isp/isp_gcmono.c

@@ -70,7 +70,7 @@ int isp_enable_gcmono(struct isp_ic_dev *dev)
 	u32 isp_gcmono_ctrl = isp_read_reg(dev, REG_ADDR(isp_gcmono_ctrl));
 	u32 isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	REG_SET_SLICE(isp_gcmono_ctrl, ISP_GCMONO_CFG_DONE, 1);
 	REG_SET_SLICE(isp_gcmono_ctrl, ISP_GCMONO_SWITCH,
 		      ISP_GCMONO_SWITCH_ENABLE);
@@ -92,7 +92,7 @@ int isp_disable_gcmono(struct isp_ic_dev *dev)
 	u32 isp_gcmono_ctrl = isp_read_reg(dev, REG_ADDR(isp_gcmono_ctrl));
 	u32 isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	REG_SET_SLICE(isp_gcmono_ctrl, ISP_GCMONO_SWITCH,
 		      ISP_GCMONO_SWITCH_DISABLE);
 	isp_write_reg(dev, REG_ADDR(isp_gcmono_ctrl), isp_gcmono_ctrl);
@@ -111,7 +111,7 @@ static int isp_s_gcmonopx(struct isp_ic_dev *dev, struct isp_gcmono_data *data)
 	int i;
 	u32 gc_px_data = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	p_table = (u32 *)&data->px;
 	for (i = 0; i < 64; i++) {
 		gc_px_data |= (*(p_table + i) << (i % 6 * 5));
@@ -133,7 +133,7 @@ static int isp_s_gcmonoWriteData(struct isp_ic_dev *dev, u32 *tblX, u32 *tblY)
 	int i;
 	// u32 gc_px_data = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	isp_write_reg(dev, REG_ADDR(isp_gcmono_y_addr), 0);
 	isp_write_reg(dev, REG_ADDR(isp_gcmono_x_addr), 0);
 	for (i = 0; i < 64; i++) {
@@ -161,7 +161,7 @@ int isp_s_gcmono(struct isp_ic_dev *dev, struct isp_gcmono_data *data)
 	u8 *p_table = NULL;
 	int i;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	REG_SET_SLICE(isp_gcmono_ctrl, ISP_GCMONO_SWITCH,
 		      ISP_GCMONO_SWITCH_DISABLE);
 	REG_SET_SLICE(isp_gcmono_ctrl, ISP_GCMONO_CFG_DONE,

+ 5 - 5
vvcam_ry/isp/isp_hdr.c

@@ -68,7 +68,7 @@ int isp_s_hdr(struct isp_ic_dev *dev)
 	u32 val;
 	int i;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	val = 0;
 #if 0
@@ -181,7 +181,7 @@ int isp_s_hdr_wb(struct isp_ic_dev *dev)
 	u32 isp_stitching_ctrl =
 	    isp_read_reg(dev, REG_ADDR(isp_stitching_ctrl));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	REG_SET_SLICE(val, STITCHING_EXP0_AWB_GAIN_GR, hdr->gr);
 	REG_SET_SLICE(val, STITCHING_EXP0_AWB_GAIN_GB, hdr->gb);
 	isp_write_reg(dev, REG_ADDR(isp_stitching_exp0_awb_gain_g), val);
@@ -208,7 +208,7 @@ int isp_s_hdr_bls(struct isp_ic_dev *dev)
 	u32 val = 0;
 	int i;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	for (i = 0; i < 12; i++) {
 		val = 0;
@@ -228,7 +228,7 @@ int isp_enable_hdr(struct isp_ic_dev *dev)
 	u32 dpcl;
 	int val = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	addr = REG_ADDR(isp_stitching_ctrl);
 	isp_stitching_ctrl = isp_read_reg(dev, addr);
 	REG_SET_SLICE(val, STITCHING_FRAME_WIDTH, dev->ctx.acqWindow.width);
@@ -250,7 +250,7 @@ int isp_disable_hdr(struct isp_ic_dev *dev)
 {
 	u32 addr, isp_stitching_ctrl = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	addr = REG_ADDR(isp_stitching_ctrl);
 	isp_stitching_ctrl = isp_read_reg(dev, addr);
 	REG_SET_SLICE(isp_stitching_ctrl, STITCHING_COMBINE_ENABLE_BIT, 1);

+ 14 - 21
vvcam_ry/isp/isp_ioctl.c

@@ -63,16 +63,7 @@
 #include <linux/regmap.h>
 #include <linux/of_reserved_mem.h>
 #endif
-
-#ifdef CONFIG_VSI_ISP_DEBUG
-#define isp_info(fmt, ...)	pr_info(fmt, ##__VA_ARGS__)
-#define isp_debug(fmt, ...)  pr_debug(fmt, ##__VA_ARGS__)
-#define isp_err(fmt, ...)  pr_err(fmt, ##__VA_ARGS__)
-#else
-#define isp_info(fmt, ...)
-#define isp_debug(fmt, ...)
-#define isp_err(fmt, ...)  pr_err(fmt, ##__VA_ARGS__)
-#endif
+#include "isp_ioctl.h"
 
 volatile MrvAllRegister_t *all_regs = NULL;
 
@@ -87,7 +78,7 @@ void isp_ic_set_hal(HalHandle_t hal)
 
 void isp_write_reg(struct isp_ic_dev *dev, u32 offset, u32 val)
 {
-	//pr_info("%s addr 0x%08x val 0x%08x\n", __func__, offset, val);
+	//isp_info("%s addr 0x%08x val 0x%08x\n", __func__, offset, val);
 	if (offset >= ISP_REG_SIZE)
 		return;
 	HalWriteReg(hal_handle, offset, val);
@@ -935,7 +926,8 @@ int isp_start_stream(struct isp_ic_dev *dev, u32 numFrames)
 	isp_imsc = isp_read_reg(dev, REG_ADDR(isp_imsc));
 	isp_imsc |=
 	    (MRV_ISP_IMSC_ISP_OFF_MASK | MRV_ISP_IMSC_FRAME_MASK |
-	     MRV_ISP_IMSC_FRAME_IN_MASK | MRV_ISP_IMSC_PIC_SIZE_ERR_MASK | MRV_ISP_IMSC_FLASH_ON_MASK | MRV_ISP_IMSC_FLASH_OFF_MASK);
+	     MRV_ISP_IMSC_FRAME_IN_MASK | MRV_ISP_IMSC_PIC_SIZE_ERR_MASK | MRV_ISP_IMSC_FLASH_ON_MASK | MRV_ISP_IMSC_FLASH_OFF_MASK |
+		 MRV_ISP_IMSC_DATA_LOSS_MASK | MRV_ISP_IMSC_SHUTTER_OFF_MASK | MRV_ISP_MIS_VSM_END_MASK);
 	/* isp_imsc |= (MRV_ISP_IMSC_FRAME_MASK | MRV_ISP_IMSC_DATA_LOSS_MASK | MRV_ISP_IMSC_FRAME_IN_MASK); */
 	isp_write_reg(dev, REG_ADDR(isp_icr), 0xFFFFFFFF);
 	isp_write_reg(dev, REG_ADDR(isp_imsc), isp_imsc);
@@ -1190,7 +1182,7 @@ int isp_ioc_read_mis(struct isp_ic_dev *dev, void __user *args)
 {
 	isp_mis_list_t* pCList = &dev->circle_list;
 	isp_mis_t mis_data;
-	u32 ary[2];
+	u64 ary[2];
 	int ret = -1;
 	ret = isp_irq_read_circle_queue(&mis_data, pCList);
 	if (ret < 0) {
@@ -1198,7 +1190,8 @@ int isp_ioc_read_mis(struct isp_ic_dev *dev, void __user *args)
 		return ret;
 	}
 
-    /*isp_info("%s  irq src %d val 0x%08x\n", __func__, mis_data.irq_src, mis_data.val);*/
+    /*isp_info("%s  irq src %d val 0x%lx\n", __func__, mis_data.irq_src, mis_data.val);*/
+
 	ary[0] = mis_data.irq_src;
 	ary[1] = mis_data.val;
 	viv_check_retval(copy_to_user(args, ary, sizeof( ary)));
@@ -1330,9 +1323,9 @@ int isp_s_hdrexp(struct isp_ic_dev *dev)
 	u32 isp_hdr_exp_conf = isp_read_reg(dev, REG_ADDR(isp_hdr_exp_conf));
 	u32 isp_stitching_imsc = isp_read_reg(dev, REG_ADDR(isp_stitching_imsc));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (!dev->hdrexp.enable) {
-        pr_info("%s, hdr disabled\n",__func__);
+        isp_info("%s, hdr disabled\n",__func__);
 		REG_SET_SLICE(isp_hdr_exp_conf, MRV_HDR_EXP_START, 0);
 		isp_write_reg(dev, REG_ADDR(isp_hdr_exp_conf), isp_hdr_exp_conf);
 		isp_write_reg(dev, REG_ADDR(isp_stitching_imsc), isp_stitching_imsc & ~0x38);
@@ -1374,7 +1367,7 @@ int isp_g_hdrexpmean(struct isp_ic_dev *dev, u8 * mean)
 {
 	int i = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (!dev || !mean)
 		return -EINVAL;
 	for (; i < 75; i++) {
@@ -1482,9 +1475,9 @@ int isp_s_hdrhist(struct isp_ic_dev *dev)
 	u32 isp_hdr_hist_prop = isp_read_reg(dev, REG_ADDR(isp_hdr_hist_prop));
 	u32 isp_stitching_imsc = isp_read_reg(dev, REG_ADDR(isp_stitching_imsc));
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (!dev->hdrhist.enable) {
-		pr_info("%s, hdr disable\n", __func__);
+		isp_info("%s, hdr disable\n", __func__);
 		REG_SET_SLICE(isp_hdr_hist_prop, MRV_HIST_MODE, MRV_HIST_MODE_NONE);
 		isp_write_reg(dev, REG_ADDR(isp_hdr_hist_prop), isp_hdr_hist_prop);
 		isp_write_reg(dev, REG_ADDR(isp_stitching_imsc),
@@ -1532,7 +1525,7 @@ int isp_g_hdrhistmean(struct isp_ic_dev *dev, u32 * mean)
 {
 	int i = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (!dev || !mean)
 		return -EINVAL;
 
@@ -2813,7 +2806,7 @@ long isp_priv_ioctl(struct isp_ic_dev *dev, unsigned int cmd, void __user *args)
 	if (!dev) {
 		return ret;
 	}
-	/*pr_info("ry [%s:%d]cmd 0x%08x\n", __func__, __LINE__, cmd);*/
+	/*isp_info("ry [%s:%d]cmd 0x%08x\n", __func__, __LINE__, cmd);*/
 	switch (cmd) {
 	case ISPIOC_RESET:
 		if((ret = isp_mi_stop(dev)) != 0 )

+ 6 - 5
vvcam_ry/isp/isp_ioctl.h

@@ -216,20 +216,21 @@ enum {
 	uint32_t isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl));       \
 	REG_SET_SLICE(isp_ctrl, MRV_ISP_ISP_GEN_CFG_UPD, 1);			\
 	isp_write_reg(dev, REG_ADDR(isp_ctrl), isp_ctrl);               \
-	}	
+	}
 
 #define CONFIG_VSI_ISP_DEBUG 1
 #ifdef CONFIG_VSI_ISP_DEBUG
-#define isp_info(fmt, ...)  pr_info(fmt, ##__VA_ARGS__)
-#define isp_debug(fmt, ...)  pr_debug(fmt, ##__VA_ARGS__)
-#define isp_err(fmt, ...)  pr_err(fmt, ##__VA_ARGS__)
+#define isp_info(fmt, ...) printk(KERN_DEBUG   pr_fmt(fmt), ##__VA_ARGS__)
+#define isp_debug(fmt, ...) printk(KERN_DEBUG   pr_fmt(fmt), ##__VA_ARGS__)
+#define isp_warn(fmt, ...) printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+#define isp_err(fmt, ...)  printk(KERN_ERR     pr_fmt(fmt), ##__VA_ARGS__)
 #else
 #define isp_info(fmt, ...)
 #define isp_debug(fmt, ...)
 #define isp_err(fmt, ...)  pr_err(fmt, ##__VA_ARGS__)
 #endif
 
-#define ISP_REG_GAP 4												        
+#define ISP_REG_GAP 4
 long isp_priv_ioctl(struct isp_ic_dev *dev, unsigned int cmd, void __user *args);
 long isp_copy_data(void *dst, void *src, int size);
 

+ 17 - 16
vvcam_ry/isp/isp_irq_queue.c

@@ -79,6 +79,7 @@
 #include <stdbool.h>
 #endif
 #include "isp_irq_queue.h"
+#include "isp_ioctl.h"
 
   //enqueue
 int isp_irq_enqueue(isp_mis_t *new,isp_mis_t* head)
@@ -88,12 +89,12 @@ int isp_irq_enqueue(isp_mis_t *new,isp_mis_t* head)
 
 
     if (new == NULL || head == NULL) {
-        //printk("%s: input wrong parameter\n", __func__);
+        //isp_info("%s: input wrong parameter\n", __func__);
         return -1;
     }
     new_node->val = new->val;
     new_node->irq_src = new->irq_src;
-    /*printk("%s: new_node %px irq_src %d", __func__, new_node,  new->irq_src);*/
+    /*isp_info("%s: new_node %px irq_src %d", __func__, new_node,  new->irq_src);*/
     INIT_LIST_HEAD(&new_node->list);
     list_add_tail(&new_node->list, &head->list);             //append to tail
  #endif
@@ -108,16 +109,16 @@ int isp_irq_dequeue(isp_mis_t* data, isp_mis_t* head)
 #ifdef __KERNEL__
     isp_mis_t* entry;
     if (data == NULL || head == NULL) {
-        //printk("%s: input wrong parameter\n", __func__);
+        //isp_info("%s: input wrong parameter\n", __func__);
         return -1;
     }
     if (list_empty(&head->list)) {
-        //printk("%s: There is no node\n", __func__);
+        //isp_info("%s: There is no node\n", __func__);
         return -1;
     }
 
     entry = list_first_entry(&head->list, isp_mis_t, list);
-    /*printk("%s: entry %px irq_src %d", __func__, entry,  entry->irq_src);*/
+    /*isp_info("%s: entry %px irq_src %d", __func__, entry,  entry->irq_src);*/
     data->val = entry->val;
     data->irq_src = entry->irq_src;
     list_del_init(&entry->list);
@@ -141,7 +142,7 @@ int isp_irq_create_circle_queue(isp_mis_list_t* pCList, int number)
   int i;
   isp_mis_t* pMisNode;
   if (pCList == NULL || number <= 0) {
-      printk("%s: create circle queue failed\n", __func__);
+      isp_info("%s: create circle queue failed\n", __func__);
       return -1;
   }
 
@@ -152,12 +153,12 @@ int isp_irq_create_circle_queue(isp_mis_list_t* pCList, int number)
       pCList->pRead = pCList->pHead;
       pCList->pWrite = pCList->pHead;
   }
-  printk("%s:pHead %px\n", __func__, pCList->pHead);
+  isp_info("%s:pHead %px\n", __func__, pCList->pHead);
   for (i = 0; i < number - 1; i++) {
       pMisNode = (isp_mis_t*)kmalloc(sizeof(isp_mis_t), GFP_KERNEL);
       INIT_LIST_HEAD(&pMisNode->list);
       list_add_tail(&pMisNode->list, &pCList->pHead->list);
-      printk("%s:pMisNode %px\n", __func__, pMisNode);
+      isp_info("%s:pMisNode %px\n", __func__, pMisNode);
   }
 
 #endif
@@ -169,18 +170,18 @@ int isp_irq_destroy_circle_queue(isp_mis_list_t* pCList)
 #ifdef __KERNEL__
   isp_mis_t* pMisNode;
   if ((pCList == NULL) || (pCList->pHead == NULL) ) {
-      printk("%s: destroy circle queue failed. pClist %px\n", __func__, pCList);
+      isp_info("%s: destroy circle queue failed. pClist %px\n", __func__, pCList);
       return -1;
   }
 
   while(!list_empty(&pCList->pHead->list)) {
       pMisNode = list_first_entry(&pCList->pHead->list, isp_mis_t, list);
-      printk("%s:pMisNode %px\n", __func__, pMisNode);
+      isp_info("%s:pMisNode %px\n", __func__, pMisNode);
       list_del(&pMisNode->list);
       kfree(pMisNode);
       pMisNode = NULL;
   }
-  printk("%s:pHead %px\n", __func__, pCList->pHead);
+  isp_info("%s:pHead %px\n", __func__, pCList->pHead);
   kfree(pCList->pHead);
   pCList->pHead = NULL;
   pCList->pRead = NULL;
@@ -194,17 +195,17 @@ int isp_irq_read_circle_queue(isp_mis_t* data, isp_mis_list_t* pCList)
 #ifdef __KERNEL__
   //isp_mis_t* pReadEntry;
   if (pCList == NULL) {
-      printk("%s: can not read circle queue\n", __func__);
+      isp_info("%s: can not read circle queue\n", __func__);
       return -1;
   }
 
   if (pCList->pRead == pCList->pWrite) {
-    /*printk("%s: There is no irq mis data\n", __func__);*/
+    /*isp_info("%s: There is no irq mis data\n", __func__);*/
     return -1;
   }
   data->val = pCList->pRead->val;
   data->irq_src = pCList->pRead->irq_src;
-  /*printk("%s: entry %px irq_src %d, msi %08x\n", __func__, pCList->pRead,  data->irq_src, data->val);*/
+  /*isp_info("%s: entry %px irq_src %d, msi %08x\n", __func__, pCList->pRead,  data->irq_src, data->val);*/
   /*Get the next entry that link with read entry list*/
   /*Update read pointer to next entry*/
   pCList->pRead = list_first_entry(&pCList->pRead->list, isp_mis_t, list);
@@ -220,13 +221,13 @@ int isp_irq_write_circle_queue(isp_mis_t* data, isp_mis_list_t* pCList)
 #ifdef __KERNEL__
   isp_mis_t* pWriteEntry;
   if (pCList == NULL) {
-      printk("%s: can not read circle queue\n", __func__);
+      isp_info("%s: can not read circle queue\n", __func__);
       return -1;
   }
 
   pCList->pWrite->val = data->val;
   pCList->pWrite->irq_src = data->irq_src;
-  /*printk("%s: entry %px irq_src %d, msi %08x\n", __func__,  pCList->pWrite,  data->irq_src, data->val);*/
+  /*isp_info("%s: entry %px irq_src %d, msi %08x\n", __func__,  pCList->pWrite,  data->irq_src, data->val);*/
   /*get the next write entry pointer that link with the write entry list*/
   pWriteEntry = list_first_entry(&pCList->pWrite->list, isp_mis_t, list);
 

+ 2 - 2
vvcam_ry/isp/isp_irq_queue.h

@@ -68,8 +68,8 @@
 } isp_src_t;
 
 typedef struct isp_mis_s {
-	unsigned int irq_src;
-	unsigned int val;
+	uint64_t irq_src;
+	uint64_t val;
 #ifdef __KERNEL__
   struct list_head list;
 #endif

+ 28 - 26
vvcam_ry/isp/isp_miv2.c

@@ -71,7 +71,7 @@ static int getRawBit(u32 type, u32 *bit, u32 *len)
 		*bit = 0;
 		*len = 8;
 		break;
-#if 0				/* normal process,  need pass type from engine. */
+#if 1
 	case ISP_PICBUF_TYPE_RAW10:
 		*bit = 1;
 		break;
@@ -190,7 +190,7 @@ static void set_raw_buffer(struct isp_ic_dev *dev, struct isp_buffer_context *bu
 			buf->addr_y = dev->pp_write.buf_addr;
 			buf->size_y = dev->pp_write.buf_size;
 		}
-	/*pr_info("%s path %d type %d addr %08x line_num = %d buf_addr = 0x%x, buf_size = %d\n",
+	/*isp_info("%s path %d type %d addr %08x line_num = %d buf_addr = 0x%x, buf_size = %d\n",
 		__func__, buf->path, buf->type, addr, line_num, buf->addr_y, buf->size_y);*/
 	if (isRaw(buf->type)) {
 		if (addr != 0) {
@@ -282,7 +282,7 @@ int isp_ioc_cfg_dma(struct isp_ic_dev *dev, void __user *args)
 	u32 bus_id;
 	u32 path_rd_fmt_bit = 0;
 	u8 id;
-	struct isp_dma_path_context  dma_path_ctx[] = 
+	struct isp_dma_path_context  dma_path_ctx[] =
 #ifndef ISP_MI_PP_READ_RY
 		{{REG_ADDR(miv2_mcm_ctrl), REG_ADDR(miv2_mcm_fmt), REG_ADDR(miv2_mcm_bus_cfg), REG_ADDR(miv2_mcm_bus_id),
 		REG_ADDR(miv2_imsc), MCM_RD_FMT_ALIGNED_MASK, MCM_RD_RAW_BIT_MASK, MCM_RD_CFG_UPD_MASK, MCM_RD_AUTO_UPDATE_MASK, \
@@ -317,16 +317,16 @@ int isp_ioc_cfg_dma(struct isp_ic_dev *dev, void __user *args)
 		REG_ADDR(isp_mi_pp_dma_y_pic_lval), 0, PP_DMA_START_MASK}};
 #endif
 	if (dev == NULL || args == NULL) {
-		pr_info("input wrong parameter %s\n", __func__);
+		isp_info("input wrong parameter %s\n", __func__);
 		return -1;
 	}
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	viv_check_retval(copy_from_user(&dma, args, sizeof(dma)));
 	id = dma.id;
 	if ( id > ISP_MI_DMA_ID_MAX){
-		pr_info("id config wrong %s\n", __func__);
+		isp_info("id config wrong %s\n", __func__);
 		return -1;
 	}
 	path_fmt = isp_read_reg(dev,  dma_path_ctx[id].fmt_addr);
@@ -377,7 +377,7 @@ int isp_ioc_cfg_dma(struct isp_ic_dev *dev, void __user *args)
 		}
 
 		llength <<= 4;
-		mi_set_slice(&path_fmt, dma_path_ctx[id].rd_fmt_align,  dma.align);
+		mi_set_slice(&path_fmt, dma_path_ctx[id].rd_fmt_align, dma.align);
 
 	} else {
 		getRawBit(dma.type, &path_rd_fmt_bit, &llength);        //The old version load all kinds of raw format with raw16 format except raw8
@@ -386,6 +386,7 @@ int isp_ioc_cfg_dma(struct isp_ic_dev *dev, void __user *args)
 			path_rd_fmt_bit = 1;
 		}
 		mi_set_slice(&path_fmt, dma_path_ctx[id].rd_raw_bit, path_rd_fmt_bit);
+		mi_set_slice(&path_fmt, dma_path_ctx[id].rd_fmt_align, dma.align); // 2:align mode1
 	}
 
 /*	if (llength != 8)
@@ -468,11 +469,11 @@ int isp_ioc_start_dma_read(struct isp_ic_dev *dev, void __user *args)
 	 u32 mi_hdr_ret_ctrl;
 	 u32 rd_wr_str;
 	if (dev == NULL || args == NULL) {
-		pr_info("input wrong parameter %s\n", __func__);
+		isp_info("input wrong parameter %s\n", __func__);
 		return -1;
 	}
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	viv_check_retval(copy_from_user(&dma_path, args, sizeof(dma_path)));
 	if (dma_path == ISP_MI_DMA_PATH_MCM_PP) {
 #ifndef ISP_MI_PP_READ_RY
@@ -665,7 +666,7 @@ struct miv2_path_address {
 static void disable_bus_timeo_intr(struct isp_ic_dev *dev, u32 bus_addr)
 {
 	u32 val;
-	pr_info("%s  bus timeo interrupt register addr 0x%08x\n", __func__, bus_addr);
+	isp_info("%s  bus timeo interrupt register addr 0x%08x\n", __func__, bus_addr);
 	val = isp_read_reg(dev, bus_addr);
 	REG_SET_SLICE(val, MP_BUS_TIMEO_INTERRUPT_DISABLE, 1);
 	isp_write_reg(dev, bus_addr, val);
@@ -784,7 +785,7 @@ static void set_data_path(int id, struct isp_mi_data_path_context *path,
 	if (path_list[id].format_conv_ctrl) {
 		conv_format_ctrl = isp_read_reg(dev, path_list[id].format_conv_ctrl);
 	}
-	pr_err("mi %s  id %d  fmt_bit[id].raw_bit 0x%08x miv2_ctrl 0x%08x ", __func__, id, path_list[id].raw_enable_bit, miv2_ctrl);
+	pr_debug("mi %s  id %d  fmt_bit[id].raw_bit 0x%08x miv2_ctrl 0x%08x ", __func__, id, path_list[id].raw_enable_bit, miv2_ctrl);
 
 	path_ctrl = isp_read_reg(dev, path_list[id].path_ctrl_addr);
 	switch (path->out_mode) {
@@ -963,7 +964,7 @@ static void set_data_path(int id, struct isp_mi_data_path_context *path,
 		 if (line_num != 0) {
 		 	y_llength = y_llength & 0xff ? (y_llength & 0xffffff00 + 0x100):y_llength;
 		}
-		pr_info("%s:line_num = %d y_llength = 0x%x\n", __func__, line_num, y_llength);
+		isp_info("%s:line_num = %d y_llength = 0x%x\n", __func__, line_num, y_llength);
 		isp_write_reg(dev, REG_ADDR(isp_mi_pp_y_llength), y_llength);
 		isp_write_reg(dev, path_list[id].raw_pic_size_addr, path->out_height * y_llength );
 #else
@@ -1005,7 +1006,7 @@ static void set_data_path(int id, struct isp_mi_data_path_context *path,
 	}
 #endif
 
-	pr_info("%s:path_ctrl 0x%08x\n", __func__, path_ctrl);
+	isp_info("%s:path_ctrl 0x%08x\n", __func__, path_ctrl);
 	acq_proc = isp_read_reg(dev, REG_ADDR(isp_acq_prop));
 	isp_write_reg(dev, REG_ADDR(isp_acq_prop),
 		      acq_proc & ~MRV_ISP_LATENCY_FIFO_SELECTION_MASK);
@@ -1062,7 +1063,7 @@ int isp_mi_start(struct isp_ic_dev *dev)
 	int i;
 	struct isp_mi_context mi = *(&dev->mi);
 	u32 imsc, miv2_mcm_bus_id;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	miv2_mcm_bus_id = isp_read_reg(dev, REG_ADDR(miv2_mcm_bus_id));
 	miv2_mcm_bus_id |= MCM_BUS_SW_EN_MASK;
@@ -1085,19 +1086,20 @@ int isp_mi_start(struct isp_ic_dev *dev)
 
 
 	//isp_write_reg(dev, REG_ADDR(miv2_imsc1), 0x7ffffff);
-	isp_write_reg(dev, REG_ADDR(miv2_imsc1), 0);
+	isp_write_reg(dev, REG_ADDR(miv2_imsc1), (MI_MP_BUS_TIMEO_MASK | MI_SP1_BUS_TIMEO_MASK | MI_SP2_BUS_TIMEO_MASK |
+		MI_MP_BUS_BUSERR_MASK | MI_SP1_BUS_BUSERR_MASK | MI_SP2_BUS_BUSERR_MASK));
 #ifdef ISP_MI_PP_WRITE_RY
 	imsc = isp_read_reg(dev, REG_ADDR(miv2_imsc2));
 	isp_write_reg(dev, REG_ADDR(miv2_imsc2),
 		      imsc | ( PPW_U_BUF_FULL_MASK | PPW_Y_BUF_FULL_MASK |
-			  PPW_V_BUF_FULL_MASK | PPR_Y_BUF_FULL_MASK | SP2_RAW2_W_BUF_FULL_MASK | 
-			  SP2_RAW2_R_BUF_FULL_MASK | HDR_W_BUF_FULL_MASK | HDR_R_BUF_FULL_MASK | 
-			  WRAP_SP2_RAW_MASK | WRAP_PPW_CR_MASK | WRAP_PPW_CB_MASK | //WRAP_PPW_Y_MASK | 
+			  PPW_V_BUF_FULL_MASK | PPR_Y_BUF_FULL_MASK | SP2_RAW2_W_BUF_FULL_MASK |
+			  SP2_RAW2_R_BUF_FULL_MASK | HDR_W_BUF_FULL_MASK | HDR_R_BUF_FULL_MASK |
+			  WRAP_SP2_RAW_MASK | WRAP_PPW_CR_MASK | WRAP_PPW_CB_MASK | //WRAP_PPW_Y_MASK |
 			  SP2_RAW2_FRAME_END_MASK | PPW_FRAME_END_MASK | HDR_VS_DMA_READY_MASK |
               HDR_S_DMA_READY_MASK | HDR_L_DMA_READY_MASK | HDR_L_DMA_READY_MASK |
 			  WRAP_HDR_VS_MASK | WRAP_HDR_S_MASK | WRAP_HDR_L_MASK | HDR_VS_FRAME_END_MASK |
 			  HDR_S_FRAME_END_MASK | HDR_L_FRAME_END_MASK | MI_RT_BUS_BUSERR_MASK |
-			  MI_RT_BUS_TIMEO_MASK));  
+			  MI_RT_BUS_TIMEO_MASK));
 #endif
 	isp_write_reg(dev, REG_ADDR(miv2_imsc3),  0x3f);
      /*add by shenwuyi for ppline entry must close for sdk test case*/
@@ -1111,7 +1113,7 @@ int isp_mi_start(struct isp_ic_dev *dev)
 
 int isp_mi_stop(struct isp_ic_dev *dev)
 {
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 #ifdef ISP_MI_PP_WRITE_RY
 	isp_write_reg(dev, REG_ADDR(miv2_imsc2), 0);
 #endif
@@ -1144,10 +1146,10 @@ int  isp_set_ppw_line_num(struct isp_ic_dev *dev)
 		pr_err("Wrong input %s\n", __func__);
 		return -1;
 	}
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	isp_write_reg(dev, REG_ADDR(mi_sp1_ppw_ycbcr_entry_line_num), dev->pp_write.entry_line_num);
-	pr_info("exit %s\n", __func__);
+	isp_info("exit %s\n", __func__);
 	return 0;
 }
 int  isp_get_ppw_pic_cnt(struct isp_ic_dev *dev, u16* pic_cnt)
@@ -1157,9 +1159,9 @@ int  isp_get_ppw_pic_cnt(struct isp_ic_dev *dev, u16* pic_cnt)
 		pr_err("Wrong input %s\n", __func__);
 		return -1;
 	}
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	*pic_cnt = isp_read_reg(dev, REG_ADDR(mi_sp1_ppw_ycbcr_entry_pic_cnt));
-	pr_info("exit %s\n", __func__);
+	isp_info("exit %s\n", __func__);
 	return 0;
 }
 #endif
@@ -1167,7 +1169,7 @@ int  isp_get_ppw_pic_cnt(struct isp_ic_dev *dev, u16* pic_cnt)
 #ifdef ISP_MI_PP_READ_RY
 int  isp_cfg_pp_dma_line_entry(struct isp_ic_dev *dev)
 {
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	uint32_t path_ctrl = isp_read_reg(dev,  REG_ADDR(isp_mi_pp_ctrl));
 	pp_dma_line_entry_t* pp_dam_line_entry = &dev->pp_dma_line_entry;
 	if (dev == NULL) {
@@ -1182,7 +1184,7 @@ int  isp_cfg_pp_dma_line_entry(struct isp_ic_dev *dev)
 	mi_set_slice(&path_ctrl,  PP_RD_YUV_CFG_UPDATE_MASK, 1);
 	isp_write_reg(dev, REG_ADDR(isp_mi_pp_ctrl), path_ctrl);
 #endif
-	pr_info("exit %s\n", __func__);
+	isp_info("exit %s\n", __func__);
 	return 0;
 }
 #endif

+ 18 - 18
vvcam_ry/isp/isp_tdnr3.c

@@ -73,7 +73,7 @@ int isp_tdnr_cfg_gamma(struct isp_ic_dev *dev)
 	//const u8 tdnrRegGap = 8;
 	bit_width = 12;
 
-    pr_info("enter %s\n", __func__);
+    isp_info("enter %s\n", __func__);
 
 	for (i = 0; i < DENOISE3D_GAMMA_BIN - 3; i += 5)
 	{
@@ -117,7 +117,7 @@ int  isp_s_tdnr(struct isp_ic_dev *dev)
 	/* spacial */
 	u32 strength = tdnr->strength;
 
-    pr_info("enter %s\n", __func__);
+    isp_info("enter %s\n", __func__);
 	strength = MIN(MAX(strength, 0), 128);
 
 	isp_denoise3d2_ctrl = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
@@ -134,7 +134,7 @@ int  isp_s_tdnr(struct isp_ic_dev *dev)
 		isp_write_reg(dev, REG_ADDR(isp_denoise3d2_strength), strength);
 	} else {
 		isp_write_reg(dev, REG_ADDR(isp_denoise3d2_strength), 0);
-		if (dev->tdnr.frames == 2) 
+		if (dev->tdnr.frames == 2)
 			return 0 ;
 	}
 #endif
@@ -213,7 +213,7 @@ int isp_tdnr_set_strength(struct isp_ic_dev *dev)
 {
 	u32 isp_denoise3d2_strength;
 	struct isp_tdnr_context *tdnr = &dev->tdnr;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	isp_denoise3d2_strength = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_strength));
 	REG_SET_SLICE(isp_denoise3d2_strength, DENOISE3D_V20_TNR_STRENGTH, tdnr->strength);
@@ -227,7 +227,7 @@ int isp_tdnr_set_motion(struct isp_ic_dev *dev)
 {
 	struct isp_tdnr_context *tdnr = &dev->tdnr;
 	u32 isp_denoise3d2_motion_inv;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	isp_denoise3d2_motion_inv = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_motion_inv));
 	REG_SET_SLICE(isp_denoise3d2_motion_inv, DENOISE3D_V20_MOTION_INV, tdnr->motion_inv_factor);
@@ -240,7 +240,7 @@ int isp_tdnr_enable(struct isp_ic_dev *dev)
 {
 	u32 regVal = 0;
 	u32 strength = dev->tdnr.strength;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
 	REG_SET_SLICE(regVal, DENOISE3D_V20_ENABLE, 1);
 	// REG_SET_SLICE(regVal, DENOISE3D_V20_REF_RESET, 1);
@@ -258,7 +258,7 @@ int isp_tdnr_disable(struct isp_ic_dev *dev)
 {
 	u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
 	// REG_SET_SLICE(regVal, DENOISE3D_V20_ENABLE, 0);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d2_ctrl), regVal);
@@ -273,7 +273,7 @@ int isp_tdnr_enable_tdnr(struct isp_ic_dev *dev)
 {
 	u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
 	REG_SET_SLICE(regVal, DENOISE3D_V20_TNR_ENABLE, 1);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d2_ctrl), regVal);
@@ -287,7 +287,7 @@ int isp_tdnr_disable_tdnr(struct isp_ic_dev *dev)
 {
 	u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
 	REG_SET_SLICE(regVal, DENOISE3D_V20_TNR_ENABLE, 0);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d2_ctrl), regVal);
@@ -300,7 +300,7 @@ int isp_tdnr_enable_2dnr(struct isp_ic_dev *dev)
 {
 	//u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	/*regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
 	REG_SET_SLICE(regVal, DENOISE3D_V20_NLM_ENABLE, 1);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d2_ctrl), regVal);*/
@@ -314,7 +314,7 @@ int isp_tdnr_disable_2dnr(struct isp_ic_dev *dev)
 {
 	//u32 regVal = 0;
 
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	/*regVal = isp_read_reg(dev, REG_ADDR(isp_denoise3d2_ctrl));
 	REG_SET_SLICE(regVal, DENOISE3D_V20_NLM_ENABLE, 0);
 	isp_write_reg(dev, REG_ADDR(isp_denoise3d2_ctrl), regVal);*/
@@ -327,7 +327,7 @@ int isp_tdnr_disable_2dnr(struct isp_ic_dev *dev)
 
 int isp_tdnr_g_stats(struct isp_ic_dev *dev, struct isp_tdnr_stats *stats)
 {
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	if (!dev || !stats) {
 		return -EINVAL;
 	}
@@ -344,7 +344,7 @@ int isp_tdnr_u_noise(struct isp_ic_dev *dev)
 {
 	u32 regVal = 0;
 	struct isp_tdnr_context *tdnr = &dev->tdnr;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	regVal = 0;
 	REG_SET_SLICE(regVal, DENOISE3D_V20_NOISE_LEVEL, tdnr->noise_level);
@@ -364,7 +364,7 @@ int isp_tdnr_u_thr(struct isp_ic_dev *dev)
 {
 	u32 regVal = 0;
 	struct isp_tdnr_context *tdnr = &dev->tdnr;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	regVal = 0;
 	REG_SET_SLICE(regVal, DENOISE3D_V20_THR_UPDATE, tdnr->update_factor);
@@ -388,7 +388,7 @@ int isp_tdnr_s_buf(struct isp_ic_dev *dev)
 	u32 miv2_imsc = isp_read_reg(dev, REG_ADDR(miv2_imsc));
 	u32 miv2_sp2_ctrl = isp_read_reg(dev, REG_ADDR(miv2_sp2_ctrl));
 	u32 isp_mi_sp2_raw2_ctrl = isp_read_reg(dev, REG_ADDR(isp_mi_sp2_raw2_ctrl));
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	/*
 
@@ -427,7 +427,7 @@ int isp_tdnr_s_buf(struct isp_ic_dev *dev)
 	in_height /= 2;
 	lval = (in_width); // RAW8 output
 	size = in_height * lval;
-	pr_info("%s 0x%08x\n", __func__, REG_ADDR(isp_mi_sp2_raw2_base_ad_init));
+	isp_info("%s 0x%08x\n", __func__, REG_ADDR(isp_mi_sp2_raw2_base_ad_init));
 	isp_write_reg(dev, REG_ADDR(isp_mi_sp2_raw2_base_ad_init), buf->pa_motion);
 	isp_write_reg(dev, REG_ADDR(isp_mi_sp2_raw2_size_init), size);
 	isp_write_reg(dev, REG_ADDR(isp_mi_sp2_raw2_offs_cnt_init), 0);
@@ -510,7 +510,7 @@ int isp_r_tdnr_refer(struct isp_ic_dev *dev)
 	u32 miv2_imsc = isp_read_reg(dev, REG_ADDR(miv2_imsc));
 	u32 miv2_sp2_ctrl = isp_read_reg(dev, REG_ADDR(miv2_sp2_ctrl));
 	u32 isp_mi_sp2_raw2_ctrl = isp_read_reg(dev, REG_ADDR(isp_mi_sp2_raw2_ctrl));
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	isp_write_reg(dev, REG_ADDR(miv2_sp2_dma_raw_pic_start_ad), buf->pa_refer);
 	isp_write_reg(dev, REG_ADDR(isp_mi_sp2_dma_raw2_pic_start_ad), buf->pa_motion);
 
@@ -543,7 +543,7 @@ int isp_r_tdnr_motion(struct isp_ic_dev *dev)
 	struct isp_tdnr_buffer* buf = &dev->tdnr.buf;
 	u32 miv2_ctrl = isp_read_reg(dev, REG_ADDR(miv2_ctrl));
 	u32 isp_mi_sp2_raw2_ctrl = isp_read_reg(dev, REG_ADDR(isp_mi_sp2_raw2_ctrl));
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 	isp_write_reg(dev, REG_ADDR(isp_mi_sp2_dma_raw2_pic_start_ad), buf->pa_motion);
 
 	REG_SET_SLICE(miv2_ctrl, SP2_RAW2_RDMA_START, 1);

+ 7 - 7
vvcam_ry/isp/isp_wdr.c

@@ -63,13 +63,13 @@ int isp_s_wdr(struct isp_ic_dev *dev)
 {
     isp_wdr_context_t* wdr = &dev->wdr;
 
-    pr_info(" enter %s\n", __func__);
+    isp_info(" enter %s\n", __func__);
 
     /*update wdr configuration  after frame end when isp enable*/
     if (!is_isp_enable(dev) || wdr->changed) {
         uint32_t isp_wdr_offset, isp_wdr_ctrl;
 
-        isp_wdr_offset = isp_read_reg(dev, REG_ADDR(isp_wdr_offset)); 
+        isp_wdr_offset = isp_read_reg(dev, REG_ADDR(isp_wdr_offset));
         REG_SET_SLICE( isp_wdr_offset, MRV_WDR_LUM_OFFSET, wdr->LumOffset );
         REG_SET_SLICE( isp_wdr_offset, MRV_WDR_RGB_OFFSET, wdr->RgbOffset );
     	isp_write_reg(dev, REG_ADDR(isp_wdr_offset), isp_wdr_offset);
@@ -81,8 +81,8 @@ int isp_s_wdr(struct isp_ic_dev *dev)
     } else {
         wdr->changed = true;
     }
-    pr_info(" %s wdr.changed %d \n", __func__, wdr->changed);
-   	return 0;    
+    isp_info(" %s wdr.changed %d \n", __func__, wdr->changed);
+   	return 0;
 }
 
 int isp_s_wdr_curve(struct isp_ic_dev *dev)
@@ -102,7 +102,7 @@ int isp_s_wdr_curve(struct isp_ic_dev *dev)
 
         if (i == 0)
         {
-        
+
             isp_write_reg(dev, REG_ADDR(isp_wdr_tonecurve_1), dYi);
         }
         else if (i == 1)
@@ -125,8 +125,8 @@ int isp_s_wdr_curve(struct isp_ic_dev *dev)
     }
 
     dYi = 0x00000000;
-    
-    isp_write_reg(dev, REG_ADDR(isp_wdr_offset), dYi);    
+
+    isp_write_reg(dev, REG_ADDR(isp_wdr_offset), dYi);
     isp_write_reg(dev, REG_ADDR(isp_wdr_deltamin), 0x00100000);
 
     return 0;

+ 2 - 2
vvcam_ry/isp/isp_wdr4.c

@@ -272,12 +272,12 @@ static void wdr4_hw_init(struct isp_ic_dev *dev)
 	u32 slice_pixel_shift;
 	u32 slice_output_shift;// isp_wdr4_normalize_shift;
 	u32 isp_wdr4_shift;// isp_wdr4_gain_shift_bit;
-	pr_info("enter %s\n", __func__);
+	isp_info("enter %s\n", __func__);
 
 	width = isp_read_reg(dev, REG_ADDR(isp_acq_h_size));
 	height = isp_read_reg(dev, REG_ADDR(isp_acq_v_size));
 
-	pr_info("isp_wdr4 res: %d %d \n", width, height);
+	isp_info("isp_wdr4 res: %d %d \n", width, height);
 	/* firware initilization */
 
     isp_wdr4_strength = 128;         // valid values: [0,128]; isp_wdr4 will merge original and enhanced image

+ 71 - 21
vvcam_ry/native/isp/vvcam_isp_driver_of.c

@@ -165,11 +165,60 @@ static void vvnative_isp_work(struct work_struct *work)
 
 }
 
-static irqreturn_t vvcam_isp_irq(int irq, void *dev_id)
+static irqreturn_t vvcam_ry_isp_irq(int irq, void *dev_id)
 {
 	struct vvcam_isp_driver_dev *pdriver_dev ;
 	struct isp_ic_dev * pisp_dev;
-    u32 isp_mis, mi_mis, mi_mis_addr, mi_icr_addr;
+    u64 isp_mis, mi_mis = 0;
+
+	pdriver_dev = (struct vvcam_isp_driver_dev *)dev_id;
+	pisp_dev = pdriver_dev->private;
+    isp_mis = isp_read_reg(pisp_dev, REG_ADDR(isp_mis));
+
+  if (isp_mis) {
+	  isp_mis_t mis_data;
+	  mis_data.irq_src = SRC_ISP_IRQ;
+	  mis_data.val = isp_mis;
+	  pisp_dev->isp_mis = isp_mis;
+	  isp_irq_write_circle_queue(&mis_data, &pisp_dev->circle_list);
+	  isp_write_reg(pisp_dev, REG_ADDR(isp_icr), isp_mis);
+	  if(isp_mis & MRV_ISP_MIS_ISP_OFF_MASK) {
+		  isp_write_reg(pisp_dev, REG_ADDR(isp_imsc), isp_read_reg(pisp_dev, REG_ADDR(isp_imsc))&(~MRV_ISP_MIS_ISP_OFF_MASK));
+	  }
+  if (isp_mis & MRV_ISP_MIS_FLASH_ON_MASK)
+	  mi_mis |= 0x1;
+  }
+
+  if (isp_mis & MRV_ISP_MIS_VSM_END_MASK) { // MP_JDP_FRAME_END
+    //isp_info("%s MRV_ISP_MIS_VSM_END_MASK >>> MP_JDP_FRAME_END_MASK...\n", __func__);
+    mi_mis |= MP_JDP_FRAME_END_MASK;
+  }
+
+  if (isp_mis & MRV_ISP_MIS_SHUTTER_OFF_MASK) { // drop frame
+	//isp_info("%s drop frame\n", __func__);
+	mi_mis = 0x100000001;
+  }
+
+  if (mi_mis) {
+	isp_mis_t mis_data;
+	mis_data.irq_src = SRC_MI_IRQ;
+	mis_data.val = mi_mis;
+	isp_irq_write_circle_queue(&mis_data, &pisp_dev->circle_list);
+  }
+
+  if (isp_mis != 0 ||mi_mis != 0 ) {
+    schedule_work(&pdriver_dev->vvnative_wq);
+  } else {
+	return IRQ_HANDLED; // return IRQ_NONE;
+  }
+    return IRQ_HANDLED;
+}
+
+static irqreturn_t vvcam_ry_mi_irq(int irq, void *dev_id)
+{
+	struct vvcam_isp_driver_dev *pdriver_dev ;
+	struct isp_ic_dev * pisp_dev;
+    u32 mi_mis, mi_mis_addr, mi_icr_addr;
 #ifdef ISP_MIV2_RY
 	u32 miv2_mis1, miv2_mis3;
 #endif
@@ -178,7 +227,6 @@ static irqreturn_t vvcam_isp_irq(int irq, void *dev_id)
 #endif
 	pdriver_dev = (struct vvcam_isp_driver_dev *)dev_id;
 	pisp_dev = pdriver_dev->private;
-    isp_mis = isp_read_reg(pisp_dev, REG_ADDR(isp_mis));
 #ifdef ISP_MIV2_RY
 	mi_icr_addr = REG_ADDR(miv2_icr);
 	mi_mis_addr = REG_ADDR(miv2_mis);
@@ -208,19 +256,6 @@ static irqreturn_t vvcam_isp_irq(int irq, void *dev_id)
 	/*pr_info("%s isp mis 0x%08x, mi mis 0x%08x\n", __func__,  \
 		isp_mis, mi_mis);*/
 #endif
-  if (isp_mis) {
-	  isp_mis_t mis_data;
-	  mis_data.irq_src = SRC_ISP_IRQ;
-	  mis_data.val = isp_mis;
-	  pisp_dev->isp_mis = isp_mis;
-	  isp_irq_write_circle_queue(&mis_data, &pisp_dev->circle_list);
-	  isp_write_reg(pisp_dev, REG_ADDR(isp_icr), isp_mis);
-	  if(isp_mis & MRV_ISP_MIS_ISP_OFF_MASK) {
-		  isp_write_reg(pisp_dev, REG_ADDR(isp_imsc), isp_read_reg(pisp_dev, REG_ADDR(isp_imsc))&(~MRV_ISP_MIS_ISP_OFF_MASK));
-	  }
-  if (isp_mis & MRV_ISP_MIS_FLASH_ON_MASK)
-	  mi_mis |= 0x1;
-  }
 
   if (mi_mis) {
 	isp_mis_t mis_data;
@@ -250,10 +285,11 @@ static irqreturn_t vvcam_isp_irq(int irq, void *dev_id)
   	isp_write_reg(pisp_dev, REG_ADDR(miv2_icr2), miv2_mis2);
   }
 #endif
+
  #if defined(ISP_MI_PP_READ_RY) || defined (ISP_3DNR_V3) || defined (ISP_MI_PP_WRITE_RY) ||  defined (ISP_MI_HDR_RY)
-   if (isp_mis != 0 ||mi_mis != 0 || miv2_mis2 != 0) {
+   if (mi_mis != 0 || miv2_mis2 != 0) {
  #else
-  if (isp_mis != 0 ||mi_mis != 0 ) {
+  if (mi_mis != 0 ) {
 #endif
     schedule_work(&pdriver_dev->vvnative_wq);
   } else {
@@ -353,7 +389,7 @@ static int vvcam_isp_release(struct inode * inode, struct file * file)
 	struct vvcam_isp_driver_dev *pdriver_dev;
 	struct isp_ic_dev *pisp_dev;
 	if ((inode == NULL) || (file == NULL) ) {
-		printk("%s: %dx\n", __func__, __LINE__);
+		isp_info("%s: %dx\n", __func__, __LINE__);
 		return 0;
 	}
 
@@ -364,6 +400,19 @@ static int vvcam_isp_release(struct inode * inode, struct file * file)
 	isp_irq_destroy_circle_queue(&(pisp_dev->circle_list));
 
 	struct device *dev = &pdriver_dev->pdev->dev;
+    if (pisp_dev->ut_addr != NULL) {
+        #define UT_USED_SIZE 0x01000000
+        dma_free_coherent(dev, UT_USED_SIZE,
+                          pisp_dev->ut_addr, pisp_dev->ut_phy_addr);
+        pisp_dev->ut_addr=NULL;
+    }
+
+    if (pisp_dev->ut_addr != NULL) {
+        #define UT_USED_SIZE 0x01000000
+        dma_free_coherent(dev, UT_USED_SIZE,
+                          pisp_dev->ut_addr, pisp_dev->ut_phy_addr);
+        pisp_dev->ut_addr = NULL;
+    }
 
 	if (pm_runtime_put_sync(dev)) {
 		pr_info("fail to resume isp %s %d\n", __func__, __LINE__);
@@ -469,14 +518,14 @@ static int vvcam_isp_probe(struct platform_device *pdev)
 	/*init work queue*/
 	INIT_WORK(&pdriver_dev->vvnative_wq,  vvnative_isp_work);
 
-	ret = devm_request_irq(&pdev->dev, pdriver_dev->irq_num[0], vvcam_isp_irq,
+	ret = devm_request_irq(&pdev->dev, pdriver_dev->irq_num[0], vvcam_ry_isp_irq,
 				IRQF_TRIGGER_RISING | IRQF_SHARED, "ISP_IRQ", (char *)pdriver_dev);
 	if (ret) {
 		pr_err("%s[%d]:request irq error!\n", __func__, __LINE__);
 		return ret;
 	}
 
-	ret = devm_request_irq(&pdev->dev, pdriver_dev->irq_num[1], vvcam_isp_irq,
+	ret = devm_request_irq(&pdev->dev, pdriver_dev->irq_num[1], vvcam_ry_mi_irq,
 		IRQF_TRIGGER_RISING, "MI_IRQ", (char *)pdriver_dev);
 	if (ret) {
 		pr_err("%s[%d]:request irq error!\n", __func__, __LINE__);
@@ -577,6 +626,7 @@ static int vvcam_isp_remove(struct platform_device *pdev)
         #define UT_USED_SIZE 0x01000000
         dma_free_coherent(&pdev->dev, UT_USED_SIZE,
                           pisp_dev->ut_addr, pisp_dev->ut_phy_addr);
+        pisp_dev->ut_addr = NULL;
     }
 
 	free_irq(pdriver_dev->irq_num[0], pdriver_dev);