Landfall

Annotated pkg/devices/fb/src/lcd/fb-lcd.cc

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