1 /* 2 * LCD device support. 3 * 4 * Copyright (C) 2018, 2020, 2023, 2024 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #pragma once 23 24 #include <l4/devices/dma.h> 25 #include <l4/devices/lcd/activation_interface.h> 26 #include <l4/devices/lcd.h> 27 28 #include <l4/re/c/video/view.h> 29 #include <l4/sys/types.h> 30 31 32 33 #ifdef __cplusplus 34 35 #include <l4/re/c/dataspace.h> 36 #include <l4/re/c/dma_space.h> 37 38 class Lcd_device 39 { 40 protected: 41 /* Display server abstraction. */ 42 43 Activation *_display; 44 45 /* Framebuffer region providing virtual and physical addresses plus the memory 46 capability for the framebuffer. */ 47 48 struct dma_region _fb_region; 49 50 /* Display operations. */ 51 52 virtual void disable_display(); 53 virtual void enable_display(); 54 55 public: 56 /* Initialise a device with a controller and display object reference. */ 57 58 Lcd_device(Activation *display) 59 : _display(display) 60 { 61 /* Subclasses must set up any memory. */ 62 63 _fb_region.vaddr = 0; 64 _fb_region.mem = L4_INVALID_CAP; 65 } 66 67 /* Framebuffer operations. */ 68 69 virtual l4_addr_t get_framebuffer() 70 { 71 return _fb_region.vaddr; 72 } 73 74 virtual l4re_ds_t get_framebuffer_cap() 75 { 76 return _fb_region.mem; 77 } 78 79 /* Querying operations. */ 80 81 virtual l4_size_t get_framebuffer_size() = 0; 82 virtual void get_view_info(l4re_video_view_info_t *view_info) = 0; 83 84 /* Device operations. */ 85 86 virtual void disable() = 0; 87 virtual void enable() = 0; 88 89 /* Device access. */ 90 91 static Lcd_device *get_device(); 92 }; 93 94 #endif 95 96 97 98 /* C language interface. */ 99 100 EXTERN_C_BEGIN 101 102 void *lcd_get_device(void); 103 l4_addr_t lcd_get_framebuffer(void *lcd); 104 l4_size_t lcd_get_framebuffer_size(void *lcd); 105 void lcd_get_view_info(void *lcd, l4re_video_view_info_t *view_info); 106 void lcd_disable(void *lcd); 107 void lcd_enable(void *lcd); 108 109 EXTERN_C_END