The Pedigree Project  0.1
VbeDisplay.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef VBE_DISPLAY_H
21 #define VBE_DISPLAY_H
22 
23 #include "pedigree/kernel/machine/Device.h"
24 #include "pedigree/kernel/machine/Display.h"
25 #include "pedigree/kernel/processor/MemoryRegion.h"
26 #include "pedigree/kernel/processor/types.h"
27 #include "pedigree/kernel/utilities/List.h"
28 #include "pedigree/kernel/utilities/MemoryAllocator.h"
29 #include "pedigree/kernel/utilities/Tree.h"
30 #include "pedigree/kernel/utilities/new"
31 
32 class Framebuffer;
33 class MemoryMappedIo;
34 
35 class VbeDisplay : public Display
36 {
37  public:
40  {
41  Vbe1_2,
42  Vbe2_0,
43  Vbe3_0
44  };
45 
46  VbeDisplay();
47  VbeDisplay(
49  size_t vidMemSz, size_t displayNum);
50 
51  virtual ~VbeDisplay();
52 
53  virtual void *getFramebuffer();
54  virtual bool getPixelFormat(Display::PixelFormat &pPf);
55  virtual bool getCurrentScreenMode(Display::ScreenMode &sm);
57  virtual bool setScreenMode(Display::ScreenMode sm);
58  virtual bool setScreenMode(size_t modeId);
59  virtual bool setScreenMode(size_t nWidth, size_t nHeight, size_t nBpp)
60  {
61  return Display::setScreenMode(nWidth, nHeight, nBpp);
62  }
63 
64  virtual rgb_t *newBuffer();
65  virtual void setCurrentBuffer(rgb_t *pBuffer);
66  virtual void updateBuffer(
67  rgb_t *pBuffer, size_t x1 = ~0UL, size_t y1 = ~0UL, size_t x2 = ~0UL,
68  size_t y2 = ~0UL);
69  virtual void killBuffer(rgb_t *pBuffer);
70  virtual void bitBlit(
71  rgb_t *pBuffer, size_t fromX, size_t fromY, size_t toX, size_t toY,
72  size_t width, size_t height);
73  virtual void fillRectangle(
74  rgb_t *pBuffer, size_t x, size_t y, size_t width, size_t height,
75  rgb_t colour);
76 
77  size_t getModeId()
78  {
79  return m_Mode.id;
80  }
81 
82  virtual void setLogicalFramebuffer(Framebuffer *p)
83  {
84  m_pLogicalFramebuffer = p;
85  }
86 
87  private:
89  VbeDisplay(const VbeDisplay &);
90  VbeDisplay &operator=(const VbeDisplay &);
91 
92  void packColour(rgb_t colour, size_t idx, uintptr_t pFb);
93 
96 
99 
102 
103  MemoryMappedIo *m_pFramebuffer;
104  Framebuffer *m_pLogicalFramebuffer;
105 
106  Device::Address *m_pFramebufferRawAddress;
107 
109  enum ModeType
110  {
111  Mode_16bpp_5r6g5b,
112  Mode_24bpp_8r8g8b,
113  Mode_Generic
114  };
115 
117  struct Buffer
118  {
119  Buffer()
120  : pBackbuffer(0), pFbBackbuffer(0), mr("Buffer"), fbmr("Fb buffer"),
121  valid(true)
122  {
123  }
124  rgb_t *pBackbuffer;
125  uint8_t *pFbBackbuffer;
126  MemoryRegion mr, fbmr;
127 
128  bool valid;
129 
130  private:
131  Buffer(const Buffer &);
132  const Buffer &operator=(const Buffer &);
133  };
136 
139 
142 };
143 
144 #endif
virtual void * getFramebuffer()
Definition: VbeDisplay.cc:118
virtual bool getPixelFormat(Display::PixelFormat &pPf)
Definition: VbeDisplay.cc:123
virtual bool setScreenMode(Display::ScreenMode sm)
Definition: VbeDisplay.cc:163
Memory mapped I/O range.
MemoryAllocator m_Allocator
Definition: VbeDisplay.h:141
virtual void fillRectangle(rgb_t *pBuffer, size_t x, size_t y, size_t width, size_t height, rgb_t colour)
Definition: VbeDisplay.cc:496
virtual bool setScreenMode(size_t nWidth, size_t nHeight, size_t nBpp)
Definition: VbeDisplay.h:59
Definition: Device.h:43
ModeType m_SpecialisedMode
Definition: VbeDisplay.h:138
virtual rgb_t * newBuffer()
Definition: VbeDisplay.cc:254
Special memory entity in the kernel's virtual address space.
Definition: MemoryRegion.h:35
List< Display::ScreenMode * > m_ModeList
Definition: VbeDisplay.h:98
Tree< rgb_t *, Buffer * > m_Buffers
Definition: VbeDisplay.h:135
A key/value dictionary.
Definition: Tree.h:33
Abstracts the system&#39;s framebuffer offering.
Display::ScreenMode m_Mode
Definition: VbeDisplay.h:101
virtual bool getScreenModes(List< Display::ScreenMode * > &sms)
Definition: VbeDisplay.cc:135
VbeVersion m_VbeVersion
Definition: VbeDisplay.h:95
virtual bool setScreenMode(ScreenMode sm)
Definition: Display.cc:110
virtual bool getCurrentScreenMode(Display::ScreenMode &sm)
Definition: VbeDisplay.cc:129