1 /* 2 * LCD device support. 3 * 4 * Copyright (C) 2018, 2020, 2023 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/lcd/activation_interface.h> 25 #include <l4/devices/lcd.h> 26 27 #include <l4/re/c/video/view.h> 28 #include <l4/sys/types.h> 29 30 31 32 #ifdef __cplusplus 33 34 #include <l4/re/dataspace> 35 #include <l4/re/dma_space> 36 #include <l4/sys/capability> 37 38 class Lcd_device 39 { 40 protected: 41 /* LCD peripheral abstraction. */ 42 43 Lcd_chip *_chip; 44 45 /* Display server abstraction. */ 46 47 Activation *_display; 48 49 /* Framebuffer virtual and physical addresses. */ 50 51 l4_addr_t fb_vaddr; 52 L4Re::Dma_space::Dma_addr fb_paddr; 53 54 /* Memory capability for the framebuffer. */ 55 56 L4::Cap<L4Re::Dataspace> _fbmem; 57 58 /* Display operations. */ 59 60 virtual void disable_display(); 61 virtual void enable_display(); 62 63 public: 64 /* Initialise a device with a controller and display object reference. */ 65 66 Lcd_device(Lcd_chip *chip, Activation *display) 67 : _chip(chip), _display(display) 68 { 69 /* Subclasses must set up any memory. */ 70 } 71 72 /* Framebuffer operations. */ 73 74 virtual l4_addr_t get_framebuffer() 75 { 76 return fb_vaddr; 77 } 78 79 virtual L4::Cap<L4Re::Dataspace> get_framebuffer_cap() 80 { 81 return _fbmem; 82 } 83 84 /* Querying operations. */ 85 86 virtual l4_size_t get_framebuffer_size() = 0; 87 virtual void get_view_info(l4re_video_view_info_t *view_info) = 0; 88 89 /* Device operations. */ 90 91 virtual void disable() = 0; 92 virtual void enable() = 0; 93 94 /* Device access. */ 95 96 static Lcd_device *get_device(); 97 }; 98 99 #endif 100 101 102 103 /* C language interface. */ 104 105 EXTERN_C_BEGIN 106 107 void *lcd_get_device(void); 108 l4_addr_t lcd_get_framebuffer(void *lcd); 109 l4_size_t lcd_get_framebuffer_size(void *lcd); 110 void lcd_get_view_info(void *lcd, l4re_video_view_info_t *view_info); 111 void lcd_disable(void *lcd); 112 void lcd_enable(void *lcd); 113 114 EXTERN_C_END