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 * 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
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
29 #ifndef _TPL_VIDEO_H
\r
30 #define _TPL_VIDEO_H
\r
32 #include <tpl_drv_common.h>
\r
35 * \enum eTplVideo_IOCtl
\r
36 * \brief Common Video IOCtl Calls
\r
37 * \extends eTplDrv_IOCtl
\r
39 enum eTplVideo_IOCtl {
\r
41 * ioctl(..., int *mode)
\r
42 * \brief Get/Set Mode
\r
43 * \return Current mode ID or -1 on error
\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
48 VIDEO_IOCTL_GETSETMODE = 4,
\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
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
59 VIDEO_IOCTL_FINDMODE,
\r
62 * ioctl(..., tVideo_IOCtl_Mode *info)
\r
63 * \brief Get mode info
\r
64 * \return 1 if the mode exists, 0 otherwise
\r
66 * Set \a info's fields to the mode specified by the \a id field.
\r
68 VIDEO_IOCTL_MODEINFO,
\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
76 * Enabes and disables the video text mode, changing the behavior of
\r
77 * writes to the device file.
\r
79 VIDEO_IOCTL_SETBUFFORMAT,
\r
82 * ioctl(..., tVideo_IOCtl_Pos *pos)
\r
83 * \brief Sets the cursor position
\r
84 * \return Boolean success
\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
92 VIDEO_IOCTL_SETCURSOR,
\r
95 * ioctl(..., tVAddr MapTo)
\r
96 * \brief Request access to Framebuffer
\r
97 * \return Boolean Success
\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
109 * \brief Mode Structure used in IOCtl Calls
\r
111 * Defines a video mode supported by (or requested of) this driver (depending
\r
112 * on what ioctl call is used)
\r
114 typedef struct sVideo_IOCtl_Mode
\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
124 * \brief Buffer Format Codes
\r
126 enum eTplVideo_BufFormats
\r
129 VIDEO_BUFFMT_FRAMEBUFFER,
\r
130 VIDEO_BUFFMT_3DSTREAM
\r
134 * \brief Describes a position in the video framebuffer
\r
136 typedef struct sVideo_IOCtl_Pos
\r
138 Sint16 x; //!< X Coordinate
\r
139 Sint16 y; //!< Y Coordinate
\r
140 } tVideo_IOCtl_Pos;
\r
143 * \brief Virtual Terminal Representation of a character
\r
145 typedef struct sVT_Char
\r
147 Uint32 Ch; //!< UTF-32 Character
\r
150 Uint16 BGCol; //!< 12-bit Foreground Colour
\r
151 Uint16 FGCol; //!< 12-bit Background Colour
\r
153 Uint32 Colour; //!< Compound colour for ease of access
\r
158 * \name Basic builtin colour definitions
\r
161 #define VT_COL_BLACK 0x0000
\r
162 #define VT_COL_GREY 0x0888
\r
163 #define VT_COL_LTGREY 0x0CCC
\r
164 #define VT_COL_WHITE 0x0FFF
\r
169 //! \brief Defines the width of a rendered character
\r
170 extern int giVT_CharWidth;
\r
171 //! \brief Defines the height of a rendered character
\r
172 extern int giVT_CharHeight;
\r
174 * \fn void VT_Font_Render(Uint32 Codepoint, void *Buffer, int Pitch, Uint32 BGC, Uint32 FGC)
\r
175 * \brief Driver helper that renders a character to a buffer
\r
176 * \param Codepoint Unicode character to render
\r
177 * \param Buffer Buffer to render to (32-bpp)
\r
178 * \param Pitch Number of DWords per line
\r
179 * \param BGC 32-bit Background Colour
\r
180 * \param FGC 32-bit Foreground Colour
\r
182 * This function is provided to help video drivers to support a simple
\r
183 * text mode by keeping the character rendering abstracted from the driver,
\r
184 * easing the driver development and reducing code duplication.
\r
186 extern void VT_Font_Render(Uint32 Codepoint, void *Buffer, int Pitch, Uint32 BGC, Uint32 FGC);
\r
188 * \fn Uint32 VT_Colour12to24(Uint16 Col12)
\r
189 * \brief Converts a colour from 12bpp to 32bpp
\r
190 * \param Col12 12-bpp input colour
\r
191 * \return Expanded 32-bpp (24-bit colour) version of \a Col12
\r
193 extern Uint32 VT_Colour12to24(Uint16 Col12);
\r