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