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(..., tVideo_IOCtl_Bitmap *Image)
\r
94 * \brief Sets the cursor image
\r
95 * \return Boolean success
\r
97 * Sets the graphics mode cursor image
\r
99 VIDEO_IOCTL_SETCURSORBITMAP
\r
101 #define DRV_VIDEO_IOCTLNAMES "getset_mode", "find+mode", "mode_info", "set_buf_format", "set_cursor", "set_cursor_bitmap"
\r
104 * \brief Mode Structure used in IOCtl Calls
\r
106 * Defines a video mode supported by (or requested of) this driver (depending
\r
107 * on what ioctl call is used)
\r
109 typedef struct sVideo_IOCtl_Mode
\r
111 short id; //!< Mode ID
\r
112 Uint16 width; //!< Width
\r
113 Uint16 height; //!< Height
\r
114 Uint8 bpp; //!< Bits per Unit (Character or Pixel, depending on \a flags)
\r
115 Uint8 flags; //!< Mode Flags
\r
116 } tVideo_IOCtl_Mode;
\r
119 * \brief Buffer Format Codes
\r
121 enum eTplVideo_BufFormats
\r
126 * The device file presents itself as an array of ::tVT_Char
\r
127 * each describing a character cell on the screen.
\r
128 * These cells are each \a giVT_CharWidth pixels wide and
\r
129 * \a giVT_CharHeight high.
\r
133 * \brief Framebuffer Mode
\r
135 * The device file presents as an array of 32-bpp pixels describing
\r
136 * the entire screen. The format of a single pixel is in xRGB format
\r
137 * (top 8 bits ignored, next 8 bits red, next 8 bits green and
\r
138 * the bottom 8 bits blue)
\r
140 VIDEO_BUFFMT_FRAMEBUFFER,
\r
142 * \brief 2D Accelerated Mode
\r
144 * The device file acts as a character device, accepting a stream of
\r
145 * commands described in eTplVideo_2DCommands when written to.
\r
147 VIDEO_BUFFMT_2DSTREAM,
\r
149 * \brief 3D Accelerated Mode
\r
151 * The device file acts as a character device, accepting a stream of
\r
152 * commands described in eTplVideo_3DCommands when written to.
\r
154 VIDEO_BUFFMT_3DSTREAM
\r
158 * \brief 2D Accellerated Video Commands
\r
160 * Commands passed in the command stream for ::VIDEO_BUFFMT_2DSTREAM
\r
162 enum eTplVideo_2DCommands
\r
165 * \brief No Operation
\r
169 * \brief Fill a region
\r
170 * \param X Uint16 - Leftmost pixels of the region
\r
171 * \param Y Uint16 - Topmost pixels of the region
\r
172 * \param W Uint16 - Width of the region
\r
173 * \param H Uint16 - Height of the region
\r
174 * \param Colour Uint32 - Value to fill with
\r
178 * \brief Copy a region from one part of the framebuffer to another
\r
179 * \param DestX Uint16 - Leftmost pixels of the destination
\r
180 * \param DestY Uint16 - Topmost pixels of the destination
\r
181 * \param SrcX Uint16 - Leftmost pixels of the source
\r
182 * \param SrcY Uint16 - Topmost pixels of the source
\r
183 * \param Width Uint16 - Width of the region
\r
184 * \param Height Uint16 - Height of the region
\r
190 * \brief Copy a region from video memory to the framebuffer
\r
192 VIDEO_2DOP_BLITBUF,
\r
195 * \brief Copy and scale a region from video memory to the framebuffer
\r
197 VIDEO_2DOP_BLITSCALEBUF,
\r
203 * \brief Describes a position in the video framebuffer
\r
205 typedef struct sVideo_IOCtl_Pos
\r
207 Sint16 x; //!< X Coordinate
\r
208 Sint16 y; //!< Y Coordinate
\r
209 } tVideo_IOCtl_Pos;
\r
212 * \brief Bitmap object (out of band image)
\r
214 typedef struct sVideo_IOCtl_Bitmap
\r
216 Sint16 W; //!< Width of image
\r
217 Sint16 H; //!< Height of image
\r
218 Sint16 XOfs; //!< X Offset of center
\r
219 Sint16 YOfs; //!< Y Offset of center
\r
220 Uint32 Data[]; //!< Image data (ARGB array)
\r
221 } tVideo_IOCtl_Bitmap;
\r
224 * \brief Virtual Terminal Representation of a character
\r
226 typedef struct sVT_Char
\r
228 Uint32 Ch; //!< UTF-32 Character
\r
231 Uint16 BGCol; //!< 12-bit Foreground Colour
\r
232 Uint16 FGCol; //!< 12-bit Background Colour
\r
234 Uint32 Colour; //!< Compound colour for ease of access
\r
239 * \name Basic builtin colour definitions
\r
242 #define VT_COL_BLACK 0x0000
\r
243 #define VT_COL_GREY 0x0888
\r
244 #define VT_COL_LTGREY 0x0CCC
\r
245 #define VT_COL_WHITE 0x0FFF
\r
250 //! \brief Defines the width of a rendered character
\r
251 extern int giVT_CharWidth;
\r
252 //! \brief Defines the height of a rendered character
\r
253 extern int giVT_CharHeight;
\r
255 * \brief Driver helper that renders a character to a buffer
\r
256 * \param Codepoint Unicode character to render
\r
257 * \param Buffer Buffer to render to
\r
258 * \param Depth Bit depth of the destination buffer
\r
259 * \param Pitch Number of bytes per line
\r
260 * \param BGC 32-bit Background Colour
\r
261 * \param FGC 32-bit Foreground Colour
\r
263 * This function is provided to help video drivers to support a simple
\r
264 * text mode by keeping the character rendering abstracted from the driver,
\r
265 * easing the driver development and reducing code duplication.
\r
267 extern void VT_Font_Render(Uint32 Codepoint, void *Buffer, int Depth, int Pitch, Uint32 BGC, Uint32 FGC);
\r
269 * \fn Uint32 VT_Colour12to24(Uint16 Col12)
\r
270 * \brief Converts a colour from 12bpp to 24bpp
\r
271 * \param Col12 12-bpp input colour
\r
272 * \return Expanded 32-bpp (24-bit colour) version of \a Col12
\r
274 extern Uint32 VT_Colour12to24(Uint16 Col12);
\r
276 * \brief Converts a colour from 12bpp to 14bpp
\r
277 * \param Col12 12-bpp input colour
\r
278 * \return 15 bits per pixel value
\r
280 extern Uint16 VT_Colour12to15(Uint16 Col12);
\r
282 * \brief Converts a colour from 12bpp to 32bpp
\r
283 * \param Col12 12-bpp input colour
\r
284 * \param Depth Desired bit depth
\r
285 * \return \a Depth bit number, denoting Col12
\r
287 * Expands the source colour into a \a Depth bits per pixel representation.
\r
288 * The colours are expanded with preference to Green, Blue and Red in that order
\r
289 * (so, green gets the first spare pixel, blue gets the next, and red never gets
\r
291 * The final bit of each component is used to fill the lower bits of the output.
\r
293 extern Uint32 VT_Colour12toN(Uint16 Col12, int Depth);
\r
296 * \brief Handlers for eTplVideo_2DCommands
\r
298 typedef struct sDrvUtil_Video_2DHandlers
\r
301 * \brief No Operation, Ignored
\r
302 * \see VIDEO_2DOP_NOP
\r
306 * \brief Fill a buffer region
\r
307 * \param X Lefthand edge
\r
308 * \param Y Top edge
\r
311 * \param Colour Colour to fill with
\r
312 * \see VIDEO_2DOP_FILL
\r
314 void (*Fill)(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour);
\r
316 * \brief Fill a buffer region
\r
317 * \param DestX Lefthand edge of destination
\r
318 * \param DestY Top edge of destination
\r
319 * \param SrcX Lefthand edge of source
\r
320 * \param SrcY Top edge of source
\r
323 * \see VIDEO_2DOP_BLIT
\r
325 void (*Blit)(void *Ent, Uint16 DestX, Uint16 DestY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H);
\r
326 } tDrvUtil_Video_2DHandlers;
\r
329 * \brief Handle a 2D operation stream for a driver
\r
330 * \param Ent Value to pass to handlers
\r
331 * \param Buffer Stream buffer
\r
332 * \param Length Length of stream
\r
333 * \param Handlers Handlers to use for the stream
\r
334 * \param SizeofHandlers Size of \a tDrvUtil_Video_2DHandlers according
\r
335 * to the driver. Used as version control and error avoidence.
\r
337 extern Uint64 DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,
\r
338 tDrvUtil_Video_2DHandlers *Handlers, int SizeofHandlers);
\r