openbsd-ports/x11/915resolution/patches/patch-915resolution_c
2007-09-17 12:14:11 +00:00

158 lines
4.0 KiB
Plaintext

$OpenBSD: patch-915resolution_c,v 1.3 2007/09/17 12:14:11 kettenis Exp $
--- 915resolution.c.orig Sun Apr 15 12:46:56 2007
+++ 915resolution.c Wed Sep 12 20:47:21 2007
@@ -22,7 +22,24 @@
#include <string.h>
#include <sys/mman.h>
#include <fcntl.h>
+#if defined(__OpenBSD__)
+#if defined(__i386__)
+#include <i386/pio.h>
+#include <i386/sysarch.h>
+#define IOPL(x) i386_iopl(x)
+#elif defined(__amd64__)
+#include <amd64/pio.h>
+#include <amd64/sysarch.h>
+#define IOPL(x) amd64_iopl(x)
+#endif
+#define OUTL(x,y) outl(y,x)
+#define OUTB(x,y) outb(y,x)
+#else
#include <sys/io.h>
+#define IOPL(x) iopl(x)
+#define OUTL(x,y) outl(x,y)
+#define OUTB(x,y) outb(x,y)
+#endif
#include <unistd.h>
#include <assert.h>
@@ -56,12 +73,12 @@ 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
+ CT_946GZ, CT_G965, CT_Q965, CT_GM965
} chipset_type;
char * chipset_type_names[] = {
"UNKNOWN", "830", "845G", "855GM", "865G", "915G", "915GM", "945G", "945GM",
- "946GZ", "G965", "Q965"
+ "946GZ", "G965", "Q965", "GM965"
};
typedef enum {
@@ -165,7 +182,7 @@ typedef struct {
void initialize_system(char * filename) {
if (!filename) {
- if (iopl(3) < 0) {
+ if (IOPL(3) < 0) {
perror("Unable to obtain the proper IO permissions");
exit(2);
}
@@ -173,7 +190,7 @@ void initialize_system(char * filename) {
}
cardinal get_chipset_id(void) {
- outl(0x80000000, 0xcf8);
+ OUTL(0x80000000, 0xcf8);
return inl(0xcfc);
}
@@ -225,6 +242,10 @@ chipset_type get_chipset(cardinal id) {
type = CT_Q965;
break;
+ case 0x2a008086:
+ type = CT_GM965;
+ break;
+
default:
type = CT_UNKWN;
break;
@@ -350,6 +371,7 @@ vbios_map * open_vbios(char * filename, chipset_type f
}
}
+#if 0
/*
* check if we have ATI Radeon
*/
@@ -398,6 +420,7 @@ vbios_map * open_vbios(char * filename, chipset_type f
close_vbios(map);
exit(2);
}
+#endif /* 0 */
/*
* Figure out where the mode table is
@@ -496,11 +519,11 @@ void unlock_vbios(vbios_map * map) {
break;
case CT_830:
case CT_855GM:
- outl(0x8000005a, 0xcf8);
+ OUTL(0x8000005a, 0xcf8);
map->b1 = inb(0xcfe);
- outl(0x8000005a, 0xcf8);
- outb(0x33, 0xcfe);
+ OUTL(0x8000005a, 0xcf8);
+ OUTB(0x33, 0xcfe);
break;
case CT_845G:
case CT_865G:
@@ -511,13 +534,14 @@ void unlock_vbios(vbios_map * map) {
case CT_946GZ:
case CT_G965:
case CT_Q965:
- outl(0x80000090, 0xcf8);
+ case CT_GM965:
+ OUTL(0x80000090, 0xcf8);
map->b1 = inb(0xcfd);
map->b2 = inb(0xcfe);
- outl(0x80000090, 0xcf8);
- outb(0x33, 0xcfd);
- outb(0x33, 0xcfe);
+ OUTL(0x80000090, 0xcf8);
+ OUTB(0x33, 0xcfd);
+ OUTB(0x33, 0xcfe);
break;
}
@@ -539,8 +563,8 @@ void relock_vbios(vbios_map * map) {
break;
case CT_830:
case CT_855GM:
- outl(0x8000005a, 0xcf8);
- outb(map->b1, 0xcfe);
+ OUTL(0x8000005a, 0xcf8);
+ OUTB(map->b1, 0xcfe);
break;
case CT_845G:
case CT_865G:
@@ -551,9 +575,10 @@ void relock_vbios(vbios_map * map) {
case CT_946GZ:
case CT_G965:
case CT_Q965:
- outl(0x80000090, 0xcf8);
- outb(map->b1, 0xcfd);
- outb(map->b2, 0xcfe);
+ case CT_GM965:
+ OUTL(0x80000090, 0xcf8);
+ OUTB(map->b1, 0xcfd);
+ OUTB(map->b2, 0xcfe);
break;
}
@@ -811,6 +836,9 @@ int parse_args(int argc, char *argv[], char ** filenam
}
else if (!strcmp(argv[index], "Q965")) {
*forced_chipset = CT_Q965;
+ }
+ else if (!strcmp(argv[index], "GM965")) {
+ *forced_chipset = CT_GM965;
}
else {
*forced_chipset = CT_UNKWN;