1 /* 2 * Framebuffer client to access framebuffer servers. 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 "fb-client.h" 23 #include "fb-ops.h" 24 25 #include <l4/cxx/ipc_stream> 26 #include <l4/re/env> 27 28 #include <stdint.h> 29 30 int 31 Framebuffer_device_interface::get_framebuffer(L4::Cap<L4Re::Dataspace> mem) throw() 32 { 33 L4::Ipc::Iostream s(l4_utcb()); 34 35 /* Send a "receive item" for requesting a capability. */ 36 37 s << L4::Ipc::Small_buf(mem); 38 39 return l4_error(s.call(cap(), Framebuffer_op_get_framebuffer)); 40 } 41 42 l4_size_t 43 Framebuffer_device_interface::get_framebuffer_size() throw() 44 { 45 L4::Ipc::Iostream s(l4_utcb()); 46 l4_size_t size; 47 48 /* Return zero on failure. */ 49 50 if (l4_error(s.call(cap(), Framebuffer_op_get_framebuffer_size))) 51 return 0; 52 53 s >> size; 54 return size; 55 } 56 57 int 58 Framebuffer_device_interface::get_view_info(l4re_video_view_info_t *view_info) throw() 59 { 60 L4::Ipc::Iostream s(l4_utcb()); 61 62 int err = l4_error(s.call(cap(), Framebuffer_op_get_view_info)); 63 if (err) return err; 64 65 unsigned long expected = sizeof(*view_info); 66 unsigned long size = expected; 67 68 s >> L4::Ipc::buf_cp_in<uint8_t>((uint8_t *) view_info, expected); 69 70 if (size != expected) return -L4_EIO; 71 return L4_EOK; 72 }