1 /* 2 Copyright (c) 2002-04, Thomas Kurschel 3 4 5 Part of Radeon accelerant 6 7 Header file explicitely for display mode changes 8 */ 9 10 #ifndef _SET_MODE_H 11 #define _SET_MODE_H 12 13 // PLL divider values 14 typedef struct { 15 uint32 post_code; // code for post divider 16 uint32 post; // value of post divider 17 uint32 extra_post_code; // code for extra post divider 18 uint32 extra_post; // value of extra post divider 19 uint32 ref; // reference divider 20 uint32 feedback; // feedback divider 21 uint32 freq; // resulting frequency 22 } pll_dividers; 23 24 25 // TV-timing 26 typedef struct { 27 uint32 freq; // TV sub carrier frequency x12 28 uint16 h_total; 29 uint16 h_sync_len; 30 uint16 h_genclk_delay; 31 uint16 h_setup_delay; 32 uint16 h_active_delay; 33 uint16 h_active_len; 34 uint16 v_total; 35 uint16 v_active_lines; 36 uint16 v_field_total; 37 uint16 v_fields; 38 uint16 f_total; 39 uint16 frame_size_adjust; 40 uint32 scale; 41 } tv_timing; 42 43 44 // TV-Out parameters 45 typedef struct { 46 uint16 y_accum_init; 47 uint16 uv_accum_init; 48 uint16 uv_inc; 49 uint16 h_inc; 50 uint32 tv_clocks_to_active; 51 52 uint16 f_restart; 53 uint16 v_restart; 54 uint16 h_restart; 55 bool mode888; 56 57 uint16 y_saw_tooth_slope; 58 uint16 y_saw_tooth_amp; 59 uint16 y_rise_accum_init; 60 uint16 y_fall_accum_init; 61 bool y_coeff_enable; 62 uint8 y_coeff_value; 63 64 pll_dividers tv_dividers; 65 pll_dividers crt_dividers; 66 67 tv_timing timing; 68 } impactv_params; 69 70 71 // CRTC register content (for mode change) 72 typedef struct { 73 uint32 crtc_h_total_disp; 74 uint32 crtc_h_sync_strt_wid; 75 uint32 crtc_v_total_disp; 76 uint32 crtc_v_sync_strt_wid; 77 uint32 crtc_pitch; 78 uint32 crtc_gen_cntl; 79 uint32 crtc_offset_cntl; 80 } crtc_regs; 81 82 83 // PLL register content (for mode change) 84 typedef struct { 85 uint32 ppll_div_3; 86 uint32 ppll_ref_div; 87 uint32 htotal_cntl; 88 89 // pure information 90 uint32 dot_clock_freq; // in 10 kHz 91 uint32 pll_output_freq;// in 10 kHz 92 int feedback_div; 93 int post_div; 94 } pll_regs; 95 96 97 // Flat Panel register content (for mode change) 98 typedef struct { 99 uint32 fp_gen_cntl; 100 uint32 fp_panel_cntl; 101 uint32 lvds_gen_cntl; 102 uint32 fp_h_sync_strt_wid; 103 uint32 fp_v_sync_strt_wid; 104 uint32 fp2_gen_cntl; 105 106 uint32 fp2_h_sync_strt_wid; 107 uint32 fp2_v_sync_strt_wid; 108 109 // RMX registers 110 uint32 fp_horz_stretch; 111 uint32 fp_vert_stretch; 112 } fp_regs; 113 114 115 #define RADEON_TV_TIMING_SIZE 32 116 #define RADEON_TV_UPSAMP_COEFF_NUM (5*3) 117 118 119 // ImpacTV-Out regs (for mode change) 120 typedef struct { 121 uint32 tv_ftotal; 122 uint32 tv_vscaler_cntl1; 123 uint32 tv_y_saw_tooth_cntl; 124 uint32 tv_y_fall_cntl; 125 uint32 tv_y_rise_cntl; 126 uint32 tv_vscaler_cntl2; 127 uint32 tv_hrestart; 128 uint32 tv_vrestart; 129 uint32 tv_frestart; 130 uint32 tv_tv_pll_cntl; 131 uint32 tv_crt_pll_cntl; 132 uint32 tv_clock_sel_cntl; 133 uint32 tv_clkout_cntl; 134 uint32 tv_htotal; 135 uint32 tv_hsize; 136 uint32 tv_hdisp; 137 uint32 tv_hstart; 138 uint32 tv_vtotal; 139 uint32 tv_vdisp; 140 uint32 tv_sync_size; 141 uint32 tv_timing_cntl; 142 uint32 tv_modulator_cntl1; 143 uint32 tv_modulator_cntl2; 144 uint32 tv_data_delay_a; 145 uint32 tv_data_delay_b; 146 uint32 tv_frame_lock_cntl; 147 uint32 tv_pll_cntl1; 148 uint32 tv_rgb_cntl; 149 uint32 tv_pre_dac_mux_cntl; 150 uint32 tv_master_cntl; 151 uint32 tv_dac_cntl; 152 uint32 tv_uv_adr; 153 uint32 tv_pll_fine_cntl; 154 uint32 tv_gain_limit_settings; 155 uint32 tv_linear_gain_settings; 156 uint32 tv_upsamp_and_gain_cntl; 157 uint32 tv_crc_cntl; 158 159 uint16 tv_hor_timing[RADEON_TV_TIMING_SIZE]; 160 uint16 tv_vert_timing[RADEON_TV_TIMING_SIZE]; 161 162 uint32 tv_upsample_filter_coeff[RADEON_TV_UPSAMP_COEFF_NUM]; 163 } impactv_regs; 164 165 166 // Monitor Signal Routing regs (for mode change) 167 // (they collide with many other *_regs, so take 168 // care to set only the bits really used for routing) 169 typedef struct { 170 // DAC registers 171 uint32 dac_cntl2; 172 uint32 dac_cntl; 173 uint32 tv_master_cntl; 174 uint32 tv_dac_cntl; 175 bool skip_tv_dac; // if true, don't write tv_dac_cntl 176 177 // Display path registers 178 uint32 disp_hw_debug; 179 uint32 disp_output_cntl; 180 uint32 disp_tv_out_cntl; 181 182 // CRTC registers 183 uint32 crtc_ext_cntl; 184 uint32 crtc2_gen_cntl; 185 186 // PLL regs 187 uint32 vclk_ecp_cntl; 188 uint32 pixclks_cntl; 189 190 // GP IO-pad 191 uint32 gpiopad_a; 192 193 // flat panel registers 194 uint32 fp_gen_cntl; 195 uint32 fp2_gen_cntl; 196 } routing_regs; 197 198 199 // crtc.c 200 uint16 Radeon_GetHSyncFudge( crtc_info *crtc, int datatype ); 201 void Radeon_CalcCRTCRegisters( accelerator_info *ai, crtc_info *crtc, 202 display_mode *mode, crtc_regs *values ); 203 void Radeon_ProgramCRTCRegisters( accelerator_info *ai, int crtc_idx, 204 crtc_regs *values ); 205 206 207 // pll.c 208 void Radeon_CalcCRTPLLDividers( const general_pll_info *general_pll, const display_mode *mode, pll_dividers *dividers ); 209 void Radeon_CalcPLLRegisters( const display_mode *mode, const pll_dividers *dividers, pll_regs *values ); 210 void Radeon_ProgramPLL( accelerator_info *ai, int crtc_idx, pll_regs *values ); 211 void Radeon_CalcPLLDividers( const pll_info *pll, uint32 freq, uint fixed_post_div, pll_dividers *dividers ); 212 void Radeon_MatchCRTPLL( 213 const pll_info *pll, 214 uint32 tv_v_total, uint32 tv_h_total, uint32 tv_frame_size_adjust, uint32 freq, 215 const display_mode *mode, uint32 max_v_tweak, uint32 max_h_tweak, 216 uint32 max_frame_rate_drift, uint32 fixed_post_div, 217 pll_dividers *dividers, 218 display_mode *tweaked_mode ); 219 void Radeon_GetTVPLLConfiguration( const general_pll_info *general_pll, pll_info *pll, 220 bool internal_encoder ); 221 void Radeon_GetTVCRTPLLConfiguration( const general_pll_info *general_pll, pll_info *pll, 222 bool internal_tv_encoder ); 223 224 225 // flat_panel.c 226 void Radeon_ReadRMXRegisters( accelerator_info *ai, fp_regs *values ); 227 void Radeon_CalcRMXRegisters( fp_info *flatpanel, display_mode *mode, bool use_rmx, fp_regs *values ); 228 void Radeon_ProgramRMXRegisters( accelerator_info *ai, fp_regs *values ); 229 230 void Radeon_ReadFPRegisters( accelerator_info *ai, fp_regs *values ); 231 void Radeon_CalcFPRegisters( accelerator_info *ai, crtc_info *crtc, 232 fp_info *fp_port, crtc_regs *crtc_values, fp_regs *values ); 233 void Radeon_ProgramFPRegisters( accelerator_info *ai, crtc_info *crtc, 234 fp_info *fp_port, fp_regs *values ); 235 236 237 // monitor_routing.h 238 void Radeon_ReadMonitorRoutingRegs( 239 accelerator_info *ai, routing_regs *values ); 240 void Radeon_CalcMonitorRouting( 241 accelerator_info *ai, const impactv_params *tv_parameters, routing_regs *values ); 242 void Radeon_ProgramMonitorRouting( 243 accelerator_info *ai, routing_regs *values ); 244 void Radeon_SetupDefaultMonitorRouting( 245 accelerator_info *ai, int whished_num_heads, bool use_laptop_panel ); 246 247 248 // impactv.c 249 250 typedef void (*impactv_write_FIFO) ( 251 accelerator_info *ai, uint16 addr, uint32 value ); 252 typedef uint32 (*impactv_read_FIFO) ( 253 accelerator_info *ai, uint16 addr ); 254 255 void Radeon_CalcImpacTVParams( 256 const general_pll_info *general_pll, impactv_params *params, 257 tv_standard_e tv_format, bool internal_encoder, 258 const display_mode *mode, display_mode *tweaked_mode ); 259 void Radeon_CalcImpacTVRegisters( 260 accelerator_info *ai, display_mode *mode, 261 impactv_params *params, impactv_regs *values, int crtc_idx, 262 bool internal_encoder, tv_standard_e tv_format, display_device_e display_device ); 263 void Radeon_ImpacTVwriteHorTimingTable( 264 accelerator_info *ai, impactv_write_FIFO write, impactv_regs *values, bool internal_encoder ); 265 void Radeon_ImpacTVwriteVertTimingTable( 266 accelerator_info *ai, impactv_write_FIFO write, impactv_regs *values ); 267 268 269 // theatre_out.c 270 void Radeon_TheatreProgramTVRegisters( accelerator_info *ai, impactv_regs *values ); 271 void Radeon_TheatreReadTVRegisters( accelerator_info *ai, impactv_regs *values ); 272 uint32 Radeon_TheatreReadFIFO( accelerator_info *ai, uint16 addr ); 273 void Radeon_TheatreWriteFIFO( accelerator_info *ai, uint16 addr, uint32 value ); 274 275 // internal_tv_out.c 276 void Radeon_InternalTVOutProgramRegisters( accelerator_info *ai, impactv_regs *values ); 277 void Radeon_InternalTVOutReadRegisters( accelerator_info *ai, impactv_regs *values ); 278 279 280 #endif 281