From 71c5c6de8c1fa39cfd668348ad0c02b913eb205e Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Wed, 1 Aug 2007 21:46:10 +0200 Subject: Added output detection based on PInS data. --- src/mga.h | 13 +++++++++++++ src/mga_bios.c | 10 ++++++++++ src/mga_driver.c | 43 ++++++++++++++++++++++++++++++------------- 3 files changed, 53 insertions(+), 13 deletions(-) diff --git a/src/mga.h b/src/mga.h index 8a3cf6b..43595a3 100644 --- a/src/mga.h +++ b/src/mga.h @@ -301,6 +301,14 @@ typedef enum { MGA_HOST_AGP_4x = 7 /**< AGP 4x capable. */ } mga_host_t; +typedef enum { + MGA_CONNECTOR_NONE = 0, + MGA_CONNECTOR_HD15, + MGA_CONNECTOR_DVI, + MGA_CONNECTOR_TV, + MGA_CONNECTOR_LAST = MGA_CONNECTOR_TV +} mga_connector_t; + /** * Card information derrived from BIOS PInS data. */ @@ -341,6 +349,11 @@ struct mga_bios_values { * Type of physical interface used for the card. */ mga_host_t host_interface; + + /** + * On G450 and G550 PInS lists the available connectors. + */ + mga_connector_t connector[2]; }; diff --git a/src/mga_bios.c b/src/mga_bios.c index dd75f3f..bf70b84 100644 --- a/src/mga_bios.c +++ b/src/mga_bios.c @@ -118,6 +118,7 @@ static void mga_initialize_bios_values( MGAPtr pMga, (void) memset( bios, 0, sizeof( *bios ) ); bios->pixel.min_freq = 50000; + bios->connector[0] = bios->connector[1] = MGA_CONNECTOR_NONE; switch( pMga->Chipset ) { case PCI_CHIP_MGA2064: @@ -341,6 +342,7 @@ static void mga_parse_bios_ver_5( struct mga_bios_values * bios, const CARD8 * bios_data ) { const unsigned scale = (bios_data[4] != 0) ? 8000 : 6000; + mga_connector_t connector; if ( bios_data[38] != 0xff ) { @@ -397,6 +399,14 @@ static void mga_parse_bios_ver_5( struct mga_bios_values * bios, } bios->host_interface = (bios_data[113] >> 3) & 0x07; + + connector = bios_data[116] & 0x0f; + if (connector <= MGA_CONNECTOR_LAST) + bios->connector[0] = connector; + + connector = (bios_data[116] >> 4) & 0x0f; + if (connector <= MGA_CONNECTOR_LAST) + bios->connector[1] = connector; } diff --git a/src/mga_driver.c b/src/mga_driver.c index ed923e8..71b9857 100644 --- a/src/mga_driver.c +++ b/src/mga_driver.c @@ -1078,24 +1078,41 @@ MGAMavenRead(ScrnInfoPtr pScrn, I2CByte reg, I2CByte *val) static void setup_outputs(ScrnInfoPtr scrn) { + MGAPtr pMga; xf86OutputPtr output; - /* FIXME: - * Create outputs depending on the hardware. - */ - output = MgaGOutputPanelInit (scrn); + pMga = MGAPTR(scrn); + + /* first output */ + switch (pMga->bios.connector[0]) { + case MGA_CONNECTOR_DVI: + output = MgaGOutputPanelInit (scrn); + break; + default: + /* in case PInS doesn't contain connector info + * or it claims there's no primary output + * we just assume it's VGA. + */ + output = MgaGOutputDac1Init (scrn); + break; + } + + /* the first output can be mapped to any crtc */ output->possible_crtcs = 1 | 2; - output->possible_clones = 1 | 2; -#if 0 - output = MgaGOutputDac1Init (scrn); - output->possible_crtcs = 1 | 2; - output->possible_clones = 1 | 2; -#endif + /* second output */ + switch (pMga->bios.connector[1]) { + case MGA_CONNECTOR_HD15: + output = MgaGOutputDac2Init (scrn); + break; + default: + output = NULL; + break; + } - output = MgaGOutputDac2Init (scrn); - output->possible_crtcs = 2; - output->possible_clones = 2; + /* the second output can only be mapped to crtc 2 */ + if (output) + output->possible_crtcs = 2; } /* Mandatory */ -- cgit v1.2.3