Added basic 2D video accelleration
[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  * In pallete colour modes the LFB is preceded by a 1024 byte pallete (allowing\r
19  * room for 256 entries of 32-bits each)\r
20  * Reading from the screen must either return zero, or read from the\r
21  * framebuffer.\r
22  * \r
23  * \section Mode Support\r
24  * All video drivers must support at least one text mode (Mode #0)\r
25  * For each graphics mode the driver exposes, there must be a corresponding\r
26  * text mode with the same resolution, this mode will be used when the\r
27  * user switches to a text Virtual Terminal while in graphics mode.\r
28  */\r
29 #ifndef _TPL_VIDEO_H\r
30 #define _TPL_VIDEO_H\r
31 \r
32 #include <tpl_drv_common.h>\r
33 \r
34 /**\r
35  * \enum eTplVideo_IOCtl\r
36  * \brief Common Video IOCtl Calls\r
37  * \extends eTplDrv_IOCtl\r
38  */\r
39 enum eTplVideo_IOCtl {\r
40         /**\r
41          * ioctl(..., int *mode)\r
42          * \brief Get/Set Mode\r
43          * \return Current mode ID or -1 on error\r
44          * \r
45          * If \a mode is non-NULL, the current video mode is set to \a *mode.\r
46          * This updated ID is then returned to the user.\r
47          */\r
48         VIDEO_IOCTL_GETSETMODE = 4,\r
49         \r
50         /**\r
51          * ioctl(..., tVideo_IOCtl_Mode *info)\r
52          * \brief Find a matching mode\r
53          * \return 1 if a mode was found, 0 otherwise\r
54          * \r
55          * Using avaliable modes matching the \a bpp and \a flags fields\r
56          * set the \a id field to the mode id of the mode with the closest\r
57          * \a width and \a height.\r
58          */\r
59         VIDEO_IOCTL_FINDMODE,\r
60         \r
61         /**\r
62          * ioctl(..., tVideo_IOCtl_Mode *info)\r
63          * \brief Get mode info\r
64          * \return 1 if the mode exists, 0 otherwise\r
65          * \r
66          * Set \a info's fields to the mode specified by the \a id field.\r
67          */\r
68         VIDEO_IOCTL_MODEINFO,\r
69         \r
70         /**\r
71          * ioctl(..., int *NewFormat)\r
72          * \brief Switches between Text, Framebuffer and 3D modes\r
73          * \param NewFormat     Pointer to the new format code (see eTplVideo_BufFormats)\r
74          * \return Original format\r
75          * \r
76          * Enabes and disables the video text mode, changing the behavior of\r
77          * writes to the device file.\r
78          */\r
79         VIDEO_IOCTL_SETBUFFORMAT,\r
80         \r
81         /**\r
82          * ioctl(..., tVideo_IOCtl_Pos *pos)\r
83          * \brief Sets the cursor position\r
84          * \return Boolean success\r
85          * \r
86          * Set the text mode cursor position (if it is supported)\r
87          * If the \a pos is set to (-1,-1) the cursor is hidden, otherwise\r
88          * \a pos MUST be within the current screen size (as given by the\r
89          * current mode's tVideo_IOCtl_Mode.width and tVideo_IOCtl_Mode.height\r
90          * fields).\r
91          */\r
92         VIDEO_IOCTL_SETCURSOR,\r
93         \r
94         /**\r
95          * ioctl(..., tVAddr MapTo)\r
96          * \brief Request access to Framebuffer\r
97          * \return Boolean Success\r
98          * \r
99          * Requests the driver to allow the user direct access to the\r
100          * framebuffer by mapping it to the supplied address.\r
101          * If the driver does not allow this boolean FALSE (0) is returned,\r
102          * else if the call succeeds (and the framebuffer ends up mapped) boolean\r
103          * TRUE (1) is returned.\r
104          */\r
105         VIDEO_IOCTL_REQLFB\r
106 };\r
107 \r
108 /**\r
109  * \brief Mode Structure used in IOCtl Calls\r
110  * \r
111  * Defines a video mode supported by (or requested of) this driver (depending\r
112  * on what ioctl call is used)\r
113  */\r
114 typedef struct sVideo_IOCtl_Mode\r
115 {\r
116         short   id;             //!< Mode ID\r
117         Uint16  width;  //!< Width\r
118         Uint16  height; //!< Height\r
119         Uint8   bpp;    //!< Bits per Unit (Character or Pixel, depending on \a flags)\r
120         Uint8   flags;  //!< Mode Flags\r
121 }       tVideo_IOCtl_Mode;\r
122 \r
123 /**\r
124  * \brief Buffer Format Codes\r
125  */\r
126 enum eTplVideo_BufFormats\r
127 {\r
128         /**\r
129          * \brief Text Mode\r
130          * \r
131          * The device file presents itself as an array of ::tVT_Char\r
132          * each describing a character cell on the screen.\r
133          * These cells are each \a giVT_CharWidth pixels wide and\r
134          * \a giVT_CharHeight high.\r
135          */\r
136         VIDEO_BUFFMT_TEXT,\r
137         /**\r
138          * \brief Framebuffer Mode\r
139          * \r
140          * The device file presents as an array of 32-bpp pixels describing\r
141          * the entire screen. The format of a single pixel is in xRGB format\r
142          * (top 8 bits ignored, next 8 bits red, next 8 bits green and\r
143          * the bottom 8 bits blue)\r
144          */\r
145         VIDEO_BUFFMT_FRAMEBUFFER,\r
146         /**\r
147          * \brief 2D Accelerated Mode\r
148          * \r
149          * The device file acts as a character device, accepting a stream of\r
150          * commands described in eTplVideo_2DCommands when written to.\r
151          */\r
152         VIDEO_BUFFMT_2DSTREAM,\r
153         /**\r
154          * \brief 3D Accelerated Mode\r
155          * \r
156          * The device file acts as a character device, accepting a stream of\r
157          * commands described in eTplVideo_3DCommands when written to.\r
158          */\r
159         VIDEO_BUFFMT_3DSTREAM\r
160 };\r
161 \r
162 /**\r
163  * \brief \r
164  */\r
165 enum eTplVideo_2DCommands\r
166 {\r
167         /**\r
168          * \brief No Operation\r
169          */\r
170         VIDEO_2DOP_NOP,\r
171         /**\r
172          * \brief Fill a region\r
173          * \param X     Uint16 - Leftmost pixels of the region\r
174          * \param Y     Uint16 - Topmost pixels of the region\r
175          * \param W     Uint16 - Width of the region\r
176          * \param H     Uint16 - Height of the region\r
177          * \param Colour        Uint32 - Value to fill with\r
178          */\r
179         VIDEO_2DOP_FILL,\r
180         /**\r
181          * \brief Copy a region from one part of the framebuffer to another\r
182          * \param DestX Uint16 - Leftmost pixels of the destination\r
183          * \param DestY Uint16 - Topmost pixels of the destination\r
184          * \param SrcX  Uint16 - Leftmost pixels of the source\r
185          * \param SrcY  Uint16 - Topmost pixels of the source\r
186          * \param Width Uint16 - Width of the region\r
187          * \param Height        Uint16 - Height of the region\r
188          */\r
189         VIDEO_2DOP_BLIT,\r
190 \r
191         NUM_VIDEO_2DOPS\r
192 };\r
193 \r
194 /**\r
195  * \brief Describes a position in the video framebuffer\r
196  */\r
197 typedef struct sVideo_IOCtl_Pos\r
198 {\r
199         Sint16  x;      //!< X Coordinate\r
200         Sint16  y;      //!< Y Coordinate\r
201 }       tVideo_IOCtl_Pos;\r
202 \r
203 /**\r
204  * \brief Virtual Terminal Representation of a character\r
205  */\r
206 typedef struct sVT_Char\r
207 {\r
208         Uint32  Ch;     //!< UTF-32 Character\r
209         union {\r
210                 struct {\r
211                         Uint16  BGCol;  //!< 12-bit Foreground Colour\r
212                         Uint16  FGCol;  //!< 12-bit Background Colour\r
213                 };\r
214                 Uint32  Colour; //!< Compound colour for ease of access\r
215         };\r
216 }       tVT_Char;\r
217 \r
218 /**\r
219  * \name Basic builtin colour definitions\r
220  * \{\r
221  */\r
222 #define VT_COL_BLACK    0x0000\r
223 #define VT_COL_GREY             0x0888\r
224 #define VT_COL_LTGREY   0x0CCC\r
225 #define VT_COL_WHITE    0x0FFF\r
226 /**\r
227  * \}\r
228  */\r
229 \r
230 //! \brief Defines the width of a rendered character\r
231 extern int      giVT_CharWidth;\r
232 //! \brief Defines the height of a rendered character\r
233 extern int      giVT_CharHeight;\r
234 /**\r
235  * \fn void VT_Font_Render(Uint32 Codepoint, void *Buffer, int Pitch, Uint32 BGC, Uint32 FGC)\r
236  * \brief Driver helper that renders a character to a buffer\r
237  * \param Codepoint     Unicode character to render\r
238  * \param Buffer        Buffer to render to (32-bpp)\r
239  * \param Pitch Number of DWords per line\r
240  * \param BGC   32-bit Background Colour\r
241  * \param FGC   32-bit Foreground Colour\r
242  * \r
243  * This function is provided to help video drivers to support a simple\r
244  * text mode by keeping the character rendering abstracted from the driver,\r
245  * easing the driver development and reducing code duplication.\r
246  */\r
247 extern void     VT_Font_Render(Uint32 Codepoint, void *Buffer, int Pitch, Uint32 BGC, Uint32 FGC);\r
248 /**\r
249  * \fn Uint32 VT_Colour12to24(Uint16 Col12)\r
250  * \brief Converts a colour from 12bpp to 32bpp\r
251  * \param Col12 12-bpp input colour\r
252  * \return Expanded 32-bpp (24-bit colour) version of \a Col12\r
253  */\r
254 extern Uint32   VT_Colour12to24(Uint16 Col12);\r
255 \r
256 /**\r
257  * \r
258  */\r
259 typedef struct sDrvUtil_Video_2DHandlers\r
260 {\r
261         void    *Nop;\r
262         void    (*Fill)(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour);\r
263         void    (*Blit)(void *Ent, Uint16 DestX, Uint16 DestY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H);\r
264 }       tDrvUtil_Video_2DHandlers;\r
265 \r
266 /**\r
267  * \brief \r
268  */\r
269 extern Uint64   DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,\r
270         tDrvUtil_Video_2DHandlers *Handlers, int SizeofHandlers);\r
271 \r
272 #endif\r

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