diff options
author | Xuelian Bai <xuelian.bai@samsung.com> | 2019-11-01 01:06:11 +0800 |
---|---|---|
committer | Xuelian Bai <xuelian.bai@samsung.com> | 2024-01-18 09:29:10 +0800 |
commit | ae6e7a9c92348647e3294c7f8f3ae4908b0c88e9 (patch) | |
tree | 7440fb38b32846d56318a236c8f9afbb1e23556f | |
parent | 5a23444b1f6b19cf5fa9dea78fd29d53d233fa9f (diff) | |
download | mesa-ae6e7a9c92348647e3294c7f8f3ae4908b0c88e9.tar.gz mesa-ae6e7a9c92348647e3294c7f8f3ae4908b0c88e9.tar.bz2 mesa-ae6e7a9c92348647e3294c7f8f3ae4908b0c88e9.zip |
Fix display issue on RPI4
RPI4 has seperated devices for display and render, so when init
Tizen, we open /dev/dri/renderD128 and init v3d screen as renderonly.
Merged commit:
commit 50839c47736cbab7db6a9fb25ea0d983434c56cc
Author: Zhaowei Yuan <zhaowei.yuan@samsung.com>
- platform_tizen: free driver_name if initialization goes wrong
Mallocated driver_name needs to be freed if following steps for
initialization goes wrong, whether hw_accel if set or not
Change-Id: Iffac62ac9717f7a4da589fd51f008968615a6321
Signed-off-by: Xuelian Bai <xuelian.bai@samsung.com>
-rw-r--r-- | packaging/mesa.spec | 2 | ||||
-rwxr-xr-x | src/egl/drivers/dri2/platform_tizen.c | 106 |
2 files changed, 51 insertions, 57 deletions
diff --git a/packaging/mesa.spec b/packaging/mesa.spec index d5a98611bf1..023d2d117cf 100644 --- a/packaging/mesa.spec +++ b/packaging/mesa.spec @@ -72,7 +72,7 @@ meson --prefix %{_prefix} build/ \ -Ddri-drivers="" \ -Dvulkan-drivers="" %else - -Dgallium-drivers="vc4,swrast" + -Dgallium-drivers="vc4,v3d,kmsro,swrast" %endif ninja -C build/ diff --git a/src/egl/drivers/dri2/platform_tizen.c b/src/egl/drivers/dri2/platform_tizen.c index 93a6c260801..3059dc39314 100755 --- a/src/egl/drivers/dri2/platform_tizen.c +++ b/src/egl/drivers/dri2/platform_tizen.c @@ -853,10 +853,10 @@ tizen_create_image_from_prime_fd(_EGLDisplay *disp, _EGLContext *ctx, //TODO: v3d don't support this, need to check /*if (flags == TBM_BO_TILED) { - attr_list[atti++] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT; - attr_list[atti++] = DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED & 0xFFFFFFFF; - attr_list[atti++] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT; - attr_list[atti++] = DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED >> 32; + attr_list[atti++] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT; + attr_list[atti++] = DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED & 0xFFFFFFFF; + attr_list[atti++] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT; + attr_list[atti++] = DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED >> 32; }*/ attr_list[atti++] = EGL_NONE; attr_list[atti++] = 0; @@ -1360,6 +1360,7 @@ static const __DRIswrastLoaderExtension tizen_swrast_loader_extension = { static const __DRIextension *tizen_dri2_loader_extensions[] = { &tizen_dri2_loader_extension.base, + &tizen_image_loader_extension.base, &image_lookup_extension.base, &use_invalidate.base, NULL, @@ -1385,7 +1386,6 @@ dri2_initialize_tizen(_EGLDisplay *disp) tpl_display_t *tpl_display = NULL; const char *err; int tbm_bufmgr_fd = -1; - char *tbm_bufmgr_device_name = NULL; int hw_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL); loader_set_logger(_eglLog); @@ -1395,7 +1395,7 @@ dri2_initialize_tizen(_EGLDisplay *disp) return _eglError(EGL_BAD_ALLOC, "eglInitialize"); disp->DriverData = (void *) dri2_dpy; - + /* Allocate an new native display, if argument passed to eglGetDisplay() is EGL_DEFAULT_DISPLAY, it will cause error in __tpl_wayland_egl_display_init() */ @@ -1425,65 +1425,63 @@ dri2_initialize_tizen(_EGLDisplay *disp) } if (hw_accel) { - int fd = -1; - - if (drmGetNodeTypeFromFd(tbm_bufmgr_fd) == DRM_NODE_RENDER) { - - tbm_bufmgr_device_name = loader_get_device_name_for_fd(tbm_bufmgr_fd); - if (tbm_bufmgr_device_name == NULL) { - err = "DRI2: failed to get tbm_bufmgr device name"; - goto cleanup_device; - } - fd = loader_open_device(tbm_bufmgr_device_name); - - } else { - if (!tbm_drm_helper_get_auth_info(&fd, NULL, NULL)) { - - /* FIXME: tbm_drm_helper_get_auth_info() does not support the case of - * display server for now. this code is fallback routine for - * that Enlightenment Server fails on tbm_drm_helper_get_auth_info. - * When tbm_drm_helper_get_auth_info() supports display server - * case, then remove below routine. - */ -#if 1 - tbm_bufmgr_device_name = loader_get_device_name_for_fd(tbm_bufmgr_fd); - if (tbm_bufmgr_device_name == NULL) { - err = "DRI2: failed to get tbm_bufmgr device name"; - goto cleanup_device; - } - fd = loader_open_device(tbm_bufmgr_device_name); -#else - err = "DRI2: failed to get fd from tbm_drm_helper_get_auth_info()"; - goto cleanup_device; -#endif - } +#if 0//FOR REF: it's another way, to open v3d directly +#define MAX_DRM_DEVICES 32 + drmDevicePtr device, devices[MAX_DRM_DEVICES] = { NULL }; + int num_devices; + num_devices = drmGetDevices2(0, devices, ARRAY_SIZE(devices)); + for (int i = 0; i < num_devices; i++) { + device = devices[i]; + + if (!(device->available_nodes & (1 << DRM_NODE_RENDER))) + continue; + + dri2_dpy->fd = loader_open_device(device->nodes[DRM_NODE_RENDER]); + if (dri2_dpy->fd < 0) { + _eglLog(_EGL_WARNING, "%s() Failed to open DRM device %s", + __func__, device->nodes[DRM_NODE_RENDER]); + continue; + } + else + break; } - - if (fd == -1) { - err = "DRI2: failed to get fd"; - goto cleanup_device; + drmFreeDevices(devices, num_devices); +#endif + dri2_dpy->fd = loader_get_user_preferred_fd(tbm_bufmgr_fd, + &dri2_dpy->is_different_gpu); + //dri2_dpy->is_different_gpu = (dri2_dpy->fd == tbm_bufmgr_fd); + + if (dri2_dpy->is_different_gpu) { + free(dri2_dpy->device_name); + dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd); + if (!dri2_dpy->device_name) { + err = "DRI2: failed to get device name for requested GPU"; + goto cleanup_device; + } } - dri2_dpy->fd = fd; - dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd); if (dri2_dpy->driver_name == NULL) { err = "DRI2: failed to get driver name"; goto cleanup_device; } - if (!dri2_load_driver(disp)) { - err = "DRI2: failed to load driver"; - goto cleanup_driver_name; - } dri2_dpy->is_render_node = drmGetNodeTypeFromFd(dri2_dpy->fd) == DRM_NODE_RENDER; /* render nodes cannot use Gem names, and thus do not support * the __DRI_DRI2_LOADER extension */ - if (!dri2_dpy->is_render_node) + if (!dri2_dpy->is_render_node) { dri2_dpy->loader_extensions = tizen_dri2_loader_extensions; - else + if (!dri2_load_driver(disp)) { + err = "DRI2: failed to load driver"; + goto cleanup_driver_name; + } + } else { dri2_dpy->loader_extensions = tizen_image_loader_extensions; - + if (!dri2_load_driver_dri3(disp)) { + err = "DRI3: failed to load driver"; + goto cleanup_driver_name; + } + } } else { dri2_dpy->fd = tbm_bufmgr_fd; dri2_dpy->driver_name = strdup("swrast"); @@ -1511,7 +1509,6 @@ dri2_initialize_tizen(_EGLDisplay *disp) if(dri2_dpy->fd != tbm_bufmgr_fd) { close(dri2_dpy->fd); } - close(tbm_bufmgr_fd); tbm_bufmgr_fd = -1; dri2_dpy->fd = -1; @@ -1546,11 +1543,8 @@ cleanup_screen: cleanup_driver: dlclose(dri2_dpy->driver); cleanup_driver_name: - if (hw_accel) - free(dri2_dpy->driver_name); + free(dri2_dpy->driver_name); cleanup_device: - if (tbm_bufmgr_device_name) - free(tbm_bufmgr_device_name); tpl_object_unreference((tpl_object_t *)tpl_display); cleanup_display: if (dri2_dpy->own_device) { |