2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
5 Desc: Graphics function OpenMonitor()
9 #include <aros/atomic.h>
10 #include <aros/debug.h>
11 #include <graphics/monitor.h>
12 #include <proto/oop.h>
14 #include "graphics_intern.h"
17 /*****************************************************************************
20 #include <proto/graphics.h>
22 AROS_LH2(struct MonitorSpec
*, OpenMonitor
,
25 AROS_LHA(STRPTR
, monitor_name
, A1
),
26 AROS_LHA(ULONG
, display_id
, D0
),
29 struct GfxBase
*, GfxBase
, 119, Graphics
)
34 monitor_name - pointer to a null terminated string
35 display_id - optional 32 bit monitor/mode identifier
38 mspc - pointer to an open MonitorSpec structure
39 NULL if MonitorSpec could not be opened
48 CloseMonitor(), graphics/monitor.h
51 Currently display_id parameter is ignored because all display modes
52 are served by the same driver (which is the defailt one).
53 In future this will change.
58 ******************************************************************************/
62 struct MonitorSpec
*mspc
= NULL
;
64 D(bug("[GFX] OpenMonitor(%s)\n", monitor_name
));
67 if (stricmp(monitor_name
, DEFAULT_MONITOR_NAME
)) {
68 ObtainSemaphoreShared(GfxBase
->MonitorListSemaphore
);
70 /* TODO: use FindName() here, however this is possible only after switch to
71 ABI v1 (because otherwise struct Node and struct ExtendedNode have different layout */
72 for (mspc
= (struct MonitorSpec
*)GfxBase
->MonitorList
.lh_Head
; mspc
->ms_Node
.xln_Succ
; mspc
= (struct MonitorSpec
*)mspc
->ms_Node
.xln_Succ
) {
73 if (!strcmp(monitor_name
, mspc
->ms_Node
.xln_Name
)) {
74 D(bug("[OpenMonitor] Found spec 0x%p\n", mspc
));
79 ReleaseSemaphore(GfxBase
->MonitorListSemaphore
);
81 if (!mspc
->ms_Node
.xln_Succ
) {
82 D(bug("[OpenMonitor] Monitor not found\n"));
86 mspc
= GfxBase
->default_monitor
;
87 } else if (display_id
!= INVALID_ID
) {
88 struct MonitorInfo info
;
90 if (GetDisplayInfoData(NULL
, (UBYTE
*)&info
, sizeof(info
), DTAG_MNTR
, display_id
) >= offsetof(struct MonitorInfo
, ViewPosition
))
93 mspc
= GfxBase
->default_monitor
;
96 AROS_ATOMIC_INC(mspc
->ms_OpenCount
);