summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorStew Benedict <stewb@mandriva.org>2005-02-23 00:05:11 +0000
committerStew Benedict <stewb@mandriva.org>2005-02-23 00:05:11 +0000
commitf6238693bdf079dedb9c32202a91c83fbecefb0b (patch)
treed37a56ce0ef866df3deb24b2f4bbc4567cdb93c9 /tools
parent4adf9a5a46a8270cc66af338d5c63de55267432c (diff)
downloaddrakx-backup-do-not-use-f6238693bdf079dedb9c32202a91c83fbecefb0b.tar
drakx-backup-do-not-use-f6238693bdf079dedb9c32202a91c83fbecefb0b.tar.gz
drakx-backup-do-not-use-f6238693bdf079dedb9c32202a91c83fbecefb0b.tar.bz2
drakx-backup-do-not-use-f6238693bdf079dedb9c32202a91c83fbecefb0b.tar.xz
drakx-backup-do-not-use-f6238693bdf079dedb9c32202a91c83fbecefb0b.zip
Support for XBox. Original code up the machine.
Diffstat (limited to 'tools')
-rw-r--r--tools/ddcprobe/Makefile2
-rw-r--r--tools/ddcprobe/ddcxinfos.c20
-rw-r--r--tools/ddcprobe/xbox.c90
-rw-r--r--tools/ddcprobe/xbox.h5
4 files changed, 110 insertions, 7 deletions
diff --git a/tools/ddcprobe/Makefile b/tools/ddcprobe/Makefile
index 321c5f4e9..fd5646869 100644
--- a/tools/ddcprobe/Makefile
+++ b/tools/ddcprobe/Makefile
@@ -18,7 +18,7 @@ INCS = -I.
LDFLAGS = -lm
ifeq (y,$(HAS_VBE))
LDFLAGS += -L. -lint10 -lx86emu
-OBJS = ddcxinfos.o vesamode.o vbe.o
+OBJS = ddcxinfos.o vesamode.o vbe.o xbox.o
LIBS = libint10.a libx86emu.a
DEFS += -DHAVE_VBE
endif
diff --git a/tools/ddcprobe/ddcxinfos.c b/tools/ddcprobe/ddcxinfos.c
index e595d549c..44d9fdc48 100644
--- a/tools/ddcprobe/ddcxinfos.c
+++ b/tools/ddcprobe/ddcxinfos.c
@@ -9,6 +9,7 @@
#include <stdarg.h>
#include "vbe.h"
#include "vesamode.h"
+#include "xbox.h"
#ifdef HAVE_VBE
#include "int10/vbios.h"
@@ -43,13 +44,17 @@ int main(void)
/* Determine PCI configuration type */
pci_config_type = 1;
- /* Initialize Int10 */
- if (InitInt10(pci_config_type)) return 1;
-
/* Get VBE information */
- if (vbe_get_vbe_info(vbe_info) == 0) {
- FreeInt10();
- return 1;
+ if (box_is_xbox() == 1) {
+ if (get_fb_info(vbe_info) == 0)
+ return 1;
+ } else {
+ /* Initialize Int10 */
+ if (InitInt10(pci_config_type)) return 1;
+ if (vbe_get_vbe_info(vbe_info) == 0) {
+ FreeInt10();
+ return 1;
+ }
}
printf("%dKB of video ram\n", vbe_info->memory_size / 1024);
@@ -64,6 +69,9 @@ int main(void)
known_vesa_modes[i].y
);
#endif
+ /* optimal on a TV, just return canned values */
+ if (box_is_xbox() == 1)
+ printf("%d %d %d\n", 16777216, 640, 480);
printf("\n");
/* Get EDID information */
diff --git a/tools/ddcprobe/xbox.c b/tools/ddcprobe/xbox.c
new file mode 100644
index 000000000..ae1d8f0d7
--- /dev/null
+++ b/tools/ddcprobe/xbox.c
@@ -0,0 +1,90 @@
+/* test for an xbox and return video ram from fb device
+ * sbenedict@mandrakesoft.com
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <sys/ioctl.h>
+#include <linux/fb.h>
+#include "vbe.h"
+
+int box_is_xbox() {
+ int is_xbox = 0;
+ int result = -1;
+ int fd;
+ size_t rd;
+ char *xbox_id = "0000\t10de02a5";
+ char id[13];
+
+ if (!(fd = open("/proc/bus/pci/devices", O_RDONLY))) {
+ printf("Unable to open /proc/bus/pci/devices\n");
+ }
+ if (!(rd = read(fd, id, sizeof(id)))) {
+ printf("Unable to read /proc/bus/pci/devices\n");
+ }
+
+ if (fd > 0)
+ close(fd);
+
+#if DEBUG
+ printf("read_id: %s\n", id);
+ printf("xbox_id: %s\n", xbox_id);
+#endif
+ result = strncmp(id, xbox_id, 13);
+ if (result == 0)
+ is_xbox = 1;
+ return is_xbox;
+}
+
+/* taken from of.c */
+int get_fb_info(struct vbe_info *ret)
+{
+ struct fb_fix_screeninfo fix;
+ unsigned char *mem;
+ int rc = 0;
+ int fd = -1;
+ int i;
+
+ if (ret == NULL)
+ return 0;
+
+ if (!rc && !(fd = open("/dev/fb0", O_RDONLY)))
+ {
+ rc = 1;
+ fprintf(stderr, "Unable to open /dev/fb0. Exiting.\n");
+ }
+
+ if ((!rc) && (ioctl(fd, FBIOGET_FSCREENINFO, &fix)))
+ {
+ rc = 1;
+ fprintf(stderr, "Framebuffer ioctl failed. Exiting.\n");
+ }
+
+ if (fd > 0)
+ close(fd);
+
+ if (!rc)
+ {
+ // Note: if OFfb, vram info is unreliable!
+ if (strcmp(fix.id, "OFfb"))
+ {
+ mem = strdup(fix.id);
+ while(((i = strlen(mem)) > 0) && isspace(mem[i - 1])) {
+ mem[i - 1] = '\0';
+ }
+ ret->oem_name = strdup(mem);
+ ret->product_name = NULL;
+ ret->vendor_name = NULL;
+ ret->product_revision = NULL;
+ ret->memory_size = fix.smem_len;
+ }
+ }
+
+ return !rc;
+}
diff --git a/tools/ddcprobe/xbox.h b/tools/ddcprobe/xbox.h
new file mode 100644
index 000000000..8e1cf2b7e
--- /dev/null
+++ b/tools/ddcprobe/xbox.h
@@ -0,0 +1,5 @@
+/* function prototypes for xbox.c
+ sbenedict@mandrakesoft.com
+*/
+int box_is_xbox();
+int get_fb_info(struct vbe_info *vbe);