From f4af247b158b49db61c00859d61ef8e0a5e2b6b3 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Fri, 5 Jul 2019 12:41:54 +0800 Subject: [PATCH] DRM -> DRI --- RELEASE-NOTES.md | 26 +++++++------- configure.ac | 28 +++++++-------- etc/MiniGUI.cfg | 4 +-- include/exstubs.h | 34 +++++++++---------- src/newgal/Makefile.am | 10 +++--- src/newgal/dri/Makefile.am | 18 ++++++++++ src/newgal/{drm/drmvideo.c => dri/drivideo.c} | 28 +++++++-------- src/newgal/{drm/drmvideo.h => dri/drivideo.h} | 12 +++---- src/newgal/{drm => dri}/makefile.ng | 0 src/newgal/drm/Makefile.am | 18 ---------- 10 files changed, 89 insertions(+), 89 deletions(-) create mode 100644 src/newgal/dri/Makefile.am rename src/newgal/{drm/drmvideo.c => dri/drivideo.c} (97%) rename src/newgal/{drm/drmvideo.h => dri/drivideo.h} (93%) rename src/newgal/{drm => dri}/makefile.ng (100%) delete mode 100644 src/newgal/drm/Makefile.am diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index dd7fc8d2..c5ba2f41 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -41,8 +41,8 @@ rendering in order that MiniGUI can handle complex writing systems Another important features of this version are the new following engines: -* The NEWGAL engine of `drm` to support modern DRM-driven graphics cards. By using - `drm` engine, one MiniGUI app can now use the hardware-accelerated graphics +* The NEWGAL engine of `dri` to support modern DRM-driven graphics cards. By using + `dri` engine, one MiniGUI app can now use the hardware-accelerated graphics rendering for 2D/3D graphics. * The IAL engine of `libinput` to support all modern input devices including mouse, keyboard, joystick, switch, multi-touch panel, gesture, tablet tool, @@ -265,11 +265,11 @@ the glyph orientation: #### Support for Linux DRI In order to support modern graphics cards or GPU, we introduced a -new NEWGAL engine of `drm`. The developer can use this engine to +new NEWGAL engine of `dri`. The developer can use this engine to run MiniGUI apps on a Linux box on which the DRI (Direct Rendering Infrastructure) is enabled. -The `drm` engine uses `libdrm` developed by Free Desktop project: +The `dri` engine uses `libdrm` developed by Free Desktop project: https://dri.freedesktop.org/wiki/ @@ -278,13 +278,13 @@ MiniGUI mainly uses this library to support the dumb frame buffer (no hardware acceleration). To avoid modifying the MiniGUI source code when supporting new GPUs, -the `drm` engine has adopted a scalable design. +the `dri` engine has adopted a scalable design. -* You can directly use the `drm` engine to run MiniGUI on a GPU +* You can directly use the `dri` engine to run MiniGUI on a GPU which supports dumb frame buffer. * When you want to take advantage of the hardware acceleration of your GPU, you can write some code for your GPU as a sub driver -of `drm` engine outside MiniGUI. +of `dri` engine outside MiniGUI. In this situation, you need to configure MiniGUI with the following option: @@ -297,24 +297,24 @@ The header file `` defines the operators (a set of callback functions) you need to implement for your GPU externally. As an example, we implement the sub driver for `i915` graphics chard -in `mg-tests/drm-extra-input/`. Please refer to `mg-tests` repository. +in `mg-tests/dri-engine/`. Please refer to `mg-tests` repository. To exploit the GPU's accelerated rendering capabilities, a MiniGUI app can use `cairo` and/or `OpenGL ES` to assist in rendering 2D/3D graphics -when using the `drm` engine. We will provide some samples in `mg-tests` +when using the `dri` engine. We will provide some samples in `mg-tests` or `mg-samples` for this purpose. -Note that for `drm` engine, we introduce a new section in MiniGUI runtime +Note that for `dri` engine, we introduce a new section in MiniGUI runtime configuration: ``` -[drm] +[dri] defaultmode=1024x768-32bpp device=/dev/dri/card0 dpi=96 ``` -You can use the key `drm.device` to specify your DRI device. +You can use the key `dri.device` to specify your DRI device. Also note that when you use the hardware accelerated sub driver, MiniGUI app may need the root privilege to call `drmSetMaster` to set the video mode. @@ -330,7 +330,7 @@ table pad. The extra input messages have the prefix `MSG_EXIN_`. If a MiniGUI app want to handle these extra input events such as gestures, you need to handle the `MSG_EXIN_XXX` messages in the app. For examples, please -refer to `mg-tests/drm-extra-input/`. +refer to `mg-tests/extra-input/`. Currently, there are two built-in IAL engines which can generates the extra input messages: diff --git a/configure.ac b/configure.ac index 609d47a2..1d59d1f5 100644 --- a/configure.ac +++ b/configure.ac @@ -264,7 +264,7 @@ enable_video_dfb_st7167="no" enable_video_stgfb="no" enable_video_fbcon="yes" -enable_video_drm="yes" +enable_video_dri="yes" enable_video_commlcd="no" enable_video_shadow="no" enable_video_mlshadow="no" @@ -889,23 +889,23 @@ CheckFBCON() dnl Find the DRM includes CheckDRM() { - AC_ARG_ENABLE(videodrm, -[ --enable-videodrm include Linux DRM NEWGAL engine ], - enable_video_drm=$enableval) - if test "x$enable_video_drm" = "xyes"; then - PKG_CHECK_MODULES(DRM, [libudev >= 200, libdrm >= 2.4], video_drm="yes", - video_drm="no; Linux DRM NEWGAL engine requires libdrm 2.4+ and libudev 200+") - if test "x$video_drm" = "xyes"; then - AC_DEFINE(_MGGAL_DRM, 1, + AC_ARG_ENABLE(videodri, +[ --enable-videodri include Linux DRM NEWGAL engine ], + enable_video_dri=$enableval) + if test "x$enable_video_dri" = "xyes"; then + PKG_CHECK_MODULES(DRM, [libudev >= 200, libdrm >= 2.4], video_dri="yes", + video_dri="no; Linux DRM NEWGAL engine requires libdrm 2.4+ and libudev 200+") + if test "x$video_dri" = "xyes"; then + AC_DEFINE(_MGGAL_DRI, 1, [Define if include Linux DRM NEWGAL engine]) - VIDEO_SUBDIRS="$VIDEO_SUBDIRS drm" - VIDEO_DRIVERS="$VIDEO_DRIVERS drm/libvideo_drm.la" + VIDEO_SUBDIRS="$VIDEO_SUBDIRS dri" + VIDEO_DRIVERS="$VIDEO_DRIVERS dri/libvideo_dri.la" DEP_LIBS="$DEP_LIBS -ldrm" need_udev="yes" DRM_INC_DIR="`$PKG_CONFIG --variable includedir libdrm`/drm" AC_SUBST(DRM_INC_DIR) else - AC_MSG_WARN([$video_drm]) + AC_MSG_WARN([$video_dri]) fi fi } @@ -2603,7 +2603,7 @@ src/font/Makefile src/font/in-core/Makefile src/newgal/Makefile src/newgal/fbcon/Makefile -src/newgal/drm/Makefile +src/newgal/dri/Makefile src/newgal/qvfb/Makefile src/newgal/pcxvfb/Makefile src/newgal/wvfb/Makefile @@ -2679,7 +2679,7 @@ AC_MSG_NOTICE([ * dummy: ${enable_video_dummy} * pc_xvfb: ${enable_video_pc_xvfb} * usvfb: ${enable_video_usvfb} - * drm: ${enable_video_drm} + * dri: ${enable_video_dri} * fbcon: ${enable_video_fbcon} * commlcd: ${enable_video_commlcd} diff --git a/etc/MiniGUI.cfg b/etc/MiniGUI.cfg index 9c044b83..253fc87c 100644 --- a/etc/MiniGUI.cfg +++ b/etc/MiniGUI.cfg @@ -33,8 +33,8 @@ mtype=IMPS2 # Linux IAL engine based on libinput # ial_engine=libinut -#{{ifdef _MGGAL_DRM -[drm] +#{{ifdef _MGGAL_DRI +[dri] defaultmode=1024x768-16bpp device=/dev/dri/card0 # The resolution of the display diff --git a/include/exstubs.h b/include/exstubs.h index 9c7c220d..add9950e 100644 --- a/include/exstubs.h +++ b/include/exstubs.h @@ -84,49 +84,49 @@ struct commlcd_info { extern "C" { #endif /* __cplusplus */ -#ifdef _MGGAL_DRM +#ifdef _MGGAL_DRI #include /* * this struct should be defined by the driver */ -struct _DrmDriver; -typedef struct _DrmDriver DrmDriver; +struct _DriDriver; +typedef struct _DriDriver DriDriver; -typedef struct _DrmDriverOps { - DrmDriver* (*create_driver) (int device_fd); - void (*destroy_driver) (DrmDriver *driver); +typedef struct _DriDriverOps { + DriDriver* (*create_driver) (int device_fd); + void (*destroy_driver) (DriDriver *driver); - uint32_t (* create_buffer) (DrmDriver *driver, + uint32_t (* create_buffer) (DriDriver *driver, int depth, int bpp, unsigned int width, unsigned int height, unsigned int *pitch); - BOOL (* fetch_buffer) (DrmDriver *driver, + BOOL (* fetch_buffer) (DriDriver *driver, uint32_t buffer_id, unsigned int *width, unsigned int *height, unsigned int *pitch); - uint8_t* (* map_buffer) (DrmDriver *driver, + uint8_t* (* map_buffer) (DriDriver *driver, uint32_t buffer_id); - void (* unmap_buffer) (DrmDriver *driver, + void (* unmap_buffer) (DriDriver *driver, uint32_t buffer_id); - uint8_t * (* begin_flush) (DrmDriver *driver, + uint8_t * (* begin_flush) (DriDriver *driver, uint32_t buffer_id); - void (* end_flush) (DrmDriver *driver, + void (* end_flush) (DriDriver *driver, uint32_t buffer_id); - void (* destroy_buffer) (DrmDriver *driver, + void (* destroy_buffer) (DriDriver *driver, uint32_t buffer_id); -} DrmDriverOps; +} DriDriverOps; -/* implement this stub to return the DRM driver operators */ -DrmDriverOps* __drm_ex_driver_get (const char* driver_name); +/* implement this stub to return the DRI driver operators */ +DriDriverOps* __dri_ex_driver_get (const char* driver_name); -#endif /* _MGGAL_DRM */ +#endif /* _MGGAL_DRI */ /* external stubs for COMMLCD NEWGAL engine */ #ifdef _MGGAL_COMMLCD diff --git a/src/newgal/Makefile.am b/src/newgal/Makefile.am index b87335fd..55e178d5 100644 --- a/src/newgal/Makefile.am +++ b/src/newgal/Makefile.am @@ -7,8 +7,8 @@ noinst_LTLIBRARIES = libnewgal.la # Define which subdirectories need to be built SUBDIRS = @VIDEO_SUBDIRS@ DIST_SUBDIRS = dummy fbcon qvfb wvfb em85xxyuv em85xxosd svpxxosd bf533 utpmc \ - mb93493 commlcd shadow mlshadow dfb em86gfx hisi rtos_xvfb pcxvfb \ - nexus s3c6410 sigma8654 mstar gdl stgfb usvfb + mb93493 commlcd shadow mlshadow dfb em86gfx hisi rtos_xvfb pcxvfb \ + nexus s3c6410 sigma8654 mstar gdl stgfb usvfb dri # x11 dga vgl svga ggi aalib EXTRA_DIST=makefile.ng makefile.msvc @@ -34,9 +34,9 @@ COMMON_SRCS = \ stretch_c.h \ sysvideo.h \ video.c \ - newgal.c \ - videomem-bucket.h \ - videomem-bucket.c + newgal.c \ + videomem-bucket.h \ + videomem-bucket.c libnewgal_la_SOURCES = $(COMMON_SRCS) libnewgal_la_LIBADD = $(DRIVERS) diff --git a/src/newgal/dri/Makefile.am b/src/newgal/dri/Makefile.am new file mode 100644 index 00000000..7848ff9c --- /dev/null +++ b/src/newgal/dri/Makefile.am @@ -0,0 +1,18 @@ + +## Makefile.am for the dri video driver +AM_CPPFLAGS = -I$(abs_top_srcdir)/src/include -I$(abs_top_srcdir)/include -I$(abs_top_srcdir)/src/newgal/ -I$(DRM_INC_DIR) + +noinst_LTLIBRARIES = libvideo_dri.la + +# The dri video driver sources +SRC_FILES = \ + drivideo.c + +HDR_FILES= \ + drivideo.h + +libvideo_dri_la_SOURCES = $(SRC_FILES) $(HDR_FILES) + +EXTRA_DIST=makefile.ng + +LIB_NAME=libvideo_dri diff --git a/src/newgal/drm/drmvideo.c b/src/newgal/dri/drivideo.c similarity index 97% rename from src/newgal/drm/drmvideo.c rename to src/newgal/dri/drivideo.c index adc356cb..44dc80c1 100644 --- a/src/newgal/drm/drmvideo.c +++ b/src/newgal/dri/drivideo.c @@ -38,7 +38,7 @@ #define _DEBUG #include "common.h" -#ifdef _MGGAL_DRM +#ifdef _MGGAL_DRI #include #include @@ -54,7 +54,7 @@ #include "exstubs.h" #include "pixels_c.h" -#include "drmvideo.h" +#include "drivideo.h" #define DRM_DRIVER_NAME "drm" @@ -121,7 +121,7 @@ struct drm_mode_info { * drm_prepare(). It resets the CRTCs to their saved states and deallocates * all memory. */ -static void drm_cleanup(DrmVideoData* vdata) +static void drm_cleanup(DriVideoData* vdata) { if (vdata->saved_crtc) { /* restore saved CRTC configuration */ @@ -259,7 +259,7 @@ static int open_drm_device(GAL_VideoDevice *device) } #ifdef __TARGET_EXTERNAL__ - device->hidden->driver_ops = __drm_ex_driver_get(driver_name); + device->hidden->driver_ops = __dri_ex_driver_get(driver_name); #endif free (driver_name); @@ -370,7 +370,7 @@ VideoBootStrap DRM_bootstrap = { * drm_find_crtc(vdata, res, conn, info): * This small helper tries to find a suitable CRTC for the given connector. */ -static int drm_find_crtc(DrmVideoData* vdata, +static int drm_find_crtc(DriVideoData* vdata, drmModeRes *res, drmModeConnector *conn, struct drm_mode_info *info) { drmModeEncoder *enc; @@ -451,7 +451,7 @@ static int drm_find_crtc(DrmVideoData* vdata, * drm_setup_connector: * Set up a single connector. */ -static int drm_setup_connector(DrmVideoData* vdata, +static int drm_setup_connector(DriVideoData* vdata, drmModeRes *res, drmModeConnector *conn, struct drm_mode_info *info) { int ret; @@ -492,7 +492,7 @@ static int drm_setup_connector(DrmVideoData* vdata, * drm_prepare: * Collect the connnectors and mode information. */ -static int drm_prepare(DrmVideoData* vdata) +static int drm_prepare(DriVideoData* vdata) { drmModeRes *res; drmModeConnector *conn; @@ -614,7 +614,7 @@ static void DRM_VideoQuit(_THIS) static int DRM_Resume(_THIS) { - DrmVideoData* vdata = this->hidden; + DriVideoData* vdata = this->hidden; int ret = -1; _DBG_PRINTF ("NEWGAL>DRM: %s called\n", __FUNCTION__); @@ -639,7 +639,7 @@ static int DRM_Resume(_THIS) static int DRM_Suspend(_THIS) { - DrmVideoData* vdata = this->hidden; + DriVideoData* vdata = this->hidden; int ret = -1; _DBG_PRINTF ("NEWGAL>DRM: %s called\n", __FUNCTION__); @@ -670,7 +670,7 @@ static int DRM_Suspend(_THIS) * Call this function to create a so called "dumb buffer". * We can use it for unaccelerated software rendering on the CPU. */ -static int drm_create_dumb_fb(DrmVideoData* vdata, const DrmModeInfo* info, +static int drm_create_dumb_fb(DriVideoData* vdata, const DrmModeInfo* info, int depth, int bpp) { struct drm_mode_create_dumb creq; @@ -738,7 +738,7 @@ err_destroy: return ret; } -static DrmModeInfo* find_mode(DrmVideoData* vdata, int width, int height) +static DrmModeInfo* find_mode(DriVideoData* vdata, int width, int height) { DrmModeInfo *iter; @@ -754,7 +754,7 @@ static DrmModeInfo* find_mode(DrmVideoData* vdata, int width, int height) static GAL_Surface *DRM_SetVideoMode_Dumb(_THIS, GAL_Surface *current, int width, int height, int bpp, Uint32 flags) { - DrmVideoData* vdata = this->hidden; + DriVideoData* vdata = this->hidden; DrmModeInfo* info; int depth; int ret; @@ -833,7 +833,7 @@ static void DRM_FreeHWSurface_Dumb(_THIS, GAL_Surface *surface) static GAL_Surface *DRM_SetVideoMode_Accl(_THIS, GAL_Surface *current, int width, int height, int bpp, Uint32 flags) { - DrmVideoData* vdata = this->hidden; + DriVideoData* vdata = this->hidden; DrmModeInfo* info; int depth; unsigned int pitch; @@ -969,5 +969,5 @@ static int DRM_SetHWAlpha_Accl(_THIS, GAL_Surface *surface, Uint8 value) return 0; } -#endif /* _MGGAL_DRM */ +#endif /* _MGGAL_DRI */ diff --git a/src/newgal/drm/drmvideo.h b/src/newgal/dri/drivideo.h similarity index 93% rename from src/newgal/drm/drmvideo.h rename to src/newgal/dri/drivideo.h index c1754b5e..25afb3f9 100644 --- a/src/newgal/drm/drmvideo.h +++ b/src/newgal/dri/drivideo.h @@ -31,8 +31,8 @@ * . */ -#ifndef _NEWGAL_DRMVIDEO_H -#define _NEWGAL_DRMVIDEO_H +#ifndef _NEWGAL_DRIVIDEO_H +#define _NEWGAL_DRIVIDEO_H #include @@ -51,8 +51,8 @@ typedef struct GAL_PrivateVideoData { char dev_name[LEN_DEVICE_NAME + 1]; int dev_fd; - DrmDriverOps* driver_ops; - DrmDriver* driver; + DriDriverOps* driver_ops; + DriDriver* driver; DrmModeInfo* mode_list; GAL_Rect** modes; @@ -74,7 +74,7 @@ typedef struct GAL_PrivateVideoData { /* only valid when using DRM driver */ uint32_t console_buff_id; -} DrmVideoData; +} DriVideoData; -#endif /* _NEWGAL_DRMVIDEO_H */ +#endif /* _NEWGAL_DRIVIDEO_H */ diff --git a/src/newgal/drm/makefile.ng b/src/newgal/dri/makefile.ng similarity index 100% rename from src/newgal/drm/makefile.ng rename to src/newgal/dri/makefile.ng diff --git a/src/newgal/drm/Makefile.am b/src/newgal/drm/Makefile.am deleted file mode 100644 index d4d5c44c..00000000 --- a/src/newgal/drm/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ - -## Makefile.am for the drm video driver -AM_CPPFLAGS = -I$(abs_top_srcdir)/src/include -I$(abs_top_srcdir)/include -I$(abs_top_srcdir)/src/newgal/ -I$(DRM_INC_DIR) - -noinst_LTLIBRARIES = libvideo_drm.la - -# The drm video driver sources -SRC_FILES = \ - drmvideo.c - -HDR_FILES= \ - drmvideo.h - -libvideo_drm_la_SOURCES = $(SRC_FILES) $(HDR_FILES) - -EXTRA_DIST=makefile.ng - -LIB_NAME=libvideo_drm