2 * \file api_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 api_drv_common.h
\r
7 * and must support the IOCtl numbers defined in this file to be
\r
8 * compatable with Acess (drivers may implement more IOCtls above
\r
9 * DRV_IOCTL_USERMIN).
\r
12 * As said, a compatable driver must implement these calls correctly,
\r
13 * but they may choose not to allow direct user access to the framebuffer.
\r
15 * \section Screen Contents
\r
16 * Writes to the driver's file while in component colour modes
\r
17 * must correspond to a change of the contents of the screen. The framebuffer
\r
18 * must start at offset 0 in the file.
\r
19 * Reading from the screen must either return zero, or read from the
\r
22 * \section Mode Support
\r
23 * All video drivers must support text output for every resolution (hardware
\r
24 * accelerated or software), and at least the _BLIT and _FILL 2D operations
\r
25 * (these may be implemented specifically for text mode).
\r
27 #ifndef _API_DRV_VIDEO_H
\r
28 #define _API_DRV_VIDEO_H
\r
30 #include <api_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, \a width and \a heights fields to the closest
\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
103 * \brief Symbolic names for Video IOCtls (#4 onwards)
\r
105 #define DRV_VIDEO_IOCTLNAMES "getset_mode", "find_mode", "mode_info", "set_buf_format", "set_cursor", "set_cursor_bitmap"
\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 pixel
\r
119 Uint8 flags; //!< Mode Flags (none defined, should be zero)
\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 Bitmap object (out of band image)
\r
218 typedef struct sVideo_IOCtl_Bitmap
\r
220 Sint16 W; //!< Width of image
\r
221 Sint16 H; //!< Height of image
\r
222 Sint16 XOfs; //!< X Offset of center
\r
223 Sint16 YOfs; //!< Y Offset of center
\r
224 Uint32 Data[]; //!< Image data (ARGB array)
\r
225 } tVideo_IOCtl_Bitmap;
\r
228 * \brief Virtual Terminal Representation of a character
\r
230 typedef struct sVT_Char
\r
232 Uint32 Ch; //!< UTF-32 Character
\r
235 Uint16 BGCol; //!< 12-bit Foreground Colour
\r
236 Uint16 FGCol; //!< 12-bit Background Colour
\r
238 Uint32 Colour; //!< Compound colour for ease of access
\r
243 * \name Basic builtin colour definitions
\r
246 #define VT_COL_BLACK 0x0000
\r
247 #define VT_COL_GREY 0x0888
\r
248 #define VT_COL_LTGREY 0x0CCC
\r
249 #define VT_COL_WHITE 0x0FFF
\r
254 //! \brief Defines the width of a rendered character
\r
255 extern int giVT_CharWidth;
\r
256 //! \brief Defines the height of a rendered character
\r
257 extern int giVT_CharHeight;
\r
259 * \name Font rendering
\r
263 * \brief Driver helper that renders a character to a buffer
\r
264 * \param Codepoint Unicode character to render
\r
265 * \param Buffer Buffer to render to
\r
266 * \param Depth Bit depth of the destination buffer
\r
267 * \param Pitch Number of bytes per line
\r
268 * \param BGC 32-bit Background Colour
\r
269 * \param FGC 32-bit Foreground Colour
\r
271 * This function is provided to help video drivers to support a simple
\r
272 * text mode by keeping the character rendering abstracted from the driver,
\r
273 * easing the driver development and reducing code duplication.
\r
275 extern void VT_Font_Render(Uint32 Codepoint, void *Buffer, int Depth, int Pitch, Uint32 BGC, Uint32 FGC);
\r
277 * \fn Uint32 VT_Colour12to24(Uint16 Col12)
\r
278 * \brief Converts a colour from 12bpp to 24bpp
\r
279 * \param Col12 12-bpp input colour
\r
280 * \return Expanded 32-bpp (24-bit colour) version of \a Col12
\r
282 extern Uint32 VT_Colour12to24(Uint16 Col12);
\r
284 * \brief Converts a colour from 12bpp to 14bpp
\r
285 * \param Col12 12-bpp input colour
\r
286 * \return 15 bits per pixel value
\r
288 extern Uint16 VT_Colour12to15(Uint16 Col12);
\r
290 * \brief Converts a colour from 12bpp to 32bpp
\r
291 * \param Col12 12-bpp input colour
\r
292 * \param Depth Desired bit depth
\r
293 * \return \a Depth bit number, denoting Col12
\r
295 * Expands the source colour into a \a Depth bits per pixel representation.
\r
296 * The colours are expanded with preference to Green, Blue and Red in that order
\r
297 * (so, green gets the first spare pixel, blue gets the next, and red never gets
\r
299 * The final bit of each component is used to fill the lower bits of the output.
\r
301 extern Uint32 VT_Colour12toN(Uint16 Col12, int Depth);
\r
307 * \brief Maximum cursor width for using the DrvUtil software cursor
\r
309 #define DRVUTIL_MAX_CURSOR_W 32
\r
311 * \brief Maximum cursor width for using the DrvUtil software cursor
\r
313 #define DRVUTIL_MAX_CURSOR_H 32
\r
316 * \brief Framebuffer information used by all DrvUtil_Video functions
\r
318 typedef struct sDrvUtil_Video_BufInfo
\r
321 * \name Framebuffer state
\r
325 * \brief Framebuffer virtual address
\r
329 * \brief Bytes between the start of each line
\r
333 * \brief Number of pixels in each line
\r
337 * \brief Total number of lines
\r
341 * \brief Bit depth of the framebuffer
\r
349 * \brief Buffer write format
\r
351 short BufferFormat;
\r
354 * \name Software cursor controls
\r
358 * \brief X coordinate of the cursor
\r
362 * \brief Y coordinate of the cursor
\r
367 * \brief Cursor bitmap
\r
369 tVideo_IOCtl_Bitmap *CursorBitmap;
\r
375 * \name Internal fields
\r
380 * \brief Buffer to store the area under the cursor
\r
382 void *CursorSaveBuf;
\r
384 int CursorReadX; //!< X offset in cursor bitmap corresponding to \a CursorDestX
\r
385 int CursorReadY; //!< Same as \a CursorReadX but for Y
\r
386 int CursorRenderW; //!< Width of rendered cursor
\r
387 int CursorRenderH; //!< Height of rendered cursor
\r
388 int CursorDestX; //!< X coordinate Destination for rendered cursor
\r
389 int CursorDestY; //!< Y coordinate destination for rendered cursor
\r
394 } tDrvUtil_Video_BufInfo;
\r
397 * \brief Handlers for eTplVideo_2DCommands
\r
399 typedef struct sDrvUtil_Video_2DHandlers
\r
402 * \brief No Operation, Ignored
\r
403 * \see VIDEO_2DOP_NOP
\r
407 * \brief Fill a buffer region
\r
408 * \param X Lefthand edge
\r
409 * \param Y Top edge
\r
412 * \param Colour Colour to fill with
\r
413 * \see VIDEO_2DOP_FILL
\r
415 void (*Fill)(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour);
\r
417 * \brief Fill a buffer region
\r
418 * \param DestX Lefthand edge of destination
\r
419 * \param DestY Top edge of destination
\r
420 * \param SrcX Lefthand edge of source
\r
421 * \param SrcY Top edge of source
\r
424 * \see VIDEO_2DOP_BLIT
\r
426 void (*Blit)(void *Ent, Uint16 DestX, Uint16 DestY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H);
\r
427 } tDrvUtil_Video_2DHandlers;
\r
430 * \brief Handle a 2D operation stream for a driver
\r
431 * \param Ent Value to pass to handlers
\r
432 * \param Buffer Stream buffer
\r
433 * \param Length Length of stream
\r
434 * \param Handlers Handlers to use for the stream
\r
435 * \param SizeofHandlers Size of \a tDrvUtil_Video_2DHandlers according
\r
436 * to the driver. Used as version control and error avoidence.
\r
438 extern int DrvUtil_Video_2DStream(void *Ent, void *Buffer, int Length,
\r
439 tDrvUtil_Video_2DHandlers *Handlers, int SizeofHandlers);
\r
442 * \brief Perform write operations to a LFB
\r
443 * \param FBInfo Framebuffer descriptor, see type for details
\r
444 * \param Offset Offset provided by VFS call
\r
445 * \param Length Length provided by VFS call
\r
446 * \param Src Data from VFS call
\r
447 * \return Number of bytes written
\r
449 * Handles all write modes in software, using the VT font calls for rendering.
\r
450 * \note Calls the cursor clear and redraw if the cursor area is touched
\r
452 extern int DrvUtil_Video_WriteLFB(tDrvUtil_Video_BufInfo *FBInfo, size_t Offset, size_t Length, void *Src);
\r
455 * \name Software cursor rendering
\r
459 * \brief Set the cursor bitmap for a buffer
\r
460 * \param Buf Framebuffer descriptor
\r
461 * \param Bitmap New cursor bitmap
\r
463 extern int DrvUtil_Video_SetCursor(tDrvUtil_Video_BufInfo *Buf, tVideo_IOCtl_Bitmap *Bitmap);
\r
465 * \brief Render the cursor at (\a X, \a Y)
\r
466 * \param Buf Framebuffer descriptor, see type for details
\r
467 * \param X X coord of the cursor
\r
468 * \param Y Y coord of the cursor
\r
470 extern void DrvUtil_Video_DrawCursor(tDrvUtil_Video_BufInfo *Buf, int X, int Y);
\r
472 * \brief Removes the rendered cursor from the screen
\r
473 * \param Buf Framebuffer descriptor, see type for details
\r
475 extern void DrvUtil_Video_RemoveCursor(tDrvUtil_Video_BufInfo *Buf);
\r
478 * \brief Text mode cursor image
\r
480 extern tVideo_IOCtl_Bitmap gDrvUtil_TextModeCursor;
\r