Mercurial > ecos-v3_0-branch
annotate packages/io/framebuf/current/src/framebuf.c @ 2729:74dbf4c3f2e1 after-copyright-change-20090129
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
| author | jlarmour |
|---|---|
| date | Thu, 29 Jan 2009 17:47:46 +0000 |
| parents | f9d071633ee7 |
| children |
| rev | line source |
|---|---|
| 2565 | 1 //========================================================================== |
| 2 // | |
| 3 // framebuf.c | |
| 4 // | |
| 5 // Generic API for accessing framebuffers | |
| 6 // | |
| 7 //========================================================================== | |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
8 // ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
9 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
10 // This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
11 // Copyright (C) 2008 Free Software Foundation, Inc. |
| 2565 | 12 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
13 // eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
14 // the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
15 // Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
16 // version. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
17 // |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
18 // eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
21 // for more details. |
| 2565 | 22 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
23 // You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
24 // along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 2565 | 26 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
27 // As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
28 // macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
29 // and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
30 // this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
31 // the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
32 // must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
33 // General Public License v2. |
| 2565 | 34 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
35 // This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
36 // on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
37 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2565
diff
changeset
|
38 // ####ECOSGPLCOPYRIGHTEND#### |
| 2565 | 39 //========================================================================== |
| 40 //###DESCRIPTIONBEGIN#### | |
| 41 // | |
| 42 // Author(s): bartv | |
| 43 // Date: 2005-03-29 | |
| 44 // | |
| 45 //###DESCRIPTIONEND#### | |
| 46 //======================================================================== | |
| 47 | |
| 48 #define __CYG_FB_IN_FRAMEBUF_C 1 | |
| 49 #include <cyg/io/framebuf.h> | |
| 50 | |
| 51 #include <cyg/infra/cyg_type.h> | |
| 52 #include <cyg/infra/cyg_ass.h> | |
| 53 #include <errno.h> | |
| 54 | |
| 55 // Implementations of the framebuffer functions. Production code | |
| 56 // normally uses extern inline versions of these, defined in | |
| 57 // framebuf.h. However real functions are supplied here in case | |
| 58 // higher-level code chooses to take the address of a function for | |
| 59 // some reason. Also when building for debugging (CYGPKG_INFRA_DEBUG) | |
| 60 // the inline functions are suppressed and the real functions here | |
| 61 // contain lots of useful assertions. | |
| 62 | |
| 63 int | |
| 64 cyg_fb_on(cyg_fb* fb) | |
| 65 { | |
| 66 int result; | |
| 67 | |
| 68 CYG_CHECK_DATA_PTRC(fb); | |
| 69 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 70 CYG_CHECK_FUNC_PTRC(fb->fb_on_fn); | |
| 71 CYG_CHECK_FUNC_PTRC(fb->fb_off_fn); | |
| 72 CYG_CHECK_FUNC_PTRC(fb->fb_write_pixel_fn); | |
| 73 CYG_CHECK_FUNC_PTRC(fb->fb_read_pixel_fn); | |
| 74 CYG_CHECK_FUNC_PTRC(fb->fb_write_hline_fn); | |
| 75 CYG_CHECK_FUNC_PTRC(fb->fb_write_vline_fn); | |
| 76 CYG_CHECK_FUNC_PTRC(fb->fb_fill_block_fn); | |
| 77 CYG_CHECK_FUNC_PTRC(fb->fb_write_block_fn); | |
| 78 CYG_CHECK_FUNC_PTRC(fb->fb_read_block_fn); | |
| 79 CYG_CHECK_FUNC_PTRC(fb->fb_move_block_fn); | |
| 80 | |
| 81 result = (*(fb->fb_on_fn))(fb); | |
| 82 return result; | |
| 83 } | |
| 84 | |
| 85 int | |
| 86 cyg_fb_off(cyg_fb* fb) | |
| 87 { | |
| 88 int result; | |
| 89 | |
| 90 CYG_CHECK_DATA_PTRC(fb); | |
| 91 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 92 CYG_CHECK_FUNC_PTRC(fb->fb_off_fn); | |
| 93 | |
| 94 result = (*(fb->fb_off_fn))(fb); | |
| 95 return result; | |
| 96 } | |
| 97 | |
| 98 void | |
| 99 cyg_fb_write_pixel(cyg_fb* fb, cyg_ucount16 x, cyg_ucount16 y, cyg_fb_colour colour) | |
| 100 { | |
| 101 CYG_CHECK_DATA_PTRC(fb); | |
| 102 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 103 CYG_CHECK_FUNC_PTRC(fb->fb_write_pixel_fn); | |
| 104 | |
| 105 CYG_PRECONDITIONC(x < fb->fb_width); | |
| 106 CYG_PRECONDITIONC(y < fb->fb_height); | |
| 107 CYG_PRECONDITIONC((colour <= 1) || (fb->fb_depth > 1)); | |
| 108 CYG_PRECONDITIONC((colour <= 3) || (fb->fb_depth > 2)); | |
| 109 CYG_PRECONDITIONC((colour <= 15) || (fb->fb_depth > 4)); | |
| 110 CYG_PRECONDITIONC((colour <= 255) || (fb->fb_depth > 8)); | |
| 111 CYG_PRECONDITIONC((colour <= 65535) || (fb->fb_depth > 16)); | |
| 112 | |
| 113 (*(fb->fb_write_pixel_fn))(fb, x, y, colour); | |
| 114 } | |
| 115 | |
| 116 cyg_fb_colour | |
| 117 cyg_fb_read_pixel(cyg_fb* fb, cyg_ucount16 x, cyg_ucount16 y) | |
| 118 { | |
| 119 CYG_CHECK_DATA_PTRC(fb); | |
| 120 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 121 CYG_CHECK_FUNC_PTRC(fb->fb_read_pixel_fn); | |
| 122 | |
| 123 CYG_PRECONDITIONC(x < fb->fb_width); | |
| 124 CYG_PRECONDITIONC(y < fb->fb_height); | |
| 125 | |
| 126 return (*(fb->fb_read_pixel_fn))(fb, x, y); | |
| 127 } | |
| 128 | |
| 129 void | |
| 130 cyg_fb_write_hline(cyg_fb* fb, cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour) | |
| 131 { | |
| 132 CYG_CHECK_DATA_PTRC(fb); | |
| 133 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 134 CYG_CHECK_FUNC_PTRC(fb->fb_write_hline_fn); | |
| 135 | |
| 136 CYG_PRECONDITIONC(x < fb->fb_width); | |
| 137 CYG_PRECONDITIONC(y < fb->fb_height); | |
| 138 CYG_PRECONDITIONC((x + len) <= fb->fb_width); | |
| 139 CYG_PRECONDITIONC((colour <= 1) || (fb->fb_depth > 1)); | |
| 140 CYG_PRECONDITIONC((colour <= 3) || (fb->fb_depth > 2)); | |
| 141 CYG_PRECONDITIONC((colour <= 15) || (fb->fb_depth > 4)); | |
| 142 CYG_PRECONDITIONC((colour <= 255) || (fb->fb_depth > 8)); | |
| 143 CYG_PRECONDITIONC((colour <= 65535) || (fb->fb_depth > 16)); | |
| 144 | |
| 145 (*(fb->fb_write_hline_fn))(fb, x, y, len, colour); | |
| 146 } | |
| 147 | |
| 148 void | |
| 149 cyg_fb_write_vline(cyg_fb* fb, cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 len, cyg_fb_colour colour) | |
| 150 { | |
| 151 CYG_CHECK_DATA_PTRC(fb); | |
| 152 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 153 CYG_CHECK_FUNC_PTRC(fb->fb_write_vline_fn); | |
| 154 | |
| 155 CYG_PRECONDITIONC(x < fb->fb_width); | |
| 156 CYG_PRECONDITIONC(y < fb->fb_height); | |
| 157 CYG_PRECONDITIONC((y + len) <= fb->fb_height); | |
| 158 CYG_PRECONDITIONC((colour <= 1) || (fb->fb_depth > 1)); | |
| 159 CYG_PRECONDITIONC((colour <= 3) || (fb->fb_depth > 2)); | |
| 160 CYG_PRECONDITIONC((colour <= 15) || (fb->fb_depth > 4)); | |
| 161 CYG_PRECONDITIONC((colour <= 255) || (fb->fb_depth > 8)); | |
| 162 CYG_PRECONDITIONC((colour <= 65535) || (fb->fb_depth > 16)); | |
| 163 | |
| 164 (*(fb->fb_write_vline_fn))(fb, x, y, len, colour); | |
| 165 } | |
| 166 | |
| 167 void | |
| 168 cyg_fb_fill_block(cyg_fb* fb, cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height, cyg_fb_colour colour) | |
| 169 { | |
| 170 CYG_CHECK_DATA_PTRC(fb); | |
| 171 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 172 CYG_CHECK_FUNC_PTRC(fb->fb_fill_block_fn); | |
| 173 | |
| 174 CYG_PRECONDITIONC(x < fb->fb_width); | |
| 175 CYG_PRECONDITIONC(y < fb->fb_height); | |
| 176 CYG_PRECONDITIONC((x + width) <= fb->fb_width); | |
| 177 CYG_PRECONDITIONC((y + height) <= fb->fb_height); | |
| 178 CYG_PRECONDITIONC((colour <= 1) || (fb->fb_depth > 1)); | |
| 179 CYG_PRECONDITIONC((colour <= 3) || (fb->fb_depth > 2)); | |
| 180 CYG_PRECONDITIONC((colour <= 15) || (fb->fb_depth > 4)); | |
| 181 CYG_PRECONDITIONC((colour <= 255) || (fb->fb_depth > 8)); | |
| 182 CYG_PRECONDITIONC((colour <= 65535) || (fb->fb_depth > 16)); | |
| 183 | |
| 184 (*(fb->fb_fill_block_fn))(fb, x, y, width, height, colour); | |
| 185 } | |
| 186 | |
| 187 void | |
| 188 cyg_fb_write_block(cyg_fb* fb, cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height, | |
| 189 const void* source, cyg_ucount16 offset, cyg_ucount16 stride) | |
| 190 { | |
| 191 CYG_CHECK_DATA_PTRC(fb); | |
| 192 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 193 CYG_CHECK_FUNC_PTRC(fb->fb_write_block_fn); | |
| 194 | |
| 195 CYG_CHECK_DATA_PTRC(source); | |
| 196 CYG_PRECONDITIONC(x < fb->fb_width); | |
| 197 CYG_PRECONDITIONC(y < fb->fb_height); | |
| 198 CYG_PRECONDITIONC((x + width) <= fb->fb_width); | |
| 199 CYG_PRECONDITIONC((y + height) <= fb->fb_height); | |
| 200 | |
| 201 (*(fb->fb_write_block_fn))(fb, x, y, width, height, source, offset, stride); | |
| 202 } | |
| 203 | |
| 204 void | |
| 205 cyg_fb_read_block(cyg_fb* fb, cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height, | |
| 206 void* dest, cyg_ucount16 offset, cyg_ucount16 stride) | |
| 207 { | |
| 208 CYG_CHECK_DATA_PTRC(fb); | |
| 209 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 210 CYG_CHECK_FUNC_PTRC(fb->fb_read_block_fn); | |
| 211 | |
| 212 CYG_CHECK_DATA_PTRC(dest); | |
| 213 CYG_PRECONDITIONC(x < fb->fb_width); | |
| 214 CYG_PRECONDITIONC(y < fb->fb_height); | |
| 215 CYG_PRECONDITIONC((x + width) <= fb->fb_width); | |
| 216 CYG_PRECONDITIONC((y + height) <= fb->fb_height); | |
| 217 | |
| 218 (*(fb->fb_read_block_fn))(fb, x, y, width, height, dest, offset, stride); | |
| 219 } | |
| 220 | |
| 221 void | |
| 222 cyg_fb_move_block(cyg_fb* fb, cyg_ucount16 x, cyg_ucount16 y, cyg_ucount16 width, cyg_ucount16 height, cyg_ucount16 new_x, cyg_ucount16 new_y) | |
| 223 { | |
| 224 CYG_CHECK_DATA_PTRC(fb); | |
| 225 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 226 CYG_CHECK_FUNC_PTRC(fb->fb_move_block_fn); | |
| 227 | |
| 228 CYG_PRECONDITIONC(x != new_x); | |
| 229 CYG_PRECONDITIONC(y != new_y); | |
| 230 CYG_PRECONDITIONC(x < fb->fb_width); | |
| 231 CYG_PRECONDITIONC(y < fb->fb_height); | |
| 232 CYG_PRECONDITIONC((x + width) <= fb->fb_width); | |
| 233 CYG_PRECONDITIONC((y + height) <= fb->fb_height); | |
| 234 CYG_PRECONDITIONC(new_x < fb->fb_width); | |
| 235 CYG_PRECONDITIONC(new_y < fb->fb_height); | |
| 236 CYG_PRECONDITIONC((new_x + width) <= fb->fb_width); | |
| 237 CYG_PRECONDITIONC((new_y + height) <= fb->fb_height); | |
| 238 | |
| 239 (*(fb->fb_move_block_fn))(fb, x, y, width, height, new_x, new_y); | |
| 240 } | |
| 241 | |
| 242 int | |
| 243 cyg_fb_ioctl(cyg_fb* fb, cyg_uint16 key, void* data, size_t* len) | |
| 244 { | |
| 245 int result; | |
| 246 | |
| 247 CYG_CHECK_DATA_PTRC(fb); | |
| 248 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 249 CYG_CHECK_FUNC_PTRC(fb->fb_ioctl_fn); | |
| 250 | |
| 251 result = (*(fb->fb_ioctl_fn))(fb, key, data, len); | |
| 252 return result; | |
| 253 } | |
| 254 | |
| 255 void | |
| 256 cyg_fb_synch(cyg_fb* fb, cyg_ucount16 when) | |
| 257 { | |
| 258 #ifdef CYGHWR_IO_FRAMEBUF_FUNCTIONALITY_DOUBLE_BUFFER | |
| 259 CYG_CHECK_DATA_PTRC(fb); | |
| 260 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 261 CYG_CHECK_FUNC_PTRC(fb->fb_move_block_fn); | |
| 262 (*(fb->fb_synch_fn))(fb, when); | |
| 263 #else | |
| 264 // Synch is a no-op | |
| 265 #endif | |
| 266 } | |
| 267 | |
| 268 void | |
| 269 cyg_fb_read_palette(cyg_fb* fb, cyg_ucount32 first, cyg_ucount32 count, void* dest) | |
| 270 { | |
| 271 #ifdef CYGHWR_IO_FRAMEBUF_FUNCTIONALITY_PALETTE | |
| 272 CYG_CHECK_DATA_PTRC(fb); | |
| 273 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 274 CYG_CHECK_FUNC_PTRC(fb->fb_read_palette_fn); | |
| 275 CYG_CHECK_DATA_PTRC(dest); | |
| 276 | |
| 277 CYG_PRECONDITIONC( (first < 16) || (fb->fb_depth > 4)); | |
| 278 CYG_PRECONDITIONC(((first + count) < 16) || (fb->fb_depth > 4)); | |
| 279 CYG_PRECONDITIONC( (first < 256) || (fb->fb_depth > 8)); | |
| 280 CYG_PRECONDITIONC(((first + count) <= 256) || (fb->fb_depth > 8)); | |
| 281 | |
| 282 (*(fb->fb_read_palette_fn))(fb, first, count, dest); | |
| 283 #else | |
| 284 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 285 CYG_UNUSED_PARAM(cyg_ucount32, first); | |
| 286 CYG_UNUSED_PARAM(cyg_ucount32, count); | |
| 287 CYG_UNUSED_PARAM(void*, dest); | |
| 288 #endif | |
| 289 } | |
| 290 | |
| 291 void | |
| 292 cyg_fb_write_palette(cyg_fb* fb, cyg_ucount32 first, cyg_ucount32 count, const void* source, cyg_ucount16 when) | |
| 293 { | |
| 294 #ifdef CYGHWR_IO_FRAMEBUF_FUNCTIONALITY_WRITEABLE_PALETTE | |
| 295 CYG_CHECK_DATA_PTRC(fb); | |
| 296 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 297 CYG_CHECK_FUNC_PTRC(fb->fb_write_palette_fn); | |
| 298 CYG_CHECK_DATA_PTRC(source); | |
| 299 | |
| 300 CYG_PRECONDITIONC( (first < 16) || (fb->fb_depth > 4)); | |
| 301 CYG_PRECONDITIONC(((first + count) < 16) || (fb->fb_depth > 4)); | |
| 302 CYG_PRECONDITIONC( (first < 256) || (fb->fb_depth > 8)); | |
| 303 CYG_PRECONDITIONC(((first + count) <= 256) || (fb->fb_depth > 8)); | |
| 304 | |
| 305 (*(fb->fb_write_palette_fn))(fb, first, count, source, when); | |
| 306 #else | |
| 307 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 308 CYG_UNUSED_PARAM(cyg_ucount32, first); | |
| 309 CYG_UNUSED_PARAM(cyg_ucount32, count); | |
| 310 CYG_UNUSED_PARAM(const void*, source); | |
| 311 CYG_UNUSED_PARAM(cyg_ucount16, when); | |
| 312 #endif | |
| 313 } | |
| 314 | |
| 315 cyg_fb_colour | |
| 316 cyg_fb_make_colour(cyg_fb* fb, cyg_ucount8 r, cyg_ucount8 g, cyg_ucount8 b) | |
| 317 { | |
| 318 #ifdef CYGHWR_IO_FRAMEBUF_FUNCTIONALITY_TRUE_COLOUR | |
| 319 CYG_CHECK_DATA_PTRC(fb); | |
| 320 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 321 CYG_CHECK_FUNC_PTRC(fb->fb_make_colour_fn); | |
| 322 CYG_PRECONDITIONC((r <= 0x00FF) && (g <= 0x00FF) && (b <= 0x00FF)); | |
| 323 | |
| 324 return (*(fb->fb_make_colour_fn))(fb, r, g, b); | |
| 325 #else | |
| 326 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 327 CYG_UNUSED_PARAM(cyg_ucount8, r); | |
| 328 CYG_UNUSED_PARAM(cyg_ucount8, g); | |
| 329 CYG_UNUSED_PARAM(cyg_ucount8, b); | |
| 330 return 0; | |
| 331 #endif | |
| 332 } | |
| 333 | |
| 334 void | |
| 335 cyg_fb_break_colour(cyg_fb* fb, cyg_fb_colour colour, cyg_ucount8* r, cyg_ucount8* g, cyg_ucount8* b) | |
| 336 { | |
| 337 #ifdef CYGHWR_IO_FRAMEBUF_FUNCTIONALITY_TRUE_COLOUR | |
| 338 CYG_CHECK_DATA_PTRC(fb); | |
| 339 CYG_PRECONDITIONC(CYG_FB_MAGIC == fb->fb_magic); | |
| 340 CYG_CHECK_FUNC_PTRC(fb->fb_break_colour_fn); | |
| 341 CYG_CHECK_DATA_PTRC(r); | |
| 342 CYG_CHECK_DATA_PTRC(g); | |
| 343 CYG_CHECK_DATA_PTRC(b); | |
| 344 | |
| 345 (*(fb->fb_break_colour_fn))(fb, colour, r, g, b); | |
| 346 #else | |
| 347 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 348 CYG_UNUSED_PARAM(cyg_fb_colour, colour); | |
| 349 CYG_UNUSED_PARAM(cyg_ucount8*, r); | |
| 350 CYG_UNUSED_PARAM(cyg_ucount8*, g); | |
| 351 CYG_UNUSED_PARAM(cyg_ucount8*, b); | |
| 352 #endif | |
| 353 } | |
| 354 | |
| 355 // ---------------------------------------------------------------------------- | |
| 356 // Dummy functions for use by device drivers when instantiating a cyg_fb | |
| 357 // structure | |
| 358 | |
| 359 int | |
| 360 cyg_fb_nop_on(cyg_fb* fb) | |
| 361 { | |
| 362 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 363 return 0; | |
| 364 } | |
| 365 | |
| 366 int | |
| 367 cyg_fb_nop_off(cyg_fb* fb) | |
| 368 { | |
| 369 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 370 return 0; | |
| 371 } | |
| 372 | |
| 373 int | |
| 374 cyg_fb_nop_ioctl(cyg_fb* fb, cyg_uint16 key, void* data, size_t* len) | |
| 375 { | |
| 376 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 377 CYG_UNUSED_PARAM(cyg_uint16, key); | |
| 378 CYG_UNUSED_PARAM(void*, data); | |
| 379 CYG_UNUSED_PARAM(size_t*, len); | |
| 380 return ENOSYS; | |
| 381 } | |
| 382 | |
| 383 void | |
| 384 cyg_fb_nop_synch(cyg_fb* fb, cyg_ucount16 when) | |
| 385 { | |
| 386 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 387 CYG_UNUSED_PARAM(cyg_ucount16, when); | |
| 388 } | |
| 389 | |
| 390 void | |
| 391 cyg_fb_nop_write_palette(cyg_fb* fb, cyg_ucount32 first, cyg_ucount32 count, const void* source, cyg_ucount16 when) | |
| 392 { | |
| 393 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 394 CYG_UNUSED_PARAM(cyg_ucount32, first); | |
| 395 CYG_UNUSED_PARAM(cyg_ucount32, count); | |
| 396 CYG_UNUSED_PARAM(const void*, source); | |
| 397 CYG_UNUSED_PARAM(cyg_ucount16, when); | |
| 398 } | |
| 399 | |
| 400 void | |
| 401 cyg_fb_nop_read_palette(cyg_fb* fb, cyg_ucount32 first, cyg_ucount32 count, void* dest) | |
| 402 { | |
| 403 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 404 CYG_UNUSED_PARAM(cyg_ucount32, first); | |
| 405 CYG_UNUSED_PARAM(cyg_ucount32, count); | |
| 406 CYG_UNUSED_PARAM(void*, dest); | |
| 407 } | |
| 408 | |
| 409 cyg_fb_colour | |
| 410 cyg_fb_nop_make_colour(cyg_fb* fb, cyg_ucount8 r, cyg_ucount8 g, cyg_ucount8 b) | |
| 411 { | |
| 412 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 413 CYG_UNUSED_PARAM(cyg_ucount8, r); | |
| 414 CYG_UNUSED_PARAM(cyg_ucount8, g); | |
| 415 CYG_UNUSED_PARAM(cyg_ucount8, b); | |
| 416 return 0; | |
| 417 } | |
| 418 | |
| 419 cyg_fb_colour | |
| 420 cyg_fb_nop_make_color(cyg_fb* fb, cyg_ucount8 r, cyg_ucount8 g, cyg_ucount8 b) | |
| 421 __attribute__((alias("cyg_fb_nop_make_colour"))); | |
| 422 | |
| 423 void | |
| 424 cyg_fb_nop_break_colour(cyg_fb* fb, cyg_fb_colour colour, cyg_ucount8* r, cyg_ucount8* g, cyg_ucount8* b) | |
| 425 { | |
| 426 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 427 CYG_UNUSED_PARAM(cyg_fb_colour, colour); | |
| 428 CYG_UNUSED_PARAM(cyg_ucount8*, r); | |
| 429 CYG_UNUSED_PARAM(cyg_ucount8*, g); | |
| 430 CYG_UNUSED_PARAM(cyg_ucount8*, b); | |
| 431 } | |
| 432 | |
| 433 void | |
| 434 cyg_fb_nop_break_color(cyg_fb* fb, cyg_fb_colour colour, cyg_ucount8* r, cyg_ucount8* g, cyg_ucount8* b) | |
| 435 __attribute__((alias("cyg_fb_nop_break_colour"))); | |
| 436 | |
| 437 // ---------------------------------------------------------------------------- | |
| 438 // Utility functions for common true colour modes | |
| 439 | |
| 440 cyg_fb_colour | |
| 441 cyg_fb_dev_make_colour_8bpp_true_332(cyg_fb* fb, cyg_ucount8 r, cyg_ucount8 g, cyg_ucount8 b) | |
| 442 { | |
| 443 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 444 return CYG_FB_MAKE_COLOUR_8BPP_TRUE_332(r, g, b); | |
| 445 } | |
| 446 | |
| 447 void | |
| 448 cyg_fb_dev_break_colour_8bpp_true_332(cyg_fb* fb, cyg_fb_colour colour, cyg_ucount8* r, cyg_ucount8* g, cyg_ucount8* b) | |
| 449 { | |
| 450 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 451 CYG_FB_BREAK_COLOUR_8BPP_TRUE_332(colour, r, g, b); | |
| 452 } | |
| 453 | |
| 454 cyg_fb_colour | |
| 455 cyg_fb_dev_make_colour_16bpp_true_565(cyg_fb* fb, cyg_ucount8 r, cyg_ucount8 g, cyg_ucount8 b) | |
| 456 { | |
| 457 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 458 return CYG_FB_MAKE_COLOUR_16BPP_TRUE_565(r, g, b); | |
| 459 } | |
| 460 | |
| 461 void | |
| 462 cyg_fb_dev_break_colour_16bpp_true_565(cyg_fb* fb, cyg_fb_colour colour, cyg_ucount8* r, cyg_ucount8* g, cyg_ucount8* b) | |
| 463 { | |
| 464 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 465 CYG_FB_BREAK_COLOUR_16BPP_TRUE_565(colour, r, g, b); | |
| 466 } | |
| 467 | |
| 468 cyg_fb_colour | |
| 469 cyg_fb_dev_make_colour_16bpp_true_555(cyg_fb* fb, cyg_ucount8 r, cyg_ucount8 g, cyg_ucount8 b) | |
| 470 { | |
| 471 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 472 return CYG_FB_MAKE_COLOUR_16BPP_TRUE_555(r, g, b); | |
| 473 } | |
| 474 | |
| 475 void | |
| 476 cyg_fb_dev_break_colour_16bpp_true_555(cyg_fb* fb, cyg_fb_colour colour, cyg_ucount8* r, cyg_ucount8* g, cyg_ucount8* b) | |
| 477 { | |
| 478 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 479 CYG_FB_BREAK_COLOUR_16BPP_TRUE_555(colour, r, g, b); | |
| 480 } | |
| 481 | |
| 482 cyg_fb_colour | |
| 483 cyg_fb_dev_make_colour_32bpp_true_0888(cyg_fb* fb, cyg_ucount8 r, cyg_ucount8 g, cyg_ucount8 b) | |
| 484 { | |
| 485 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 486 return CYG_FB_MAKE_COLOUR_32BPP_TRUE_0888(r, g, b); | |
| 487 } | |
| 488 | |
| 489 void | |
| 490 cyg_fb_dev_break_colour_32bpp_true_0888(cyg_fb* fb, cyg_fb_colour colour, cyg_ucount8* r, cyg_ucount8* g, cyg_ucount8* b) | |
| 491 { | |
| 492 CYG_UNUSED_PARAM(cyg_fb*, fb); | |
| 493 CYG_FB_BREAK_COLOUR_32BPP_TRUE_0888(colour, r, g, b); | |
| 494 } | |
| 495 |
