diff options
author | xinliang <xinliang.liu@linaro.org> | 2016-03-03 18:47:10 +0800 |
---|---|---|
committer | marxu01 <marico.xu@arm.com> | 2016-03-08 17:33:11 +0800 |
commit | 43d38354eea3f59fb24693c8e5a394863bef278e (patch) | |
tree | ef513a84509b4b6a7326bd3b8c2fedaa091a34af | |
parent | ee9f1d96193d4fc2887183b613f209b18a93e718 (diff) |
Add kirin drmmode driver.
Change-Id: I331e8f826d58a8349fa00e030468649da15bb464
-rw-r--r-- | README | 16 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/armsoc_driver.c | 1 | ||||
-rw-r--r-- | src/drmmode_driver.h | 1 | ||||
-rw-r--r-- | src/drmmode_kirin/drmmode_kirin.c | 95 |
5 files changed, 105 insertions, 11 deletions
@@ -5,25 +5,21 @@ DRM driver selection -------------------- While most operations use only the standard DRM modesetting interfaces, certain operations unavoidably rely on specific driver behaviour (including dumb buffer allocation flags and cursor -plane z-ordering). As such, the armsoc driver must be configured for a particular DRM driver. +plane z-ordering). As such, the armsoc driver should choose a particular DRM driver dynamically +according to the current environment. The currently supported DRM drivers are: - pl111 - exynos - -To configure armsoc for one of these, pass the --with-drmmode option to ./configure. For example: - -$ ./configure --with-drmmode=pl111 +- kirin For other drivers, you will need to implement this support yourself. A template implementation is -provided in src/drmmode_template which can be built by passing --with-drmmode=template to ./configure. +provided in src/drmmode_template. The interface is defined and documented in src/drmmode_driver.h, and you should refer to this while modifying the template to set up your DRM driver's abstraction appropriately. -You can also copy src/drmmode_template into src/drmmode_<yourdrivername> and build with: - -$ ./configure --with-drmmode=<yourdrivername> - +You can also copy src/drmmode_template into src/drmmode_<yourdrivername>, +modify the driver_name to match with the name used in the kernel drm driver. Summary of bo reference counting -------------------------------- diff --git a/src/Makefile.am b/src/Makefile.am index e5bfe8b..07cd626 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,7 +41,8 @@ armsoc_drv_la_LDFLAGS = -module -avoid-version -no-undefined armsoc_drv_la_LIBADD = @XORG_LIBS@ armsoc_drv_ladir = @moduledir@/drivers DRMMODE_SRCS = drmmode_exynos/drmmode_exynos.c \ - drmmode_pl111/drmmode_pl111.c + drmmode_pl111/drmmode_pl111.c \ + drmmode_kirin/drmmode_kirin.c armsoc_drv_la_SOURCES = \ diff --git a/src/armsoc_driver.c b/src/armsoc_driver.c index f21d8ef..0bf2b21 100644 --- a/src/armsoc_driver.c +++ b/src/armsoc_driver.c @@ -735,6 +735,7 @@ static struct drmmode_interface *get_drmmode_implementation(int drm_fd) struct drmmode_interface *ifaces[] = { &exynos_interface, &pl111_interface, + &kirin_interface, }; int i; diff --git a/src/drmmode_driver.h b/src/drmmode_driver.h index 55c8b8a..edc87c7 100644 --- a/src/drmmode_driver.h +++ b/src/drmmode_driver.h @@ -104,6 +104,7 @@ struct drmmode_interface { extern struct drmmode_interface exynos_interface; extern struct drmmode_interface pl111_interface; +extern struct drmmode_interface kirin_interface; #endif diff --git a/src/drmmode_kirin/drmmode_kirin.c b/src/drmmode_kirin/drmmode_kirin.c new file mode 100644 index 0000000..f956a9b --- /dev/null +++ b/src/drmmode_kirin/drmmode_kirin.c @@ -0,0 +1,95 @@ +/* + * Copyright © 2016 Linaro Limited. + * Copyright © 2016 Hisilicon Limited. + * + * Permission is hereby granted, free of charge, to any person +obtaining a + * copy of this software and associated documentation files (the +"Software"), + * to deal in the Software without restriction, including without +limitation + * the rights to use, copy, modify, merge, publish, distribute, +sublicense, + * and/or sell copies of the Software, and to permit persons to whom +the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the +next + * paragraph) shall be included in all copies or substantial portions +of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE + * SOFTWARE. + * + */ + +#include <xf86drm.h> +#include "../drmmode_driver.h" + +/* Cursor dimensions + * Technically we probably don't have any size limit.. since we + * are just using an overlay... but xserver will always create + * cursor images in the max size, so don't use width/height values + * that are too big + */ +/* width */ +#define CURSORW (64) +/* height */ +#define CURSORH (64) +/* Padding added down each side of cursor image */ +#define CURSORPAD (0) + +#define ALIGN(val, align) (((val) + (align) - 1) & ~((align) - 1)) + +static int create_custom_gem(int fd, struct armsoc_create_gem *create_gem) +{ + struct drm_mode_create_dumb arg; + unsigned int pitch; + int ret; + + /* For 32bpp mali 450GPU needs pitch 8 bytes alignment */ + pitch = ALIGN(create_gem->width * ((create_gem->bpp + 7) / 8), 8); + memset(&arg, 0, sizeof(arg)); + arg.width = create_gem->width; + arg.height = create_gem->height; + arg.bpp = create_gem->bpp; + arg.pitch = pitch; + arg.size = pitch * create_gem->height; + + ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg); + if (ret) + return ret; + + create_gem->handle = arg.handle; + create_gem->pitch = arg.pitch; + create_gem->size = arg.size; + + return 0; +} + +struct drmmode_interface kirin_interface = { + "kirin" /* name of drm driver */, + 1 /* use_page_flip_events */, + 1 /* use_early_display */, + CURSORW /* cursor width */, + CURSORH /* cursor_height */, + CURSORPAD /* cursor padding */, + HWCURSOR_API_NONE /* software cursor */, + NULL /* no plane for cursor */, + 0 /* vblank_query_supported */, + create_custom_gem /* create_custom_gem */, +}; + |