From 4c91a72ff1a189ed333c41eadc696a7a8d1160ef Mon Sep 17 00:00:00 2001 From: Daniele Debernardi Date: Tue, 6 Feb 2018 22:21:25 +0100 Subject: [PATCH] [fbdebug] Add panning functionality (#1207) --- main/fbdebug/APKBUILD | 4 ++-- main/fbdebug/fbdebug.c | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/main/fbdebug/APKBUILD b/main/fbdebug/APKBUILD index 2373fd4f6..75b772b76 100644 --- a/main/fbdebug/APKBUILD +++ b/main/fbdebug/APKBUILD @@ -1,7 +1,7 @@ # Contributor: drebrez # Maintainer: drebrez pkgname=fbdebug -pkgver=0.1 +pkgver=0.2 pkgrel=0 pkgdesc="Framebuffer debugging tool" url="https://github.com/postmarketOS" @@ -22,4 +22,4 @@ package() { "${pkgdir}/usr/sbin/fbdebug" } -sha512sums="adaad7542ccac8d10eac5761933c24de654ae169ea1d64649a8b728b4ecac987c77ca4f77d64a43e260c0042b207482936102ba55d9c528331eabefc746f3bae fbdebug.c" +sha512sums="d6e581f1de822ecac3a392ecd1a555d559fa28315006a94dbe86be2589137584b558e20abc5ae912e4b00c9d8a35db5139eb514b2c95dd2b2299a3fcd47cda46 fbdebug.c" diff --git a/main/fbdebug/fbdebug.c b/main/fbdebug/fbdebug.c index 425751216..41ad46bba 100644 --- a/main/fbdebug/fbdebug.c +++ b/main/fbdebug/fbdebug.c @@ -16,6 +16,7 @@ along with this program. If not, see . */ #include +#include #include #include #include @@ -26,8 +27,10 @@ along with this program. If not, see . void usage(char* appname) { - printf("Usage: %s [-d DEV] [-h]\n\ + printf("Usage: %s [-d DEV] [-i] [-p] [-h]\n\ -d Framebuffer device (default /dev/fb0)\n\ + -i Show fixed and variable screen info\n\ + -p Perform the panning of the display\n\ -h Show this help\n", appname); } @@ -108,14 +111,28 @@ int main(int argc, char** argv) // parse command line options fb_device = "/dev/fb0"; + bool show_info = false; + bool pan_display = false; + + if (argc < 2) + { + usage(argv[0]); + exit(1); + } int opt; - while ((opt = getopt(argc, argv, "d:h")) != -1) + while ((opt = getopt(argc, argv, "d:iph")) != -1) { switch (opt) { case 'd': fb_device = optarg; break; + case 'i': + show_info = true; + break; + case 'p': + pan_display = true; + break; case 'h': default: usage(argv[0]); @@ -141,7 +158,8 @@ int main(int argc, char** argv) } // print all the fixed screen info values - print_fix_screeninfo(&scr_fix); + if (show_info) + print_fix_screeninfo(&scr_fix); // call ioctl. retrieve variable screen info if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &scr_var) < 0) @@ -153,7 +171,20 @@ int main(int argc, char** argv) } // print all the variable screen info values - print_var_screeninfo(&scr_var); + if (show_info) + print_var_screeninfo(&scr_var); + + if (pan_display) + { + // call ioctl. pan the display + if (ioctl(fb_fd, FBIOPAN_DISPLAY, &scr_var) < 0) + { + printf("Unable to pan the display: %s\n", + strerror(errno)); + close(fb_fd); + return 1; + } + } // close the framebuffer device close(fb_fd);