2021-11-26 06:41:56 +03:00
|
|
|
/**
|
|
|
|
* @brief set-resolution - Change the display resolution.
|
|
|
|
*
|
|
|
|
* @copyright
|
2018-08-14 11:13:38 +03:00
|
|
|
* This file is part of ToaruOS and is released under the terms
|
|
|
|
* of the NCSA / University of Illinois License - see LICENSE.md
|
|
|
|
* Copyright (C) 2018 K. Lange
|
|
|
|
*/
|
2018-04-25 12:39:07 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
2018-07-19 16:52:17 +03:00
|
|
|
#include <errno.h>
|
2018-04-25 12:39:07 +03:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <kernel/video.h>
|
|
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
|
|
if (argc < 3) {
|
2018-10-27 10:18:09 +03:00
|
|
|
fprintf(stderr, "Usage: %s [--initialize DRIVER] WIDTH HEIGHT\n", argv[0]);
|
2018-11-02 03:07:58 +03:00
|
|
|
return 1;
|
2018-04-25 12:39:07 +03:00
|
|
|
}
|
|
|
|
|
2018-08-14 11:13:38 +03:00
|
|
|
/* Open framebuffer */
|
2018-04-25 12:39:07 +03:00
|
|
|
int fd = open("/dev/fb0", O_RDONLY);
|
|
|
|
|
2018-07-19 16:52:17 +03:00
|
|
|
if (fd < 0) {
|
|
|
|
perror("open");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-10-27 10:18:09 +03:00
|
|
|
int i = 1;
|
|
|
|
int init = 0;
|
|
|
|
char * driver = NULL;
|
|
|
|
|
|
|
|
if (argc > 4 && !strcmp(argv[1],"--initialize")) {
|
|
|
|
init = 1;
|
|
|
|
driver = argv[2];
|
|
|
|
i += 2;
|
|
|
|
}
|
|
|
|
|
2018-08-14 11:13:38 +03:00
|
|
|
/* Prepare ioctl from arguments */
|
2018-04-25 12:39:07 +03:00
|
|
|
struct vid_size s;
|
2018-10-27 10:18:09 +03:00
|
|
|
s.width = atoi(argv[i]);
|
|
|
|
s.height = atoi(argv[i+1]);
|
2018-04-25 12:39:07 +03:00
|
|
|
|
2018-08-14 11:13:38 +03:00
|
|
|
/* Send ioctl */
|
2018-10-27 10:18:09 +03:00
|
|
|
if (init) {
|
|
|
|
char tmp[100];
|
2021-05-31 04:47:02 +03:00
|
|
|
sprintf(tmp, "%s,%u,%u", driver, s.width, s.height);
|
2018-10-27 10:18:09 +03:00
|
|
|
if (ioctl(fd, IO_VID_REINIT, tmp) < 0) {
|
|
|
|
perror("ioctl");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ioctl(fd, IO_VID_SET, &s) < 0) {
|
|
|
|
perror("ioctl");
|
|
|
|
return 1;
|
|
|
|
}
|
2018-07-19 16:52:17 +03:00
|
|
|
}
|
2018-04-25 12:39:07 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|