1 /* 2 * Export the framebuffer as a data space accessible via the "fb" capability. 3 * 4 * Copyright (C) 2018 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 #include <l4/devices/lcd-device.h> 23 #include "fb-lcd.h" 24 #include "fb-server.h" 25 26 #include <l4/cxx/ipc_stream> 27 #include <l4/re/dataspace> 28 #include <l4/re/env> 29 #include <l4/re/util/object_registry> 30 31 32 33 // Device-specific methods. 34 35 l4_size_t 36 Framebuffer_lcd_server::get_framebuffer_size() 37 { 38 return _device->get_framebuffer_size(); 39 } 40 41 void 42 Framebuffer_lcd_server::get_view_info(l4re_video_view_info_t *view_info) 43 { 44 _device->get_view_info(view_info); 45 } 46 47 48 49 static L4Re::Util::Registry_server<> server; 50 51 52 53 // Main program. 54 55 int run() 56 { 57 // Obtain the LCD device. 58 59 Lcd_device *lcd_device = Lcd_device::get_device(); 60 61 // Memory allocation capability for the framebuffer data. 62 63 L4::Cap<L4Re::Dataspace> mem = lcd_device->get_framebuffer_cap(); 64 65 if (!mem.is_valid()) return 1; 66 67 // Enable the LCD device. 68 69 lcd_device->enable(); 70 71 // Initialise and register a server object. 72 73 Framebuffer_lcd_server server_obj(mem, lcd_device); 74 server.registry()->register_obj(&server_obj, "fb"); 75 76 // Enter the IPC server loop. 77 78 server.loop(); 79 return 0; 80 }