.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd |
---|
3 | 4 | * Author: Chris Zhong <zyw@rock-chips.com> |
---|
4 | | - * |
---|
5 | | - * This software is licensed under the terms of the GNU General Public |
---|
6 | | - * License version 2, as published by the Free Software Foundation, and |
---|
7 | | - * may be copied, distributed, and modified under those terms. |
---|
8 | | - * |
---|
9 | | - * This program is distributed in the hope that it will be useful, |
---|
10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | | - * GNU General Public License for more details. |
---|
13 | 5 | */ |
---|
14 | 6 | |
---|
15 | 7 | #include <linux/clk.h> |
---|
.. | .. |
---|
596 | 588 | if (ret) |
---|
597 | 589 | goto err_get_training_status; |
---|
598 | 590 | |
---|
599 | | - dp->link.rate = status[0]; |
---|
600 | | - dp->link.num_lanes = status[1]; |
---|
| 591 | + dp->max_rate = status[0]; |
---|
| 592 | + dp->max_lanes = status[1]; |
---|
601 | 593 | |
---|
602 | 594 | err_get_training_status: |
---|
603 | 595 | if (ret) |
---|
.. | .. |
---|
646 | 638 | return ret; |
---|
647 | 639 | } |
---|
648 | 640 | |
---|
649 | | - DRM_DEV_DEBUG_KMS(dp->dev, "rate:0x%x, lanes:%d\n", dp->link.rate, |
---|
650 | | - dp->link.num_lanes); |
---|
651 | | - return 0; |
---|
| 641 | + DRM_DEV_DEBUG_KMS(dp->dev, "rate:0x%x, lanes:%d\n", dp->max_rate, |
---|
| 642 | + dp->max_lanes); |
---|
| 643 | + return ret; |
---|
652 | 644 | } |
---|
653 | 645 | |
---|
654 | 646 | int cdn_dp_set_video_status(struct cdn_dp_device *dp, int active) |
---|
.. | .. |
---|
687 | 679 | case YCBCR_4_2_0: |
---|
688 | 680 | val[0] = 5; |
---|
689 | 681 | break; |
---|
690 | | - }; |
---|
| 682 | + } |
---|
691 | 683 | |
---|
692 | 684 | switch (video->color_depth) { |
---|
693 | 685 | case 6: |
---|
.. | .. |
---|
705 | 697 | case 16: |
---|
706 | 698 | val[1] = 4; |
---|
707 | 699 | break; |
---|
708 | | - }; |
---|
| 700 | + } |
---|
709 | 701 | |
---|
710 | 702 | msa_misc = 2 * val[0] + 32 * val[1] + |
---|
711 | 703 | ((video->color_fmt == Y_ONLY) ? (1 << 14) : 0); |
---|
.. | .. |
---|
725 | 717 | bit_per_pix = (video->color_fmt == YCBCR_4_2_2) ? |
---|
726 | 718 | (video->color_depth * 2) : (video->color_depth * 3); |
---|
727 | 719 | |
---|
728 | | - link_rate = drm_dp_bw_code_to_link_rate(dp->link.rate) / 1000; |
---|
| 720 | + link_rate = drm_dp_bw_code_to_link_rate(dp->max_rate) / 1000; |
---|
729 | 721 | |
---|
730 | 722 | ret = cdn_dp_reg_write(dp, BND_HSYNC2VSYNC, VIF_BYPASS_INTERLACE); |
---|
731 | 723 | if (ret) |
---|
.. | .. |
---|
744 | 736 | */ |
---|
745 | 737 | do { |
---|
746 | 738 | tu_size_reg += 2; |
---|
747 | | - symbol = tu_size_reg * mode->clock * bit_per_pix; |
---|
748 | | - do_div(symbol, dp->link.num_lanes * link_rate * 8); |
---|
| 739 | + symbol = (u64)tu_size_reg * mode->clock * bit_per_pix; |
---|
| 740 | + do_div(symbol, dp->max_lanes * link_rate * 8); |
---|
749 | 741 | rem = do_div(symbol, 1000); |
---|
750 | 742 | if (tu_size_reg > 64) { |
---|
751 | 743 | ret = -EINVAL; |
---|
752 | 744 | DRM_DEV_ERROR(dp->dev, |
---|
753 | 745 | "tu error, clk:%d, lanes:%d, rate:%d\n", |
---|
754 | | - mode->clock, dp->link.num_lanes, |
---|
755 | | - link_rate); |
---|
| 746 | + mode->clock, dp->max_lanes, link_rate); |
---|
756 | 747 | goto err_config_video; |
---|
757 | 748 | } |
---|
758 | 749 | } while ((symbol <= 1) || (tu_size_reg - symbol < 4) || |
---|
.. | .. |
---|
766 | 757 | |
---|
767 | 758 | /* set the FIFO Buffer size */ |
---|
768 | 759 | val = div_u64(mode->clock * (symbol + 1), 1000) + link_rate; |
---|
769 | | - val /= (dp->link.num_lanes * link_rate); |
---|
| 760 | + val /= (dp->max_lanes * link_rate); |
---|
770 | 761 | val = div_u64(8 * (symbol + 1), bit_per_pix) - val; |
---|
771 | 762 | val += 2; |
---|
772 | 763 | ret = cdn_dp_reg_write(dp, DP_VC_TABLE(15), val); |
---|
.. | .. |
---|
787 | 778 | case 16: |
---|
788 | 779 | val = BCS_16; |
---|
789 | 780 | break; |
---|
790 | | - }; |
---|
| 781 | + } |
---|
791 | 782 | |
---|
792 | 783 | val += video->color_fmt << 8; |
---|
793 | 784 | ret = cdn_dp_reg_write(dp, DP_FRAMER_PXL_REPR, val); |
---|
.. | .. |
---|
919 | 910 | u32 val; |
---|
920 | 911 | |
---|
921 | 912 | if (audio->channels == 2) { |
---|
922 | | - if (dp->link.num_lanes == 1) |
---|
| 913 | + if (dp->max_lanes == 1) |
---|
923 | 914 | sub_pckt_num = 2; |
---|
924 | 915 | else |
---|
925 | 916 | sub_pckt_num = 4; |
---|
.. | .. |
---|
998 | 989 | writel(I2S_DEC_START, dp->regs + AUDIO_SRC_CNTL); |
---|
999 | 990 | } |
---|
1000 | 991 | |
---|
1001 | | -static void cdn_dp_audio_config_spdif(struct cdn_dp_device *dp, |
---|
1002 | | - struct audio_info *audio) |
---|
| 992 | +static void cdn_dp_audio_config_spdif(struct cdn_dp_device *dp) |
---|
1003 | 993 | { |
---|
1004 | 994 | u32 val; |
---|
1005 | | - int sub_pckt_num = 1; |
---|
1006 | 995 | |
---|
1007 | | - if (audio->channels == 2) { |
---|
1008 | | - if (dp->link.num_lanes == 1) |
---|
1009 | | - sub_pckt_num = 2; |
---|
1010 | | - else |
---|
1011 | | - sub_pckt_num = 4; |
---|
1012 | | - } |
---|
1013 | 996 | writel(SYNC_WR_TO_CH_ZERO, dp->regs + FIFO_CNTL); |
---|
1014 | 997 | |
---|
1015 | | - val = MAX_NUM_CH(audio->channels); |
---|
1016 | | - val |= AUDIO_TYPE_LPCM; |
---|
1017 | | - val |= CFG_SUB_PCKT_NUM(sub_pckt_num); |
---|
| 998 | + val = MAX_NUM_CH(2) | AUDIO_TYPE_LPCM | CFG_SUB_PCKT_NUM(4); |
---|
1018 | 999 | writel(val, dp->regs + SMPL2PKT_CNFG); |
---|
1019 | 1000 | writel(SMPL2PKT_EN, dp->regs + SMPL2PKT_CNTL); |
---|
1020 | 1001 | |
---|
.. | .. |
---|
1023 | 1004 | |
---|
1024 | 1005 | clk_prepare_enable(dp->spdif_clk); |
---|
1025 | 1006 | clk_set_rate(dp->spdif_clk, CDN_DP_SPDIF_CLK); |
---|
1026 | | -} |
---|
1027 | | - |
---|
1028 | | -void cdn_dp_infoframe_set(struct cdn_dp_device *dp, int entry_id, |
---|
1029 | | - u8 *buf, u32 len, int type) |
---|
1030 | | -{ |
---|
1031 | | - unsigned int idx; |
---|
1032 | | - u32 *packet = (u32 *)buf; |
---|
1033 | | - u32 length = len / 4; |
---|
1034 | | - |
---|
1035 | | - for (idx = 0; idx < length; idx++) |
---|
1036 | | - writel(cpu_to_le32(*packet++), dp->regs + SOURCE_PIF_DATA_WR); |
---|
1037 | | - |
---|
1038 | | - writel(entry_id, dp->regs + SOURCE_PIF_WR_ADDR); |
---|
1039 | | - writel(HOST_WR, dp->regs + SOURCE_PIF_WR_REQ); |
---|
1040 | | - writel(ACTIVE_IDLE_TYPE(1) | TYPE_VALID | |
---|
1041 | | - PACKET_TYPE(type) | PKT_ALLOC_ADDRESS(entry_id), |
---|
1042 | | - dp->regs + SOURCE_PIF_PKT_ALLOC_REG); |
---|
1043 | | - writel(PKT_ALLOC_WR_EN, dp->regs + SOURCE_PIF_PKT_ALLOC_WR_EN); |
---|
1044 | 1007 | } |
---|
1045 | 1008 | |
---|
1046 | 1009 | int cdn_dp_audio_config(struct cdn_dp_device *dp, struct audio_info *audio) |
---|
.. | .. |
---|
1064 | 1027 | if (audio->format == AFMT_I2S) |
---|
1065 | 1028 | cdn_dp_audio_config_i2s(dp, audio); |
---|
1066 | 1029 | else if (audio->format == AFMT_SPDIF) |
---|
1067 | | - cdn_dp_audio_config_spdif(dp, audio); |
---|
| 1030 | + cdn_dp_audio_config_spdif(dp); |
---|
1068 | 1031 | |
---|
1069 | 1032 | ret = cdn_dp_reg_write(dp, AUDIO_PACK_CONTROL, AUDIO_PACK_EN); |
---|
1070 | 1033 | |
---|