summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiarhei Siamashka <siarhei.siamashka@gmail.com>2011-05-16 03:09:02 +0300
committerSiarhei Siamashka <siarhei.siamashka@gmail.com>2011-05-16 03:09:02 +0300
commit04110b388a02002c1d37f8300327b04e6ee4bd9b (patch)
tree988c565b74e0fe8c6960dc21609af5c936fd4df9
Initial import of 915resolution-0.5.3.tar.gz
-rw-r--r--915resolution.c931
-rw-r--r--LICENSE.txt16
-rw-r--r--Makefile15
-rw-r--r--README.txt174
-rw-r--r--changes.log14
-rw-r--r--chipset_info.txt9
-rwxr-xr-xdump_bios4
7 files changed, 1163 insertions, 0 deletions
diff --git a/915resolution.c b/915resolution.c
new file mode 100644
index 0000000..bdce4f0
--- /dev/null
+++ b/915resolution.c
@@ -0,0 +1,931 @@
+/* 915 resolution by steve tomljenovic
+ *
+ * This was tested only on Sony VGN-FS550. Use at your own risk
+ *
+ * This code is based on the techniques used in :
+ *
+ * - 855patch. Many thanks to Christian Zietz (czietz gmx net)
+ * for demonstrating how to shadow the VBIOS into system RAM
+ * and then modify it.
+ *
+ * - 1280patch by Andrew Tipton (andrewtipton null li).
+ *
+ * - 855resolution by Alain Poirier
+ *
+ * This source code is into the public domain.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#define __USE_GNU
+#include <string.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <sys/io.h>
+#include <unistd.h>
+#include <assert.h>
+
+
+
+#define NEW(a) ((a *)(calloc(1, sizeof(a))))
+#define FREE(a) (free(a))
+
+#define VBIOS_START 0xc0000
+#define VBIOS_SIZE 0x10000
+
+#define VBIOS_FILE "/dev/mem"
+
+#define FALSE 0
+#define TRUE 1
+
+#define MODE_TABLE_OFFSET_845G 617
+
+#define VERSION "0.5.3"
+
+#define ATI_SIGNATURE1 "ATI MOBILITY RADEON"
+#define ATI_SIGNATURE2 "ATI Technologies Inc"
+#define NVIDIA_SIGNATURE "NVIDIA Corp"
+#define INTEL_SIGNATURE "Intel Corp"
+
+typedef unsigned char * address;
+typedef unsigned char byte;
+typedef unsigned short word;
+typedef unsigned char boolean;
+typedef unsigned int cardinal;
+
+typedef enum {
+ CT_UNKWN, CT_830, CT_845G, CT_855GM, CT_865G, CT_915G, CT_915GM, CT_945G, CT_945GM,
+ CT_946GZ, CT_G965, CT_Q965
+} chipset_type;
+
+char * chipset_type_names[] = {
+ "UNKNOWN", "830", "845G", "855GM", "865G", "915G", "915GM", "945G", "945GM",
+ "946GZ", "G965", "Q965"
+};
+
+typedef enum {
+ BT_UNKWN, BT_1, BT_2, BT_3
+} bios_type;
+
+char * bios_type_names[] = {"UNKNOWN", "TYPE 1", "TYPE 2", "TYPE 3"};
+
+int freqs[] = { 60, 75, 85 };
+
+typedef struct {
+ byte mode;
+ byte bits_per_pixel;
+ word resolution;
+ byte unknown;
+} __attribute__((packed)) vbios_mode;
+
+typedef struct {
+ byte unknow1[2];
+ byte x1;
+ byte x_total;
+ byte x2;
+ byte y1;
+ byte y_total;
+ byte y2;
+} __attribute__((packed)) vbios_resolution_type1;
+
+typedef struct {
+ unsigned long clock;
+
+ word x1;
+ word htotal;
+ word x2;
+ word hblank;
+ word hsyncstart;
+ word hsyncend;
+
+ word y1;
+ word vtotal;
+ word y2;
+ word vblank;
+ word vsyncstart;
+ word vsyncend;
+} __attribute__((packed)) vbios_modeline_type2;
+
+typedef struct {
+ byte xchars;
+ byte ychars;
+ byte unknown[4];
+
+ vbios_modeline_type2 modelines[];
+} __attribute__((packed)) vbios_resolution_type2;
+
+typedef struct {
+ unsigned long clock;
+
+ word x1;
+ word htotal;
+ word x2;
+ word hblank;
+ word hsyncstart;
+ word hsyncend;
+
+ word y1;
+ word vtotal;
+ word y2;
+ word vblank;
+ word vsyncstart;
+ word vsyncend;
+
+ word timing_h;
+ word timing_v;
+
+ byte unknown[6];
+} __attribute__((packed)) vbios_modeline_type3;
+
+typedef struct {
+ unsigned char unknown[6];
+
+ vbios_modeline_type3 modelines[];
+} __attribute__((packed)) vbios_resolution_type3;
+
+
+typedef struct {
+ cardinal chipset_id;
+ chipset_type chipset;
+ bios_type bios;
+
+ int bios_fd;
+ address bios_ptr;
+
+ vbios_mode * mode_table;
+ cardinal mode_table_size;
+
+ byte b1, b2;
+
+ boolean unlocked;
+} vbios_map;
+
+
+void initialize_system(char * filename) {
+
+ if (!filename) {
+ if (iopl(3) < 0) {
+ perror("Unable to obtain the proper IO permissions");
+ exit(2);
+ }
+ }
+}
+
+cardinal get_chipset_id(void) {
+ outl(0x80000000, 0xcf8);
+ return inl(0xcfc);
+}
+
+chipset_type get_chipset(cardinal id) {
+ chipset_type type;
+
+ switch (id) {
+ case 0x35758086:
+ type = CT_830;
+ break;
+
+ case 0x25608086:
+ type = CT_845G;
+ break;
+
+ case 0x35808086:
+ type = CT_855GM;
+ break;
+
+ case 0x25708086:
+ type = CT_865G;
+ break;
+
+ case 0x25808086:
+ type = CT_915G;
+ break;
+
+ case 0x25908086:
+ type = CT_915GM;
+ break;
+
+ case 0x27708086:
+ type = CT_945G;
+ break;
+
+ case 0x27a08086:
+ type = CT_945GM;
+ break;
+
+ case 0x29708086:
+ type = CT_946GZ;
+ break;
+
+ case 0x29a08086:
+ type = CT_G965;
+ break;
+
+ case 0x29908086:
+ type = CT_Q965;
+ break;
+
+ default:
+ type = CT_UNKWN;
+ break;
+ }
+
+ return type;
+}
+
+
+vbios_resolution_type1 * map_type1_resolution(vbios_map * map, word res) {
+ vbios_resolution_type1 * ptr = ((vbios_resolution_type1*)(map->bios_ptr + res));
+ return ptr;
+}
+
+vbios_resolution_type2 * map_type2_resolution(vbios_map * map, word res) {
+ vbios_resolution_type2 * ptr = ((vbios_resolution_type2*)(map->bios_ptr + res));
+ return ptr;
+}
+
+vbios_resolution_type3 * map_type3_resolution(vbios_map * map, word res) {
+ vbios_resolution_type3 * ptr = ((vbios_resolution_type3*)(map->bios_ptr + res));
+ return ptr;
+}
+
+
+boolean detect_bios_type(vbios_map * map, boolean modeline, int entry_size) {
+ int i;
+ short int r1, r2;
+ float f;
+
+ r1 = r2 = 32000;
+
+ for (i=0; i < map->mode_table_size; i++) {
+ if (map->mode_table[i].resolution <= r1) {
+ r1 = map->mode_table[i].resolution;
+ }
+ else {
+ if (map->mode_table[i].resolution <= r2) {
+ r2 = map->mode_table[i].resolution;
+ }
+ }
+
+ /*printf("r1 = %d r2 = %d\n", r1, r2);*/
+ }
+
+
+ f = ((float) (r2-r1-6)) / entry_size;
+
+ return f == (int) f;
+}
+
+
+void close_vbios(vbios_map * map);
+
+
+vbios_map * open_vbios(char * filename, chipset_type forced_chipset) {
+ vbios_map * map = NEW(vbios_map);
+
+ /*
+ * Determine chipset
+ */
+
+ if (!filename && forced_chipset == CT_UNKWN) {
+ map->chipset_id = get_chipset_id();
+
+ map->chipset = get_chipset(map->chipset_id);
+ }
+ else if (forced_chipset != CT_UNKWN) {
+ map->chipset = forced_chipset;
+ }
+ else {
+ map->chipset = CT_915GM;
+ }
+
+ /*
+ * Map the video bios to memory
+ */
+
+ if (!filename) {
+ map->bios_fd = open(VBIOS_FILE, O_RDWR);
+ if(map->bios_fd < 0) {
+ if (map->chipset == CT_UNKWN) {
+ fprintf(stderr, "Invalid chipset detected: %x\n", map->chipset_id);
+ }
+ perror("Unable to open the BIOS file");
+ exit(2);
+ }
+
+ map->bios_ptr = mmap(0, VBIOS_SIZE,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ map->bios_fd, VBIOS_START);
+
+ if (map->bios_ptr == MAP_FAILED) {
+ if (map->chipset == CT_UNKWN) {
+ fprintf(stderr, "Invalid chipset detected: %x\n", map->chipset_id);
+ }
+ perror("Cannot mmap() the video BIOS\n");
+ close(map->bios_fd);
+ exit(2);
+ }
+ }
+ else {
+ map->bios_fd = open(filename, O_RDWR);
+ if(map->bios_fd < 0) {
+ if (map->chipset == CT_UNKWN) {
+ fprintf(stderr, "Invalid chipset detected: %x\n", map->chipset_id);
+ }
+ perror("Unable to open the BIOS file");
+ exit(2);
+ }
+
+ map->bios_ptr = mmap(0, VBIOS_SIZE,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ map->bios_fd, 0);
+
+ if (map->bios_ptr == MAP_FAILED) {
+ if (map->chipset == CT_UNKWN) {
+ fprintf(stderr, "Invalid chipset detected: %x\n", map->chipset_id);
+ }
+ perror("Cannot mmap() the BIOS file\n");
+ close(map->bios_fd);
+ exit(2);
+ }
+ }
+
+ /*
+ * check if we have ATI Radeon
+ */
+
+ if (memmem(map->bios_ptr, VBIOS_SIZE, ATI_SIGNATURE1, strlen(ATI_SIGNATURE1)) ||
+ memmem(map->bios_ptr, VBIOS_SIZE, ATI_SIGNATURE2, strlen(ATI_SIGNATURE2)) ) {
+ fprintf(stderr, "ATI chipset detected. 915resolution only works with Intel 800/900 series graphic chipsets.\n");
+ close(map->bios_fd);
+ exit(2);
+ }
+
+ /*
+ * check if we have NVIDIA
+ */
+
+ if (memmem(map->bios_ptr, VBIOS_SIZE, NVIDIA_SIGNATURE, strlen(NVIDIA_SIGNATURE))) {
+ fprintf(stderr, "NVIDIA chipset detected. 915resolution only works with Intel 800/900 series graphic chipsets.\n");
+ close(map->bios_fd);
+ exit(2);
+ }
+
+ /*
+ * check if we have Intel
+ */
+
+ if (map->chipset == CT_UNKWN && memmem(map->bios_ptr, VBIOS_SIZE, INTEL_SIGNATURE, strlen(INTEL_SIGNATURE))) {
+ fprintf(stderr, "Intel chipset detected. However, 915resolution was unable to determine the chipset type.\n");
+
+ fprintf(stderr, "Chipset Id: %x\n", map->chipset_id);
+
+ fprintf(stderr, "Please report this problem to stomljen@yahoo.com\n");
+
+ close_vbios(map);
+ exit(2);
+ }
+
+ /*
+ * check for others
+ */
+
+ if (map->chipset == CT_UNKWN) {
+ fprintf(stderr, "Unknown chipset type and unrecognized bios.\n");
+ fprintf(stderr, "915resolution only works with Intel 800/900 series graphic chipsets.\n");
+
+ fprintf(stderr, "Chipset Id: %x\n", map->chipset_id);
+ close_vbios(map);
+ exit(2);
+ }
+
+ /*
+ * Figure out where the mode table is
+ */
+
+ {
+ address p = map->bios_ptr + 16;
+ address limit = map->bios_ptr + VBIOS_SIZE - (3 * sizeof(vbios_mode));
+
+ while (p < limit && map->mode_table == 0) {
+ vbios_mode * mode_ptr = (vbios_mode *) p;
+
+ if (((mode_ptr[0].mode & 0xf0) == 0x30) && ((mode_ptr[1].mode & 0xf0) == 0x30) &&
+ ((mode_ptr[2].mode & 0xf0) == 0x30) && ((mode_ptr[3].mode & 0xf0) == 0x30)) {
+
+ map->mode_table = mode_ptr;
+ }
+
+ p++;
+ }
+
+ if (map->mode_table == 0) {
+ fprintf(stderr, "Unable to locate the mode table.\n");
+ fprintf(stderr, "Please run the program 'dump_bios' as root and\n");
+ fprintf(stderr, "email the file 'vbios.dmp' to stomljen@yahoo.com.\n");
+
+ fprintf(stderr, "Chipset: %s\n", chipset_type_names[map->chipset]);
+ close_vbios(map);
+ exit(2);
+ }
+ }
+
+ /*
+ * Determine size of mode table
+ */
+
+ {
+ vbios_mode * mode_ptr = map->mode_table;
+
+ while (mode_ptr->mode != 0xff) {
+ map->mode_table_size++;
+ mode_ptr++;
+ }
+ }
+
+ /*
+ * Figure out what type of bios we have
+ * order of detection is important
+ */
+
+ if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type3))) {
+ map->bios = BT_3;
+ }
+ else if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type2))) {
+ map->bios = BT_2;
+ }
+ else if (detect_bios_type(map, FALSE, sizeof(vbios_resolution_type1))) {
+ map->bios = BT_1;
+ }
+ else {
+ fprintf(stderr, "Unable to determine bios type.\n");
+ fprintf(stderr, "Please run the program 'dump_bios' as root and\n");
+ fprintf(stderr, "email the file 'vbios.dmp' to stomljen@yahoo.com.\n");
+
+ fprintf(stderr, "Chipset: %s\n", chipset_type_names[map->chipset]);
+ fprintf(stderr, "Mode Table Offset: $C0000 + $%x\n", ((cardinal)map->mode_table) - ((cardinal)map->bios_ptr));
+ fprintf(stderr, "Mode Table Entries: %u\n", map->mode_table_size);
+ exit(2);
+ }
+
+ return map;
+}
+
+void close_vbios(vbios_map * map) {
+ assert(!map->unlocked);
+
+ if(map->bios_ptr == MAP_FAILED) {
+ fprintf(stderr, "BIOS should be open already!\n");
+ exit(2);
+ }
+
+ munmap(map->bios_ptr, VBIOS_SIZE);
+ close(map->bios_fd);
+
+ FREE(map);
+}
+
+void unlock_vbios(vbios_map * map) {
+
+ assert(!map->unlocked);
+
+ map->unlocked = TRUE;
+
+ switch (map->chipset) {
+ case CT_UNKWN:
+ break;
+ case CT_830:
+ case CT_855GM:
+ outl(0x8000005a, 0xcf8);
+ map->b1 = inb(0xcfe);
+
+ outl(0x8000005a, 0xcf8);
+ outb(0x33, 0xcfe);
+ break;
+ case CT_845G:
+ case CT_865G:
+ case CT_915G:
+ case CT_915GM:
+ case CT_945G:
+ case CT_945GM:
+ case CT_946GZ:
+ case CT_G965:
+ case CT_Q965:
+ outl(0x80000090, 0xcf8);
+ map->b1 = inb(0xcfd);
+ map->b2 = inb(0xcfe);
+
+ outl(0x80000090, 0xcf8);
+ outb(0x33, 0xcfd);
+ outb(0x33, 0xcfe);
+ break;
+ }
+
+#if DEBUG
+ {
+ cardinal t = inl(0xcfc);
+ printf("unlock PAM: (0x%08x)\n", t);
+ }
+#endif
+}
+
+void relock_vbios(vbios_map * map) {
+
+ assert(map->unlocked);
+ map->unlocked = FALSE;
+
+ switch (map->chipset) {
+ case CT_UNKWN:
+ break;
+ case CT_830:
+ case CT_855GM:
+ outl(0x8000005a, 0xcf8);
+ outb(map->b1, 0xcfe);
+ break;
+ case CT_845G:
+ case CT_865G:
+ case CT_915G:
+ case CT_915GM:
+ case CT_945G:
+ case CT_945GM:
+ case CT_946GZ:
+ case CT_G965:
+ case CT_Q965:
+ outl(0x80000090, 0xcf8);
+ outb(map->b1, 0xcfd);
+ outb(map->b2, 0xcfe);
+ break;
+ }
+
+#if DEBUG
+ {
+ cardinal t = inl(0xcfc);
+ printf("relock PAM: (0x%08x)\n", t);
+ }
+#endif
+}
+
+
+void list_modes(vbios_map *map, cardinal raw) {
+ cardinal i, x, y;
+
+ for (i=0; i < map->mode_table_size; i++) {
+ switch(map->bios) {
+ case BT_1:
+ {
+ vbios_resolution_type1 * res = map_type1_resolution(map, map->mode_table[i].resolution);
+
+ x = ((((cardinal) res->x2) & 0xf0) << 4) | res->x1;
+ y = ((((cardinal) res->y2) & 0xf0) << 4) | res->y1;
+
+ if (x != 0 && y != 0) {
+ printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel);
+ }
+
+ if (raw)
+ {
+ printf("Mode %02x (raw) :\n\t%02x %02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n\t%02x\n", map->mode_table[i].mode, res->unknow1[0],res->unknow1[1], res->x1,res->x_total,res->x2,res->y1,res->y_total,res->y2);
+ }
+
+ }
+ break;
+ case BT_2:
+ {
+ vbios_resolution_type2 * res = map_type2_resolution(map, map->mode_table[i].resolution);
+
+ x = res->modelines[0].x1+1;
+ y = res->modelines[0].y1+1;
+
+ if (x != 0 && y != 0) {
+ printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel);
+ }
+ }
+ break;
+ case BT_3:
+ {
+ vbios_resolution_type3 * res = map_type3_resolution(map, map->mode_table[i].resolution);
+
+ x = res->modelines[0].x1+1;
+ y = res->modelines[0].y1+1;
+
+ if (x != 0 && y != 0) {
+ printf("Mode %02x : %dx%d, %d bits/pixel\n", map->mode_table[i].mode, x, y, map->mode_table[i].bits_per_pixel);
+ }
+ }
+ break;
+ case BT_UNKWN:
+ break;
+ }
+ }
+}
+
+static void gtf_timings(int x, int y, int freq,
+ unsigned long *clock,
+ word *hsyncstart, word *hsyncend, word *hblank,
+ word *vsyncstart, word *vsyncend, word *vblank)
+{
+ int hbl, vbl, vfreq;
+
+ vbl = y + (y+1)/(20000.0/(11*freq) - 1) + 1.5;
+ vfreq = vbl * freq;
+ hbl = 16 * (int)(x * (30.0 - 300000.0 / vfreq) /
+ (70.0 + 300000.0 / vfreq) / 16.0 + 0.5);
+
+ *vsyncstart = y;
+ *vsyncend = y + 3;
+ *vblank = vbl - 1;
+ *hsyncstart = x + hbl / 2 - (x + hbl + 50) / 100 * 8 - 1;
+ *hsyncend = x + hbl / 2 - 1;
+ *hblank = x + hbl - 1;
+ *clock = (x + hbl) * vfreq / 1000;
+}
+
+void set_mode(vbios_map * map, cardinal mode, cardinal x, cardinal y, cardinal bp, cardinal htotal, cardinal vtotal) {
+ int xprev, yprev;
+ cardinal i, j;
+
+ for (i=0; i < map->mode_table_size; i++) {
+ if (map->mode_table[i].mode == mode) {
+ switch(map->bios) {
+ case BT_1:
+ {
+ vbios_resolution_type1 * res = map_type1_resolution(map, map->mode_table[i].resolution);
+
+ if (bp) {
+ map->mode_table[i].bits_per_pixel = bp;
+ }
+
+ res->x2 = (htotal?(((htotal-x) >> 8) & 0x0f) : (res->x2 & 0x0f)) | ((x >> 4) & 0xf0);
+ res->x1 = (x & 0xff);
+
+ res->y2 = (vtotal?(((vtotal-y) >> 8) & 0x0f) : (res->y2 & 0x0f)) | ((y >> 4) & 0xf0);
+ res->y1 = (y & 0xff);
+ if (htotal)
+ res->x_total = ((htotal-x) & 0xff);
+
+ if (vtotal)
+ res->y_total = ((vtotal-y) & 0xff);
+ }
+ break;
+ case BT_2:
+ {
+ vbios_resolution_type2 * res = map_type2_resolution(map, map->mode_table[i].resolution);
+
+ res->xchars = x / 8;
+ res->ychars = y / 16 - 1;
+ xprev = res->modelines[0].x1;
+ yprev = res->modelines[0].y1;
+
+ for(j=0; j < 3; j++) {
+ vbios_modeline_type2 * modeline = &res->modelines[j];
+
+ if (modeline->x1 == xprev && modeline->y1 == yprev) {
+ modeline->x1 = modeline->x2 = x-1;
+ modeline->y1 = modeline->y2 = y-1;
+
+ gtf_timings(x, y, freqs[j], &modeline->clock,
+ &modeline->hsyncstart, &modeline->hsyncend,
+ &modeline->hblank, &modeline->vsyncstart,
+ &modeline->vsyncend, &modeline->vblank);
+
+ if (htotal)
+ modeline->htotal = htotal;
+ else
+ modeline->htotal = modeline->hblank;
+
+ if (vtotal)
+ modeline->vtotal = vtotal;
+ else
+ modeline->vtotal = modeline->vblank;
+ }
+ }
+ }
+ break;
+ case BT_3:
+ {
+ vbios_resolution_type3 * res = map_type3_resolution(map, map->mode_table[i].resolution);
+
+ xprev = res->modelines[0].x1;
+ yprev = res->modelines[0].y1;
+
+ for (j=0; j < 3; j++) {
+ vbios_modeline_type3 * modeline = &res->modelines[j];
+
+ if (modeline->x1 == xprev && modeline->y1 == yprev) {
+ modeline->x1 = modeline->x2 = x-1;
+ modeline->y1 = modeline->y2 = y-1;
+
+ gtf_timings(x, y, freqs[j], &modeline->clock,
+ &modeline->hsyncstart, &modeline->hsyncend,
+ &modeline->hblank, &modeline->vsyncstart,
+ &modeline->vsyncend, &modeline->vblank);
+ if (htotal)
+ modeline->htotal = htotal;
+ else
+ modeline->htotal = modeline->hblank;
+ if (vtotal)
+ modeline->vtotal = vtotal;
+ else
+ modeline->vtotal = modeline->vblank;
+
+ modeline->timing_h = y-1;
+ modeline->timing_v = x-1;
+ }
+ }
+ }
+ break;
+ case BT_UNKWN:
+ break;
+ }
+ }
+ }
+}
+
+void display_map_info(vbios_map * map) {
+ printf("Chipset: %s\n", chipset_type_names[map->chipset]);
+ printf("BIOS: %s\n", bios_type_names[map->bios]);
+
+ printf("Mode Table Offset: $C0000 + $%x\n", ((cardinal)map->mode_table) - ((cardinal)map->bios_ptr));
+ printf("Mode Table Entries: %u\n", map->mode_table_size);
+}
+
+
+int parse_args(int argc, char *argv[], char ** filename, chipset_type *forced_chipset, cardinal *list, cardinal *mode, cardinal *x, cardinal *y, cardinal *bp, cardinal *raw, cardinal *htotal, cardinal *vtotal) {
+ cardinal index = 1;
+
+ *list = *mode = *x = *y = *raw = *htotal = *vtotal = 0;
+
+ *forced_chipset = CT_UNKWN;
+
+ *filename = NULL;
+
+ if ((argc > index) && !strcmp(argv[index], "-f")) {
+ index++;
+
+ if(argc<=index) {
+ return 0;
+ }
+
+ *filename = argv[index];
+
+ index++;
+
+ if(argc<=index) {
+ return 0;
+ }
+ }
+
+ if ((argc > index) && !strcmp(argv[index], "-c")) {
+ index++;
+
+ if(argc<=index) {
+ return 0;
+ }
+
+ if (!strcmp(argv[index], "845")) {
+ *forced_chipset = CT_845G;
+ }
+ else if (!strcmp(argv[index], "855")) {
+ *forced_chipset = CT_855GM;
+ }
+ else if (!strcmp(argv[index], "865")) {
+ *forced_chipset = CT_865G;
+ }
+ else if (!strcmp(argv[index], "915G")) {
+ *forced_chipset = CT_915G;
+ }
+ else if (!strcmp(argv[index], "915GM")) {
+ *forced_chipset = CT_915GM;
+ }
+ else if (!strcmp(argv[index], "945G")) {
+ *forced_chipset = CT_945G;
+ }
+ else if (!strcmp(argv[index], "945GM")) {
+ *forced_chipset = CT_945GM;
+ }
+ else if (!strcmp(argv[index], "946GZ")) {
+ *forced_chipset = CT_946GZ;
+ }
+ else if (!strcmp(argv[index], "G965")) {
+ *forced_chipset = CT_G965;
+ }
+ else if (!strcmp(argv[index], "Q965")) {
+ *forced_chipset = CT_Q965;
+ }
+ else {
+ *forced_chipset = CT_UNKWN;
+ }
+
+ index++;
+
+ if (argc<=index) {
+ return 0;
+ }
+ }
+
+ if ((argc > index) && !strcmp(argv[index], "-l")) {
+ *list = 1;
+ index++;
+
+ if(argc<=index) {
+ return 0;
+ }
+ }
+
+ if ((argc > index) && !strcmp(argv[index], "-r")) {
+ *raw = 1;
+ index++;
+
+ if(argc<=index) {
+ return 0;
+ }
+ }
+
+ if (argc-index < 3 || argc-index > 6) {
+ return -1;
+ }
+
+ *mode = (cardinal) strtol(argv[index], NULL, 16);
+ *x = (cardinal)atoi(argv[index+1]);
+ *y = (cardinal)atoi(argv[index+2]);
+
+
+ if (argc-index > 3) {
+ *bp = (cardinal)atoi(argv[index+3]);
+ }
+ else {
+ *bp = 0;
+ }
+
+ if (argc-index > 4) {
+ *htotal = (cardinal)atoi(argv[index+4]);
+ }
+ else {
+ *htotal = 0;
+ }
+
+ if (argc-index > 5) {
+ *vtotal = (cardinal)atoi(argv[index+5]);
+ }
+ else {
+ *vtotal = 0;
+ }
+
+ return 0;
+}
+
+void usage(char *name) {
+ printf("Usage: %s [-f file] [-c chipset] [-l] [mode X Y] [bits/pixel] [htotal] [vtotal]\n", name);
+ printf(" Set the resolution to XxY for a video mode\n");
+ printf(" Bits per pixel are optional. htotal/vtotal settings are additionally optional.\n");
+ printf(" Options:\n");
+ printf(" -f use an alternate file (THIS IS USED FOR DEBUG PURPOSES)\n");
+ printf(" -c force chipset type (THIS IS USED FOR DEBUG PURPOSES)\n");
+ printf(" -l display the modes found in the video BIOS\n");
+ printf(" -r display the modes found in the video BIOS in raw mode (THIS IS USED FOR DEBUG PURPOSES)\n");
+}
+
+int main (int argc, char *argv[]) {
+ vbios_map * map;
+ cardinal list, mode, x, y, bp, raw, htotal, vtotal;
+ char * filename;
+ chipset_type forced_chipset;
+
+ printf("Intel 800/900 Series VBIOS Hack : version %s\n\n", VERSION);
+
+ if (parse_args(argc, argv, &filename, &forced_chipset, &list, &mode, &x, &y, &bp, &raw, &htotal, &vtotal) == -1) {
+ usage(argv[0]);
+ return 2;
+ }
+
+ initialize_system(filename);
+
+ map = open_vbios(filename, forced_chipset);
+ display_map_info(map);
+
+ printf("\n");
+
+ if (list) {
+ list_modes(map, raw);
+ }
+
+ if (mode!=0 && x!=0 && y!=0) {
+ if (!filename)
+ unlock_vbios(map);
+
+ set_mode(map, mode, x, y, bp, htotal, vtotal);
+
+ if (!filename)
+ relock_vbios(map);
+
+ printf("Patch mode %02x to resolution %dx%d complete\n", mode, x, y);
+
+ if (list) {
+ list_modes(map, raw);
+ }
+ }
+
+ close_vbios(map);
+
+ return 0;
+}
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..70f8f06
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,16 @@
+/* =====================================================================
+ * This source code is into the public domain.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * =====================================================================
+ */
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..4e8db6e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,15 @@
+PRG=915resolution
+
+SRCS=915resolution.c
+OBJS=${SRCS:.c=.o}
+
+CFLAGS:=-s -Wall -ggdb
+
+${PRG}: ${OBJS}
+
+clean:
+ rm -f ${OBJS} ${PRG} *~
+
+install: ${PRG}
+ cp ${PRG} /usr/sbin
+
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..7d6f782
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,174 @@
+915resolution
+=============
+
+This software changes the resolution of an available vbios mode.
+
+It patches only the RAM version of the video bios so the new resolution
+is loose each time you reboot. If you want to set the resolution each
+time you reboot and before to launch X, use your rc.local, local.start ...
+file of your Linux version.
+
+915resolution supports the 845G, 855GM, 865G, 915G, 915GM, 945G, and 945GM chipsets.
+
+
+Usage
+-----
+
+You must be root to launch it.
+
+ Usage: 915resolution [-l] [mode X Y] [bits/pixel]
+ Options:
+ -l display the modes found into the vbios
+
+ Note that bits per pixel is optional. If you do specify anything,
+ then the original value will be preserved.
+
+
+Installing
+----------
+
+$ make
+$ su
+# make install
+
+Setting
+-------
+
+ 1. Switch to root
+ # su
+
+ 2. Display the available resolutions :
+
+ # 915resolution -l
+ Intel 800/900 Series VBIOS Hack : version 0.5.2
+
+ Chipset: 915GM
+ BIOS: TYPE 1
+ Mode Table Offset: $C0000 + $269
+ Mode Table Entries: 36
+ Mode Table Offset: $C0000 + $269
+ Mode Table Entries: 36
+
+ Mode 30 : 640x480, 8 bits/pixel
+ Mode 32 : 800x600, 8 bits/pixel
+ Mode 34 : 1024x768, 8 bits/pixel
+ Mode 38 : 1280x1024, 8 bits/pixel
+ Mode 3a : 1600x1200, 8 bits/pixel
+ Mode 3c : 1920x1440, 8 bits/pixel
+ Mode 41 : 640x480, 16 bits/pixel
+ Mode 43 : 800x600, 16 bits/pixel
+ Mode 45 : 1024x768, 16 bits/pixel
+ Mode 49 : 1280x1024, 16 bits/pixel
+ Mode 4b : 1600x1200, 16 bits/pixel
+ Mode 4d : 1920x1440, 16 bits/pixel
+ Mode 50 : 640x480, 32 bits/pixel
+ Mode 52 : 800x600, 32 bits/pixel
+ Mode 54 : 1024x768, 32 bits/pixel
+ Mode 58 : 1280x1024, 32 bits/pixel
+ Mode 5a : 1600x1200, 32 bits/pixel
+ Mode 5c : 1920x1440, 32 bits/pixel
+ Mode 60 : 1280x770, 8 bits/pixel
+ Mode 61 : 1280x770, 16 bits/pixel
+ Mode 62 : 1280x770, 32 bits/pixel
+ Mode 63 : 512x771, 8 bits/pixel
+ Mode 64 : 512x771, 16 bits/pixel
+ Mode 65 : 512x771, 32 bits/pixel
+
+ 3. I personnaly decided to overwrite the 1280x1024 resolution
+ because I don't use it :
+
+ # 915resolution 38 1280 800
+
+ 4. Now the bios reports a 1280x800 resolution :
+
+ # 915resolution -l
+ Intel 800/900 Series VBIOS Hack : version 0.5.2
+
+ Chipset: 915GM
+ BIOS: TYPE 1
+ Mode Table Offset: $C0000 + $269
+ Mode Table Entries: 36
+ Mode Table Offset: $C0000 + $269
+ Mode Table Entries: 36
+
+ Mode 30 : 640x480, 8 bits/pixel
+ Mode 32 : 800x600, 8 bits/pixel
+ Mode 34 : 1024x768, 8 bits/pixel
+ Mode 38 : 1280x800, 8 bits/pixel
+ Mode 3a : 1600x1200, 8 bits/pixel
+ Mode 3c : 1920x1440, 8 bits/pixel
+ Mode 41 : 640x480, 16 bits/pixel
+ Mode 43 : 800x600, 16 bits/pixel
+ Mode 45 : 1024x768, 16 bits/pixel
+ Mode 49 : 1280x800, 16 bits/pixel
+ Mode 4b : 1600x1200, 16 bits/pixel
+ Mode 4d : 1920x1440, 16 bits/pixel
+ Mode 50 : 640x480, 32 bits/pixel
+ Mode 52 : 800x600, 32 bits/pixel
+ Mode 54 : 1024x768, 32 bits/pixel
+ Mode 58 : 1280x800, 32 bits/pixel
+ Mode 5a : 1600x1200, 32 bits/pixel
+ Mode 5c : 1920x1440, 32 bits/pixel
+ Mode 60 : 1280x770, 8 bits/pixel
+ Mode 61 : 1280x770, 16 bits/pixel
+ Mode 62 : 1280x770, 32 bits/pixel
+ Mode 63 : 512x771, 8 bits/pixel
+ Mode 64 : 512x771, 16 bits/pixel
+ Mode 65 : 512x771, 32 bits/pixel
+
+ 5. On some machines 24 bits per pixel is the desired resolution.
+ An alternate invocation to achieve this would be:
+
+ # 915resolution 38 1280 800 24
+
+ 6. My xorg.conf has the following screen definition :
+
+ Section "Screen"
+ Identifier "Screen 1"
+ Device "device"
+ Monitor "LCD"
+ DefaultDepth 16
+
+ Subsection "Display"
+ Depth 16
+ Modes "1280x800"
+ EndSubsection
+ EndSection
+
+ 7. 915resolution must run before the X server is started. So I don't need to
+ do this every time I put it in my startup scripts. Where these scripts
+ are very from distribution to distribution. I'm running SUSE 9.2, so I
+ put the definition in /etc/init.d/boot.local:
+
+ #! /bin/sh
+ #
+ # Copyright (c) 2002 SuSE Linux AG Nuernberg, Germany. All rights reserved.
+ #
+ # Author: Werner Fink <werner@suse.de>, 1996
+ # Burchard Steinbild, 1996
+ #
+ # /etc/init.d/boot.local
+ #
+ # script with local commands to be executed from init on system startup
+ #
+ # Here you should add things, that should happen directly after booting
+ # before we're going to the first run level.
+ #
+
+ /usr/bin/915resolution 38 1280 800
+
+ 8. Start up the X server
+ # startx
+
+
+Disclaimer
+----------
+
+915resolution is free to use, distribute or modify. But please mention
+my name and the names of the respective contributors.
+I tried to make the programs as safe as possible but obviously I can't
+guarantee that they'll work for you. So don't blame me if something bad
+happens.
+
+ Steve Tomljenovic
+ stomljen at yahoo dot com
diff --git a/changes.log b/changes.log
new file mode 100644
index 0000000..92b26d0
--- /dev/null
+++ b/changes.log
@@ -0,0 +1,14 @@
+Version 0.5.3 Apr 15, 2007
+ - Added support for 830, 946GZ, G965, Q965
+ - Fixed bug when mapping to file
+ - Added correct timing routines
+
+Version 0.5.2 Feb 2, 2006
+ - Added htotal/vtotal feature for BIOS type 1 (865G) from Sergey Saukh (thelich at yandex.ru)
+
+Version 0.5.1 Jan 25, 2006
+ - Added 945GM chipset
+
+Version 0.5
+ - Improved error reporting on invalid chipsets
+
diff --git a/chipset_info.txt b/chipset_info.txt
new file mode 100644
index 0000000..927500f
--- /dev/null
+++ b/chipset_info.txt
@@ -0,0 +1,9 @@
+CHIPSET ID PAM
+======================================================
+845G, 845GL, 845GV $2560_8086 $91 - $92
+865G, 865GV $2570_8086 $91 - $92
+855GM, 855GME, 852GM, 852GMV $3580_8086 $5A - $5b
+915G $2580_8086 $91 - $92
+915PM, 915GM, 915GMS, 910GML $2590_8086 $91 - $92
+945G $2770_8086 $91 - $92
+945GM $27A0_8086 $91 - $92
diff --git a/dump_bios b/dump_bios
new file mode 100755
index 0000000..d8248d3
--- /dev/null
+++ b/dump_bios
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+dd if=/dev/mem of=vbios.dmp bs=16384 skip=48 count=4
+