backend-drm: get the drm device from the output

If we have multiple drm devices, we cannot use the drm device from the backend,
because we would only get the primary device and not the device of the output.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
dev
Michael Tretter 3 years ago committed by Daniel Stone
parent 6e36787dfd
commit deebfd99e3
  1. 5
      libweston/backend-drm/drm-gbm.c
  2. 45
      libweston/backend-drm/drm.c
  3. 2
      libweston/backend-drm/fb.c
  4. 22
      libweston/backend-drm/kms.c
  5. 15
      libweston/backend-drm/modes.c
  6. 25
      libweston/backend-drm/state-propose.c

@ -146,7 +146,7 @@ static void drm_output_fini_cursor_egl(struct drm_output *output)
static int
drm_output_init_cursor_egl(struct drm_output *output, struct drm_backend *b)
{
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
unsigned int i;
/* No point creating cursors if we don't have a plane for them. */
@ -290,8 +290,7 @@ struct drm_fb *
drm_output_render_gl(struct drm_output_state *state, pixman_region32_t *damage)
{
struct drm_output *output = state->output;
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
struct gbm_bo *bo;
struct drm_fb *ret;

@ -270,8 +270,7 @@ void
drm_output_update_complete(struct drm_output *output, uint32_t flags,
unsigned int sec, unsigned int usec)
{
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
struct drm_plane_state *ps;
struct timespec ts;
@ -352,13 +351,13 @@ void
drm_output_render(struct drm_output_state *state, pixman_region32_t *damage)
{
struct drm_output *output = state->output;
struct drm_device *device = output->device;
struct weston_compositor *c = output->base.compositor;
struct drm_plane_state *scanout_state;
struct drm_plane *scanout_plane = output->scanout_plane;
struct drm_property_info *damage_info =
&scanout_plane->props[WDRM_PLANE_FB_DAMAGE_CLIPS];
struct drm_backend *b = to_drm_backend(c);
struct drm_device *device = b->drm;
struct drm_backend *b = device->backend;
struct drm_fb *fb;
pixman_region32_t scanout_damage;
pixman_box32_t *rects;
@ -524,9 +523,9 @@ drm_output_start_repaint_loop(struct weston_output *output_base)
struct drm_output *output = to_drm_output(output_base);
struct drm_pending_state *pending_state;
struct drm_plane *scanout_plane = output->scanout_plane;
struct drm_backend *backend =
to_drm_backend(output_base->compositor);
struct drm_device *device = backend->drm;
struct drm_device *device = output->device;
struct drm_backend *backend = device->backend;
struct weston_compositor *compositor = backend->compositor;
struct timespec ts, tnow;
struct timespec vbl2now;
int64_t refresh_nsec;
@ -566,7 +565,7 @@ drm_output_start_repaint_loop(struct weston_output *output_base)
* Stale ts could happen on Linux 3.17+, so make sure it
* is not older than 1 refresh duration since now.
*/
weston_compositor_read_presentation_clock(backend->compositor,
weston_compositor_read_presentation_clock(compositor,
&tnow);
timespec_sub(&vbl2now, &tnow, &ts);
refresh_nsec =
@ -688,8 +687,8 @@ static int
drm_output_switch_mode(struct weston_output *output_base, struct weston_mode *mode)
{
struct drm_output *output = to_drm_output(output_base);
struct drm_backend *b = to_drm_backend(output_base->compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
struct drm_backend *b = device->backend;
struct drm_mode *drm_mode = drm_output_choose_mode(output, mode);
if (!drm_mode) {
@ -1049,8 +1048,7 @@ static void
drm_set_dpms(struct weston_output *output_base, enum dpms_enum level)
{
struct drm_output *output = to_drm_output(output_base);
struct drm_backend *b = to_drm_backend(output_base->compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
struct drm_pending_state *pending_state = device->repaint_data;
struct drm_output_state *state;
int ret;
@ -1158,7 +1156,7 @@ make_connector_name(const drmModeConnector *con)
static int
drm_output_init_pixman(struct drm_output *output, struct drm_backend *b)
{
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
int w = output->base.current_mode->width;
int h = output->base.current_mode->height;
uint32_t format = output->gbm_format;
@ -1390,8 +1388,7 @@ drm_output_set_seat(struct weston_output *base,
static int
drm_output_init_gamma_size(struct drm_output *output)
{
struct drm_backend *backend = to_drm_backend(output->base.compositor);
struct drm_device *device = backend->drm;
struct drm_device *device = output->device;
drmModeCrtc *crtc;
assert(output->base.compositor);
@ -1437,8 +1434,9 @@ drm_connector_get_possible_crtcs_mask(struct drm_connector *connector)
static struct drm_crtc *
drm_output_pick_crtc(struct drm_output *output)
{
struct drm_backend *backend;
struct drm_device *device;
struct drm_device *device = output->device;
struct drm_backend *backend = device->backend;
struct weston_compositor *compositor = backend->compositor;
struct weston_head *base;
struct drm_head *head;
struct drm_crtc *crtc;
@ -1451,9 +1449,6 @@ drm_output_pick_crtc(struct drm_output *output)
unsigned int i;
bool match;
backend = to_drm_backend(output->base.compositor);
device = backend->drm;
/* This algorithm ignores drmModeEncoder::possible_clones restriction,
* because it is more often set wrong than not in the kernel. */
@ -1494,8 +1489,7 @@ drm_output_pick_crtc(struct drm_output *output)
* If they did, this is not the best CRTC as it might be needed
* for another output we haven't enabled yet. */
match = false;
wl_list_for_each(base, &backend->compositor->head_list,
compositor_link) {
wl_list_for_each(base, &compositor->head_list, compositor_link) {
head = to_drm_head(base);
if (head->base.output == &output->base)
@ -1636,7 +1630,7 @@ static int
drm_output_init_planes(struct drm_output *output)
{
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
output->scanout_plane =
drm_output_find_special_plane(device, output,
@ -1674,7 +1668,7 @@ static void
drm_output_deinit_planes(struct drm_output *output)
{
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
/* If the compositor is already shutting down, the planes have already
* been destroyed. */
@ -1810,7 +1804,8 @@ static int
drm_output_enable(struct weston_output *base)
{
struct drm_output *output = to_drm_output(base);
struct drm_backend *b = to_drm_backend(base->compositor);
struct drm_device *device = output->device;
struct drm_backend *b = device->backend;
int ret;
assert(!output->virtual);

@ -532,7 +532,7 @@ drm_fb_get_from_view(struct drm_output_state *state, struct weston_view *ev,
{
struct drm_output *output = state->output;
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
struct weston_buffer *buffer = ev->surface->buffer_ref.buffer;
struct drm_buffer_fb *buf_fb;
bool is_opaque = weston_view_is_opaque(ev, &ev->transform.boundingbox);

@ -514,9 +514,7 @@ drm_output_set_gamma(struct weston_output *output_base,
{
int rc;
struct drm_output *output = to_drm_output(output_base);
struct drm_backend *backend =
to_drm_backend(output->base.compositor);
struct drm_device *device = backend->drm;
struct drm_device *device = output->device;
/* check */
if (output_base->gamma_size != size)
@ -540,8 +538,8 @@ drm_output_assign_state(struct drm_output_state *state,
enum drm_state_apply_mode mode)
{
struct drm_output *output = state->output;
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
struct drm_backend *b = device->backend;
struct drm_plane_state *plane_state;
struct drm_head *head;
@ -599,8 +597,7 @@ static void
drm_output_set_cursor(struct drm_output_state *output_state)
{
struct drm_output *output = output_state->output;
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
struct drm_crtc *crtc = output->crtc;
struct drm_plane *plane = output->cursor_plane;
struct drm_plane_state *state;
@ -653,8 +650,8 @@ static int
drm_output_apply_state_legacy(struct drm_output_state *state)
{
struct drm_output *output = state->output;
struct drm_backend *backend = to_drm_backend(output->base.compositor);
struct drm_device *device = backend->drm;
struct drm_device *device = output->device;
struct drm_backend *backend = device->backend;
struct drm_plane *scanout_plane = output->scanout_plane;
struct drm_crtc *crtc = output->crtc;
struct drm_property_info *dpms_prop;
@ -941,8 +938,8 @@ drm_output_apply_state_atomic(struct drm_output_state *state,
uint32_t *flags)
{
struct drm_output *output = state->output;
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
struct drm_backend *b = device->backend;
struct drm_crtc *crtc = output->crtc;
struct drm_plane_state *plane_state;
struct drm_mode *current_mode = to_drm_mode(output->base.current_mode);
@ -1387,8 +1384,7 @@ page_flip_handler(int fd, unsigned int frame,
unsigned int sec, unsigned int usec, void *data)
{
struct drm_output *output = data;
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
uint32_t flags = WP_PRESENTATION_FEEDBACK_KIND_VSYNC |
WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION |
WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK;

@ -489,11 +489,9 @@ drm_output_choose_mode(struct drm_output *output,
struct drm_mode *tmp_mode = NULL, *mode_fall_back = NULL, *mode;
enum weston_mode_aspect_ratio src_aspect = WESTON_MODE_PIC_AR_NONE;
enum weston_mode_aspect_ratio target_aspect = WESTON_MODE_PIC_AR_NONE;
struct drm_backend *b;
struct drm_device *device;
b = to_drm_backend(output->base.compositor);
device = b->drm;
device = output->device;
target_aspect = target_mode->aspect_ratio;
src_aspect = output->base.current_mode->aspect_ratio;
if (output->base.current_mode->width == target_mode->width &&
@ -739,8 +737,7 @@ drm_output_try_add_mode(struct drm_output *output, const drmModeModeInfo *info)
{
struct weston_mode *base;
struct drm_mode *mode = NULL;
struct drm_backend *backend;
struct drm_device *device;
struct drm_device *device = output->device;
const drmModeModeInfo *chosen = NULL;
assert(info);
@ -754,8 +751,6 @@ drm_output_try_add_mode(struct drm_output *output, const drmModeModeInfo *info)
if (chosen == info) {
assert(mode);
backend = to_drm_backend(output->base.compositor);
device = backend->drm;
drm_output_destroy_mode(device, mode);
chosen = NULL;
}
@ -783,8 +778,7 @@ drm_output_try_add_mode(struct drm_output *output, const drmModeModeInfo *info)
static int
drm_output_update_modelist_from_heads(struct drm_output *output)
{
struct drm_backend *backend = to_drm_backend(output->base.compositor);
struct drm_device *device = backend->drm;
struct drm_device *device = output->device;
struct weston_head *head_base;
struct drm_head *head;
drmModeConnector *conn;
@ -814,8 +808,7 @@ drm_output_set_mode(struct weston_output *base,
const char *modeline)
{
struct drm_output *output = to_drm_output(base);
struct drm_backend *b = to_drm_backend(base->compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
struct drm_head *head = to_drm_head(weston_output_get_first_head(base));
struct drm_mode *current;

@ -83,10 +83,9 @@ drm_output_try_view_on_plane(struct drm_plane *plane,
struct drm_fb *fb, uint64_t zpos)
{
struct drm_output *output = output_state->output;
struct weston_compositor *ec = output->base.compositor;
struct weston_surface *surface = ev->surface;
struct drm_backend *b = to_drm_backend(ec);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
struct drm_backend *b = device->backend;
struct drm_plane_state *state = NULL;
assert(!device->sprites_are_broken);
@ -162,7 +161,8 @@ out:
static void
cursor_bo_update(struct drm_plane_state *plane_state, struct weston_view *ev)
{
struct drm_device *device = plane_state->plane->device;
struct drm_output *output = plane_state->output;
struct drm_device *device = output->device;
struct gbm_bo *bo = plane_state->fb->bo;
struct weston_buffer *buffer = ev->surface->buffer_ref.buffer;
uint32_t buf[device->cursor_width * device->cursor_height];
@ -194,8 +194,8 @@ drm_output_prepare_cursor_view(struct drm_output_state *output_state,
struct weston_view *ev, uint64_t zpos)
{
struct drm_output *output = output_state->output;
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
struct drm_backend *b = device->backend;
struct drm_plane *plane = output->cursor_plane;
struct drm_plane_state *plane_state;
bool needs_update = false;
@ -430,8 +430,8 @@ drm_output_find_plane_for_view(struct drm_output_state *state,
uint64_t current_lowest_zpos)
{
struct drm_output *output = state->output;
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_device *device = b->drm;
struct drm_device *device = output->device;
struct drm_backend *b = device->backend;
struct drm_plane_state *ps = NULL;
struct drm_plane *plane;
@ -636,7 +636,8 @@ drm_output_propose_state(struct weston_output *output_base,
enum drm_output_propose_state_mode mode)
{
struct drm_output *output = to_drm_output(output_base);
struct drm_backend *b = to_drm_backend(output->base.compositor);
struct drm_device *device = output->device;
struct drm_backend *b = device->backend;
struct weston_paint_node *pnode;
struct drm_output_state *state;
struct drm_plane_state *scanout_state = NULL;
@ -915,10 +916,10 @@ err:
void
drm_assign_planes(struct weston_output *output_base)
{
struct drm_backend *b = to_drm_backend(output_base->compositor);
struct drm_device *device = b->drm;
struct drm_pending_state *pending_state = device->repaint_data;
struct drm_output *output = to_drm_output(output_base);
struct drm_device *device = output->device;
struct drm_backend *b = device->backend;
struct drm_pending_state *pending_state = device->repaint_data;
struct drm_output_state *state = NULL;
struct drm_plane_state *plane_state;
struct weston_paint_node *pnode;

Loading…
Cancel
Save