| 1 | #include <stdio.h> |
| 2 | #include <sys/types.h> |
| 3 | #include <sys/stat.h> |
| 4 | #include <fcntl.h> |
| 5 | #include <unistd.h> |
| 6 | #include <sys/ioctl.h> |
| 7 | #include <linux/fb.h> |
| 8 | #include <linux/omapfb.h> |
| 9 | #include <linux/kd.h> |
| 10 | |
| 11 | int main() |
| 12 | { |
| 13 | struct fb_var_screeninfo fbvar; |
| 14 | int ret, fbdev, kbdfd; |
| 15 | |
| 16 | fbdev = open("/dev/fb0", O_RDWR); |
| 17 | if (fbdev == -1) { |
| 18 | perror("open fb0"); |
| 19 | goto end_fb0; |
| 20 | } |
| 21 | |
| 22 | ret = ioctl(fbdev, FBIOGET_VSCREENINFO, &fbvar); |
| 23 | if (ret == -1) { |
| 24 | perror("FBIOGET_VSCREENINFO ioctl"); |
| 25 | goto end_fb0; |
| 26 | } |
| 27 | |
| 28 | if (fbvar.yoffset != 0) { |
| 29 | printf("fixing yoffset.. "); |
| 30 | fbvar.yoffset = 0; |
| 31 | ret = ioctl(fbdev, FBIOPAN_DISPLAY, &fbvar); |
| 32 | if (ret < 0) |
| 33 | perror("ioctl FBIOPAN_DISPLAY"); |
| 34 | else |
| 35 | printf("ok\n"); |
| 36 | } |
| 37 | |
| 38 | end_fb0: |
| 39 | if (fbdev >= 0) |
| 40 | close(fbdev); |
| 41 | |
| 42 | fbdev = open("/dev/fb1", O_RDWR); |
| 43 | if (fbdev == -1) { |
| 44 | perror("open fb1"); |
| 45 | goto end_fb1; |
| 46 | } |
| 47 | |
| 48 | ret = ioctl(fd, OMAPFB_QUERY_PLANE, &pi); |
| 49 | ret |= ioctl(fd, OMAPFB_QUERY_MEM, &mi); |
| 50 | if (ret != 0) |
| 51 | perror("QUERY_*"); |
| 52 | |
| 53 | pi.enabled = 0; |
| 54 | ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi); |
| 55 | if (ret != 0) |
| 56 | perror("SETUP_PLANE"); |
| 57 | |
| 58 | mi.size = 0; |
| 59 | ret = ioctl(fd, OMAPFB_SETUP_MEM, &mi); |
| 60 | if (ret != 0) |
| 61 | perror("SETUP_MEM"); |
| 62 | |
| 63 | end_fb1: |
| 64 | if (fbdev >= 0) |
| 65 | close(fbdev); |
| 66 | |
| 67 | kbdfd = open("/dev/tty", O_RDWR); |
| 68 | if (kbdfd == -1) { |
| 69 | perror("open /dev/tty"); |
| 70 | return 1; |
| 71 | } |
| 72 | |
| 73 | if (ioctl(kbdfd, KDSETMODE, KD_TEXT) == -1) |
| 74 | perror("KDSETMODE KD_TEXT"); |
| 75 | |
| 76 | close(kbdfd); |
| 77 | |
| 78 | return 0; |
| 79 | } |