revert between 56095 -> 55830 in arch
[AROS.git] / rom / graphics / dispinfo.c
blob42214cd40b0b3a97b433a51cb712f308b9ba97ed
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
8 #include <proto/alib.h>
9 #include <proto/exec.h>
10 #include <proto/oop.h>
11 #include <proto/arossupport.h>
12 #include <proto/utility.h>
13 #include <proto/graphics.h>
15 #include <exec/lists.h>
16 #include <exec/memory.h>
17 #include <exec/rawfmt.h>
19 #include <graphics/displayinfo.h>
20 #include <graphics/monitor.h>
22 #include <cybergraphx/cybergraphics.h>
24 #include <oop/oop.h>
26 #include <hidd/gfx.h>
28 #include <stddef.h>
29 #include <string.h>
31 #include "graphics_intern.h"
32 #include "gfxfuncsupport.h"
33 #include "dispinfo.h"
35 HIDDT_ModeID get_best_resolution_and_depth(struct monitor_driverdata *mdd, struct GfxBase *GfxBase)
37 HIDDT_ModeID ret = vHidd_ModeID_Invalid;
38 struct DisplayInfoHandle *dh;
39 ULONG best_resolution = 0;
40 ULONG best_depth = 0;
42 for (dh = mdd->modes; dh->id != vHidd_ModeID_Invalid; dh++) {
43 OOP_Object *sync, *pf;
44 IPTR depth;
46 HIDD_Gfx_GetMode(mdd->gfxhidd, dh->id, &sync, &pf);
47 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
49 if (depth >= best_depth) {
50 IPTR width, height;
51 ULONG res;
53 OOP_GetAttr(sync, aHidd_Sync_HDisp, &width);
54 OOP_GetAttr(sync, aHidd_Sync_VDisp, &height);
56 res = width * height;
57 if (res > best_resolution) {
58 ret = dh->id;
59 best_resolution = res;
61 best_depth = depth;
64 return ret;
67 /* Looks up a DriverData corresponding to a MonitorSpec */
68 struct monitor_driverdata *MonitorFromSpec(struct MonitorSpec *mspc, struct GfxBase *GfxBase)
70 struct monitor_driverdata *ret = NULL;
71 struct monitor_driverdata *mdd;
72 OOP_Object *drv;
74 if (!mspc)
75 return NULL;
78 * FIXME: NULL ms_Object will likely mean chipset MonitorSpec (they don't have 1:1 relation with sync objects)
79 * Process this correctly here. Or am i wrong ?
81 if (!mspc->ms_Object)
82 return NULL;
84 OOP_GetAttr((OOP_Object *)mspc->ms_Object, aHidd_Sync_GfxHidd, (IPTR *)&drv);
86 ObtainSemaphoreShared(&CDD(GfxBase)->displaydb_sem);
88 for (mdd = CDD(GfxBase)->monitors; mdd; mdd = mdd->next)
91 * Sync objects know nothing about fakegfx proxy class.
92 * They carry a pointer to a real driver object.
94 if (mdd->gfxhidd_orig == drv)
96 ret = mdd;
97 break;
101 ReleaseSemaphore(&CDD(GfxBase)->displaydb_sem);
103 return ret;