tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / rom / intuition / findmonitor.c
blob40f24d2659a005d7082e578638bbc713b65573c0
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Internal monitor database functions
6 */
8 #include <proto/graphics.h>
9 #include <proto/intuition.h>
11 #include "intuition_intern.h"
12 #include "monitorclass_private.h"
15 * Find a monitorclass object corresponsing to a given monitor ID.
17 void *FindMonitorNode(ULONG id, struct IntuitionBase *IntuitionBase)
19 struct MinNode *n;
20 void *ret = NULL;
22 ObtainSemaphoreShared(&GetPrivIBase(IntuitionBase)->MonitorListSem);
24 for (n = GetPrivIBase(IntuitionBase)->MonitorList.mlh_Head; n->mln_Succ; n = n->mln_Succ)
26 if (DoMethod((Object *)n, MM_CheckID, id))
28 ret = n;
29 break;
33 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
35 return ret;
38 static void *FindMonitorByName(const char *name, struct IntuitionBase *IntuitionBase)
40 void *ret;
42 ObtainSemaphoreShared(&GetPrivIBase(IntuitionBase)->MonitorListSem);
43 ret = FindName((struct List *)&GetPrivIBase(IntuitionBase)->MonitorList, name);
44 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
46 return ret;
50 * Find the best monitor node according to either modeid or name.
51 * From MorphOS comments it can be suggested that MorphOS has a concept of
52 * display drivers family, to which several drivers may belong.
53 * In AROS we don't have this concept. So, this function is very simple and just
54 * looks up the object by either name or modeid. 'class' argument is ignored.
56 void *FindBestMonitorNode(void *class, const char *name, ULONG modeid, struct IntuitionBase *IntuitionBase)
58 void *ret;
60 if (modeid == INVALID_ID)
62 ret = FindMonitorByName(name, IntuitionBase);
64 else
66 ret = FindMonitorNode(modeid, IntuitionBase);
69 return ret;
73 * Find the best monitor with 3D capabilities. Our "best" criteria is a special index,
74 * actually showing how much hardware 3D modes we support.
75 * This is purely experimental. Perhaps heuristics in OpenScreen() could be done better,
76 * however currently we try to follow MorphOS way.
78 void *FindBest3dMonitor(void *family, struct IntuitionBase *IntuitionBase)
80 void *ret = NULL;
81 ULONG maxidx = 0;
82 struct MinNode *n;
83 ULONG idx;
85 ObtainSemaphoreShared(&GetPrivIBase(IntuitionBase)->MonitorListSem);
87 for (n = GetPrivIBase(IntuitionBase)->MonitorList.mlh_Head; n->mln_Succ; n = n->mln_Succ)
89 idx = DoMethod((Object *)n, MM_Calc3dCapability);
91 if (idx > maxidx)
93 maxidx = idx;
94 ret = n;
98 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
100 return ret;
104 * Find best matching mode ID for the given monitor.
105 * The idea is simple. Convert name to ID then use BestModeIDA().
107 ULONG FindBestModeID(const char *name, ULONG depth, ULONG width, ULONG height, struct IntuitionBase *IntuitionBase)
109 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
110 Object *obj = FindMonitorByName(name, IntuitionBase);
112 if (obj)
114 struct TagItem tags[] =
116 {BIDTAG_MonitorID , 0 },
117 {BIDTAG_DesiredWidth , width },
118 {BIDTAG_DesiredHeight, height},
119 {BIDTAG_Depth , depth },
120 {TAG_DONE , 0 }
123 GetAttr(MA_MonitorID, obj, &tags[0].ti_Data);
124 return BestModeIDA(tags);
127 return INVALID_ID;