From 3aa2145919a3c8a7c08b455600c3c95e33744e12 Mon Sep 17 00:00:00 2001 From: Rudolf Cornelissen Date: Sat, 15 Oct 2005 10:38:11 +0000 Subject: [PATCH] added DPMS support (in the normal sense) for TVout: TVpicture is turned off completely when screensaver turns off screen. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14392 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../accelerants/nvidia/SetDisplayMode.c | 12 +++ .../nvidia/engine/nv_brooktreetv.c | 87 +++++++++---------- .../accelerants/nvidia/engine/nv_proto.h | 1 + 3 files changed, 55 insertions(+), 45 deletions(-) diff --git a/src/add-ons/accelerants/nvidia/SetDisplayMode.c b/src/add-ons/accelerants/nvidia/SetDisplayMode.c index 8d1b28f2d3..50ba1b0984 100644 --- a/src/add-ons/accelerants/nvidia/SetDisplayMode.c +++ b/src/add-ons/accelerants/nvidia/SetDisplayMode.c @@ -97,6 +97,7 @@ status_t SET_DISPLAY_MODE(display_mode *mode_to_set) head1_dpms_fetch(&display, &h, &v); head1_dpms(false, false, false); if (si->ps.secondary_head) head2_dpms(false, false, false); + if (si->ps.tvout) BT_dpms(false); /*where in framebuffer the screen is (should this be dependant on previous MOVEDISPLAY?)*/ startadd = (uint8*)si->fbc.frame_buffer - (uint8*)si->framebuffer; @@ -329,6 +330,8 @@ status_t SET_DISPLAY_MODE(display_mode *mode_to_set) head1_dpms(display, h, v); /* turn screen two on if a dualhead mode is active */ if (target.flags & DUALHEAD_BITS) head2_dpms(display,h,v); + /* turn TVout on if this is a TVout mode */ + if (target.flags & TV_BITS) BT_dpms(true); /* set up acceleration for this mode */ /* note: @@ -510,18 +513,22 @@ status_t SET_DPMS_MODE(uint32 dpms_flags) { case B_DPMS_ON: /* H: on, V: on, display on */ head1_dpms(true, true, true); if (si->ps.secondary_head) head2_dpms(true, true, true); + if (si->dm.flags & TV_BITS) BT_dpms(true); break; case B_DPMS_STAND_BY: head1_dpms(false, false, true); if (si->ps.secondary_head) head2_dpms(false, false, true); + if (si->dm.flags & TV_BITS) BT_dpms(false); break; case B_DPMS_SUSPEND: head1_dpms(false, true, false); if (si->ps.secondary_head) head2_dpms(false, true, false); + if (si->dm.flags & TV_BITS) BT_dpms(false); break; case B_DPMS_OFF: /* H: off, V: off, display off */ head1_dpms(false, false, false); if (si->ps.secondary_head) head2_dpms(false, false, false); + if (si->dm.flags & TV_BITS) BT_dpms(false); break; default: LOG(8,("SET: Invalid DPMS settings (DH) 0x%08x\n", dpms_flags)); @@ -535,15 +542,19 @@ status_t SET_DPMS_MODE(uint32 dpms_flags) { { case B_DPMS_ON: /* H: on, V: on, display on */ head1_dpms(true, true, true); + if (si->dm.flags & TV_BITS) BT_dpms(true); break; case B_DPMS_STAND_BY: head1_dpms(false, false, true); + if (si->dm.flags & TV_BITS) BT_dpms(false); break; case B_DPMS_SUSPEND: head1_dpms(false, true, false); + if (si->dm.flags & TV_BITS) BT_dpms(false); break; case B_DPMS_OFF: /* H: off, V: off, display off */ head1_dpms(false, false, false); + if (si->dm.flags & TV_BITS) BT_dpms(false); break; default: LOG(8,("SET: Invalid DPMS settings (DH) 0x%08x\n", dpms_flags)); @@ -551,6 +562,7 @@ status_t SET_DPMS_MODE(uint32 dpms_flags) { return B_ERROR; } } + interrupt_enable(true); return B_OK; } diff --git a/src/add-ons/accelerants/nvidia/engine/nv_brooktreetv.c b/src/add-ons/accelerants/nvidia/engine/nv_brooktreetv.c index 4ba93b6bd4..29c5331434 100644 --- a/src/add-ons/accelerants/nvidia/engine/nv_brooktreetv.c +++ b/src/add-ons/accelerants/nvidia/engine/nv_brooktreetv.c @@ -1211,48 +1211,6 @@ static uint8 BT_read_monstat(uint8* monstat) return stat; }//end BT_read_monstat. -static uint8 BT_dpms(bool display) -{ - uint8 stat; - - uint8 buffer[3]; - - LOG(4,("Brooktree: setting DPMS: ")); - - /* reset status */ - i2c_flag_error (-1); - - /* shutdown all analog electronics... */ - buffer[0] = si->ps.tv_encoder.adress + WR; - /* select first TV config register to write */ - buffer[1] = 0xba; - if (display) - { - /* enable all DACs */ - buffer[2] = 0x00; - LOG(4,("display on\n")); - } - else - { - /* shutdown all DACs */ - buffer[2] = 0x10; - LOG(4,("display off\n")); - } - - i2c_bstart(si->ps.tv_encoder.bus); - i2c_writebuffer(si->ps.tv_encoder.bus, buffer, 3); - i2c_bstop(si->ps.tv_encoder.bus); - /* log on errors */ - stat = i2c_flag_error(0); - if (stat) - { - LOG(4,("Brooktree: I2C errors occurred while setting DPMS\n")); - return stat; - } - - return stat; -}//end BT_dpms. - static uint8 BT_killclk_blackout(void) { uint8 stat; @@ -1333,12 +1291,51 @@ static uint8 BT_killclk_blackout(void) return stat; } - /* shutdown all analog electronics */ - stat = BT_dpms(false); - return stat; }//end BT_killclk_blackout. +uint8 BT_dpms(bool display) +{ + uint8 stat; + + uint8 buffer[3]; + + LOG(4,("Brooktree: setting DPMS: ")); + + /* reset status */ + i2c_flag_error (-1); + + /* shutdown all analog electronics... */ + buffer[0] = si->ps.tv_encoder.adress + WR; + /* select first TV config register to write */ + buffer[1] = 0xba; + if (display) + { + /* enable all DACs */ + buffer[2] = 0x00; + LOG(4,("display on\n")); + } + else + { + /* shutdown all DACs */ + buffer[2] = 0x10; + LOG(4,("display off\n")); + } + + i2c_bstart(si->ps.tv_encoder.bus); + i2c_writebuffer(si->ps.tv_encoder.bus, buffer, 3); + i2c_bstop(si->ps.tv_encoder.bus); + /* log on errors */ + stat = i2c_flag_error(0); + if (stat) + { + LOG(4,("Brooktree: I2C errors occurred while setting DPMS\n")); + return stat; + } + + return stat; +}//end BT_dpms. + uint8 BT_check_tvmode(display_mode target) { uint8 status = NOT_SUPPORTED; diff --git a/src/add-ons/accelerants/nvidia/engine/nv_proto.h b/src/add-ons/accelerants/nvidia/engine/nv_proto.h index e3f182795d..a7b051003a 100644 --- a/src/add-ons/accelerants/nvidia/engine/nv_proto.h +++ b/src/add-ons/accelerants/nvidia/engine/nv_proto.h @@ -60,6 +60,7 @@ status_t nv_dac2_set_pix_pll(display_mode target); /* Brooktree TV functions */ bool BT_probe(void); +uint8 BT_dpms(bool display); uint8 BT_check_tvmode(display_mode target); status_t BT_stop_tvout(void); status_t BT_setmode(display_mode target);