1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 * $Id: lcd-bitmap.c 29248 2011-02-08 20:05:25Z thomasjfox $
10 * Copyright (C) 2011 Lorenzo Miori, Thomas Martitz
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
28 #include <sys/ioctl.h>
33 #include "screendump.h"
36 static int dev_fd
= 0;
39 void lcd_shutdown(void)
42 munmap(dev_fb
, FRAMEBUFFER_SIZE
);
46 void lcd_init_device(void)
49 struct fb_var_screeninfo vinfo
;
50 struct fb_fix_screeninfo finfo
;
52 /* Open the framebuffer device */
53 dev_fd
= open("/dev/fb0", O_RDWR
);
55 perror("Error: cannot open framebuffer device");
58 printf("The framebuffer device was opened successfully.\n");
60 /* Get the fixed properties */
61 if (ioctl(dev_fd
, FBIOGET_FSCREENINFO
, &finfo
) == -1) {
62 perror("Error reading fixed information");
66 /* Now we get the settable settings, and we set 16 bit bpp */
67 if (ioctl(dev_fd
, FBIOGET_VSCREENINFO
, &vinfo
) == -1) {
68 perror("Error reading variable information");
72 vinfo
.bits_per_pixel
= 16;
74 if (ioctl(dev_fd
, FBIOPUT_VSCREENINFO
, &vinfo
)) {
75 perror("fbset(ioctl)");
79 printf("%dx%d, %dbpp\n", vinfo
.xres
, vinfo
.yres
, vinfo
.bits_per_pixel
);
81 /* Figure out the size of the screen in bytes */
82 screensize
= vinfo
.xres
* vinfo
.yres
* vinfo
.bits_per_pixel
/ 8;
83 if (screensize
!= FRAMEBUFFER_SIZE
)
86 perror("Display and framebuffer mismatch!\n");
89 /* Map the device to memory */
90 dev_fb
= mmap(0, screensize
, PROT_READ
| PROT_WRITE
, MAP_SHARED
, dev_fd
, 0);
91 if ((int)dev_fb
== -1) {
92 perror("Error: failed to map framebuffer device to memory");
95 printf("The framebuffer device was mapped to memory successfully.\n");