paul@0 | 1 | /* |
paul@0 | 2 | * Access the LCD on JZ4740-based platforms. |
paul@0 | 3 | * |
paul@0 | 4 | * (c) 2018 Paul Boddie <paul@boddie.org.uk> |
paul@0 | 5 | * |
paul@0 | 6 | * This program is free software; you can redistribute it and/or |
paul@0 | 7 | * modify it under the terms of the GNU General Public License as |
paul@0 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@0 | 9 | * the License, or (at your option) any later version. |
paul@0 | 10 | * |
paul@0 | 11 | * This program is distributed in the hope that it will be useful, |
paul@0 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@0 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@0 | 14 | * GNU General Public License for more details. |
paul@0 | 15 | * |
paul@0 | 16 | * You should have received a copy of the GNU General Public License |
paul@0 | 17 | * along with this program; if not, write to the Free Software |
paul@0 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@0 | 19 | * Boston, MA 02110-1301, USA |
paul@0 | 20 | */ |
paul@0 | 21 | |
paul@0 | 22 | #include <l4/devices/lcd-device.h> |
paul@0 | 23 | #include <l4/re/c/video/view.h> |
paul@0 | 24 | #include <l4/sys/cache.h> |
paul@0 | 25 | |
paul@0 | 26 | #include <stdint.h> |
paul@0 | 27 | |
paul@0 | 28 | int main(void) |
paul@0 | 29 | { |
paul@0 | 30 | l4re_video_view_info_t view_info; |
paul@0 | 31 | l4_size_t i, limit, line, digit, row, mask, value, onpix, offpix; |
paul@0 | 32 | |
paul@0 | 33 | /* Obtain device and get framebuffer details. */ |
paul@0 | 34 | |
paul@0 | 35 | void *lcd_device = lcd_get_device(); |
paul@0 | 36 | l4_addr_t fb_vaddr = lcd_get_framebuffer(lcd_device); |
paul@0 | 37 | l4_size_t fb_size = lcd_get_framebuffer_size(lcd_device); |
paul@0 | 38 | uint32_t *fb32 = (uint32_t *) fb_vaddr; |
paul@0 | 39 | uint16_t *fb16 = (uint16_t *) fb_vaddr; |
paul@0 | 40 | |
paul@0 | 41 | if (!fb_vaddr) return 1; |
paul@0 | 42 | |
paul@0 | 43 | lcd_get_view_info(lcd_device, &view_info); |
paul@0 | 44 | lcd_enable(lcd_device); |
paul@0 | 45 | |
paul@0 | 46 | /* Try and show some values. */ |
paul@0 | 47 | |
paul@0 | 48 | onpix = 0xffaaffaa; offpix = 0x11551155; |
paul@0 | 49 | mask = 0x80000000; value = (l4_size_t) view_info.width; |
paul@0 | 50 | |
paul@0 | 51 | i = 0; |
paul@0 | 52 | limit = fb_size / view_info.pixel_info.bytes_per_pixel; |
paul@0 | 53 | line = limit / view_info.height; |
paul@0 | 54 | digit = line / 32; |
paul@0 | 55 | row = line * 10; |
paul@0 | 56 | |
paul@0 | 57 | while (i < limit) |
paul@0 | 58 | { |
paul@0 | 59 | if (view_info.pixel_info.bytes_per_pixel == 2) |
paul@0 | 60 | fb16[i] = value & mask ? onpix : offpix; |
paul@0 | 61 | else |
paul@0 | 62 | fb32[i] = value & mask ? onpix : offpix; |
paul@0 | 63 | |
paul@0 | 64 | i++; |
paul@0 | 65 | |
paul@0 | 66 | if ((i % digit) == 0) |
paul@0 | 67 | { |
paul@0 | 68 | if (mask == 1) mask = 0x80000000; |
paul@0 | 69 | else mask >>= 1; |
paul@0 | 70 | |
paul@0 | 71 | onpix = (onpix >> 8) | ((onpix & 0xff) << 24); |
paul@0 | 72 | offpix = (offpix >> 8) | ((offpix & 0xff) << 24); |
paul@0 | 73 | |
paul@0 | 74 | if (i == row) value = (l4_size_t) view_info.height; |
paul@0 | 75 | else if (i == (row * 2)) value = 0x80000001; |
paul@0 | 76 | } |
paul@0 | 77 | } |
paul@0 | 78 | |
paul@0 | 79 | l4_cache_clean_data((unsigned long) fb_vaddr, (unsigned long) fb_vaddr + fb_size); |
paul@0 | 80 | |
paul@0 | 81 | while (1); |
paul@0 | 82 | |
paul@0 | 83 | return 0; |
paul@0 | 84 | } |