2 * (c) 2008-2009 Alexander Warg <warg@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
5 * This file is part of TUD:OS and distributed under the terms of the
6 * GNU General Public License 2.
7 * Please see the COPYING-GPL-2 file for details.
9 * As a special exception, you may use this file as part of a free software
10 * library without restriction. Specifically, if other files instantiate
11 * templates or use macros or inline functions from this file, or you compile
12 * this file and link it with other files to produce an executable, this
13 * file does not by itself cause the resulting executable to be covered by
14 * the GNU General Public License. This exception does not however
15 * invalidate any other reasons why the executable file might be covered by
16 * the GNU General Public License.
19 #include <l4/re/error_helper>
20 #include <l4/re/util/video/goos_fb>
21 #include <l4/re/util/cap_alloc>
22 #include <l4/re/util/env_ns>
26 #include <l4/re/namespace>
28 namespace L4Re { namespace Util { namespace Video {
33 using namespace L4Re::Video;
38 chksys(_goos->info(&gi), "requesting goos info");
40 if (gi.has_dynamic_views())
42 chksys(_goos->create_view(&_view), "createing dynamic goos view");
45 else // we just assume view 0 to be our's and ignore other possible views
46 _view = _goos->view(0);
49 chksys(_view.info(&vi), "requesting goos view information");
51 _buffer = chkcap(cap_alloc.alloc<L4Re::Dataspace>(),
52 "allocating goos buffer cap");
54 if (vi.has_static_buffer())
55 chksys(_goos->get_static_buffer(vi.buffer_index, _buffer),
56 "requesting static goos buffer");
59 unsigned long buffer_sz = gi.pixel_info.bytes_per_pixel() * gi.width * gi.height;
60 _buffer_index = chksys(_goos->create_buffer(buffer_sz, _buffer),
61 "allocating goos buffer");
62 _flags |= F_dyn_buffer;
64 // use the allocated buffer, at offset 0
65 vi.buffer_index = _buffer_index;
67 vi.pixel_info = gi.pixel_info;
68 vi.bytes_per_line = gi.width * gi.pixel_info.bytes_per_pixel();
70 // we want a fullscreen view
74 vi.height = gi.height;
76 chksys(_view.set_info(vi), "setting up dynamic view");
77 chksys(_view.push_top(), "bringiong view to top");
82 Goos_fb::setup(L4::Cap<L4Re::Video::Goos> goos)
89 Goos_fb::setup(char const *name)
92 //_goos = chkcap(cap_alloc.alloc<L4Re::Video::Goos>(), "allocating goos cap");
93 _goos = chkcap(ns.query<L4Re::Video::Goos>(name), "requesting goos cap", 0);
96 //chksys(L4Re::Env::env()->names()->query(name, _goos), "requesting goos service");
100 Goos_fb::Goos_fb(L4::Cap<L4Re::Video::Goos> goos)
101 : _goos(goos), _buffer(L4_INVALID_CAP), _flags(0)
105 Goos_fb::Goos_fb(char const *name)
106 : _goos(L4_INVALID_CAP), _buffer(L4_INVALID_CAP), _flags(0)
110 Goos_fb::attach_buffer()
114 L4Re::chksys(L4Re::Env::env()->rm()->attach(&fb_addr, _buffer->size(), L4Re::Rm::Search_addr, _buffer, 0, L4_SUPERPAGESHIFT), "attaching frame-buffer memory");
120 if (!_goos.is_valid())
123 if (_flags & F_dyn_view)
124 _goos->delete_view(_view);
126 if (_flags & F_dyn_buffer)
127 _goos->delete_buffer(_buffer_index);
129 if (_buffer.is_valid())
130 cap_alloc.free(_buffer);
132 if (_flags & F_dyn_goos)
133 cap_alloc.free(_goos);