1 /* 2 * Copyright 2011, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Michael Lotz, mmlr@mlotz.ch 7 */ 8 9 10 #include "PanelFitter.h" 11 12 #include "accelerant.h" 13 #include "intel_extreme.h" 14 15 #include <stdlib.h> 16 #include <string.h> 17 18 19 #undef TRACE 20 #define TRACE_FITTER 21 #ifdef TRACE_FITTER 22 # define TRACE(x...) _sPrintf("intel_extreme: " x) 23 #else 24 # define TRACE(x...) 25 #endif 26 27 #define ERROR(x...) _sPrintf("intel_extreme: " x) 28 #define CALLED(x...) TRACE("CALLED %s\n", __PRETTY_FUNCTION__) 29 30 31 // #pragma mark - PanelFitter 32 33 34 PanelFitter::PanelFitter(int32 pipeIndex) 35 : 36 fBaseRegister(PCH_PANEL_FITTER_BASE_REGISTER 37 + pipeIndex * PCH_PANEL_FITTER_PIPE_OFFSET) 38 { 39 } 40 41 42 bool 43 PanelFitter::IsEnabled() 44 { 45 return (read32(fBaseRegister + PCH_PANEL_FITTER_CONTROL) 46 & PANEL_FITTER_ENABLED) != 0; 47 } 48 49 50 void 51 PanelFitter::Enable(const display_mode& mode) 52 { 53 // TODO: program the right window size and position based on the mode 54 _Enable(true); 55 } 56 57 58 void 59 PanelFitter::Disable() 60 { 61 _Enable(false); 62 } 63 64 65 void 66 PanelFitter::_Enable(bool enable) 67 { 68 uint32 targetRegister = fBaseRegister + PCH_PANEL_FITTER_CONTROL; 69 write32(targetRegister, read32(targetRegister) & ~PANEL_FITTER_ENABLED 70 | (enable ? PANEL_FITTER_ENABLED : 0)); 71 read32(targetRegister); 72 } 73