From 06f4c4397d23324a9c2d318ad467a6291fcae31a Mon Sep 17 00:00:00 2001 From: Rudolf Cornelissen Date: Thu, 22 Apr 2004 20:11:04 +0000 Subject: [PATCH] analog output switching updates: not ready yet... git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7297 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../accelerants/nvidia/SetDisplayMode.c | 6 +- .../accelerants/nvidia/engine/nv_general.c | 71 ++++++++++--------- .../accelerants/nvidia/engine/nv_info.c | 54 +++++++++++++- .../accelerants/nvidia/engine/nv_proto.h | 1 + 4 files changed, 93 insertions(+), 39 deletions(-) diff --git a/src/add-ons/accelerants/nvidia/SetDisplayMode.c b/src/add-ons/accelerants/nvidia/SetDisplayMode.c index b6b66ae8e5..776bcd3386 100644 --- a/src/add-ons/accelerants/nvidia/SetDisplayMode.c +++ b/src/add-ons/accelerants/nvidia/SetDisplayMode.c @@ -132,9 +132,9 @@ status_t SET_DISPLAY_MODE(display_mode *mode_to_set) /* set output connectors assignment if possible */ if ((target.flags & DUALHEAD_BITS) == DUALHEAD_SWITCH) /* invert output assignment in switch mode */ - nv_general_output_select(true); + nv_general_head_select(true); else - nv_general_output_select(false); + nv_general_head_select(false); /* set the pixel clock PLL(s) */ LOG(8,("SETMODE: target clock %dkHz\n",target.timing.pixel_clock)); @@ -263,7 +263,7 @@ status_t SET_DISPLAY_MODE(display_mode *mode_to_set) // cross = false; // } /* set output connectors assignment if possible */ - nv_general_output_select(false); + nv_general_head_select(false); } switch(target.space) diff --git a/src/add-ons/accelerants/nvidia/engine/nv_general.c b/src/add-ons/accelerants/nvidia/engine/nv_general.c index e9f7af9188..66b9a86ed2 100644 --- a/src/add-ons/accelerants/nvidia/engine/nv_general.c +++ b/src/add-ons/accelerants/nvidia/engine/nv_general.c @@ -874,6 +874,9 @@ return nv_general_bios_to_powergraphics(); return B_OK; } +/* this routine switches the CRTC/DAC sets to 'connectors', but only for analog + * outputs. We need this to make sure the analog 'switch' is set in the same way the + * digital 'switch' is set by the BIOS or we might not be able to use dualhead. */ status_t nv_general_output_select(bool cross) { /* make sure this call is warranted */ @@ -881,12 +884,11 @@ status_t nv_general_output_select(bool cross) { /* NV11 cards can't switch heads; we lack info to switch heads via outputs * if flatpanels are used */ - //fixme: nolonger used: will be removed later on. - if (0)//(si->ps.card_type != NV11) && !si->ps.tmds1_active && !si->ps.tmds2_active) + if (si->ps.card_type != NV11) { if (cross) { - LOG(4,("INIT: switching outputs to be cross-connected\n")); + LOG(4,("INIT: switching analog outputs to be cross-connected\n")); /* enable head 2 on connector 1 */ /* (b8 = select CRTC (head) for output, @@ -898,7 +900,7 @@ status_t nv_general_output_select(bool cross) } else { - LOG(4,("INIT: switching outputs to be straight-through\n")); + LOG(4,("INIT: switching analog outputs to be straight-through\n")); /* enable head 1 on connector 1 */ DACW(OUTPUT, 0x00000001); @@ -908,34 +910,7 @@ status_t nv_general_output_select(bool cross) } else { - /* make sure we have outputs wired straight through first */ - if (si->ps.card_type == NV11) - { - LOG(4,("INIT: NV11 outputs are hardwired to be straight-through\n")); - } - else - { - LOG(4,("INIT: switching outputs to be straight-through\n")); - - /* enable head 1 on connector 1 */ - DACW(OUTPUT, 0x00000001); - /* enable head 2 on connector 2 */ - DAC2W(OUTPUT, 0x00000101); - } - - /* now invert CRTC use to do switching */ - if (cross) - { - LOG(4,("INIT: switching CRTC use to be cross-connected\n")); - si->crtc_switch_mode = !si->ps.crtc2_prim; - } - else - { - LOG(4,("INIT: switching CRTC use to be straight-through\n")); - si->crtc_switch_mode = si->ps.crtc2_prim; - } - /* update CRTC and DAC functions access */ - setup_virtualized_heads(si->crtc_switch_mode); + LOG(4,("INIT: NV11 analog outputs are hardwired to be straight-through\n")); } return B_OK; } @@ -945,10 +920,38 @@ status_t nv_general_output_select(bool cross) } } +/* this routine switches CRTC/DAC set use. We need this because it's unknown howto + * switch digital panels to/from a specific CRTC/DAC set. */ +status_t nv_general_head_select(bool cross) +{ + /* make sure this call is warranted */ + if (si->ps.secondary_head) + { + /* invert CRTC/DAC use to do switching */ + if (cross) + { + LOG(4,("INIT: switching CRTC/DAC use to be cross-connected\n")); + si->crtc_switch_mode = !si->ps.crtc2_prim; + } + else + { + LOG(4,("INIT: switching CRTC/DAC use to be straight-through\n")); + si->crtc_switch_mode = si->ps.crtc2_prim; + } + /* update CRTC and DAC functions access */ + setup_virtualized_heads(si->crtc_switch_mode); + + return B_OK; + } + else + { + return B_ERROR; + } +} + /* basic change of card state from VGA to enhanced mode: * Should work from VGA BIOS POST init state. */ -static -status_t nv_general_bios_to_powergraphics() +static status_t nv_general_bios_to_powergraphics() { LOG(2, ("INIT: Skipping card coldstart!\n")); diff --git a/src/add-ons/accelerants/nvidia/engine/nv_info.c b/src/add-ons/accelerants/nvidia/engine/nv_info.c index 4e885b9881..d9960ec398 100644 --- a/src/add-ons/accelerants/nvidia/engine/nv_info.c +++ b/src/add-ons/accelerants/nvidia/engine/nv_info.c @@ -246,9 +246,58 @@ void fake_pins(void) /* find out the BIOS preprogrammed panel use status... */ detect_panels(); +//in progress! + if (si->ps.secondary_head) + { + if (si->ps.card_type != NV11) + { + uint8 monitors = 0x00; + + /* presetup by the card's BIOS, we can't change this (lack of info) */ + if (si->ps.tmds1_active) monitors |= 0x01; + if (si->ps.tmds2_active) monitors |= 0x02; +//fixme: checkout NV25, NV18, NV11... NV34 must use DAC _and_ DAC2 for det. + /* connect analog outputs straight through */ + nv_general_output_select(false); + /* sense analog monitor on primary connector */ + if (nv_dac_crt_connected()) monitors |= 0x04; + /* cross connect analog outputs */ + nv_general_output_select(true); + /* sense analog monitor on secondary connector */ + if (nv_dac_crt_connected()) monitors |= 0x08; + /* re-connect analog outputs straight through */ + nv_general_output_select(false); + +//fixme! two monitors on one DAC _can_ happen!!! (switch analog outputs then!) + switch (monitors) + { + case 0x01: /* digital panel on DAC1, nothing on DAC2 */ + case 0x04: /* analog panel or CRT on DAC1, nothing on DAC2 */ + case 0x05: /* both types on DAC1, nothing on DAC2 (shouldn't happen) */ + LOG(2,("INFO: head 1 has a monitor only: defaulting to head 1 use\n")); + break; + case 0x02: /* digital panel on DAC2, nothing on DAC1 */ + case 0x08: /* analog panel or CRT on DAC2, nothing on DAC1 */ + case 0x0a: /* both types on DAC2, nothing on DAC1 (shouldn't happen) */ + LOG(2,("INFO: head 2 has a monitor only: defaulting to head 2 use\n")); + si->ps.crtc2_prim = true; + break; + default: /* monitors found on both DACs, or nothing found at all */ + LOG(2,("INFO: head 2 has a monitor only: defaulting to head 2 use\n")); + break; + } + } + else + { + LOG(4,("INFO: NV11 outputs are hardwired to be straight-through\n")); + } + } +// + +//fixme: remove.. /* if no panel, but one analog monitor is detected, and it's on the secondary * head on dualhead cards, we use that head as primary head */ - if (si->ps.secondary_head && !si->ps.tmds1_active && !si->ps.tmds2_active) +/* if (si->ps.secondary_head && !si->ps.tmds1_active && !si->ps.tmds2_active) { if (nv_dac2_crt_connected() && !nv_dac_crt_connected()) { @@ -256,6 +305,7 @@ void fake_pins(void) si->ps.crtc2_prim = true; } } +*/ /* select other CRTC for primary head use if specified by user in settings file */ if (si->ps.secondary_head && si->settings.switchhead) @@ -449,7 +499,7 @@ static void detect_panels() * we use that head as primary head */ if (si->ps.secondary_head && si->ps.tmds2_active && !si->ps.tmds1_active) { - LOG(2,("INFO: CRTC2 has a panel only: defaulting to CRTC2 use\n")); + LOG(2,("INFO: CRTC2 has a panel only: defaulting to CRTC2 for primary use\n")); si->ps.crtc2_prim = true; } diff --git a/src/add-ons/accelerants/nvidia/engine/nv_proto.h b/src/add-ons/accelerants/nvidia/engine/nv_proto.h index 0a36d86240..b72705105b 100644 --- a/src/add-ons/accelerants/nvidia/engine/nv_proto.h +++ b/src/add-ons/accelerants/nvidia/engine/nv_proto.h @@ -3,6 +3,7 @@ status_t nv_general_powerup(void); status_t nv_set_cas_latency(void); void setup_virtualized_heads(bool); status_t nv_general_output_select(bool); +status_t nv_general_head_select(bool); status_t nv_general_wait_retrace(void); status_t nv_general_validate_pic_size (display_mode *target, uint32 *bytes_per_row, bool *acc_mode);