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