[fbdebug] Add panning functionality (#1207)

This commit is contained in:
Daniele Debernardi 2018-02-06 22:21:25 +01:00 committed by Oliver Smith
parent 12487a1efa
commit 4c91a72ff1
2 changed files with 37 additions and 6 deletions

View file

@ -1,7 +1,7 @@
# Contributor: drebrez <drebrez@gmail.com>
# Maintainer: drebrez <drebrez@gmail.com>
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"

View file

@ -16,6 +16,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
@ -26,8 +27,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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,6 +158,7 @@ int main(int argc, char** argv)
}
// print all the fixed screen info values
if (show_info)
print_fix_screeninfo(&scr_fix);
// call ioctl. retrieve variable screen info
@ -153,8 +171,21 @@ int main(int argc, char** argv)
}
// print all the variable screen info values
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);
}