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 113 // Bios values used by Mobility Asics 114 uint32 bios_4_scratch; 115 uint32 bios_5_scratch; 116 uint32 bios_6_scratch; 117 } fp_regs; 118 119 120 #define RADEON_TV_TIMING_SIZE 32 121 #define RADEON_TV_UPSAMP_COEFF_NUM (5*3) 122 123 124 // ImpacTV-Out regs (for mode change) 125 typedef struct { 126 uint32 tv_ftotal; 127 uint32 tv_vscaler_cntl1; 128 uint32 tv_y_saw_tooth_cntl; 129 uint32 tv_y_fall_cntl; 130 uint32 tv_y_rise_cntl; 131 uint32 tv_vscaler_cntl2; 132 uint32 tv_hrestart; 133 uint32 tv_vrestart; 134 uint32 tv_frestart; 135 uint32 tv_tv_pll_cntl; 136 uint32 tv_crt_pll_cntl; 137 uint32 tv_clock_sel_cntl; 138 uint32 tv_clkout_cntl; 139 uint32 tv_htotal; 140 uint32 tv_hsize; 141 uint32 tv_hdisp; 142 uint32 tv_hstart; 143 uint32 tv_vtotal; 144 uint32 tv_vdisp; 145 uint32 tv_sync_size; 146 uint32 tv_timing_cntl; 147 uint32 tv_modulator_cntl1; 148 uint32 tv_modulator_cntl2; 149 uint32 tv_data_delay_a; 150 uint32 tv_data_delay_b; 151 uint32 tv_frame_lock_cntl; 152 uint32 tv_pll_cntl1; 153 uint32 tv_rgb_cntl; 154 uint32 tv_pre_dac_mux_cntl; 155 uint32 tv_master_cntl; 156 uint32 tv_dac_cntl; 157 uint32 tv_uv_adr; 158 uint32 tv_pll_fine_cntl; 159 uint32 tv_gain_limit_settings; 160 uint32 tv_linear_gain_settings; 161 uint32 tv_upsamp_and_gain_cntl; 162 uint32 tv_crc_cntl; 163 164 uint16 tv_hor_timing[RADEON_TV_TIMING_SIZE]; 165 uint16 tv_vert_timing[RADEON_TV_TIMING_SIZE]; 166 167 uint32 tv_upsample_filter_coeff[RADEON_TV_UPSAMP_COEFF_NUM]; 168 } impactv_regs; 169 170 171 // Monitor Signal Routing regs (for mode change) 172 // (they collide with many other *_regs, so take 173 // care to set only the bits really used for routing) 174 typedef struct { 175 // DAC registers 176 uint32 dac_cntl2; 177 uint32 dac_cntl; 178 uint32 tv_master_cntl; 179 uint32 tv_dac_cntl; 180 bool skip_tv_dac; // if true, don't write tv_dac_cntl 181 182 // Display path registers 183 uint32 disp_hw_debug; 184 uint32 disp_output_cntl; 185 uint32 disp_tv_out_cntl; 186 187 // CRTC registers 188 uint32 crtc_ext_cntl; 189 uint32 crtc2_gen_cntl; 190 191 // PLL regs 192 uint32 vclk_ecp_cntl; 193 uint32 pixclks_cntl; 194 195 // GP IO-pad 196 uint32 gpiopad_a; 197 198 // flat panel registers 199 uint32 fp_gen_cntl; 200 uint32 fp2_gen_cntl; 201 } routing_regs; 202 203 204 // crtc.c 205 uint16 Radeon_GetHSyncFudge( crtc_info *crtc, int datatype ); 206 void Radeon_CalcCRTCRegisters( accelerator_info *ai, crtc_info *crtc, 207 display_mode *mode, crtc_regs *values ); 208 void Radeon_ProgramCRTCRegisters( accelerator_info *ai, int crtc_idx, 209 crtc_regs *values ); 210 211 212 // pll.c 213 void Radeon_CalcCRTPLLDividers( const general_pll_info *general_pll, const display_mode *mode, pll_dividers *dividers ); 214 void Radeon_CalcPLLRegisters( const display_mode *mode, const pll_dividers *dividers, pll_regs *values ); 215 void Radeon_ProgramPLL( accelerator_info *ai, int crtc_idx, pll_regs *values ); 216 void Radeon_CalcPLLDividers( const pll_info *pll, uint32 freq, uint fixed_post_div, pll_dividers *dividers ); 217 void Radeon_MatchCRTPLL( 218 const pll_info *pll, 219 uint32 tv_v_total, uint32 tv_h_total, uint32 tv_frame_size_adjust, uint32 freq, 220 const display_mode *mode, uint32 max_v_tweak, uint32 max_h_tweak, 221 uint32 max_frame_rate_drift, uint32 fixed_post_div, 222 pll_dividers *dividers, 223 display_mode *tweaked_mode ); 224 void Radeon_GetTVPLLConfiguration( const general_pll_info *general_pll, pll_info *pll, 225 bool internal_encoder ); 226 void Radeon_GetTVCRTPLLConfiguration( const general_pll_info *general_pll, pll_info *pll, 227 bool internal_tv_encoder ); 228 229 230 // flat_panel.c 231 void Radeon_ReadRMXRegisters( accelerator_info *ai, fp_regs *values ); 232 void Radeon_CalcRMXRegisters( fp_info *flatpanel, display_mode *mode, bool use_rmx, fp_regs *values ); 233 void Radeon_ProgramRMXRegisters( accelerator_info *ai, fp_regs *values ); 234 235 void Radeon_ReadFPRegisters( accelerator_info *ai, fp_regs *values ); 236 void Radeon_CalcFPRegisters( accelerator_info *ai, crtc_info *crtc, 237 fp_info *fp_port, crtc_regs *crtc_values, fp_regs *values ); 238 void Radeon_ProgramFPRegisters( accelerator_info *ai, crtc_info *crtc, 239 fp_info *fp_port, fp_regs *values ); 240 241 242 // monitor_routing.h 243 void Radeon_ReadMonitorRoutingRegs( 244 accelerator_info *ai, routing_regs *values ); 245 void Radeon_CalcMonitorRouting( 246 accelerator_info *ai, const impactv_params *tv_parameters, routing_regs *values ); 247 void Radeon_ProgramMonitorRouting( 248 accelerator_info *ai, routing_regs *values ); 249 void Radeon_SetupDefaultMonitorRouting( 250 accelerator_info *ai, int whished_num_heads, bool use_laptop_panel ); 251 252 253 // impactv.c 254 255 typedef void (*impactv_write_FIFO) ( 256 accelerator_info *ai, uint16 addr, uint32 value ); 257 typedef uint32 (*impactv_read_FIFO) ( 258 accelerator_info *ai, uint16 addr ); 259 260 void Radeon_CalcImpacTVParams( 261 const general_pll_info *general_pll, impactv_params *params, 262 tv_standard_e tv_format, bool internal_encoder, 263 const display_mode *mode, display_mode *tweaked_mode ); 264 void Radeon_CalcImpacTVRegisters( 265 accelerator_info *ai, display_mode *mode, 266 impactv_params *params, impactv_regs *values, int crtc_idx, 267 bool internal_encoder, tv_standard_e tv_format, display_device_e display_device ); 268 void Radeon_ImpacTVwriteHorTimingTable( 269 accelerator_info *ai, impactv_write_FIFO write, impactv_regs *values, bool internal_encoder ); 270 void Radeon_ImpacTVwriteVertTimingTable( 271 accelerator_info *ai, impactv_write_FIFO write, impactv_regs *values ); 272 273 274 // theatre_out.c 275 void Radeon_TheatreProgramTVRegisters( accelerator_info *ai, impactv_regs *values ); 276 void Radeon_TheatreReadTVRegisters( accelerator_info *ai, impactv_regs *values ); 277 uint32 Radeon_TheatreReadFIFO( accelerator_info *ai, uint16 addr ); 278 void Radeon_TheatreWriteFIFO( accelerator_info *ai, uint16 addr, uint32 value ); 279 280 // internal_tv_out.c 281 void Radeon_InternalTVOutProgramRegisters( accelerator_info *ai, impactv_regs *values ); 282 void Radeon_InternalTVOutReadRegisters( accelerator_info *ai, impactv_regs *values ); 283 284 285 #endif 286