2 * \file tpl_drv_video.h
\r
3 * \brief Video Driver Interface Definitions
\r
4 * \note For AcessOS Version 1
\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
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
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
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
27 #ifndef _TPL_VIDEO_H
\r
28 #define _TPL_VIDEO_H
\r
30 #include <tpl_drv_common.h>
\r
33 * \enum eTplVideo_IOCtl
\r
34 * \brief Common Video IOCtl Calls
\r
35 * \extends eTplDrv_IOCtl
\r
37 enum eTplVideo_IOCtl {
\r
39 * ioctl(..., int *mode)
\r
40 * \brief Get/Set Mode
\r
41 * \return Current mode ID or -1 on error
\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
46 VIDEO_IOCTL_GETSETMODE = 4,
\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
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
57 VIDEO_IOCTL_FINDMODE,
\r
60 * ioctl(..., tVideo_IOCtl_Mode *info)
\r
61 * \brief Get mode info
\r
62 * \return 1 if the mode exists, 0 otherwise
\r
64 * Set \a info's fields to the mode specified by the \a id field.
\r
66 VIDEO_IOCTL_MODEINFO,
\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
74 * Enabes and disables the video text mode, changing the behavior of
\r
75 * writes to the device file.
\r
77 VIDEO_IOCTL_SETBUFFORMAT,
\r
80 * ioctl(..., tVideo_IOCtl_Pos *pos)
\r
81 * \brief Sets the cursor position
\r
82 * \return Boolean success
\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
90 VIDEO_IOCTL_SETCURSOR,
\r
93 * ioctl(..., tVAddr MapTo)
\r
94 * \brief Request access to Framebuffer
\r
95 * \return Boolean Success
\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
105 #define DRV_VIDEO_IOCTLNAMES "getset_mode", "find+mode", "mode_info", "set_buf_format", "set_cursor", "request_framebuffer"
\r
108 * \brief Mode Structure used in IOCtl Calls
\r
110 * Defines a video mode supported by (or requested of) this driver (depending
\r
111 * on what ioctl call is used)
\r
113 typedef struct sVideo_IOCtl_Mode
\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
123 * \brief Buffer Format Codes
\r
125 enum eTplVideo_BufFormats
\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
137 * \brief Framebuffer Mode
\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
144 VIDEO_BUFFMT_FRAMEBUFFER,
\r
146 * \brief 2D Accelerated Mode
\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
151 VIDEO_BUFFMT_2DSTREAM,
\r
153 * \brief 3D Accelerated Mode
\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
158 VIDEO_BUFFMT_3DSTREAM
\r
162 * \brief 2D Accellerated Video Commands
\r
164 * Commands passed in the command stream for ::VIDEO_BUFFMT_2DSTREAM
\r
166 enum eTplVideo_2DCommands
\r
169 * \brief No Operation
\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
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
194 * \brief Copy a region from video memory to the framebuffer
\r
196 VIDEO_2DOP_BLITBUF,
\r
199 * \brief Copy and scale a region from video memory to the framebuffer
\r
201 VIDEO_2DOP_BLITSCALEBUF,
\r
207 * \brief Describes a position in the video framebuffer
\r
209 typedef struct sVideo_IOCtl_Pos
\r
211 Sint16 x; //!< X Coordinate
\r
212 Sint16 y; //!< Y Coordinate
\r
213 } tVideo_IOCtl_Pos;
\r
216 * \brief Virtual Terminal Representation of a character
\r
218 typedef struct sVT_Char
\r
220 Uint32 Ch; //!< UTF-32 Character
\r
223 Uint16 BGCol; //!< 12-bit Foreground Colour
\r
224 Uint16 FGCol; //!< 12-bit Background Colour
\r
226 Uint32 Colour; //!< Compound colour for ease of access
\r
231 * \name Basic builtin colour definitions
\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
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
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
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
259 extern void VT_Font_Render(Uint32 Codepoint, void *Buffer, int Depth, int Pitch, Uint32 BGC, Uint32 FGC);
\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
266 extern Uint32 VT_Colour12to24(Uint16 Col12);
\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
272 extern Uint16 VT_Colour12to15(Uint16 Col12);
\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
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
283 * The final bit of each component is used to fill the lower bits of the output.
\r
285 extern Uint32 VT_Colour12toN(Uint16 Col12, int Depth);
\r
288 * \brief Handlers for eTplVideo_2DCommands
\r
290 typedef struct sDrvUtil_Video_2DHandlers
\r
293 * \brief No Operation, Ignored
\r
294 * \see VIDEO_2DOP_NOP
\r
298 * \brief Fill a buffer region
\r
299 * \param X Lefthand edge
\r
300 * \param Y Top edge
\r
303 * \param Colour Colour to fill with
\r
304 * \see VIDEO_2DOP_FILL
\r
306 void (*Fill)(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour);
\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
315 * \see VIDEO_2DOP_BLIT
\r
317 void (*Blit)(void *Ent, Uint16 DestX, Uint16 DestY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H);
\r
318 } tDrvUtil_Video_2DHandlers;
\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
329 extern Uint64 DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,
\r
330 tDrvUtil_Video_2DHandlers *Handlers, int SizeofHandlers);
\r