set-resolution.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* vim: tabstop=4 shiftwidth=4 noexpandtab
  2. * This file is part of ToaruOS and is released under the terms
  3. * of the NCSA / University of Illinois License - see LICENSE.md
  4. * Copyright (C) 2018 K. Lange
  5. *
  6. * set-resolution - Change the display resolution.
  7. *
  8. * Simple tool to interface with the IO_VID_SET ioctl.
  9. *
  10. * TODO: This is probably something we should request from the
  11. * compositor rather than a separate application...
  12. */
  13. #include <stdio.h>
  14. #include <unistd.h>
  15. #include <fcntl.h>
  16. #include <stdlib.h>
  17. #include <stdint.h>
  18. #include <string.h>
  19. #include <errno.h>
  20. #include <sys/ioctl.h>
  21. #include <kernel/video.h>
  22. int main(int argc, char * argv[]) {
  23. if (argc < 3) {
  24. fprintf(stderr, "Usage: %s width height\n", argv[0]);
  25. }
  26. /* Open framebuffer */
  27. int fd = open("/dev/fb0", O_RDONLY);
  28. if (fd < 0) {
  29. perror("open");
  30. return 1;
  31. }
  32. /* Prepare ioctl from arguments */
  33. struct vid_size s;
  34. s.width = atoi(argv[1]);
  35. s.height = atoi(argv[2]);
  36. /* Send ioctl */
  37. if (ioctl(fd, IO_VID_SET, &s) < 0) {
  38. perror("ioctl");
  39. return 1;
  40. }
  41. return 0;
  42. }