2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
5 Desc: Graphics function GetDisplayInfoData()
11 #include <aros/debug.h>
12 #include <proto/graphics.h>
13 #include <graphics/displayinfo.h>
14 #include <hidd/graphics.h>
15 #include <proto/oop.h>
18 #include "graphics_intern.h"
21 /****************************************************************************************/
23 static const ULONG size_checks
[] =
25 sizeof(struct DisplayInfo
),
26 sizeof(struct DimensionInfo
),
27 sizeof(struct MonitorInfo
),
28 sizeof(struct NameInfo
),
33 static ULONG
check_sizes(ULONG tagID
, ULONG size
);
34 static ULONG
compute_numbits(HIDDT_Pixel mask
);
36 #define DLONGSZ (sizeof (ULONG) * 2)
37 #define DTAG_TO_IDX(dtag) (((dtag) & 0x7FFFF000) >> 12)
39 /*****************************************************************************
42 #include <proto/graphics.h>
44 AROS_LH5(ULONG
, GetDisplayInfoData
,
47 AROS_LHA(DisplayInfoHandle
, handle
, A0
),
48 AROS_LHA(UBYTE
*, buf
, A1
),
49 AROS_LHA(ULONG
, size
, D0
),
50 AROS_LHA(ULONG
, tagID
, D1
),
51 AROS_LHA(ULONG
, ID
, D2
),
54 struct GfxBase
*, GfxBase
, 126, Graphics
)
57 Fills buffer with information about displayinfo handle.
60 handle - displayinfo handle
61 buf - pointer to destination buffer
62 size - buffer size in bytes
63 tagID - data chunk type
64 DTAG_DISP (DisplayInfo)
65 DTAG_DIMS (DimensionInfo)
66 DTAG_MNTR (MonitorInfo)
68 ID - displayinfo identifier, optionally used if handle is NULL
71 result - if positive, number of bytes actually transferred
72 if zero, no information for ID was available
81 FindDisplayInfo(), NextDisplayInfo(), graphics/displayinfo.h
84 This function provides the following private parameters:
85 DimensionInfo.reserved[0] - driver user data (intuition's monitorclass object)
86 DimensionInfo.reserved[1] - pixelformat object
87 Do not rely on this in end user software! This is private to AROS and
88 subject to change at any time!
92 ******************************************************************************/
96 struct QueryHeader
*qh
;
98 OOP_Object
*gfxhidd
, *sync
, *pf
;
99 HIDDT_ModeID hiddmode
;
100 struct HIDD_ModeProperties HIDDProps
= {0};
103 /* FindDisplayInfo() handles INVALID_ID itself */
104 handle
= FindDisplayInfo(ID
);
107 D(bug("!!! COULD NOT GET HANDLE IN GetDisplayInfoData()\n"));
111 gfxhidd
= DIH(handle
)->drv
->gfxhidd
;
112 hiddmode
= DIH(handle
)->id
;
114 /* Get mode info from the HIDD */
115 if (!HIDD_Gfx_GetMode(gfxhidd
, hiddmode
, &sync
, &pf
))
117 D(bug("NO VALID MODE PASSED TO GetDisplayInfoData() !!!\n"));
121 D(bug("GetDisplayInfoData(handle=%d, tagID=%x)\n"
122 , (ULONG
)handle
, tagID
));
124 /* Build the queryheader */
125 structsize
= check_sizes(tagID
, size
);
128 qh
= AllocMem(structsize
, MEMF_CLEAR
);
132 /* Fill in the queryheader */
133 qh
->StructID
= tagID
;
135 qh
->SkipID
= TAG_SKIP
;
137 qh
->Length
= (structsize
+ (DLONGSZ
- 1)) / DLONGSZ
;
143 struct DisplayInfo
*di
;
144 IPTR redmask
, greenmask
, bluemask
;
147 HIDD_Gfx_ModeProperties(gfxhidd
, hiddmode
, &HIDDProps
, sizeof(HIDDProps
));
149 di
= (struct DisplayInfo
*)qh
;
151 /* All modes returned from the HIDD are available */
152 di
->NotAvailable
= FALSE
;
154 /* Set the propertyflags,
155 Note that we enforce some flags because we emulate these features by software */
156 di
->PropertyFlags
= DIPF_IS_FOREIGN
| DIPF_IS_WB
| DIPF_IS_SPRITES
| DIPF_IS_DBUFFER
| HIDDProps
.DisplayInfoFlags
;
158 /* Too many colors to count here. This field is really obsolete */
159 di
->PaletteRange
= 65535;
161 /* Compute red green and blue bits */
162 OOP_GetAttr(pf
, aHidd_PixFmt_RedMask
, &redmask
);
163 OOP_GetAttr(pf
, aHidd_PixFmt_GreenMask
, &greenmask
);
164 OOP_GetAttr(pf
, aHidd_PixFmt_BlueMask
, &bluemask
);
166 di
->RedBits
= compute_numbits(redmask
);
167 di
->GreenBits
= compute_numbits(greenmask
);
168 di
->BlueBits
= compute_numbits(bluemask
);
170 OOP_GetAttr(sync
, aHidd_Sync_PixelClock
, &pixclk
);
172 /* FIXME: don't know what to put here */
173 di
->Resolution
.x
= 22;
174 di
->Resolution
.y
= 22;
177 di
->PixelSpeed
= 1000000000 / pixclk
;
179 /* We can emulate one sprite via software, because it's necessary for mouse pointer. */
180 di
->NumStdSprites
= (HIDDProps
.DisplayInfoFlags
& DIPF_IS_SPRITES
) ? HIDDProps
.NumHWSprites
: 1;
182 /* At the moment sprites always have the same resolution as display */
183 di
->SpriteResolution
= di
->Resolution
;
190 struct DimensionInfo
*di
;
191 IPTR depth
, width
, height
;
192 IPTR minwidth
, minheight
;
193 IPTR maxwidth
, maxheight
;
195 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
196 OOP_GetAttr(sync
, aHidd_Sync_HDisp
, &width
);
197 OOP_GetAttr(sync
, aHidd_Sync_VDisp
, &height
);
198 OOP_GetAttr(sync
, aHidd_Sync_HMin
, &minwidth
);
199 OOP_GetAttr(sync
, aHidd_Sync_VMin
, &minheight
);
200 OOP_GetAttr(sync
, aHidd_Sync_HMax
, &maxwidth
);
201 OOP_GetAttr(sync
, aHidd_Sync_VMax
, &maxheight
);
203 di
= (struct DimensionInfo
*)qh
;
204 di
->MaxDepth
= depth
;
206 di
->MinRasterWidth
= minwidth
;
207 di
->MinRasterHeight
= minheight
;
208 di
->MaxRasterWidth
= maxwidth
;
209 di
->MaxRasterHeight
= maxheight
;
211 di
->Nominal
.MinX
= 0;
212 di
->Nominal
.MinY
= 0;
213 di
->Nominal
.MaxX
= width
- 1;
214 di
->Nominal
.MaxY
= height
- 1;
216 di
->MaxOScan
= di
->Nominal
;
217 di
->VideoOScan
= di
->Nominal
;
218 di
->TxtOScan
= di
->Nominal
;
219 di
->StdOScan
= di
->Nominal
;
221 di->MaxOScan.MinX = di->Nominal.MinX;
222 di->MaxOScan.MinY = di->Nominal.MinY;
223 di->MaxOScan.MaxX = di->Nominal.MaxX;
224 di->MaxOScan.MaxY = di->Nominal.MaxY;
226 di->VideoOScan.MinX = di->Nominal.MinX;
227 di->VideoOScan.MinY = di->Nominal.MinY;
228 di->VideoOScan.MaxX = di->Nominal.MaxX;
229 di->VideoOScan.MaxY = di->Nominal.MaxY;
231 di->TxtOScan.MinX = di->Nominal.MinX;
232 di->TxtOScan.MinY = di->Nominal.MinY;
233 di->TxtOScan.MaxX = di->Nominal.MaxX;
234 di->TxtOScan.MaxY = di->Nominal.MaxY;
236 di->StdOScan.MinX = di->Nominal.MinX;
237 di->StdOScan.MinY = di->Nominal.MinY;
238 di->StdOScan.MaxX = di->Nominal.MaxX;
239 di->StdOScan.MaxY = di->Nominal.MaxY;
241 di
->reserved
[0] = (IPTR
)DIH(handle
)->drv
->userdata
;
242 di
->reserved
[1] = (IPTR
)pf
;
249 struct MonitorInfo
*mi
;
251 HIDD_Gfx_ModeProperties(gfxhidd
, hiddmode
, &HIDDProps
, sizeof(HIDDProps
));
253 mi
= (struct MonitorInfo
*)qh
;
255 OOP_GetAttr(sync
, aHidd_Sync_MonitorSpec
, (IPTR
*)&mi
->Mspc
);
258 mi->ViewPosition.X = ?;
259 mi->ViewPosition.Y = ?;
260 mi->ViewResolution.X = ?;
261 mi->ViewResolution.Y = ?;
263 mi->MouseTicks.X = ?;
264 mi->MouseTicks.Y = ?;
265 mi->DefaultViewPosition.X = ?;
266 mi->DefaultViewPosition.Y = ?;
270 mi
->TotalRows
= mi
->Mspc
->total_rows
;
271 mi
->TotalColorClocks
= mi
->Mspc
->total_colorclocks
;
272 mi
->ViewPositionRange
= mi
->Mspc
->ms_LegalView
;
275 mi
->PreferredModeID
= ID
;
276 mi
->Compatibility
= HIDDProps
.CompositionFlags
? MCOMPAT_SELF
: MCOMPAT_NOBODY
;
284 IPTR depth
, stdpixfmt
;
285 STRPTR sync_description
;
287 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
288 OOP_GetAttr(pf
, aHidd_PixFmt_StdPixFmt
, &stdpixfmt
);
290 OOP_GetAttr(sync
, aHidd_Sync_Description
, (IPTR
*)&sync_description
);
291 ni
= (struct NameInfo
*)qh
;
293 if (sync_description
&& sync_description
[0] &&
294 (IS_REAL_STDPIXFMT(stdpixfmt
) || (stdpixfmt
== vHidd_StdPixFmt_Unknown
)))
296 STRPTR pixfmt_name
= "";
300 case vHidd_StdPixFmt_RGB16
:
301 case vHidd_StdPixFmt_RGB15
:
302 case vHidd_StdPixFmt_RGB24
:
306 case vHidd_StdPixFmt_RGB16_LE
:
307 case vHidd_StdPixFmt_RGB15_LE
:
308 pixfmt_name
= "RGB PC";
311 case vHidd_StdPixFmt_BGR24
:
312 case vHidd_StdPixFmt_BGR16
:
313 case vHidd_StdPixFmt_BGR15
:
317 case vHidd_StdPixFmt_BGR16_LE
:
318 case vHidd_StdPixFmt_BGR15_LE
:
319 pixfmt_name
= "BGR PC";
322 case vHidd_StdPixFmt_ARGB32
:
323 pixfmt_name
= "ARGB";
326 case vHidd_StdPixFmt_BGRA32
:
327 pixfmt_name
= "BGRA";
330 case vHidd_StdPixFmt_RGBA32
:
331 pixfmt_name
= "RGBA";
334 case vHidd_StdPixFmt_0RGB32
:
335 pixfmt_name
= "0RGB";
338 case vHidd_StdPixFmt_BGR032
:
339 pixfmt_name
= "BGR0";
342 case vHidd_StdPixFmt_RGB032
:
343 pixfmt_name
= "RGB0";
348 snprintf(ni
->Name
, DISPLAYNAMELEN
, "%s %2dbit %s",
349 sync_description
, (int)depth
, pixfmt_name
);
356 OOP_GetAttr(sync
, aHidd_Sync_HDisp
, &width
);
357 OOP_GetAttr(sync
, aHidd_Sync_VDisp
, &height
);
358 snprintf(ni
->Name
, DISPLAYNAMELEN
, "AROS: %ldx%ldx%ld", width
, height
, depth
);
364 D(bug("!!! UNKNOWN tagID IN CALL TO GetDisplayInfoData() !!!\n"));
368 D(bug("GDID: %d\n", structsize
));
370 if (size
> structsize
)
372 CopyMem(qh
, buf
, size
);
373 FreeMem(qh
, structsize
);
374 /* NULL-terminate the name in case if it was trimmed */
375 if (tagID
== DTAG_NAME
)
382 } /* GetDisplayInfoData */
384 /****************************************************************************************/
386 static ULONG
check_sizes(ULONG tagID
, ULONG size
)
390 idx
= DTAG_TO_IDX(tagID
);
394 D(bug("!!! INVALID tagID TO GetDisplayInfoData"));
398 return size_checks
[idx
];
401 /****************************************************************************************/
403 static ULONG
compute_numbits(HIDDT_Pixel mask
)
408 for (i
= 0; i
<= 31; i
++)
410 if (mask
& (1L << i
)) numbits
++;
416 /****************************************************************************************/