.. | .. |
---|
283 | 283 | struct rkcif_device *cif_dev = priv->cif_dev; |
---|
284 | 284 | |
---|
285 | 285 | if (priv->hdr_cfg.hdr_mode == HDR_X2) { |
---|
286 | | - rkcif_free_rx_buf(&cif_dev->stream[0], priv->buf_num); |
---|
287 | | - rkcif_free_rx_buf(&cif_dev->stream[1], priv->buf_num); |
---|
| 286 | + rkcif_free_rx_buf(&cif_dev->stream[0], cif_dev->stream[0].rx_buf_num); |
---|
| 287 | + rkcif_free_rx_buf(&cif_dev->stream[1], cif_dev->stream[1].rx_buf_num); |
---|
288 | 288 | } else if (priv->hdr_cfg.hdr_mode == HDR_X3) { |
---|
289 | | - rkcif_free_rx_buf(&cif_dev->stream[0], priv->buf_num); |
---|
290 | | - rkcif_free_rx_buf(&cif_dev->stream[1], priv->buf_num); |
---|
291 | | - rkcif_free_rx_buf(&cif_dev->stream[2], priv->buf_num); |
---|
| 289 | + rkcif_free_rx_buf(&cif_dev->stream[0], cif_dev->stream[0].rx_buf_num); |
---|
| 290 | + rkcif_free_rx_buf(&cif_dev->stream[1], cif_dev->stream[1].rx_buf_num); |
---|
| 291 | + rkcif_free_rx_buf(&cif_dev->stream[2], cif_dev->stream[2].rx_buf_num); |
---|
292 | 292 | } else { |
---|
293 | | - rkcif_free_rx_buf(&cif_dev->stream[0], priv->buf_num); |
---|
| 293 | + rkcif_free_rx_buf(&cif_dev->stream[0], cif_dev->stream[0].rx_buf_num); |
---|
294 | 294 | } |
---|
295 | 295 | if (cif_dev->is_thunderboot) { |
---|
296 | 296 | cif_dev->wait_line_cache = 0; |
---|
.. | .. |
---|
327 | 327 | __func__, mode->rdbk_mode, mode->name, priv->toisp_inf.link_mode); |
---|
328 | 328 | } |
---|
329 | 329 | |
---|
| 330 | +static void sditf_channel_disable(struct sditf_priv *priv, int user); |
---|
330 | 331 | static long sditf_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) |
---|
331 | 332 | { |
---|
332 | 333 | struct sditf_priv *priv = to_sditf_priv(sd); |
---|
.. | .. |
---|
336 | 337 | struct v4l2_subdev *sensor_sd; |
---|
337 | 338 | int *pbuf_num = NULL; |
---|
338 | 339 | int ret = 0; |
---|
| 340 | + int *on = NULL; |
---|
339 | 341 | |
---|
340 | 342 | switch (cmd) { |
---|
341 | 343 | case RKISP_VICAP_CMD_MODE: |
---|
342 | 344 | mode = (struct rkisp_vicap_mode *)arg; |
---|
| 345 | + mutex_lock(&cif_dev->stream_lock); |
---|
343 | 346 | memcpy(&priv->mode, mode, sizeof(*mode)); |
---|
| 347 | + mutex_unlock(&cif_dev->stream_lock); |
---|
344 | 348 | sditf_reinit_mode(priv, &priv->mode); |
---|
345 | 349 | if (priv->is_combine_mode) |
---|
346 | 350 | mode->input.merge_num = cif_dev->sditf_cnt; |
---|
.. | .. |
---|
363 | 367 | return v4l2_subdev_call(sensor_sd, core, ioctl, cmd, arg); |
---|
364 | 368 | } |
---|
365 | 369 | break; |
---|
| 370 | + case RKISP_VICAP_CMD_QUICK_STREAM: |
---|
| 371 | + on = (int *)arg; |
---|
| 372 | + if (*on) { |
---|
| 373 | + rkcif_stream_resume(cif_dev, RKCIF_RESUME_ISP); |
---|
| 374 | + } else { |
---|
| 375 | + if (priv->toisp_inf.link_mode == TOISP0) { |
---|
| 376 | + sditf_channel_disable(priv, 0); |
---|
| 377 | + } else if (priv->toisp_inf.link_mode == TOISP1) { |
---|
| 378 | + sditf_channel_disable(priv, 1); |
---|
| 379 | + } else if (priv->toisp_inf.link_mode == TOISP_UNITE) { |
---|
| 380 | + sditf_channel_disable(priv, 0); |
---|
| 381 | + sditf_channel_disable(priv, 1); |
---|
| 382 | + } |
---|
| 383 | + rkcif_stream_suspend(cif_dev, RKCIF_RESUME_ISP); |
---|
| 384 | + } |
---|
| 385 | + break; |
---|
| 386 | + case RKISP_VICAP_CMD_SET_RESET: |
---|
| 387 | + if (priv->mode.rdbk_mode == RKISP_VICAP_ONLINE) { |
---|
| 388 | + cif_dev->is_toisp_reset = true; |
---|
| 389 | + return 0; |
---|
| 390 | + } |
---|
| 391 | + break; |
---|
366 | 392 | default: |
---|
367 | 393 | break; |
---|
368 | 394 | } |
---|
.. | .. |
---|
382 | 408 | struct rkmodule_hdr_cfg *hdr_cfg; |
---|
383 | 409 | int buf_num; |
---|
384 | 410 | int ret = 0; |
---|
| 411 | + int on; |
---|
385 | 412 | |
---|
386 | 413 | switch (cmd) { |
---|
387 | 414 | case RKISP_VICAP_CMD_MODE: |
---|
.. | .. |
---|
413 | 440 | return -EFAULT; |
---|
414 | 441 | } |
---|
415 | 442 | ret = sditf_ioctl(sd, cmd, hdr_cfg); |
---|
| 443 | + return ret; |
---|
| 444 | + case RKISP_VICAP_CMD_QUICK_STREAM: |
---|
| 445 | + if (copy_from_user(&on, up, sizeof(int))) |
---|
| 446 | + return -EFAULT; |
---|
| 447 | + ret = sditf_ioctl(sd, cmd, &on); |
---|
| 448 | + return ret; |
---|
| 449 | + case RKISP_VICAP_CMD_SET_RESET: |
---|
| 450 | + ret = sditf_ioctl(sd, cmd, NULL); |
---|
416 | 451 | return ret; |
---|
417 | 452 | default: |
---|
418 | 453 | break; |
---|
.. | .. |
---|
464 | 499 | ch0 = 24;//dvp |
---|
465 | 500 | ctrl_val = (ch0 << 3) | 0x1; |
---|
466 | 501 | if (user == 0) |
---|
467 | | - int_en = CIF_TOISP0_FS(0); |
---|
| 502 | + int_en = CIF_TOISP0_FS(0) | CIF_TOISP0_FE(0); |
---|
468 | 503 | else |
---|
469 | | - int_en = CIF_TOISP1_FS(0); |
---|
| 504 | + int_en = CIF_TOISP1_FS(0) | CIF_TOISP1_FE(0); |
---|
470 | 505 | priv->toisp_inf.ch_info[0].is_valid = true; |
---|
471 | 506 | priv->toisp_inf.ch_info[0].id = ch0; |
---|
472 | 507 | } else if (priv->hdr_cfg.hdr_mode == HDR_X2) { |
---|
.. | .. |
---|
475 | 510 | ctrl_val = (ch0 << 3) | 0x1; |
---|
476 | 511 | ctrl_val |= (ch1 << 11) | 0x100; |
---|
477 | 512 | if (user == 0) |
---|
478 | | - int_en = CIF_TOISP0_FS(0) | CIF_TOISP0_FS(1); |
---|
| 513 | + int_en = CIF_TOISP0_FS(0) | CIF_TOISP0_FS(1) | |
---|
| 514 | + CIF_TOISP0_FE(0) | CIF_TOISP0_FE(1); |
---|
479 | 515 | else |
---|
480 | | - int_en = CIF_TOISP1_FS(0) | CIF_TOISP1_FS(1); |
---|
| 516 | + int_en = CIF_TOISP1_FS(0) | CIF_TOISP1_FS(1) | |
---|
| 517 | + CIF_TOISP1_FE(0) | CIF_TOISP1_FE(1); |
---|
481 | 518 | priv->toisp_inf.ch_info[0].is_valid = true; |
---|
482 | 519 | priv->toisp_inf.ch_info[0].id = ch0; |
---|
483 | 520 | priv->toisp_inf.ch_info[1].is_valid = true; |
---|
.. | .. |
---|
490 | 527 | ctrl_val |= (ch1 << 11) | 0x100; |
---|
491 | 528 | ctrl_val |= (ch2 << 19) | 0x10000; |
---|
492 | 529 | if (user == 0) |
---|
493 | | - int_en = CIF_TOISP0_FS(0) | CIF_TOISP0_FS(1) | CIF_TOISP0_FS(2); |
---|
| 530 | + int_en = CIF_TOISP0_FS(0) | CIF_TOISP0_FS(1) | CIF_TOISP0_FS(2) | |
---|
| 531 | + CIF_TOISP0_FE(0) | CIF_TOISP0_FE(1) | CIF_TOISP0_FE(2); |
---|
494 | 532 | else |
---|
495 | | - int_en = CIF_TOISP1_FS(0) | CIF_TOISP1_FS(1) | CIF_TOISP1_FS(2); |
---|
| 533 | + int_en = CIF_TOISP1_FS(0) | CIF_TOISP1_FS(1) | CIF_TOISP1_FS(2) | |
---|
| 534 | + CIF_TOISP1_FE(0) | CIF_TOISP1_FE(1) | CIF_TOISP1_FE(2); |
---|
496 | 535 | priv->toisp_inf.ch_info[0].is_valid = true; |
---|
497 | 536 | priv->toisp_inf.ch_info[0].id = ch0; |
---|
498 | 537 | priv->toisp_inf.ch_info[1].is_valid = true; |
---|
.. | .. |
---|
587 | 626 | sditf_channel_enable(priv, 0); |
---|
588 | 627 | sditf_channel_enable(priv, 1); |
---|
589 | 628 | } |
---|
590 | | - if (priv->hdr_cfg.hdr_mode == NO_HDR) { |
---|
591 | | - rkcif_free_rx_buf(&cif_dev->stream[0], priv->buf_num); |
---|
592 | | - cif_dev->stream[0].is_line_wake_up = false; |
---|
593 | | - } else if (priv->hdr_cfg.hdr_mode == HDR_X2) { |
---|
594 | | - rkcif_free_rx_buf(&cif_dev->stream[1], priv->buf_num); |
---|
595 | | - cif_dev->stream[0].is_line_wake_up = false; |
---|
596 | | - cif_dev->stream[1].is_line_wake_up = false; |
---|
597 | | - } else if (priv->hdr_cfg.hdr_mode == HDR_X3) { |
---|
598 | | - rkcif_free_rx_buf(&cif_dev->stream[2], priv->buf_num); |
---|
599 | | - cif_dev->stream[0].is_line_wake_up = false; |
---|
600 | | - cif_dev->stream[1].is_line_wake_up = false; |
---|
601 | | - cif_dev->stream[2].is_line_wake_up = false; |
---|
| 629 | + |
---|
| 630 | + if (cif_dev->is_thunderboot) { |
---|
| 631 | + if (priv->hdr_cfg.hdr_mode == NO_HDR) { |
---|
| 632 | + rkcif_free_rx_buf(&cif_dev->stream[0], cif_dev->stream[0].rx_buf_num); |
---|
| 633 | + cif_dev->stream[0].is_line_wake_up = false; |
---|
| 634 | + } else if (priv->hdr_cfg.hdr_mode == HDR_X2) { |
---|
| 635 | + rkcif_free_rx_buf(&cif_dev->stream[1], cif_dev->stream[1].rx_buf_num); |
---|
| 636 | + cif_dev->stream[0].is_line_wake_up = false; |
---|
| 637 | + cif_dev->stream[1].is_line_wake_up = false; |
---|
| 638 | + } else if (priv->hdr_cfg.hdr_mode == HDR_X3) { |
---|
| 639 | + rkcif_free_rx_buf(&cif_dev->stream[2], cif_dev->stream[2].rx_buf_num); |
---|
| 640 | + cif_dev->stream[0].is_line_wake_up = false; |
---|
| 641 | + cif_dev->stream[1].is_line_wake_up = false; |
---|
| 642 | + cif_dev->stream[2].is_line_wake_up = false; |
---|
| 643 | + } |
---|
| 644 | + cif_dev->wait_line_cache = 0; |
---|
| 645 | + cif_dev->wait_line = 0; |
---|
| 646 | + cif_dev->wait_line_bak = 0; |
---|
| 647 | + cif_dev->is_thunderboot = false; |
---|
602 | 648 | } |
---|
603 | | - cif_dev->wait_line_cache = 0; |
---|
604 | | - cif_dev->wait_line = 0; |
---|
605 | | - cif_dev->wait_line_bak = 0; |
---|
| 649 | +} |
---|
| 650 | + |
---|
| 651 | +void sditf_disable_immediately(struct sditf_priv *priv) |
---|
| 652 | +{ |
---|
| 653 | + struct rkcif_device *cif_dev = priv->cif_dev; |
---|
| 654 | + u32 ctrl_val = 0x10101; |
---|
| 655 | + |
---|
| 656 | + if (priv->toisp_inf.link_mode == TOISP0) { |
---|
| 657 | + rkcif_write_register_and(cif_dev, CIF_REG_TOISP0_CTRL, ~ctrl_val); |
---|
| 658 | + } else if (priv->toisp_inf.link_mode == TOISP1) { |
---|
| 659 | + rkcif_write_register_and(cif_dev, CIF_REG_TOISP1_CTRL, ~ctrl_val); |
---|
| 660 | + } else if (priv->toisp_inf.link_mode == TOISP_UNITE) { |
---|
| 661 | + rkcif_write_register_and(cif_dev, CIF_REG_TOISP0_CTRL, ~ctrl_val); |
---|
| 662 | + rkcif_write_register_and(cif_dev, CIF_REG_TOISP1_CTRL, ~ctrl_val); |
---|
| 663 | + } |
---|
606 | 664 | } |
---|
607 | 665 | |
---|
608 | 666 | static void sditf_check_capture_mode(struct rkcif_device *cif_dev) |
---|
.. | .. |
---|
627 | 685 | struct rkcif_device *cif_dev = priv->cif_dev; |
---|
628 | 686 | struct v4l2_subdev_format fmt; |
---|
629 | 687 | unsigned int mode = RKCIF_STREAM_MODE_TOISP; |
---|
630 | | - int ret = 0; |
---|
631 | 688 | |
---|
632 | 689 | sditf_check_capture_mode(cif_dev); |
---|
633 | 690 | sditf_get_set_fmt(&priv->sd, NULL, &fmt); |
---|
634 | 691 | if (priv->mode.rdbk_mode == RKISP_VICAP_ONLINE) { |
---|
635 | 692 | if (priv->toisp_inf.link_mode == TOISP0) { |
---|
636 | | - ret = sditf_channel_enable(priv, 0); |
---|
| 693 | + sditf_channel_enable(priv, 0); |
---|
637 | 694 | } else if (priv->toisp_inf.link_mode == TOISP1) { |
---|
638 | | - ret = sditf_channel_enable(priv, 1); |
---|
| 695 | + sditf_channel_enable(priv, 1); |
---|
639 | 696 | } else if (priv->toisp_inf.link_mode == TOISP_UNITE) { |
---|
640 | | - ret = sditf_channel_enable(priv, 0); |
---|
641 | | - ret |= sditf_channel_enable(priv, 1); |
---|
| 697 | + sditf_channel_enable(priv, 0); |
---|
| 698 | + sditf_channel_enable(priv, 1); |
---|
642 | 699 | } |
---|
643 | 700 | mode = RKCIF_STREAM_MODE_TOISP; |
---|
644 | 701 | } else if (priv->mode.rdbk_mode == RKISP_VICAP_RDBK_AUTO) { |
---|
645 | 702 | mode = RKCIF_STREAM_MODE_TOISP_RDBK; |
---|
646 | 703 | } |
---|
647 | | - if (ret) |
---|
648 | | - return ret; |
---|
649 | 704 | |
---|
650 | 705 | if (priv->hdr_cfg.hdr_mode == NO_HDR || |
---|
651 | 706 | priv->hdr_cfg.hdr_mode == HDR_COMPR) { |
---|
652 | | - ret = rkcif_do_start_stream(&cif_dev->stream[0], mode); |
---|
| 707 | + rkcif_do_start_stream(&cif_dev->stream[0], mode); |
---|
653 | 708 | } else if (priv->hdr_cfg.hdr_mode == HDR_X2) { |
---|
654 | | - ret = rkcif_do_start_stream(&cif_dev->stream[0], mode); |
---|
655 | | - ret |= rkcif_do_start_stream(&cif_dev->stream[1], mode); |
---|
| 709 | + rkcif_do_start_stream(&cif_dev->stream[0], mode); |
---|
| 710 | + rkcif_do_start_stream(&cif_dev->stream[1], mode); |
---|
656 | 711 | } else if (priv->hdr_cfg.hdr_mode == HDR_X3) { |
---|
657 | | - ret = rkcif_do_start_stream(&cif_dev->stream[0], mode); |
---|
658 | | - ret |= rkcif_do_start_stream(&cif_dev->stream[1], mode); |
---|
659 | | - ret |= rkcif_do_start_stream(&cif_dev->stream[2], mode); |
---|
| 712 | + rkcif_do_start_stream(&cif_dev->stream[0], mode); |
---|
| 713 | + rkcif_do_start_stream(&cif_dev->stream[1], mode); |
---|
| 714 | + rkcif_do_start_stream(&cif_dev->stream[2], mode); |
---|
660 | 715 | } |
---|
661 | 716 | INIT_LIST_HEAD(&priv->buf_free_list); |
---|
662 | | - return ret; |
---|
| 717 | + return 0; |
---|
663 | 718 | } |
---|
664 | 719 | |
---|
665 | 720 | static int sditf_stop_stream(struct sditf_priv *priv) |
---|
.. | .. |
---|
718 | 773 | } else { |
---|
719 | 774 | ret = sditf_stop_stream(priv); |
---|
720 | 775 | sditf_free_buf(priv); |
---|
| 776 | + priv->mode.rdbk_mode = RKISP_VICAP_RDBK_AIQ; |
---|
721 | 777 | } |
---|
722 | 778 | |
---|
723 | 779 | } |
---|
.. | .. |
---|
806 | 862 | return -EINVAL; |
---|
807 | 863 | |
---|
808 | 864 | rx_buf = to_cif_rx_buf(dbufs); |
---|
809 | | - v4l2_dbg(rkcif_debug, 3, &cif_dev->v4l2_dev, "buf back to vicap 0x%x\n", |
---|
| 865 | + v4l2_dbg(3, rkcif_debug, &cif_dev->v4l2_dev, "buf back to vicap 0x%x\n", |
---|
810 | 866 | (u32)rx_buf->dummy.dma_addr); |
---|
811 | 867 | spin_lock_irqsave(&stream->vbq_lock, flags); |
---|
812 | 868 | stream->last_rx_buf_idx = dbufs->sequence + 1; |
---|
.. | .. |
---|
814 | 870 | |
---|
815 | 871 | if (!list_empty(&stream->rx_buf_head) && |
---|
816 | 872 | cif_dev->is_thunderboot && |
---|
| 873 | + (!cif_dev->is_rtt_suspend) && |
---|
817 | 874 | (dbufs->type == BUF_SHORT || |
---|
818 | 875 | (dbufs->type != BUF_SHORT && (!dbufs->is_switch)))) { |
---|
819 | 876 | spin_lock_irqsave(&cif_dev->buffree_lock, buffree_flags); |
---|
.. | .. |
---|
827 | 884 | |
---|
828 | 885 | if (!is_free && (!dbufs->is_switch)) { |
---|
829 | 886 | list_add_tail(&rx_buf->list, &stream->rx_buf_head); |
---|
830 | | - rkcif_assign_check_buffer_update_toisp(stream); |
---|
| 887 | + if (cif_dev->resume_mode != RKISP_RTT_MODE_ONE_FRAME) { |
---|
| 888 | + rkcif_assign_check_buffer_update_toisp(stream); |
---|
| 889 | + if (!stream->dma_en) { |
---|
| 890 | + stream->to_en_dma = RKCIF_DMAEN_BY_ISP; |
---|
| 891 | + rkcif_enable_dma_capture(stream, true); |
---|
| 892 | + cif_dev->sensor_work.on = 1; |
---|
| 893 | + schedule_work(&cif_dev->sensor_work.work); |
---|
| 894 | + } |
---|
| 895 | + } |
---|
831 | 896 | if (cif_dev->rdbk_debug) { |
---|
832 | 897 | u32 offset = 0; |
---|
833 | 898 | |
---|
.. | .. |
---|
855 | 920 | } |
---|
856 | 921 | spin_unlock_irqrestore(&stream->vbq_lock, flags); |
---|
857 | 922 | |
---|
| 923 | + if (!cif_dev->is_thunderboot || |
---|
| 924 | + cif_dev->is_rdbk_to_online == false) |
---|
| 925 | + return 0; |
---|
| 926 | + |
---|
858 | 927 | if (dbufs->runtime_us && cif_dev->early_line == 0) { |
---|
859 | 928 | if (!cif_dev->sensor_linetime) |
---|
860 | 929 | cif_dev->sensor_linetime = rkcif_get_linetime(stream); |
---|