hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/media/platform/rockchip/isp/isp_stats_v32.c
....@@ -428,6 +428,8 @@
428428 struct rkisp_device *dev = stats_vdev->dev;
429429 struct rkisp_buffer *buf;
430430 unsigned long flags;
431
+ u32 size = stats_vdev->vdev_fmt.fmt.meta.buffersize;
432
+ u32 val = 0;
431433
432434 spin_lock_irqsave(&stats_vdev->rd_lock, flags);
433435 if (!stats_vdev->nxt_buf && !list_empty(&stats_vdev->stat)) {
....@@ -439,18 +441,23 @@
439441 spin_unlock_irqrestore(&stats_vdev->rd_lock, flags);
440442
441443 if (stats_vdev->nxt_buf) {
442
- rkisp_write(dev, ISP3X_MI_3A_WR_BASE, stats_vdev->nxt_buf->buff_addr[0], false);
444
+ val = stats_vdev->nxt_buf->buff_addr[0];
443445 v4l2_dbg(2, rkisp_debug, &dev->v4l2_dev,
444446 "%s BASE:0x%x SHD:0x%x\n",
445
- __func__, stats_vdev->nxt_buf->buff_addr[0],
447
+ __func__, val,
446448 isp3_stats_read(stats_vdev, ISP3X_MI_3A_WR_BASE));
447449 if (!dev->hw_dev->is_single) {
448450 stats_vdev->cur_buf = stats_vdev->nxt_buf;
449451 stats_vdev->nxt_buf = NULL;
450452 }
451453 } else if (stats_vdev->stats_buf[0].mem_priv) {
452
- rkisp_write(dev, ISP3X_MI_3A_WR_BASE,
453
- stats_vdev->stats_buf[0].dma_addr, false);
454
+ val = stats_vdev->stats_buf[0].dma_addr;
455
+ }
456
+
457
+ if (val) {
458
+ rkisp_write(dev, ISP3X_MI_3A_WR_BASE, val, false);
459
+ if (dev->hw_dev->unite)
460
+ rkisp_next_write(dev, ISP3X_MI_3A_WR_BASE, val + size / 2, false);
454461 }
455462 }
456463
....@@ -533,14 +540,15 @@
533540 rkisp_stats_send_meas(struct rkisp_isp_stats_vdev *stats_vdev,
534541 struct rkisp_isp_readout_work *meas_work)
535542 {
536
- unsigned int cur_frame_id = -1;
543
+ struct rkisp_device *dev = stats_vdev->dev;
544
+ struct rkisp_hw_dev *hw = dev->hw_dev;
545
+ struct rkisp_isp_params_vdev *params_vdev = &dev->params_vdev;
537546 struct rkisp_buffer *cur_buf = stats_vdev->cur_buf;
538547 struct rkisp32_isp_stat_buffer *cur_stat_buf = NULL;
539548 struct rkisp_stats_ops_v32 *ops =
540549 (struct rkisp_stats_ops_v32 *)stats_vdev->priv_ops;
541
- struct rkisp_isp_params_vdev *params_vdev = &stats_vdev->dev->params_vdev;
542
- u32 size = sizeof(struct rkisp32_isp_stat_buffer);
543
- int ret = 0;
550
+ u32 size = stats_vdev->vdev_fmt.fmt.meta.buffersize;
551
+ u32 cur_frame_id = meas_work->frame_id;
544552 bool is_dummy = false;
545553 unsigned long flags;
546554
....@@ -548,97 +556,107 @@
548556 if (!cur_buf && stats_vdev->stats_buf[0].mem_priv) {
549557 rkisp_finish_buffer(stats_vdev->dev, &stats_vdev->stats_buf[0]);
550558 cur_stat_buf = stats_vdev->stats_buf[0].vaddr;
551
- cur_stat_buf->frame_id = -1;
559
+ cur_stat_buf->frame_id = cur_frame_id;
560
+ cur_stat_buf->params_id = params_vdev->cur_frame_id;
552561 is_dummy = true;
553562 } else if (cur_buf) {
554563 cur_stat_buf = cur_buf->vaddr[0];
564
+ cur_stat_buf->frame_id = cur_frame_id;
565
+ cur_stat_buf->params_id = params_vdev->cur_frame_id;
555566 }
556
- /* config buf for next frame */
557
- stats_vdev->cur_buf = NULL;
558
- if (stats_vdev->nxt_buf) {
559
- stats_vdev->cur_buf = stats_vdev->nxt_buf;
560
- stats_vdev->nxt_buf = NULL;
561
- }
562
- rkisp_stats_update_buf(stats_vdev);
563567
564
- cur_frame_id = meas_work->frame_id;
568
+ /* buffer done when frame of right handle */
569
+ if (hw->unite == ISP_UNITE_ONE) {
570
+ if (dev->unite_index == ISP_UNITE_LEFT) {
571
+ cur_buf = NULL;
572
+ is_dummy = false;
573
+ } else if (cur_stat_buf) {
574
+ cur_stat_buf = (void *)cur_stat_buf + size / 2;
575
+ cur_stat_buf->frame_id = cur_frame_id;
576
+ cur_stat_buf->params_id = params_vdev->cur_frame_id;
577
+ }
578
+ }
579
+
580
+ if (hw->unite != ISP_UNITE_ONE || dev->unite_index == ISP_UNITE_RIGHT) {
581
+ /* config buf for next frame */
582
+ stats_vdev->cur_buf = NULL;
583
+ if (stats_vdev->nxt_buf) {
584
+ stats_vdev->cur_buf = stats_vdev->nxt_buf;
585
+ stats_vdev->nxt_buf = NULL;
586
+ }
587
+ rkisp_stats_update_buf(stats_vdev);
588
+ }
565589 } else {
566590 cur_buf = NULL;
567591 }
568592
569593 if (meas_work->isp3a_ris & ISP3X_3A_RAWAWB)
570
- ret |= ops->get_rawawb_meas(stats_vdev, cur_stat_buf);
594
+ ops->get_rawawb_meas(stats_vdev, cur_stat_buf);
571595
572596 if (meas_work->isp3a_ris & ISP3X_3A_RAWAF ||
573597 stats_vdev->af_meas_done_next)
574
- ret |= ops->get_rawaf_meas(stats_vdev, cur_stat_buf);
598
+ ops->get_rawaf_meas(stats_vdev, cur_stat_buf);
575599
576600 if (meas_work->isp3a_ris & ISP3X_3A_RAWAE_BIG ||
577601 stats_vdev->ae_meas_done_next)
578
- ret |= ops->get_rawae3_meas(stats_vdev, cur_stat_buf);
602
+ ops->get_rawae3_meas(stats_vdev, cur_stat_buf);
579603
580604 if (meas_work->isp3a_ris & ISP3X_3A_RAWHIST_BIG)
581
- ret |= ops->get_rawhst3_meas(stats_vdev, cur_stat_buf);
605
+ ops->get_rawhst3_meas(stats_vdev, cur_stat_buf);
582606
583607 if (meas_work->isp3a_ris & ISP3X_3A_RAWAE_CH0)
584
- ret |= ops->get_rawae0_meas(stats_vdev, cur_stat_buf);
608
+ ops->get_rawae0_meas(stats_vdev, cur_stat_buf);
585609
586610 if (meas_work->isp3a_ris & ISP3X_3A_RAWAE_CH1)
587
- ret |= ops->get_rawae1_meas(stats_vdev, cur_stat_buf);
611
+ ops->get_rawae1_meas(stats_vdev, cur_stat_buf);
588612
589613 if (meas_work->isp3a_ris & ISP3X_3A_RAWAE_CH2)
590
- ret |= ops->get_rawae2_meas(stats_vdev, cur_stat_buf);
614
+ ops->get_rawae2_meas(stats_vdev, cur_stat_buf);
591615
592616 if (meas_work->isp3a_ris & ISP3X_3A_RAWHIST_CH0)
593
- ret |= ops->get_rawhst0_meas(stats_vdev, cur_stat_buf);
617
+ ops->get_rawhst0_meas(stats_vdev, cur_stat_buf);
594618
595619 if (meas_work->isp3a_ris & ISP3X_3A_RAWHIST_CH1)
596
- ret |= ops->get_rawhst1_meas(stats_vdev, cur_stat_buf);
620
+ ops->get_rawhst1_meas(stats_vdev, cur_stat_buf);
597621
598622 if (meas_work->isp3a_ris & ISP3X_3A_RAWHIST_CH2)
599
- ret |= ops->get_rawhst2_meas(stats_vdev, cur_stat_buf);
623
+ ops->get_rawhst2_meas(stats_vdev, cur_stat_buf);
600624
601625 if (meas_work->isp_ris & ISP3X_FRAME) {
602
- ret |= ops->get_bls_stats(stats_vdev, cur_stat_buf);
603
- ret |= ops->get_dhaz_stats(stats_vdev, cur_stat_buf);
604
- ret |= ops->get_vsm_stats(stats_vdev, cur_stat_buf);
626
+ ops->get_bls_stats(stats_vdev, cur_stat_buf);
627
+ ops->get_dhaz_stats(stats_vdev, cur_stat_buf);
628
+ ops->get_vsm_stats(stats_vdev, cur_stat_buf);
605629 }
606630
607
- if (ret || (cur_stat_buf && !cur_stat_buf->meas_type)) {
631
+ if (is_dummy) {
632
+ spin_lock_irqsave(&stats_vdev->rd_lock, flags);
633
+ if (!list_empty(&stats_vdev->stat)) {
634
+ cur_buf = list_first_entry(&stats_vdev->stat, struct rkisp_buffer, queue);
635
+ list_del(&cur_buf->queue);
636
+ }
637
+ spin_unlock_irqrestore(&stats_vdev->rd_lock, flags);
608638 if (cur_buf) {
609
- spin_lock_irqsave(&stats_vdev->rd_lock, flags);
610
- list_add_tail(&cur_buf->queue, &stats_vdev->stat);
611
- spin_unlock_irqrestore(&stats_vdev->rd_lock, flags);
612
- }
613
- } else {
614
- if (is_dummy) {
615
- spin_lock_irqsave(&stats_vdev->rd_lock, flags);
616
- if (!list_empty(&stats_vdev->stat)) {
617
- cur_buf = list_first_entry(&stats_vdev->stat, struct rkisp_buffer, queue);
618
- list_del(&cur_buf->queue);
619
- } else {
620
- cur_stat_buf->frame_id = cur_frame_id;
621
- cur_stat_buf->params_id = params_vdev->cur_frame_id;
622
- }
623
- spin_unlock_irqrestore(&stats_vdev->rd_lock, flags);
624
- if (cur_buf) {
625
- memcpy(cur_buf->vaddr[0], cur_stat_buf, size);
626
- cur_stat_buf = cur_buf->vaddr[0];
627
- }
628
- }
629
- if (cur_buf && cur_stat_buf) {
630
- cur_stat_buf->frame_id = cur_frame_id;
631
- cur_stat_buf->params_id = params_vdev->cur_frame_id;
632
- cur_stat_buf->params.info2ddr.buf_fd = -1;
633
- cur_stat_buf->params.info2ddr.owner = 0;
634
- rkisp_stats_info2ddr(stats_vdev, cur_stat_buf);
635
-
636
- vb2_set_plane_payload(&cur_buf->vb.vb2_buf, 0, size);
637
- cur_buf->vb.sequence = cur_frame_id;
638
- cur_buf->vb.vb2_buf.timestamp = meas_work->timestamp;
639
- vb2_buffer_done(&cur_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
639
+ memcpy(cur_buf->vaddr[0], stats_vdev->stats_buf[0].vaddr, size);
640
+ cur_stat_buf = cur_buf->vaddr[0];
640641 }
641642 }
643
+ if (cur_buf && cur_stat_buf) {
644
+ cur_stat_buf->frame_id = cur_frame_id;
645
+ cur_stat_buf->params_id = params_vdev->cur_frame_id;
646
+ cur_stat_buf->params.info2ddr.buf_fd = -1;
647
+ cur_stat_buf->params.info2ddr.owner = 0;
648
+ rkisp_stats_info2ddr(stats_vdev, cur_stat_buf);
649
+
650
+ vb2_set_plane_payload(&cur_buf->vb.vb2_buf, 0, size);
651
+ cur_buf->vb.sequence = cur_frame_id;
652
+ cur_buf->vb.vb2_buf.timestamp = meas_work->timestamp;
653
+ vb2_buffer_done(&cur_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
654
+ }
655
+ v4l2_dbg(4, rkisp_debug, &dev->v4l2_dev,
656
+ "%s id:%d seq:%d params_id:%d ris:0x%x buf:%p meas_type:0x%x\n",
657
+ __func__, dev->unite_index,
658
+ cur_frame_id, params_vdev->cur_frame_id, meas_work->isp3a_ris,
659
+ cur_buf, !cur_stat_buf ? 0 : cur_stat_buf->meas_type);
642660 }
643661
644662 static int
....@@ -890,12 +908,12 @@
890908 rkisp_stats_send_meas_lite(struct rkisp_isp_stats_vdev *stats_vdev,
891909 struct rkisp_isp_readout_work *meas_work)
892910 {
893
- struct rkisp_isp_params_vdev *params_vdev = &stats_vdev->dev->params_vdev;
911
+ struct rkisp_device *dev = stats_vdev->dev;
912
+ struct rkisp_isp_params_vdev *params_vdev = &dev->params_vdev;
894913 unsigned int cur_frame_id = meas_work->frame_id;
895914 struct rkisp_buffer *cur_buf = NULL;
896915 struct rkisp32_lite_stat_buffer *cur_stat_buf = NULL;
897916 u32 size = sizeof(struct rkisp32_lite_stat_buffer);
898
- int ret = 0;
899917
900918 spin_lock(&stats_vdev->rd_lock);
901919 if (!list_empty(&stats_vdev->stat)) {
....@@ -913,45 +931,42 @@
913931 }
914932
915933 if (meas_work->isp3a_ris & ISP3X_3A_RAWAWB)
916
- ret |= rkisp_stats_get_rawawb_meas_lite(stats_vdev, cur_stat_buf);
934
+ rkisp_stats_get_rawawb_meas_lite(stats_vdev, cur_stat_buf);
917935
918936 if (meas_work->isp3a_ris & ISP3X_3A_RAWAF ||
919937 stats_vdev->af_meas_done_next)
920
- ret |= rkisp_stats_get_rawaf_meas_lite(stats_vdev, cur_stat_buf);
938
+ rkisp_stats_get_rawaf_meas_lite(stats_vdev, cur_stat_buf);
921939
922940 if (meas_work->isp3a_ris & ISP3X_3A_RAWAE_BIG ||
923941 stats_vdev->ae_meas_done_next)
924
- ret |= rkisp_stats_get_rawae3_meas_lite(stats_vdev, cur_stat_buf);
942
+ rkisp_stats_get_rawae3_meas_lite(stats_vdev, cur_stat_buf);
925943
926944 if (meas_work->isp3a_ris & ISP3X_3A_RAWHIST_BIG)
927
- ret |= rkisp_stats_get_rawhst3_meas_lite(stats_vdev, cur_stat_buf);
945
+ rkisp_stats_get_rawhst3_meas_lite(stats_vdev, cur_stat_buf);
928946
929947 if (meas_work->isp3a_ris & ISP3X_3A_RAWAE_CH0)
930
- ret |= rkisp_stats_get_rawaelite_meas_lite(stats_vdev, cur_stat_buf);
948
+ rkisp_stats_get_rawaelite_meas_lite(stats_vdev, cur_stat_buf);
931949
932950 if (meas_work->isp3a_ris & ISP3X_3A_RAWHIST_CH0)
933
- ret |= rkisp_stats_get_rawhstlite_meas_lite(stats_vdev, cur_stat_buf);
951
+ rkisp_stats_get_rawhstlite_meas_lite(stats_vdev, cur_stat_buf);
934952
935953 if (meas_work->isp_ris & ISP3X_FRAME) {
936
- ret |= rkisp_stats_get_bls_stats(stats_vdev, cur_stat_buf);
937
- ret |= rkisp_stats_get_dhaz_stats(stats_vdev, cur_stat_buf);
954
+ rkisp_stats_get_bls_stats(stats_vdev, cur_stat_buf);
955
+ rkisp_stats_get_dhaz_stats(stats_vdev, cur_stat_buf);
938956 }
939957
940958 if (cur_buf) {
941
- if (ret || !cur_stat_buf->meas_type) {
942
- unsigned long flags;
943
-
944
- spin_lock_irqsave(&stats_vdev->rd_lock, flags);
945
- list_add_tail(&cur_buf->queue, &stats_vdev->stat);
946
- spin_unlock_irqrestore(&stats_vdev->rd_lock, flags);
947
- } else {
948
- rkisp_stats_info2ddr(stats_vdev, cur_stat_buf);
949
- vb2_set_plane_payload(&cur_buf->vb.vb2_buf, 0, size);
950
- cur_buf->vb.sequence = cur_frame_id;
951
- cur_buf->vb.vb2_buf.timestamp = meas_work->timestamp;
952
- vb2_buffer_done(&cur_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
953
- }
959
+ rkisp_stats_info2ddr(stats_vdev, cur_stat_buf);
960
+ vb2_set_plane_payload(&cur_buf->vb.vb2_buf, 0, size);
961
+ cur_buf->vb.sequence = cur_frame_id;
962
+ cur_buf->vb.vb2_buf.timestamp = meas_work->timestamp;
963
+ vb2_buffer_done(&cur_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
954964 }
965
+ v4l2_dbg(4, rkisp_debug, &dev->v4l2_dev,
966
+ "%s seq:%d params_id:%d ris:0x%x buf:%p meas_type:0x%x\n",
967
+ __func__,
968
+ cur_frame_id, params_vdev->cur_frame_id, meas_work->isp_ris,
969
+ cur_buf, !cur_stat_buf ? 0 : cur_stat_buf->meas_type);
955970 }
956971
957972 static void
....@@ -1048,6 +1063,7 @@
10481063 {
10491064 struct rkisp_device *dev = stats_vdev->dev;
10501065 u32 size = stats_vdev->vdev_fmt.fmt.meta.buffersize;
1066
+ u32 div = dev->hw_dev->unite ? 2 : 1;
10511067
10521068 if (dev->isp_sdev.in_fmt.fmt_type == FMT_YUV)
10531069 return;
....@@ -1059,8 +1075,8 @@
10591075 else
10601076 memset(stats_vdev->stats_buf[0].vaddr, 0, size);
10611077 rkisp_stats_update_buf(stats_vdev);
1062
- rkisp_write(dev, ISP3X_MI_DBR_WR_SIZE, size, false);
1063
- rkisp_set_bits(dev, ISP3X_SWS_CFG, 0, ISP3X_3A_DDR_WRITE_EN, false);
1078
+ rkisp_unite_write(dev, ISP3X_MI_DBR_WR_SIZE, size / div, false);
1079
+ rkisp_unite_set_bits(dev, ISP3X_SWS_CFG, 0, ISP3X_3A_DDR_WRITE_EN, false);
10641080 if (stats_vdev->nxt_buf) {
10651081 stats_vdev->cur_buf = stats_vdev->nxt_buf;
10661082 stats_vdev->nxt_buf = NULL;
....@@ -1080,6 +1096,7 @@
10801096
10811097 void rkisp_init_stats_vdev_v32(struct rkisp_isp_stats_vdev *stats_vdev)
10821098 {
1099
+ int mult = stats_vdev->dev->hw_dev->unite ? 2 : 1;
10831100 u32 size;
10841101
10851102 stats_vdev->vdev_fmt.fmt.meta.dataformat =
....@@ -1087,13 +1104,13 @@
10871104 if (stats_vdev->dev->isp_ver == ISP_V32) {
10881105 stats_vdev->priv_ops = &stats_ddr_ops_v32;
10891106 stats_vdev->rd_stats_from_ddr = true;
1090
- size = sizeof(struct rkisp32_isp_stat_buffer);
1107
+ size = ALIGN(sizeof(struct rkisp32_isp_stat_buffer), 16);
10911108 } else {
10921109 stats_vdev->priv_ops = NULL;
10931110 stats_vdev->rd_stats_from_ddr = false;
10941111 size = sizeof(struct rkisp32_lite_stat_buffer);
10951112 }
1096
- stats_vdev->vdev_fmt.fmt.meta.buffersize = size;
1113
+ stats_vdev->vdev_fmt.fmt.meta.buffersize = size * mult;
10971114 stats_vdev->ops = &rkisp_isp_stats_ops_tbl;
10981115 }
10991116