vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / accelerants / intel_extreme / PanelFitter.cpp
blob8357d611099000ac3431a471124a2153aa50366b
1 /*
2 * Copyright 2011, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Michael Lotz, mmlr@mlotz.ch
7 */
10 #include "PanelFitter.h"
12 #include "accelerant.h"
13 #include "intel_extreme.h"
15 #include <stdlib.h>
16 #include <string.h>
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
27 #define ERROR(x...) _sPrintf("intel_extreme: " x)
28 #define CALLED(x...) TRACE("CALLED %s\n", __PRETTY_FUNCTION__)
31 // #pragma mark - PanelFitter
34 PanelFitter::PanelFitter(int32 pipeIndex)
36 fBaseRegister(PCH_PANEL_FITTER_BASE_REGISTER
37 + pipeIndex * PCH_PANEL_FITTER_PIPE_OFFSET)
42 bool
43 PanelFitter::IsEnabled()
45 return (read32(fBaseRegister + PCH_PANEL_FITTER_CONTROL)
46 & PANEL_FITTER_ENABLED) != 0;
50 void
51 PanelFitter::Enable(const display_mode& mode)
53 // TODO: program the right window size and position based on the mode
54 _Enable(true);
58 void
59 PanelFitter::Disable()
61 _Enable(false);
65 void
66 PanelFitter::_Enable(bool enable)
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);