I’ve got a simple C program appended, which we can run on a couple of
machines with no problem, but of course when we run it on >mine<, we’re
getting some funky results.
My machine is a p3 500mz with Voodoo3, runs Photon fine.
Here is the command I’m running:
modetest -Ddevg-banshee.so -I0 -d0x121a,0x0005
Here is the output of modetest:
Opening [devg-banshee.so]
PCI device parameters:
bus = 0x0
vendor = 0x121A
device = 0x5
Valid display modes:
0x804: -1338924742x-1338721044, 8 bpp
0x804: -1338924742x-1338721044, 16 bpp
0x804: -1338924742x-1338721044, 24 bpp
0x804: -1338924742x-1338721044, 32 bpp
Here is output of crttrap trap:
/usr/photon/bin/devgt-iographics -dldevg-banshee.so -I0 -d0x121a,0x0005
/usr/photon/bin/devgt-iographics -dldevg-vesabios.so -I0 -d0x121a,0x0005
crttrap: wrote config file as /etc/system/config/graphics-modes
Obviously the dimensions are a bit off
What’d we do wrong?
–
Patrick_Mueller@oti.com
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#include <malloc.h>
#include <unistd.h>
#include <pthread.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/neutrino.h>
#include <graphics/display.h>
typedef struct {
char dll[80];
int pciBus;
int pciVendorID;
int pciDeviceID;
} GraphicsDeviceOptions;
typedef int (*f_mode) (disp_adapter_t *ctx, disp_modefuncs_t *fns, int
tabsize);
static void parseCommandLine(int argc, char **argv, GraphicsDeviceOptions
*options) {
int c, pci = 0;
char *token, tmp[80];
while((c = getopt( argc, argv, “D:I:d:” )) != -1) {
switch (c) {
case ‘D’:
//printf("%s\n", optarg);
strcpy(options->dll, optarg);
break;
case ‘I’:
//printf("%s\n", optarg);
options->pciBus = atoi(optarg);
pci = 1;
break;
case ‘d’:
//printf("%s\n", optarg);
strcpy(tmp, optarg);
token = strtok(tmp, “,”);
if (token == NULL) {
printf(“Invalid device and vendor IDs.\n”);
exit(1);
}
options->pciVendorID = atoh(&token[2]);
token = NULL;
token = strtok(NULL, “,”);
if (token == NULL) {
printf(“Invalid device and vendor IDs.\n”);
exit(1);
}
options->pciDeviceID = atoh(&token[2]);
token = NULL;
break;
default:
exit(1);
}
}
if (!pci) {
options->pciBus = -1;
options->pciVendorID = -1;
options->pciDeviceID = -1;
}
}
static void printModes(GraphicsDeviceOptions *options) {
f_mode mode;
disp_modefuncs_t mode_funcs;
disp_adapter_t adapter;
void *dll;
int size = 50, i = 0, rc;
disp_mode_t *list;
disp_mode_info_t info;
memset(&adapter, 0, sizeof(disp_adapter_t));
printf(“Opening [%s]\n”, options->dll);
if (options->pciBus != -1) {
printf(“PCI device parameters:\n”);
adapter.bus.pci.pci_index = options->pciBus;
adapter.bus.pci.pci_vendor_id = options->pciVendorID;
adapter.bus.pci.pci_device_id = options->pciDeviceID;
printf(“bus = 0x%X\n”, options->pciBus);
printf(“vendor = 0x%X\n”, options->pciVendorID);
printf(“device = 0x%X\n”, options->pciDeviceID);
}
dll = dlopen(options->dll, 0);
if (NULL == dll) {
printf(“dlopen() error: %s\n”, dlerror());
return;
}
mode = (f_mode)dlsym(dll, “devg_get_modefuncs”);
if (NULL == mode) {
printf(“Error getting symbol devg_get_modefuncs: %s\n”,
dlerror());
return;
}
rc = mode(&adapter, &mode_funcs, sizeof(disp_modefuncs_t));
if (-1 == rc) {
printf(“Error calling devg_get_modefuncs\n”);
return;
}
rc = mode_funcs.init(&adapter, NULL);
if (-1 == rc) {
printf(“Error calling mode_funcs.init()\n”);
fflush(stdout);
return;
}
list = calloc(size, sizeof(disp_mode_t));
mode_funcs.get_modelist(&adapter, 0, list, 0, size);
printf(“Valid display modes:\n”);
while (list _!= DISP_MODE_LISTEND) {
mode_funcs.get_modeinfo(&adapter, 0, list, &info);
printf(“0x%X: %dx%d, %d bpp\n”, info.mode, info.xres, info.yres,
DISP_BITS_PER_PIXEL(info.pixel_format));
i++;
}
free(list);
mode_funcs.fini(&adapter);
}
int main(int argc, char **argv) {
GraphicsDeviceOptions options;
if (ThreadCtl(NTO_TCTL_IO, 0) == -1) {
perror(“ThreadCtl”);
exit(1);
}
if (argc > 1) {
parseCommandLine(argc, argv, &options);
printModes(&options);
}
else {
printf(“Invalid command line.\n”);
}
return 0;
}