NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: xsrc/49495



Can you please try running the attached program and seeing whether
anything shows up on your display?

make writefb
./writefb /dev/ttyE0 0xff350053

(Run as root; this will permanently set ttyE0 into dumbfb mode, unless
you write another program that puts it back into text mode.)

This will determine whether the problem is just with the kernel
driver, or whether X is actually involved too.
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/time.h>

#include <dev/wscons/wsconsio.h>

#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

#define	howmany(n, d)	(((n) + ((d) - 1)) / (d))
#define	roundup(n, d)	(howmany(n, d) * (d))

static void
signal_ignore(int signo __unused)
{
}

int
main(int argc, char **argv)
{
	const char *device;
	char *ep;
	unsigned long value;
	int fd;
	struct wsdisplay_fbinfo fbi;
	unsigned int mode;
	size_t fbsize;
	uint32_t *fb;
	size_t i;

	setprogname(argv[0]);
	if (signal(SIGPIPE, &signal_ignore) == SIG_ERR)
		err(1, "signal(SIGPIPE)");

	if (argc != 3)
		errx(1, "Usage: %s <device> <value>\n", getprogname());

	device = argv[1];
	errno = 0;
	value = strtoul(argv[2], &ep, 0);
	if ((argv[2][0] == '\0') || (*ep != '\0'))
		errx(1, "bad value");
	if ((errno == ERANGE) && (value == ULONG_MAX))
		errx(1, "value too large");

	fd = open(argv[1], O_RDWR);
	if (fd == -1)
		err(1, "open fb");

	if (ioctl(fd, WSDISPLAYIO_GINFO, &fbi) == -1)
		err(1, "ioctl(WSDISPLAYIO_GINFO)");
	warnx("width    %u", fbi.width);
	warnx("height   %u", fbi.height);
	warnx("depth    %u", fbi.depth);
	warnx("cmsize   %u", fbi.cmsize);

	if (fbi.depth != 32)
		errx(1, "bad depth");

	if (ioctl(fd, WSDISPLAYIO_GMODE, &mode) == -1)
		err(1, "ioctl(WSDISPLAYIO_GMODE)");
	warnx("mode	%u", mode);

	mode = WSDISPLAYIO_MODE_DUMBFB;
	if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) == -1)
		err(1, "ioctl(WSDISPLAYIO_SMODE)");

	fbsize = roundup((fbi.width * fbi.height * howmany(fbi.depth, 8)),
	    getpagesize());
	fb = mmap(NULL, fbsize, (PROT_READ | PROT_WRITE), MAP_PRIVATE, fd, 0);
	if (fb == MAP_FAILED)
		err(1, "mmap fb");

	for (i = 0; i < (fbsize / 4); i++)
		fb[i] = value;

	if (munmap(fb, fbsize) == -1)
		err(1, "munmap fb");

	if (close(fd) == -1)
		err(1, "close fb");

	return 0;
}


Home | Main Index | Thread Index | Old Index