diff options
author | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2003-10-24 13:30:19 +0000 |
---|---|---|
committer | Gwenolé Beauchesne <gbeauchesne@mandriva.org> | 2003-10-24 13:30:19 +0000 |
commit | 1767b4a1709cbebff59e96144463e19927e71a3c (patch) | |
tree | e0e947d0cce59f75a2c352b5f697588e17d009ff | |
parent | c5b81552b9abf8ef78056bd1db685aa7d9362620 (diff) | |
download | drakx-1767b4a1709cbebff59e96144463e19927e71a3c.tar drakx-1767b4a1709cbebff59e96144463e19927e71a3c.tar.gz drakx-1767b4a1709cbebff59e96144463e19927e71a3c.tar.bz2 drakx-1767b4a1709cbebff59e96144463e19927e71a3c.tar.xz drakx-1767b4a1709cbebff59e96144463e19927e71a3c.zip |
Really read necessary mode_list info from VBE. Check that kernel could
actually get something useful into EDID block.
-rw-r--r-- | tools/ddcprobe/ddcxinfos.c | 18 | ||||
-rw-r--r-- | tools/ddcprobe/vbe.c | 9 | ||||
-rw-r--r-- | tools/ddcprobe/vbe.h | 3 |
3 files changed, 20 insertions, 10 deletions
diff --git a/tools/ddcprobe/ddcxinfos.c b/tools/ddcprobe/ddcxinfos.c index 4aec99d29..04ab260cf 100644 --- a/tools/ddcprobe/ddcxinfos.c +++ b/tools/ddcprobe/ddcxinfos.c @@ -21,6 +21,8 @@ int main(void) struct vbe_edid1_info *edid; struct vbe_modeline *modelines; #if KERNEL_BOOT_INFO + u_int32_t vga_bios_base, vga_bios_size; + u_int32_t page_size; int dev_mem_fd; char *mem; #endif @@ -34,13 +36,15 @@ int main(void) perror("open /dev/mem"); return 1; } - if ((mem = (char *)mmap(0, VGA_BIOS_SIZE, PROT_READ, MAP_PRIVATE, dev_mem_fd, VGA_BIOS_BASE)) == MAP_FAILED) { - perror("mmap /dev/mem at VGA_BIOS_BASE"); + page_size = getpagesize(); + vga_bios_base = vbe_info->mode_list.base & ~0xffff; + vga_bios_size = (vbe_info->mode_list.base - vga_bios_base + page_size - 1) & -page_size; + mem = malloc(vga_bios_size); + if (lseek(dev_mem_fd, vga_bios_base, SEEK_SET) != vga_bios_base) return 1; - } - - if ((vbe_info->mode_list.base & ~0xffff) != VGA_BIOS_BASE) return 1; - mode_list = (u_int16_t *)(mem + vbe_info->mode_list.base - VGA_BIOS_BASE); + if (read(dev_mem_fd, mem, vga_bios_size) != vga_bios_size) + return 1; + mode_list = (u_int16_t *)(mem + vbe_info->mode_list.base - vga_bios_base); #endif #if defined(__i386__) mode_list = (u_int16_t *)vbe_info->mode_list.ptr; @@ -60,7 +64,7 @@ int main(void) printf("\n"); #if KERNEL_BOOT_INFO - munmap(mem, VGA_BIOS_SIZE); + free(mem); close(dev_mem_fd); #endif diff --git a/tools/ddcprobe/vbe.c b/tools/ddcprobe/vbe.c index bee57c5dc..7a5633c7e 100644 --- a/tools/ddcprobe/vbe.c +++ b/tools/ddcprobe/vbe.c @@ -224,7 +224,7 @@ struct vbe_edid1_info *vbe_get_edid_info() return ret; #endif #if KERNEL_BOOT_INFO - int edid_fd; + int i, invalid, edid_fd; struct vbe_edid1_info *ret = NULL; ret = malloc(sizeof(struct vbe_edid1_info)); @@ -239,6 +239,13 @@ struct vbe_edid1_info *vbe_get_edid_info() close(edid_fd); + /* Check that kernel could actually get something useful. */ + invalid = 1; + for (i = 0; invalid && i < 8; i++) + invalid = invalid && (ret->header[i] == EDID_INVALID); + if (invalid) + return NULL; + return ret; #endif return NULL; diff --git a/tools/ddcprobe/vbe.h b/tools/ddcprobe/vbe.h index a25b88c34..32ccc7902 100644 --- a/tools/ddcprobe/vbe.h +++ b/tools/ddcprobe/vbe.h @@ -8,10 +8,9 @@ #endif #define BOOT_VBE_INFO "/proc/BOOT/vbe" #define BOOT_EDID_INFO "/proc/BOOT/edid" +#define EDID_INVALID 0x13 #define EDID_BLOCK_SIZE 128 #define VBE_BLOCK_SIZE 512 -#define VGA_BIOS_BASE 0xc0000 -#define VGA_BIOS_SIZE (512 * 1024) /* FIXME: wild guess (512 KB are enough?) */ union vbe_addr { struct { |