Merge "minui: Clean up graphics_drm.cpp." am: 648f252c71

am: f6b6b75916

Change-Id: I897a2b2a5046554a92ee8be59bc6e90ebbe2b8f5
This commit is contained in:
Tao Bao 2017-02-09 19:51:15 +00:00 committed by android-build-merger
commit ed5ee5292c

View file

@ -14,16 +14,14 @@
* limitations under the License. * limitations under the License.
*/ */
#include <drm_fourcc.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/cdefs.h>
#include <sys/ioctl.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <drm_fourcc.h>
#include <xf86drm.h> #include <xf86drm.h>
#include <xf86drmMode.h> #include <xf86drmMode.h>
@ -33,9 +31,9 @@
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*(A))) #define ARRAY_SIZE(A) (sizeof(A)/sizeof(*(A)))
struct drm_surface { struct drm_surface {
GRSurface base; GRSurface base;
uint32_t fb_id; uint32_t fb_id;
uint32_t handle; uint32_t handle;
}; };
static drm_surface *drm_surfaces[2]; static drm_surface *drm_surfaces[2];
@ -47,429 +45,377 @@ static drmModeConnector *main_monitor_connector;
static int drm_fd = -1; static int drm_fd = -1;
static void drm_disable_crtc(int drm_fd, drmModeCrtc *crtc) { static void drm_disable_crtc(int drm_fd, drmModeCrtc *crtc) {
if (crtc) { if (crtc) {
drmModeSetCrtc(drm_fd, crtc->crtc_id, drmModeSetCrtc(drm_fd, crtc->crtc_id,
0, // fb_id 0, // fb_id
0, 0, // x,y 0, 0, // x,y
NULL, // connectors nullptr, // connectors
0, // connector_count 0, // connector_count
NULL); // mode nullptr); // mode
} }
} }
static void drm_enable_crtc(int drm_fd, drmModeCrtc *crtc, static void drm_enable_crtc(int drm_fd, drmModeCrtc* crtc, struct drm_surface* surface) {
struct drm_surface *surface) { int32_t ret = drmModeSetCrtc(drm_fd, crtc->crtc_id, surface->fb_id, 0, 0, // x,y
int32_t ret; &main_monitor_connector->connector_id,
1, // connector_count
&main_monitor_crtc->mode);
ret = drmModeSetCrtc(drm_fd, crtc->crtc_id, if (ret) {
surface->fb_id, printf("drmModeSetCrtc failed ret=%d\n", ret);
0, 0, // x,y }
&main_monitor_connector->connector_id,
1, // connector_count
&main_monitor_crtc->mode);
if (ret)
printf("drmModeSetCrtc failed ret=%d\n", ret);
} }
static void drm_blank(minui_backend* backend __unused, bool blank) { static void drm_blank(minui_backend* backend __unused, bool blank) {
if (blank) if (blank) {
drm_disable_crtc(drm_fd, main_monitor_crtc); drm_disable_crtc(drm_fd, main_monitor_crtc);
else } else {
drm_enable_crtc(drm_fd, main_monitor_crtc, drm_enable_crtc(drm_fd, main_monitor_crtc, drm_surfaces[current_buffer]);
drm_surfaces[current_buffer]); }
} }
static void drm_destroy_surface(struct drm_surface *surface) { static void drm_destroy_surface(struct drm_surface *surface) {
struct drm_gem_close gem_close; if (!surface) return;
int ret;
if(!surface) if (surface->base.data) {
return; munmap(surface->base.data, surface->base.row_bytes * surface->base.height);
}
if (surface->base.data) if (surface->fb_id) {
munmap(surface->base.data, int ret = drmModeRmFB(drm_fd, surface->fb_id);
surface->base.row_bytes * surface->base.height); if (ret) {
printf("drmModeRmFB failed ret=%d\n", ret);
if (surface->fb_id) {
ret = drmModeRmFB(drm_fd, surface->fb_id);
if (ret)
printf("drmModeRmFB failed ret=%d\n", ret);
} }
}
if (surface->handle) { if (surface->handle) {
memset(&gem_close, 0, sizeof(gem_close)); drm_gem_close gem_close = {};
gem_close.handle = surface->handle; gem_close.handle = surface->handle;
ret = drmIoctl(drm_fd, DRM_IOCTL_GEM_CLOSE, &gem_close); int ret = drmIoctl(drm_fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
if (ret) if (ret) {
printf("DRM_IOCTL_GEM_CLOSE failed ret=%d\n", ret); printf("DRM_IOCTL_GEM_CLOSE failed ret=%d\n", ret);
} }
}
free(surface); free(surface);
} }
static int drm_format_to_bpp(uint32_t format) { static int drm_format_to_bpp(uint32_t format) {
switch(format) { switch (format) {
case DRM_FORMAT_ABGR8888: case DRM_FORMAT_ABGR8888:
case DRM_FORMAT_BGRA8888: case DRM_FORMAT_BGRA8888:
case DRM_FORMAT_RGBX8888: case DRM_FORMAT_RGBX8888:
case DRM_FORMAT_BGRX8888: case DRM_FORMAT_BGRX8888:
case DRM_FORMAT_XBGR8888: case DRM_FORMAT_XBGR8888:
case DRM_FORMAT_XRGB8888: case DRM_FORMAT_XRGB8888:
return 32; return 32;
case DRM_FORMAT_RGB565: case DRM_FORMAT_RGB565:
return 16; return 16;
default: default:
printf("Unknown format %d\n", format); printf("Unknown format %d\n", format);
return 32; return 32;
} }
} }
static drm_surface *drm_create_surface(int width, int height) { static drm_surface *drm_create_surface(int width, int height) {
struct drm_surface *surface; drm_surface* surface = static_cast<drm_surface*>(calloc(1, sizeof(*surface)));
struct drm_mode_create_dumb create_dumb; if (!surface) {
uint32_t format; printf("Can't allocate memory\n");
int ret; return nullptr;
}
surface = (struct drm_surface*)calloc(1, sizeof(*surface));
if (!surface) {
printf("Can't allocate memory\n");
return NULL;
}
uint32_t format;
#if defined(RECOVERY_ABGR) #if defined(RECOVERY_ABGR)
format = DRM_FORMAT_RGBA8888; format = DRM_FORMAT_RGBA8888;
#elif defined(RECOVERY_BGRA) #elif defined(RECOVERY_BGRA)
format = DRM_FORMAT_ARGB8888; format = DRM_FORMAT_ARGB8888;
#elif defined(RECOVERY_RGBX) #elif defined(RECOVERY_RGBX)
format = DRM_FORMAT_XBGR8888; format = DRM_FORMAT_XBGR8888;
#else #else
format = DRM_FORMAT_RGB565; format = DRM_FORMAT_RGB565;
#endif #endif
memset(&create_dumb, 0, sizeof(create_dumb)); drm_mode_create_dumb create_dumb = {};
create_dumb.height = height; create_dumb.height = height;
create_dumb.width = width; create_dumb.width = width;
create_dumb.bpp = drm_format_to_bpp(format); create_dumb.bpp = drm_format_to_bpp(format);
create_dumb.flags = 0; create_dumb.flags = 0;
ret = drmIoctl(drm_fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_dumb); int ret = drmIoctl(drm_fd, DRM_IOCTL_MODE_CREATE_DUMB, &create_dumb);
if (ret) { if (ret) {
printf("DRM_IOCTL_MODE_CREATE_DUMB failed ret=%d\n",ret); printf("DRM_IOCTL_MODE_CREATE_DUMB failed ret=%d\n", ret);
drm_destroy_surface(surface); drm_destroy_surface(surface);
return NULL; return nullptr;
} }
surface->handle = create_dumb.handle; surface->handle = create_dumb.handle;
uint32_t handles[4], pitches[4], offsets[4]; uint32_t handles[4], pitches[4], offsets[4];
handles[0] = surface->handle; handles[0] = surface->handle;
pitches[0] = create_dumb.pitch; pitches[0] = create_dumb.pitch;
offsets[0] = 0; offsets[0] = 0;
ret = drmModeAddFB2(drm_fd, width, height, ret =
format, handles, pitches, offsets, drmModeAddFB2(drm_fd, width, height, format, handles, pitches, offsets, &(surface->fb_id), 0);
&(surface->fb_id), 0); if (ret) {
if (ret) { printf("drmModeAddFB2 failed ret=%d\n", ret);
printf("drmModeAddFB2 failed ret=%d\n", ret); drm_destroy_surface(surface);
drm_destroy_surface(surface); return nullptr;
return NULL; }
}
struct drm_mode_map_dumb map_dumb; drm_mode_map_dumb map_dumb = {};
memset(&map_dumb, 0, sizeof(map_dumb)); map_dumb.handle = create_dumb.handle;
map_dumb.handle = create_dumb.handle; ret = drmIoctl(drm_fd, DRM_IOCTL_MODE_MAP_DUMB, &map_dumb);
ret = drmIoctl(drm_fd, DRM_IOCTL_MODE_MAP_DUMB, &map_dumb); if (ret) {
if (ret) { printf("DRM_IOCTL_MODE_MAP_DUMB failed ret=%d\n", ret);
printf("DRM_IOCTL_MODE_MAP_DUMB failed ret=%d\n",ret); drm_destroy_surface(surface);
drm_destroy_surface(surface); return nullptr;
return NULL;; }
}
surface->base.height = height; surface->base.height = height;
surface->base.width = width; surface->base.width = width;
surface->base.row_bytes = create_dumb.pitch; surface->base.row_bytes = create_dumb.pitch;
surface->base.pixel_bytes = create_dumb.bpp / 8; surface->base.pixel_bytes = create_dumb.bpp / 8;
surface->base.data = (unsigned char*) surface->base.data =
mmap(NULL, static_cast<unsigned char*>(mmap(nullptr, surface->base.height * surface->base.row_bytes,
surface->base.height * surface->base.row_bytes, PROT_READ | PROT_WRITE, MAP_SHARED, drm_fd, map_dumb.offset));
PROT_READ | PROT_WRITE, MAP_SHARED, if (surface->base.data == MAP_FAILED) {
drm_fd, map_dumb.offset); perror("mmap() failed");
if (surface->base.data == MAP_FAILED) { drm_destroy_surface(surface);
perror("mmap() failed"); return nullptr;
drm_destroy_surface(surface); }
return NULL;
}
return surface; return surface;
} }
static drmModeCrtc *find_crtc_for_connector(int fd, static drmModeCrtc* find_crtc_for_connector(int fd, drmModeRes* resources,
drmModeRes *resources, drmModeConnector* connector) {
drmModeConnector *connector) { // Find the encoder. If we already have one, just use it.
int i, j; drmModeEncoder* encoder;
drmModeEncoder *encoder; if (connector->encoder_id) {
int32_t crtc; encoder = drmModeGetEncoder(fd, connector->encoder_id);
} else {
encoder = nullptr;
}
/* int32_t crtc;
* Find the encoder. If we already have one, just use it. if (encoder && encoder->crtc_id) {
*/ crtc = encoder->crtc_id;
if (connector->encoder_id) drmModeFreeEncoder(encoder);
encoder = drmModeGetEncoder(fd, connector->encoder_id); return drmModeGetCrtc(fd, crtc);
else }
encoder = NULL;
if (encoder && encoder->crtc_id) { // Didn't find anything, try to find a crtc and encoder combo.
crtc = encoder->crtc_id; crtc = -1;
for (int i = 0; i < connector->count_encoders; i++) {
encoder = drmModeGetEncoder(fd, connector->encoders[i]);
if (encoder) {
for (int j = 0; j < resources->count_crtcs; j++) {
if (!(encoder->possible_crtcs & (1 << j))) continue;
crtc = resources->crtcs[j];
break;
}
if (crtc >= 0) {
drmModeFreeEncoder(encoder); drmModeFreeEncoder(encoder);
return drmModeGetCrtc(fd, crtc); return drmModeGetCrtc(fd, crtc);
}
} }
}
/* return nullptr;
* Didn't find anything, try to find a crtc and encoder combo.
*/
crtc = -1;
for (i = 0; i < connector->count_encoders; i++) {
encoder = drmModeGetEncoder(fd, connector->encoders[i]);
if (encoder) {
for (j = 0; j < resources->count_crtcs; j++) {
if (!(encoder->possible_crtcs & (1 << j)))
continue;
crtc = resources->crtcs[j];
break;
}
if (crtc >= 0) {
drmModeFreeEncoder(encoder);
return drmModeGetCrtc(fd, crtc);
}
}
}
return NULL;
} }
static drmModeConnector *find_used_connector_by_type(int fd, static drmModeConnector* find_used_connector_by_type(int fd, drmModeRes* resources, unsigned type) {
drmModeRes *resources, for (int i = 0; i < resources->count_connectors; i++) {
unsigned type) { drmModeConnector* connector = drmModeGetConnector(fd, resources->connectors[i]);
int i; if (connector) {
for (i = 0; i < resources->count_connectors; i++) { if ((connector->connector_type == type) && (connector->connection == DRM_MODE_CONNECTED) &&
drmModeConnector *connector; (connector->count_modes > 0)) {
return connector;
connector = drmModeGetConnector(fd, resources->connectors[i]); }
if (connector) { drmModeFreeConnector(connector);
if ((connector->connector_type == type) &&
(connector->connection == DRM_MODE_CONNECTED) &&
(connector->count_modes > 0))
return connector;
drmModeFreeConnector(connector);
}
} }
return NULL; }
return nullptr;
} }
static drmModeConnector *find_first_connected_connector(int fd, static drmModeConnector* find_first_connected_connector(int fd, drmModeRes* resources) {
drmModeRes *resources) { for (int i = 0; i < resources->count_connectors; i++) {
int i; drmModeConnector* connector;
for (i = 0; i < resources->count_connectors; i++) {
drmModeConnector *connector;
connector = drmModeGetConnector(fd, resources->connectors[i]); connector = drmModeGetConnector(fd, resources->connectors[i]);
if (connector) { if (connector) {
if ((connector->count_modes > 0) && if ((connector->count_modes > 0) && (connector->connection == DRM_MODE_CONNECTED))
(connector->connection == DRM_MODE_CONNECTED)) return connector;
return connector;
drmModeFreeConnector(connector); drmModeFreeConnector(connector);
}
} }
return NULL; }
return nullptr;
} }
static drmModeConnector *find_main_monitor(int fd, drmModeRes *resources, static drmModeConnector* find_main_monitor(int fd, drmModeRes* resources, uint32_t* mode_index) {
uint32_t *mode_index) { /* Look for LVDS/eDP/DSI connectors. Those are the main screens. */
unsigned i = 0; static constexpr unsigned kConnectorPriority[] = {
int modes; DRM_MODE_CONNECTOR_LVDS,
/* Look for LVDS/eDP/DSI connectors. Those are the main screens. */ DRM_MODE_CONNECTOR_eDP,
unsigned kConnectorPriority[] = { DRM_MODE_CONNECTOR_DSI,
DRM_MODE_CONNECTOR_LVDS, };
DRM_MODE_CONNECTOR_eDP,
DRM_MODE_CONNECTOR_DSI,
};
drmModeConnector *main_monitor_connector = NULL; drmModeConnector* main_monitor_connector = nullptr;
do { unsigned i = 0;
main_monitor_connector = find_used_connector_by_type(fd, do {
resources, main_monitor_connector = find_used_connector_by_type(fd, resources, kConnectorPriority[i]);
kConnectorPriority[i]); i++;
i++; } while (!main_monitor_connector && i < ARRAY_SIZE(kConnectorPriority));
} while (!main_monitor_connector && i < ARRAY_SIZE(kConnectorPriority));
/* If we didn't find a connector, grab the first one that is connected. */ /* If we didn't find a connector, grab the first one that is connected. */
if (!main_monitor_connector) if (!main_monitor_connector) {
main_monitor_connector = main_monitor_connector = find_first_connected_connector(fd, resources);
find_first_connected_connector(fd, resources); }
/* If we still didn't find a connector, give up and return. */ /* If we still didn't find a connector, give up and return. */
if (!main_monitor_connector) if (!main_monitor_connector) return nullptr;
return NULL;
*mode_index = 0; *mode_index = 0;
for (modes = 0; modes < main_monitor_connector->count_modes; modes++) { for (int modes = 0; modes < main_monitor_connector->count_modes; modes++) {
if (main_monitor_connector->modes[modes].type & if (main_monitor_connector->modes[modes].type & DRM_MODE_TYPE_PREFERRED) {
DRM_MODE_TYPE_PREFERRED) { *mode_index = modes;
*mode_index = modes; break;
break;
}
} }
}
return main_monitor_connector; return main_monitor_connector;
} }
static void disable_non_main_crtcs(int fd, static void disable_non_main_crtcs(int fd, drmModeRes* resources, drmModeCrtc* main_crtc) {
drmModeRes *resources, for (int i = 0; i < resources->count_connectors; i++) {
drmModeCrtc* main_crtc) { drmModeConnector* connector = drmModeGetConnector(fd, resources->connectors[i]);
int i; drmModeCrtc* crtc = find_crtc_for_connector(fd, resources, connector);
drmModeCrtc* crtc; if (crtc->crtc_id != main_crtc->crtc_id) {
drm_disable_crtc(fd, crtc);
for (i = 0; i < resources->count_connectors; i++) {
drmModeConnector *connector;
connector = drmModeGetConnector(fd, resources->connectors[i]);
crtc = find_crtc_for_connector(fd, resources, connector);
if (crtc->crtc_id != main_crtc->crtc_id)
drm_disable_crtc(fd, crtc);
drmModeFreeCrtc(crtc);
} }
drmModeFreeCrtc(crtc);
}
} }
static GRSurface* drm_init(minui_backend* backend __unused) { static GRSurface* drm_init(minui_backend* backend __unused) {
drmModeRes *res = NULL; drmModeRes* res = nullptr;
uint32_t selected_mode;
char *dev_name;
int width, height;
int ret, i;
/* Consider DRM devices in order. */ /* Consider DRM devices in order. */
for (i = 0; i < DRM_MAX_MINOR; i++) { for (int i = 0; i < DRM_MAX_MINOR; i++) {
uint64_t cap = 0; char* dev_name;
int ret = asprintf(&dev_name, DRM_DEV_NAME, DRM_DIR_NAME, i);
if (ret < 0) continue;
ret = asprintf(&dev_name, DRM_DEV_NAME, DRM_DIR_NAME, i); drm_fd = open(dev_name, O_RDWR, 0);
if (ret < 0) free(dev_name);
continue; if (drm_fd < 0) continue;
drm_fd = open(dev_name, O_RDWR, 0); uint64_t cap = 0;
free(dev_name); /* We need dumb buffers. */
if (drm_fd < 0) ret = drmGetCap(drm_fd, DRM_CAP_DUMB_BUFFER, &cap);
continue; if (ret || cap == 0) {
close(drm_fd);
/* We need dumb buffers. */ continue;
ret = drmGetCap(drm_fd, DRM_CAP_DUMB_BUFFER, &cap);
if (ret || cap == 0) {
close(drm_fd);
continue;
}
res = drmModeGetResources(drm_fd);
if (!res) {
close(drm_fd);
continue;
}
/* Use this device if it has at least one connected monitor. */
if (res->count_crtcs > 0 && res->count_connectors > 0)
if (find_first_connected_connector(drm_fd, res))
break;
drmModeFreeResources(res);
close(drm_fd);
res = NULL;
} }
if (drm_fd < 0 || res == NULL) { res = drmModeGetResources(drm_fd);
perror("cannot find/open a drm device"); if (!res) {
return NULL; close(drm_fd);
continue;
} }
main_monitor_connector = find_main_monitor(drm_fd, /* Use this device if it has at least one connected monitor. */
res, &selected_mode); if (res->count_crtcs > 0 && res->count_connectors > 0) {
if (find_first_connected_connector(drm_fd, res)) break;
if (!main_monitor_connector) {
printf("main_monitor_connector not found\n");
drmModeFreeResources(res);
close(drm_fd);
return NULL;
} }
main_monitor_crtc = find_crtc_for_connector(drm_fd, res,
main_monitor_connector);
if (!main_monitor_crtc) {
printf("main_monitor_crtc not found\n");
drmModeFreeResources(res);
close(drm_fd);
return NULL;
}
disable_non_main_crtcs(drm_fd,
res, main_monitor_crtc);
main_monitor_crtc->mode = main_monitor_connector->modes[selected_mode];
width = main_monitor_crtc->mode.hdisplay;
height = main_monitor_crtc->mode.vdisplay;
drmModeFreeResources(res); drmModeFreeResources(res);
close(drm_fd);
res = nullptr;
}
drm_surfaces[0] = drm_create_surface(width, height); if (drm_fd < 0 || res == nullptr) {
drm_surfaces[1] = drm_create_surface(width, height); perror("cannot find/open a drm device");
if (!drm_surfaces[0] || !drm_surfaces[1]) { return nullptr;
drm_destroy_surface(drm_surfaces[0]); }
drm_destroy_surface(drm_surfaces[1]);
drmModeFreeResources(res);
close(drm_fd);
return NULL;
}
current_buffer = 0; uint32_t selected_mode;
main_monitor_connector = find_main_monitor(drm_fd, res, &selected_mode);
drm_enable_crtc(drm_fd, main_monitor_crtc, drm_surfaces[1]); if (!main_monitor_connector) {
printf("main_monitor_connector not found\n");
drmModeFreeResources(res);
close(drm_fd);
return nullptr;
}
return &(drm_surfaces[0]->base); main_monitor_crtc = find_crtc_for_connector(drm_fd, res, main_monitor_connector);
if (!main_monitor_crtc) {
printf("main_monitor_crtc not found\n");
drmModeFreeResources(res);
close(drm_fd);
return nullptr;
}
disable_non_main_crtcs(drm_fd, res, main_monitor_crtc);
main_monitor_crtc->mode = main_monitor_connector->modes[selected_mode];
int width = main_monitor_crtc->mode.hdisplay;
int height = main_monitor_crtc->mode.vdisplay;
drmModeFreeResources(res);
drm_surfaces[0] = drm_create_surface(width, height);
drm_surfaces[1] = drm_create_surface(width, height);
if (!drm_surfaces[0] || !drm_surfaces[1]) {
drm_destroy_surface(drm_surfaces[0]);
drm_destroy_surface(drm_surfaces[1]);
drmModeFreeResources(res);
close(drm_fd);
return nullptr;
}
current_buffer = 0;
drm_enable_crtc(drm_fd, main_monitor_crtc, drm_surfaces[1]);
return &(drm_surfaces[0]->base);
} }
static GRSurface* drm_flip(minui_backend* backend __unused) { static GRSurface* drm_flip(minui_backend* backend __unused) {
int ret; int ret = drmModePageFlip(drm_fd, main_monitor_crtc->crtc_id, drm_surfaces[current_buffer]->fb_id,
0, nullptr);
ret = drmModePageFlip(drm_fd, main_monitor_crtc->crtc_id, if (ret < 0) {
drm_surfaces[current_buffer]->fb_id, 0, NULL); printf("drmModePageFlip failed ret=%d\n", ret);
if (ret < 0) { return nullptr;
printf("drmModePageFlip failed ret=%d\n", ret); }
return NULL; current_buffer = 1 - current_buffer;
} return &(drm_surfaces[current_buffer]->base);
current_buffer = 1 - current_buffer;
return &(drm_surfaces[current_buffer]->base);
} }
static void drm_exit(minui_backend* backend __unused) { static void drm_exit(minui_backend* backend __unused) {
drm_disable_crtc(drm_fd, main_monitor_crtc); drm_disable_crtc(drm_fd, main_monitor_crtc);
drm_destroy_surface(drm_surfaces[0]); drm_destroy_surface(drm_surfaces[0]);
drm_destroy_surface(drm_surfaces[1]); drm_destroy_surface(drm_surfaces[1]);
drmModeFreeCrtc(main_monitor_crtc); drmModeFreeCrtc(main_monitor_crtc);
drmModeFreeConnector(main_monitor_connector); drmModeFreeConnector(main_monitor_connector);
close(drm_fd); close(drm_fd);
drm_fd = -1; drm_fd = -1;
} }
static minui_backend drm_backend = { static minui_backend drm_backend = {
.init = drm_init, .init = drm_init,
.flip = drm_flip, .flip = drm_flip,
.blank = drm_blank, .blank = drm_blank,
.exit = drm_exit, .exit = drm_exit,
}; };
minui_backend* open_drm() { minui_backend* open_drm() {
return &drm_backend; return &drm_backend;
} }