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