summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMystery Man <unknown@mandriva.org>2004-05-11 12:41:07 +0000
committerMystery Man <unknown@mandriva.org>2004-05-11 12:41:07 +0000
commitf0b2cf434b3a176276e79046eafc71a26d94ca3d (patch)
treea2f73175aefefa9f630d80119507e1c95868367e /tools
parent3e4ad5e1b687f262a1d7cc39a0b905a595ac7f95 (diff)
downloaddrakx-f0b2cf434b3a176276e79046eafc71a26d94ca3d.tar
drakx-f0b2cf434b3a176276e79046eafc71a26d94ca3d.tar.gz
drakx-f0b2cf434b3a176276e79046eafc71a26d94ca3d.tar.bz2
drakx-f0b2cf434b3a176276e79046eafc71a26d94ca3d.tar.xz
drakx-f0b2cf434b3a176276e79046eafc71a26d94ca3d.zip
This commit was manufactured by cvs2svn to create branch
'MDK-10-update'.
Diffstat (limited to 'tools')
-rw-r--r--tools/ddcprobe/Makefile29
-rw-r--r--tools/ddcprobe/ddcxinfos.c73
-rw-r--r--tools/ddcprobe/vbe.c709
-rw-r--r--tools/ddcprobe/vbe.h312
4 files changed, 0 insertions, 1123 deletions
diff --git a/tools/ddcprobe/Makefile b/tools/ddcprobe/Makefile
deleted file mode 100644
index bcbf1464d..000000000
--- a/tools/ddcprobe/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-CFLAGS=-Wall -O # -g -DDEBUG
-LDFLAGS = -lm
-TARGETS=ddcxinfos
-
-ARCH := $(patsubst i%86,i386,$(shell uname -m))
-ARCH := $(patsubst sparc%,sparc,$(ARCH))
-
-ifeq (i386,$(ARCH))
-
-ddcxinfos: lrmi.o vesamode.o vbe.o ddcxinfos.o
-
-libvbe.a: lrmi.o vesamode.o vbe.o
- $(AR) cru $@ $^
-
-#install: $(DESTDIR)/usr/include/vbe.h $(DESTDIR)/usr/lib/libvbe.a
-
-$(DESTDIR)/usr/include/vbe.h:
- install -m 644 vbe.h $(DESTDIR)/usr/include/vbe.h
-
-$(DESTDIR)/usr/lib/libvbe.a:
- install -m 644 libvbe.a $(DESTDIR)/usr/lib/libvbe.a
-
-else
-ddcxinfos: not_handled.c
- gcc -o $@ $<
-endif
-
-clean:
- $(RM) $(TARGETS) *.o core
diff --git a/tools/ddcprobe/ddcxinfos.c b/tools/ddcprobe/ddcxinfos.c
deleted file mode 100644
index 22ed653b8..000000000
--- a/tools/ddcprobe/ddcxinfos.c
+++ /dev/null
@@ -1,73 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include "vbe.h"
-#include "vesamode.h"
-#ident "$Id$"
-
-#define SQR(x) ((x) * (x))
-
-int main(int argc, char **argv)
-{
- int i, j;
- u_int16_t *mode_list;
- unsigned char hmin, hmax, vmin, vmax;
- struct vbe_info *vbe_info;
- struct vbe_edid1_info *edid;
- struct vbe_modeline *modelines;
-
-
- if ((vbe_info = vbe_get_vbe_info()) == NULL) return 1;
-
- printf("%dKB of video ram\n", vbe_info->memory_size * 64);
-
- /* List supported standard modes. */
- for (mode_list = vbe_info->mode_list.list; *mode_list != 0xffff; mode_list++)
- for (i = 0; known_vesa_modes[i].x; i++)
- if (known_vesa_modes[i].number == *mode_list)
- printf("%d %d %d\n",
- known_vesa_modes[i].colors,
- known_vesa_modes[i].x,
- known_vesa_modes[i].y
- );
- printf("\n");
-
- if ((edid = vbe_get_edid_info()) == NULL) return 0;
- if (edid->version == 255 && edid->revision == 255) return 0;
-
- vbe_get_edid_ranges(edid, &hmin, &hmax, &vmin, &vmax);
- modelines = vbe_get_edid_modelines(edid);
-
- if (hmin > hmax || vmin > vmax) return 0;
-
- printf(hmin ? "%d-%d kHz HorizSync\n" : "\n", hmin, hmax);
- printf(vmin ? "%d-%d Hz VertRefresh\n" : "\n", vmin, vmax);
-
- if (edid->max_size_horizontal != 127 && edid->max_size_vertical != 127) {
- char manufacturer[4];
- double size = sqrt(SQR(edid->max_size_horizontal) +
- SQR(edid->max_size_vertical)) / 2.54;
- manufacturer[0] = edid->manufacturer_name.char1 + 'A' - 1;
- manufacturer[1] = edid->manufacturer_name.char2 + 'A' - 1;
- manufacturer[2] = edid->manufacturer_name.char3 + 'A' - 1;
- manufacturer[3] = '\0';
- printf(size ? "%3.2f inches monitor (truly %3.2f') EISA ID=%s%04x\n" : "\n", size * 1.08, size, manufacturer, edid->product_code);
- }
-
- for(j=0; modelines && (modelines[j].refresh != 0); j++){
- printf("# %dx%d, %1.1f%sHz",
- modelines[j].width,
- modelines[j].height,
- modelines[j].refresh,
- modelines[j].interlaced?"i":""
- );
- if(modelines[j].modeline) {
- printf("; hfreq=%f, vfreq=%f\n%s\n",
- modelines[j].hfreq,
- modelines[j].vfreq,
- modelines[j].modeline);
- } else printf("\n");
- }
- return 0;
-}
diff --git a/tools/ddcprobe/vbe.c b/tools/ddcprobe/vbe.c
deleted file mode 100644
index a67e56d0b..000000000
--- a/tools/ddcprobe/vbe.c
+++ /dev/null
@@ -1,709 +0,0 @@
-#include <sys/types.h>
-#include <sys/io.h>
-#include <sys/mman.h>
-#include <netinet/in.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <assert.h>
-#include <limits.h>
-#include <ctype.h>
-#include "lrmi.h"
-#include "vesamode.h"
-#include "vbe.h"
-#ident "$Id$"
-
-/* Return information about a particular video mode. */
-struct vbe_mode_info *vbe_get_mode_info(u_int16_t mode)
-{
- struct LRMI_regs regs;
- char *mem;
- struct vbe_mode_info *ret = NULL;
-
- /* Initialize LRMI. */
- if(LRMI_init() == 0) {
- return NULL;
- }
-
- /* Allocate a chunk of memory. */
- mem = LRMI_alloc_real(sizeof(struct vbe_mode_info));
- if(mem == NULL) {
- return NULL;
- }
- memset(mem, 0, sizeof(struct vbe_mode_info));
-
- memset(&regs, 0, sizeof(regs));
- regs.eax = 0x4f01;
- regs.ecx = mode;
- regs.es = ((u_int32_t)mem) >> 4;
- regs.edi = ((u_int32_t)mem) & 0x0f;
-
- /* Do it. */
- iopl(3);
- ioperm(0, 0x400, 1);
-
- if(LRMI_int(0x10, &regs) == 0) {
- LRMI_free_real(mem);
- return NULL;
- }
-
- /* Check for successful return. */
- if((regs.eax & 0xffff) != 0x004f) {
- LRMI_free_real(mem);
- return NULL;
- }
-
- /* Get memory for return. */
- ret = malloc(sizeof(struct vbe_mode_info));
- if(ret == NULL) {
- LRMI_free_real(mem);
- return NULL;
- }
-
- /* Copy the buffer for return. */
- memcpy(ret, mem, sizeof(struct vbe_mode_info));
-
- /* Clean up and return. */
- LRMI_free_real(mem);
- return ret;
-}
-
-/* Get VBE info. */
-struct vbe_info *vbe_get_vbe_info()
-{
- struct LRMI_regs regs;
- unsigned char *mem;
- struct vbe_info *ret = NULL;
- int i;
-
- /* Initialize LRMI. */
- if(LRMI_init() == 0) {
- return NULL;
- }
-
- /* Allocate a chunk of memory. */
- mem = LRMI_alloc_real(sizeof(struct vbe_mode_info));
- if(mem == NULL) {
- return NULL;
- }
- memset(mem, 0, sizeof(struct vbe_mode_info));
-
- /* Set up registers for the interrupt call. */
- memset(&regs, 0, sizeof(regs));
- regs.eax = 0x4f00;
- regs.es = ((u_int32_t)mem) >> 4;
- regs.edi = ((u_int32_t)mem) & 0x0f;
- memcpy(mem, "VBE2", 4);
-
- /* Do it. */
- iopl(3);
- ioperm(0, 0x400, 1);
-
- if(LRMI_int(0x10, &regs) == 0) {
- LRMI_free_real(mem);
- return NULL;
- }
-
- /* Check for successful return code. */
- if((regs.eax & 0xffff) != 0x004f) {
- LRMI_free_real(mem);
- return NULL;
- }
-
- /* Get memory to return the information. */
- ret = malloc(sizeof(struct vbe_info));
- if(ret == NULL) {
- LRMI_free_real(mem);
- return NULL;
- }
- memcpy(ret, mem, sizeof(struct vbe_info));
-
- /* Set up pointers to usable memory. */
- ret->mode_list.list = (u_int16_t*) ((ret->mode_list.addr.seg << 4) +
- (ret->mode_list.addr.ofs));
- ret->oem_name.string = (char*) ((ret->oem_name.addr.seg << 4) +
- (ret->oem_name.addr.ofs));
-
- /* Snip, snip. */
- mem = strdup(ret->oem_name.string); /* leak */
- while(((i = strlen(mem)) > 0) && isspace(mem[i - 1])) {
- mem[i - 1] = '\0';
- }
- ret->oem_name.string = mem;
-
- /* Set up pointers for VESA 3.0+ strings. */
- if(ret->version[1] >= 3) {
-
- /* Vendor name. */
- ret->vendor_name.string = (char*)
- ((ret->vendor_name.addr.seg << 4)
- + (ret->vendor_name.addr.ofs));
-
- mem = strdup(ret->vendor_name.string); /* leak */
- while(((i = strlen(mem)) > 0) && isspace(mem[i - 1])) {
- mem[i - 1] = '\0';
- }
- ret->vendor_name.string = mem;
-
- /* Product name. */
- ret->product_name.string = (char*)
- ((ret->product_name.addr.seg << 4)
- + (ret->product_name.addr.ofs));
-
- mem = strdup(ret->product_name.string); /* leak */
- while(((i = strlen(mem)) > 0) && isspace(mem[i - 1])) {
- mem[i - 1] = '\0';
- }
- ret->product_name.string = mem;
-
- /* Product revision. */
- ret->product_revision.string = (char*)
- ((ret->product_revision.addr.seg << 4)
- + (ret->product_revision.addr.ofs));
-
- mem = strdup(ret->product_revision.string); /* leak */
- while(((i = strlen(mem)) > 0) && isspace(mem[i - 1])) {
- mem[i - 1] = '\0';
- }
- ret->product_revision.string = mem;
- }
-
- /* Cleanup. */
- LRMI_free_real(mem);
- return ret;
-}
-
-/* Check if EDID queries are suorted. */
-int vbe_get_edid_supported()
-{
- struct LRMI_regs regs;
- int ret = 0;
-
- /* Initialize LRMI. */
- if(LRMI_init() == 0) {
- return 0;
- }
-
- memset(&regs, 0, sizeof(regs));
- regs.eax = 0x4f15;
- regs.ebx = 0x0000;
- regs.es = 0x3000;
- regs.edi = 0x3000;
-
- /* Do it. */
- iopl(3);
- ioperm(0, 0x400, 1);
-
- if(LRMI_int(0x10, &regs) == 0) {
- return 0;
- }
-
- /* Check for successful return. */
- if((regs.eax & 0xff) == 0x4f) {
- /* Supported. */
- ret = 1;
- } else {
- /* Not supported. */
- ret = 0;
- }
-
- /* Clean up and return. */
- return ret;
-}
-
-/* Get EDID info. */
-struct vbe_edid1_info *vbe_get_edid_info()
-{
- struct LRMI_regs regs;
- unsigned char *mem;
- struct vbe_edid1_info *ret = NULL;
- u_int16_t man;
-
- /* Initialize LRMI. */
- if(LRMI_init() == 0) {
- return NULL;
- }
-
- /* Allocate a chunk of memory. */
- mem = LRMI_alloc_real(sizeof(struct vbe_edid1_info));
- if(mem == NULL) {
- return NULL;
- }
- memset(mem, 0, sizeof(struct vbe_edid1_info));
-
- memset(&regs, 0, sizeof(regs));
- regs.eax = 0x4f15;
- regs.ebx = 0x0001;
- regs.es = ((u_int32_t)mem) >> 4;
- regs.edi = ((u_int32_t)mem) & 0x0f;
-
- /* Do it. */
- iopl(3);
- ioperm(0, 0x400, 1);
-
- if(LRMI_int(0x10, &regs) == 0) {
- LRMI_free_real(mem);
- return NULL;
- }
-
-#if 0
- /* Check for successful return. */
- if((regs.eax & 0xffff) != 0x004f) {
- LRMI_free_real(mem);
- return NULL;
- }
-#elseif
- /* Check for successful return. */
- if((regs.eax & 0xff) != 0x4f) {
- LRMI_free_real(mem);
- return NULL;
- }
-#endif
-
- /* Get memory for return. */
- ret = malloc(sizeof(struct vbe_edid1_info));
- if(ret == NULL) {
- LRMI_free_real(mem);
- return NULL;
- }
-
- /* Copy the buffer for return. */
- memcpy(ret, mem, sizeof(struct vbe_edid1_info));
-
- memcpy(&man, &ret->manufacturer_name, 2);
- man = ntohs(man);
- memcpy(&ret->manufacturer_name, &man, 2);
-
- LRMI_free_real(mem);
- return ret;
-}
-
-/* Figure out what the current video mode is. */
-int32_t vbe_get_mode()
-{
- struct LRMI_regs regs;
- int32_t ret = -1;
-
- /* Initialize LRMI. */
- if(LRMI_init() == 0) {
- return -1;
- }
-
- memset(&regs, 0, sizeof(regs));
- regs.eax = 0x4f03;
-
- /* Do it. */
- iopl(3);
- ioperm(0, 0x400, 1);
-
- if(LRMI_int(0x10, &regs) == 0) {
- return -1;
- }
-
- /* Save the returned value. */
- if((regs.eax & 0xffff) == 0x004f) {
- ret = regs.ebx & 0xffff;
- } else {
- ret = -1;
- }
-
- /* Clean up and return. */
- return ret;
-}
-
-/* Set the video mode. */
-void vbe_set_mode(u_int16_t mode)
-{
- struct LRMI_regs regs;
-
- /* Initialize LRMI. */
- if(LRMI_init() == 0) {
- return;
- }
-
- memset(&regs, 0, sizeof(regs));
- regs.eax = 0x4f02;
- regs.ebx = mode;
-
- /* Do it. */
- iopl(3);
- ioperm(0, 0x400, 1);
- LRMI_int(0x10, &regs);
-
- /* Return. */
- return;
-}
-
-/* Just read ranges from the EDID. */
-void vbe_get_edid_ranges(struct vbe_edid1_info *edid,
- unsigned char *hmin, unsigned char *hmax,
- unsigned char *vmin, unsigned char *vmax)
-{
- struct vbe_edid_monitor_descriptor *monitor;
- int i;
-
- *hmin = *hmax = *vmin = *vmax = 0;
-
- for(i = 0; i < 4; i++) {
- monitor = &edid->monitor_details.monitor_descriptor[i];
- if(monitor->type == vbe_edid_monitor_descriptor_range) {
- *hmin = monitor->data.range_data.horizontal_min;
- *hmax = monitor->data.range_data.horizontal_max;
- *vmin = monitor->data.range_data.vertical_min;
- *vmax = monitor->data.range_data.vertical_max;
- }
- }
-}
-
-static int compare_vbe_modelines(const void *m1, const void *m2)
-{
- const struct vbe_modeline *M1 = (const struct vbe_modeline*) m1;
- const struct vbe_modeline *M2 = (const struct vbe_modeline*) m2;
- if(M1->width < M2->width) return -1;
- if(M1->width > M2->width) return 1;
- return 0;
-}
-
-struct vbe_modeline *vbe_get_edid_modelines()
-{
- struct vbe_edid1_info *edid;
- struct vbe_modeline *ret;
- char buf[LINE_MAX];
- int modeline_count = 0, i, j;
-
- if((edid = vbe_get_edid_info()) == NULL) {
- return NULL;
- }
-
- memcpy(buf, &edid->established_timings,
- sizeof(edid->established_timings));
- for(i = 0; i < (8 * sizeof(edid->established_timings)); i++) {
- if(buf[i / 8] & (1 << (i % 8))) {
- modeline_count++;
- }
- }
-
- /* Count the number of standard timings. */
- for(i = 0; i < 8; i++) {
- int x, v;
- x = edid->standard_timing[i].xresolution;
- v = edid->standard_timing[i].vfreq;
- if(((edid->standard_timing[i].xresolution & 0x01) != x) &&
- ((edid->standard_timing[i].vfreq & 0x01) != v)) {
- modeline_count++;
- }
- }
-
- ret = malloc(sizeof(struct vbe_modeline) * (modeline_count + 1));
- if(ret == NULL) {
- return NULL;
- }
- memset(ret, 0, sizeof(struct vbe_modeline) * (modeline_count + 1));
-
- modeline_count = 0;
-
- /* Fill out established timings. */
- if(edid->established_timings.timing_720x400_70) {
- ret[modeline_count].width = 720;
- ret[modeline_count].height = 400;
- ret[modeline_count].refresh = 70;
- modeline_count++;
- }
- if(edid->established_timings.timing_720x400_88) {
- ret[modeline_count].width = 720;
- ret[modeline_count].height = 400;
- ret[modeline_count].refresh = 88;
- modeline_count++;
- }
- if(edid->established_timings.timing_640x480_60) {
- ret[modeline_count].width = 640;
- ret[modeline_count].height = 480;
- ret[modeline_count].refresh = 60;
- modeline_count++;
- }
- if(edid->established_timings.timing_640x480_67) {
- ret[modeline_count].width = 640;
- ret[modeline_count].height = 480;
- ret[modeline_count].refresh = 67;
- modeline_count++;
- }
- if(edid->established_timings.timing_640x480_72) {
- ret[modeline_count].width = 640;
- ret[modeline_count].height = 480;
- ret[modeline_count].refresh = 72;
- modeline_count++;
- }
- if(edid->established_timings.timing_640x480_75) {
- ret[modeline_count].width = 640;
- ret[modeline_count].height = 480;
- ret[modeline_count].refresh = 75;
- modeline_count++;
- }
- if(edid->established_timings.timing_800x600_56) {
- ret[modeline_count].width = 800;
- ret[modeline_count].height = 600;
- ret[modeline_count].refresh = 56;
- modeline_count++;
- }
- if(edid->established_timings.timing_800x600_60) {
- ret[modeline_count].width = 800;
- ret[modeline_count].height = 600;
- ret[modeline_count].refresh = 60;
- modeline_count++;
- }
- if(edid->established_timings.timing_800x600_72) {
- ret[modeline_count].width = 800;
- ret[modeline_count].height = 600;
- ret[modeline_count].refresh = 72;
- modeline_count++;
- }
- if(edid->established_timings.timing_800x600_75) {
- ret[modeline_count].width = 800;
- ret[modeline_count].height = 600;
- ret[modeline_count].refresh = 75;
- modeline_count++;
- }
- if(edid->established_timings.timing_832x624_75) {
- ret[modeline_count].width = 832;
- ret[modeline_count].height = 624;
- ret[modeline_count].refresh = 75;
- modeline_count++;
- }
- if(edid->established_timings.timing_1024x768_87i) {
- ret[modeline_count].width = 1024;
- ret[modeline_count].height = 768;
- ret[modeline_count].refresh = 87;
- ret[modeline_count].interlaced = 1;
- modeline_count++;
- }
- if(edid->established_timings.timing_1024x768_60){
- ret[modeline_count].width = 1024;
- ret[modeline_count].height = 768;
- ret[modeline_count].refresh = 60;
- modeline_count++;
- }
- if(edid->established_timings.timing_1024x768_70){
- ret[modeline_count].width = 1024;
- ret[modeline_count].height = 768;
- ret[modeline_count].refresh = 70;
- modeline_count++;
- }
- if(edid->established_timings.timing_1024x768_75){
- ret[modeline_count].width = 1024;
- ret[modeline_count].height = 768;
- ret[modeline_count].refresh = 75;
- modeline_count++;
- }
- if(edid->established_timings.timing_1280x1024_75) {
- ret[modeline_count].width = 1280;
- ret[modeline_count].height = 1024;
- ret[modeline_count].refresh = 75;
- modeline_count++;
- }
-
- /* Add in standard timings. */
- for(i = 0; i < 8; i++) {
- float aspect = 1;
- int x, v;
- x = edid->standard_timing[i].xresolution;
- v = edid->standard_timing[i].vfreq;
- if(((edid->standard_timing[i].xresolution & 0x01) != x) &&
- ((edid->standard_timing[i].vfreq & 0x01) != v)) {
- switch(edid->standard_timing[i].aspect) {
- case aspect_75: aspect = 0.7500; break;
- case aspect_8: aspect = 0.8000; break;
- case aspect_5625: aspect = 0.5625; break;
- default: aspect = 1; break;
- }
- x = (edid->standard_timing[i].xresolution + 31) * 8;
- ret[modeline_count].width = x;
- ret[modeline_count].height = x * aspect;
- ret[modeline_count].refresh =
- edid->standard_timing[i].vfreq + 60;
- modeline_count++;
- }
- }
-
- /* Now tack on any matching modelines. */
- for(i = 0; ret[i].refresh != 0; i++) {
- struct vesa_timing_t *t = NULL;
- for(j = 0; known_vesa_timings[j].refresh != 0; j++) {
- t = &known_vesa_timings[j];
- if(ret[i].width == t->x)
- if(ret[i].height == t->y)
- if(ret[i].refresh == t->refresh) {
- snprintf(buf, sizeof(buf),
- "ModeLine \"%dx%d\"\t%6.2f "
- "%4d %4d %4d %4d %4d %4d %4d %4d %s %s"
- , t->x, t->y, t->dotclock,
- t->timings[0],
- t->timings[0] + t->timings[1],
- t->timings[0] + t->timings[1] +
- t->timings[2],
- t->timings[0] + t->timings[1] +
- t->timings[2] + t->timings[3],
- t->timings[4],
- t->timings[4] + t->timings[5],
- t->timings[4] + t->timings[5] +
- t->timings[6],
- t->timings[4] + t->timings[5] +
- t->timings[6] + t->timings[7],
- t->hsync == hsync_pos ?
- "+hsync" : "-hsync",
- t->vsync == vsync_pos ?
- "+vsync" : "-vsync");
- ret[i].modeline = strdup(buf);
- ret[i].hfreq = t->hfreq;
- ret[i].vfreq = t->vfreq;
- }
- }
- }
-
- modeline_count = 0;
- for(i = 0; ret[i].refresh != 0; i++) {
- modeline_count++;
- }
- qsort(ret, modeline_count, sizeof(ret[0]), compare_vbe_modelines);
-
- return ret;
-}
-
-const void *vbe_save_svga_state()
-{
- struct LRMI_regs regs;
- unsigned char *mem;
- u_int16_t block_size;
- void *data;
-
- /* Initialize LRMI. */
- if(LRMI_init() == 0) {
- return NULL;
- }
-
- memset(&regs, 0, sizeof(regs));
- regs.eax = 0x4f04;
- regs.ecx = 0xffff;
- regs.edx = 0;
-
- iopl(3);
- ioperm(0, 0x400, 1);
-
- if(LRMI_int(0x10, &regs) == 0) {
- return NULL;
- }
-
- if((regs.eax & 0xff) != 0x4f) {
- fprintf(stderr, "Get SuperVGA Video State not supported.\n");
- return NULL;
- }
-
- if((regs.eax & 0xffff) != 0x004f) {
- fprintf(stderr, "Get SuperVGA Video State Info failed.\n");
- return NULL;
- }
-
- block_size = 64 * (regs.ebx & 0xffff);
-
- /* Allocate a chunk of memory. */
- mem = LRMI_alloc_real(block_size);
- if(mem == NULL) {
- return NULL;
- }
- memset(mem, 0, sizeof(block_size));
-
- memset(&regs, 0, sizeof(regs));
- regs.eax = 0x4f04;
- regs.ecx = 0x000f;
- regs.edx = 0x0001;
- regs.es = ((u_int32_t)mem) >> 4;
- regs.ebx = ((u_int32_t)mem) & 0x0f;
- memset(mem, 0, block_size);
- iopl(3);
- ioperm(0, 0x400, 1);
-
- if(LRMI_int(0x10, &regs) == 0) {
- LRMI_free_real(mem);
- return NULL;
- }
-
- if((regs.eax & 0xffff) != 0x004f) {
- fprintf(stderr, "Get SuperVGA Video State Save failed.\n");
- return NULL;
- }
-
- data = malloc(block_size);
- if(data == NULL) {
- LRMI_free_real(mem);
- return NULL;
- }
-
- /* Clean up and return. */
- memcpy(data, mem, block_size);
- LRMI_free_real(mem);
- return data;
-}
-
-void vbe_restore_svga_state(const void *state)
-{
- struct LRMI_regs regs;
- unsigned char *mem;
- u_int16_t block_size;
-
- /* Initialize LRMI. */
- if(LRMI_init() == 0) {
- return;
- }
-
- memset(&regs, 0, sizeof(regs));
- regs.eax = 0x4f04;
- regs.ecx = 0x000f;
- regs.edx = 0;
-
- /* Find out how much memory we need. */
- iopl(3);
- ioperm(0, 0x400, 1);
-
- if(LRMI_int(0x10, &regs) == 0) {
- return;
- }
-
- if((regs.eax & 0xff) != 0x4f) {
- fprintf(stderr, "Get SuperVGA Video State not supported.\n");
- return;
- }
-
- if((regs.eax & 0xffff) != 0x004f) {
- fprintf(stderr, "Get SuperVGA Video State Info failed.\n");
- return;
- }
-
- block_size = 64 * (regs.ebx & 0xffff);
-
- /* Allocate a chunk of memory. */
- mem = LRMI_alloc_real(block_size);
- if(mem == NULL) {
- return;
- }
- memset(mem, 0, sizeof(block_size));
-
- memset(&regs, 0, sizeof(regs));
- regs.eax = 0x4f04;
- regs.ecx = 0x000f;
- regs.edx = 0x0002;
- regs.es = 0x2000;
- regs.ebx = 0x0000;
- memcpy(mem, state, block_size);
-
- iopl(3);
- ioperm(0, 0x400, 1);
-
- if(LRMI_int(0x10, &regs) == 0) {
- LRMI_free_real(mem);
- return;
- }
-
- if((regs.eax & 0xffff) != 0x004f) {
- fprintf(stderr, "Get SuperVGA Video State Restore failed.\n");
- return;
- }
-}
diff --git a/tools/ddcprobe/vbe.h b/tools/ddcprobe/vbe.h
deleted file mode 100644
index 338d3bd88..000000000
--- a/tools/ddcprobe/vbe.h
+++ /dev/null
@@ -1,312 +0,0 @@
-#ifndef vbe_h
-#define vbe_h
-#ident "$Id$"
-#include <sys/types.h>
-
-/* Record returned by int 0x10, function 0x4f, subfunction 0x00. */
-struct vbe_info {
- unsigned char signature[4];
- unsigned char version[2];
- union {
- struct {
- u_int16_t ofs;
- u_int16_t seg;
- } addr;
- const char *string;
- } oem_name;
- u_int32_t capabilities;
- union {
- struct {
- u_int16_t ofs;
- u_int16_t seg;
- } addr;
- u_int16_t *list;
- } mode_list;
- u_int16_t memory_size;
- /* VESA 3.0+ */
- u_int16_t vbe_revision;
- union {
- struct {
- u_int16_t ofs;
- u_int16_t seg;
- } addr;
- const char *string;
- } vendor_name;
- union {
- struct {
- u_int16_t ofs;
- u_int16_t seg;
- } addr;
- const char *string;
- } product_name;
- union {
- struct {
- u_int16_t ofs;
- u_int16_t seg;
- } addr;
- const char *string;
- } product_revision;
- char reserved1[222];
- char reserved2[256];
-} __attribute__ ((packed));
-
-/* Stuff returned by int 0x10, function 0x4f, subfunction 0x01. */
-struct vbe_mode_info {
- /* required for all VESA versions */
- struct {
- /* VBE 1.0+ */
- u_int16_t supported: 1;
- u_int16_t optional_info_available: 1;
- u_int16_t bios_output_supported: 1;
- u_int16_t color: 1;
- u_int16_t graphics: 1;
- /* VBE 2.0+ */
- u_int16_t not_vga_compatible: 1;
- u_int16_t not_bank_switched: 1;
- u_int16_t lfb: 1;
- /* VBE 1.0+ */
- u_int16_t unknown: 1;
- u_int16_t must_enable_directaccess_in_10: 1;
- } mode_attributes;
- struct {
- unsigned char exists: 1;
- unsigned char readable: 1;
- unsigned char writeable: 1;
- unsigned char reserved: 5;
- } windowa_attributes, windowb_attributes;
- u_int16_t window_granularity;
- u_int16_t window_size;
- u_int16_t windowa_start_segment, windowb_start_segment;
- u_int16_t window_positioning_seg, window_positioning_ofs;
- u_int16_t bytes_per_scanline;
- /* optional for VESA 1.0/1.1, required for OEM modes */
- u_int16_t w, h;
- unsigned char cell_width, cell_height;
- unsigned char memory_planes;
- unsigned char bpp;
- unsigned char banks;
- enum {
- memory_model_text = 0,
- memory_model_cga = 1,
- memory_model_hgc = 2,
- memory_model_ega16 = 3,
- memory_model_packed_pixel = 4,
- memory_model_sequ256 = 5,
- memory_model_direct_color = 6,
- memory_model_yuv = 7,
- } memory_model: 8;
- unsigned char bank_size;
- unsigned char image_pages;
- unsigned char reserved1;
- /* required for VESA 1.2+ */
- unsigned char red_mask, red_field;
- unsigned char green_mask, green_field;
- unsigned char blue_mask, blue_field;
- unsigned char reserved_mask, reserved_field;
- unsigned char direct_color_mode_info;
- /* VESA 2.0+ */
- u_int32_t linear_buffer_address;
- u_int32_t offscreen_memory_address;
- u_int16_t offscreen_memory_size;
- unsigned char reserved2[206];
-} __attribute__ ((packed));
-
-/* Modeline information used by XFree86. */
-struct vbe_modeline {
- u_int16_t width, height;
- unsigned char interlaced;
- float refresh;
- char *modeline;
- float hfreq, vfreq, pixel_clock;
-};
-
-/* Aspect ratios used in EDID info. */
-enum vbe_edid_aspect {
- aspect_unknown = 0,
- aspect_75,
- aspect_8,
- aspect_5625,
-};
-
-/* Detailed timing information used in EDID v1.x */
-struct vbe_edid_detailed_timing {
- u_int16_t pixel_clock;
-#define VBE_EDID_DETAILED_TIMING_PIXEL_CLOCK(_x) \
- ((_x).pixel_clock * 10000)
- unsigned char horizontal_active;
- unsigned char horizontal_blanking;
- unsigned char horizontal_active_hi: 4;
- unsigned char horizontal_blanking_hi: 4;
-#define VBE_EDID_DETAILED_TIMING_HORIZONTAL_ACTIVE(_x) \
- (((_x).horizontal_active_hi << 8) + (_x).horizontal_active)
-#define VBE_EDID_DETAILED_TIMING_HORIZONTAL_BLANKING(_x) \
- (((_x).horizontal_blanking_hi << 8) + (_x).horizontal_blanking)
- unsigned char vertical_active;
- unsigned char vertical_blanking;
- unsigned char vertical_active_hi: 4;
- unsigned char vertical_blanking_hi: 4;
-#define VBE_EDID_DETAILED_TIMING_VERTICAL_ACTIVE(_x) \
- (((_x).vertical_active_hi << 8) + (_x).vertical_active)
-#define VBE_EDID_DETAILED_TIMING_VERTICAL_BLANKING(_x) \
- (((_x).vertical_blanking_hi << 8) + (_x).vertical_blanking)
- unsigned char hsync_offset;
- unsigned char hsync_pulse_width;
- unsigned char vsync_offset: 4;
- unsigned char vsync_pulse_width: 4;
- unsigned char hsync_offset_hi: 2;
- unsigned char hsync_pulse_width_hi: 2;
- unsigned char vsync_offset_hi: 2;
- unsigned char vsync_pulse_width_hi: 2;
-#define VBE_EDID_DETAILED_TIMING_HSYNC_OFFSET(_x) \
- (((_x).hsync_offset_hi << 8) + (_x).hsync_offset)
-#define VBE_EDID_DETAILED_TIMING_HSYNC_PULSE_WIDTH(_x) \
- (((_x).hsync_pulse_width_hi << 8) + (_x).hsync_pulse_width)
-#define VBE_EDID_DETAILED_TIMING_VSYNC_OFFSET(_x) \
- (((_x).vsync_offset_hi << 4) + (_x).vsync_offset)
-#define VBE_EDID_DETAILED_TIMING_VSYNC_PULSE_WIDTH(_x) \
- (((_x).vsync_pulse_width_hi << 4) + (_x).vsync_pulse_width)
- unsigned char himage_size;
- unsigned char vimage_size;
- unsigned char himage_size_hi: 4;
- unsigned char vimage_size_hi: 4;
-#define VBE_EDID_DETAILED_TIMING_HIMAGE_SIZE(_x) \
- (((_x).himage_size_hi << 8) + (_x).himage_size)
-#define VBE_EDID_DETAILED_TIMING_VIMAGE_SIZE(_x) \
- (((_x).vimage_size_hi << 8) + (_x).vimage_size)
- unsigned char hborder;
- unsigned char vborder;
- struct {
- unsigned char interlaced: 1;
- unsigned char stereo: 2;
- unsigned char digital_composite: 2;
- unsigned char variant: 2;
- unsigned char zero: 1;
- } flags __attribute__ ((packed));
-} __attribute__ ((packed));
-
-enum {
- vbe_edid_monitor_descriptor_serial = 0xff,
- vbe_edid_monitor_descriptor_ascii = 0xfe,
- vbe_edid_monitor_descriptor_range = 0xfd,
- vbe_edid_monitor_descriptor_name = 0xfc,
-} vbe_edid_monitor_descriptor_types;
-
-struct vbe_edid_monitor_descriptor {
- u_int16_t zero_flag_1;
- unsigned char zero_flag_2;
- unsigned char type;
- unsigned char zero_flag_3;
- union {
- char string[13];
- struct {
- unsigned char vertical_min;
- unsigned char vertical_max;
- unsigned char horizontal_min;
- unsigned char horizontal_max;
- unsigned char pixel_clock_max;
- unsigned char gtf_data[8];
- } range_data;
- } data;
-} __attribute__ ((packed));
-
-struct vbe_edid1_info {
- unsigned char header[8];
- struct {
- u_int16_t char3: 5;
- u_int16_t char2: 5;
- u_int16_t char1: 5;
- u_int16_t zero: 1;
- } manufacturer_name __attribute__ ((packed));
- u_int16_t product_code;
- u_int32_t serial_number;
- unsigned char week;
- unsigned char year;
- unsigned char version;
- unsigned char revision;
- struct {
- unsigned char separate_sync: 1;
- unsigned char composite_sync: 1;
- unsigned char sync_on_green: 1;
- unsigned char unused: 2;
- unsigned char voltage_level: 2;
- unsigned char digital: 1;
- } video_input_definition __attribute__ ((packed));
- unsigned char max_size_horizontal;
- unsigned char max_size_vertical;
- unsigned char gamma;
- struct {
- unsigned char unused1: 3;
- unsigned char rgb: 1;
- unsigned char unused2: 1;
- unsigned char active_off: 1;
- unsigned char suspend: 1;
- unsigned char standby: 1;
- } feature_support __attribute__ ((packed));
- unsigned char color_characteristics[10];
- struct {
- unsigned char timing_720x400_70: 1;
- unsigned char timing_720x400_88: 1;
- unsigned char timing_640x480_60: 1;
- unsigned char timing_640x480_67: 1;
- unsigned char timing_640x480_72: 1;
- unsigned char timing_640x480_75: 1;
- unsigned char timing_800x600_56: 1;
- unsigned char timing_800x600_60: 1;
- unsigned char timing_800x600_72: 1;
- unsigned char timing_800x600_75: 1;
- unsigned char timing_832x624_75: 1;
- unsigned char timing_1024x768_87i: 1;
- unsigned char timing_1024x768_60: 1;
- unsigned char timing_1024x768_70: 1;
- unsigned char timing_1024x768_75: 1;
- unsigned char timing_1280x1024_75: 1;
- } established_timings __attribute__ ((packed));
- struct {
- unsigned char timing_1152x870_75: 1;
- unsigned char reserved: 7;
- } manufacturer_timings __attribute__ ((packed));
- struct {
- u_int16_t xresolution: 8;
- u_int16_t vfreq: 6;
- u_int16_t aspect: 2;
- } standard_timing[8] __attribute__ ((packed));
- union {
- struct vbe_edid_detailed_timing detailed_timing[4];
- struct vbe_edid_monitor_descriptor monitor_descriptor[4];
- } monitor_details __attribute__ ((packed));
- unsigned char extension_flag;
- unsigned char checksum;
- unsigned char padding[128];
-} __attribute__ ((packed));
-
-#define VBE_LINEAR_FRAMEBUFFER 0x4000
-
-/* Get VESA information. */
-struct vbe_info *vbe_get_vbe_info();
-
-/* Get information about a particular video mode, bitwise or with
- VBE_LINEAR_FRAMEBUFFER to check if LFB version is supported. */
-struct vbe_mode_info *vbe_get_mode_info(u_int16_t mode);
-
-/* Check if EDID reads are supported, and do them. */
-int vbe_get_edid_supported();
-struct vbe_edid1_info *vbe_get_edid_info();
-
-/* Get the current video mode, -1 on error. */
-int32_t vbe_get_mode();
-/* Set a new video mode, bitwise or with VBE_LINEAR_FRAMEBUFFER. */
-void vbe_set_mode(u_int16_t mode);
-
-/* Save/restore the SVGA state. Call free() on the state record when done. */
-const void *vbe_save_svga_state();
-void vbe_restore_svga_state(const void *state);
-
-/* Get the ranges of values suitable for the attached monitor. */
-void vbe_get_edid_ranges(struct vbe_edid1_info *edid,
- unsigned char *hmin, unsigned char *hmax,
- unsigned char *vmin, unsigned char *vmax);
-
-/* Get a list of modelines that will work with this monitor. */
-struct vbe_modeline *vbe_get_edid_modelines();
-
-#endif