endianess fixes of vc4 hidd...
[AROS.git] / arch / arm-native / soc / broadcom / 2708 / hidd / vc4gfx / vc4gfx_pixfmts.c
blob4f933d575314edc9f126a6307a60aa01b6fe2046
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 IPTR pftags_32bpp[ARRAYSIZE_TRUECOLOR] =
26 ARRAYSIZE_TRUECOLOR,
28 16,
29 24,
31 0x00FF0000,
32 0x0000FF00,
33 0x000000FF,
34 0x00000000,
35 32,
37 32,
38 vHidd_StdPixFmt_BGR032
40 #endif
42 #if defined(VC_FMT_24)
43 IPTR pftags_24bpp[ARRAYSIZE_TRUECOLOR] =
45 ARRAYSIZE_TRUECOLOR,
47 16,
48 24,
50 0x00FF0000,
51 0x0000FF00,
52 0x000000FF,
53 0x00000000,
54 24,
56 24,
57 vHidd_StdPixFmt_BGR24
59 #endif
61 #if defined(VC_FMT_16)
62 IPTR pftags_16bpp[ARRAYSIZE_TRUECOLOR] =
64 ARRAYSIZE_TRUECOLOR,
65 16,
66 21,
67 27,
69 0x0000F800,
70 0x000007E0,
71 0x0000001F,
72 0x00000000,
73 16,
75 16,
76 vHidd_StdPixFmt_RGB16_LE
78 #endif
80 #if defined(VC_FMT_15)
81 IPTR pftags_15bpp[ARRAYSIZE_TRUECOLOR] =
83 ARRAYSIZE_TRUECOLOR,
84 17,
85 22,
86 27,
88 0x00007C00,
89 0x000003E0,
90 0x0000001F,
91 0x00000000,
92 15,
94 15,
95 vHidd_StdPixFmt_RGB15_LE
97 #endif
99 #if defined(VC_FMT_8)
100 IPTR pftags_8bpp[ARRAYSIZE_LUT] =
102 ARRAYSIZE_LUT,
107 0x00FF0000,
108 0x0000FF00,
109 0x000000FF,
110 0x00000000,
111 0x000000FF,
116 vHidd_StdPixFmt_LUT8
118 #endif
120 IPTR vc_fmts[6] =
122 #if defined(VC_FMT_32)
123 (IPTR)pftags_32bpp,
124 #endif
125 #if defined(VC_FMT_24)
126 (IPTR)pftags_24bpp,
127 #endif
128 #if defined(VC_FMT_16)
129 (IPTR)pftags_16bpp,
130 #endif
131 #if defined(VC_FMT_15)
132 (IPTR)pftags_15bpp,
133 #endif
134 #if defined(VC_FMT_8)
135 (IPTR)pftags_8bpp,
136 #endif
140 APTR FNAME_SUPPORT(GenPixFmts)(OOP_Class *cl)
142 struct TagItem *pixfmtarray = NULL;
143 IPTR **supportedfmts = (IPTR**)vc_fmts;
144 int fmtcount = 0;
146 while (supportedfmts[fmtcount] != 0)
147 fmtcount++;
149 D(bug("[VideoCore] %s: Allocating storage for %d pixfmts\n", __PRETTY_FUNCTION__, fmtcount));
151 if ((pixfmtarray = AllocVec((fmtcount + 1) * sizeof(struct TagItem), MEMF_PUBLIC)) != NULL)
153 for (fmtcount = 0; supportedfmts[fmtcount] != 0; fmtcount++)
155 struct TagItem *newfmt_tags = NULL;
156 if (supportedfmts[fmtcount][0] == ARRAYSIZE_TRUECOLOR)
158 D(bug("[VideoCore] %s: %dbit TRUECOLOR pixfmt\n", __PRETTY_FUNCTION__, supportedfmts[fmtcount][9]));
159 newfmt_tags = AllocVec((ARRAYSIZE_TRUECOLOR + 2) * sizeof(struct TagItem), MEMF_PUBLIC);
160 newfmt_tags[0].ti_Tag = aHidd_PixFmt_RedShift;
161 newfmt_tags[0].ti_Data = supportedfmts[fmtcount][1];
162 newfmt_tags[1].ti_Tag = aHidd_PixFmt_GreenShift;
163 newfmt_tags[1].ti_Data = supportedfmts[fmtcount][2];
164 newfmt_tags[2].ti_Tag = aHidd_PixFmt_BlueShift;
165 newfmt_tags[2].ti_Data = supportedfmts[fmtcount][3];
166 newfmt_tags[3].ti_Tag = aHidd_PixFmt_AlphaShift;
167 newfmt_tags[3].ti_Data = supportedfmts[fmtcount][4];
168 newfmt_tags[4].ti_Tag = aHidd_PixFmt_RedMask;
169 newfmt_tags[4].ti_Data = supportedfmts[fmtcount][5];
170 newfmt_tags[5].ti_Tag = aHidd_PixFmt_GreenMask;
171 newfmt_tags[5].ti_Data = supportedfmts[fmtcount][6];
172 newfmt_tags[6].ti_Tag = aHidd_PixFmt_BlueMask;
173 newfmt_tags[6].ti_Data = supportedfmts[fmtcount][7];
174 newfmt_tags[7].ti_Tag = aHidd_PixFmt_AlphaMask;
175 newfmt_tags[7].ti_Data = supportedfmts[fmtcount][8];
176 newfmt_tags[8].ti_Tag = aHidd_PixFmt_ColorModel;
177 newfmt_tags[8].ti_Data = vHidd_ColorModel_TrueColor;
178 newfmt_tags[9].ti_Tag = aHidd_PixFmt_Depth;
179 newfmt_tags[9].ti_Data = supportedfmts[fmtcount][9];
180 newfmt_tags[10].ti_Tag = aHidd_PixFmt_BytesPerPixel;
181 newfmt_tags[10].ti_Data = supportedfmts[fmtcount][10];
182 newfmt_tags[11].ti_Tag = aHidd_PixFmt_BitsPerPixel;
183 newfmt_tags[11].ti_Data = supportedfmts[fmtcount][11];
184 newfmt_tags[12].ti_Tag = aHidd_PixFmt_StdPixFmt;
185 newfmt_tags[12].ti_Data = supportedfmts[fmtcount][12];
186 newfmt_tags[13].ti_Tag = aHidd_PixFmt_BitMapType;
187 newfmt_tags[13].ti_Data = vHidd_BitMapType_Chunky;
188 newfmt_tags[14].ti_Tag = TAG_DONE;
190 else if (supportedfmts[fmtcount][0] == ARRAYSIZE_LUT)
192 D(bug("[VideoCore] %s: %dbit LUT pixfmt\n", __PRETTY_FUNCTION__, supportedfmts[fmtcount][11]));
193 newfmt_tags = AllocVec((ARRAYSIZE_LUT + 2) * sizeof(struct TagItem), MEMF_PUBLIC);
194 newfmt_tags[0].ti_Tag = aHidd_PixFmt_RedShift;
195 newfmt_tags[0].ti_Data = supportedfmts[fmtcount][1];
196 newfmt_tags[1].ti_Tag = aHidd_PixFmt_GreenShift;
197 newfmt_tags[1].ti_Data = supportedfmts[fmtcount][2];
198 newfmt_tags[2].ti_Tag = aHidd_PixFmt_BlueShift;
199 newfmt_tags[2].ti_Data = supportedfmts[fmtcount][3];
200 newfmt_tags[3].ti_Tag = aHidd_PixFmt_AlphaShift;
201 newfmt_tags[3].ti_Data = supportedfmts[fmtcount][4];
202 newfmt_tags[4].ti_Tag = aHidd_PixFmt_RedMask;
203 newfmt_tags[4].ti_Data = supportedfmts[fmtcount][5];
204 newfmt_tags[5].ti_Tag = aHidd_PixFmt_GreenMask;
205 newfmt_tags[5].ti_Data = supportedfmts[fmtcount][6];
206 newfmt_tags[6].ti_Tag = aHidd_PixFmt_BlueMask;
207 newfmt_tags[6].ti_Data = supportedfmts[fmtcount][7];
208 newfmt_tags[7].ti_Tag = aHidd_PixFmt_AlphaMask;
209 newfmt_tags[7].ti_Data = supportedfmts[fmtcount][8];
210 newfmt_tags[8].ti_Tag = aHidd_PixFmt_CLUTMask;
211 newfmt_tags[8].ti_Data = supportedfmts[fmtcount][9];
212 newfmt_tags[9].ti_Tag = aHidd_PixFmt_CLUTShift;
213 newfmt_tags[9].ti_Data = supportedfmts[fmtcount][10];
214 newfmt_tags[10].ti_Tag = aHidd_PixFmt_ColorModel;
215 newfmt_tags[10].ti_Data = vHidd_ColorModel_Palette;
216 newfmt_tags[11].ti_Tag = aHidd_PixFmt_Depth;
217 newfmt_tags[11].ti_Data = supportedfmts[fmtcount][11];
218 newfmt_tags[12].ti_Tag = aHidd_PixFmt_BytesPerPixel;
219 newfmt_tags[12].ti_Data = supportedfmts[fmtcount][12];
220 newfmt_tags[13].ti_Tag = aHidd_PixFmt_BitsPerPixel;
221 newfmt_tags[13].ti_Data = supportedfmts[fmtcount][13];
222 newfmt_tags[14].ti_Tag = aHidd_PixFmt_StdPixFmt;
223 newfmt_tags[14].ti_Data = supportedfmts[fmtcount][14];
224 newfmt_tags[15].ti_Tag = aHidd_PixFmt_BitMapType;
225 newfmt_tags[15].ti_Data = vHidd_BitMapType_Chunky;
226 newfmt_tags[16].ti_Tag = TAG_DONE;
228 else
230 D(bug("[VideoCore] %s: ERROR - Unhandled pixfmt\n", __PRETTY_FUNCTION__));
231 supportedfmts++;
232 continue;
234 pixfmtarray[fmtcount].ti_Tag = aHidd_Gfx_PixFmtTags;
235 pixfmtarray[fmtcount].ti_Data = (IPTR)newfmt_tags;
237 pixfmtarray[fmtcount].ti_Tag = TAG_DONE;
239 #if defined(DEBUGPIXFMT)
240 if (pixfmtarray)
242 struct TagItem *cur_pixfmt = pixfmtarray;
243 while (cur_pixfmt->ti_Tag != TAG_DONE)
245 D(bug("[VideoCoreGfx] %s: 0x%p: %08x, %08x\n", __PRETTY_FUNCTION__, cur_pixfmt, cur_pixfmt->ti_Tag, cur_pixfmt->ti_Data));
246 cur_pixfmt++;
249 #endif
250 return (APTR)pixfmtarray;