Big Changes - See commit details
[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  * Reads and 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 */\r
21 #ifndef _TPL_VIDEO_H\r
22 #define _TPL_VIDEO_H\r
23 \r
24 #include <tpl_drv_common.h>\r
25 \r
26 /**\r
27  * \enum eTplVideo_IOCtl\r
28  * \brief Common Video IOCtl Calls\r
29  * \extends eTplDrv_IOCtl\r
30  */\r
31 enum eTplVideo_IOCtl {\r
32         /**\r
33          * ioctl(..., int *mode)\r
34          * \brief Get/Set Mode\r
35          * \return Current mode ID or -1 on error\r
36          * \r
37          * If \a mode is non-NULL, the current video mode is set to \a *mode.\r
38          * This updated ID is then returned to the user.\r
39          */\r
40         VIDEO_IOCTL_GETSETMODE = 4,\r
41         \r
42         /**\r
43          * ioctl(..., tVideo_IOCtl_Mode *info)\r
44          * \brief Find a matching mode\r
45          * \return 1 if a mode was found, 0 otherwise\r
46          * \r
47          * Using avaliable modes matching the \a bpp and \a flags fields\r
48          * set the \a id field to the mode id of the mode with the closest\r
49          * \a width and \a height.\r
50          */\r
51         VIDEO_IOCTL_FINDMODE,\r
52         \r
53         /**\r
54          * ioctl(..., tVideo_IOCtl_Mode *info)\r
55          * \brief Get mode info\r
56          * \return 1 if the mode exists, 0 otherwise\r
57          * \r
58          * Set \a info's fields to the mode specified by the \a id field.\r
59          */\r
60         VIDEO_IOCTL_MODEINFO,\r
61         \r
62         /**\r
63          * ioctl(..., tVideo_IOCtl_Pos *pos)\r
64          * \brief Sets the cursor position\r
65          * \return Boolean success\r
66          * \r
67          * Set the text mode cursor position (if it is supported)\r
68          * If the \a pos is set to (-1,-1) the cursor is hidden, otherwise\r
69          * \a pos MUST be within the current screen size (as given by the\r
70          * current mode's tVideo_IOCtl_Mode.width and tVideo_IOCtl_Mode.height\r
71          * fields).\r
72          */\r
73         VIDEO_IOCTL_SETCURSOR,\r
74         \r
75         /**\r
76          * ioctl(..., tVAddr MapTo)\r
77          * \brief Request access to Framebuffer\r
78          * \return Boolean Success\r
79          * \r
80          * Requests the driver to allow the user direct access to the\r
81          * framebuffer by mapping it to the supplied address.\r
82          * If the driver does not allow this boolean FALSE (0) is returned,\r
83          * else if the call succeeds (and the framebuffer ends up mapped) boolean\r
84          * TRUE (1) is returned.\r
85          */\r
86         VIDEO_IOCTL_REQLFB\r
87 };\r
88 \r
89 /**\r
90  * \brief Mode Structure used in IOCtl Calls\r
91  * \r
92  * Defines a video mode supported by (or requested of) this driver (depending\r
93  * on what ioctl call is used)\r
94  */\r
95 typedef struct sVideo_IOCtl_Mode\r
96 {\r
97         short   id;             //!< Mode ID\r
98         Uint16  width;  //!< Width\r
99         Uint16  height; //!< Height\r
100         Uint8   bpp;    //!< Bits per Unit (Character or Pixel, depending on \a flags)\r
101         Uint8   flags;  //!< Mode Flags\r
102 }       tVideo_IOCtl_Mode;\r
103 \r
104 //! \name Video Mode flags\r
105 //! \{\r
106 /**\r
107  * \brief Text Mode Flag\r
108  * \note A text mode should have the ::sVideo_IOCtl_Mode.bpp set to 12\r
109  */\r
110 #define VIDEO_FLAG_TEXT 0x1\r
111 /**\r
112  * \brief Slow (non-accellerated mode)\r
113  */\r
114 #define VIDEO_FLAG_SLOW 0x2\r
115 //! \}\r
116 \r
117 /**\r
118  * \brief Describes a position in the video framebuffer\r
119  */\r
120 typedef struct sVideo_IOCtl_Pos\r
121 {\r
122         Sint16  x;      //!< X Coordinate\r
123         Sint16  y;      //!< Y Coordinate\r
124 }       tVideo_IOCtl_Pos;\r
125 \r
126 /**\r
127  * \brief Virtual Terminal Representation of a character\r
128  */\r
129 typedef struct sVT_Char\r
130 {\r
131         Uint32  Ch;     //!< UTF-32 Character\r
132         union {\r
133                 struct {\r
134                         Uint16  BGCol;  //!< 12-bit Foreground Colour\r
135                         Uint16  FGCol;  //!< 12-bit Background Colour\r
136                 };\r
137                 Uint32  Colour; //!< Compound colour for ease of access\r
138         };\r
139 }       tVT_Char;\r
140 \r
141 /**\r
142  * \name Basic builtin colour definitions\r
143  * \{\r
144  */\r
145 #define VT_COL_BLACK    0x0000\r
146 #define VT_COL_GREY             0x0888\r
147 #define VT_COL_LTGREY   0x0CCC\r
148 #define VT_COL_WHITE    0x0FFF\r
149 /**\r
150  * \}\r
151  */\r
152 \r
153 //! \brief Defines the width of a rendered character\r
154 extern int      giVT_CharWidth;\r
155 //! \brief Defines the height of a rendered character\r
156 extern int      giVT_CharHeight;\r
157 /**\r
158  * \fn void VT_Font_Render(Uint32 Codepoint, void *Buffer, int Pitch, Uint32 BGC, Uint32 FGC)\r
159  * \brief Driver helper that renders a character to a buffer\r
160  * \param Codepoint     Unicode character to render\r
161  * \param Buffer        Buffer to render to (32-bpp)\r
162  * \param Pitch Number of DWords per line\r
163  * \param BGC   32-bit Background Colour\r
164  * \param FGC   32-bit Foreground Colour\r
165  * \r
166  * This function is provided to help video drivers to support a simple\r
167  * text mode by keeping the character rendering abstracted from the driver,\r
168  * easing the driver development and reducing code duplication.\r
169  */\r
170 extern void     VT_Font_Render(Uint32 Codepoint, void *Buffer, int Pitch, Uint32 BGC, Uint32 FGC);\r
171 /**\r
172  * \fn Uint32 VT_Colour12to24(Uint16 Col12)\r
173  * \brief Converts a colour from 12bpp to 32bpp\r
174  * \param Col12 12-bpp input colour\r
175  * \return Expanded 32-bpp (24-bit colour) version of \a Col12\r
176  */\r
177 extern Uint32   VT_Colour12to24(Uint16 Col12);\r
178 \r
179 #endif\r

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