2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include "sysmon_intern.h"
8 #include <clib/alib_protos.h>
10 /* Video information */
11 #if defined(VRAM_HACK)
13 /* This code is a HACK which uses private nouveau.hidd API to get the VRAM/GART
14 information. This will work only on nVidia cards running nouveau driver.
15 The reason for this hack is that there is no public API that would return
18 #include <proto/graphics.h>
19 #include <proto/oop.h>
20 #include <hidd/graphics.h>
21 struct BitMap
* bm
= NULL
;
22 #undef HiddGfxNouveauAttrBase
23 #undef HiddBitMapAttrBase
24 OOP_AttrBase HiddGfxNouveauAttrBase
;
25 OOP_AttrBase HiddBitMapAttrBase
;
26 #define IID_Hidd_Gfx_Nouveau "hidd.gfx.nouveau"
29 aoHidd_Gfx_Nouveau_VRAMSize
, /* [G..] The amount of total VRAM in bytes */
30 aoHidd_Gfx_Nouveau_GARTSize
, /* [G..] The amount of total GART in bytes */
31 aoHidd_Gfx_Nouveau_VRAMFree
, /* [G..] The amount of free VRAM in bytes */
32 aoHidd_Gfx_Nouveau_GARTFree
, /* [G..] The amount of free GART in bytes */
34 num_Hidd_Gfx_Nouveau_Attrs
37 #define aHidd_Gfx_Nouveau_VRAMSize (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_VRAMSize)
38 #define aHidd_Gfx_Nouveau_GARTSize (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_GARTSize)
39 #define aHidd_Gfx_Nouveau_VRAMFree (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_VRAMFree)
40 #define aHidd_Gfx_Nouveau_GARTFree (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_GARTFree)
41 struct Library
* OOPBase
= NULL
;
46 static BOOL
InitVideo(struct SysMonData
*smdata
)
48 #if defined(VRAM_HACK)
49 struct OOP_ABDescr attrbases
[] =
51 { IID_Hidd_BitMap
, &HiddBitMapAttrBase
},
52 { IID_Hidd_Gfx_Nouveau
, &HiddGfxNouveauAttrBase
},
55 struct Screen
* wbscreen
;
57 OOPBase
= OpenLibrary("oop.library", 0L);
62 if (!OOP_ObtainAttrBases(attrbases
))
65 wbscreen
= LockPubScreen(NULL
);
66 bm
= AllocBitMap(32, 32, 0, BMF_DISPLAYABLE
, wbscreen
->RastPort
.BitMap
);
67 UnlockPubScreen(NULL
, wbscreen
);
72 static VOID
DeInitVideo(struct SysMonData
*smdata
)
74 #if defined(VRAM_HACK)
77 OOP_ReleaseAttrBase(IID_Hidd_BitMap
);
78 OOP_ReleaseAttrBase(IID_Hidd_Gfx_Nouveau
);
80 CloseLibrary(OOPBase
);
84 VOID
UpdateVideoStaticInformation(struct SysMonData
* smdata
)
86 #if defined(VRAM_HACK)
87 TEXT buffer
[64] = {0};
88 IPTR vram_size
, gart_size
;
90 OOP_Object
* oopbm
= HIDD_BM_OBJ(bm
);
92 OOP_GetAttr(oopbm
, aHidd_BitMap_GfxHidd
, (APTR
)&gfxhidd
);
93 OOP_GetAttr(gfxhidd
, aHidd_Gfx_Nouveau_VRAMSize
, &vram_size
);
94 OOP_GetAttr(gfxhidd
, aHidd_Gfx_Nouveau_GARTSize
, &gart_size
);
95 __sprintf(buffer
, "%ld kB", (ULONG
)(vram_size
/ 1024));
96 set(smdata
->memorysize
[MEMORY_VRAM
], MUIA_Text_Contents
, buffer
);
97 __sprintf(buffer
, "%ld kB", (ULONG
)(gart_size
/ 1024));
98 set(smdata
->memorysize
[MEMORY_GART
], MUIA_Text_Contents
, buffer
);
102 VOID
UpdateVideoInformation(struct SysMonData
* smdata
)
104 #if defined(VRAM_HACK)
105 TEXT buffer
[64] = {0};
106 IPTR vram_free
, gart_free
;
107 OOP_Object
* gfxhidd
;
108 OOP_Object
* oopbm
= HIDD_BM_OBJ(bm
);
110 OOP_GetAttr(oopbm
, aHidd_BitMap_GfxHidd
, (APTR
)&gfxhidd
);
111 OOP_GetAttr(gfxhidd
, aHidd_Gfx_Nouveau_VRAMFree
, &vram_free
);
112 OOP_GetAttr(gfxhidd
, aHidd_Gfx_Nouveau_GARTFree
, &gart_free
);
113 __sprintf(buffer
, "%ld kB", (ULONG
)(vram_free
/ 1024));
114 set(smdata
->memoryfree
[MEMORY_VRAM
], MUIA_Text_Contents
, buffer
);
115 __sprintf(buffer
, "%ld kB", (ULONG
)(gart_free
/ 1024));
116 set(smdata
->memoryfree
[MEMORY_GART
], MUIA_Text_Contents
, buffer
);
120 struct SysMonModule videomodule
=
123 .DeInit
= DeInitVideo
,