diff options
author | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2010-07-28 19:06:04 -0400 |
---|---|---|
committer | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2010-09-23 22:14:44 -0400 |
commit | a54be174e425cb41eb774714d03ff98562ee0824 (patch) | |
tree | 18629d30908ed45af499d610ff404558faaf944c /drivers/video/via | |
parent | b002741d174a32f8162b2110ad9757b6fb6afcc3 (diff) |
viafb: rework output device routing
This patch rips the device routing out of the 3 main functions to
separate functions to make them available for transition to a better
controlling scheme.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: Joseph Chan <JosephChan@via.com.tw>
Diffstat (limited to 'drivers/video/via')
-rw-r--r-- | drivers/video/via/hw.c | 183 |
1 files changed, 94 insertions, 89 deletions
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c index 1ce2c211bd1d..2f7f64006499 100644 --- a/drivers/video/via/hw.c +++ b/drivers/video/via/hw.c | |||
@@ -860,18 +860,78 @@ void viafb_set_output_path(int device, int set_iga, int output_interface) | |||
860 | enable_second_display_channel(); | 860 | enable_second_display_channel(); |
861 | } | 861 | } |
862 | 862 | ||
863 | static void set_crt_output_path(int set_iga) | 863 | static void set_source_common(u8 index, u8 offset, u8 iga) |
864 | { | 864 | { |
865 | viafb_write_reg_mask(CR36, VIACR, 0x00, BIT4 + BIT5); | 865 | u8 value, mask = 1 << offset; |
866 | 866 | ||
867 | switch (set_iga) { | 867 | switch (iga) { |
868 | case IGA1: | ||
869 | value = 0x00; | ||
870 | break; | ||
871 | case IGA2: | ||
872 | value = mask; | ||
873 | break; | ||
874 | default: | ||
875 | printk(KERN_WARNING "viafb: Unsupported source: %d\n", iga); | ||
876 | return; | ||
877 | } | ||
878 | |||
879 | via_write_reg_mask(VIACR, index, value, mask); | ||
880 | } | ||
881 | |||
882 | static void set_crt_source(u8 iga) | ||
883 | { | ||
884 | u8 value; | ||
885 | |||
886 | switch (iga) { | ||
868 | case IGA1: | 887 | case IGA1: |
869 | viafb_write_reg_mask(SR16, VIASR, 0x00, BIT6); | 888 | value = 0x00; |
870 | break; | 889 | break; |
871 | case IGA2: | 890 | case IGA2: |
872 | viafb_write_reg_mask(SR16, VIASR, 0x40, BIT6); | 891 | value = 0x40; |
873 | break; | 892 | break; |
893 | default: | ||
894 | printk(KERN_WARNING "viafb: Unsupported source: %d\n", iga); | ||
895 | return; | ||
874 | } | 896 | } |
897 | |||
898 | via_write_reg_mask(VIASR, 0x16, value, 0x40); | ||
899 | } | ||
900 | |||
901 | static inline void set_6C_source(u8 iga) | ||
902 | { | ||
903 | set_source_common(0x6C, 7, iga); | ||
904 | } | ||
905 | |||
906 | static inline void set_93_source(u8 iga) | ||
907 | { | ||
908 | set_source_common(0x93, 7, iga); | ||
909 | } | ||
910 | |||
911 | static inline void set_96_source(u8 iga) | ||
912 | { | ||
913 | set_source_common(0x96, 4, iga); | ||
914 | } | ||
915 | |||
916 | static inline void set_dvp1_source(u8 iga) | ||
917 | { | ||
918 | set_source_common(0x9B, 4, iga); | ||
919 | } | ||
920 | |||
921 | static inline void set_lvds1_source(u8 iga) | ||
922 | { | ||
923 | set_source_common(0x99, 4, iga); | ||
924 | } | ||
925 | |||
926 | static inline void set_lvds2_source(u8 iga) | ||
927 | { | ||
928 | set_source_common(0x97, 4, iga); | ||
929 | } | ||
930 | |||
931 | static void set_crt_output_path(int set_iga) | ||
932 | { | ||
933 | viafb_write_reg_mask(CR36, VIACR, 0x00, BIT4 + BIT5); | ||
934 | set_crt_source(set_iga); | ||
875 | } | 935 | } |
876 | 936 | ||
877 | static void dvi_patch_skew_dvp0(void) | 937 | static void dvi_patch_skew_dvp0(void) |
@@ -944,76 +1004,45 @@ static void set_dvi_output_path(int set_iga, int output_interface) | |||
944 | { | 1004 | { |
945 | switch (output_interface) { | 1005 | switch (output_interface) { |
946 | case INTERFACE_DVP0: | 1006 | case INTERFACE_DVP0: |
1007 | set_96_source(set_iga); | ||
1008 | set_6C_source(set_iga); | ||
947 | viafb_write_reg_mask(CR6B, VIACR, 0x01, BIT0); | 1009 | viafb_write_reg_mask(CR6B, VIACR, 0x01, BIT0); |
948 | 1010 | viafb_write_reg_mask(CR6C, VIACR, 0x21, BIT0 + BIT5); | |
949 | if (set_iga == IGA1) { | ||
950 | viafb_write_reg_mask(CR96, VIACR, 0x00, BIT4); | ||
951 | viafb_write_reg_mask(CR6C, VIACR, 0x21, BIT0 + | ||
952 | BIT5 + BIT7); | ||
953 | } else { | ||
954 | viafb_write_reg_mask(CR96, VIACR, 0x10, BIT4); | ||
955 | viafb_write_reg_mask(CR6C, VIACR, 0xA1, BIT0 + | ||
956 | BIT5 + BIT7); | ||
957 | } | ||
958 | |||
959 | viafb_write_reg_mask(SR1E, VIASR, 0xC0, BIT7 + BIT6); | 1011 | viafb_write_reg_mask(SR1E, VIASR, 0xC0, BIT7 + BIT6); |
960 | |||
961 | dvi_patch_skew_dvp0(); | 1012 | dvi_patch_skew_dvp0(); |
962 | break; | 1013 | break; |
963 | 1014 | ||
964 | case INTERFACE_DVP1: | 1015 | case INTERFACE_DVP1: |
965 | if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { | 1016 | if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { |
966 | if (set_iga == IGA1) | 1017 | set_93_source(set_iga); |
967 | viafb_write_reg_mask(CR93, VIACR, 0x21, | 1018 | viafb_write_reg_mask(CR93, VIACR, 0x21, BIT0 + BIT5); |
968 | BIT0 + BIT5 + BIT7); | ||
969 | else | ||
970 | viafb_write_reg_mask(CR93, VIACR, 0xA1, | ||
971 | BIT0 + BIT5 + BIT7); | ||
972 | } else { | 1019 | } else { |
973 | if (set_iga == IGA1) | 1020 | set_dvp1_source(set_iga); |
974 | viafb_write_reg_mask(CR9B, VIACR, 0x00, BIT4); | ||
975 | else | ||
976 | viafb_write_reg_mask(CR9B, VIACR, 0x10, BIT4); | ||
977 | } | 1021 | } |
978 | 1022 | ||
979 | viafb_write_reg_mask(SR1E, VIASR, 0x30, BIT4 + BIT5); | 1023 | viafb_write_reg_mask(SR1E, VIASR, 0x30, BIT4 + BIT5); |
980 | break; | 1024 | break; |
981 | case INTERFACE_DFP_HIGH: | 1025 | case INTERFACE_DFP_HIGH: |
982 | if (viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266) { | 1026 | if (viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266) { |
983 | if (set_iga == IGA1) { | 1027 | via_write_reg_mask(VIACR, CR97, 0x03, 0x03); |
984 | viafb_write_reg_mask(CR96, VIACR, 0x00, BIT4); | 1028 | set_lvds2_source(set_iga); |
985 | viafb_write_reg_mask(CR97, VIACR, 0x03, | 1029 | set_96_source(set_iga); |
986 | BIT0 + BIT1 + BIT4); | ||
987 | } else { | ||
988 | viafb_write_reg_mask(CR96, VIACR, 0x10, BIT4); | ||
989 | viafb_write_reg_mask(CR97, VIACR, 0x13, | ||
990 | BIT0 + BIT1 + BIT4); | ||
991 | } | ||
992 | } | 1030 | } |
1031 | |||
993 | viafb_write_reg_mask(SR2A, VIASR, 0x0C, BIT2 + BIT3); | 1032 | viafb_write_reg_mask(SR2A, VIASR, 0x0C, BIT2 + BIT3); |
994 | break; | 1033 | break; |
995 | 1034 | ||
996 | case INTERFACE_DFP_LOW: | 1035 | case INTERFACE_DFP_LOW: |
997 | if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) | 1036 | if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) |
998 | break; | 1037 | break; |
999 | 1038 | set_dvp1_source(set_iga); | |
1000 | if (set_iga == IGA1) { | 1039 | set_lvds1_source(set_iga); |
1001 | viafb_write_reg_mask(CR99, VIACR, 0x00, BIT4); | ||
1002 | viafb_write_reg_mask(CR9B, VIACR, 0x00, BIT4); | ||
1003 | } else { | ||
1004 | viafb_write_reg_mask(CR99, VIACR, 0x10, BIT4); | ||
1005 | viafb_write_reg_mask(CR9B, VIACR, 0x10, BIT4); | ||
1006 | } | ||
1007 | |||
1008 | viafb_write_reg_mask(SR2A, VIASR, 0x03, BIT0 + BIT1); | 1040 | viafb_write_reg_mask(SR2A, VIASR, 0x03, BIT0 + BIT1); |
1009 | dvi_patch_skew_dvp_low(); | 1041 | dvi_patch_skew_dvp_low(); |
1010 | break; | 1042 | break; |
1011 | 1043 | ||
1012 | case INTERFACE_TMDS: | 1044 | case INTERFACE_TMDS: |
1013 | if (set_iga == IGA1) | 1045 | set_lvds1_source(set_iga); |
1014 | viafb_write_reg_mask(CR99, VIACR, 0x00, BIT4); | ||
1015 | else | ||
1016 | viafb_write_reg_mask(CR99, VIACR, 0x10, BIT4); | ||
1017 | break; | 1046 | break; |
1018 | } | 1047 | } |
1019 | 1048 | ||
@@ -1031,45 +1060,31 @@ static void set_lcd_output_path(int set_iga, int output_interface) | |||
1031 | 1060 | ||
1032 | viafb_write_reg_mask(CR6B, VIACR, 0x00, BIT3); | 1061 | viafb_write_reg_mask(CR6B, VIACR, 0x00, BIT3); |
1033 | viafb_write_reg_mask(CR6A, VIACR, 0x08, BIT3); | 1062 | viafb_write_reg_mask(CR6A, VIACR, 0x08, BIT3); |
1034 | |||
1035 | switch (output_interface) { | 1063 | switch (output_interface) { |
1036 | case INTERFACE_DVP0: | 1064 | case INTERFACE_DVP0: |
1037 | if (set_iga == IGA1) { | 1065 | set_96_source(set_iga); |
1038 | viafb_write_reg_mask(CR96, VIACR, 0x00, BIT4); | 1066 | if (set_iga == IGA2) |
1039 | } else { | ||
1040 | viafb_write_reg(CR91, VIACR, 0x00); | 1067 | viafb_write_reg(CR91, VIACR, 0x00); |
1041 | viafb_write_reg_mask(CR96, VIACR, 0x10, BIT4); | ||
1042 | } | ||
1043 | break; | 1068 | break; |
1044 | 1069 | ||
1045 | case INTERFACE_DVP1: | 1070 | case INTERFACE_DVP1: |
1046 | if (set_iga == IGA1) | 1071 | set_dvp1_source(set_iga); |
1047 | viafb_write_reg_mask(CR9B, VIACR, 0x00, BIT4); | 1072 | if (set_iga == IGA2) |
1048 | else { | ||
1049 | viafb_write_reg(CR91, VIACR, 0x00); | 1073 | viafb_write_reg(CR91, VIACR, 0x00); |
1050 | viafb_write_reg_mask(CR9B, VIACR, 0x10, BIT4); | ||
1051 | } | ||
1052 | break; | 1074 | break; |
1053 | 1075 | ||
1054 | case INTERFACE_DFP_HIGH: | 1076 | case INTERFACE_DFP_HIGH: |
1055 | if (set_iga == IGA1) | 1077 | set_lvds2_source(set_iga); |
1056 | viafb_write_reg_mask(CR97, VIACR, 0x00, BIT4); | 1078 | set_96_source(set_iga); |
1057 | else { | 1079 | if (set_iga == IGA2) |
1058 | viafb_write_reg(CR91, VIACR, 0x00); | 1080 | viafb_write_reg(CR91, VIACR, 0x00); |
1059 | viafb_write_reg_mask(CR97, VIACR, 0x10, BIT4); | ||
1060 | viafb_write_reg_mask(CR96, VIACR, 0x10, BIT4); | ||
1061 | } | ||
1062 | break; | 1081 | break; |
1063 | 1082 | ||
1064 | case INTERFACE_DFP_LOW: | 1083 | case INTERFACE_DFP_LOW: |
1065 | if (set_iga == IGA1) | 1084 | set_lvds1_source(set_iga); |
1066 | viafb_write_reg_mask(CR99, VIACR, 0x00, BIT4); | 1085 | set_dvp1_source(set_iga); |
1067 | else { | 1086 | if (set_iga == IGA2) |
1068 | viafb_write_reg(CR91, VIACR, 0x00); | 1087 | viafb_write_reg(CR91, VIACR, 0x00); |
1069 | viafb_write_reg_mask(CR99, VIACR, 0x10, BIT4); | ||
1070 | viafb_write_reg_mask(CR9B, VIACR, 0x10, BIT4); | ||
1071 | } | ||
1072 | |||
1073 | break; | 1088 | break; |
1074 | 1089 | ||
1075 | case INTERFACE_DFP: | 1090 | case INTERFACE_DFP: |
@@ -1078,30 +1093,20 @@ static void set_lcd_output_path(int set_iga, int output_interface) | |||
1078 | viaparinfo->chip_info->gfx_chip_name)) | 1093 | viaparinfo->chip_info->gfx_chip_name)) |
1079 | viafb_write_reg_mask(CR97, VIACR, 0x84, | 1094 | viafb_write_reg_mask(CR97, VIACR, 0x84, |
1080 | BIT7 + BIT2 + BIT1 + BIT0); | 1095 | BIT7 + BIT2 + BIT1 + BIT0); |
1081 | if (set_iga == IGA1) { | 1096 | |
1082 | viafb_write_reg_mask(CR97, VIACR, 0x00, BIT4); | 1097 | set_lvds1_source(set_iga); |
1083 | viafb_write_reg_mask(CR99, VIACR, 0x00, BIT4); | 1098 | set_lvds2_source(set_iga); |
1084 | } else { | 1099 | if (set_iga == IGA2) |
1085 | viafb_write_reg(CR91, VIACR, 0x00); | 1100 | viafb_write_reg(CR91, VIACR, 0x00); |
1086 | viafb_write_reg_mask(CR97, VIACR, 0x10, BIT4); | ||
1087 | viafb_write_reg_mask(CR99, VIACR, 0x10, BIT4); | ||
1088 | } | ||
1089 | break; | 1101 | break; |
1090 | 1102 | ||
1091 | case INTERFACE_LVDS0: | 1103 | case INTERFACE_LVDS0: |
1092 | case INTERFACE_LVDS0LVDS1: | 1104 | case INTERFACE_LVDS0LVDS1: |
1093 | if (set_iga == IGA1) | 1105 | set_lvds1_source(set_iga); |
1094 | viafb_write_reg_mask(CR99, VIACR, 0x00, BIT4); | ||
1095 | else | ||
1096 | viafb_write_reg_mask(CR99, VIACR, 0x10, BIT4); | ||
1097 | |||
1098 | break; | 1106 | break; |
1099 | 1107 | ||
1100 | case INTERFACE_LVDS1: | 1108 | case INTERFACE_LVDS1: |
1101 | if (set_iga == IGA1) | 1109 | set_lvds2_source(set_iga); |
1102 | viafb_write_reg_mask(CR97, VIACR, 0x00, BIT4); | ||
1103 | else | ||
1104 | viafb_write_reg_mask(CR97, VIACR, 0x10, BIT4); | ||
1105 | break; | 1110 | break; |
1106 | } | 1111 | } |
1107 | } | 1112 | } |