Fixed `make install` issues, bugs with VESA
[tpg/acess2.git] / Kernel / include / tpl_drv_video.h
1 /**\r
2  * \file tpl_drv_video.h\r
3  * \brief Video Driver Interface Definitions\r
4  * \note For AcessOS Version 1\r
5  * \r
6  * Video drivers extend the common driver interface tpl_drv_common.h\r
7  * and must support _at least_ the IOCtl numbers defined in this file\r
8  * to be compatable with Acess.\r
9  * \r
10  * \section IOCtls\r
11  * As said, a compatable driver must implement these calls correctly,\r
12  * but they may choose not to allow direct user access to the framebuffer.\r
13  * \r
14  * \section Screen Contents\r
15  * Writes to the driver's file while in component colour modes\r
16  * must correspond to a change of the contents of the screen. The framebuffer\r
17  * must start at offset 0 in the file.\r
18  * Reading from the screen must either return zero, or read from the\r
19  * framebuffer.\r
20  * \r
21  * \section Mode Support\r
22  * All video drivers must support at least one text mode (Mode #0)\r
23  * For each graphics mode the driver exposes, there must be a corresponding\r
24  * text mode with the same resolution, this mode will be used when the\r
25  * user switches to a text Virtual Terminal while in graphics mode.\r
26  */\r
27 #ifndef _TPL_VIDEO_H\r
28 #define _TPL_VIDEO_H\r
29 \r
30 #include <tpl_drv_common.h>\r
31 \r
32 /**\r
33  * \enum eTplVideo_IOCtl\r
34  * \brief Common Video IOCtl Calls\r
35  * \extends eTplDrv_IOCtl\r
36  */\r
37 enum eTplVideo_IOCtl {\r
38         /**\r
39          * ioctl(..., int *mode)\r
40          * \brief Get/Set Mode\r
41          * \return Current mode ID or -1 on error\r
42          * \r
43          * If \a mode is non-NULL, the current video mode is set to \a *mode.\r
44          * This updated ID is then returned to the user.\r
45          */\r
46         VIDEO_IOCTL_GETSETMODE = 4,\r
47         \r
48         /**\r
49          * ioctl(..., tVideo_IOCtl_Mode *info)\r
50          * \brief Find a matching mode\r
51          * \return 1 if a mode was found, 0 otherwise\r
52          * \r
53          * Using avaliable modes matching the \a bpp and \a flags fields\r
54          * set the \a id field to the mode id of the mode with the closest\r
55          * \a width and \a height.\r
56          */\r
57         VIDEO_IOCTL_FINDMODE,\r
58         \r
59         /**\r
60          * ioctl(..., tVideo_IOCtl_Mode *info)\r
61          * \brief Get mode info\r
62          * \return 1 if the mode exists, 0 otherwise\r
63          * \r
64          * Set \a info's fields to the mode specified by the \a id field.\r
65          */\r
66         VIDEO_IOCTL_MODEINFO,\r
67         \r
68         /**\r
69          * ioctl(..., int *NewFormat)\r
70          * \brief Switches between Text, Framebuffer and 3D modes\r
71          * \param NewFormat     Pointer to the new format code (see eTplVideo_BufFormats)\r
72          * \return Original format\r
73          * \r
74          * Enabes and disables the video text mode, changing the behavior of\r
75          * writes to the device file.\r
76          */\r
77         VIDEO_IOCTL_SETBUFFORMAT,\r
78         \r
79         /**\r
80          * ioctl(..., tVideo_IOCtl_Pos *pos)\r
81          * \brief Sets the cursor position\r
82          * \return Boolean success\r
83          * \r
84          * Set the text mode cursor position (if it is supported)\r
85          * If the \a pos is set to (-1,-1) the cursor is hidden, otherwise\r
86          * \a pos MUST be within the current screen size (as given by the\r
87          * current mode's tVideo_IOCtl_Mode.width and tVideo_IOCtl_Mode.height\r
88          * fields).\r
89          */\r
90         VIDEO_IOCTL_SETCURSOR,\r
91         \r
92         /**\r
93          * ioctl(..., tVAddr MapTo)\r
94          * \brief Request access to Framebuffer\r
95          * \return Boolean Success\r
96          * \r
97          * Requests the driver to allow the user direct access to the\r
98          * framebuffer by mapping it to the supplied address.\r
99          * If the driver does not allow this boolean FALSE (0) is returned,\r
100          * else if the call succeeds (and the framebuffer ends up mapped) boolean\r
101          * TRUE (1) is returned.\r
102          */\r
103         VIDEO_IOCTL_REQLFB\r
104 };\r
105 #define DRV_VIDEO_IOCTLNAMES    "getset_mode", "find+mode", "mode_info", "set_buf_format", "set_cursor", "request_framebuffer"\r
106 \r
107 /**\r
108  * \brief Mode Structure used in IOCtl Calls\r
109  * \r
110  * Defines a video mode supported by (or requested of) this driver (depending\r
111  * on what ioctl call is used)\r
112  */\r
113 typedef struct sVideo_IOCtl_Mode\r
114 {\r
115         short   id;             //!< Mode ID\r
116         Uint16  width;  //!< Width\r
117         Uint16  height; //!< Height\r
118         Uint8   bpp;    //!< Bits per Unit (Character or Pixel, depending on \a flags)\r
119         Uint8   flags;  //!< Mode Flags\r
120 }       tVideo_IOCtl_Mode;\r
121 \r
122 /**\r
123  * \brief Buffer Format Codes\r
124  */\r
125 enum eTplVideo_BufFormats\r
126 {\r
127         /**\r
128          * \brief Text Mode\r
129          * \r
130          * The device file presents itself as an array of ::tVT_Char\r
131          * each describing a character cell on the screen.\r
132          * These cells are each \a giVT_CharWidth pixels wide and\r
133          * \a giVT_CharHeight high.\r
134          */\r
135         VIDEO_BUFFMT_TEXT,\r
136         /**\r
137          * \brief Framebuffer Mode\r
138          * \r
139          * The device file presents as an array of 32-bpp pixels describing\r
140          * the entire screen. The format of a single pixel is in xRGB format\r
141          * (top 8 bits ignored, next 8 bits red, next 8 bits green and\r
142          * the bottom 8 bits blue)\r
143          */\r
144         VIDEO_BUFFMT_FRAMEBUFFER,\r
145         /**\r
146          * \brief 2D Accelerated Mode\r
147          * \r
148          * The device file acts as a character device, accepting a stream of\r
149          * commands described in eTplVideo_2DCommands when written to.\r
150          */\r
151         VIDEO_BUFFMT_2DSTREAM,\r
152         /**\r
153          * \brief 3D Accelerated Mode\r
154          * \r
155          * The device file acts as a character device, accepting a stream of\r
156          * commands described in eTplVideo_3DCommands when written to.\r
157          */\r
158         VIDEO_BUFFMT_3DSTREAM\r
159 };\r
160 \r
161 /**\r
162  * \brief 2D Accellerated Video Commands\r
163  * \r
164  * Commands passed in the command stream for ::VIDEO_BUFFMT_2DSTREAM\r
165  */\r
166 enum eTplVideo_2DCommands\r
167 {\r
168         /**\r
169          * \brief No Operation\r
170          */\r
171         VIDEO_2DOP_NOP,\r
172         /**\r
173          * \brief Fill a region\r
174          * \param X     Uint16 - Leftmost pixels of the region\r
175          * \param Y     Uint16 - Topmost pixels of the region\r
176          * \param W     Uint16 - Width of the region\r
177          * \param H     Uint16 - Height of the region\r
178          * \param Colour        Uint32 - Value to fill with\r
179          */\r
180         VIDEO_2DOP_FILL,\r
181         /**\r
182          * \brief Copy a region from one part of the framebuffer to another\r
183          * \param DestX Uint16 - Leftmost pixels of the destination\r
184          * \param DestY Uint16 - Topmost pixels of the destination\r
185          * \param SrcX  Uint16 - Leftmost pixels of the source\r
186          * \param SrcY  Uint16 - Topmost pixels of the source\r
187          * \param Width Uint16 - Width of the region\r
188          * \param Height        Uint16 - Height of the region\r
189          */\r
190         VIDEO_2DOP_BLIT,\r
191 \r
192 \r
193         /**\r
194          * \brief Copy a region from video memory to the framebuffer\r
195          */\r
196         VIDEO_2DOP_BLITBUF,\r
197 \r
198         /**\r
199          * \brief Copy and scale a region from video memory to the framebuffer\r
200          */\r
201         VIDEO_2DOP_BLITSCALEBUF,\r
202 \r
203         NUM_VIDEO_2DOPS\r
204 };\r
205 \r
206 /**\r
207  * \brief Describes a position in the video framebuffer\r
208  */\r
209 typedef struct sVideo_IOCtl_Pos\r
210 {\r
211         Sint16  x;      //!< X Coordinate\r
212         Sint16  y;      //!< Y Coordinate\r
213 }       tVideo_IOCtl_Pos;\r
214 \r
215 /**\r
216  * \brief Virtual Terminal Representation of a character\r
217  */\r
218 typedef struct sVT_Char\r
219 {\r
220         Uint32  Ch;     //!< UTF-32 Character\r
221         union {\r
222                 struct {\r
223                         Uint16  BGCol;  //!< 12-bit Foreground Colour\r
224                         Uint16  FGCol;  //!< 12-bit Background Colour\r
225                 };\r
226                 Uint32  Colour; //!< Compound colour for ease of access\r
227         };\r
228 }       tVT_Char;\r
229 \r
230 /**\r
231  * \name Basic builtin colour definitions\r
232  * \{\r
233  */\r
234 #define VT_COL_BLACK    0x0000\r
235 #define VT_COL_GREY             0x0888\r
236 #define VT_COL_LTGREY   0x0CCC\r
237 #define VT_COL_WHITE    0x0FFF\r
238 /**\r
239  * \}\r
240  */\r
241 \r
242 //! \brief Defines the width of a rendered character\r
243 extern int      giVT_CharWidth;\r
244 //! \brief Defines the height of a rendered character\r
245 extern int      giVT_CharHeight;\r
246 /**\r
247  * \brief Driver helper that renders a character to a buffer\r
248  * \param Codepoint     Unicode character to render\r
249  * \param Buffer        Buffer to render to\r
250  * \param Depth Bit depth of the destination buffer\r
251  * \param Pitch Number of bytes per line\r
252  * \param BGC   32-bit Background Colour\r
253  * \param FGC   32-bit Foreground Colour\r
254  * \r
255  * This function is provided to help video drivers to support a simple\r
256  * text mode by keeping the character rendering abstracted from the driver,\r
257  * easing the driver development and reducing code duplication.\r
258  */\r
259 extern void     VT_Font_Render(Uint32 Codepoint, void *Buffer, int Depth, int Pitch, Uint32 BGC, Uint32 FGC);\r
260 /**\r
261  * \fn Uint32 VT_Colour12to24(Uint16 Col12)\r
262  * \brief Converts a colour from 12bpp to 24bpp\r
263  * \param Col12 12-bpp input colour\r
264  * \return Expanded 32-bpp (24-bit colour) version of \a Col12\r
265  */\r
266 extern Uint32   VT_Colour12to24(Uint16 Col12);\r
267 /**\r
268  * \brief Converts a colour from 12bpp to 14bpp\r
269  * \param Col12 12-bpp input colour\r
270  * \return 15 bits per pixel value\r
271  */\r
272 extern Uint16   VT_Colour12to15(Uint16 Col12);\r
273 /**\r
274  * \brief Converts a colour from 12bpp to 32bpp\r
275  * \param Col12 12-bpp input colour\r
276  * \param Depth Desired bit depth\r
277  * \return \a Depth bit number, denoting Col12\r
278  * \r
279  * Expands the source colour into a \a Depth bits per pixel representation.\r
280  * The colours are expanded with preference to Green, Blue and Red in that order\r
281  * (so, green gets the first spare pixel, blue gets the next, and red never gets\r
282  * the spare). \n\r
283  * The final bit of each component is used to fill the lower bits of the output.\r
284  */\r
285 extern Uint32   VT_Colour12toN(Uint16 Col12, int Depth);\r
286 \r
287 /**\r
288  * \brief Handlers for eTplVideo_2DCommands\r
289  */\r
290 typedef struct sDrvUtil_Video_2DHandlers\r
291 {\r
292         /**\r
293          * \brief No Operation, Ignored\r
294          * \see VIDEO_2DOP_NOP\r
295          */\r
296         void    *Nop;\r
297         /**\r
298          * \brief Fill a buffer region\r
299          * \param X     Lefthand edge\r
300          * \param Y     Top edge\r
301          * \param W     Width\r
302          * \param H     Height\r
303          * \param Colour        Colour to fill with\r
304          * \see VIDEO_2DOP_FILL\r
305          */\r
306         void    (*Fill)(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour);\r
307         /**\r
308          * \brief Fill a buffer region\r
309          * \param DestX Lefthand edge of destination\r
310          * \param DestY Top edge of destination\r
311          * \param SrcX  Lefthand edge of source\r
312          * \param SrcY  Top edge of source\r
313          * \param W     Width\r
314          * \param H     Height\r
315          * \see VIDEO_2DOP_BLIT\r
316          */\r
317         void    (*Blit)(void *Ent, Uint16 DestX, Uint16 DestY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H);\r
318 }       tDrvUtil_Video_2DHandlers;\r
319 \r
320 /**\r
321  * \brief Handle a 2D operation stream for a driver\r
322  * \param Ent   Value to pass to handlers\r
323  * \param Buffer        Stream buffer\r
324  * \param Length        Length of stream\r
325  * \param Handlers      Handlers to use for the stream\r
326  * \param SizeofHandlers        Size of \a tDrvUtil_Video_2DHandlers according\r
327  *        to the driver. Used as version control and error avoidence.\r
328  */\r
329 extern Uint64   DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,\r
330         tDrvUtil_Video_2DHandlers *Handlers, int SizeofHandlers);\r
331 \r
332 #endif\r

UCC git Repository :: git.ucc.asn.au