3 * (c) 2008-2009 Technische Universität Dresden
4 * This file is part of TUD:OS and distributed under the terms of the
5 * GNU General Public License 2.
6 * Please see the COPYING-GPL-2 file for details.
8 * As a special exception, you may use this file as part of a free software
9 * library without restriction. Specifically, if other files instantiate
10 * templates or use macros or inline functions from this file, or you compile
11 * this file and link it with other files to produce an executable, this
12 * file does not by itself cause the resulting executable to be covered by
13 * the GNU General Public License. This exception does not however
14 * invalidate any other reasons why the executable file might be covered by
15 * the GNU General Public License.
20 #include <l4/re/dataspace>
21 #include <l4/re/protocols>
22 #include <l4/re/video/goos>
23 #include <l4/re/video/goos-sys.h>
25 #include <l4/sys/capability>
26 #include <l4/cxx/ipc_server>
29 namespace L4Re { namespace Util { namespace Video {
32 * \brief Goos server class.
33 * \ingroup api_l4re_util
38 /** Goos memory dataspace */
39 L4::Cap<L4Re::Dataspace> _fb_ds;
40 /** Goos information */
41 L4Re::Video::Goos::Info _screen_info;
42 /** View information */
43 L4Re::Video::View::Info _view_info;
47 * \brief Return framebuffer memory dataspace.
48 * \return Goos memory dataspace
50 L4::Cap<L4Re::Dataspace> get_fb() const { return _fb_ds; }
53 * \brief Goos information structure.
54 * \return Return goos information structure.
56 L4Re::Video::Goos::Info const *screen_info() const { return &_screen_info; }
59 * \brief View information structure.
60 * \return Return view information structure.
62 L4Re::Video::View::Info const *view_info() const { return &_view_info; }
65 * \brief Refresh area of the framebuffer
67 * \param x X coordinate (pixels)
68 * \param y Y coordinate (pixels)
69 * \param w Width of area in pixels
70 * \param h Height of area in pixels
72 * \return 0 on success, negative error code otherwise
74 virtual int refresh(int x, int y, int w, int h)
75 { (void)x; (void)y; (void)w; (void)h; return -L4_ENOSYS; }
78 * \brief Server dispatch function.
80 * \param obj Server object ID to work on
81 * \param ios Input/Output stream.
85 int dispatch(l4_umword_t obj, L4::Ipc_iostream &ios);
88 * \brief Initialize the view information structure of this object.
90 * This function initializes the view info structure of this goos object
91 * based on the information in the goos information, i.e. the width,
92 * height and pixel_info of the goos information has to contain valid
93 * values before calling init_info().
97 using L4Re::Video::View;
99 _view_info.flags = View::F_none;
101 _view_info.view_index = 0;
104 _view_info.width = _screen_info.width;
105 _view_info.height = _screen_info.height;
106 _view_info.pixel_info = _screen_info.pixel_info;
107 _view_info.buffer_index = 0;
113 virtual ~Goos_svr() {}
118 Goos_svr::dispatch(l4_umword_t, L4::Ipc_iostream &ios)
123 if (tag.label() != L4Re::Protocol::Goos)
124 return -L4_EBADPROTO;
130 case L4Re::Video::Goos_::View_info:
139 case L4Re::Video::Goos_::Info:
140 ios.put(_screen_info);
142 case L4Re::Video::Goos_::Get_buffer:
149 ios << L4::Ipc::Snd_fpage(_fb_ds, L4_CAP_FPAGE_RW);
151 case L4Re::Video::Goos_::View_refresh:
155 ios >> idx >> x >> y >> w >> h;
159 return refresh(x, y, w, h);