Skip to content

Instantly share code, notes, and snippets.

@ao-kenji
Created November 10, 2013 14:07
Show Gist options
  • Save ao-kenji/7398717 to your computer and use it in GitHub Desktop.
Save ao-kenji/7398717 to your computer and use it in GitHub Desktop.
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <dev/wscons/wsconsio.h>
uint gtype;
uint gmode;
uint orig_gmode;
struct wsdisplay_fbinfo ws_fbinfo;
int
main()
{
int fd, ret;
unsigned int data;
/*
fd = open("/dev/wsdisplay0", O_RDWR, 0666);
*/
fd = open("/dev/ttyC0", O_RDWR, 0666);
if (fd == -1) {
perror("open");
return 1;
}
ioctl(fd, WSDISPLAYIO_GTYPE, &gtype);
printf("GTYPE: %d\n", gtype);
ioctl(fd, WSDISPLAYIO_GMODE, &orig_gmode);
printf("GMODE: %d\n", orig_gmode);
gmode = WSDISPLAYIO_MODE_MAPPED;
ret = ioctl(fd, WSDISPLAYIO_SMODE, &gmode);
printf("WSDISPLAYIO_SMODE:\n");
printf("\treturn = %d\n", ret);
ioctl(fd, WSDISPLAYIO_GINFO, &ws_fbinfo);
printf("WSDISPLAYIO_GINFO: %d %d %d %d\n",
ws_fbinfo.height, ws_fbinfo.width,
ws_fbinfo.depth, ws_fbinfo.cmsize);
ret = ioctl(fd, WSDISPLAYIO_GETSUPPORTEDDEPTH, &data);
printf("WSDISPLAYIO_GETSUPPORTEDDEPTH: %x\n", data);
{
struct wsdisplay_gfx_mode gfx_mode ;
gfx_mode.width = 1280;
gfx_mode.height = 1024;
gfx_mode.depth = 1;
if (ioctl(fd , WSDISPLAYIO_SETGFXMODE , &gfx_mode) == -1)
printf("WSDISPLAYIO_SETGFXMODE failed\n");
}
ret = ioctl(fd, WSDISPLAYIO_SMODE, &orig_gmode);
printf("WSDISPLAYIO_SMODE:\n");
printf("\treturn = %d\n", ret);
close(fd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment