forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/media/platform/rockchip/isp/rkisp.c
....@@ -87,12 +87,6 @@
8787
8888 static void rkisp_config_cmsk(struct rkisp_device *dev);
8989
90
-struct backup_reg {
91
- const u32 base;
92
- const u32 shd;
93
- u32 val;
94
-};
95
-
9690 static inline struct rkisp_device *sd_to_isp_dev(struct v4l2_subdev *sd)
9791 {
9892 return container_of(sd->v4l2_dev, struct rkisp_device, v4l2_dev);
....@@ -213,17 +207,16 @@
213207 max_h = CIF_ISP_INPUT_H_MAX_V21;
214208 break;
215209 case ISP_V30:
216
- if (dev->hw_dev->is_unite) {
217
- max_w = CIF_ISP_INPUT_W_MAX_V30_UNITE;
218
- max_h = CIF_ISP_INPUT_H_MAX_V30_UNITE;
219
- } else {
220
- max_w = CIF_ISP_INPUT_W_MAX_V30;
221
- max_h = CIF_ISP_INPUT_H_MAX_V30;
222
- }
210
+ max_w = dev->hw_dev->unite ?
211
+ CIF_ISP_INPUT_W_MAX_V30_UNITE : CIF_ISP_INPUT_W_MAX_V30;
212
+ max_h = dev->hw_dev->unite ?
213
+ CIF_ISP_INPUT_H_MAX_V30_UNITE : CIF_ISP_INPUT_H_MAX_V30;
223214 break;
224215 case ISP_V32:
225
- max_w = CIF_ISP_INPUT_W_MAX_V32;
226
- max_h = CIF_ISP_INPUT_H_MAX_V32;
216
+ max_w = dev->hw_dev->unite ?
217
+ CIF_ISP_INPUT_W_MAX_V32_UNITE : CIF_ISP_INPUT_W_MAX_V32;
218
+ max_h = dev->hw_dev->unite ?
219
+ CIF_ISP_INPUT_H_MAX_V32_UNITE : CIF_ISP_INPUT_H_MAX_V32;
227220 break;
228221 case ISP_V32_L:
229222 max_w = CIF_ISP_INPUT_W_MAX_V32_L;
....@@ -518,7 +511,9 @@
518511 do_div(data_rate, 1000 * 1000);
519512 /* increase margin: 25% * num */
520513 data_rate += (data_rate >> 2) * num;
521
-
514
+ /* one frame two-run, data double */
515
+ if (hw->is_multi_overflow && num > 1)
516
+ data_rate *= 2;
522517 /* compare with isp clock adjustment table */
523518 for (i = 0; i < hw->num_clk_rate_tbl; i++)
524519 if (data_rate <= hw->clk_rate_tbl[i].clk_rate)
....@@ -528,7 +523,7 @@
528523
529524 /* set isp clock rate */
530525 rkisp_set_clk_rate(hw->clks[0], hw->clk_rate_tbl[i].clk_rate * 1000000UL);
531
- if (hw->is_unite)
526
+ if (hw->unite == ISP_UNITE_TWO)
532527 rkisp_set_clk_rate(hw->clks[5], hw->clk_rate_tbl[i].clk_rate * 1000000UL);
533528 /* aclk equal to core clk */
534529 if (dev->isp_ver == ISP_V32)
....@@ -541,48 +536,39 @@
541536 struct rkisp_hw_dev *hw = dev->hw_dev;
542537
543538 if (on) {
544
- /* enable bay3d and mi */
539
+ /* enable mi */
545540 rkisp_update_regs(dev, ISP3X_MI_WR_CTRL, ISP3X_MI_WR_CTRL);
546541 rkisp_update_regs(dev, ISP3X_ISP_CTRL1, ISP3X_ISP_CTRL1);
547
- if (dev->isp_ver == ISP_V21) {
548
- rkisp_update_regs(dev, ISP21_BAY3D_CTRL, ISP21_BAY3D_CTRL);
549
- } else if (dev->isp_ver == ISP_V30) {
542
+ if (dev->isp_ver == ISP_V30) {
550543 rkisp_update_regs(dev, ISP3X_MPFBC_CTRL, ISP3X_MPFBC_CTRL);
551544 rkisp_update_regs(dev, ISP3X_MI_BP_WR_CTRL, ISP3X_MI_BP_WR_CTRL);
552
- rkisp_update_regs(dev, ISP3X_BAY3D_CTRL, ISP3X_BAY3D_CTRL);
553545 rkisp_update_regs(dev, ISP3X_SWS_CFG, ISP3X_SWS_CFG);
554546 } else if (dev->isp_ver == ISP_V32) {
555547 rkisp_update_regs(dev, ISP3X_MI_BP_WR_CTRL, ISP3X_MI_BP_WR_CTRL);
556548 rkisp_update_regs(dev, ISP32_MI_BPDS_WR_CTRL, ISP32_MI_BPDS_WR_CTRL);
557549 rkisp_update_regs(dev, ISP32_MI_MPDS_WR_CTRL, ISP32_MI_MPDS_WR_CTRL);
558
- rkisp_update_regs(dev, ISP3X_BAY3D_CTRL, ISP3X_BAY3D_CTRL);
559550 }
560551 } else {
561
- /* disabled bay3d and mi. rv1106 sdmmc workaround, 3a_wr no close */
552
+ /* disabled mi. rv1106 sdmmc workaround, 3a_wr no close */
562553 writel(CIF_MI_CTRL_INIT_OFFSET_EN | CIF_MI_CTRL_INIT_BASE_EN,
563554 hw->base_addr + ISP3X_MI_WR_CTRL);
564
- if (dev->isp_ver == ISP_V21) {
565
- writel(0, hw->base_addr + ISP21_BAY3D_CTRL);
566
- } else if (dev->isp_ver == ISP_V30) {
555
+ if (dev->isp_ver == ISP_V30) {
567556 writel(0, hw->base_addr + ISP3X_MPFBC_CTRL);
568557 writel(0, hw->base_addr + ISP3X_MI_BP_WR_CTRL);
569
- writel(0, hw->base_addr + ISP3X_BAY3D_CTRL);
570558 writel(0xc, hw->base_addr + ISP3X_SWS_CFG);
571
- if (hw->is_unite) {
559
+ if (hw->unite == ISP_UNITE_TWO) {
572560 writel(0, hw->base_next_addr + ISP3X_MI_WR_CTRL);
573561 writel(0, hw->base_next_addr + ISP3X_MPFBC_CTRL);
574562 writel(0, hw->base_next_addr + ISP3X_MI_BP_WR_CTRL);
575
- writel(0, hw->base_next_addr + ISP3X_BAY3D_CTRL);
576563 writel(0xc, hw->base_next_addr + ISP3X_SWS_CFG);
577564 }
578565 } else if (dev->isp_ver == ISP_V32) {
579566 writel(0, hw->base_addr + ISP3X_MI_BP_WR_CTRL);
580567 writel(0, hw->base_addr + ISP32_MI_BPDS_WR_CTRL);
581568 writel(0, hw->base_addr + ISP32_MI_MPDS_WR_CTRL);
582
- writel(0, hw->base_addr + ISP3X_BAY3D_CTRL);
583569 }
584570 }
585
- rkisp_unite_write(dev, ISP3X_MI_WR_INIT, CIF_MI_INIT_SOFT_UPD, true, hw->is_unite);
571
+ rkisp_unite_write(dev, ISP3X_MI_WR_INIT, CIF_MI_INIT_SOFT_UPD, true);
586572 }
587573
588574 /*
....@@ -602,7 +588,8 @@
602588 hw->cur_dev_id = dev->dev_id;
603589 rkisp_dmarx_get_frame(dev, &cur_frame_id, NULL, NULL, true);
604590
605
- if (hw->is_multi_overflow && is_try)
591
+ /* isp process the same frame */
592
+ if (is_try)
606593 goto run_next;
607594
608595 val = 0;
....@@ -632,13 +619,12 @@
632619 }
633620
634621 if (rd_mode != dev->rd_mode) {
635
- rkisp_unite_set_bits(dev, ISP_HDRMGE_BASE, ISP_HDRMGE_MODE_MASK,
636
- val, false, hw->is_unite);
622
+ rkisp_unite_set_bits(dev, ISP_HDRMGE_BASE, ISP_HDRMGE_MODE_MASK, val, false);
637623 dev->skip_frame = 2;
638624 is_upd = true;
639625 }
640626
641
- if (dev->isp_ver == ISP_V20 && dev->dmarx_dev.trigger == T_MANUAL && !is_try) {
627
+ if (dev->isp_ver == ISP_V20 && dev->dmarx_dev.trigger == T_MANUAL) {
642628 if (dev->rd_mode != rd_mode && dev->br_dev.en) {
643629 tmp = dev->isp_sdev.in_crop.height;
644630 val = rkisp_read(dev, CIF_DUAL_CROP_CTRL, false);
....@@ -659,12 +645,15 @@
659645 }
660646 dev->rd_mode = rd_mode;
661647
662
- rkisp_params_first_cfg(&dev->params_vdev, &dev->isp_sdev.in_fmt,
663
- dev->isp_sdev.quantization);
664
- rkisp_params_cfg(params_vdev, cur_frame_id);
665
- rkisp_config_cmsk(dev);
666
- rkisp_stream_frame_start(dev, 0);
667
- if (!hw->is_single && !is_try) {
648
+ if (hw->unite != ISP_UNITE_ONE || dev->unite_index == ISP_UNITE_LEFT) {
649
+ rkisp_params_first_cfg(&dev->params_vdev, &dev->isp_sdev.in_fmt,
650
+ dev->isp_sdev.quantization);
651
+ rkisp_params_cfg(params_vdev, cur_frame_id);
652
+ rkisp_config_cmsk(dev);
653
+ rkisp_stream_frame_start(dev, 0);
654
+ }
655
+
656
+ if (!hw->is_single) {
668657 /* multi sensor need to reset isp resize mode if scale up */
669658 val = 0;
670659 if (rkisp_read(dev, ISP3X_MAIN_RESIZE_CTRL, true) & 0xf0)
....@@ -700,7 +689,7 @@
700689 } else {
701690 if (dev->isp_ver == ISP_V32_L)
702691 rkisp_write(dev, ISP32_SELF_SCALE_UPDATE, ISP32_SCALE_FORCE_UPD, true);
703
- rkisp_unite_write(dev, ISP3X_MI_WR_INIT, CIF_MI_INIT_SOFT_UPD, true, hw->is_unite);
692
+ rkisp_unite_write(dev, ISP3X_MI_WR_INIT, CIF_MI_INIT_SOFT_UPD, true);
704693 }
705694 /* sensor mode & index */
706695 if (dev->isp_ver >= ISP_V21) {
....@@ -711,7 +700,7 @@
711700 else
712701 val |= ISP21_SENSOR_MODE(dev->multi_mode);
713702 writel(val, hw->base_addr + ISP_ACQ_H_OFFS);
714
- if (hw->is_unite)
703
+ if (hw->unite == ISP_UNITE_TWO)
715704 writel(val, hw->base_next_addr + ISP_ACQ_H_OFFS);
716705 v4l2_dbg(2, rkisp_debug, &dev->v4l2_dev,
717706 "sensor mode:%d index:%d | 0x%x\n",
....@@ -731,36 +720,98 @@
731720 else
732721 dev->rdbk_cnt_x1++;
733722 dev->rdbk_cnt++;
734
-
735
- rkisp_params_cfgsram(params_vdev);
736
- params_vdev->rdbk_times = dma2frm + 1;
723
+ if (dev->isp_ver == ISP_V20)
724
+ params_vdev->rdbk_times = dma2frm + 1;
737725
738726 run_next:
739
- if (hw->is_multi_overflow && !dev->is_first_double) {
740
- stats_vdev->rdbk_drop = false;
741
- if (dev->sw_rd_cnt) {
742
- rkisp_multi_overflow_hdl(dev, false);
743
- params_vdev->rdbk_times += dev->sw_rd_cnt;
744
- stats_vdev->rdbk_drop = true;
745
- is_upd = true;
746
- } else if (is_try) {
727
+ rkisp_params_cfgsram(params_vdev, true);
728
+ stats_vdev->rdbk_drop = false;
729
+ if (dev->is_frame_double) {
730
+ is_upd = true;
731
+ if (is_try) {
732
+ /* the frame second running to on mi */
747733 rkisp_multi_overflow_hdl(dev, true);
748
- is_upd = true;
734
+ rkisp_update_regs(dev, ISP_LDCH_BASE, ISP_LDCH_BASE);
735
+
736
+ val = ISP3X_YNR_FST_FRAME | ISP3X_DHAZ_FST_FRAME | ISP3X_CNR_FST_FRAME;
737
+ if (dev->isp_ver == ISP_V32)
738
+ val |= ISP32_SHP_FST_FRAME;
739
+ else
740
+ val |= ISP3X_CNR_FST_FRAME;
741
+ rkisp_unite_clear_bits(dev, ISP3X_ISP_CTRL1, val, false);
742
+ val = rkisp_read_reg_cache(dev, ISP3X_DRC_IIRWG_GAIN);
743
+ writel(val, hw->base_addr + ISP3X_DRC_IIRWG_GAIN);
744
+ if (hw->unite == ISP_UNITE_TWO)
745
+ writel(val, hw->base_next_addr + ISP3X_DRC_IIRWG_GAIN);
746
+ val = rkisp_read_reg_cache(dev, ISP3X_DRC_EXPLRATIO);
747
+ writel(val, hw->base_addr + ISP3X_DRC_EXPLRATIO);
748
+ if (hw->unite == ISP_UNITE_TWO)
749
+ writel(val, hw->base_next_addr + ISP3X_DRC_EXPLRATIO);
750
+ val = rkisp_read_reg_cache(dev, ISP3X_YNR_GLOBAL_CTRL);
751
+ writel(val, hw->base_addr + ISP3X_YNR_GLOBAL_CTRL);
752
+ if (hw->unite == ISP_UNITE_TWO)
753
+ writel(val, hw->base_next_addr + ISP3X_YNR_GLOBAL_CTRL);
754
+ if (dev->isp_ver == ISP_V21 || dev->isp_ver == ISP_V30) {
755
+ val = rkisp_read_reg_cache(dev, ISP3X_CNR_CTRL);
756
+ writel(val, hw->base_addr + ISP3X_CNR_CTRL);
757
+ if (hw->unite == ISP_UNITE_TWO)
758
+ writel(val, hw->base_next_addr + ISP3X_CNR_CTRL);
759
+ }
760
+ } else {
761
+ /* the frame first running to off mi to save bandwidth */
762
+ rkisp_multi_overflow_hdl(dev, false);
763
+
764
+ /* FST_FRAME no to read sram thumb */
765
+ val = ISP3X_YNR_FST_FRAME | ISP3X_DHAZ_FST_FRAME;
766
+ if (dev->isp_ver == ISP_V32)
767
+ val |= ISP32_SHP_FST_FRAME;
768
+ else
769
+ val |= ISP3X_CNR_FST_FRAME;
770
+ rkisp_unite_set_bits(dev, ISP3X_ISP_CTRL1, 0, val, false);
771
+ /* ADRC low iir thumb weight for first sensor switch */
772
+ val = rkisp_read_reg_cache(dev, ISP3X_DRC_IIRWG_GAIN);
773
+ val &= ~ISP3X_DRC_IIR_WEIGHT_MASK;
774
+ writel(val, hw->base_addr + ISP3X_DRC_IIRWG_GAIN);
775
+ if (hw->unite == ISP_UNITE_TWO)
776
+ writel(val, hw->base_next_addr + ISP3X_DRC_IIRWG_GAIN);
777
+ /* ADRC iir5x5 and cur3x3 weight */
778
+ val = rkisp_read_reg_cache(dev, ISP3X_DRC_EXPLRATIO);
779
+ val &= ~ISP3X_DRC_WEIPRE_FRAME_MASK;
780
+ writel(val, hw->base_addr + ISP3X_DRC_EXPLRATIO);
781
+ if (hw->unite == ISP_UNITE_TWO)
782
+ writel(val, hw->base_next_addr + ISP3X_DRC_EXPLRATIO);
783
+ /* YNR_THUMB_MIX_CUR_EN for thumb read addr to 0 */
784
+ val = rkisp_read_reg_cache(dev, ISP3X_YNR_GLOBAL_CTRL);
785
+ val |= ISP3X_YNR_THUMB_MIX_CUR_EN;
786
+ writel(val, hw->base_addr + ISP3X_YNR_GLOBAL_CTRL);
787
+ if (hw->unite == ISP_UNITE_TWO)
788
+ writel(val, hw->base_next_addr + ISP3X_YNR_GLOBAL_CTRL);
789
+ if (dev->isp_ver == ISP_V21 || dev->isp_ver == ISP_V30) {
790
+ /* CNR_THUMB_MIX_CUR_EN for thumb read addr to 0 */
791
+ val = rkisp_read_reg_cache(dev, ISP3X_CNR_CTRL);
792
+ val |= ISP3X_CNR_THUMB_MIX_CUR_EN;
793
+ writel(val, hw->base_addr + ISP3X_CNR_CTRL);
794
+ if (hw->unite == ISP_UNITE_TWO)
795
+ writel(val, hw->base_next_addr + ISP3X_CNR_CTRL);
796
+ }
797
+ stats_vdev->rdbk_drop = true;
749798 }
750799 }
751800
752
- /* read 3d lut at frame end */
801
+ /* disable isp force update to read 3dlut
802
+ * 3dlut auto update at frame end for single sensor
803
+ */
753804 if (hw->is_single && is_upd &&
754805 rkisp_read_reg_cache(dev, ISP_3DLUT_UPDATE) & 0x1) {
755
- rkisp_unite_write(dev, ISP_3DLUT_UPDATE, 0, true, hw->is_unite);
806
+ rkisp_unite_write(dev, ISP_3DLUT_UPDATE, 0, true);
756807 is_3dlut_upd = true;
757808 }
758809 if (is_upd) {
759810 val = rkisp_read(dev, ISP_CTRL, false);
760811 val |= CIF_ISP_CTRL_ISP_CFG_UPD;
761
- rkisp_unite_write(dev, ISP_CTRL, val, true, hw->is_unite);
812
+ rkisp_unite_write(dev, ISP_CTRL, val, true);
762813 /* bayer pat after ISP_CFG_UPD for multi sensor to read lsc r/g/b table */
763
- rkisp_update_regs(dev, ISP_ACQ_PROP, ISP_ACQ_PROP);
814
+ rkisp_update_regs(dev, ISP3X_ISP_CTRL1, ISP3X_ISP_CTRL1);
764815 /* fix ldch multi sensor case:
765816 * ldch will pre-read data when en and isp force upd or frame end,
766817 * udelay for ldch pre-read data.
....@@ -771,12 +822,12 @@
771822 udelay(50);
772823 val &= ~(BIT(0) | BIT(31));
773824 writel(val, hw->base_addr + ISP_LDCH_BASE);
774
- if (hw->is_unite)
825
+ if (hw->unite == ISP_UNITE_TWO)
775826 writel(val, hw->base_next_addr + ISP_LDCH_BASE);
776827 }
777828 }
778829 if (is_3dlut_upd)
779
- rkisp_unite_write(dev, ISP_3DLUT_UPDATE, 1, true, hw->is_unite);
830
+ rkisp_unite_write(dev, ISP_3DLUT_UPDATE, 1, true);
780831
781832 /* if output stream enable, wait it end */
782833 val = rkisp_read(dev, CIF_MI_CTRL_SHD, true);
....@@ -807,11 +858,13 @@
807858 val &= ~SW_IBUF_OP_MODE(0xf);
808859 tmp = SW_IBUF_OP_MODE(dev->rd_mode);
809860 val |= tmp | SW_CSI2RX_EN | SW_DMA_2FRM_MODE(dma2frm);
861
+ if (dev->isp_ver > ISP_V20)
862
+ dma2frm = dev->sw_rd_cnt;
810863 v4l2_dbg(2, rkisp_debug, &dev->v4l2_dev,
811
- "readback frame:%d time:%d 0x%x\n",
812
- cur_frame_id, dma2frm + 1, val);
864
+ "readback frame:%d time:%d 0x%x try:%d\n",
865
+ cur_frame_id, dma2frm + 1, val, is_try);
813866 if (!hw->is_shutdown)
814
- rkisp_unite_write(dev, CSI2RX_CTRL0, val, true, hw->is_unite);
867
+ rkisp_unite_write(dev, CSI2RX_CTRL0, val, true);
815868 }
816869
817870 static void rkisp_fast_switch_rx_buf(struct rkisp_device *dev, bool is_current)
....@@ -819,6 +872,9 @@
819872 struct rkisp_stream *stream;
820873 struct rkisp_buffer *buf;
821874 u32 i, val;
875
+
876
+ if (!dev->is_rtt_first)
877
+ return;
822878
823879 for (i = RKISP_STREAM_RAWRD0; i < RKISP_MAX_DMARX_STREAM; i++) {
824880 stream = &dev->dmarx_dev.stream[i];
....@@ -865,6 +921,12 @@
865921 isp = dev;
866922 is_try = true;
867923 times = 0;
924
+ if (hw->unite == ISP_UNITE_ONE) {
925
+ if (dev->sw_rd_cnt < 2)
926
+ isp->unite_index = ISP_UNITE_RIGHT;
927
+ if (!hw->is_multi_overflow || (dev->sw_rd_cnt & 0x1))
928
+ is_try = false;
929
+ }
868930 goto end;
869931 }
870932 hw->is_idle = true;
....@@ -878,11 +940,16 @@
878940 goto end;
879941 if (!IS_HDR_RDBK(dev->rd_mode))
880942 goto end;
943
+ if (dev->is_suspend) {
944
+ if (dev->suspend_sync)
945
+ complete(&dev->pm_cmpl);
946
+ goto end;
947
+ }
881948
882949 for (i = 0; i < hw->dev_num; i++) {
883950 isp = hw->isp[i];
884951 if (!isp ||
885
- (isp && !(isp->isp_state & ISP_START)))
952
+ (isp && (!(isp->isp_state & ISP_START) || isp->is_suspend)))
886953 continue;
887954 rkisp_rdbk_trigger_event(isp, T_CMD_LEN, &len[i]);
888955 if (max < len[i]) {
....@@ -892,7 +959,7 @@
892959 }
893960
894961 /* wait 2 frame to start isp for fast */
895
- if (dev->is_pre_on && max == 1 && !atomic_read(&dev->isp_sdev.frm_sync_seq))
962
+ if (dev->is_rtt_first && max == 1 && !atomic_read(&dev->isp_sdev.frm_sync_seq))
896963 goto end;
897964
898965 if (max) {
....@@ -914,17 +981,42 @@
914981 times = t.times;
915982 hw->cur_dev_id = id;
916983 hw->is_idle = false;
984
+ /* this frame will read count by isp */
917985 isp->sw_rd_cnt = 0;
918
- if (hw->is_multi_overflow && (hw->pre_dev_id != id)) {
986
+ /* frame double for multi camera resolution out of hardware limit
987
+ * first for HW save this camera information, and second to output image
988
+ */
989
+ isp->is_frame_double = false;
990
+ if (hw->is_multi_overflow &&
991
+ (hw->unite == ISP_UNITE_ONE ||
992
+ (hw->pre_dev_id != -1 && hw->pre_dev_id != id))) {
993
+ isp->is_frame_double = true;
919994 isp->sw_rd_cnt = 1;
920995 times = 0;
921996 }
922
- if (isp->is_pre_on && t.frame_id == 0) {
997
+ /* resolution out of hardware limit
998
+ * frame is vertically divided into left and right
999
+ */
1000
+ isp->unite_index = ISP_UNITE_LEFT;
1001
+ if (hw->unite == ISP_UNITE_ONE) {
1002
+ isp->sw_rd_cnt *= 2;
1003
+ isp->sw_rd_cnt += 1;
1004
+ }
1005
+ /* first frame handle twice for thunderboot
1006
+ * first output stats to AIQ and wait new params to run second
1007
+ */
1008
+ if (isp->is_rtt_first && t.frame_id == 0) {
9231009 isp->is_first_double = true;
9241010 isp->skip_frame = 1;
925
- isp->sw_rd_cnt = 0;
1011
+ if (hw->unite != ISP_UNITE_ONE) {
1012
+ isp->sw_rd_cnt = 0;
1013
+ isp->is_frame_double = false;
1014
+ }
9261015 rkisp_fast_switch_rx_buf(isp, false);
1016
+ } else {
1017
+ isp->is_rtt_first = false;
9271018 }
1019
+ isp->params_vdev.rdbk_times = isp->sw_rd_cnt + 1;
9281020 }
9291021 end:
9301022 spin_unlock_irqrestore(&hw->rdbk_lock, lock_flags);
....@@ -982,12 +1074,6 @@
9821074 {
9831075 u32 val = 0;
9841076
985
- if (dev->hw_dev->is_multi_overflow &&
986
- dev->sw_rd_cnt &&
987
- irq & ISP_FRAME_END &&
988
- !dev->is_first_double)
989
- goto end;
990
-
9911077 dev->irq_ends |= (irq & dev->irq_ends_mask);
9921078 v4l2_dbg(3, rkisp_debug, &dev->v4l2_dev,
9931079 "%s irq:0x%x ends:0x%x mask:0x%x\n",
....@@ -1002,8 +1088,12 @@
10021088 !IS_HDR_RDBK(dev->rd_mode))
10031089 return;
10041090
1091
+ if (dev->sw_rd_cnt)
1092
+ goto end;
1093
+
10051094 if (dev->is_first_double) {
10061095 rkisp_fast_switch_rx_buf(dev, true);
1096
+ dev->is_rtt_first = false;
10071097 dev->skip_frame = 0;
10081098 dev->irq_ends = 0;
10091099 return;
....@@ -1068,26 +1158,25 @@
10681158 {
10691159 struct v4l2_rect *out_crop = &dev->isp_sdev.out_crop;
10701160 u32 width = out_crop->width, mult = 1;
1071
- bool is_unite = dev->hw_dev->is_unite;
1161
+ u32 unite = dev->hw_dev->unite;
10721162
10731163 /* isp2.0 no ism */
10741164 if (dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21 ||
10751165 dev->isp_ver == ISP_V32_L)
10761166 return;
10771167
1078
- if (is_unite)
1168
+ if (unite)
10791169 width = width / 2 + RKMOUDLE_UNITE_EXTEND_PIXEL;
1080
- rkisp_unite_write(dev, CIF_ISP_IS_RECENTER, 0, false, is_unite);
1081
- rkisp_unite_write(dev, CIF_ISP_IS_MAX_DX, 0, false, is_unite);
1082
- rkisp_unite_write(dev, CIF_ISP_IS_MAX_DY, 0, false, is_unite);
1083
- rkisp_unite_write(dev, CIF_ISP_IS_DISPLACE, 0, false, is_unite);
1084
- rkisp_unite_write(dev, CIF_ISP_IS_H_OFFS, out_crop->left, false, is_unite);
1085
- rkisp_unite_write(dev, CIF_ISP_IS_V_OFFS, out_crop->top, false, is_unite);
1086
- rkisp_unite_write(dev, CIF_ISP_IS_H_SIZE, width, false, is_unite);
1170
+ rkisp_unite_write(dev, CIF_ISP_IS_RECENTER, 0, false);
1171
+ rkisp_unite_write(dev, CIF_ISP_IS_MAX_DX, 0, false);
1172
+ rkisp_unite_write(dev, CIF_ISP_IS_MAX_DY, 0, false);
1173
+ rkisp_unite_write(dev, CIF_ISP_IS_DISPLACE, 0, false);
1174
+ rkisp_unite_write(dev, CIF_ISP_IS_H_OFFS, out_crop->left, false);
1175
+ rkisp_unite_write(dev, CIF_ISP_IS_V_OFFS, out_crop->top, false);
1176
+ rkisp_unite_write(dev, CIF_ISP_IS_H_SIZE, width, false);
10871177 if (dev->cap_dev.stream[RKISP_STREAM_SP].interlaced)
10881178 mult = 2;
1089
- rkisp_unite_write(dev, CIF_ISP_IS_V_SIZE, out_crop->height / mult,
1090
- false, is_unite);
1179
+ rkisp_unite_write(dev, CIF_ISP_IS_V_SIZE, out_crop->height / mult, false);
10911180
10921181 if (dev->isp_ver == ISP_V30 || dev->isp_ver == ISP_V32)
10931182 return;
....@@ -1096,86 +1185,19 @@
10961185 rkisp_write(dev, CIF_ISP_IS_CTRL, 1, false);
10971186 }
10981187
1099
-static int rkisp_reset_handle_v2x(struct rkisp_device *dev)
1188
+static int rkisp_reset_handle(struct rkisp_device *dev)
11001189 {
1101
- void __iomem *base = dev->base_addr;
1102
- void *reg_buf = NULL;
1103
- u32 *reg, *reg1, i;
1104
- struct backup_reg backup[] = {
1105
- {
1106
- .base = MI_MP_WR_Y_BASE,
1107
- .shd = MI_MP_WR_Y_BASE_SHD,
1108
- }, {
1109
- .base = MI_MP_WR_CB_BASE,
1110
- .shd = MI_MP_WR_CB_BASE_SHD,
1111
- }, {
1112
- .base = MI_MP_WR_CR_BASE,
1113
- .shd = MI_MP_WR_CR_BASE_SHD,
1114
- }, {
1115
- .base = MI_SP_WR_Y_BASE,
1116
- .shd = MI_SP_WR_Y_BASE_SHD,
1117
- }, {
1118
- .base = MI_SP_WR_CB_BASE,
1119
- .shd = MI_SP_WR_CB_BASE_AD_SHD,
1120
- }, {
1121
- .base = MI_SP_WR_CR_BASE,
1122
- .shd = MI_SP_WR_CR_BASE_AD_SHD,
1123
- }, {
1124
- .base = MI_RAW0_WR_BASE,
1125
- .shd = MI_RAW0_WR_BASE_SHD,
1126
- }, {
1127
- .base = MI_RAW1_WR_BASE,
1128
- .shd = MI_RAW1_WR_BASE_SHD,
1129
- }, {
1130
- .base = MI_RAW2_WR_BASE,
1131
- .shd = MI_RAW2_WR_BASE_SHD,
1132
- }, {
1133
- .base = MI_RAW3_WR_BASE,
1134
- .shd = MI_RAW3_WR_BASE_SHD,
1135
- }, {
1136
- .base = MI_RAW0_RD_BASE,
1137
- .shd = MI_RAW0_RD_BASE_SHD,
1138
- }, {
1139
- .base = MI_RAW1_RD_BASE,
1140
- .shd = MI_RAW1_RD_BASE_SHD,
1141
- }, {
1142
- .base = MI_RAW2_RD_BASE,
1143
- .shd = MI_RAW2_RD_BASE_SHD,
1144
- }, {
1145
- .base = MI_GAIN_WR_BASE,
1146
- .shd = MI_GAIN_WR_BASE_SHD,
1147
- }
1148
- };
1149
-
1150
- reg_buf = kzalloc(RKISP_ISP_SW_REG_SIZE, GFP_KERNEL);
1151
- if (!reg_buf)
1152
- return -ENOMEM;
1190
+ u32 val;
11531191
11541192 dev_info(dev->dev, "%s enter\n", __func__);
1193
+ rkisp_hw_reg_save(dev->hw_dev);
11551194
1156
- memcpy_fromio(reg_buf, base, RKISP_ISP_SW_REG_SIZE);
11571195 rkisp_soft_reset(dev->hw_dev, true);
11581196
1159
- /* process special reg */
1160
- reg = reg_buf + ISP_CTRL;
1161
- *reg &= ~(CIF_ISP_CTRL_ISP_ENABLE |
1162
- CIF_ISP_CTRL_ISP_INFORM_ENABLE |
1163
- CIF_ISP_CTRL_ISP_CFG_UPD);
1164
- reg = reg_buf + MI_WR_INIT;
1165
- *reg = 0;
1166
- reg = reg_buf + CSI2RX_CTRL0;
1167
- *reg &= ~SW_CSI2RX_EN;
1168
- /* skip mmu range */
1169
- memcpy_toio(base, reg_buf, ISP21_MI_BAY3D_RD_BASE_SHD);
1170
- memcpy_toio(base + CSI2RX_CTRL0, reg_buf + CSI2RX_CTRL0,
1171
- RKISP_ISP_SW_REG_SIZE - CSI2RX_CTRL0);
1172
- /* config shd_reg to base_reg */
1173
- for (i = 0; i < ARRAY_SIZE(backup); i++) {
1174
- reg = reg_buf + backup[i].base;
1175
- reg1 = reg_buf + backup[i].shd;
1176
- backup[i].val = *reg;
1177
- writel(*reg1, base + backup[i].base);
1178
- }
1197
+ rkisp_hw_reg_restore(dev->hw_dev);
1198
+
1199
+ val = CIF_ISP_DATA_LOSS | CIF_ISP_PIC_SIZE_ERROR;
1200
+ rkisp_unite_set_bits(dev, CIF_ISP_IMSC, 0, val, true);
11791201
11801202 /* clear state */
11811203 dev->isp_err_cnt = 0;
....@@ -1183,40 +1205,12 @@
11831205 rkisp_set_state(&dev->isp_state, ISP_FRAME_END);
11841206 dev->hw_dev->monitor.state = ISP_FRAME_END;
11851207
1186
- /* update module */
1187
- reg = reg_buf + DUAL_CROP_CTRL;
1188
- if (*reg & 0xf)
1189
- writel(*reg | CIF_DUAL_CROP_CFG_UPD, base + DUAL_CROP_CTRL);
1190
- reg = reg_buf + SELF_RESIZE_CTRL;
1191
- if (*reg & 0xf)
1192
- writel(*reg | CIF_RSZ_CTRL_CFG_UPD, base + SELF_RESIZE_CTRL);
1193
- reg = reg_buf + MAIN_RESIZE_CTRL;
1194
- if (*reg & 0xf)
1195
- writel(*reg | CIF_RSZ_CTRL_CFG_UPD, base + MAIN_RESIZE_CTRL);
1196
-
1197
- /* update mi and isp, base_reg will update to shd_reg */
1198
- force_cfg_update(dev);
1199
- reg = reg_buf + ISP_CTRL;
1200
- *reg |= CIF_ISP_CTRL_ISP_ENABLE |
1201
- CIF_ISP_CTRL_ISP_INFORM_ENABLE |
1202
- CIF_ISP_CTRL_ISP_CFG_UPD;
1203
- writel(*reg, base + ISP_CTRL);
1204
- udelay(50);
1205
- /* config base_reg */
1206
- for (i = 0; i < ARRAY_SIZE(backup); i++)
1207
- writel(backup[i].val, base + backup[i].base);
1208
- /* mpfbc base_reg = shd_reg, write is base but read is shd */
1209
- if (dev->isp_ver == ISP_V20)
1210
- writel(rkisp_read_reg_cache(dev, ISP_MPFBC_HEAD_PTR),
1211
- base + ISP_MPFBC_HEAD_PTR);
1212
- rkisp_set_bits(dev, CIF_ISP_IMSC, 0, CIF_ISP_DATA_LOSS | CIF_ISP_PIC_SIZE_ERROR, true);
12131208 if (IS_HDR_RDBK(dev->hdr.op_mode)) {
12141209 if (!dev->hw_dev->is_idle)
12151210 rkisp_trigger_read_back(dev, 1, 0, true);
12161211 else
12171212 rkisp_rdbk_trigger_event(dev, T_CMD_QUEUE, NULL);
12181213 }
1219
- kfree(reg_buf);
12201214 dev_info(dev->dev, "%s exit\n", __func__);
12211215 return 0;
12221216 }
....@@ -1230,11 +1224,6 @@
12301224 struct rkisp_pipeline *p;
12311225 int ret, i, j, timeout = 5, mipi_irq_cnt = 0;
12321226
1233
- if (!monitor->reset_handle) {
1234
- monitor->is_en = false;
1235
- return;
1236
- }
1237
-
12381227 dev_info(hw->dev, "%s enter\n", __func__);
12391228 while (!(monitor->state & ISP_STOP) && monitor->is_en) {
12401229 ret = wait_for_completion_timeout(&monitor->cmpl,
....@@ -1242,8 +1231,11 @@
12421231 /* isp stop to exit
12431232 * isp err to reset
12441233 * mipi err wait isp idle, then reset
1234
+ * online vicap if isp err, notify vicap reset, then vicap notify isp reset
1235
+ * by ioctl RKISP_VICAP_CMD_SET_STREAM
12451236 */
12461237 if (monitor->state & ISP_STOP ||
1238
+ monitor->state & ISP_CIF_RESET ||
12471239 (ret && !(monitor->state & ISP_ERROR)) ||
12481240 (!ret &&
12491241 monitor->state & ISP_FRAME_END &&
....@@ -1292,10 +1284,22 @@
12921284
12931285 /* restart isp */
12941286 isp = hw->isp[hw->cur_dev_id];
1295
- ret = monitor->reset_handle(isp);
1296
- if (ret) {
1297
- monitor->is_en = false;
1298
- break;
1287
+ if (!IS_HDR_RDBK(isp->hdr.op_mode) && isp->isp_ver >= ISP_V30) {
1288
+ struct v4l2_subdev *remote = NULL;
1289
+ struct v4l2_subdev *isp_subdev = NULL;
1290
+
1291
+ isp_subdev = &(isp->isp_sdev.sd);
1292
+ remote = get_remote_sensor(isp_subdev);
1293
+ v4l2_subdev_call(remote, core, ioctl,
1294
+ RKISP_VICAP_CMD_SET_RESET, NULL);
1295
+ monitor->state |= ISP_CIF_RESET;
1296
+ continue;
1297
+ } else {
1298
+ ret = rkisp_reset_handle(isp);
1299
+ if (ret) {
1300
+ monitor->is_en = false;
1301
+ break;
1302
+ }
12991303 }
13001304
13011305 for (i = 0; i < hw->dev_num; i++) {
....@@ -1329,9 +1333,6 @@
13291333 struct rkisp_monitor *monitor = &dev->hw_dev->monitor;
13301334
13311335 monitor->dev = dev->hw_dev;
1332
- monitor->reset_handle = NULL;
1333
- if (dev->isp_ver == ISP_V20 || dev->isp_ver == ISP_V21)
1334
- monitor->reset_handle = rkisp_reset_handle_v2x;
13351336
13361337 init_completion(&monitor->cmpl);
13371338 INIT_WORK(&monitor->work, rkisp_restart_monitor);
....@@ -1389,20 +1390,18 @@
13891390
13901391 for (i = 0; i < 9; i++)
13911392 rkisp_unite_write(dev, CIF_ISP_CC_COEFF_0 + i * 4,
1392
- *(coeff + i), false, dev->hw_dev->is_unite);
1393
+ *(coeff + i), false);
13931394
13941395 val = rkisp_read_reg_cache(dev, CIF_ISP_CTRL);
13951396
13961397 if (dev->isp_sdev.quantization == V4L2_QUANTIZATION_FULL_RANGE)
13971398 rkisp_unite_write(dev, CIF_ISP_CTRL, val |
13981399 CIF_ISP_CTRL_ISP_CSM_Y_FULL_ENA |
1399
- CIF_ISP_CTRL_ISP_CSM_C_FULL_ENA,
1400
- false, dev->hw_dev->is_unite);
1400
+ CIF_ISP_CTRL_ISP_CSM_C_FULL_ENA, false);
14011401 else
14021402 rkisp_unite_write(dev, CIF_ISP_CTRL, val &
14031403 ~(CIF_ISP_CTRL_ISP_CSM_Y_FULL_ENA |
1404
- CIF_ISP_CTRL_ISP_CSM_C_FULL_ENA),
1405
- false, dev->hw_dev->is_unite);
1404
+ CIF_ISP_CTRL_ISP_CSM_C_FULL_ENA), false);
14061405 }
14071406
14081407 static void rkisp_config_cmsk_single(struct rkisp_device *dev,
....@@ -1498,6 +1497,7 @@
14981497 left.win[0].win_en &= ~BIT(i);
14991498 left.win[1].win_en &= ~BIT(i);
15001499 left.win[2].win_en &= ~BIT(i);
1500
+ right.win[i].h_offs = h_offs - w + RKMOUDLE_UNITE_EXTEND_PIXEL;
15011501 } else {
15021502 /* cmsk window at dual isp */
15031503 left.win[i].h_size = ALIGN(w - h_offs, 8);
....@@ -1601,7 +1601,7 @@
16011601 cfg = dev->cmsk_cfg;
16021602 spin_unlock_irqrestore(&dev->cmsk_lock, lock_flags);
16031603
1604
- if (!dev->hw_dev->is_unite)
1604
+ if (!dev->hw_dev->unite)
16051605 rkisp_config_cmsk_single(dev, &cfg);
16061606 else
16071607 rkisp_config_cmsk_dual(dev, &cfg);
....@@ -1616,7 +1616,7 @@
16161616 struct ispsd_out_fmt *out_fmt;
16171617 struct v4l2_rect *in_crop;
16181618 struct rkisp_sensor_info *sensor;
1619
- bool is_unite = dev->hw_dev->is_unite;
1619
+ bool is_unite = !!dev->hw_dev->unite;
16201620 u32 isp_ctrl = 0;
16211621 u32 irq_mask = 0;
16221622 u32 signal = 0;
....@@ -1646,22 +1646,20 @@
16461646 in_fmt->mbus_code == MEDIA_BUS_FMT_Y10_1X10 ||
16471647 in_fmt->mbus_code == MEDIA_BUS_FMT_Y12_1X12) {
16481648 if (dev->isp_ver >= ISP_V20)
1649
- rkisp_unite_write(dev, ISP_DEBAYER_CONTROL,
1650
- 0, false, is_unite);
1649
+ rkisp_unite_write(dev, ISP_DEBAYER_CONTROL, 0, false);
16511650 else
16521651 rkisp_write(dev, CIF_ISP_DEMOSAIC,
1653
- CIF_ISP_DEMOSAIC_BYPASS |
1654
- CIF_ISP_DEMOSAIC_TH(0xc), false);
1652
+ CIF_ISP_DEMOSAIC_BYPASS |
1653
+ CIF_ISP_DEMOSAIC_TH(0xc), false);
16551654 } else {
16561655 if (dev->isp_ver >= ISP_V20)
16571656 rkisp_unite_write(dev, ISP_DEBAYER_CONTROL,
16581657 SW_DEBAYER_EN |
16591658 SW_DEBAYER_FILTER_G_EN |
1660
- SW_DEBAYER_FILTER_C_EN,
1661
- false, is_unite);
1659
+ SW_DEBAYER_FILTER_C_EN, false);
16621660 else
16631661 rkisp_write(dev, CIF_ISP_DEMOSAIC,
1664
- CIF_ISP_DEMOSAIC_TH(0xc), false);
1662
+ CIF_ISP_DEMOSAIC_TH(0xc), false);
16651663 }
16661664
16671665 if (sensor && sensor->mbus.type == V4L2_MBUS_BT656)
....@@ -1714,38 +1712,31 @@
17141712 if (rkisp_read_reg_cache(dev, CIF_ISP_CTRL) & ISP32_MIR_ENABLE)
17151713 isp_ctrl |= ISP32_MIR_ENABLE;
17161714
1717
- rkisp_unite_write(dev, CIF_ISP_CTRL, isp_ctrl, false, is_unite);
1715
+ rkisp_unite_write(dev, CIF_ISP_CTRL, isp_ctrl, false);
17181716 acq_prop |= signal | in_fmt->yuv_seq |
17191717 CIF_ISP_ACQ_PROP_BAYER_PAT(in_fmt->bayer_pat) |
17201718 CIF_ISP_ACQ_PROP_FIELD_SEL_ALL;
1721
- rkisp_unite_write(dev, CIF_ISP_ACQ_PROP, acq_prop, false, is_unite);
1722
- rkisp_unite_write(dev, CIF_ISP_ACQ_NR_FRAMES, 0, true, is_unite);
1719
+ rkisp_unite_write(dev, CIF_ISP_ACQ_PROP, acq_prop, false);
1720
+ rkisp_unite_write(dev, CIF_ISP_ACQ_NR_FRAMES, 0, true);
17231721
17241722 if (is_unite)
17251723 width = width / 2 + RKMOUDLE_UNITE_EXTEND_PIXEL;
17261724 /* Acquisition Size */
1727
- rkisp_unite_write(dev, CIF_ISP_ACQ_H_OFFS, acq_mult * in_crop->left,
1728
- false, is_unite);
1729
- rkisp_unite_write(dev, CIF_ISP_ACQ_V_OFFS, in_crop->top,
1730
- false, is_unite);
1731
- rkisp_unite_write(dev, CIF_ISP_ACQ_H_SIZE, acq_mult * width,
1732
- false, is_unite);
1725
+ rkisp_unite_write(dev, CIF_ISP_ACQ_H_OFFS, acq_mult * in_crop->left, false);
1726
+ rkisp_unite_write(dev, CIF_ISP_ACQ_V_OFFS, in_crop->top, false);
1727
+ rkisp_unite_write(dev, CIF_ISP_ACQ_H_SIZE, acq_mult * width, false);
17331728
17341729 /* ISP Out Area differ with ACQ is only FIFO, so don't crop in this */
1735
- rkisp_unite_write(dev, CIF_ISP_OUT_H_OFFS, 0, true, is_unite);
1736
- rkisp_unite_write(dev, CIF_ISP_OUT_V_OFFS, 0, true, is_unite);
1737
- rkisp_unite_write(dev, CIF_ISP_OUT_H_SIZE, width, false, is_unite);
1730
+ rkisp_unite_write(dev, CIF_ISP_OUT_H_OFFS, 0, true);
1731
+ rkisp_unite_write(dev, CIF_ISP_OUT_V_OFFS, 0, true);
1732
+ rkisp_unite_write(dev, CIF_ISP_OUT_H_SIZE, width, false);
17381733
17391734 if (dev->cap_dev.stream[RKISP_STREAM_SP].interlaced) {
1740
- rkisp_unite_write(dev, CIF_ISP_ACQ_V_SIZE, in_crop->height / 2,
1741
- false, is_unite);
1742
- rkisp_unite_write(dev, CIF_ISP_OUT_V_SIZE, in_crop->height / 2,
1743
- false, is_unite);
1735
+ rkisp_unite_write(dev, CIF_ISP_ACQ_V_SIZE, in_crop->height / 2, false);
1736
+ rkisp_unite_write(dev, CIF_ISP_OUT_V_SIZE, in_crop->height / 2, false);
17441737 } else {
1745
- rkisp_unite_write(dev, CIF_ISP_ACQ_V_SIZE, in_crop->height + extend_line,
1746
- false, is_unite);
1747
- rkisp_unite_write(dev, CIF_ISP_OUT_V_SIZE, in_crop->height + extend_line,
1748
- false, is_unite);
1738
+ rkisp_unite_write(dev, CIF_ISP_ACQ_V_SIZE, in_crop->height + extend_line, false);
1739
+ rkisp_unite_write(dev, CIF_ISP_OUT_V_SIZE, in_crop->height + extend_line, false);
17491740 }
17501741
17511742 /* interrupt mask */
....@@ -1754,7 +1745,7 @@
17541745 irq_mask |= ISP2X_LSC_LUT_ERR;
17551746 if (dev->is_pre_on)
17561747 irq_mask |= CIF_ISP_FRAME_IN;
1757
- rkisp_unite_write(dev, CIF_ISP_IMSC, irq_mask, true, is_unite);
1748
+ rkisp_unite_write(dev, CIF_ISP_IMSC, irq_mask, true);
17581749
17591750 if ((dev->isp_ver == ISP_V20 ||
17601751 dev->isp_ver == ISP_V21) &&
....@@ -1909,8 +1900,7 @@
19091900 if (dev->isp_ver == ISP_V32)
19101901 dpcl |= BIT(0);
19111902
1912
- rkisp_unite_set_bits(dev, CIF_VI_DPCL, 0, dpcl, true,
1913
- dev->hw_dev->is_unite);
1903
+ rkisp_unite_set_bits(dev, CIF_VI_DPCL, 0, dpcl, true);
19141904 return ret;
19151905 }
19161906
....@@ -2007,9 +1997,9 @@
20071997
20081998 v4l2_dbg(1, rkisp_debug, &dev->v4l2_dev,
20091999 "%s refcnt:%d\n", __func__,
2010
- atomic_read(&dev->hw_dev->refcnt));
2000
+ atomic_read(&hw->refcnt));
20112001
2012
- if (atomic_read(&dev->hw_dev->refcnt) > 1)
2002
+ if (atomic_read(&hw->refcnt) > 1)
20132003 goto end;
20142004 /*
20152005 * ISP(mi) stop in mi frame end -> Stop ISP(mipi) ->
....@@ -2065,7 +2055,7 @@
20652055
20662056 val = readl(base + CIF_ISP_CTRL);
20672057 writel(val | CIF_ISP_CTRL_ISP_CFG_UPD, base + CIF_ISP_CTRL);
2068
- if (hw->is_unite)
2058
+ if (hw->unite == ISP_UNITE_TWO)
20692059 rkisp_next_write(dev, CIF_ISP_CTRL,
20702060 val | CIF_ISP_CTRL_ISP_CFG_UPD, true);
20712061
....@@ -2082,11 +2072,11 @@
20822072 safe_rate = hw->clk_rate_tbl[0].clk_rate * 1000000UL;
20832073 if (old_rate > safe_rate) {
20842074 rkisp_set_clk_rate(hw->clks[0], safe_rate);
2085
- if (hw->is_unite)
2075
+ if (hw->unite == ISP_UNITE_TWO)
20862076 rkisp_set_clk_rate(hw->clks[5], safe_rate);
20872077 udelay(100);
20882078 }
2089
- rkisp_soft_reset(dev->hw_dev, false);
2079
+ rkisp_soft_reset(hw, false);
20902080 }
20912081
20922082 if (dev->isp_ver == ISP_V12 || dev->isp_ver == ISP_V13) {
....@@ -2097,18 +2087,20 @@
20972087 writel(0, base + CIF_ISP_CSI0_MASK3);
20982088 } else if (dev->isp_ver >= ISP_V20) {
20992089 writel(0, base + CSI2RX_CSI2_RESETN);
2100
- if (hw->is_unite)
2090
+ if (hw->unite == ISP_UNITE_TWO)
21012091 rkisp_next_write(dev, CSI2RX_CSI2_RESETN, 0, true);
21022092 }
21032093
21042094 hw->is_dvfs = false;
21052095 hw->is_runing = false;
2106
- dev->hw_dev->is_idle = true;
2107
- dev->hw_dev->is_mi_update = false;
2096
+ hw->is_idle = true;
2097
+ hw->is_mi_update = false;
2098
+ hw->pre_dev_id = -1;
21082099 end:
21092100 dev->irq_ends_mask = 0;
21102101 dev->hdr.op_mode = 0;
21112102 dev->sw_rd_cnt = 0;
2103
+ dev->stats_vdev.rdbk_drop = false;
21122104 rkisp_set_state(&dev->isp_state, ISP_STOP);
21132105
21142106 if (dev->isp_ver >= ISP_V20)
....@@ -2154,12 +2146,9 @@
21542146 val = dev->isp_sdev.out_crop.height / 15;
21552147 val = dev->cap_dev.wait_line / val;
21562148 val = ISP3X_RAWAF_INELINE0(val) | ISP3X_RAWAF_INTLINE0_EN;
2157
- rkisp_unite_write(dev, ISP3X_RAWAF_INT_LINE,
2158
- val, false, dev->hw_dev->is_unite);
2159
- rkisp_unite_set_bits(dev, ISP_ISP3A_IMSC, 0,
2160
- ISP2X_3A_RAWAF, false, dev->hw_dev->is_unite);
2161
- rkisp_unite_clear_bits(dev, CIF_ISP_IMSC,
2162
- ISP2X_LSC_LUT_ERR, false, dev->hw_dev->is_unite);
2149
+ rkisp_unite_write(dev, ISP3X_RAWAF_INT_LINE, val, false);
2150
+ rkisp_unite_set_bits(dev, ISP_ISP3A_IMSC, 0, ISP2X_3A_RAWAF, false);
2151
+ rkisp_unite_clear_bits(dev, CIF_ISP_IMSC, ISP2X_LSC_LUT_ERR, false);
21632152 dev->rawaf_irq_cnt = 0;
21642153 }
21652154 }
....@@ -2187,12 +2176,11 @@
21872176 val |= NOC_HURRY_PRIORITY(2) | NOC_HURRY_W_MODE(2) | NOC_HURRY_R_MODE(1);
21882177 if (atomic_read(&dev->hw_dev->refcnt) > 1)
21892178 is_direct = false;
2190
- rkisp_unite_write(dev, CIF_ISP_CTRL, val, is_direct, dev->hw_dev->is_unite);
2179
+ rkisp_unite_write(dev, CIF_ISP_CTRL, val, is_direct);
21912180 rkisp_clear_reg_cache_bits(dev, CIF_ISP_CTRL, CIF_ISP_CTRL_ISP_CFG_UPD);
21922181
21932182 dev->isp_err_cnt = 0;
21942183 dev->isp_isr_cnt = 0;
2195
- dev->isp_state = ISP_START | ISP_FRAME_END;
21962184 dev->irq_ends_mask |= ISP_FRAME_END;
21972185 dev->irq_ends = 0;
21982186
....@@ -2668,14 +2656,16 @@
26682656 max_h = CIF_ISP_INPUT_H_MAX_V21;
26692657 break;
26702658 case ISP_V30:
2671
- max_w = dev->hw_dev->is_unite ?
2659
+ max_w = dev->hw_dev->unite ?
26722660 CIF_ISP_INPUT_W_MAX_V30_UNITE : CIF_ISP_INPUT_W_MAX_V30;
2673
- max_h = dev->hw_dev->is_unite ?
2661
+ max_h = dev->hw_dev->unite ?
26742662 CIF_ISP_INPUT_H_MAX_V30_UNITE : CIF_ISP_INPUT_H_MAX_V30;
26752663 break;
26762664 case ISP_V32:
2677
- max_w = CIF_ISP_INPUT_W_MAX_V32;
2678
- max_h = CIF_ISP_INPUT_H_MAX_V32;
2665
+ max_w = dev->hw_dev->unite ?
2666
+ CIF_ISP_INPUT_W_MAX_V32_UNITE : CIF_ISP_INPUT_W_MAX_V32;
2667
+ max_h = dev->hw_dev->unite ?
2668
+ CIF_ISP_INPUT_H_MAX_V32_UNITE : CIF_ISP_INPUT_H_MAX_V32;
26792669 break;
26802670 case ISP_V32_L:
26812671 max_w = CIF_ISP_INPUT_W_MAX_V32_L;
....@@ -2865,6 +2855,7 @@
28652855 {
28662856 struct rkisp_device *isp_dev = sd_to_isp_dev(sd);
28672857 struct rkisp_hw_dev *hw_dev = isp_dev->hw_dev;
2858
+ int ret;
28682859
28692860 if (!on) {
28702861 if (IS_HDR_RDBK(isp_dev->rd_mode)) {
....@@ -2877,10 +2868,13 @@
28772868 wake_up(&s->done);
28782869 }
28792870 }
2880
- wait_event_timeout(isp_dev->sync_onoff,
2881
- isp_dev->isp_state & ISP_STOP ||
2882
- !IS_HDR_RDBK(isp_dev->rd_mode),
2883
- msecs_to_jiffies(50));
2871
+ ret = wait_event_timeout(isp_dev->sync_onoff,
2872
+ isp_dev->isp_state & ISP_STOP ||
2873
+ !IS_HDR_RDBK(isp_dev->rd_mode),
2874
+ msecs_to_jiffies(500));
2875
+ if (!ret)
2876
+ v4l2_warn(&isp_dev->v4l2_dev, "%s wait timeout, mode:%d state:0x%x\n",
2877
+ __func__, isp_dev->rd_mode, isp_dev->isp_state);
28842878 rkisp_isp_stop(isp_dev);
28852879 atomic_dec(&hw_dev->refcnt);
28862880 rkisp_params_stream_stop(&isp_dev->params_vdev);
....@@ -2901,6 +2895,7 @@
29012895 rkisp_config_cif(isp_dev);
29022896 rkisp_isp_start(isp_dev);
29032897 rkisp_global_update_mi(isp_dev);
2898
+ isp_dev->isp_state = ISP_START | ISP_FRAME_END;
29042899 rkisp_rdbk_trigger_event(isp_dev, T_CMD_QUEUE, NULL);
29052900 return 0;
29062901 }
....@@ -2936,7 +2931,7 @@
29362931 u32 val = pool->buf.buff_addr[RKISP_PLANE_Y];
29372932
29382933 rkisp_write(dev, stream->config->mi.y_base_ad_init, val, false);
2939
- if (dev->hw_dev->is_unite) {
2934
+ if (dev->hw_dev->unite == ISP_UNITE_TWO) {
29402935 u32 offs = stream->out_fmt.width / 2 - RKMOUDLE_UNITE_EXTEND_PIXEL;
29412936
29422937 if (stream->memory)
....@@ -3054,7 +3049,8 @@
30543049
30553050 pool->dbufs = dbufs;
30563051 v4l2_dbg(1, rkisp_debug, &dev->v4l2_dev,
3057
- "%s type:0x%x dbufs[%d]:%p", __func__, dbufs->type, i, dbufs);
3052
+ "%s type:0x%x first:%d dbufs[%d]:%p", __func__,
3053
+ dbufs->type, dbufs->is_first, i, dbufs);
30583054
30593055 if (dbufs->is_resmem) {
30603056 dma = dbufs->dma;
....@@ -3412,11 +3408,64 @@
34123408 if (dev->is_bigmode)
34133409 mode |= RKISP_ISP_BIGMODE;
34143410 info->mode = mode;
3415
- if (dev->hw_dev->is_unite)
3411
+ if (dev->hw_dev->unite)
34163412 info->act_width = in_crop->width / 2 + RKMOUDLE_UNITE_EXTEND_PIXEL;
34173413 else
34183414 info->act_width = in_crop->width;
34193415 info->act_height = in_crop->height;
3416
+ return 0;
3417
+}
3418
+
3419
+static int rkisp_set_work_mode_by_vicap(struct rkisp_device *isp_dev,
3420
+ struct rkisp_vicap_mode *vicap_mode)
3421
+{
3422
+ struct rkisp_hw_dev *hw = isp_dev->hw_dev;
3423
+ int rd_mode = isp_dev->rd_mode;
3424
+
3425
+ isp_dev->is_suspend_one_frame = false;
3426
+ if (vicap_mode->rdbk_mode == RKISP_VICAP_ONLINE) {
3427
+ if (!hw->is_single)
3428
+ return -EINVAL;
3429
+ /* switch to online mode for single sensor */
3430
+ switch (rd_mode) {
3431
+ case HDR_RDBK_FRAME3:
3432
+ isp_dev->rd_mode = HDR_LINEX3_DDR;
3433
+ break;
3434
+ case HDR_RDBK_FRAME2:
3435
+ isp_dev->rd_mode = HDR_LINEX2_DDR;
3436
+ break;
3437
+ default:
3438
+ isp_dev->rd_mode = HDR_NORMAL;
3439
+ }
3440
+ } else if (vicap_mode->rdbk_mode == RKISP_VICAP_RDBK_AUTO ||
3441
+ vicap_mode->rdbk_mode == RKISP_VICAP_RDBK_AUTO_ONE_FRAME) {
3442
+ /* switch to readback mode */
3443
+ switch (rd_mode) {
3444
+ case HDR_LINEX3_DDR:
3445
+ isp_dev->rd_mode = HDR_RDBK_FRAME3;
3446
+ break;
3447
+ case HDR_LINEX2_DDR:
3448
+ isp_dev->rd_mode = HDR_RDBK_FRAME2;
3449
+ break;
3450
+ default:
3451
+ isp_dev->rd_mode = HDR_RDBK_FRAME1;
3452
+ }
3453
+ if (vicap_mode->rdbk_mode == RKISP_VICAP_RDBK_AUTO_ONE_FRAME)
3454
+ isp_dev->is_suspend_one_frame = true;
3455
+ } else {
3456
+ return -EINVAL;
3457
+ }
3458
+ isp_dev->hdr.op_mode = isp_dev->rd_mode;
3459
+ if (rd_mode != isp_dev->rd_mode && hw->cur_dev_id == isp_dev->dev_id) {
3460
+ rkisp_unite_write(isp_dev, CSI2RX_CTRL0,
3461
+ SW_IBUF_OP_MODE(isp_dev->rd_mode), true);
3462
+ if (IS_HDR_RDBK(isp_dev->rd_mode))
3463
+ rkisp_unite_set_bits(isp_dev, CTRL_SWS_CFG, 0,
3464
+ SW_MPIP_DROP_FRM_DIS, true);
3465
+ else
3466
+ rkisp_unite_clear_bits(isp_dev, CTRL_SWS_CFG,
3467
+ SW_MPIP_DROP_FRM_DIS, true);
3468
+ }
34203469 return 0;
34213470 }
34223471
....@@ -3445,7 +3494,7 @@
34453494 rkisp_get_info(isp_dev, arg);
34463495 break;
34473496 case RKISP_CMD_GET_TB_HEAD_V32:
3448
- if (isp_dev->tb_head.complete != RKISP_TB_OK || !isp_dev->is_pre_on) {
3497
+ if (isp_dev->tb_head.complete != RKISP_TB_OK) {
34493498 ret = -EINVAL;
34503499 break;
34513500 }
....@@ -3543,6 +3592,16 @@
35433592 isp_dev->hw_dev->is_multi_overflow = false;
35443593 rkisp_hw_enum_isp_size(isp_dev->hw_dev);
35453594 }
3595
+ break;
3596
+ case RKISP_VICAP_CMD_SET_STREAM:
3597
+ ret = rkisp_reset_handle(isp_dev);
3598
+ if (!ret) {
3599
+ if (isp_dev->hw_dev->monitor.state & ISP_CIF_RESET)
3600
+ isp_dev->hw_dev->monitor.state &= ~ISP_CIF_RESET;
3601
+ }
3602
+ break;
3603
+ case RKISP_VICAP_CMD_MODE:
3604
+ ret = rkisp_set_work_mode_by_vicap(isp_dev, arg);
35463605 break;
35473606 default:
35483607 ret = -ENOIOCTLCMD;
....@@ -3646,6 +3705,9 @@
36463705 case RKISP_CMD_MULTI_DEV_FORCE_ENUM:
36473706 ret = rkisp_ioctl(sd, cmd, NULL);
36483707 break;
3708
+ case RKISP_VICAP_CMD_SET_STREAM:
3709
+ ret = rkisp_ioctl(sd, cmd, NULL);
3710
+ break;
36493711 default:
36503712 ret = -ENOIOCTLCMD;
36513713 }
....@@ -3699,7 +3761,7 @@
36993761 struct ispsd_in_fmt *in_fmt = &isp_sd->in_fmt;
37003762 struct ispsd_out_fmt *out_fmt = &isp_sd->out_fmt;
37013763
3702
- *in_fmt = rkisp_isp_input_formats[0];
3764
+ *in_fmt = rkisp_isp_input_formats[8];
37033765 in_frm->width = RKISP_DEFAULT_WIDTH;
37043766 in_frm->height = RKISP_DEFAULT_HEIGHT;
37053767 in_frm->code = in_fmt->mbus_code;
....@@ -3765,6 +3827,7 @@
37653827 atomic_set(&isp_sdev->frm_sync_seq, 0);
37663828 rkisp_monitor_init(isp_dev);
37673829 INIT_WORK(&isp_dev->rdbk_work, rkisp_rdbk_work);
3830
+ init_completion(&isp_dev->pm_cmpl);
37683831 return 0;
37693832 err_cleanup_media_entity:
37703833 media_entity_cleanup(&sd->entity);
....@@ -3804,9 +3867,54 @@
38043867 (cond) ? 0 : -ETIMEDOUT; \
38053868 })
38063869
3870
+void rkisp_save_tb_info(struct rkisp_device *isp_dev)
3871
+{
3872
+ struct rkisp_isp_params_vdev *params_vdev = &isp_dev->params_vdev;
3873
+ void *resmem_va = phys_to_virt(isp_dev->resmem_pa);
3874
+ struct rkisp_thunderboot_resmem_head *head = resmem_va;
3875
+ int size = 0, offset = 0;
3876
+ void *param = NULL;
3877
+
3878
+ switch (isp_dev->isp_ver) {
3879
+ case ISP_V32:
3880
+ size = sizeof(struct rkisp32_thunderboot_resmem_head);
3881
+ offset = size * isp_dev->dev_id;
3882
+ break;
3883
+ default:
3884
+ break;
3885
+ }
3886
+
3887
+ if (size && size < isp_dev->resmem_size) {
3888
+ dma_sync_single_for_cpu(isp_dev->dev, isp_dev->resmem_addr + offset,
3889
+ size, DMA_FROM_DEVICE);
3890
+ if (isp_dev->is_rtt_first)
3891
+ params_vdev->is_first_cfg = true;
3892
+ if (isp_dev->isp_ver == ISP_V32) {
3893
+ struct rkisp32_thunderboot_resmem_head *tmp = resmem_va + offset;
3894
+
3895
+ param = &tmp->cfg;
3896
+ head = &tmp->head;
3897
+ v4l2_info(&isp_dev->v4l2_dev,
3898
+ "tb param module en:0x%llx upd:0x%llx cfg upd:0x%llx\n",
3899
+ tmp->cfg.module_en_update,
3900
+ tmp->cfg.module_ens,
3901
+ tmp->cfg.module_cfg_update);
3902
+ }
3903
+ if (param && (isp_dev->isp_state & ISP_STOP))
3904
+ params_vdev->ops->save_first_param(params_vdev, param);
3905
+ } else if (size > isp_dev->resmem_size) {
3906
+ v4l2_err(&isp_dev->v4l2_dev,
3907
+ "resmem size:%zu no enough for head:%d\n",
3908
+ isp_dev->resmem_size, size);
3909
+ head->complete = RKISP_TB_NG;
3910
+ }
3911
+ memcpy(&isp_dev->tb_head, head, sizeof(*head));
3912
+}
3913
+
38073914 #ifdef CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP
38083915 void rkisp_chk_tb_over(struct rkisp_device *isp_dev)
38093916 {
3917
+ struct rkisp_isp_params_vdev *params_vdev = &isp_dev->params_vdev;
38103918 struct rkisp_hw_dev *hw = isp_dev->hw_dev;
38113919 struct rkisp_thunderboot_resmem_head *head;
38123920 enum rkisp_tb_state tb_state;
....@@ -3815,19 +3923,20 @@
38153923 if (!isp_dev->is_thunderboot)
38163924 return;
38173925
3926
+ if (isp_dev->isp_ver == ISP_V32 && params_vdev->is_first_cfg)
3927
+ goto end;
3928
+
38183929 resmem_va = phys_to_virt(isp_dev->resmem_pa);
38193930 head = (struct rkisp_thunderboot_resmem_head *)resmem_va;
38203931 dma_sync_single_for_cpu(isp_dev->dev, isp_dev->resmem_addr,
38213932 sizeof(struct rkisp_thunderboot_resmem_head),
38223933 DMA_FROM_DEVICE);
38233934
3824
- shm_head_poll_timeout(isp_dev, !!head->complete, 5000, 200 * USEC_PER_MSEC);
3935
+ shm_head_poll_timeout(isp_dev, !!head->complete, 5000, 400 * USEC_PER_MSEC);
38253936 if (head->complete != RKISP_TB_OK) {
38263937 v4l2_err(&isp_dev->v4l2_dev, "wait thunderboot over timeout\n");
38273938 } else {
3828
- struct rkisp_isp_params_vdev *params_vdev = &isp_dev->params_vdev;
3829
- void *param = NULL;
3830
- u32 size = 0, offset = 0, timeout = 50;
3939
+ int i, timeout = 50;
38313940
38323941 /* wait for all isp dev to register */
38333942 if (head->camera_num > 1) {
....@@ -3837,48 +3946,23 @@
38373946 break;
38383947 usleep_range(200, 210);
38393948 }
3840
- }
3841
-
3842
- switch (isp_dev->isp_ver) {
3843
- case ISP_V32:
3844
- size = sizeof(struct rkisp32_thunderboot_resmem_head);
3845
- offset = size * isp_dev->dev_id;
3846
- break;
3847
- default:
3848
- break;
3849
- }
3850
-
3851
- if (size && size < isp_dev->resmem_size) {
3852
- dma_sync_single_for_cpu(isp_dev->dev, isp_dev->resmem_addr + offset,
3853
- size, DMA_FROM_DEVICE);
3854
- params_vdev->is_first_cfg = true;
3855
- if (isp_dev->isp_ver == ISP_V32) {
3856
- struct rkisp32_thunderboot_resmem_head *tmp = resmem_va + offset;
3857
-
3858
- param = &tmp->cfg;
3859
- head = &tmp->head;
3860
- v4l2_info(&isp_dev->v4l2_dev,
3861
- "tb param module en:0x%llx upd:0x%llx cfg upd:0x%llx\n",
3862
- tmp->cfg.module_en_update,
3863
- tmp->cfg.module_ens,
3864
- tmp->cfg.module_cfg_update);
3949
+ if (head->camera_num > hw->dev_num) {
3950
+ v4l2_err(&isp_dev->v4l2_dev,
3951
+ "thunderboot invalid camera num:%d, dev num:%d\n",
3952
+ head->camera_num, hw->dev_num);
3953
+ goto end;
38653954 }
3866
- if (param)
3867
- params_vdev->ops->save_first_param(params_vdev, param);
3868
- } else if (size > isp_dev->resmem_size) {
3869
- v4l2_err(&isp_dev->v4l2_dev,
3870
- "resmem size:%zu no enough for head:%d\n",
3871
- isp_dev->resmem_size, size);
3872
- head->complete = RKISP_TB_NG;
38733955 }
3956
+ for (i = 0; i < head->camera_num; i++)
3957
+ rkisp_save_tb_info(hw->isp[i]);
38743958 }
3875
- memcpy(&isp_dev->tb_head, head, sizeof(*head));
3959
+end:
3960
+ head = &isp_dev->tb_head;
38763961 v4l2_info(&isp_dev->v4l2_dev,
3877
- "thunderboot info: %d, %d, %d, %d, %d, %d | %d %d\n",
3962
+ "tb info en:%d comp:%d cnt:%d w:%d h:%d cam:%d idx:%d\n",
38783963 head->enable,
38793964 head->complete,
38803965 head->frm_total,
3881
- head->hdr_mode,
38823966 head->width,
38833967 head->height,
38843968 head->camera_num,
....@@ -4005,7 +4089,7 @@
40054089 struct rkisp_device *dev)
40064090 {
40074091 struct rkisp_hw_dev *hw = dev->hw_dev;
4008
- void __iomem *base = !hw->is_unite ?
4092
+ void __iomem *base = hw->unite != ISP_UNITE_TWO ?
40094093 hw->base_addr : hw->base_next_addr;
40104094 unsigned int isp_mis_tmp = 0;
40114095 unsigned int isp_err = 0;
....@@ -4026,7 +4110,7 @@
40264110 if (isp3a_mis & ISP2X_3A_RAWAE_BIG && dev->params_vdev.rdbk_times > 0)
40274111 writel(BIT(31), base + RAWAE_BIG1_BASE + RAWAE_BIG_CTRL);
40284112
4029
- if (hw->is_unite) {
4113
+ if (hw->unite == ISP_UNITE_TWO) {
40304114 u32 val = rkisp_read(dev, ISP3X_ISP_RIS, true);
40314115
40324116 if (val) {
....@@ -4057,9 +4141,14 @@
40574141 }
40584142
40594143 if (IS_HDR_RDBK(dev->hdr.op_mode)) {
4060
- /* read 3d lut at isp readback */
4061
- if (!dev->hw_dev->is_single)
4062
- rkisp_write(dev, ISP_3DLUT_UPDATE, 0, true);
4144
+ /* disabled frame end to read 3dlut for multi sensor
4145
+ * 3dlut will update at isp readback
4146
+ */
4147
+ if (!dev->hw_dev->is_single) {
4148
+ writel(0, hw->base_addr + ISP_3DLUT_UPDATE);
4149
+ if (hw->unite == ISP_UNITE_TWO)
4150
+ writel(0, hw->base_next_addr + ISP_3DLUT_UPDATE);
4151
+ }
40634152 rkisp_stats_rdbk_enable(&dev->stats_vdev, true);
40644153 goto vs_skip;
40654154 }
....@@ -4087,7 +4176,7 @@
40874176 if (isp_mis & CIF_ISP_FRAME)
40884177 sof_event_later = true;
40894178 if (dev->vs_irq < 0 && !sof_event_later) {
4090
- dev->isp_sdev.frm_timestamp = ktime_get_ns();
4179
+ dev->isp_sdev.frm_timestamp = rkisp_time_get_ns(dev);
40914180 rkisp_isp_queue_event_sof(&dev->isp_sdev);
40924181 rkisp_stream_frame_start(dev, isp_mis);
40934182 }
....@@ -4155,7 +4244,7 @@
41554244 /* sampled input frame is complete */
41564245 if (isp_mis & CIF_ISP_FRAME_IN) {
41574246 dev->isp_sdev.dbg.interval =
4158
- ktime_get_ns() - dev->isp_sdev.dbg.timestamp;
4247
+ rkisp_time_get_ns(dev) - dev->isp_sdev.dbg.timestamp;
41594248 rkisp_set_state(&dev->isp_state, ISP_FRAME_IN);
41604249 writel(CIF_ISP_FRAME_IN, base + CIF_ISP_ICR);
41614250 isp_mis_tmp = readl(base + CIF_ISP_MIS);
....@@ -4169,7 +4258,7 @@
41694258 dev->rawaf_irq_cnt = 0;
41704259 if (!dev->is_pre_on || !IS_HDR_RDBK(dev->rd_mode))
41714260 dev->isp_sdev.dbg.interval =
4172
- ktime_get_ns() - dev->isp_sdev.dbg.timestamp;
4261
+ rkisp_time_get_ns(dev) - dev->isp_sdev.dbg.timestamp;
41734262 /* Clear Frame In (ISP) */
41744263 rkisp_set_state(&dev->isp_state, ISP_FRAME_END);
41754264 writel(CIF_ISP_FRAME, base + CIF_ISP_ICR);
....@@ -4189,7 +4278,7 @@
41894278 u64 tmp = dev->isp_sdev.dbg.interval +
41904279 dev->isp_sdev.dbg.timestamp;
41914280
4192
- dev->isp_sdev.dbg.timestamp = ktime_get_ns();
4281
+ dev->isp_sdev.dbg.timestamp = rkisp_time_get_ns(dev);
41934282 /* v-blank: frame(N)start - frame(N-1)end */
41944283 dev->isp_sdev.dbg.delay = dev->isp_sdev.dbg.timestamp - tmp;
41954284 }
....@@ -4241,7 +4330,7 @@
42414330
42424331 /* cur frame end and next frame start irq togeter */
42434332 if (dev->vs_irq < 0 && sof_event_later) {
4244
- dev->isp_sdev.frm_timestamp = ktime_get_ns();
4333
+ dev->isp_sdev.frm_timestamp = rkisp_time_get_ns(dev);
42454334 rkisp_isp_queue_event_sof(&dev->isp_sdev);
42464335 rkisp_stream_frame_start(dev, isp_mis);
42474336 }