revert between 56095 -> 55830 in arch
[AROS.git] / arch / arm-native / soc / broadcom / 2708 / hidd / vc4gfx / vc4gfx_pixfmts.c
blob51f63f0b2772573d91f41a11827034faeb200457
1 /*
2 Copyright © 2013-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 1
7 #include <aros/debug.h>
9 #define __OOP_NOATTRBASES__
11 #include <proto/oop.h>
12 #include <proto/utility.h>
13 #include <assert.h>
14 #include <graphics/gfx.h>
15 #include <hidd/gfx.h>
16 #include <oop/oop.h>
18 #include "vc4gfx_hidd.h"
20 #define ARRAYSIZE_TRUECOLOR 13
21 #define ARRAYSIZE_LUT 15
23 #if defined(VC_FMT_32)
24 #if AROS_BIG_ENDIAN
25 IPTR pftags_32bpp[ARRAYSIZE_TRUECOLOR] =
27 ARRAYSIZE_TRUECOLOR,
28 16,
31 24,
32 0x0000FF00,
33 0x00FF0000,
34 0xFF000000,
35 0x000000FF,
36 32,
38 32,
39 vHidd_StdPixFmt_BGR032
41 #else
42 IPTR pftags_32bpp[ARRAYSIZE_TRUECOLOR] =
44 ARRAYSIZE_TRUECOLOR,
47 16,
48 24,
49 0xFF000000,
50 0x00FF0000,
51 0x0000FF00,
52 0x000000FF,
53 32,
55 32,
56 vHidd_StdPixFmt_RGB032
58 #endif
59 #endif
61 #if defined(VC_FMT_24)
62 #if AROS_BIG_ENDIAN
63 IPTR pftags_24bpp[ARRAYSIZE_TRUECOLOR] =
65 ARRAYSIZE_TRUECOLOR,
68 16,
70 0x000000FF,
71 0x0000FF00,
72 0x00FF0000,
73 0x00000000,
74 24,
76 24,
77 vHidd_StdPixFmt_RGB24
79 #else
80 IPTR pftags_24bpp[ARRAYSIZE_TRUECOLOR] =
82 ARRAYSIZE_TRUECOLOR,
84 16,
85 24,
87 0x00FF0000,
88 0x0000FF00,
89 0x000000FF,
90 0x00000000,
91 24,
93 24,
94 vHidd_StdPixFmt_BGR24
96 #endif
97 #endif
99 #if defined(VC_FMT_16)
100 IPTR pftags_16bpp[ARRAYSIZE_TRUECOLOR] =
102 ARRAYSIZE_TRUECOLOR,
107 0x0000F800,
108 0x000007E0,
109 0x0000001F,
110 0x00000000,
114 vHidd_StdPixFmt_RGB16_LE
116 #endif
118 #if defined(VC_FMT_15)
119 IPTR pftags_15bpp[ARRAYSIZE_TRUECOLOR] =
121 ARRAYSIZE_TRUECOLOR,
126 0x00007C00,
127 0x000003E0,
128 0x0000001F,
129 0x00000000,
133 vHidd_StdPixFmt_RGB15_LE
135 #endif
137 #if defined(VC_FMT_8)
138 IPTR pftags_8bpp[ARRAYSIZE_LUT] =
140 ARRAYSIZE_LUT,
145 0x00FF0000,
146 0x0000FF00,
147 0x000000FF,
148 0x00000000,
149 0x000000FF,
154 vHidd_StdPixFmt_LUT8
156 #endif
158 IPTR vc_fmts[6] =
160 #if defined(VC_FMT_32)
161 (IPTR)pftags_32bpp,
162 #endif
163 #if defined(VC_FMT_24)
164 (IPTR)pftags_24bpp,
165 #endif
166 #if defined(VC_FMT_16)
167 (IPTR)pftags_16bpp,
168 #endif
169 #if defined(VC_FMT_15)
170 (IPTR)pftags_15bpp,
171 #endif
172 #if defined(VC_FMT_8)
173 (IPTR)pftags_8bpp,
174 #endif
178 APTR FNAME_SUPPORT(GenPixFmts)(OOP_Class *cl)
180 struct TagItem *pixfmtarray = NULL;
181 IPTR **supportedfmts = (IPTR**)vc_fmts;
182 int fmtcount = 0;
184 while (supportedfmts[fmtcount] != 0)
185 fmtcount++;
187 D(bug("[VideoCore] %s: Allocating storage for %d pixfmts\n", __PRETTY_FUNCTION__, fmtcount));
189 if ((pixfmtarray = AllocVec((fmtcount + 1) * sizeof(struct TagItem), MEMF_PUBLIC)) != NULL)
191 for (fmtcount = 0; supportedfmts[fmtcount] != 0; fmtcount++)
193 struct TagItem *newfmt_tags = NULL;
194 if (supportedfmts[fmtcount][0] == ARRAYSIZE_TRUECOLOR)
196 D(bug("[VideoCore] %s: %dbit TRUECOLOR pixfmt\n", __PRETTY_FUNCTION__, supportedfmts[fmtcount][9]));
197 newfmt_tags = AllocVec((ARRAYSIZE_TRUECOLOR + 2) * sizeof(struct TagItem), MEMF_PUBLIC);
198 newfmt_tags[0].ti_Tag = aHidd_PixFmt_RedShift;
199 newfmt_tags[0].ti_Data = supportedfmts[fmtcount][1];
200 newfmt_tags[1].ti_Tag = aHidd_PixFmt_GreenShift;
201 newfmt_tags[1].ti_Data = supportedfmts[fmtcount][2];
202 newfmt_tags[2].ti_Tag = aHidd_PixFmt_BlueShift;
203 newfmt_tags[2].ti_Data = supportedfmts[fmtcount][3];
204 newfmt_tags[3].ti_Tag = aHidd_PixFmt_AlphaShift;
205 newfmt_tags[3].ti_Data = supportedfmts[fmtcount][4];
206 newfmt_tags[4].ti_Tag = aHidd_PixFmt_RedMask;
207 newfmt_tags[4].ti_Data = supportedfmts[fmtcount][5];
208 newfmt_tags[5].ti_Tag = aHidd_PixFmt_GreenMask;
209 newfmt_tags[5].ti_Data = supportedfmts[fmtcount][6];
210 newfmt_tags[6].ti_Tag = aHidd_PixFmt_BlueMask;
211 newfmt_tags[6].ti_Data = supportedfmts[fmtcount][7];
212 newfmt_tags[7].ti_Tag = aHidd_PixFmt_AlphaMask;
213 newfmt_tags[7].ti_Data = supportedfmts[fmtcount][8];
214 newfmt_tags[8].ti_Tag = aHidd_PixFmt_ColorModel;
215 newfmt_tags[8].ti_Data = vHidd_ColorModel_TrueColor;
216 newfmt_tags[9].ti_Tag = aHidd_PixFmt_Depth;
217 newfmt_tags[9].ti_Data = supportedfmts[fmtcount][9];
218 newfmt_tags[10].ti_Tag = aHidd_PixFmt_BytesPerPixel;
219 newfmt_tags[10].ti_Data = supportedfmts[fmtcount][10];
220 newfmt_tags[11].ti_Tag = aHidd_PixFmt_BitsPerPixel;
221 newfmt_tags[11].ti_Data = supportedfmts[fmtcount][11];
222 newfmt_tags[12].ti_Tag = aHidd_PixFmt_StdPixFmt;
223 newfmt_tags[12].ti_Data = supportedfmts[fmtcount][12];
224 newfmt_tags[13].ti_Tag = aHidd_PixFmt_BitMapType;
225 newfmt_tags[13].ti_Data = vHidd_BitMapType_Chunky;
226 newfmt_tags[14].ti_Tag = TAG_DONE;
228 else if (supportedfmts[fmtcount][0] == ARRAYSIZE_LUT)
230 D(bug("[VideoCore] %s: %dbit LUT pixfmt\n", __PRETTY_FUNCTION__, supportedfmts[fmtcount][11]));
231 newfmt_tags = AllocVec((ARRAYSIZE_LUT + 2) * sizeof(struct TagItem), MEMF_PUBLIC);
232 newfmt_tags[0].ti_Tag = aHidd_PixFmt_RedShift;
233 newfmt_tags[0].ti_Data = supportedfmts[fmtcount][1];
234 newfmt_tags[1].ti_Tag = aHidd_PixFmt_GreenShift;
235 newfmt_tags[1].ti_Data = supportedfmts[fmtcount][2];
236 newfmt_tags[2].ti_Tag = aHidd_PixFmt_BlueShift;
237 newfmt_tags[2].ti_Data = supportedfmts[fmtcount][3];
238 newfmt_tags[3].ti_Tag = aHidd_PixFmt_AlphaShift;
239 newfmt_tags[3].ti_Data = supportedfmts[fmtcount][4];
240 newfmt_tags[4].ti_Tag = aHidd_PixFmt_RedMask;
241 newfmt_tags[4].ti_Data = supportedfmts[fmtcount][5];
242 newfmt_tags[5].ti_Tag = aHidd_PixFmt_GreenMask;
243 newfmt_tags[5].ti_Data = supportedfmts[fmtcount][6];
244 newfmt_tags[6].ti_Tag = aHidd_PixFmt_BlueMask;
245 newfmt_tags[6].ti_Data = supportedfmts[fmtcount][7];
246 newfmt_tags[7].ti_Tag = aHidd_PixFmt_AlphaMask;
247 newfmt_tags[7].ti_Data = supportedfmts[fmtcount][8];
248 newfmt_tags[8].ti_Tag = aHidd_PixFmt_CLUTMask;
249 newfmt_tags[8].ti_Data = supportedfmts[fmtcount][9];
250 newfmt_tags[9].ti_Tag = aHidd_PixFmt_CLUTShift;
251 newfmt_tags[9].ti_Data = supportedfmts[fmtcount][10];
252 newfmt_tags[10].ti_Tag = aHidd_PixFmt_ColorModel;
253 newfmt_tags[10].ti_Data = vHidd_ColorModel_Palette;
254 newfmt_tags[11].ti_Tag = aHidd_PixFmt_Depth;
255 newfmt_tags[11].ti_Data = supportedfmts[fmtcount][11];
256 newfmt_tags[12].ti_Tag = aHidd_PixFmt_BytesPerPixel;
257 newfmt_tags[12].ti_Data = supportedfmts[fmtcount][12];
258 newfmt_tags[13].ti_Tag = aHidd_PixFmt_BitsPerPixel;
259 newfmt_tags[13].ti_Data = supportedfmts[fmtcount][13];
260 newfmt_tags[14].ti_Tag = aHidd_PixFmt_StdPixFmt;
261 newfmt_tags[14].ti_Data = supportedfmts[fmtcount][14];
262 newfmt_tags[15].ti_Tag = aHidd_PixFmt_BitMapType;
263 newfmt_tags[15].ti_Data = vHidd_BitMapType_Chunky;
264 newfmt_tags[16].ti_Tag = TAG_DONE;
266 else
268 D(bug("[VideoCore] %s: ERROR - Unhandled pixfmt\n", __PRETTY_FUNCTION__));
269 supportedfmts++;
270 continue;
272 pixfmtarray[fmtcount].ti_Tag = aHidd_Gfx_PixFmtTags;
273 pixfmtarray[fmtcount].ti_Data = (IPTR)newfmt_tags;
275 pixfmtarray[fmtcount].ti_Tag = TAG_DONE;
277 #if defined(DEBUGPIXFMT)
278 if (pixfmtarray)
280 struct TagItem *cur_pixfmt = pixfmtarray;
281 while (cur_pixfmt->ti_Tag != TAG_DONE)
283 D(bug("[VideoCoreGfx] %s: 0x%p: %08x, %08x\n", __PRETTY_FUNCTION__, cur_pixfmt, cur_pixfmt->ti_Tag, cur_pixfmt->ti_Data));
284 cur_pixfmt++;
287 #endif
288 return (APTR)pixfmtarray;