Created
November 10, 2013 14:07
-
-
Save ao-kenji/7398717 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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, >ype); | |
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