From 84cbe0e39f4b0e83fa1d4351d67d42a65fe65390 Mon Sep 17 00:00:00 2001 From: Rudolf Cornelissen Date: Sun, 20 Nov 2005 20:46:17 +0000 Subject: [PATCH] added preliminary DPMS support for laptop panels (disabling/enabling backlight). Not for NV11 though, and only if no external DVI panel is connected to a supported laptop. Please note: this feature can possibly be extended for NV11 and external panels if enough feedback (logfile) gets to me. If the driver/screen nolonger works for someone please let me know as well. Bumped version to 0.66. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15051 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../accelerants/nvidia/engine/nv_crtc.c | 102 ++++++++++++------ .../accelerants/nvidia/engine/nv_crtc2.c | 100 +++++++++++------ .../accelerants/nvidia/engine/nv_general.c | 2 +- 3 files changed, 133 insertions(+), 71 deletions(-) diff --git a/src/add-ons/accelerants/nvidia/engine/nv_crtc.c b/src/add-ons/accelerants/nvidia/engine/nv_crtc.c index 2ca2304e46..0262685255 100644 --- a/src/add-ons/accelerants/nvidia/engine/nv_crtc.c +++ b/src/add-ons/accelerants/nvidia/engine/nv_crtc.c @@ -570,29 +570,45 @@ status_t nv_crtc_dpms(bool display, bool h, bool v, bool do_panel) /* end synchronous reset because display should be enabled */ SEQW(RESET, 0x03); - if (do_panel && si->ps.tmds1_active && !si->ps.laptop) + if (do_panel && si->ps.tmds1_active) { - /* restore original panelsync and panel-enable */ - uint32 panelsync = 0x00000000; - if(si->ps.p1_timing.flags & B_POSITIVE_VSYNC) panelsync |= 0x00000001; - if(si->ps.p1_timing.flags & B_POSITIVE_HSYNC) panelsync |= 0x00000010; - /* display enable polarity (not an official flag) */ - if(si->ps.p1_timing.flags & B_BLANK_PEDESTAL) panelsync |= 0x10000000; - DACW(FP_TG_CTRL, ((DACR(FP_TG_CTRL) & 0xcfffffcc) | panelsync)); + if (!si->ps.laptop) + { + /* restore original panelsync and panel-enable */ + uint32 panelsync = 0x00000000; + if(si->ps.p1_timing.flags & B_POSITIVE_VSYNC) panelsync |= 0x00000001; + if(si->ps.p1_timing.flags & B_POSITIVE_HSYNC) panelsync |= 0x00000010; + /* display enable polarity (not an official flag) */ + if(si->ps.p1_timing.flags & B_BLANK_PEDESTAL) panelsync |= 0x10000000; + DACW(FP_TG_CTRL, ((DACR(FP_TG_CTRL) & 0xcfffffcc) | panelsync)); - //fixme?: looks like we don't need this after all: - /* powerup both LVDS (laptop panellink) and TMDS (DVI panellink) - * internal transmitters... */ - /* note: - * the powerbits in this register are hardwired to the DVI connectors, - * instead of to the DACs! (confirmed NV34) */ - //fixme... - //DACW(FP_DEBUG0, (DACR(FP_DEBUG0) & 0xcfffffff)); - /* ... and powerup external TMDS transmitter if it exists */ - /* (confirmed OK on NV28 and NV34) */ - //CRTCW(0x59, (CRTCR(0x59) | 0x01)); + //fixme?: looks like we don't need this after all: + /* powerup both LVDS (laptop panellink) and TMDS (DVI panellink) + * internal transmitters... */ + /* note: + * the powerbits in this register are hardwired to the DVI connectors, + * instead of to the DACs! (confirmed NV34) */ + //fixme... + //DACW(FP_DEBUG0, (DACR(FP_DEBUG0) & 0xcfffffff)); + /* ... and powerup external TMDS transmitter if it exists */ + /* (confirmed OK on NV28 and NV34) */ + //CRTCW(0x59, (CRTCR(0x59) | 0x01)); - sprintf(msg, "%s(panel-)", msg); + sprintf(msg, "%s(panel-)", msg); + } + else + { + //fixme? linux only does this on dualhead cards... + //fixme: see if LVDS head can be determined with two panels there... + if (!si->ps.tmds2_active && (si->ps.card_type != NV11)) + { + /* b2 = 0 = enable laptop panel backlight */ + /* note: this seems to be a write-only register. */ + NV_REG32(NV32_LVDS_PWR) = 0x00000003; + + sprintf(msg, "%s(panel-)", msg); + } + } } sprintf(msg, "%sdisplay on, ", msg); @@ -602,24 +618,40 @@ status_t nv_crtc_dpms(bool display, bool h, bool v, bool do_panel) /* turn screen off */ SEQW(CLKMODE, (temp | 0x20)); - if (do_panel && si->ps.tmds1_active && !si->ps.laptop) + if (do_panel && si->ps.tmds1_active) { - /* shutoff panelsync and disable panel */ - DACW(FP_TG_CTRL, ((DACR(FP_TG_CTRL) & 0xcfffffcc) | 0x20000022)); + if (!si->ps.laptop) + { + /* shutoff panelsync and disable panel */ + DACW(FP_TG_CTRL, ((DACR(FP_TG_CTRL) & 0xcfffffcc) | 0x20000022)); - //fixme?: looks like we don't need this after all: - /* powerdown both LVDS (laptop panellink) and TMDS (DVI panellink) - * internal transmitters... */ - /* note: - * the powerbits in this register are hardwired to the DVI connectors, - * instead of to the DACs! (confirmed NV34) */ - //fixme... - //DACW(FP_DEBUG0, (DACR(FP_DEBUG0) | 0x30000000)); - /* ... and powerdown external TMDS transmitter if it exists */ - /* (confirmed OK on NV28 and NV34) */ - //CRTCW(0x59, (CRTCR(0x59) & 0xfe)); + //fixme?: looks like we don't need this after all: + /* powerdown both LVDS (laptop panellink) and TMDS (DVI panellink) + * internal transmitters... */ + /* note: + * the powerbits in this register are hardwired to the DVI connectors, + * instead of to the DACs! (confirmed NV34) */ + //fixme... + //DACW(FP_DEBUG0, (DACR(FP_DEBUG0) | 0x30000000)); + /* ... and powerdown external TMDS transmitter if it exists */ + /* (confirmed OK on NV28 and NV34) */ + //CRTCW(0x59, (CRTCR(0x59) & 0xfe)); - sprintf(msg, "%s(panel-)", msg); + sprintf(msg, "%s(panel-)", msg); + } + else + { + //fixme? linux only does this on dualhead cards... + //fixme: see if LVDS head can be determined with two panels there... + if (!si->ps.tmds2_active && (si->ps.card_type != NV11)) + { + /* b2 = 1 = disable laptop panel backlight */ + /* note: this seems to be a write-only register. */ + NV_REG32(NV32_LVDS_PWR) = 0x00000007; + + sprintf(msg, "%s(panel-)", msg); + } + } } sprintf(msg, "%sdisplay off, ", msg); diff --git a/src/add-ons/accelerants/nvidia/engine/nv_crtc2.c b/src/add-ons/accelerants/nvidia/engine/nv_crtc2.c index 137ee46908..184d3bf50a 100644 --- a/src/add-ons/accelerants/nvidia/engine/nv_crtc2.c +++ b/src/add-ons/accelerants/nvidia/engine/nv_crtc2.c @@ -553,29 +553,44 @@ status_t nv_crtc2_dpms(bool display, bool h, bool v, bool do_panel) /* end synchronous reset because display should be enabled */ SEQW(RESET, 0x03); - if (do_panel && si->ps.tmds2_active && !si->ps.laptop) + if (do_panel && si->ps.tmds2_active) { - /* restore original panelsync and panel-enable */ - uint32 panelsync = 0x00000000; - if(si->ps.p2_timing.flags & B_POSITIVE_VSYNC) panelsync |= 0x00000001; - if(si->ps.p2_timing.flags & B_POSITIVE_HSYNC) panelsync |= 0x00000010; - /* display enable polarity (not an official flag) */ - if(si->ps.p2_timing.flags & B_BLANK_PEDESTAL) panelsync |= 0x10000000; - DAC2W(FP_TG_CTRL, ((DAC2R(FP_TG_CTRL) & 0xcfffffcc) | panelsync)); + if (!si->ps.laptop) + { + /* restore original panelsync and panel-enable */ + uint32 panelsync = 0x00000000; + if(si->ps.p2_timing.flags & B_POSITIVE_VSYNC) panelsync |= 0x00000001; + if(si->ps.p2_timing.flags & B_POSITIVE_HSYNC) panelsync |= 0x00000010; + /* display enable polarity (not an official flag) */ + if(si->ps.p2_timing.flags & B_BLANK_PEDESTAL) panelsync |= 0x10000000; + DAC2W(FP_TG_CTRL, ((DAC2R(FP_TG_CTRL) & 0xcfffffcc) | panelsync)); - //fixme?: looks like we don't need this after all: - /* powerup both LVDS (laptop panellink) and TMDS (DVI panellink) - * internal transmitters... */ - /* note: - * the powerbits in this register are hardwired to the DVI connectors, - * instead of to the DACs! (confirmed NV34) */ - //fixme... - //DAC2W(FP_DEBUG0, (DAC2R(FP_DEBUG0) & 0xcfffffff)); - /* ... and powerup external TMDS transmitter if it exists */ - /* (confirmed OK on NV28 and NV34) */ - //CRTC2W(0x59, (CRTC2R(0x59) | 0x01)); + //fixme?: looks like we don't need this after all: + /* powerup both LVDS (laptop panellink) and TMDS (DVI panellink) + * internal transmitters... */ + /* note: + * the powerbits in this register are hardwired to the DVI connectors, + * instead of to the DACs! (confirmed NV34) */ + //fixme... + //DAC2W(FP_DEBUG0, (DAC2R(FP_DEBUG0) & 0xcfffffff)); + /* ... and powerup external TMDS transmitter if it exists */ + /* (confirmed OK on NV28 and NV34) */ + //CRTC2W(0x59, (CRTC2R(0x59) | 0x01)); - sprintf(msg, "%s(panel-)", msg); + sprintf(msg, "%s(panel-)", msg); + } + else + { + //fixme: see if LVDS head can be determined with two panels there... + if (!si->ps.tmds1_active && (si->ps.card_type != NV11)) + { + /* b2 = 0 = enable laptop panel backlight */ + /* note: this seems to be a write-only register. */ + NV_REG32(NV32_LVDS_PWR) = 0x00000003; + + sprintf(msg, "%s(panel-)", msg); + } + } } sprintf(msg, "%sdisplay on, ", msg); @@ -585,24 +600,39 @@ status_t nv_crtc2_dpms(bool display, bool h, bool v, bool do_panel) /* turn screen off */ SEQW(CLKMODE, (temp | 0x20)); - if (do_panel && si->ps.tmds2_active && !si->ps.laptop) + if (do_panel && si->ps.tmds2_active) { - /* shutoff panelsync and disable panel */ - DAC2W(FP_TG_CTRL, ((DAC2R(FP_TG_CTRL) & 0xcfffffcc) | 0x20000022)); + if (!si->ps.laptop) + { + /* shutoff panelsync and disable panel */ + DAC2W(FP_TG_CTRL, ((DAC2R(FP_TG_CTRL) & 0xcfffffcc) | 0x20000022)); - //fixme?: looks like we don't need this after all: - /* powerdown both LVDS (laptop panellink) and TMDS (DVI panellink) - * internal transmitters... */ - /* note: - * the powerbits in this register are hardwired to the DVI connectors, - * instead of to the DACs! (confirmed NV34) */ - //fixme... - //DAC2W(FP_DEBUG0, (DAC2R(FP_DEBUG0) | 0x30000000)); - /* ... and powerdown external TMDS transmitter if it exists */ - /* (confirmed OK on NV28 and NV34) */ - //CRTC2W(0x59, (CRTC2R(0x59) & 0xfe)); + //fixme?: looks like we don't need this after all: + /* powerdown both LVDS (laptop panellink) and TMDS (DVI panellink) + * internal transmitters... */ + /* note: + * the powerbits in this register are hardwired to the DVI connectors, + * instead of to the DACs! (confirmed NV34) */ + //fixme... + //DAC2W(FP_DEBUG0, (DAC2R(FP_DEBUG0) | 0x30000000)); + /* ... and powerdown external TMDS transmitter if it exists */ + /* (confirmed OK on NV28 and NV34) */ + //CRTC2W(0x59, (CRTC2R(0x59) & 0xfe)); - sprintf(msg, "%s(panel-)", msg); + sprintf(msg, "%s(panel-)", msg); + } + else + { + //fixme: see if LVDS head can be determined with two panels there... + if (!si->ps.tmds1_active && (si->ps.card_type != NV11)) + { + /* b2 = 1 = disable laptop panel backlight */ + /* note: this seems to be a write-only register. */ + NV_REG32(NV32_LVDS_PWR) = 0x00000007; + + sprintf(msg, "%s(panel-)", msg); + } + } } sprintf(msg, "%sdisplay off, ", msg); diff --git a/src/add-ons/accelerants/nvidia/engine/nv_general.c b/src/add-ons/accelerants/nvidia/engine/nv_general.c index 1b72d03d0a..dca591fd19 100644 --- a/src/add-ons/accelerants/nvidia/engine/nv_general.c +++ b/src/add-ons/accelerants/nvidia/engine/nv_general.c @@ -91,7 +91,7 @@ status_t nv_general_powerup() { status_t status; - LOG(1,("POWERUP: Haiku nVidia Accelerant 0.65 running.\n")); + LOG(1,("POWERUP: Haiku nVidia Accelerant 0.66 running.\n")); /* log VBLANK INT usability status */ if (si->ps.int_assigned)