Documented GVF_SAVE_VAR alongside other flags, and removed a query/doubt
[AROS.git] / rom / graphics / openmonitor.c
blob2ef2192a2dd23a8b8b9219b71ebd3997eee537aa
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function OpenMonitor()
6 Lang: english
7 */
9 #include <aros/atomic.h>
10 #include <aros/debug.h>
11 #include <graphics/monitor.h>
12 #include <proto/oop.h>
14 #include <stddef.h>
16 #include "graphics_intern.h"
17 #include "dispinfo.h"
19 /*****************************************************************************
21 NAME */
22 #include <proto/graphics.h>
24 AROS_LH2(struct MonitorSpec *, OpenMonitor,
26 /* SYNOPSIS */
27 AROS_LHA(STRPTR, monitor_name, A1),
28 AROS_LHA(ULONG, display_id, D0),
30 /* LOCATION */
31 struct GfxBase *, GfxBase, 119, Graphics)
33 /* FUNCTION
35 INPUTS
36 monitor_name - pointer to a null terminated string
37 display_id - optional 32 bit monitor/mode identifier
39 RESULT
40 mspc - pointer to an open MonitorSpec structure
41 NULL if MonitorSpec could not be opened
43 NOTES
45 EXAMPLE
47 BUGS
49 SEE ALSO
50 CloseMonitor(), graphics/monitor.h
52 INTERNALS
54 HISTORY
57 ******************************************************************************/
59 AROS_LIBFUNC_INIT
61 struct MonitorSpec *mspc = NULL;
63 D(bug("[GFX] OpenMonitor(%s)\n", monitor_name));
65 if (monitor_name)
67 if (stricmp(monitor_name, DEFAULT_MONITOR_NAME))
69 ObtainSemaphoreShared(GfxBase->MonitorListSemaphore);
71 mspc = (struct MonitorSpec *)FindName(&GfxBase->MonitorList, monitor_name);
72 D(bug("[OpenMonitor] Found spec 0x%p\n", mspc));
74 ReleaseSemaphore(GfxBase->MonitorListSemaphore);
76 else
77 mspc = GfxBase->default_monitor;
79 else if (display_id != INVALID_ID)
81 struct MonitorInfo info;
83 if (GetDisplayInfoData(NULL, (UBYTE *)&info, sizeof(info), DTAG_MNTR, display_id) >= offsetof(struct MonitorInfo, ViewPosition))
84 mspc = info.Mspc;
86 else
87 mspc = GfxBase->default_monitor;
89 if (mspc)
90 AROS_ATOMIC_INC(mspc->ms_OpenCount);
92 return mspc;
94 AROS_LIBFUNC_EXIT
95 } /* OpenMonitor */