1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright (C) 2014 David Herrmann <dh.herrmann@gmail.com>
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
28 #include <systemd/sd-bus.h>
29 #include <systemd/sd-event.h>
35 typedef struct grdev_tile grdev_tile;
36 typedef struct grdev_display_cache grdev_display_cache;
38 typedef struct grdev_pipe_vtable grdev_pipe_vtable;
39 typedef struct grdev_pipe grdev_pipe;
40 typedef struct grdev_card_vtable grdev_card_vtable;
41 typedef struct grdev_card grdev_card;
47 bool grdev_is_drm_card(grdev_card *card);
48 grdev_card *grdev_find_drm_card(grdev_session *session, dev_t devnum);
49 int grdev_drm_card_new(grdev_card **out, grdev_session *session, struct udev_device *ud);
50 void grdev_drm_card_hotplug(grdev_card *card, struct udev_device *ud);
63 LIST_FIELDS(grdev_tile, childs_by_node);
65 grdev_display *display;
83 LIST_HEAD(grdev_tile, child_list);
88 int grdev_tile_new_leaf(grdev_tile **out, grdev_pipe *pipe);
89 int grdev_tile_new_node(grdev_tile **out);
90 grdev_tile *grdev_tile_free(grdev_tile *tile);
92 DEFINE_TRIVIAL_CLEANUP_FUNC(grdev_tile*, grdev_tile_free);
94 struct grdev_display {
95 grdev_session *session;
107 struct grdev_display_cache {
109 grdev_display_target target;
120 grdev_display *grdev_find_display(grdev_session *session, const char *name);
122 int grdev_display_new(grdev_display **out, grdev_session *session, const char *name);
123 grdev_display *grdev_display_free(grdev_display *display);
125 DEFINE_TRIVIAL_CLEANUP_FUNC(grdev_display*, grdev_display_free);
131 struct grdev_pipe_vtable {
132 void (*free) (grdev_pipe *pipe);
133 void (*enable) (grdev_pipe *pipe);
134 void (*disable) (grdev_pipe *pipe);
135 grdev_fb *(*target) (grdev_pipe *pipe);
139 const grdev_pipe_vtable *vtable;
144 grdev_display_cache *cache;
145 sd_event_source *vsync_src;
162 #define GRDEV_PIPE_INIT(_vtable, _card) ((grdev_pipe){ \
163 .vtable = (_vtable), \
167 grdev_pipe *grdev_find_pipe(grdev_card *card, const char *name);
169 int grdev_pipe_add(grdev_pipe *pipe, const char *name, size_t n_fbs);
170 grdev_pipe *grdev_pipe_free(grdev_pipe *pipe);
172 DEFINE_TRIVIAL_CLEANUP_FUNC(grdev_pipe*, grdev_pipe_free);
174 void grdev_pipe_ready(grdev_pipe *pipe, bool running);
175 void grdev_pipe_frame(grdev_pipe *pipe);
176 void grdev_pipe_schedule(grdev_pipe *pipe, uint64_t frames);
182 struct grdev_card_vtable {
183 void (*free) (grdev_card *card);
184 void (*enable) (grdev_card *card);
185 void (*disable) (grdev_card *card);
186 void (*commit) (grdev_card *card);
187 void (*restore) (grdev_card *card);
191 const grdev_card_vtable *vtable;
192 grdev_session *session;
201 #define GRDEV_CARD_INIT(_vtable, _session) ((grdev_card){ \
202 .vtable = (_vtable), \
203 .session = (_session), \
206 grdev_card *grdev_find_card(grdev_session *session, const char *name);
208 int grdev_card_add(grdev_card *card, const char *name);
209 grdev_card *grdev_card_free(grdev_card *card);
211 DEFINE_TRIVIAL_CLEANUP_FUNC(grdev_card*, grdev_card_free);
217 struct grdev_session {
218 grdev_context *context;
221 grdev_event_fn event_fn;
224 unsigned long n_pins;
227 Hashmap *display_map;
235 grdev_session *grdev_session_pin(grdev_session *session);
236 grdev_session *grdev_session_unpin(grdev_session *session);
238 DEFINE_TRIVIAL_CLEANUP_FUNC(grdev_session*, grdev_session_unpin);
244 struct grdev_context {
249 Hashmap *session_map;