From a32d74d1c71088d86a82edd437cd02741e191762 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Tue, 11 Mar 2014 09:01:01 +0000 Subject: [PATCH] @feature: Add new drm compositing module Signed-off-by: Chris Michael --- configure.ac | 14 +- src/modules/Makefile.mk | 3 +- src/modules/Makefile_wl_drm.mk | 17 + src/modules/wl_drm/e-module-wl_drm.edj | Bin 13048 -> 0 bytes src/modules/wl_drm/e_drm_output.c | 604 -------------------- src/modules/wl_drm/e_evdev.c | 664 ---------------------- src/modules/wl_drm/e_mod_main.c | 727 ++----------------------- src/modules/wl_drm/e_mod_main.h | 234 -------- src/modules/wl_drm/e_sprite.c | 88 --- src/modules/wl_drm/e_tty.c | 201 ------- src/modules/wl_drm/module.desktop | 16 - 11 files changed, 69 insertions(+), 2499 deletions(-) create mode 100644 src/modules/Makefile_wl_drm.mk delete mode 100644 src/modules/wl_drm/e-module-wl_drm.edj delete mode 100644 src/modules/wl_drm/e_drm_output.c delete mode 100644 src/modules/wl_drm/e_evdev.c delete mode 100644 src/modules/wl_drm/e_mod_main.h delete mode 100644 src/modules/wl_drm/e_sprite.c delete mode 100644 src/modules/wl_drm/e_tty.c delete mode 100644 src/modules/wl_drm/module.desktop diff --git a/configure.ac b/configure.ac index 07babf5e3..a388a07d3 100644 --- a/configure.ac +++ b/configure.ac @@ -822,7 +822,8 @@ if test "x${have_wayland}" = "xyes"; then fi AM_CONDITIONAL([HAVE_WAYLAND], [test "x${have_wayland}" = "xyes"]) -AM_CONDITIONAL([HAVE_WAYLAND_ONLY], [test "x${have_wayland_only}" = "xyes"]) +AM_CONDITIONAL([HAVE_WAYLAND_ONLY], + [test "x${have_wayland}" = "xyes" && test "x${e_cv_want_wayland_only}" = "xyes"]) AM_CONDITIONAL([HAVE_WAYLAND_CLIENTS], [test "x${have_wayland_clients}" = "xyes"]) AM_CONDITIONAL([HAVE_WAYLAND_EGL], [test "x${have_wayland_egl}" = "xyes"]) @@ -859,6 +860,16 @@ define([CHECK_MODULE_WL_FB], ]) AM_CONDITIONAL([HAVE_WL_FB], [test "x${WL_FB}" = "xtrue"]) +define([CHECK_MODULE_WL_DRM], +[ + if test "x${have_wayland}" = "xyes" && test "x${e_cv_want_wayland_only}" = "xyes"; then + AC_E_CHECK_PKG(WL_DRM, [ ecore-drm >= $efl_version ecore >= $efl_version eina >= $efl_version ], [WL_DRM=true], [WL_DRM=false]) + else + WL_DRM=false + fi +]) +AM_CONDITIONAL([HAVE_WL_DRM], [test "x${WL_DRM}" = "xtrue"]) + AC_E_OPTIONAL_MODULE([ibar], true) AC_E_OPTIONAL_MODULE([clock], true) AC_E_OPTIONAL_MODULE([pager], true) @@ -914,6 +925,7 @@ AC_E_OPTIONAL_MODULE([contact], false) AC_E_OPTIONAL_MODULE([wl_desktop_shell], true, [CHECK_MODULE_WL_DESKTOP_SHELL]) AC_E_OPTIONAL_MODULE([wl_x11], $have_wayland, $wl_x11) AC_E_OPTIONAL_MODULE([wl_fb], $have_wayland, [CHECK_MODULE_WL_FB]) +AC_E_OPTIONAL_MODULE([wl_drm], $have_wayland, [CHECK_MODULE_WL_DRM]) #AC_E_OPTIONAL_MODULE([wl_screenshot], true, [CHECK_MODULE_WL_SCREENSHOT]) HALT="/sbin/shutdown -h now" diff --git a/src/modules/Makefile.mk b/src/modules/Makefile.mk index 710d821f7..4e9c6c11b 100644 --- a/src/modules/Makefile.mk +++ b/src/modules/Makefile.mk @@ -122,8 +122,7 @@ include src/modules/Makefile_packagekit.mk include src/modules/Makefile_contact.mk -#if HAVE_WAYLAND_DRM -#include src/modules/Makefile_wl_drm.mk +include src/modules/Makefile_wl_drm.mk include src/modules/Makefile_wl_desktop_shell.mk diff --git a/src/modules/Makefile_wl_drm.mk b/src/modules/Makefile_wl_drm.mk new file mode 100644 index 000000000..301e44ef7 --- /dev/null +++ b/src/modules/Makefile_wl_drm.mk @@ -0,0 +1,17 @@ +if USE_MODULE_WL_DRM +wl_drmdir = $(MDIR)/wl_drm + +wl_drmpkgdir = $(MDIR)/wl_drm/$(MODULE_ARCH) +wl_drmpkg_LTLIBRARIES = src/modules/wl_drm/module.la + +src_modules_wl_drm_module_la_DEPENDENCIES = $(MDEPENDENCIES) +src_modules_wl_drm_module_la_CPPFLAGS = $(MOD_CPPFLAGS) @WL_DRM_CFLAGS@ @WAYLAND_CFLAGS@ +src_modules_wl_drm_module_la_LIBADD = $(LIBS) @WL_DRM_LIBS@ @WAYLAND_LIBS@ +src_modules_wl_drm_module_la_LDFLAGS = $(MOD_LDFLAGS) +src_modules_wl_drm_module_la_SOURCES = src/modules/wl_drm/e_mod_main.c + +# TODO: incomplete +#.PHONY: wl_drm install-wl_drm +#wl_drm: $(wl_drmpkg_LTLIBRARIES) $(wl_drm_DATA) +#install-wl_drm: install-wl_drmDATA install-wl_drmpkgLTLIBRARIES +endif diff --git a/src/modules/wl_drm/e-module-wl_drm.edj b/src/modules/wl_drm/e-module-wl_drm.edj deleted file mode 100644 index 2c1f4d26ef39661e481afc89202019f6d41e07cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13048 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 diff --git a/src/modules/wl_drm/e_drm_output.c b/src/modules/wl_drm/e_drm_output.c deleted file mode 100644 index b42bb6bed..000000000 --- a/src/modules/wl_drm/e_drm_output.c +++ /dev/null @@ -1,604 +0,0 @@ -#include "e.h" -#include "e_mod_main.h" - -EINTERN int -e_drm_output_subpixel_convert(int value) -{ - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - switch (value) - { - case DRM_MODE_SUBPIXEL_NONE: - return WL_OUTPUT_SUBPIXEL_NONE; - case DRM_MODE_SUBPIXEL_HORIZONTAL_RGB: - return WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB; - case DRM_MODE_SUBPIXEL_HORIZONTAL_BGR: - return WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR; - case DRM_MODE_SUBPIXEL_VERTICAL_RGB: - return WL_OUTPUT_SUBPIXEL_VERTICAL_RGB; - case DRM_MODE_SUBPIXEL_VERTICAL_BGR: - return WL_OUTPUT_SUBPIXEL_VERTICAL_BGR; - case DRM_MODE_SUBPIXEL_UNKNOWN: - default: - return WL_OUTPUT_SUBPIXEL_UNKNOWN; - } -} - -EINTERN Eina_Bool -e_drm_output_add_mode(E_Drm_Output *output, drmModeModeInfo *info) -{ - E_Drm_Output_Mode *mode; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!(mode = malloc(sizeof(E_Drm_Output_Mode)))) - return EINA_FALSE; - - mode->base.flags = 0; - mode->base.w = info->hdisplay; - mode->base.h = info->vdisplay; - mode->base.refresh = info->vrefresh; - mode->info = *info; - - wl_list_insert(output->base.modes.prev, &mode->base.link); - - return EINA_TRUE; -} - -EINTERN void -e_drm_output_set_modes(E_Drm_Compositor *dcomp) -{ - E_Drm_Output *output; - E_Drm_Output_Mode *mode; - int ret = 0; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - wl_list_for_each(output, &dcomp->base.outputs, base.link) - { - mode = (E_Drm_Output_Mode *)output->base.current; - ret = drmModeSetCrtc(dcomp->drm.fd, output->crtc_id, - output->fb_id[output->current ^ 1], 0, 0, - &output->conn_id, 1, &mode->info); - if (ret < 0) - printf("Failed to set drm mode: %m\n"); - } -} - -EINTERN void -e_drm_output_scanout_buffer_destroy(struct wl_listener *listener, void *data __UNUSED__) -{ - E_Drm_Output *output; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - output = container_of(listener, E_Drm_Output, scanout_buffer_destroy_listener); - output->scanout_buffer = NULL; - if (!output->pending_scanout_buffer) - e_compositor_schedule_repaint(output->base.compositor); -} - -EINTERN void -e_drm_output_pending_scanout_buffer_destroy(struct wl_listener *listener, void *data __UNUSED__) -{ - E_Drm_Output *output; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - output = container_of(listener, E_Drm_Output, - pending_scanout_buffer_destroy_listener); - output->pending_scanout_buffer = NULL; - e_compositor_schedule_repaint(output->base.compositor); -} - -EINTERN void -e_drm_output_repaint(E_Output *base, pixman_region32_t *damage) -{ - E_Drm_Output *output; - E_Drm_Compositor *dcomp; - E_Surface *es; - E_Sprite *sprite; - unsigned int fb_id = 0; - int ret = 0; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - output = (E_Drm_Output *)base; - dcomp = (E_Drm_Compositor *)output->base.compositor; - - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_RENDERBUFFER, output->rbo[output->current]); - if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) - return; - - e_drm_output_prepare_scanout_surface(output); - - wl_list_for_each_reverse(es, &dcomp->base.surfaces, link) - e_surface_draw(es, &output->base, damage); - - glFlush(); - - output->current ^= 1; - - if (output->pending_fs_surf_fb_id != 0) - fb_id = output->pending_fs_surf_fb_id; - else - fb_id = output->fb_id[output->current ^ 1]; - - if (drmModePageFlip(dcomp->drm.fd, output->crtc_id, fb_id, - DRM_MODE_PAGE_FLIP_EVENT, output) < 0) - return; - - wl_list_for_each(sprite, &dcomp->sprites, link) - { - unsigned int flags = 0; - drmVBlank vbl; - - vbl.request.type = (DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT); - vbl.request.sequence = 1; - if (!e_sprite_crtc_supported(base, sprite->possible_crtcs)) - continue; - ret = drmModeSetPlane(dcomp->drm.fd, sprite->plane_id, output->crtc_id, - sprite->pending_fb_id, flags, sprite->dx, - sprite->dy, sprite->dw, sprite->dh, sprite->sx, - sprite->sy, sprite->sw, sprite->sh); - if (ret) - printf("Setplane Failed: %s\n", strerror(errno)); - - vbl.request.signal = (unsigned long)sprite; - ret = drmWaitVBlank(dcomp->drm.fd, &vbl); - if (ret) - printf("VBlank event request failed: %s\n", strerror(errno)); - } -} - -EINTERN void -e_drm_output_destroy(E_Output *base) -{ - E_Drm_Output *output; - E_Drm_Compositor *dcomp; - drmModeCrtcPtr ocrtc; - int i = 0; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - output = (E_Drm_Output *)base; - dcomp = (E_Drm_Compositor *)output->base.compositor; - ocrtc = output->orig_crtc; - - /* TODO: backlight */ - /* if (base->backlight) */ - - e_drm_output_set_cursor(&output->base, NULL); - - drmModeSetCrtc(dcomp->drm.fd, ocrtc->crtc_id, ocrtc->buffer_id, - ocrtc->x, ocrtc->y, &output->conn_id, 1, &ocrtc->mode); - drmModeFreeCrtc(ocrtc); - - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_RENDERBUFFER, 0); - glBindRenderbuffer(GL_RENDERBUFFER, 0); - glDeleteRenderbuffers(2, output->rbo); - - for (i = 0; i < 2; i++) - { - drmModeRmFB(dcomp->drm.fd, output->fb_id[i]); - dcomp->base.destroy_image(dcomp->base.egl_display, output->image[i]); - gbm_bo_destroy(output->bo[i]); - } - - dcomp->crtc_alloc &= ~(1 << output->crtc_id); - dcomp->conn_alloc &= ~(1 << output->conn_id); - - e_output_destroy(&output->base); - wl_list_remove(&output->base.link); - - free(output); -} - -EINTERN void -e_drm_output_assign_planes(E_Output *base) -{ - E_Compositor *comp; - E_Surface *es; - pixman_region32_t overlap, soverlap; - E_Input_Device *dev; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - comp = base->compositor; - pixman_region32_init(&overlap); - wl_list_for_each(es, &comp->surfaces, link) - { - pixman_region32_init(&soverlap); - pixman_region32_intersect(&soverlap, &overlap, &es->transform.box); - dev = (E_Input_Device *)comp->input_device; - if (es == dev->sprite) - { - e_drm_output_set_cursor_region(base, dev, &soverlap); - if (!dev->hw_cursor) - pixman_region32_union(&overlap, &overlap, &es->transform.box); - } - else if (!e_drm_output_prepare_overlay_surface(base, es, &soverlap)) - { - pixman_region32_fini(&es->damage); - pixman_region32_init(&es->damage); - } - else - pixman_region32_union(&overlap, &overlap, &es->transform.box); - - pixman_region32_fini(&soverlap); - } - pixman_region32_fini(&overlap); - - e_drm_output_disable_sprites(base); -} - -EINTERN void -e_drm_output_set_dpms(E_Output *base, E_Dpms_Level level) -{ - E_Drm_Output *output; - E_Compositor *comp; - E_Drm_Compositor *dcomp; - drmModeConnectorPtr conn; - drmModePropertyPtr prop; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - output = (E_Drm_Output *)base; - comp = base->compositor; - dcomp = (E_Drm_Compositor *)comp; - - if (!(conn = drmModeGetConnector(dcomp->drm.fd, output->conn_id))) - return; - if (!(prop = e_drm_output_get_property(dcomp->drm.fd, conn, "DPMS"))) - { - drmModeFreeConnector(conn); - return; - } - drmModeConnectorSetProperty(dcomp->drm.fd, conn->connector_id, - prop->prop_id, level); - drmModeFreeProperty(prop); - drmModeFreeConnector(conn); -} - -EINTERN Eina_Bool -e_drm_output_prepare_scanout_surface(E_Drm_Output *output) -{ - E_Drm_Compositor *dcomp; - E_Surface *es; - EGLint hdl, stride; - int ret = 0; - unsigned int fb_id = 0; - struct gbm_bo *bo; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - dcomp = (E_Drm_Compositor *)output->base.compositor; - es = container_of(dcomp->base.surfaces.next, E_Surface, link); - - /* Need to verify output->region contained in surface opaque - * region. Or maybe just that format doesn't have alpha. */ - return EINA_TRUE; - - if ((es->geometry.x != output->base.x) || - (es->geometry.y != output->base.y) || - (es->geometry.w != output->base.current->w) || - (es->geometry.h != output->base.current->h) || - (es->transform.enabled) || (es->image == EGL_NO_IMAGE_KHR)) - return EINA_FALSE; - - bo = gbm_bo_create_from_egl_image(dcomp->gbm, dcomp->base.egl_display, - es->image, es->geometry.w, - es->geometry.h, GBM_BO_USE_SCANOUT); - hdl = gbm_bo_get_handle(bo).s32; - stride = gbm_bo_get_pitch(bo); - - gbm_bo_destroy(bo); - - if (hdl == 0) return EINA_FALSE; - - ret = drmModeAddFB(dcomp->drm.fd, output->base.current->w, - output->base.current->h, 24, 32, stride, hdl, &fb_id); - if (ret) return EINA_FALSE; - - output->pending_fs_surf_fb_id = fb_id; - - output->pending_scanout_buffer = es->buffer; - output->pending_scanout_buffer->busy_count++; - - wl_signal_add(&output->pending_scanout_buffer->resource.destroy_signal, - &output->pending_scanout_buffer_destroy_listener); - - pixman_region32_fini(&es->damage); - pixman_region32_init(&es->damage); - - return EINA_TRUE; -} - -EINTERN void -e_drm_output_disable_sprites(E_Output *base) -{ - E_Compositor *comp; - E_Drm_Compositor *dcomp; - E_Drm_Output *output; - E_Sprite *s; - int ret = 0; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - comp = base->compositor; - dcomp = (E_Drm_Compositor *)comp; - output = (E_Drm_Output *)base; - - wl_list_for_each(s, &dcomp->sprites, link) - { - if (s->pending_fb_id) continue; - ret = drmModeSetPlane(dcomp->drm.fd, s->plane_id, output->crtc_id, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - if (ret) - printf("Failed to disable plane: %s\n", strerror(errno)); - drmModeRmFB(dcomp->drm.fd, s->fb_id); - s->surface = NULL; - s->pending_surface = NULL; - s->fb_id = 0; - s->pending_fb_id = 0; - } -} - -EINTERN drmModePropertyPtr -e_drm_output_get_property(int fd, drmModeConnectorPtr conn, const char *name) -{ - drmModePropertyPtr props; - int i = 0; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - for (i = 0; i < conn->count_props; i++) - { - if (!(props = drmModeGetProperty(fd, conn->props[i]))) - continue; - if (!strcmp(props->name, name)) return props; - drmModeFreeProperty(props); - } - - return NULL; -} - -EINTERN int -e_drm_output_prepare_overlay_surface(E_Output *base, E_Surface *es, pixman_region32_t *overlap) -{ - E_Compositor *comp; - E_Drm_Compositor *dcomp; - E_Sprite *s; - Eina_Bool found = EINA_FALSE; - EGLint hdl, stride; - struct gbm_bo *bo; - unsigned int fb_id = 0; - unsigned int hdls[4], pitches[4], offsets[4]; - int ret = 0; - pixman_region32_t drect, srect; - pixman_box32_t *box; - unsigned int format; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - comp = base->compositor; - dcomp = (E_Drm_Compositor *)comp; - - if (dcomp->sprites_broken) return -1; - if (e_surface_is_primary(comp, es)) return -1; - if (es->image == EGL_NO_IMAGE_KHR) return -1; - - if (!e_drm_output_surface_transform_supported(es)) - return -1; - if (!e_drm_output_surface_overlap_supported(base, overlap)) - return -1; - - wl_list_for_each(s, &dcomp->sprites, link) - { - if (!e_sprite_crtc_supported(base, s->possible_crtcs)) - continue; - if (!s->pending_fb_id) - { - found = EINA_TRUE; - break; - } - } - - if (!found) return -1; - - bo = gbm_bo_create_from_egl_image(dcomp->gbm, dcomp->base.egl_display, - es->image, es->geometry.w, - es->geometry.h, GBM_BO_USE_SCANOUT); - format = gbm_bo_get_format(bo); - hdl = gbm_bo_get_handle(bo).s32; - stride = gbm_bo_get_pitch(bo); - - gbm_bo_destroy(bo); - - if (!e_drm_output_surface_format_supported(s, format)) - return -1; - - if (!hdl) return -1; - - hdls[0] = hdl; - pitches[0] = stride; - offsets[0] = 0; - - ret = drmModeAddFB2(dcomp->drm.fd, es->geometry.w, es->geometry.h, - format, hdls, pitches, offsets, &fb_id, 0); - if (ret) - { - dcomp->sprites_broken = EINA_TRUE; - return -1; - } - - if ((s->surface) && (s->surface != es)) - { - E_Surface *os; - - os = s->surface; - pixman_region32_fini(&os->damage); - pixman_region32_init_rect(&os->damage, os->geometry.x, os->geometry.y, - os->geometry.w, os->geometry.h); - } - - s->pending_fb_id = fb_id; - s->pending_surface = es; - es->buffer->busy_count++; - - pixman_region32_init(&drect); - pixman_region32_intersect(&drect, &es->transform.box, &base->region); - pixman_region32_translate(&drect, -base->x, -base->y); - - box = pixman_region32_extents(&drect); - s->dx = box->x1; - s->dy = box->y1; - s->dw = (box->x2 - box->x1); - s->dh = (box->y2 - box->y1); - pixman_region32_fini(&drect); - - pixman_region32_init(&srect); - pixman_region32_intersect(&srect, &es->transform.box, &base->region); - pixman_region32_translate(&srect, -es->geometry.x, -es->geometry.y); - - box = pixman_region32_extents(&srect); - s->sx = box->x1 << 16; - s->sy = box->y1 << 16; - s->sw = (box->x2 - box->x1) << 16; - s->sh = (box->y2 - box->y1) << 16; - pixman_region32_fini(&srect); - - wl_signal_add(&es->buffer->resource.destroy_signal, - &s->pending_destroy_listener); - - return 0; -} - -EINTERN Eina_Bool -e_drm_output_surface_transform_supported(E_Surface *es) -{ - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if ((es) && (es->transform.enabled)) return EINA_TRUE; - return EINA_FALSE; -} - -EINTERN Eina_Bool -e_drm_output_surface_overlap_supported(E_Output *base __UNUSED__, pixman_region32_t *overlap) -{ - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (pixman_region32_not_empty(overlap)) return EINA_TRUE; - return EINA_FALSE; -} - -EINTERN Eina_Bool -e_drm_output_surface_format_supported(E_Sprite *s, unsigned int format) -{ - unsigned int i = 0; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - for (i = 0; i < s->format_count; i++) - if (s->formats[i] == format) return EINA_TRUE; - - return EINA_FALSE; -} - -EINTERN void -e_drm_output_set_cursor_region(E_Output *output, E_Input_Device *device, pixman_region32_t *overlap) -{ - pixman_region32_t cregion; - Eina_Bool prior = EINA_FALSE; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!device->sprite) return; - pixman_region32_init(&cregion); - pixman_region32_intersect(&cregion, &device->sprite->transform.box, - &output->region); - if (!pixman_region32_not_empty(&cregion)) - { - e_drm_output_set_cursor(output, NULL); - goto out; - } - - prior = device->hw_cursor; - if ((pixman_region32_not_empty(overlap)) || - (!e_drm_output_set_cursor(output, device))) - { - if (prior) - { - e_surface_damage(device->sprite); - e_drm_output_set_cursor(output, NULL); - } - device->hw_cursor = EINA_FALSE; - } - else - { - if (!prior) e_surface_damage_below(device->sprite); - pixman_region32_fini(&device->sprite->damage); - pixman_region32_init(&device->sprite->damage); - device->hw_cursor = EINA_TRUE; - } - -out: - pixman_region32_fini(&cregion); -} - -EINTERN Eina_Bool -e_drm_output_set_cursor(E_Output *output, E_Input_Device *device) -{ - E_Drm_Output *doutput; - E_Drm_Compositor *dcomp; - EGLint hdl, stride; - int ret = -1; - struct gbm_bo *bo; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - doutput = (E_Drm_Output *)output; - dcomp = (E_Drm_Compositor *)doutput->base.compositor; - - if (!device) - { - drmModeSetCursor(dcomp->drm.fd, doutput->crtc_id, 0, 0, 0); - return EINA_TRUE; - } - - if (device->sprite->image == EGL_NO_IMAGE_KHR) return EINA_FALSE; - - if ((device->sprite->geometry.w > 64) || - (device->sprite->geometry.h > 64)) - return EINA_FALSE; - - bo = gbm_bo_create_from_egl_image(dcomp->gbm, dcomp->base.egl_display, - device->sprite->image, 64, 64, - GBM_BO_USE_CURSOR_64X64); - if (!bo) return EINA_FALSE; - - hdl = gbm_bo_get_handle(bo).s32; - stride = gbm_bo_get_pitch(bo); - gbm_bo_destroy(bo); - - if (stride != (64 * 4)) return EINA_FALSE; - - if ((ret = drmModeSetCursor(dcomp->drm.fd, doutput->crtc_id, hdl, 64, 64))) - { - drmModeSetCursor(dcomp->drm.fd, doutput->crtc_id, 0, 0, 0); - return EINA_FALSE; - } - - ret = drmModeMoveCursor(dcomp->drm.fd, doutput->crtc_id, - device->sprite->geometry.x - doutput->base.x, - device->sprite->geometry.y - doutput->base.y); - if (ret) - { - drmModeSetCursor(dcomp->drm.fd, doutput->crtc_id, 0, 0, 0); - return EINA_FALSE; - } - - return EINA_TRUE; -} diff --git a/src/modules/wl_drm/e_evdev.c b/src/modules/wl_drm/e_evdev.c deleted file mode 100644 index 4ce4760ac..000000000 --- a/src/modules/wl_drm/e_evdev.c +++ /dev/null @@ -1,664 +0,0 @@ -#include "e.h" -#include "e_mod_main.h" - -#define E_EVDEV_ABSOLUTE_MOTION (1 << 0) -#define E_EVDEV_ABSOLUTE_MT_DOWN (1 << 1) -#define E_EVDEV_ABSOLUTE_MT_MOTION (1 << 2) -#define E_EVDEV_ABSOLUTE_MT_UP (1 << 3) -#define E_EVDEV_RELATIVE_MOTION (1 << 4) - -#define BITS_PER_LONG (sizeof(unsigned long) * 8) -#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1) -#define OFF(x) ((x)%BITS_PER_LONG) -#define BIT(x) (1UL<> OFF(bit)) & 1) - -#define MODIFIER_CTRL (1 << 8) -#define MODIFIER_ALT (1 << 9) -#define MODIFIER_SUPER (1 << 10) - -/* local function prototypes */ -static Eina_Bool _e_evdev_config_udev_monitor(struct udev *udev, E_Evdev_Input *master); -static E_Evdev_Input_Device *_e_evdev_input_device_create(E_Evdev_Input *master, struct wl_display *display __UNUSED__, const char *path); -static Eina_Bool _e_evdev_configure_device(E_Evdev_Input_Device *dev); -static Eina_Bool _e_evdev_is_motion_event(struct input_event *e); -static void _e_evdev_flush_motion(E_Evdev_Input_Device *dev, unsigned int timestamp); -static void _e_evdev_process_touch(E_Evdev_Input_Device *device, struct input_event *e); -static void _e_evdev_process_events(E_Evdev_Input_Device *device, struct input_event *ev, int count); - -static int _e_evdev_cb_udev(int fd __UNUSED__, unsigned int mask __UNUSED__, void *data); -static void _e_evdev_cb_device_added(struct udev_device *dev, E_Evdev_Input *master); -static void _e_evdev_cb_device_removed(struct udev_device *dev, E_Evdev_Input *master); -static int _e_evdev_cb_device_data(int fd, unsigned int mask __UNUSED__, void *data); - -/* local variables */ -/* wayland interfaces */ -/* external variables */ - -EINTERN void -e_evdev_add_devices(struct udev *udev, E_Input_Device *base) -{ - E_Evdev_Input *input; - struct udev_enumerate *ue; - struct udev_list_entry *entry; - struct udev_device *device; - const char *path = NULL; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - input = (E_Evdev_Input *)base; - ue = udev_enumerate_new(udev); - udev_enumerate_add_match_subsystem(ue, "input"); - udev_enumerate_scan_devices(ue); - udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(ue)) - { - path = udev_list_entry_get_name(entry); - device = udev_device_new_from_syspath(udev, path); - if (strncmp("event", udev_device_get_sysname(device), 5) != 0) - continue; - _e_evdev_cb_device_added(device, input); - udev_device_unref(device); - } - udev_enumerate_unref(ue); - - if (wl_list_empty(&input->devices)) - printf("No Input Devices Found\n"); -} - -EINTERN void -e_evdev_remove_devices(E_Input_Device *base) -{ - E_Evdev_Input *input; - E_Evdev_Input_Device *device, *next; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - input = (E_Evdev_Input *)base; - wl_list_for_each_safe(device, next, &input->devices, link) - { - wl_event_source_remove(device->source); - wl_list_remove(&device->link); - if (device->mtdev) mtdev_close_delete(device->mtdev); - close(device->fd); - free(device->devnode); - free(device); - } -} - -EINTERN void -e_evdev_input_create(E_Compositor *comp, struct udev *udev, const char *seat) -{ - E_Evdev_Input *input; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!(input = malloc(sizeof(E_Evdev_Input)))) return; - memset(input, 0, sizeof(E_Evdev_Input)); - e_input_device_init(&input->base, comp); - wl_list_init(&input->devices); - input->seat = strdup(seat); - if (!_e_evdev_config_udev_monitor(udev, input)) - { - free(input->seat); - free(input); - return; - } - e_evdev_add_devices(udev, &input->base); - comp->input_device = &input->base.input_device; -} - -EINTERN void -e_evdev_input_destroy(E_Input_Device *base) -{ - E_Evdev_Input *input; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - input = (E_Evdev_Input *)base; - e_evdev_remove_devices(base); - wl_list_remove(&input->base.link); - free(input->seat); - free(input); -} - -/* local functions */ -static Eina_Bool -_e_evdev_config_udev_monitor(struct udev *udev, E_Evdev_Input *master) -{ - struct wl_event_loop *loop; - E_Compositor *comp; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - comp = master->base.compositor; - if (!(master->monitor = udev_monitor_new_from_netlink(udev, "udev"))) - return EINA_FALSE; - udev_monitor_filter_add_match_subsystem_devtype(master->monitor, "input", NULL); - if (udev_monitor_enable_receiving(master->monitor)) - return EINA_FALSE; - loop = wl_display_get_event_loop(comp->display); - wl_event_loop_add_fd(loop, udev_monitor_get_fd(master->monitor), - WL_EVENT_READABLE, _e_evdev_cb_udev, master); - return EINA_TRUE; -} - -static E_Evdev_Input_Device * -_e_evdev_input_device_create(E_Evdev_Input *master, struct wl_display *display __UNUSED__, const char *path) -{ - E_Evdev_Input_Device *device; - E_Compositor *comp; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!(device = malloc(sizeof(E_Evdev_Input_Device)))) return NULL; - comp = master->base.compositor; - device->output = container_of(comp->outputs.next, E_Output, link); - device->master = master; - device->is_pad = EINA_FALSE; - device->is_mt = EINA_FALSE; - device->mtdev = NULL; - device->devnode = strdup(path); - device->mt.slot = -1; - device->rel.dx = 0; - device->rel.dy = 0; - - device->fd = open(path, O_RDONLY | O_NONBLOCK); - if (device->fd < 0) goto err0; - - if (!_e_evdev_configure_device(device)) goto err1; - - if (device->is_mt) - { - if (!(device->mtdev = mtdev_new_open(device->fd))) - printf("mtdev Failed to open device: %s\n", path); - } - - device->source = - wl_event_loop_add_fd(comp->input_loop, device->fd, WL_EVENT_READABLE, - _e_evdev_cb_device_data, device); - if (!device->source) goto err1; - - wl_list_insert(master->devices.prev, &device->link); - - return device; - -err1: - close(device->fd); - -err0: - free(device->devnode); - free(device); - return NULL; -} - -static Eina_Bool -_e_evdev_configure_device(E_Evdev_Input_Device *dev) -{ - struct input_absinfo absinfo; - unsigned long ebits[NBITS(EV_MAX)]; - unsigned long abits[NBITS(ABS_MAX)]; - unsigned long kbits[NBITS(KEY_MAX)]; - Eina_Bool has_key = EINA_FALSE, has_abs = EINA_FALSE; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - ioctl(dev->fd, EVIOCGBIT(0, sizeof(ebits)), ebits); - if (TEST_BIT(ebits, EV_ABS)) - { - has_abs = EINA_TRUE; - ioctl(dev->fd, EVIOCGBIT(EV_ABS, sizeof(abits)), abits); - if (TEST_BIT(abits, ABS_X)) - { - ioctl(dev->fd, EVIOCGABS(ABS_X), &absinfo); - dev->absolute.min_x = absinfo.minimum; - dev->absolute.max_x = absinfo.maximum; - } - if (TEST_BIT(abits, ABS_Y)) - { - ioctl(dev->fd, EVIOCGABS(ABS_Y), &absinfo); - dev->absolute.min_y = absinfo.minimum; - dev->absolute.max_y = absinfo.maximum; - } - if (TEST_BIT(abits, ABS_MT_SLOT)) - { - dev->is_mt = EINA_TRUE; - dev->mt.slot = 0; - } - } - if (TEST_BIT(ebits, EV_KEY)) - { - has_key = EINA_TRUE; - ioctl(dev->fd, EVIOCGBIT(EV_KEY, sizeof(kbits)), kbits); - if ((TEST_BIT(kbits, BTN_TOOL_FINGER)) && - (!TEST_BIT(kbits, BTN_TOOL_PEN))) - dev->is_pad = EINA_TRUE; - } - - if ((has_abs) && (!has_key)) return EINA_FALSE; - - return EINA_TRUE; -} - -static Eina_Bool -_e_evdev_is_motion_event(struct input_event *e) -{ - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - switch (e->type) - { - case EV_REL: - switch (e->code) - { - case REL_X: - case REL_Y: - return EINA_TRUE; - } - case EV_ABS: - switch (e->code) - { - case ABS_X: - case ABS_Y: - case ABS_MT_POSITION_X: - case ABS_MT_POSITION_Y: - return EINA_TRUE; - } - } - - return EINA_FALSE; -} - -static void -_e_evdev_flush_motion(E_Evdev_Input_Device *dev, unsigned int timestamp) -{ - struct wl_input_device *master; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!dev->type) return; - master = &dev->master->base.input_device; - if (dev->type & E_EVDEV_RELATIVE_MOTION) - { - e_input_notify_motion(master, timestamp, - master->x + dev->rel.dx, - master->y + dev->rel.dy); - dev->type &= ~E_EVDEV_RELATIVE_MOTION; - dev->rel.dx = 0; - dev->rel.dy = 0; - } - if (dev->type & E_EVDEV_ABSOLUTE_MT_DOWN) - { - e_input_notify_touch(master, timestamp, dev->mt.slot, - dev->mt.x[dev->mt.slot], - dev->mt.y[dev->mt.slot], - WL_INPUT_DEVICE_TOUCH_DOWN); - dev->type &= ~E_EVDEV_ABSOLUTE_MT_DOWN; - dev->type &= ~E_EVDEV_ABSOLUTE_MT_MOTION; - } - if (dev->type & E_EVDEV_ABSOLUTE_MT_MOTION) - { - e_input_notify_touch(master, timestamp, dev->mt.slot, - dev->mt.x[dev->mt.slot], - dev->mt.y[dev->mt.slot], - WL_INPUT_DEVICE_TOUCH_MOTION); - dev->type &= ~E_EVDEV_ABSOLUTE_MT_DOWN; - dev->type &= ~E_EVDEV_ABSOLUTE_MT_MOTION; - } - if (dev->type & E_EVDEV_ABSOLUTE_MT_UP) - { - e_input_notify_touch(master, timestamp, dev->mt.slot, 0, 0, - WL_INPUT_DEVICE_TOUCH_UP); - dev->type &= ~E_EVDEV_ABSOLUTE_MT_UP; - } - if (dev->type & E_EVDEV_ABSOLUTE_MOTION) - { - e_input_notify_motion(master, timestamp, - dev->absolute.x, dev->absolute.y); - dev->type &= ~E_EVDEV_ABSOLUTE_MOTION; - } -} - -static inline void -_e_evdev_process_key(E_Evdev_Input_Device *device, struct input_event *e, int timestamp) -{ - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (e->value == 2) return; - - switch (e->code) - { - case BTN_TOOL_PEN: - case BTN_TOOL_RUBBER: - case BTN_TOOL_BRUSH: - case BTN_TOOL_PENCIL: - case BTN_TOOL_AIRBRUSH: - case BTN_TOOL_FINGER: - case BTN_TOOL_MOUSE: - case BTN_TOOL_LENS: - if (device->is_pad) - { - device->absolute.rx = 1; - device->absolute.ry = 1; - } - break; - case BTN_TOUCH: - if (device->is_mt) break; - e->code = BTN_LEFT; - case BTN_LEFT: - case BTN_RIGHT: - case BTN_MIDDLE: - case BTN_SIDE: - case BTN_EXTRA: - case BTN_FORWARD: - case BTN_BACK: - case BTN_TASK: - e_input_notify_button(&device->master->base.input_device, - timestamp, e->code, e->value); - break; - default: - e_input_notify_key(&device->master->base.input_device, - timestamp, e->code, e->value); - break; - } -} - -static inline void -_e_evdev_process_absolute_motion(E_Evdev_Input_Device *device, struct input_event *e) -{ - int sw, sh; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - sw = device->output->current->w; - sh = device->output->current->h; - - switch (e->code) - { - case ABS_X: - device->absolute.x = - (e->value - device->absolute.min_x) * sw / - (device->absolute.max_x - device->absolute.min_x) + - device->output->x; - device->type |= E_EVDEV_ABSOLUTE_MOTION; - break; - case ABS_Y: - device->absolute.y = - (e->value - device->absolute.min_y) * sh / - (device->absolute.max_y - device->absolute.min_y) + - device->output->y; - device->type |= E_EVDEV_ABSOLUTE_MOTION; - break; - } -} - -static inline void -_e_evdev_process_absolute_motion_touchpad(E_Evdev_Input_Device *device, struct input_event *e) -{ - /* FIXME: Make this configurable. */ - const int touchpad_speed = 700; - - switch (e->code) - { - case ABS_X: - e->value -= device->absolute.min_x; - if (device->absolute.rx) - device->absolute.rx = 0; - else - { - device->rel.dx = - (e->value - device->absolute.ox) * touchpad_speed / - (device->absolute.max_x - device->absolute.min_x); - } - device->absolute.ox = e->value; - device->type |= E_EVDEV_RELATIVE_MOTION; - break; - case ABS_Y: - e->value -= device->absolute.min_y; - if (device->absolute.ry) - device->absolute.ry = 0; - else - { - device->rel.dy = - (e->value - device->absolute.oy) * touchpad_speed / - (device->absolute.max_y - device->absolute.min_y); - } - device->absolute.oy = e->value; - device->type |= E_EVDEV_RELATIVE_MOTION; - break; - } -} - -static inline void -_e_evdev_process_relative(E_Evdev_Input_Device *device, struct input_event *e, unsigned int timestamp) -{ - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - switch (e->code) - { - case REL_X: - device->rel.dx += e->value; - device->type |= E_EVDEV_RELATIVE_MOTION; - break; - case REL_Y: - device->rel.dy += e->value; - device->type |= E_EVDEV_RELATIVE_MOTION; - break; - case REL_WHEEL: - e_input_notify_axis(&device->master->base.input_device, timestamp, - WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, e->value); - break; - case REL_HWHEEL: - e_input_notify_axis(&device->master->base.input_device, timestamp, - WL_INPUT_DEVICE_AXIS_HORIZONTAL_SCROLL, e->value); - break; - } -} - -static inline void -_e_evdev_process_absolute(E_Evdev_Input_Device *device, struct input_event *e) -{ - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (device->is_pad) - _e_evdev_process_absolute_motion_touchpad(device, e); - else if (device->is_mt) - _e_evdev_process_touch(device, e); - else - _e_evdev_process_absolute_motion(device, e); -} - -static void -_e_evdev_process_touch(E_Evdev_Input_Device *device, struct input_event *e) -{ - int sw, sh; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - sw = device->output->current->w; - sh = device->output->current->h; - - switch (e->code) - { - case ABS_MT_SLOT: - device->mt.slot = e->value; - break; - case ABS_MT_TRACKING_ID: - if (e->value >= 0) - device->type |= E_EVDEV_ABSOLUTE_MT_DOWN; - else - device->type |= E_EVDEV_ABSOLUTE_MT_UP; - break; - case ABS_MT_POSITION_X: - device->mt.x[device->mt.slot] = - (e->value - device->absolute.min_x) * sw / - (device->absolute.max_x - device->absolute.min_x) + - device->output->x; - device->type |= E_EVDEV_ABSOLUTE_MT_MOTION; - break; - case ABS_MT_POSITION_Y: - device->mt.y[device->mt.slot] = - (e->value - device->absolute.min_y) * sh / - (device->absolute.max_y - device->absolute.min_y) + - device->output->y; - device->type |= E_EVDEV_ABSOLUTE_MT_MOTION; - break; - } -} - -static void -_e_evdev_process_events(E_Evdev_Input_Device *device, struct input_event *ev, int count) -{ - struct input_event *e, *end; - unsigned int timestamp = 0; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - device->type = 0; - e = ev; - end = e + count; - for (e = ev; e < end; e++) - { - timestamp = e->time.tv_sec * 1000 + e->time.tv_usec / 1000; - if (!_e_evdev_is_motion_event(e)) - _e_evdev_flush_motion(device, timestamp); - switch (e->type) - { - case EV_REL: - _e_evdev_process_relative(device, e, timestamp); - break; - case EV_ABS: - _e_evdev_process_absolute(device, e); - break; - case EV_KEY: - _e_evdev_process_key(device, e, timestamp); - break; - } - } - _e_evdev_flush_motion(device, timestamp); -} - -static int -_e_evdev_cb_udev(int fd __UNUSED__, unsigned int mask __UNUSED__, void *data) -{ - E_Evdev_Input *master; - struct udev_device *dev; - const char *action; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!(master = data)) return 1; - if (!(dev = udev_monitor_receive_device(master->monitor))) - return 1; - if ((action = udev_device_get_action(dev))) - { - if (strncmp("event", udev_device_get_sysname(dev), 5) != 0) - return 0; - if (!strcmp(action, "add")) - _e_evdev_cb_device_added(dev, master); - else if (!strcmp(action, "remove")) - _e_evdev_cb_device_removed(dev, master); - } - udev_device_unref(dev); - return 0; -} - -static void -_e_evdev_cb_device_added(struct udev_device *dev, E_Evdev_Input *master) -{ - E_Compositor *comp; - const char *node, *seat; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!(seat = udev_device_get_property_value(dev, "ID_SEAT"))) - seat = "seat0"; - if (strcmp(seat, master->seat)) return; - comp = master->base.compositor; - node = udev_device_get_devnode(dev); - _e_evdev_input_device_create(master, comp->display, node); -} - -static void -_e_evdev_cb_device_removed(struct udev_device *dev, E_Evdev_Input *master) -{ - const char *node; - E_Evdev_Input_Device *device, *next; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - node = udev_device_get_devnode(dev); - wl_list_for_each_safe(device, next, &master->devices, link) - { - if (!strcmp(device->devnode, node)) - { - wl_event_source_remove(device->source); - wl_list_remove(&device->link); - if (device->mtdev) mtdev_close_delete(device->mtdev); - close(device->fd); - free(device->devnode); - free(device); - break; - } - } -} - -static int -_e_evdev_cb_device_data(int fd, unsigned int mask __UNUSED__, void *data) -{ - E_Compositor *comp; - E_Evdev_Input_Device *device; - struct input_event ev[32]; - int len = 0; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - device = data; - comp = device->master->base.compositor; - if (!comp->focus) return 1; - - do - { - if (device->mtdev) - len = mtdev_get(device->mtdev, fd, ev, - (sizeof(ev) / sizeof(ev)[0]) * - sizeof(struct input_event)); - else - len = read(fd, &ev, sizeof(ev)); - - if ((len < 0) || (len % sizeof(ev[0]) != 0)) - return 1; - - printf("Process Input Events Len: %d\n", len); - - _e_evdev_process_events(device, ev, (len / sizeof(ev[0]))); - - } while (len > 0); - - /* len = read(fd, &ev, sizeof(ev)); */ - - /* device->type = 0; */ - /* e = ev; */ - /* end = (void *)ev + len; */ - /* for (e = ev; e < end; e++) */ - /* { */ - /* timestamp = (e->time.tv_sec * 1000 + e->time.tv_usec / 1000); */ - /* if (!_e_evdev_is_motion_event(e)) */ - /* _e_evdev_flush_motion(device, timestamp); */ - /* switch (e->type) */ - /* { */ - /* case EV_REL: */ - /* _e_evdev_process_relative_motion(device, e); */ - /* break; */ - /* case EV_ABS: */ - /* _e_evdev_process_absolute(device, e); */ - /* break; */ - /* case EV_KEY: */ - /* _e_evdev_process_key(device, e, timestamp); */ - /* break; */ - /* } */ - /* } */ - - /* _e_evdev_flush_motion(device, timestamp); */ - - return 1; -} diff --git a/src/modules/wl_drm/e_mod_main.c b/src/modules/wl_drm/e_mod_main.c index 5c5a65c5b..99e9e52a9 100644 --- a/src/modules/wl_drm/e_mod_main.c +++ b/src/modules/wl_drm/e_mod_main.c @@ -1,713 +1,62 @@ #include "e.h" -#include "e_mod_main.h" +#include +#include "e_comp_wl.h" +#include -/* local function prototypes */ -static void _cb_tty(E_Compositor *comp, int event); -static int _cb_drm_input(int fd, unsigned int mask __UNUSED__, void *data __UNUSED__); -static int _cb_drm_udev_event(int fd __UNUSED__, unsigned int mask __UNUSED__, void *data); -static void _cb_drm_page_flip(int fd __UNUSED__, unsigned int frame __UNUSED__, unsigned int sec, unsigned int usec, void *data); -static void _cb_drm_vblank(int fd __UNUSED__, unsigned int frame __UNUSED__, unsigned int sec __UNUSED__, unsigned int usec __UNUSED__, void *data); -static Eina_Bool _egl_init(E_Drm_Compositor *dcomp, struct udev_device *dev); -static void _sprites_init(E_Drm_Compositor *dcomp); -static void _sprites_shutdown(E_Drm_Compositor *dcomp); -static Eina_Bool _outputs_init(E_Drm_Compositor *dcomp, unsigned int conn, struct udev_device *drm_device); -static Eina_Bool _output_create(E_Drm_Compositor *dcomp, drmModeRes *res, drmModeConnector *conn, int x, int y, struct udev_device *drm_device); -static void _outputs_update(E_Drm_Compositor *dcomp, struct udev_device *drm_device); -static Eina_Bool _udev_event_is_hotplug(E_Drm_Compositor *dcomp, struct udev_device *dev); +#define SCREEN_WIDTH 1920 +#define SCREEN_HEIGHT 1200 -/* local variables */ -static drmModeModeInfo builtin_mode = -{ - 63500, /* clock */ - 1024, 1072, 1176, 1328, 0, - 768, 771, 775, 798, 0, - 59920, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC, - 0, - "1024x768" -}; - -/* external variables */ -E_Drm_Compositor *_drm_comp = NULL; - -EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Drm" }; +EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Drm" }; EAPI void * e_modapi_init(E_Module *m) { - struct wl_display *disp; - struct udev_enumerate *ue; - struct udev_list_entry *entry; - struct udev_device *drm_dev = NULL; - struct wl_event_loop *loop; - const char *seat = NULL; + E_Comp *comp; - DLOGFN(__FILE__, __LINE__, __FUNCTION__); + printf("LOAD WL_DRM MODULE\n"); - /* try to get the wayland display */ - if (!(disp = (struct wl_display *)m->data)) return NULL; + /* try to init ecore_drm */ + /* if (!ecore_drm_init()) */ + /* { */ + /* fprintf(stderr, "Could not initialize ecore_drm"); */ + /* return NULL; */ + /* } */ - /* allocate space for the drm compositor */ - if (!(_drm_comp = malloc(sizeof(E_Drm_Compositor)))) return NULL; - - memset(_drm_comp, 0, sizeof(E_Drm_Compositor)); - - if (!(_drm_comp->udev = udev_new())) + comp = e_comp_new(); + comp->comp_type = E_PIXMAP_TYPE_WL; + comp->ee = ecore_evas_drm_new(NULL, 0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + if (!comp->ee) { - free(_drm_comp); + fprintf(stderr, "Could not create ecore_evas_drm canvas"); return NULL; } - _drm_comp->base.display = disp; - if (!(_drm_comp->tty = e_tty_create(&_drm_comp->base, _cb_tty, 0))) + if (!e_xinerama_fake_screens_exist()) { - free(_drm_comp); - return NULL; + E_Screen *screen; + + screen = E_NEW(E_Screen, 1); + screen->escreen = screen->screen = 0; + screen->x = 0; + screen->y = 0; + screen->w = SCREEN_WIDTH; + screen->h = SCREEN_HEIGHT; + e_xinerama_screens_set(eina_list_append(NULL, screen)); } + comp->man = e_manager_new(0, comp, SCREEN_WIDTH, SCREEN_HEIGHT); + e_comp_wl_init(); + e_comp_canvas_init(comp); + e_comp_canvas_fake_layers_init(comp); + comp->pointer = e_pointer_canvas_new(comp->evas, 1); - ue = udev_enumerate_new(_drm_comp->udev); - udev_enumerate_add_match_subsystem(ue, "drm"); - udev_enumerate_add_match_sysname(ue, "card[0-9]*"); - - udev_enumerate_scan_devices(ue); - udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(ue)) - { - struct udev_device *dev; - const char *path = NULL; - - path = udev_list_entry_get_name(entry); - dev = udev_device_new_from_syspath(_drm_comp->udev, path); - if (!(seat = udev_device_get_property_value(dev, "ID_SEAT"))) - seat = "seat0"; - if (!strcmp(seat, "seat0")) - { - drm_dev = dev; - break; - } - udev_device_unref(dev); - } - - if (!drm_dev) - { - free(_drm_comp); - return NULL; - } - - /* init egl */ - if (!_egl_init(_drm_comp, drm_dev)) - { - free(_drm_comp); - return NULL; - } - - /* _drm_comp->base.destroy = _cb_destroy; */ - _drm_comp->base.focus = EINA_TRUE; - - _drm_comp->prev_state = E_COMPOSITOR_STATE_ACTIVE; - - glGenFramebuffers(1, &_drm_comp->base.fbo); - glBindFramebuffer(GL_FRAMEBUFFER, _drm_comp->base.fbo); - - if (!e_compositor_init(&_drm_comp->base, disp)) - { - free(_drm_comp); - return NULL; - } - - wl_list_init(&_drm_comp->sprites); - _sprites_init(_drm_comp); - - if (!_outputs_init(_drm_comp, 0, drm_dev)) - { - free(_drm_comp); - return NULL; - } - - udev_device_unref(drm_dev); - udev_enumerate_unref(ue); - - e_evdev_input_create(&_drm_comp->base, _drm_comp->udev, seat); - - loop = wl_display_get_event_loop(_drm_comp->base.display); - _drm_comp->drm_source = - wl_event_loop_add_fd(loop, _drm_comp->drm.fd, WL_EVENT_READABLE, - _cb_drm_input, _drm_comp); - - _drm_comp->udev_monitor = - udev_monitor_new_from_netlink(_drm_comp->udev, "udev"); - if (!_drm_comp->udev_monitor) - { - free(_drm_comp); - return NULL; - } - udev_monitor_filter_add_match_subsystem_devtype(_drm_comp->udev_monitor, - "drm", NULL); - - _drm_comp->udev_drm_source = - wl_event_loop_add_fd(loop, udev_monitor_get_fd(_drm_comp->udev_monitor), - WL_EVENT_READABLE, _cb_drm_udev_event, _drm_comp); - if (udev_monitor_enable_receiving(_drm_comp->udev_monitor) < 0) - { - free(_drm_comp); - return NULL; - } - - return &_drm_comp->base; + return m; } EAPI int -e_modapi_shutdown(E_Module *m __UNUSED__) +e_modapi_shutdown(E_Module *m EINA_UNUSED) { - E_Input_Device *input, *next; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - e_compositor_shutdown(&_drm_comp->base); - gbm_device_destroy(_drm_comp->gbm); - _sprites_shutdown(_drm_comp); - drmDropMaster(_drm_comp->drm.fd); - e_tty_destroy(_drm_comp->tty); - - wl_list_for_each_safe(input, next, &_drm_comp->base.inputs, link) - e_evdev_input_destroy(input); - - free(_drm_comp); - _drm_comp = NULL; + /* shutdown ecore_drm */ + /* ecore_drm_shutdown(); */ return 1; } - -EAPI int -e_modapi_save(E_Module *m __UNUSED__) -{ - return 1; -} - -/* local function prototypes */ -static void -_cb_tty(E_Compositor *comp, int event) -{ - E_Output *output; - E_Drm_Output *doutput; - E_Sprite *sprite; - E_Input_Device *input; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - switch (event) - { - case 0: // TTY_ENTER_VT - comp->focus = EINA_TRUE; - if (drmSetMaster(_drm_comp->drm.fd)) - { - printf("Failed to set master: %m\n"); - wl_display_terminate(comp->display); - } - comp->state = _drm_comp->prev_state; - e_drm_output_set_modes(_drm_comp); - e_compositor_damage_all(comp); - wl_list_for_each(input, &comp->inputs, link) - e_evdev_add_devices(_drm_comp->udev, input); - break; - case 1: // TTY_LEAVE_VT - comp->focus = EINA_FALSE; - _drm_comp->prev_state = comp->state; - comp->state = E_COMPOSITOR_STATE_SLEEPING; - wl_list_for_each(output, &comp->outputs, link) - { - output->repaint_needed = EINA_FALSE; - e_drm_output_set_cursor(output, NULL); - } - doutput = - container_of(comp->outputs.next, E_Drm_Output, base.link); - - wl_list_for_each(sprite, &_drm_comp->sprites, link) - drmModeSetPlane(_drm_comp->drm.fd, sprite->plane_id, - doutput->crtc_id, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - - wl_list_for_each(input, &comp->inputs, link) - e_evdev_remove_devices(input); - - if (drmDropMaster(_drm_comp->drm.fd < 0)) - printf("Failed to drop master: %m\n"); - - break; - } -} - -static int -_cb_drm_input(int fd, unsigned int mask __UNUSED__, void *data __UNUSED__) -{ - drmEventContext ectxt; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - memset(&ectxt, 0, sizeof(ectxt)); - - ectxt.version = DRM_EVENT_CONTEXT_VERSION; - ectxt.page_flip_handler = _cb_drm_page_flip; - ectxt.vblank_handler = _cb_drm_vblank; - drmHandleEvent(fd, &ectxt); - - return 1; -} - -static int -_cb_drm_udev_event(int fd __UNUSED__, unsigned int mask __UNUSED__, void *data) -{ - E_Drm_Compositor *dcomp; - struct udev_device *event; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!(dcomp = data)) return 1; - event = udev_monitor_receive_device(dcomp->udev_monitor); - if (_udev_event_is_hotplug(dcomp, event)) - _outputs_update(dcomp, event); - udev_device_unref(event); - return 1; -} - -static void -_cb_drm_page_flip(int fd __UNUSED__, unsigned int frame __UNUSED__, unsigned int sec, unsigned int usec, void *data) -{ - E_Drm_Output *doutput; - E_Drm_Compositor *dcomp; - unsigned int msecs; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!(doutput = data)) return; - dcomp = (E_Drm_Compositor *)doutput->base.compositor; - - if (doutput->scanout_buffer) - { - e_buffer_post_release(doutput->scanout_buffer); - wl_list_remove(&doutput->scanout_buffer_destroy_listener.link); - doutput->scanout_buffer = NULL; - drmModeRmFB(dcomp->drm.fd, doutput->fs_surf_fb_id); - doutput->fs_surf_fb_id = 0; - } - - if (doutput->pending_scanout_buffer) - { - doutput->scanout_buffer = doutput->pending_scanout_buffer; - wl_list_remove(&doutput->pending_scanout_buffer_destroy_listener.link); - wl_signal_add(&doutput->scanout_buffer->resource.destroy_signal, - &doutput->scanout_buffer_destroy_listener); - doutput->pending_scanout_buffer = NULL; - doutput->fs_surf_fb_id = doutput->pending_fs_surf_fb_id; - doutput->pending_fs_surf_fb_id = 0; - } - - msecs = sec * 1000 + usec / 1000; - e_output_finish_frame(&doutput->base, msecs); -} - -static void -_cb_drm_vblank(int fd __UNUSED__, unsigned int frame __UNUSED__, unsigned int sec __UNUSED__, unsigned int usec __UNUSED__, void *data) -{ - E_Sprite *es; - E_Drm_Compositor *dcomp; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!(es = data)) return; - dcomp = es->compositor; - - if (es->surface) - { - e_buffer_post_release(es->surface->buffer); - wl_list_remove(&es->destroy_listener.link); - es->surface = NULL; - drmModeRmFB(dcomp->drm.fd, es->fb_id); - es->fb_id = 0; - } - - if (es->pending_surface) - { - wl_list_remove(&es->pending_destroy_listener.link); - wl_signal_add(&es->pending_surface->buffer->resource.destroy_signal, - &es->destroy_listener); - es->surface = es->pending_surface; - es->pending_surface = NULL; - es->fb_id = es->pending_fb_id; - es->pending_fb_id = 0; - } -} - -static Eina_Bool -_egl_init(E_Drm_Compositor *dcomp, struct udev_device *dev) -{ - EGLint maj, min; - const char *ext, *fname, *snum; - int fd = 0; - static const EGLint ctxt_att[] = - { - EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE - }; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if ((snum = udev_device_get_sysnum(dev))) - dcomp->drm.id = atoi(snum); - if ((!snum) || (dcomp->drm.id < 0)) - return EINA_FALSE; - - fname = udev_device_get_devnode(dev); - if (!(fd = open(fname, (O_RDWR | O_CLOEXEC)))) - return EINA_FALSE; - - dcomp->drm.fd = fd; - dcomp->gbm = gbm_create_device(dcomp->drm.fd); - -// dcomp->base.egl_display = eglGetDisplay(dcomp->base.display); - dcomp->base.egl_display = eglGetDisplay(dcomp->gbm); - if (!dcomp->base.egl_display) - return EINA_FALSE; - - if (!eglInitialize(dcomp->base.egl_display, &maj, &min)) - return EINA_FALSE; - - ext = eglQueryString(dcomp->base.egl_display, EGL_EXTENSIONS); - if (!strstr(ext, "EGL_KHR_surfaceless_gles2")) - return EINA_FALSE; - - if (!eglBindAPI(EGL_OPENGL_ES_API)) return EINA_FALSE; - - dcomp->base.egl_context = - eglCreateContext(dcomp->base.egl_display, NULL, EGL_NO_CONTEXT, ctxt_att); - if (!dcomp->base.egl_context) return EINA_FALSE; - - if (!eglMakeCurrent(dcomp->base.egl_display, EGL_NO_SURFACE, - EGL_NO_SURFACE, dcomp->base.egl_context)) - return EINA_FALSE; - - return EINA_TRUE; -} - -static void -_sprites_init(E_Drm_Compositor *dcomp) -{ - E_Sprite *es; - drmModePlaneRes *res; - drmModePlane *plane; - unsigned int i = 0; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!(res = drmModeGetPlaneResources(dcomp->drm.fd))) - return; - - for (i = 0; i < res->count_planes; i++) - { - if (!(plane = drmModeGetPlane(dcomp->drm.fd, res->planes[i]))) - continue; - if (!(es = e_sprite_create(dcomp, plane))) - { - free(plane); - continue; - } - drmModeFreePlane(plane); - wl_list_insert(&dcomp->sprites, &es->link); - } - free(res->planes); - free(res); -} - -static void -_sprites_shutdown(E_Drm_Compositor *dcomp) -{ - E_Drm_Output *doutput; - E_Sprite *es, *next; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - doutput = container_of(dcomp->base.outputs.next, E_Drm_Output, base.link); - - wl_list_for_each_safe(es, next, &dcomp->sprites, link) - { - drmModeSetPlane(dcomp->drm.fd, es->plane_id, doutput->crtc_id, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - drmModeRmFB(dcomp->drm.fd, es->fb_id); - free(es); - } -} - -static Eina_Bool -_outputs_init(E_Drm_Compositor *dcomp, unsigned int conn, struct udev_device *drm_device) -{ - drmModeConnector *connector; - drmModeRes *res; - int i = 0, x = 0, y = 0; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!(res = drmModeGetResources(dcomp->drm.fd))) - return EINA_FALSE; - - if (!(dcomp->crtcs = calloc(res->count_crtcs, sizeof(unsigned int)))) - { - drmModeFreeResources(res); - return EINA_FALSE; - } - - dcomp->num_crtcs = res->count_crtcs; - memcpy(dcomp->crtcs, res->crtcs, sizeof(unsigned int) * dcomp->num_crtcs); - - for (i = 0; i < res->count_connectors; i++) - { - if (!(connector = - drmModeGetConnector(dcomp->drm.fd, res->connectors[i]))) - continue; - if ((connector->connection == DRM_MODE_CONNECTED) && - ((conn == 0) || (connector->connector_id == conn))) - { - if (!_output_create(dcomp, res, connector, x, y, drm_device)) - { - drmModeFreeConnector(connector); - continue; - } - x += container_of(dcomp->base.outputs.prev, E_Output, - link)->current->w; - } - drmModeFreeConnector(connector); - } - - if (wl_list_empty(&dcomp->base.outputs)) - { - drmModeFreeResources(res); - return EINA_FALSE; - } - - drmModeFreeResources(res); - - return EINA_TRUE; -} - -static Eina_Bool -_output_create(E_Drm_Compositor *dcomp, drmModeRes *res, drmModeConnector *conn, int x, int y, struct udev_device *drm_device) -{ - E_Drm_Output *output; - E_Drm_Output_Mode *mode, *next; - drmModeEncoder *encoder; - int i = 0, ret = 0; - unsigned int hdl, stride; - - if (!(encoder = drmModeGetEncoder(dcomp->drm.fd, conn->encoders[0]))) - return EINA_FALSE; - - for (i = 0; i < res->count_crtcs; i++) - { - if ((encoder->possible_crtcs & (1 << i)) && - !(dcomp->crtc_alloc & (1 << res->crtcs[i]))) - break; - } - if (i == res->count_crtcs) - { - drmModeFreeEncoder(encoder); - return EINA_FALSE; - } - - if (!(output = malloc(sizeof(E_Drm_Output)))) - { - drmModeFreeEncoder(encoder); - return EINA_FALSE; - } - - memset(output, 0, sizeof(E_Drm_Output)); - - output->fb_id[0] = -1; - output->fb_id[1] = -1; - output->base.subpixel = e_drm_output_subpixel_convert(conn->subpixel); - output->base.make = "unknown"; - output->base.model = "unknown"; - wl_list_init(&output->base.modes); - - output->crtc_id = res->crtcs[i]; - dcomp->crtc_alloc |= (1 << output->crtc_id); - output->conn_id = conn->connector_id; - dcomp->conn_alloc |= (1 << output->conn_id); - - output->orig_crtc = drmModeGetCrtc(dcomp->drm.fd, output->crtc_id); - drmModeFreeEncoder(encoder); - - for (i = 0; i < conn->count_modes; i++) - { - if (!e_drm_output_add_mode(output, &conn->modes[i])) - goto efree; - } - - if (conn->count_modes == 0) - { - if (!e_drm_output_add_mode(output, &builtin_mode)) - goto efree; - } - - mode = container_of(output->base.modes.next, E_Drm_Output_Mode, base.link); - output->base.current = &mode->base; - mode->base.flags = (WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED); - - glGenRenderbuffers(2, output->rbo); - - for (i = 0; i < 2; i++) - { - glBindRenderbuffer(GL_RENDERBUFFER, output->rbo[i]); - output->bo[i] = - gbm_bo_create(dcomp->gbm, output->base.current->w, - output->base.current->h, GBM_BO_FORMAT_XRGB8888, - (GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING)); - if (!output->bo[i]) goto ebuffs; - output->image[i] = - dcomp->base.create_image(dcomp->base.egl_display, NULL, - EGL_NATIVE_PIXMAP_KHR, output->bo[i], NULL); - if (!output->image[i]) goto ebuffs; - dcomp->base.image_target_renderbuffer_storage(GL_RENDERBUFFER, - output->image[i]); - stride = gbm_bo_get_pitch(output->bo[i]); - hdl = gbm_bo_get_handle(output->bo[i]).u32; - ret = drmModeAddFB(dcomp->drm.fd, output->base.current->w, - output->base.current->h, 24, 32, stride, hdl, - &output->fb_id[i]); - if (ret) goto ebuffs; - } - - output->current = 0; - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_RENDERBUFFER, output->rbo[output->current]); - ret = drmModeSetCrtc(dcomp->drm.fd, output->crtc_id, - output->fb_id[output->current ^ 1], 0, 0, - &output->conn_id, 1, &mode->info); - if (ret) goto efb; - - /* TODO: backlight init */ - - e_output_init(&output->base, &dcomp->base, x, y, - conn->mmWidth, conn->mmHeight, 0); - - wl_list_insert(dcomp->base.outputs.prev, &output->base.link); - - output->scanout_buffer_destroy_listener.notify = - e_drm_output_scanout_buffer_destroy; - output->pending_scanout_buffer_destroy_listener.notify = - e_drm_output_pending_scanout_buffer_destroy; - - output->pending_fs_surf_fb_id = 0; - output->base.repaint = e_drm_output_repaint; - output->base.destroy = e_drm_output_destroy; - output->base.assign_planes = e_drm_output_assign_planes; - output->base.set_dpms = e_drm_output_set_dpms; - - return EINA_TRUE; - -efb: - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_RENDERBUFFER, 0); - -ebuffs: - for (i = 0; i < 2; i++) - { - if ((int)output->fb_id[i] != -1) - drmModeRmFB(dcomp->drm.fd, output->fb_id[i]); - if (output->image[i]) - dcomp->base.destroy_image(dcomp->base.egl_display, output->image[i]); - if (output->bo[i]) gbm_bo_destroy(output->bo[i]); - } - glBindRenderbuffer(GL_RENDERBUFFER, 0); - glDeleteRenderbuffers(2, output->rbo); - -efree: - wl_list_for_each_safe(mode, next, &output->base.modes, base.link) - { - wl_list_remove(&mode->base.link); - free(mode); - } - drmModeFreeCrtc(output->orig_crtc); - dcomp->crtc_alloc &= ~(1 << output->crtc_id); - dcomp->conn_alloc &= ~(1 << output->conn_id); - free(output); - - return EINA_TRUE; -} - -static void -_outputs_update(E_Drm_Compositor *dcomp, struct udev_device *drm_device) -{ - drmModeConnector *conn; - drmModeRes *res; - E_Drm_Output *doutput, *next; - int x = 0, y = 0; - int xo = 0, yo = 0; - unsigned int connected = 0, disconnects = 0; - int i = 0; - - if (!(res = drmModeGetResources(dcomp->drm.fd))) - return; - - for (i = 0; i < res->count_connectors; i++) - { - int conn_id; - - conn_id = res->connectors[i]; - if (!(conn = drmModeGetConnector(dcomp->drm.fd, conn_id))) - continue; - if (conn->connection != DRM_MODE_CONNECTED) - { - drmModeFreeConnector(conn); - continue; - } - connected |= (1 << conn_id); - if (!(dcomp->conn_alloc & (1 << conn_id))) - { - E_Output *last; - - last = container_of(dcomp->base.outputs.prev, E_Output, link); - if (!wl_list_empty(&dcomp->base.outputs)) - x = last->x + last->current->w; - else - x = 0; - y = 0; - _output_create(dcomp, res, conn, x, y, drm_device); - } - drmModeFreeConnector(conn); - } - drmModeFreeResources(res); - - if ((disconnects = dcomp->conn_alloc & ~connected)) - { - wl_list_for_each_safe(doutput, next, &dcomp->base.outputs, base.link) - { - if ((xo != 0) || (yo != 0)) - e_output_move(&doutput->base, doutput->base.x - xo, - doutput->base.y - yo); - if (disconnects & (1 << doutput->conn_id)) - { - disconnects &= ~(1 << doutput->conn_id); - xo += doutput->base.current->w; - e_drm_output_destroy(&doutput->base); - } - } - } - - if (dcomp->conn_alloc == 0) - wl_display_terminate(dcomp->base.display); -} - -static Eina_Bool -_udev_event_is_hotplug(E_Drm_Compositor *dcomp, struct udev_device *dev) -{ - const char *snum, *val; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - snum = udev_device_get_sysnum(dev); - if ((!snum) || (atoi(snum) != dcomp->drm.id)) - return EINA_FALSE; - - if (!(val = udev_device_get_property_value(dev, "HOTPLUG"))) - return EINA_FALSE; - - if (!strcmp(val, "1")) return EINA_TRUE; - - return EINA_FALSE; -} diff --git a/src/modules/wl_drm/e_mod_main.h b/src/modules/wl_drm/e_mod_main.h deleted file mode 100644 index 73be2b6cd..000000000 --- a/src/modules/wl_drm/e_mod_main.h +++ /dev/null @@ -1,234 +0,0 @@ -#ifndef E_MOD_MAIN_H -# define E_MOD_MAIN_H - -# define DLOGFNS 1 - -# ifdef DLOGFNS -# include -# define DLOGFN(fl, ln, fn) printf("-E-DRM: %25s: %5i - %s\n", fl, ln, fn); -# else -# define DLOGFN(fl, ln, fn) -# endif - -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include - -typedef void (*tty_vt_func_t)(E_Compositor *comp, int event); -typedef struct _E_Tty E_Tty; -typedef struct _E_Drm_Compositor E_Drm_Compositor; -typedef struct _E_Sprite E_Sprite; -typedef struct _E_Drm_Output_Mode E_Drm_Output_Mode; -typedef struct _E_Drm_Output E_Drm_Output; -typedef struct _E_Drm_Fb E_Drm_Fb; -typedef struct _E_Evdev_Input E_Evdev_Input; -typedef struct _E_Evdev_Input_Device E_Evdev_Input_Device; - -struct _E_Drm_Fb -{ - E_Drm_Output *output; - unsigned int fb, stride, hdl, size; - int fd; - Eina_Bool client_buffer : 1; - - struct - { - struct wl_buffer *buffer; - struct wl_listener buffer_destroy; - } reference; - - struct gbm_bo *bo; - - void *map; -}; - -struct _E_Drm_Compositor -{ - E_Wayland_Compositor base; - - struct udev *udev; - struct wl_event_source *drm_source; - struct udev_monitor *udev_monitor; - struct wl_event_source *udev_drm_source; - struct - { - int id, fd; - } drm; - struct gbm_device *gbm; - unsigned int *crtcs; - int num_crtcs; - unsigned int crtc_alloc; - unsigned int conn_alloc; - - E_Tty *tty; - - struct - { - unsigned int width, height; - } min, max; - - struct wl_list sprites; - Eina_Bool sprites_broken; - unsigned int prev_state; -}; - -struct _E_Tty -{ - E_Wayland_Compositor *comp; - - int fd; - struct termios term_attribs; - struct wl_event_source *input_source; - struct wl_event_source *vt_source; - tty_vt_func_t vt_func; - int vt, start_vt; - Eina_Bool has_vt : 1; - int kbd_mode; -}; - -struct _E_Sprite -{ - struct wl_list link; - - E_Drm_Output *output; - E_Drm_Fb *current_fb, *next_fb; - E_Drm_Compositor *compositor; - - unsigned int possible_crtcs; - unsigned int plane_id; - - int sx, sy; - unsigned int sw, sh; - unsigned int dx, dy, dw, dh; - - unsigned int format_count; - unsigned int formats[]; -}; - -struct _E_Drm_Output_Mode -{ - E_Wayland_Output_Mode base; - drmModeModeInfo info; -}; - -struct _E_Drm_Output -{ - E_Wayland_Output base; - - unsigned int crtc_id; - unsigned int conn_id; - drmModeCrtcPtr orig_crtc; - - struct - { - Eina_Bool vblank : 1; - Eina_Bool page_flip : 1; - } pending; - - struct gbm_surface *gsurface; - struct gbm_bo *gcursor[2]; - - struct - { - E_Wayland_Surface *surface; - int current; - } cursor; - - E_Drm_Fb *current, *next, *dummy[2]; - - pixman_image_t *img[2]; - int current_img; - - pixman_region32_t prev_damage; - - /* TODO: backlight */ -}; - -struct _E_Evdev_Input -{ - E_Wayland_Input base; - struct wl_list devices; - struct udev_monitor *monitor; - struct wl_event_source *monitor_source; - char *seat; -}; - -struct _E_Evdev_Input_Device -{ - E_Evdev_Input *master; - struct wl_list link; - struct wl_event_source *source; - E_Wayland_Output *output; - char *devnode; - int fd; - struct - { - int min_x, max_x, min_y, max_y; - int ox, oy, rx, ry; - int x, y; - } absolute; - struct - { - int slot; - int x[16], y[16]; - } mt; - struct mtdev *mtdev; - struct - { - int dx, dy; - } rel; - - int type; - - Eina_Bool is_pad : 1; - Eina_Bool is_mt : 1; -}; - -extern E_Drm_Compositor *_comp; - -EAPI extern E_Module_Api e_modapi; - -EAPI void *e_modapi_init(E_Module *m); -EAPI int e_modapi_shutdown(E_Module *m); -EAPI int e_modapi_save(E_Module *m); - -EINTERN E_Sprite *e_sprite_create(E_Drm_Compositor *dcomp, drmModePlane *plane); -EINTERN Eina_Bool e_sprite_crtc_supported(E_Wayland_Output *output, unsigned int supported); - -EINTERN E_Tty *e_tty_create(E_Wayland_Compositor *comp, tty_vt_func_t vt_func, int tty); -EINTERN void e_tty_destroy(E_Tty *et); - -EINTERN int e_drm_output_subpixel_convert(int value); -EINTERN Eina_Bool e_drm_output_add_mode(E_Drm_Output *output, drmModeModeInfo *info); -EINTERN void e_drm_output_set_modes(E_Drm_Compositor *dcomp); -EINTERN void e_drm_output_scanout_buffer_destroy(struct wl_listener *listener, void *data); -EINTERN void e_drm_output_pending_scanout_buffer_destroy(struct wl_listener *listener, void *data); -EINTERN void e_drm_output_repaint(E_Wayland_Output *base, pixman_region32_t *damage); -EINTERN void e_drm_output_destroy(E_Wayland_Output *base); -EINTERN void e_drm_output_assign_planes(E_Wayland_Output *base); -EINTERN void e_drm_output_set_dpms(E_Wayland_Output *base, E_Dpms_Level level); -EINTERN Eina_Bool e_drm_output_prepare_scanout_surface(E_Drm_Output *output); -EINTERN void e_drm_output_disable_sprites(E_Wayland_Output *base); -EINTERN drmModePropertyPtr e_drm_output_get_property(int fd, drmModeConnectorPtr conn, const char *name); -EINTERN int e_drm_output_prepare_overlay_surface(E_Wayland_Output *base, E_Wayland_Surface *es, pixman_region32_t *overlap); -EINTERN Eina_Bool e_drm_output_surface_transform_supported(E_Wayland_Surface *es); -EINTERN Eina_Bool e_drm_output_surface_overlap_supported(E_Wayland_Output *base EINA_UNUSED, pixman_region32_t *overlap); -EINTERN Eina_Bool e_drm_output_surface_format_supported(E_Sprite *s, unsigned int format); -EINTERN void e_drm_output_set_cursor_region(E_Wayland_Output *output, E_Wayland_Input *device, pixman_region32_t *overlap); -EINTERN Eina_Bool e_drm_output_set_cursor(E_Wayland_Output *output, E_Wayland_Input *device); - -EINTERN void e_evdev_add_devices(struct udev *udev, E_Wayland_Input *base); -EINTERN void e_evdev_remove_devices(E_Wayland_Input *base); -EINTERN void e_evdev_input_create(E_Wayland_Compositor *comp, struct udev *udev, const char *seat); -EINTERN void e_evdev_input_destroy(E_Wayland_Input *base); - -#endif diff --git a/src/modules/wl_drm/e_sprite.c b/src/modules/wl_drm/e_sprite.c deleted file mode 100644 index fa33d1ca6..000000000 --- a/src/modules/wl_drm/e_sprite.c +++ /dev/null @@ -1,88 +0,0 @@ -#include "e.h" -#include "e_mod_main.h" - -/* local function prototypes */ -static void _e_sprite_cb_buffer_destroy(struct wl_listener *listener, void *data __UNUSED__); -static void _e_sprite_cb_pending_buffer_destroy(struct wl_listener *listener, void *data __UNUSED__); - -/* local variables */ -/* wayland interfaces */ -/* external variables */ - -EINTERN E_Sprite * -e_sprite_create(E_Drm_Compositor *dcomp, drmModePlane *plane) -{ - E_Sprite *es; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!plane) return NULL; - - es = malloc(sizeof(E_Sprite) + ((sizeof(unsigned int)) * plane->count_formats)); - if (!es) return NULL; - - memset(es, 0, sizeof(E_Sprite)); - - es->compositor = dcomp; - es->possible_crtcs = plane->possible_crtcs; - es->plane_id = plane->plane_id; - es->surface = NULL; - es->pending_surface = NULL; - es->fb_id = 0; - es->pending_fb_id = 0; - es->destroy_listener.notify = _e_sprite_cb_buffer_destroy; - es->pending_destroy_listener.notify = _e_sprite_cb_pending_buffer_destroy; - es->format_count = plane->count_formats; - memcpy(es->formats, plane->formats, - plane->count_formats * sizeof(plane->formats[0])); - - return es; -} - -EINTERN Eina_Bool -e_sprite_crtc_supported(E_Output *output, unsigned int supported) -{ - E_Compositor *comp; - E_Drm_Compositor *dcomp; - E_Drm_Output *doutput; - int crtc = 0; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - comp = output->compositor; - dcomp = (E_Drm_Compositor *)comp; - doutput = (E_Drm_Output *)output; - - for (crtc = 0; crtc < dcomp->num_crtcs; crtc++) - { - if (dcomp->crtcs[crtc] != doutput->crtc_id) - continue; - if (supported & (1 << crtc)) - return EINA_TRUE; - } - - return EINA_FALSE; -} - -/* local functions */ -static void -_e_sprite_cb_buffer_destroy(struct wl_listener *listener, void *data __UNUSED__) -{ - E_Sprite *es; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - es = container_of(listener, E_Sprite, destroy_listener); - es->surface = NULL; -} - -static void -_e_sprite_cb_pending_buffer_destroy(struct wl_listener *listener, void *data __UNUSED__) -{ - E_Sprite *es; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - es = container_of(listener, E_Sprite, pending_destroy_listener); - es->pending_surface = NULL; -} diff --git a/src/modules/wl_drm/e_tty.c b/src/modules/wl_drm/e_tty.c deleted file mode 100644 index 40902b780..000000000 --- a/src/modules/wl_drm/e_tty.c +++ /dev/null @@ -1,201 +0,0 @@ -#include "e.h" -#include "e_mod_main.h" - -/* local function prototypes */ -static int _e_tty_open_vt(E_Tty *et); -static int _e_tty_cb_input(int fd __UNUSED__, uint32_t mask __UNUSED__, void *data); -static int _e_tty_cb_handle(int sig __UNUSED__, void *data); - -EINTERN E_Tty * -e_tty_create(E_Compositor *comp, tty_vt_func_t vt_func, int tty) -{ - E_Tty *et = NULL; - struct stat buff; - struct termios raw_attribs; - struct wl_event_loop *loop; - struct vt_mode mode; - int ret = 0; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!(et = malloc(sizeof(E_Tty)))) - { - e_error_message_show(_("Could not allocate space for E_Tty\n")); - return NULL; - } - - memset(et, 0, sizeof(E_Tty)); - - et->comp = comp; - et->vt_func = vt_func; - if (tty > 0) - { - char fname[16]; - - snprintf(fname, sizeof(fname), "/dev/tty%d", tty); - printf("Using %s for tty\n", fname); - et->fd = open(fname, O_RDWR | O_NOCTTY | O_CLOEXEC); - } - else if ((fstat(et->fd, &buff) == 0) && - (major(buff.st_rdev) == TTY_MAJOR) && (minor(buff.st_rdev) > 0)) - et->fd = fcntl(0, F_DUPFD_CLOEXEC, 0); - else - et->fd = _e_tty_open_vt(et); - - if (et->fd <= 0) - { - e_error_message_show(_("Could not open a tty.\n")); - free(et); - return NULL; - } - - if (tcgetattr(et->fd, &et->term_attribs) < 0) - { - e_error_message_show(_("Could not get terminal attributes: %m\n")); - free(et); - return NULL; - } - - raw_attribs = et->term_attribs; - cfmakeraw(&raw_attribs); - - raw_attribs.c_oflag |= (OPOST | OCRNL); - if (tcsetattr(et->fd, TCSANOW, &raw_attribs) < 0) - { - e_error_message_show(_("Could not put terminal in raw mode: %m\n")); - free(et); - return NULL; - } - - loop = wl_display_get_event_loop(comp->display); - et->input_source = - wl_event_loop_add_fd(loop, et->fd, WL_EVENT_READABLE, _e_tty_cb_input, et); - - if ((ret = ioctl(et->fd, KDSETMODE, KD_GRAPHICS))) - { - e_error_message_show(_("Failed to set graphics mode on tty: %m\n")); - free(et); - return NULL; - } - - et->has_vt = EINA_TRUE; - mode.mode = VT_PROCESS; - mode.relsig = SIGUSR1; - mode.acqsig = SIGUSR1; - if (ioctl(et->fd, VT_SETMODE, &mode) < 0) - { - e_error_message_show(_("Failed to take control of vt handling: %m\n")); - free(et); - return NULL; - } - - et->vt_source = - wl_event_loop_add_signal(loop, SIGUSR1, _e_tty_cb_handle, et); - - return et; -} - -EINTERN void -e_tty_destroy(E_Tty *et) -{ - struct vt_mode mode; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if (!et) return; - if (ioctl(et->fd, KDSETMODE, KD_TEXT)) - e_error_message_show(_("Failed to set KD_TEXT mode on tty: %m\n")); - if (tcsetattr(et->fd, TCSANOW, &et->term_attribs) < 0) - e_error_message_show(_("Could not restore terminal to canonical mode: %m\n")); - mode.mode = VT_AUTO; - if (ioctl(et->fd, VT_SETMODE, &mode) < 0) - e_error_message_show(_("Could not reset vt handling: %m\n")); - if ((et->has_vt) && (et->vt != et->start_vt)) - { - ioctl(et->fd, VT_ACTIVATE, et->start_vt); - ioctl(et->fd, VT_WAITACTIVE, et->start_vt); - } - close(et->fd); - free(et); -} - -/* local functions */ -static int -_e_tty_open_vt(E_Tty *et) -{ - int tty0, fd; - char fname[16]; - struct vt_stat vts; - - DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - if ((tty0 = open("/dev/tty0", O_WRONLY | O_CLOEXEC)) < 0) - { - e_error_message_show(_("Failed to open tty0: %m\n")); - return -1; - } - - if ((ioctl(tty0, VT_OPENQRY, &et->vt) < 0) || (et->vt == -1)) - { - e_error_message_show(_("Failed to open tty0: %m\n")); - close(tty0); - return -1; - } - close(tty0); - - snprintf(fname, sizeof(fname), "/dev/tty%d", et->vt); - printf("Compositor: Using new vt %s\n", fname); - fd = open(fname, O_RDWR | O_NOCTTY | O_CLOEXEC); - if (fd < 0) return fd; - - if (ioctl(fd, VT_GETSTATE, &vts) == 0) - et->start_vt = vts.v_active; - else - et->start_vt = et->vt; - - if ((ioctl(fd, VT_ACTIVATE, et->vt) < 0) || - (ioctl(fd, VT_WAITACTIVE, et->vt) < 0)) - { - e_error_message_show(_("Failed to switch to new vt: %m\n")); - close(fd); - return -1; - } - - return fd; -} - -static int -_e_tty_cb_input(int fd __UNUSED__, uint32_t mask __UNUSED__, void *data) -{ - E_Tty *et; - -// DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - et = data; - tcflush(et->fd, TCIFLUSH); - return 1; -} - -static int -_e_tty_cb_handle(int sig __UNUSED__, void *data) -{ - E_Tty *et; - -// DLOGFN(__FILE__, __LINE__, __FUNCTION__); - - et = data; - if (et->has_vt) - { - et->vt_func(et->comp, 1); - et->has_vt = EINA_FALSE; - ioctl(et->fd, VT_RELDISP, 1); - } - else - { - ioctl(et->fd, VT_RELDISP, VT_ACKACQ); - et->vt_func(et->comp, 0); - et->has_vt = EINA_TRUE; - } - - return 1; -} diff --git a/src/modules/wl_drm/module.desktop b/src/modules/wl_drm/module.desktop deleted file mode 100644 index 7461be660..000000000 --- a/src/modules/wl_drm/module.desktop +++ /dev/null @@ -1,16 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Type=Link -Name=Wayland Drm -Name[eo]=Mastrumado de ciferecaj rajtoj de Wayland -Name[fr]=Gestion des droits numériques Wayland -Comment=Enlightenment DRM Composite Manager -Comment[ca]=Administrador de composició DRM de l'Enlightenment -Comment[eo]=Administrilo de kunmetaĵo Enlightenment DRM -Comment[es]=Administrador de composición DRM de Enlightenment -Comment[fr]=Gestionnaire Composite avec DRM de Enlightenment -Comment[gl]=Xestor de composición DRM de Enlightenment -Comment[it]=Composite manager DRM di Enlightenment -Comment[pt]=Gestor de composição Enlightenment DRM -Icon=e-module-wl_drm -X-Enlightenment-ModuleType=look