From: Junkyeong Kim Date: Mon, 23 Nov 2015 11:44:56 +0000 (+0900) Subject: ecore_drm: Add ECORE_DRM_DEVICE_SUPPORT_SPRD define for SPRD device X-Git-Tag: accepted/tizen/mobile/20151124.233811^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f02998e1c2c0a49a481fde8c86b3cf6e392eb03f;p=platform%2Fupstream%2Fefl.git ecore_drm: Add ECORE_DRM_DEVICE_SUPPORT_SPRD define for SPRD device Summary: Support spreadtrum graphic chipset device. Change-Id: Ie69d0e095f0933a95ab6c9ceb801100d8ee1c203 Signed-off-by: Junkyeong Kim --- diff --git a/configure.ac b/configure.ac index dadb5fc..56d9dd4 100644 --- a/configure.ac +++ b/configure.ac @@ -3162,7 +3162,13 @@ EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eeze]) EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eo]) EFL_INTERNAL_DEPEND_PKG([ECORE_DRM], [eina]) -EFL_DEPEND_PKG([ECORE_DRM], [DRM], [libdrm >= 2.4 xkbcommon >= 0.3.0 gbm]) +PKG_CHECK_MODULES(DRM, libdrm_sprd, [HAVE_SPRD=yes], [HAVE_SPRD=no]) +if test "x$HAVE_SPRD" = xyes; then + EFL_DEPEND_PKG([ECORE_DRM], [DRM], [libdrm >= 2.4 libdrm_sprd xkbcommon >= 0.3.0 gbm]) +else + EFL_DEPEND_PKG([ECORE_DRM], [DRM], [libdrm >= 2.4 xkbcommon >= 0.3.0 gbm]) +fi + EFL_DEPEND_PKG([ECORE_DRM], [LIBINPUT], [libinput >= 0.6.0]) # API change from 0.7 to 0.8. So we define this to support both for now. diff --git a/packaging/efl.spec b/packaging/efl.spec index 1bb703c..99f3fb5 100644 --- a/packaging/efl.spec +++ b/packaging/efl.spec @@ -101,6 +101,9 @@ BuildRequires: pkgconfig(libtbm) BuildRequires: pkgconfig(libdrm) BuildRequires: pkgconfig(wayland-client) BuildRequires: pkgconfig(wayland-server) +%if ("%{?tizen_target_name}" == "TM1") +BuildRequires: pkgconfig(libdrm_sprd) +%endif ############ efl Provides: efl-data @@ -620,6 +623,9 @@ Development files for elua %setup -q cp %{SOURCE1001} . +%if ("%{?tizen_target_name}" == "TM1") +CFLAGS+=" -DECORE_DRM_DEVICE_SUPPORT_SPRD " +%endif %build diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c index 2b47f72..63efa40 100644 --- a/src/lib/ecore_drm/ecore_drm_device.c +++ b/src/lib/ecore_drm/ecore_drm_device.c @@ -5,6 +5,11 @@ #include "ecore_drm_private.h" #include +#ifdef ECORE_DRM_DEVICE_SUPPORT_SPRD +#include +struct sprd_drm_device *sprd_dev = NULL; +#endif + #define INSIDE(x, y, xx, yy, ww, hh) \ (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && \ ((x) >= (xx)) && ((y) >= (yy))) @@ -261,6 +266,53 @@ ecore_drm_device_free(Ecore_Drm_Device *dev) free(dev); } +#ifdef ECORE_DRM_DEVICE_SUPPORT_SPRD +static Eina_Bool +_ecore_drm_device_sprd_check(int fd) +{ + drmVersionPtr drm_info; + int drmIRQ = 78; + int length = 0; + + if (sprd_dev) + { + ERR("sprd_dev already exist."); + return EINA_FALSE; + } + + drm_info = drmGetVersion(fd); + length = drm_info->name_len; + + if (length != 4) + { + drmFreeVersion(drm_info); + return EINA_FALSE; + } + if (strncmp("sprd", drm_info->name, 4)) + { + drmFreeVersion(drm_info); + return EINA_FALSE; + } + drmFreeVersion(drm_info); + + if (drmCtlInstHandler(fd, drmIRQ)) + { + ERR("drmCtlInstHandler fail."); + return EINA_FALSE; + } + + sprd_dev = sprd_device_create(fd); + if (sprd_dev == NULL) + { + ERR("sprd_device_create fail.(fd:%d)", fd); + return EINA_FALSE; + } + + DBG("sprd_device_create done.(fd:%d)", fd); + return EINA_TRUE; +} +#endif + EAPI Eina_Bool ecore_drm_device_open(Ecore_Drm_Device *dev) { @@ -276,6 +328,16 @@ ecore_drm_device_open(Ecore_Drm_Device *dev) _ecore_drm_launcher_device_open_no_pending(dev->drm.name, O_RDWR); if (dev->drm.fd < 0) return EINA_FALSE; +#ifdef ECORE_DRM_DEVICE_SUPPORT_SPRD + /* add for sprd device */ + if (_ecore_drm_device_sprd_check(dev->drm.fd) == EINA_FALSE) + { + _ecore_drm_launcher_device_close(dev->drm.name, dev->drm.fd); + dev->drm.fd = -1; + return EINA_FALSE; + } +#endif + DBG("Opened Device %s : %d", dev->drm.name, dev->drm.fd); ver = drmGetVersion(dev->drm.fd); @@ -346,6 +408,14 @@ ecore_drm_device_open(Ecore_Drm_Device *dev) EAPI Eina_Bool ecore_drm_device_close(Ecore_Drm_Device *dev) { +#ifdef ECORE_DRM_DEVICE_SUPPORT_SPRD + if (sprd_dev) + { + sprd_device_destroy(sprd_dev); + sprd_dev = NULL; + } +#endif + /* check for valid device */ EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE);