As someone stuck with both nVidia and ATI cards, I'd vote against using NV-CONTROL. Detecting the RAM for different manufacturers via different methods sounds harder to maintain.
(--) fglrx(0): VideoRAM: 131072 kByte, Type: DDR SGRAM / SDRAM
Roderick Colenbrander wrote:
Parsing the X log file is way to hacky in my opinion to determine the amount of video memory. Depending on how many X servers you use it can be a different file. In case of nvidia videocards I would prefer to use the NV-CONTROL extension for X. (it is available on Linux/Solaris/FreeBSD) In other cases I would use the pci header of the videocard. A part of it contains what memory ranges are mapped and a part of it corresponds to the size which is mapped for the framebuffer. For instance 128MB on my system:
0000:01:00.0 VGA compatible controller: nVidia Corporation NV35 [GeForce FX 5900] (rev a1) (prog-if 00 [VGA]) Flags: bus master, 66MHz, medium devsel, latency 248, IRQ 11 Memory at de000000 (32-bit, non-prefetchable) [size=16M] Memory at d0000000 (32-bit, prefetchable) [size=128M] Expansion ROM at dfee0000 [disabled] [size=128K] Capabilities: <available only to root>
The only thing is that the pci header can't be thrusted in all cases but I would say it is a lot better than nothing.
Regards, Roderick