vga_getmodeinfo(3) returns pointer to mode information structure for a mode


#include <vga.h>

vga_modeinfo *vga_getmodeinfo(int mode );


The function returns a pointer to a statical allocated mode information structure which is filled out with details for a video mode mode.

#include <vga.h> defines vga_modeinfo as

typedef struct {
int width;
int height;
int bytesperpixel;
int colors;
int linewidth;
int maxlogicalwidth;
int startaddressrange;
int maxpixels;
int haveblit;
int flags;
/* Extended fields, not always available: */
int chiptype;
int memory;
int linewidth_unit;
char *linear_aperture;
int aperture_size;
void (*set_aperture_page) (int page);
void *extensions;
} vga_modeinfo;

If the given mode is out of range, NULL is returned. Beware, even when vga_getmodeinfo() returns details about a certain mode, you must check if it is currently available (may depend on memory size and other details) with vga_hasmode (3).

The fields meaning in detail:

Basic mode details

Width of mode in pixels.
Height of mode in pixel lines.
Bytes per pixel. This is 1, 2, 3, or 4 (for 256, 32K & 64K, 16M, 16M$ modes) and 0 for planar VGA modes.
Logical scanline width in bytes. This is the memory offset between two pixels above each other in two adjacent screen lines. It is not valid to assume that linewidth == width * bytesperpixel in general!
The number of colors which you can display simultaneously 2, 16, 256, 32768, 65536, or 16777216. Generally 16 and 256 mean that a color lookup table is used. 2 means that only black/white is used and the others use some high/true color mode.

Possible modifications of the memory layout

The maximum logical scanline width (in bytes) which you can set for this mode with vga_setlogicalwidth(3) while still expecting a perfect screen image.
Mask of changeable bits of start address (in pixels). All bits zero in startaddressrange must also be zero in a call to vga_setdisplaystart(3) when you want to avoid noisy video signals.

Memory size

Maximum number of pixels that will fit in a logical screen (depends on video memory).

Further, advanced capabilities

Indicates whether the following bitblit functions are available. It is a logical or of the following predefined values (which each have only one bit set).
has vga_bitblt(3) old style accelerator function.
has vga_fillblt(3) old style accelerator function.
has vga_imageblt(3) old style accelerator function.
has vga_hlinelistblt(3) old style accelerator function.
has vga_blitwait(3) old style accelerator function.

Miscellaneous flags. It is a logical or of the following predefined values (which each have only one bit set).
vga_setreadpage(3) and vga_setwritepage(3) are available in this mode.
Mode is interlaced, which means it will tend to flicker and the user might be happier if the application chooses another mode.
Mode user mode X like memory layout (planar 256 colors VGA mode). See vga_setmodeX(3) for some explanations.
Dynamically loaded mode. This mode was defined in /etc/vga/libvga.conf by the user. He will probably prefer its usage. However, usually this should be of no interest to the user.
Mode can be set to linear addressing with vga_setlinearaddressing(3).
Linear addressing is already enabled for this mode.
The extended fields in this information structure are set to sensible information. If EXT_INFO_AVAILABLE is not set you should even not access these fields as you might have encountered an old version of svgalib and the fields migth actually not have been allocated at all.
For 16M4 modes it means that the 4 bytes per pixel actually mean 0BGR rather than BGR0 as per default. For 16M mode it means that the 3 bytes actually mean RGB instead of BGR.

The first is a general limitation of Mach32, the latter one of Mach32 with a ramdac of type 4. The vga_ drawing functions takes this into account.

A vga_ext_set(3) is available and can be called.

Extended mode information

You must check for EXT_INFO_AVAILABLE in flags before trying to access these values.
the chiptype that was detected/set. This specifies a subtype of the current vga_getchipset(3) setting whose value depends on the chipset. It should be only used for debugging or internally.
memory available on the SVGA card in KB.
use only a multiple of this value for set_logicalwidth(3) or set_displaystart(3) to ensure graceful alignment of lines onto the vga memory in this mode and for noiseless video signals.
ptr to a mmaped secondary linear framebuffer (not related to the use of vga_setlinearaddressing(3)) (NULL if unavailable)
size of the secondary framebuffer in KB. 0 if unavailable.
a function taking an int as parameter to select a page in the framebuffer addressed by read/writes to this memory arey (if aperture_size < memory.
pointer to additional, internal, chipset specific info (contents of the EEPROM for Mach32 driver.)

The vgatest(6) demo displays most of this info for all supported modes.


This manual page was edited by Michael Weller <[email protected]>. The exact source of the referenced function as well as of the original documentation is unknown.

It is very likely that both are at least to some extent are due to Harm Hanemaayer <[email protected]>.

Occasionally this might be wrong. I hereby asked to be excused by the original author and will happily accept any additions or corrections to this first version of the svgalib manual.