diff options
Diffstat (limited to 'firmware/target/hosted/samsungypr/lcd-ypr.c')
-rw-r--r-- | firmware/target/hosted/samsungypr/lcd-ypr.c | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/firmware/target/hosted/samsungypr/lcd-ypr.c b/firmware/target/hosted/samsungypr/lcd-ypr.c new file mode 100644 index 0000000000..40528c298a --- /dev/null +++ b/firmware/target/hosted/samsungypr/lcd-ypr.c | |||
@@ -0,0 +1,96 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: lcd-bitmap.c 29248 2011-02-08 20:05:25Z thomasjfox $ | ||
9 | * | ||
10 | * Copyright (C) 2011 Lorenzo Miori, Thomas Martitz | ||
11 | * | ||
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. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdlib.h> | ||
23 | #include <unistd.h> | ||
24 | #include <stdio.h> | ||
25 | #include "string.h" | ||
26 | #include <linux/fb.h> | ||
27 | #include <sys/mman.h> | ||
28 | #include <sys/ioctl.h> | ||
29 | |||
30 | #include "file.h" | ||
31 | #include "debug.h" | ||
32 | #include "system.h" | ||
33 | #include "screendump.h" | ||
34 | #include "lcd.h" | ||
35 | |||
36 | static int dev_fd = 0; | ||
37 | fb_data *dev_fb = 0; | ||
38 | |||
39 | void lcd_shutdown(void) | ||
40 | { | ||
41 | printf("FB closed."); | ||
42 | munmap(dev_fb, FRAMEBUFFER_SIZE); | ||
43 | close(dev_fd); | ||
44 | } | ||
45 | |||
46 | void lcd_init_device(void) | ||
47 | { | ||
48 | size_t screensize; | ||
49 | struct fb_var_screeninfo vinfo; | ||
50 | struct fb_fix_screeninfo finfo; | ||
51 | |||
52 | /* Open the framebuffer device */ | ||
53 | dev_fd = open("/dev/fb0", O_RDWR); | ||
54 | if (dev_fd == -1) { | ||
55 | perror("Error: cannot open framebuffer device"); | ||
56 | exit(1); | ||
57 | } | ||
58 | printf("The framebuffer device was opened successfully.\n"); | ||
59 | |||
60 | /* Get the fixed properties */ | ||
61 | if (ioctl(dev_fd, FBIOGET_FSCREENINFO, &finfo) == -1) { | ||
62 | perror("Error reading fixed information"); | ||
63 | exit(2); | ||
64 | } | ||
65 | |||
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"); | ||
69 | exit(3); | ||
70 | } | ||
71 | |||
72 | vinfo.bits_per_pixel = 16; | ||
73 | |||
74 | if (ioctl(dev_fd, FBIOPUT_VSCREENINFO, &vinfo)) { | ||
75 | perror("fbset(ioctl)"); | ||
76 | exit(4); | ||
77 | } | ||
78 | |||
79 | printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel); | ||
80 | |||
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) | ||
84 | { | ||
85 | exit(4); | ||
86 | perror("Display and framebuffer mismatch!\n"); | ||
87 | } | ||
88 | |||
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"); | ||
93 | exit(4); | ||
94 | } | ||
95 | printf("The framebuffer device was mapped to memory successfully.\n"); | ||
96 | } | ||