diff options
-rw-r--r-- | src/tdm_fbdev.c | 38 | ||||
-rw-r--r-- | src/tdm_fbdev.h | 1 | ||||
-rw-r--r-- | src/tdm_fbdev_display.c | 129 |
3 files changed, 64 insertions, 104 deletions
diff --git a/src/tdm_fbdev.c b/src/tdm_fbdev.c index 4aa4a98..3bae591 100644 --- a/src/tdm_fbdev.c +++ b/src/tdm_fbdev.c @@ -3,7 +3,6 @@ #endif #include "tdm_fbdev.h" - #include <tdm_helper.h> #define TDM_FBDEV_NAME "fbdev" @@ -15,8 +14,13 @@ static tdm_func_display fbdev_func_display = NULL, //display_get_capture_capability fbdev_display_get_outputs, fbdev_display_get_fd, + fbdev_display_get_buffer_fd, fbdev_display_handle_events, NULL, //display_create_pp, +}; + +static tdm_func_output fbdev_func_output = +{ fbdev_output_get_capability, fbdev_output_get_layers, fbdev_output_set_property, @@ -30,6 +34,10 @@ static tdm_func_display fbdev_func_display = fbdev_output_set_mode, fbdev_output_get_mode, NULL, //output_create_capture +}; + +static tdm_func_layer fbdev_func_layer = +{ fbdev_layer_get_capability, fbdev_layer_set_property, fbdev_layer_get_property, @@ -137,16 +145,13 @@ _tdm_fbdev_init_internal(void) { TDM_INFO("page flip not supported, errno=%d", errno); vinfo->yres_virtual = vinfo->yres; + } - /* - * TODO: Does FBIOPAN_DISPLAY ioctl must be invoked for the second time? - */ - ret = ioctl(fbdev_data->fbdev_fd, FBIOPAN_DISPLAY, vinfo); - if(ret < 0) - { - TDM_ERR("FBIOPAN_DISPLAY ioctl failed, errno=%d", errno); - goto close_1; - } + ret = ioctl(fbdev_data->fbdev_fd, FBIOPAN_DISPLAY, vinfo); + if(ret < 0) + { + TDM_ERR("FBIOPAN_DISPLAY ioctl failed, errno=%d", errno); + goto close_1; } ret = ioctl(fbdev_data->fbdev_fd, FBIOGET_FSCREENINFO, finfo); @@ -264,17 +269,22 @@ tdm_fbdev_init(tdm_display *dpy, tdm_error *error) return NULL; } + LIST_INITHEAD(&fbdev_data->buffer_list); + ret = tdm_backend_register_func_display(dpy, &fbdev_func_display); if (ret != TDM_ERROR_NONE) goto failed; - LIST_INITHEAD(&fbdev_data->buffer_list); + ret = tdm_backend_register_func_output(dpy, &fbdev_func_output); + if (ret != TDM_ERROR_NONE) + goto failed; + + ret = tdm_backend_register_func_layer(dpy, &fbdev_func_layer); + if (ret != TDM_ERROR_NONE) + goto failed; fbdev_data->dpy = dpy; - /* - * TODO: does somebody open framebuffer device beside us? - */ fbdev_data->fbdev_fd = _tdm_fbdev_open_fbdev(); if(fbdev_data->fbdev_fd < 0) { diff --git a/src/tdm_fbdev.h b/src/tdm_fbdev.h index a2c7d13..6da001b 100644 --- a/src/tdm_fbdev.h +++ b/src/tdm_fbdev.h @@ -28,6 +28,7 @@ tdm_error fbdev_display_get_capabilitiy(tdm_backend_data *bdata, tdm_caps_display *caps); tdm_output** fbdev_display_get_outputs(tdm_backend_data *bdata, int *count, tdm_error *error); tdm_error fbdev_display_get_fd(tdm_backend_data *bdata, int *fd); +tdm_error fbdev_display_get_buffer_fd(tdm_backend_data *bdata, int *fd); tdm_error fbdev_display_handle_events(tdm_backend_data *bdata); tdm_pp* fbdev_display_create_pp(tdm_backend_data *bdata, tdm_error *error); tdm_error fbdev_output_get_capability(tdm_output *output, tdm_caps_output *caps); diff --git a/src/tdm_fbdev_display.c b/src/tdm_fbdev_display.c index 5fdf085..b2a6867 100644 --- a/src/tdm_fbdev_display.c +++ b/src/tdm_fbdev_display.c @@ -14,12 +14,9 @@ */ static tbm_format supported_formats[] = { -/* - TBM_FORMAT_XRGB8888, - TBM_FORMAT_XBGR8888, - TBM_FORMAT_RGBX8888, - TBM_FORMAT_BGRX8888, -*/ + /* + * TODO: add support of 16 bit formats + */ TBM_FORMAT_ARGB8888, TBM_FORMAT_ABGR8888, TBM_FORMAT_RGBA8888, @@ -149,10 +146,6 @@ tdm_fbdev_creat_output(tdm_fbdev_data *fbdev_data) */ output->connector_type_id = 1; - /* - * TODO: Check does Framebuffer support multiple modes and - * switching between them? - */ output->count_modes = 1; output->output_modes = calloc(output->count_modes, sizeof(tdm_output_mode)); if (!output->output_modes) @@ -163,9 +156,9 @@ tdm_fbdev_creat_output(tdm_fbdev_data *fbdev_data) for(i = 0; i < output->count_modes ; i++) { - output->output_modes[i].width = fbdev_data->vinfo->xres; - output->output_modes[i].height = fbdev_data->vinfo->yres; - output->output_modes[i].refresh = 60; + output->output_modes[i].hdisplay = fbdev_data->vinfo->xres; + output->output_modes[i].vdisplay = fbdev_data->vinfo->yres; + output->output_modes[i].vrefresh = 60; output->output_modes[i].flags = -1; output->output_modes[i].type = -1; @@ -305,103 +298,51 @@ failed_get: return NULL; } -static struct udev_device* -_tdm_find_primary_gpu(void) +tdm_error +fbdev_display_get_fd(tdm_backend_data *bdata, int *fd) { - struct udev *udev; - struct udev_enumerate *e; - struct udev_list_entry *entry; - const char *path, *id; - struct udev_device *device, *drm_device, *pci; + tdm_fbdev_data *fbdev_data = (tdm_fbdev_data *)bdata; + int file_fd; - udev = udev_new(); - if (!udev) - { - TDM_ERR("fail to initialize udev context\n"); - return NULL; - } + RETURN_VAL_IF_FAIL(fbdev_data, TDM_ERROR_INVALID_PARAMETER); + RETURN_VAL_IF_FAIL(fd, TDM_ERROR_INVALID_PARAMETER); - e = udev_enumerate_new(udev); - udev_enumerate_add_match_subsystem(e, "drm"); - udev_enumerate_add_match_sysname(e, "card[0-9]*"); - - udev_enumerate_scan_devices(e); - drm_device = NULL; - udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) { - path = udev_list_entry_get_name(entry); - device = udev_device_new_from_syspath(udev, path); - if (!device) - continue; - - pci = udev_device_get_parent_with_subsystem_devtype(device, - "pci", NULL); - if (pci) { - id = udev_device_get_sysattr_value(pci, "boot_vga"); - if (id && !strcmp(id, "1")) { - if (drm_device) - udev_device_unref(drm_device); - drm_device = device; - break; - } - } + /* + * Event-based applications use poll/select for pageflip or vsync events, + * since farmebuffer does not produce such events we create common file. + * Without this file application will be locked on poll/select or return + * an error after timer expiring. + */ + file_fd = open("/tmp/tdm_fbdev_select", O_RDWR | O_CREAT | O_TRUNC, ACCESSPERMS); + TDM_INFO("Open fake file: /tmp/tdm_fbdev_select %d", file_fd); - if (!drm_device) - drm_device = device; - else - udev_device_unref(device); - } + *fd = file_fd; - udev_enumerate_unref(e); - return drm_device; + return TDM_ERROR_NONE; } tdm_error -fbdev_display_get_fd(tdm_backend_data *bdata, int *fd) +fbdev_display_get_buffer_fd(tdm_backend_data *bdata, int *fd) { tdm_fbdev_data *fbdev_data = (tdm_fbdev_data *)bdata; + int bufmgr_fd; RETURN_VAL_IF_FAIL(fbdev_data, TDM_ERROR_INVALID_PARAMETER); RETURN_VAL_IF_FAIL(fd, TDM_ERROR_INVALID_PARAMETER); - int drm_fd = -1; - /* - * TODO: Temp code. Open drm device for novice test utility, It needs - * it to open and using tbm buffer manger + * We assume that shared memory backend will be used, howewer tbm buffer + * manager uses dup() system call on received filed descriptor, that is + * why we must provide tbm buffer manager with valid file descriptor */ - drm_fd = drmOpen("/dev/card0", NULL); - if (drm_fd < 0) - { - TDM_ERR("Cannot open '%s' drm", "/dev/card0"); - } - if (drm_fd < 0) - { - struct udev_device *drm_device = NULL; - const char *filename; - TDM_WRN("Cannot open drm device.. search by udev"); - drm_device = _tdm_find_primary_gpu(); - if (drm_device == NULL) - { - TDM_ERR("fail to find drm device\n"); - goto close_l; - } - filename = udev_device_get_devnode(drm_device); + bufmgr_fd = open("/tmp/tdm_fbdev_bufmng", O_RDWR | O_CREAT | O_TRUNC, ACCESSPERMS); + TDM_INFO("Open fake file: /tdm_fbdev_bufmgr %d", bufmgr_fd); - drm_fd = open(filename, O_RDWR | O_CLOEXEC); - if (drm_fd < 0) - TDM_ERR("Cannot open drm device(%s)\n", filename); + *fd = bufmgr_fd; - TDM_DBG("open drm device (name:%s, fd:%d)", filename, fd); - - udev_device_unref(drm_device); - } - - *fd = drm_fd; - -close_l: return TDM_ERROR_NONE; } @@ -470,6 +411,10 @@ fbdev_output_get_capability(tdm_output *output, tdm_caps_output *caps) fbdev_data = fbdev_output->fbdev_data; + snprintf(caps->maker, TDM_NAME_LEN, "unknown"); + snprintf(caps->model, TDM_NAME_LEN, "unknown"); + snprintf(caps->name, TDM_NAME_LEN, "unknown"); + caps->status = fbdev_output->status; caps->type = fbdev_output->connector_type; caps->type_id = fbdev_output->connector_type_id; @@ -486,7 +431,7 @@ fbdev_output_get_capability(tdm_output *output, tdm_caps_output *caps) for (i = 0; i < caps->mode_count; i++) caps->modes[i] = fbdev_output->output_modes[i]; - caps->mmWidth = fbdev_data->vinfo->width;; + caps->mmWidth = fbdev_data->vinfo->width; caps->mmHeight = fbdev_data->vinfo->height; caps->subpixel = -1; @@ -715,6 +660,10 @@ fbdev_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value) return TDM_ERROR_OPERATION_FAILED; } + /* + * TODO: framebuffer have to be reinitialized again, Maybe + */ + fbdev_output->dpms_value = dpms_value; fbmode = 0; |