From b8a1db839c422a4ef8ae470405e8333f695fc79b Mon Sep 17 00:00:00 2001 From: thead_admin Date: Sun, 5 Mar 2023 22:30:11 +0800 Subject: [PATCH] Linux_SDK_V1.1.2 --- vvcam/common/vvsensor.h | 1 + vvcam/dw200/dw200_ioctl.h | 1 + vvcam/isp/isp_ioctl.c | 13 ++++ vvcam/isp/isp_ioctl.h | 1 + vvcam/isp/isp_irq_queue.c | 16 +++++ vvcam/isp/isp_irq_queue.h | 1 + vvcam/native/dw200/vvcam_dwe_driver.c | 3 + vvcam/native/flash_led/flash_led_driver.c | 72 +++++++++++++++-------- vvcam/native/flash_led/flash_led_ioctl.c | 3 - vvcam/native/flash_led/flash_led_ioctl.h | 3 +- vvcam/native/isp/vvcam_isp_driver_of.c | 38 ++++++++---- vvcam/native/sensor/sensor_ioctl.c | 3 + vvcam_ry/isp/ic_dev.h | 4 ++ vvcam_ry/isp/isp_dmsc2.c | 5 -- vvcam_ry/isp/isp_ioctl.c | 20 +++++-- vvcam_ry/isp/isp_ioctl.h | 3 +- vvcam_ry/isp/isp_irq_queue.c | 15 +++++ vvcam_ry/isp/isp_irq_queue.h | 1 + vvcam_ry/isp/isp_rgbgamma.c | 46 +++++++++------ vvcam_ry/native/isp/vvcam_isp_driver_of.c | 48 +++++++++++---- 20 files changed, 213 insertions(+), 84 deletions(-) diff --git a/vvcam/common/vvsensor.h b/vvcam/common/vvsensor.h index 2bc6e17..416d3d8 100755 --- a/vvcam/common/vvsensor.h +++ b/vvcam/common/vvsensor.h @@ -217,6 +217,7 @@ typedef struct vvcam_mode_info { uint32_t reg_data_count; uint32_t mipi_phy_freq; uint32_t mipi_line_num; + char *config_file_3a; } vvcam_mode_info_t; typedef struct sensor_blc_s diff --git a/vvcam/dw200/dw200_ioctl.h b/vvcam/dw200/dw200_ioctl.h index 14d458f..2542f3c 100644 --- a/vvcam/dw200/dw200_ioctl.h +++ b/vvcam/dw200/dw200_ioctl.h @@ -115,5 +115,6 @@ int vse_read_irq(struct dw200_subdev *dev, u32 *ret); int vse_start_dma_read(struct dw200_subdev *dev, u64 addr); /* mi output pa */ int vse_update_buffers(struct dw200_subdev *dev, u64 *addr); +void visys_reset(void); #endif // _DWE_IOC_H_ diff --git a/vvcam/isp/isp_ioctl.c b/vvcam/isp/isp_ioctl.c index fe944d9..b083302 100755 --- a/vvcam/isp/isp_ioctl.c +++ b/vvcam/isp/isp_ioctl.c @@ -974,6 +974,19 @@ int isp_stop_stream(struct isp_ic_dev *dev) return 0; } +void isp_force_stop(struct isp_ic_dev *dev) +{ + pr_info("enter %s\n", __func__); + isp_disable(dev); + mdelay(40); + isp_mi_stop(dev); + isp_stop_stream(dev); + isp_reset(dev); + pr_info("exit %s\n", __func__); + return; +} + + int isp_s_cc(struct isp_ic_dev *dev) { struct isp_cc_context *cc = &dev->cc; diff --git a/vvcam/isp/isp_ioctl.h b/vvcam/isp/isp_ioctl.h index d424273..97a60d7 100755 --- a/vvcam/isp/isp_ioctl.h +++ b/vvcam/isp/isp_ioctl.h @@ -437,4 +437,5 @@ int isp_set_crop(struct isp_ic_dev *dev); int isp_ioc_g_feature(struct isp_ic_dev *dev, void __user *args); int isp_ioc_g_feature_veresion(struct isp_ic_dev *dev, void __user *args); +void isp_force_stop(struct isp_ic_dev *dev); #endif /* _ISP_IOC_H_ */ diff --git a/vvcam/isp/isp_irq_queue.c b/vvcam/isp/isp_irq_queue.c index 4bbe84d..35f3eee 100755 --- a/vvcam/isp/isp_irq_queue.c +++ b/vvcam/isp/isp_irq_queue.c @@ -237,3 +237,19 @@ int isp_irq_write_circle_queue(isp_mis_t* data, isp_mis_list_t* pCList) return 0; } +int isp_irq_reset_circle_queue(isp_mis_list_t* pCList) +{ +#ifdef __KERNEL__ + + if (pCList == NULL) { + isp_err("%s: can not reset circle queue\n", __func__); + return -1; + } + + pCList->pRead = pCList->pHead; + pCList->pWrite = pCList->pHead; + +#endif + return 0; +} + diff --git a/vvcam/isp/isp_irq_queue.h b/vvcam/isp/isp_irq_queue.h index e2f560d..2dc3fe9 100755 --- a/vvcam/isp/isp_irq_queue.h +++ b/vvcam/isp/isp_irq_queue.h @@ -94,5 +94,6 @@ int isp_irq_destroy_circle_queue(isp_mis_list_t* pCList); int isp_irq_read_circle_queue(isp_mis_t* data, isp_mis_list_t* pCList); int isp_irq_write_circle_queue(isp_mis_t* data, isp_mis_list_t* pCList); +int isp_irq_reset_circle_queue(isp_mis_list_t* pCList); #endif \ No newline at end of file diff --git a/vvcam/native/dw200/vvcam_dwe_driver.c b/vvcam/native/dw200/vvcam_dwe_driver.c index 12af8a1..4882683 100644 --- a/vvcam/native/dw200/vvcam_dwe_driver.c +++ b/vvcam/native/dw200/vvcam_dwe_driver.c @@ -254,6 +254,9 @@ static int vvcam_dwe_release(struct inode * inode, struct file * file) 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); + dwe_reset(pdw200); + vse_reset(pdw200); + dwe_disable_irq(pdw200); mutex_unlock(pdw200->vvmutex); } /*destory circle queue*/ diff --git a/vvcam/native/flash_led/flash_led_driver.c b/vvcam/native/flash_led/flash_led_driver.c index 0037ce6..2dbaa36 100755 --- a/vvcam/native/flash_led/flash_led_driver.c +++ b/vvcam/native/flash_led/flash_led_driver.c @@ -102,29 +102,35 @@ 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; + 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; + 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; + if(frame_id%2) + floodlight_on = true; + else + projection_on = true; + break; case PROJECTION_ALWAYS_ON: - projection_on = true; - break; + projection_on = true; + break; case FLOODLIGHT_ALWAYS_ON: - floodlight_on =true; - break; + floodlight_on = true; + break; + case BOTH_ON: + projection_on = true; + floodlight_on = true; + break; case BOTH_OFF: + projection_on = false; + floodlight_on = false; break; default: pr_warn("invald switch mode:%d\n",pflash_led_dev->switch_mode); @@ -165,10 +171,12 @@ 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 (pflash_led_dev->touch_pin != -1) { + 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); @@ -200,8 +208,10 @@ 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); + if (pflash_led_dev->touch_pin != -1) { + irq = gpio_to_irq(pflash_led_dev->touch_pin); + free_irq(irq, pflash_led_dev); + } pflash_led_dev->enable = 0; @@ -268,6 +278,7 @@ static int flash_led_of_parse(struct platform_device *pdev) pr_err("%s:flash_led_touch request failed\n", __func__); } } else { + pflash_led_dev->touch_pin = -1; pr_err("flash_led_touch not defined for %s\n", pflash_led_dev->flash_led_name); } @@ -441,7 +452,12 @@ static void flash_led_interrupt_func(struct work_struct *work) } return; } - flash_led_switch(pflash_led_dev,frame_irq_cnt); + + if (pflash_led_dev->switch_mode != BOTH_ON \ + && pflash_led_dev->switch_mode != BOTH_OFF) { + flash_led_switch(pflash_led_dev,frame_irq_cnt); + } + if ((frame_irq_cnt % 2) == 0) { if (!IS_ERR(pflash_led_dev->floodlight_adc)) { @@ -471,7 +487,9 @@ static irqreturn_t touch_pin_isr(int irq, void *dev) static int flash_pin_init(struct flash_led_ctrl *dev) { - gpio_request(dev->touch_pin, "flash led touch pin"); + if (dev->touch_pin != -1) { + gpio_request(dev->touch_pin, "flash led touch pin"); + } INIT_WORK(&dev->flash_led_work, flash_led_interrupt_func); @@ -496,7 +514,11 @@ static int touch_pin_uinit(struct flash_led_ctrl *dev) { dev->enable = 0; cancel_work_sync(&dev->flash_led_work); - gpio_free(dev->touch_pin); + + if (dev->touch_pin != -1) { + gpio_free(dev->touch_pin); + } + return 0; } diff --git a/vvcam/native/flash_led/flash_led_ioctl.c b/vvcam/native/flash_led/flash_led_ioctl.c index dc51171..89debc5 100755 --- a/vvcam/native/flash_led/flash_led_ioctl.c +++ b/vvcam/native/flash_led/flash_led_ioctl.c @@ -398,7 +398,6 @@ int flash_led_init(struct flash_led_ctrl *dev) } if (floodlight->i2c_bus == projection->i2c_bus) { - pr_info("%s, %d, floodlight->i2c_bus = %d projection->i2c_bus %d\n", __func__, __LINE__, floodlight->i2c_bus, projection->i2c_bus); ret = register_i2c_client(floodlight); if (ret != 0) { pr_err("[%s]: register_i2c_client flash_led_idx = %d failed\n",__func__, dev->device_idx); @@ -408,7 +407,6 @@ int flash_led_init(struct flash_led_ctrl *dev) projection->i2c_client = floodlight->i2c_client; } else { if (floodlight->i2c_bus != UNDEFINED_IN_DTS) { - pr_info("%s, %d, floodlight->i2c_bus = %d \n", __func__, __LINE__, floodlight->i2c_bus); ret = register_i2c_client(floodlight); if (ret != 0) { pr_err("[%s]: floodlight register_i2c_client flash_led_idx = %d failed\n",__func__, dev->device_idx); @@ -417,7 +415,6 @@ int flash_led_init(struct flash_led_ctrl *dev) } if (projection->i2c_bus != UNDEFINED_IN_DTS) { - pr_info("%s, %d, projection->i2c_bus %d\n", __func__, __LINE__, projection->i2c_bus); ret = register_i2c_client(projection); if (ret != 0) { pr_err("[%s]: projection register_i2c_client flash_led_idx = %d failed\n",__func__, dev->device_idx); diff --git a/vvcam/native/flash_led/flash_led_ioctl.h b/vvcam/native/flash_led/flash_led_ioctl.h index e96056b..23a1aa4 100755 --- a/vvcam/native/flash_led/flash_led_ioctl.h +++ b/vvcam/native/flash_led/flash_led_ioctl.h @@ -50,7 +50,8 @@ typedef enum { PROJECTION_ODD_FLOODLIGHT_EVEN = 1, PROJECTION_ALWAYS_ON = 2, FLOODLIGHT_ALWAYS_ON = 3, - BOTH_OFF =4, + BOTH_ON = 4, + BOTH_OFF = 5, } flash_led_switch_mod_t; typedef struct { diff --git a/vvcam/native/isp/vvcam_isp_driver_of.c b/vvcam/native/isp/vvcam_isp_driver_of.c index 48db1f4..69b42f9 100755 --- a/vvcam/native/isp/vvcam_isp_driver_of.c +++ b/vvcam/native/isp/vvcam_isp_driver_of.c @@ -340,10 +340,10 @@ static int vvcam_isp_runtime_suspend(struct device *dev) clk_disable_unprepare(pdriver_dev->hclk); clk_disable_unprepare(pdriver_dev->isp0_pclk); clk_disable_unprepare(pdriver_dev->cclk); - if (IS_ERR(pdriver_dev->isp1_pclk)) - dev_err(dev, "isp1_pclk is null\n"); - else + if (!IS_ERR_OR_NULL(pdriver_dev->isp1_pclk)) { clk_disable_unprepare(pdriver_dev->isp1_pclk); + } + pr_info("isp %s\n", __func__); return 0; } @@ -454,8 +454,8 @@ static int vvcam_isp_open(struct inode * inode, struct file * file) file->private_data = pdriver_dev; pisp_dev = pdriver_dev->private; struct device *dev = &pdriver_dev->pdev->dev; - /*create circle queue*/ - isp_irq_create_circle_queue(&(pisp_dev->circle_list), QUEUE_NODE_COUNT); + + isp_irq_reset_circle_queue(&(pisp_dev->circle_list)); if (pm_runtime_get_sync(dev)) { ret = vvcam_isp_runtime_resume(dev); if (ret) @@ -494,6 +494,9 @@ static int vvcam_isp_release(struct inode * inode, struct file * file) int ret = 0; struct vvcam_isp_driver_dev *pdriver_dev; struct isp_ic_dev *pisp_dev; + + pr_info("enter %s\n", __func__); + if ((inode == NULL) || (file == NULL) ) { pr_info("%s: %dx\n", __func__, __LINE__); return 0; @@ -503,8 +506,8 @@ static int vvcam_isp_release(struct inode * inode, struct file * file) struct device *dev = &pdriver_dev->pdev->dev; file->private_data = pdriver_dev; pisp_dev = pdriver_dev->private; - pr_info("enter %s\n", __func__); - isp_irq_destroy_circle_queue(&(pisp_dev->circle_list)); + + isp_force_stop(pisp_dev); if (pisp_dev->ut_addr != NULL) { #define UT_USED_SIZE 0x01000000 @@ -517,6 +520,8 @@ static int vvcam_isp_release(struct inode * inode, struct file * file) if (ret) { pr_err("fail to suspen isp %s %d ret = %d\n", __func__, __LINE__, ret); } + + pr_info("exit %s\n", __func__); return 0; }; @@ -581,6 +586,7 @@ static int vvcam_isp_probe(struct platform_device *pdev) return -ENOMEM; } memset(pisp_dev,0,sizeof(struct isp_ic_dev )); + isp_irq_create_circle_queue(&(pisp_dev->circle_list), QUEUE_NODE_COUNT); pr_info("%s:isp[%d]: psensor_dev =0x%px\n", __func__,pdev->id,pisp_dev); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -673,10 +679,12 @@ static int vvcam_isp_probe(struct platform_device *pdev) //return -1; } - pdriver_dev->isp1_pclk = devm_clk_get(&pdev->dev, "isp1_pclk"); - if (IS_ERR(pdriver_dev->isp1_pclk)) { - dev_err(&pdev->dev, "failed to get isp1_pclk"); - //return -1; + if (pdriver_dev->device_idx == 1) { + pdriver_dev->isp1_pclk = devm_clk_get(&pdev->dev, "isp1_pclk"); + if (IS_ERR(pdriver_dev->isp1_pclk)) { + dev_err(&pdev->dev, "failed to get isp1_pclk"); + //return -1; + } } if ((devise_register_index == 0)) { @@ -724,11 +732,11 @@ static int vvcam_isp_probe(struct platform_device *pdev) struct device *dev = &pdriver_dev->pdev->dev; pm_runtime_enable(dev); - ret = vvcam_isp_runtime_resume(dev); + ret = pm_runtime_resume_and_get(dev); if (ret < 0) { dev_err(dev, "fail to resume isp\n"); } - vvcam_isp_runtime_suspend(dev); + ret = pm_runtime_put_sync(dev); if (ret < 0) { dev_err(dev, "fail to suspend isp\n"); } @@ -762,6 +770,10 @@ static int vvcam_isp_remove(struct platform_device *pdev) pisp_dev->irq_is_request[0] = 0; pisp_dev->irq_is_request[1] = 0; + isp_irq_destroy_circle_queue(&(pisp_dev->circle_list)); + struct device *dev = &pdev->dev; + pm_runtime_disable(dev); + cdev_del(&pdriver_dev->cdev); device_destroy(pdriver_dev->class, pdriver_dev->devt); diff --git a/vvcam/native/sensor/sensor_ioctl.c b/vvcam/native/sensor/sensor_ioctl.c index 59ad184..a55a2d5 100755 --- a/vvcam/native/sensor/sensor_ioctl.c +++ b/vvcam/native/sensor/sensor_ioctl.c @@ -391,9 +391,12 @@ long sensor_priv_ioctl(struct vvcam_sensor_dev *dev, unsigned int cmd, void __us case VVSENSORIOC_SENSOR_SCCB_CFG: { + /* struct vvcam_sccb_cfg_s sccb_config; check_retval(copy_from_user(&sccb_config, args, sizeof(sccb_config))); ret = vvcam_sensor_sccb_config(dev,&sccb_config); + */ + ret = 0; break; } diff --git a/vvcam_ry/isp/ic_dev.h b/vvcam_ry/isp/ic_dev.h index 14ef93c..bab96b8 100755 --- a/vvcam_ry/isp/ic_dev.h +++ b/vvcam_ry/isp/ic_dev.h @@ -674,6 +674,7 @@ struct isp_exp2_context { /* write 4096/8192 EXPV2 mean value to dma by MI MP-JDP path. */ /* physical address, alloacte by user */ u64 pa; + uint8_t* va; }; #define ISP_2DNR_SIGMA_BIN 60 @@ -914,6 +915,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 { diff --git a/vvcam_ry/isp/isp_dmsc2.c b/vvcam_ry/isp/isp_dmsc2.c index 00858f3..108a42c 100755 --- a/vvcam_ry/isp/isp_dmsc2.c +++ b/vvcam_ry/isp/isp_dmsc2.c @@ -418,12 +418,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; diff --git a/vvcam_ry/isp/isp_ioctl.c b/vvcam_ry/isp/isp_ioctl.c index 893d0f0..b8a1e27 100755 --- a/vvcam_ry/isp/isp_ioctl.c +++ b/vvcam_ry/isp/isp_ioctl.c @@ -968,6 +968,18 @@ int isp_stop_stream(struct isp_ic_dev *dev) return 0; } +void ry_force_stop(struct isp_ic_dev *dev) +{ + pr_info("enter %s\n", __func__); + isp_disable(dev); + mdelay(40); + isp_mi_stop(dev); + isp_stop_stream(dev); + isp_reset(dev); + pr_info("exit %s\n", __func__); + return; +} + int isp_s_cc(struct isp_ic_dev *dev) { struct isp_cc_context *cc = &dev->cc; @@ -3455,12 +3467,8 @@ 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); } break; } diff --git a/vvcam_ry/isp/isp_ioctl.h b/vvcam_ry/isp/isp_ioctl.h index 6991101..06f25cb 100755 --- a/vvcam_ry/isp/isp_ioctl.h +++ b/vvcam_ry/isp/isp_ioctl.h @@ -344,7 +344,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); @@ -429,4 +429,5 @@ int isp_set_crop(struct isp_ic_dev *dev); int isp_ioc_g_feature(struct isp_ic_dev *dev, void __user *args); int isp_ioc_g_feature_veresion(struct isp_ic_dev *dev, void __user *args); +void ry_force_stop(struct isp_ic_dev *dev); #endif /* _ISP_IOC_H_ */ diff --git a/vvcam_ry/isp/isp_irq_queue.c b/vvcam_ry/isp/isp_irq_queue.c index 16a8687..a108f4d 100755 --- a/vvcam_ry/isp/isp_irq_queue.c +++ b/vvcam_ry/isp/isp_irq_queue.c @@ -238,3 +238,18 @@ int isp_irq_write_circle_queue(isp_mis_t* data, isp_mis_list_t* pCList) return 0; } +int isp_irq_reset_circle_queue(isp_mis_list_t* pCList) +{ +#ifdef __KERNEL__ + + if (pCList == NULL) { + isp_err("%s: can not reset circle queue\n", __func__); + return -1; + } + + pCList->pRead = pCList->pHead; + pCList->pWrite = pCList->pHead; + +#endif + return 0; +} \ No newline at end of file diff --git a/vvcam_ry/isp/isp_irq_queue.h b/vvcam_ry/isp/isp_irq_queue.h index 018859d..628bb03 100755 --- a/vvcam_ry/isp/isp_irq_queue.h +++ b/vvcam_ry/isp/isp_irq_queue.h @@ -92,6 +92,7 @@ int isp_irq_create_circle_queue(isp_mis_list_t* pCList, int number); int isp_irq_destroy_circle_queue(isp_mis_list_t* pCList); int isp_irq_read_circle_queue(isp_mis_t* data, isp_mis_list_t* pCList); int isp_irq_write_circle_queue(isp_mis_t* data, isp_mis_list_t* pCList); +int isp_irq_reset_circle_queue(isp_mis_list_t* pCList); #endif #endif \ No newline at end of file diff --git a/vvcam_ry/isp/isp_rgbgamma.c b/vvcam_ry/isp/isp_rgbgamma.c index 91342a0..f4c7cae 100755 --- a/vvcam_ry/isp/isp_rgbgamma.c +++ b/vvcam_ry/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 @@ -194,24 +202,26 @@ 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_RY pr_err("unsupported function %s", __func__); return -1; #else u8 ret; - 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); - - isp_s_rgbgammapx(dev, data); - isp_s_rgbgammaWriteData(dev, data); - ret = 0; - if (dev->rgbgamma.enable) { - ret = isp_enable_rgbgamma(dev); + if (dev->rgbgamma.data_changed) { + u32 isp_ctrl = isp_read_reg(dev, REG_ADDR(isp_ctrl)); + 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 -} +} \ No newline at end of file diff --git a/vvcam_ry/native/isp/vvcam_isp_driver_of.c b/vvcam_ry/native/isp/vvcam_isp_driver_of.c index e047dc3..8e62c31 100755 --- a/vvcam_ry/native/isp/vvcam_isp_driver_of.c +++ b/vvcam_ry/native/isp/vvcam_isp_driver_of.c @@ -160,7 +160,19 @@ 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); + } + } } } @@ -186,13 +198,13 @@ static irqreturn_t vvcam_ry_isp_irq(int irq, void *dev_id) 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; + mi_mis |= (0x1 | MP_JDP_FRAME_END_MASK); // line mode ry 3a start after frame done } - if (isp_mis & MRV_ISP_MIS_VSM_END_MASK) { // MP_JDP_FRAME_END + //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; - } + //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__); @@ -301,10 +313,11 @@ static irqreturn_t vvcam_ry_mi_irq(int irq, void *dev_id) static int vvcam_isp_runtime_suspend(struct device *dev) { struct vvcam_isp_driver_dev *pdriver_dev = dev_get_drvdata(dev); + pr_info("ry %s enter\n", __func__); clk_disable_unprepare(pdriver_dev->aclk); clk_disable_unprepare(pdriver_dev->hclk); clk_disable_unprepare(pdriver_dev->cclk); - pr_info("ry %s\n", __func__); + pr_info("ry %s exit\n", __func__); return 0; } static int vvcam_isp_runtime_resume(struct device *dev) @@ -346,8 +359,8 @@ static int vvcam_isp_open(struct inode * inode, struct file * file) pdriver_dev = container_of(inode->i_cdev, struct vvcam_isp_driver_dev, cdev); file->private_data = pdriver_dev; pisp_dev = pdriver_dev->private; - /*create circle queue*/ - isp_irq_create_circle_queue(&(pisp_dev->circle_list), QUEUE_NODE_COUNT); + + isp_irq_reset_circle_queue(&(pisp_dev->circle_list)); struct device *dev = &pdriver_dev->pdev->dev; if (pm_runtime_get_sync(dev)) { @@ -388,6 +401,9 @@ static int vvcam_isp_release(struct inode * inode, struct file * file) int ret = 0; struct vvcam_isp_driver_dev *pdriver_dev; struct isp_ic_dev *pisp_dev; + + pr_info("ry enter %s\n", __func__); + if ((inode == NULL) || (file == NULL) ) { isp_info("%s: %dx\n", __func__, __LINE__); return 0; @@ -396,8 +412,8 @@ static int vvcam_isp_release(struct inode * inode, struct file * file) pdriver_dev = container_of(inode->i_cdev, struct vvcam_isp_driver_dev, cdev); file->private_data = pdriver_dev; pisp_dev = pdriver_dev->private; - pr_info("enter %s\n", __func__); - isp_irq_destroy_circle_queue(&(pisp_dev->circle_list)); + + ry_force_stop(pisp_dev); struct device *dev = &pdriver_dev->pdev->dev; if (pisp_dev->ut_addr != NULL) { @@ -418,6 +434,8 @@ static int vvcam_isp_release(struct inode * inode, struct file * file) pr_info("fail to resume isp %s %d\n", __func__, __LINE__); } + pr_info("ry exit %s\n", __func__); + return 0; }; @@ -482,6 +500,7 @@ static int vvcam_isp_probe(struct platform_device *pdev) return -ENOMEM; } memset(pisp_dev,0,sizeof(struct isp_ic_dev )); + isp_irq_create_circle_queue(&(pisp_dev->circle_list), QUEUE_NODE_COUNT); pr_info("%s:isp[%d]: psensor_dev =0x%px\n", __func__,pdev->id,pisp_dev); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -598,11 +617,11 @@ static int vvcam_isp_probe(struct platform_device *pdev) struct device *dev = &pdriver_dev->pdev->dev; pm_runtime_enable(dev); - ret = vvcam_isp_runtime_resume(dev); + ret = pm_runtime_resume_and_get(dev); if (ret < 0) { dev_err(dev, "fail to resume isp ry\n"); } - vvcam_isp_runtime_suspend(dev); + ret = pm_runtime_put_sync(dev); if (ret < 0) { dev_err(dev, "fail to suspend isp ry\n"); } @@ -631,6 +650,11 @@ static int vvcam_isp_remove(struct platform_device *pdev) free_irq(pdriver_dev->irq_num[0], pdriver_dev); free_irq(pdriver_dev->irq_num[1], pdriver_dev); + + isp_irq_destroy_circle_queue(&(pisp_dev->circle_list)); + struct device *dev = &pdev->dev; + pm_runtime_disable(dev); + cdev_del(&pdriver_dev->cdev); device_destroy(pdriver_dev->class, pdriver_dev->devt);