diff options
author | Hemant Hariyani <hemanthariyani@ti.com> | 2011-06-16 11:02:12 +0100 |
---|---|---|
committer | Andy Green <andy.green@linaro.org> | 2011-06-16 11:02:12 +0100 |
commit | 519093b76f8d5f7c75cf7b06fc6a5d7df611f2c2 (patch) | |
tree | 7aad990d980273ef26ec8b9b5dec35cddb4c328d | |
parent | 297b0704fed097954eb823704253a2af75ba8abe (diff) |
Subject: [PATCH 4/5] OMAP4:SGX-KM: Adding DRM support to 3PDD
This patch adds DRM support to 3rd party display driver. As a
consequence, omaplfb sysfs entries do not work anymore and need
to be reworked.
Change-Id: I2af145d15138ee441c3708ec40fb8bea7a9a70bd
Signed-off-by: Hemant Hariyani <hemanthariyani@ti.com>
-rw-r--r-- | drivers/gpu/pvr/Makefile | 1 | ||||
-rw-r--r-- | drivers/gpu/pvr/omaplfb/3rdparty_dc_drm_shared.h | 45 | ||||
-rw-r--r-- | drivers/gpu/pvr/omaplfb/omaplfb.h | 23 | ||||
-rw-r--r-- | drivers/gpu/pvr/omaplfb/omaplfb_displayclass.c | 230 | ||||
-rw-r--r-- | drivers/gpu/pvr/omaplfb/omaplfb_linux.c | 130 |
5 files changed, 336 insertions, 93 deletions
diff --git a/drivers/gpu/pvr/Makefile b/drivers/gpu/pvr/Makefile index bed0ee05159..725688b4666 100644 --- a/drivers/gpu/pvr/Makefile +++ b/drivers/gpu/pvr/Makefile @@ -152,7 +152,6 @@ sgx_displayclass-y := \ omaplfb-y := \ omaplfb/omaplfb_displayclass.o \ - omaplfb/omaplfb-sysfs.o \ omaplfb/omaplfb_linux.o dbgdrv-$(CONFIG_SGX_PDUMP) := \ diff --git a/drivers/gpu/pvr/omaplfb/3rdparty_dc_drm_shared.h b/drivers/gpu/pvr/omaplfb/3rdparty_dc_drm_shared.h new file mode 100644 index 00000000000..0dee80a8014 --- /dev/null +++ b/drivers/gpu/pvr/omaplfb/3rdparty_dc_drm_shared.h @@ -0,0 +1,45 @@ +/********************************************************************** + * + * Copyright (C) Imagination Technologies Ltd. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful but, except + * as otherwise stated in writing, without any warranty; without even the + * implied warranty of merchantability or fitness for a particular purpose. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + * The full GNU General Public License is included in this distribution in + * the file called "COPYING". + * + * Contact Information: + * Imagination Technologies Ltd. <gpl-support@imgtec.com> + * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK + * + ******************************************************************************/ + +#ifndef __3RDPARTY_DC_DRM_SHARED_H__ +#define __3RDPARTY_DC_DRM_SHARED_H__ +#if defined(SUPPORT_DRI_DRM) + +#define PVR_DRM_DISP_CMD_ENTER_VT 1 +#define PVR_DRM_DISP_CMD_LEAVE_VT 2 + +#define PVR_DRM_DISP_CMD_ON 3 +#define PVR_DRM_DISP_CMD_STANDBY 4 +#define PVR_DRM_DISP_CMD_SUSPEND 5 +#define PVR_DRM_DISP_CMD_OFF 6 + +#define PVR_DRM_DISP_ARG_CMD 0 +#define PVR_DRM_DISP_ARG_DEV 1 +#define PVR_DRM_DISP_NUM_ARGS 2 + +#endif +#endif + diff --git a/drivers/gpu/pvr/omaplfb/omaplfb.h b/drivers/gpu/pvr/omaplfb/omaplfb.h index 57620ab0add..5dee3e945b6 100644 --- a/drivers/gpu/pvr/omaplfb/omaplfb.h +++ b/drivers/gpu/pvr/omaplfb/omaplfb.h @@ -27,6 +27,9 @@ #ifndef __OMAPLFB_H__ #define __OMAPLFB_H__ +/* max number of overlays to which a framebuffer data can be direct */ +#define OMAPFB_MAX_OVL_PER_FB 3 + extern IMG_BOOL PVRGetDisplayClassJTable(PVRSRV_DC_DISP2SRV_KMJTABLE *psJTable); typedef void * OMAP_HANDLE; @@ -60,6 +63,7 @@ typedef struct OMAPLFB_FLIP_ITEM_TAG typedef struct PVRPDP_SWAPCHAIN_TAG { + unsigned int uiSwapChainID; unsigned long ulBufferCount; OMAPLFB_BUFFER* psBuffer; OMAPLFB_FLIP_ITEM* psFlipItems; @@ -90,6 +94,7 @@ typedef struct OMAPLFB_FBINFO_TAG typedef struct OMAPLFB_DEVINFO_TAG { + unsigned int uiSwapChainID; IMG_UINT32 uDeviceID; OMAPLFB_BUFFER sSystemBuffer; PVRSRV_DC_DISP2SRV_KMJTABLE sPVRJTable; @@ -107,9 +112,9 @@ typedef struct OMAPLFB_DEVINFO_TAG DISPLAY_DIMS sDisplayDim; struct workqueue_struct* sync_display_wq; struct work_struct sync_display_work; - struct kobject kobj; - OMAP_BOOL ignore_sync; - +#if defined(SUPPORT_DRI_DRM) + OMAP_BOOL bLeaveVT; +#endif } OMAPLFB_DEVINFO; typedef enum _OMAP_ERROR_ @@ -126,12 +131,6 @@ typedef enum _OMAP_ERROR_ } OMAP_ERROR; -struct omaplfb_device { - struct device *dev; - OMAPLFB_DEVINFO *display_info_list; - int display_count; -}; - #define OMAPLFB_PAGE_SIZE 4096 #define OMAPLFB_PAGE_MASK (OMAPLFB_PAGE_SIZE - 1) #define OMAPLFB_PAGE_TRUNC (~OMAPLFB_PAGE_MASK) @@ -157,17 +156,17 @@ struct omaplfb_device { #define ERROR_PRINTK(format, ...) printk("ERROR " DRIVER_PREFIX \ " (%s %i): " format "\n", __func__, __LINE__, ## __VA_ARGS__) -OMAP_ERROR OMAPLFBInit(struct omaplfb_device *omaplfb_dev); +OMAP_ERROR OMAPLFBInit(void); OMAP_ERROR OMAPLFBDeinit(void); +OMAP_ERROR UnBlankDisplay(OMAPLFB_DEVINFO *psDevInfo); void *OMAPLFBAllocKernelMem(unsigned long ulSize); void OMAPLFBFreeKernelMem(void *pvMem); void OMAPLFBPresentSync(OMAPLFB_DEVINFO *psDevInfo, OMAPLFB_FLIP_ITEM *psFlipItem); +void OMAPLFBPresentSyncAddr(OMAPLFB_DEVINFO *psDevInfo, unsigned long aPhyAddr); OMAP_ERROR OMAPLFBGetLibFuncAddr(char *szFunctionName, PFN_DC_GET_PVRJTABLE *ppfnFuncTable); void OMAPLFBFlip(OMAPLFB_SWAPCHAIN *psSwapChain, unsigned long aPhyAddr); -void omaplfb_create_sysfs(struct omaplfb_device *odev); -void omaplfb_remove_sysfs(struct omaplfb_device *odev); #ifdef LDM_PLATFORM void OMAPLFBDriverSuspend(void); void OMAPLFBDriverResume(void); diff --git a/drivers/gpu/pvr/omaplfb/omaplfb_displayclass.c b/drivers/gpu/pvr/omaplfb/omaplfb_displayclass.c index 76d5ce26cf0..aca3b4de874 100644 --- a/drivers/gpu/pvr/omaplfb/omaplfb_displayclass.c +++ b/drivers/gpu/pvr/omaplfb/omaplfb_displayclass.c @@ -45,21 +45,29 @@ #include <../drivers/video/omap2/omapfb/omapfb.h> #endif +#if defined(SUPPORT_DRI_DRM) +#include <drm/drmP.h> +#else #include <linux/module.h> +#endif + #include <linux/string.h> #include <linux/notifier.h> -#ifdef CONFIG_TILER_OMAP -#include <mach/tiler.h> -#define TILER_MIN_PADDR 0x60000000 -#define TILER_MAX_PADDR 0x7fffffff -#endif - #include "img_defs.h" #include "servicesext.h" #include "kerneldisplay.h" #include "omaplfb.h" +#if defined(SUPPORT_DRI_DRM) +#include "pvr_drm.h" +#include "3rdparty_dc_drm_shared.h" +#endif + +#if !defined(PVR_LINUX_USING_WORKQUEUES) +#error "PVR_LINUX_USING_WORKQUEUES must be defined" +#endif + #define OMAPLFB_COMMAND_COUNT 1 #define MAX_BUFFERS_FLIPPING 4 /* Put 0 as desired bpp to use the default in the framebuffer */ @@ -144,6 +152,12 @@ static PVRSRV_ERROR SetDCSrcColourKey(IMG_HANDLE hDevice, */ static PVRSRV_ERROR CloseDCDevice(IMG_HANDLE hDevice) { +#if defined(SUPPORT_DRI_DRM) + OMAPLFB_DEVINFO *psDevInfo = (OMAPLFB_DEVINFO *)hDevice; + + psDevInfo->bLeaveVT = OMAP_FALSE; + UnBlankDisplay(psDevInfo); +#endif /* Nothing to do */ return PVRSRV_OK; } @@ -289,7 +303,7 @@ static void SetFlushStateExternal(OMAPLFB_DEVINFO* psDevInfo, * Unblank the framebuffer display * in: psDevInfo */ -static OMAP_ERROR UnBlankDisplay(OMAPLFB_DEVINFO *psDevInfo) +OMAP_ERROR UnBlankDisplay(OMAPLFB_DEVINFO *psDevInfo) { DEBUG_PRINTK("Executing for display %u", psDevInfo->uDeviceID); @@ -298,7 +312,7 @@ static OMAP_ERROR UnBlankDisplay(OMAPLFB_DEVINFO *psDevInfo) if (fb_blank(psDevInfo->psLINFBInfo, FB_BLANK_UNBLANK)) { console_unlock(); - WARNING_PRINTK("fb_blank failed"); + WARNING_PRINTK("fb_blank FB_BLANK_UNBLANK failed"); return OMAP_ERROR_GENERIC; } console_unlock(); @@ -307,6 +321,29 @@ static OMAP_ERROR UnBlankDisplay(OMAPLFB_DEVINFO *psDevInfo) } /* + * Blank the framebuffer display + * in: psDevInfo + */ +#if defined(SUPPORT_DRI_DRM) && defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL) +static OMAP_ERROR BlankDisplay(OMAPLFB_DEVINFO *psDevInfo, int blank_cmd) +{ + DEBUG_PRINTK("Executing for display %u", + psDevInfo->uDeviceID); + + acquire_console_sem(); + if (fb_blank(psDevInfo->psLINFBInfo, blank_cmd)) + { + release_console_sem(); + WARNING_PRINTK("fb_blank %i failed", blank_cmd); + return OMAP_ERROR_GENERIC; + } + release_console_sem(); + + return OMAP_OK; +} +#endif + +/* * Framebuffer listener * in: psNotif, event, data */ @@ -837,6 +874,14 @@ static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice, goto ErrorUnRegisterDisplayClient; } + psDevInfo->uiSwapChainID++; + if (psDevInfo->uiSwapChainID == 0) + { + psDevInfo->uiSwapChainID++; + } + psSwapChain->uiSwapChainID = psDevInfo->uiSwapChainID; + *pui32SwapChainID = psDevInfo->uiSwapChainID; + *phSwapChain = (IMG_HANDLE)psSwapChain; return PVRSRV_OK; @@ -1037,7 +1082,11 @@ static void OMAPLFBSyncIHandler(struct work_struct *work) mutex_lock(&psDevInfo->sSwapChainLockMutex); psSwapChain = psDevInfo->psSwapChain; - if (!psSwapChain || psSwapChain->bFlushCommands) + if (!psSwapChain || psSwapChain->bFlushCommands +#if defined(SUPPORT_DRI_DRM) + || psDevInfo->bLeaveVT +#endif + ) goto ExitUnlock; psFlipItem = &psSwapChain->psFlipItems[psSwapChain->ulRemoveIndex]; @@ -1123,7 +1172,11 @@ static IMG_BOOL ProcessFlip(IMG_HANDLE hCmdCookie, mutex_lock(&psDevInfo->sSwapChainLockMutex); - if (psDevInfo->bDeviceSuspended) + if (psDevInfo->bDeviceSuspended +#if defined(SUPPORT_DRI_DRM) + || psDevInfo->bLeaveVT == OMAP_TRUE +#endif + ) { /* If is suspended then assume the commands are completed */ psSwapChain->psPVRJTable->pfnPVRSRVCmdComplete( @@ -1134,7 +1187,7 @@ static IMG_BOOL ProcessFlip(IMG_HANDLE hCmdCookie, #if defined(SYS_USING_INTERRUPTS) if( psFlipCmd->ui32SwapInterval == 0 || - psDevInfo->ignore_sync || + psSwapChain->bFlushCommands == OMAP_TRUE) { #endif @@ -1249,6 +1302,150 @@ void OMAPLFBDriverResume(void) } #endif /* defined(LDM_PLATFORM) */ +#if defined(SUPPORT_DRI_DRM) && defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL) +static OMAPLFB_DEVINFO *OMAPLFBPVRDevIDToDevInfo(unsigned uiPVRDevID) +{ + int i; + + for(i = 0; i < FRAMEBUFFER_COUNT; i++) + { + if (uiPVRDevID == (&pDisplayDevices[i])->uDeviceID) + { + return &pDisplayDevices[i]; + } + } + + WARNING_PRINTK("Couldn't find device %u\n", uiPVRDevID); + + return NULL; +} + +int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Ioctl)(struct drm_device unref__ *dev, void *arg, struct drm_file unref__ *pFile) +{ + uint32_t *puiArgs; + uint32_t uiCmd; + unsigned uiPVRDevID; + int ret = 0; + OMAPLFB_DEVINFO *psDevInfo; + + if (arg == NULL) + { + return -EFAULT; + } + + puiArgs = (uint32_t *)arg; + uiCmd = puiArgs[PVR_DRM_DISP_ARG_CMD]; + uiPVRDevID = puiArgs[PVR_DRM_DISP_ARG_DEV]; + + psDevInfo = OMAPLFBPVRDevIDToDevInfo(uiPVRDevID); + if (psDevInfo == NULL) + { + return -EINVAL; + } + + + switch (uiCmd) + { + case PVR_DRM_DISP_CMD_LEAVE_VT: + case PVR_DRM_DISP_CMD_ENTER_VT: + { + OMAP_BOOL bLeaveVT = (uiCmd == PVR_DRM_DISP_CMD_LEAVE_VT); + DEBUG_PRINTK("PVR Device %u: %s\n", uiPVRDevID, + bLeaveVT ? "Leave VT" : "Enter VT"); + + mutex_lock(&psDevInfo->sSwapChainLockMutex); + psDevInfo->bLeaveVT = bLeaveVT; + + if (psDevInfo->psSwapChain != NULL) + { + FlushInternalSyncQueue(psDevInfo->psSwapChain); + + if (bLeaveVT) + { + OMAPLFBPresentSyncAddr(psDevInfo, + (unsigned long) psDevInfo->sSystemBuffer.sSysAddr.uiAddr); + } + } + + mutex_unlock(&psDevInfo->sSwapChainLockMutex); + UnBlankDisplay(psDevInfo); + break; + } + case PVR_DRM_DISP_CMD_ON: + case PVR_DRM_DISP_CMD_STANDBY: + case PVR_DRM_DISP_CMD_SUSPEND: + case PVR_DRM_DISP_CMD_OFF: + { + int iFBMode; +#if defined(DEBUG) + { + const char *pszMode; + switch(uiCmd) + { + case PVR_DRM_DISP_CMD_ON: + pszMode = "On"; + break; + case PVR_DRM_DISP_CMD_STANDBY: + pszMode = "Standby"; + break; + case PVR_DRM_DISP_CMD_SUSPEND: + pszMode = "Suspend"; + break; + case PVR_DRM_DISP_CMD_OFF: + pszMode = "Off"; + break; + default: + pszMode = "(Unknown Mode)"; + break; + } + DEBUG_PRINTK("PVR Device %u: Display %s\n", + uiPVRDevID, pszMode); + } +#endif + switch(uiCmd) + { + case PVR_DRM_DISP_CMD_ON: + iFBMode = FB_BLANK_UNBLANK; + break; + case PVR_DRM_DISP_CMD_STANDBY: + iFBMode = FB_BLANK_HSYNC_SUSPEND; + break; + case PVR_DRM_DISP_CMD_SUSPEND: + iFBMode = FB_BLANK_VSYNC_SUSPEND; + break; + case PVR_DRM_DISP_CMD_OFF: + iFBMode = FB_BLANK_POWERDOWN; + break; + default: + return -EINVAL; + } + + mutex_lock(&psDevInfo->sSwapChainLockMutex); + + if (psDevInfo->psSwapChain != NULL) + { + FlushInternalSyncQueue(psDevInfo->psSwapChain); + } + + mutex_unlock(&psDevInfo->sSwapChainLockMutex); + /* XXX: Internally all the previous ioctl commands are + * implemented the same in omapfb + */ + BlankDisplay(psDevInfo, iFBMode); + + break; + } + default: + { + ret = -EINVAL; + break; + } + } + + return ret; +} +#endif + /* * Frees the kernel framebuffer * in: psDevInfo @@ -1465,6 +1662,7 @@ static OMAP_ERROR InitDev(OMAPLFB_DEVINFO *psDevInfo, int fb_idx) DEBUG_PRINTK("*Stride (bytes): %u", (unsigned int)psLINFBInfo->fix.line_length); +#ifndef CONFIG_DRM #ifdef CONFIG_TILER_OMAP /* If TILER is being used, use correct physical stride and FB size */ if ((psPVRFBInfo->sSysAddr.uiAddr >= TILER_MIN_PADDR) && @@ -1484,6 +1682,7 @@ static OMAP_ERROR InitDev(OMAPLFB_DEVINFO *psDevInfo, int fb_idx) psPVRFBInfo->ulHeight * psPVRFBInfo->ulByteStride; } #endif +#endif /* Get physical display size for DPI calculation */ if (psLINFBInfo->var.width < 0 || psLINFBInfo->var.height < 0) { @@ -1552,7 +1751,7 @@ static OMAP_ERROR InitDev(OMAPLFB_DEVINFO *psDevInfo, int fb_idx) /* * Initialization routine for the 3rd party display driver */ -OMAP_ERROR OMAPLFBInit(struct omaplfb_device *omaplfb_dev) +OMAP_ERROR OMAPLFBInit(void) { OMAPLFB_DEVINFO *psDevInfo; PFN_CMD_PROC pfnCmdProcList[OMAPLFB_COMMAND_COUNT]; @@ -1592,13 +1791,12 @@ OMAP_ERROR OMAPLFBInit(struct omaplfb_device *omaplfb_dev) sizeof(OMAPLFB_DEVINFO) * FRAMEBUFFER_COUNT); if(!pDisplayDevices) { + pDisplayDevices = NULL; ERROR_PRINTK("Out of memory"); return OMAP_ERROR_OUT_OF_MEMORY; } memset(pDisplayDevices, 0, sizeof(OMAPLFB_DEVINFO) * FRAMEBUFFER_COUNT); - omaplfb_dev->display_info_list = pDisplayDevices; - omaplfb_dev->display_count = FRAMEBUFFER_COUNT; /* * Initialize each display device @@ -1637,7 +1835,9 @@ OMAP_ERROR OMAPLFBInit(struct omaplfb_device *omaplfb_dev) psDevInfo->psSwapChain = 0; psDevInfo->bFlushCommands = OMAP_FALSE; psDevInfo->bDeviceSuspended = OMAP_FALSE; - psDevInfo->ignore_sync = OMAP_FALSE; +#if defined(SUPPORT_DRI_DRM) + psDevInfo->bLeaveVT = OMAP_FALSE; +#endif if(psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers > 1) { diff --git a/drivers/gpu/pvr/omaplfb/omaplfb_linux.c b/drivers/gpu/pvr/omaplfb/omaplfb_linux.c index 2b5d9f3bfe0..35755301296 100644 --- a/drivers/gpu/pvr/omaplfb/omaplfb_linux.c +++ b/drivers/gpu/pvr/omaplfb/omaplfb_linux.c @@ -24,8 +24,13 @@ * ******************************************************************************/ -#include <linux/version.h> +#if defined(SUPPORT_DRI_DRM) +#include <drm/drmP.h> +#else #include <linux/module.h> +#endif + +#include <linux/version.h> #include <linux/fb.h> #include <asm/io.h> @@ -59,13 +64,21 @@ #endif #endif - #include "img_defs.h" #include "servicesext.h" #include "kerneldisplay.h" #include "omaplfb.h" #include "pvrmodule.h" +#if defined(SUPPORT_DRI_DRM) +#include "pvr_drm.h" +#include "3rdparty_dc_drm_shared.h" +#endif + +#if !defined(PVR_LINUX_USING_WORKQUEUES) +#error "PVR_LINUX_USING_WORKQUEUES must be defined" +#endif + MODULE_SUPPORTED_DEVICE(DEVNAME); #if defined(CONFIG_OUTER_CACHE) /* Kernel config option */ @@ -236,14 +249,19 @@ void OMAPLFBFlip(OMAPLFB_SWAPCHAIN *psSwapChain, unsigned long aPhyAddr) omapfb_unlock(fbdev); } +void OMAPLFBPresentSync(OMAPLFB_DEVINFO *psDevInfo, OMAPLFB_FLIP_ITEM *psFlipItem) +{ + OMAPLFBPresentSyncAddr(psDevInfo, (unsigned long)psFlipItem->sSysAddr->uiAddr); +} + /* * Present frame and synchronize with the display to prevent tearing * On DSI panels the sync function is used to handle FRAMEDONE IRQ * On DPI panels the wait_for_vsync is used to handle VSYNC IRQ * in: psDevInfo */ -void OMAPLFBPresentSync(OMAPLFB_DEVINFO *psDevInfo, - OMAPLFB_FLIP_ITEM *psFlipItem) +void OMAPLFBPresentSyncAddr(OMAPLFB_DEVINFO *psDevInfo, + unsigned long paddr) { struct fb_info *framebuffer = psDevInfo->psLINFBInfo; struct omapfb_info *ofbi = FB2OFB(framebuffer); @@ -269,15 +287,13 @@ void OMAPLFBPresentSync(OMAPLFB_DEVINFO *psDevInfo, driver->get_update_mode(display) == OMAP_DSS_UPDATE_MANUAL) { /* Wait first for the DSI bus to be released then update */ err = driver->sync(display); - OMAPLFBFlipNoLock(psDevInfo->psSwapChain, - (unsigned long)psFlipItem->sSysAddr->uiAddr); + OMAPLFBFlipNoLock(psDevInfo->psSwapChain, paddr); } else if (manager && manager->wait_for_vsync) { /* * Update the video pipelines registers then wait until the * frame is shown with a VSYNC */ - OMAPLFBFlipNoLock(psDevInfo->psSwapChain, - (unsigned long)psFlipItem->sSysAddr->uiAddr); + OMAPLFBFlipNoLock(psDevInfo->psSwapChain, paddr); err = manager->wait_for_vsync(manager); } @@ -292,44 +308,6 @@ void OMAPLFBPresentSync(OMAPLFB_DEVINFO *psDevInfo, static volatile OMAP_BOOL bDeviceSuspended; -static int omaplfb_probe(struct platform_device *pdev) -{ - struct omaplfb_device *odev; - - odev = kzalloc(sizeof(*odev), GFP_KERNEL); - - if (!odev) - return -ENOMEM; - - if (OMAPLFBInit(odev) != OMAP_OK) { - dev_err(&pdev->dev, "failed to setup omaplfb\n"); - kfree(odev); - return -ENODEV; - } - - odev->dev = &pdev->dev; - platform_set_drvdata(pdev, odev); - omaplfb_create_sysfs(odev); - - return 0; -} - -static int omaplfb_remove(struct platform_device *pdev) -{ - struct omaplfb_device *odev; - - odev = platform_get_drvdata(pdev); - - omaplfb_remove_sysfs(odev); - - if (OMAPLFBDeinit() != OMAP_OK) - WARNING_PRINTK("Driver cleanup failed"); - - kfree(odev); - - return 0; -} - /* * Common suspend driver function * in: psSwapChain, aPhyAddr @@ -345,7 +323,6 @@ static void OMAPLFBCommonSuspend(void) OMAPLFBDriverSuspend(); bDeviceSuspended = OMAP_TRUE; } - #if 0 /* * Function called when the driver is requested to release @@ -368,6 +345,8 @@ static struct platform_device omaplfb_device = { #if defined(SGX_EARLYSUSPEND) && defined(CONFIG_HAS_EARLYSUSPEND) +static struct early_suspend omaplfb_early_suspend; + /* * Android specific, driver is requested to be suspended * in: ea_event @@ -389,23 +368,18 @@ static void OMAPLFBDriverResume_Entry(struct early_suspend *ea_event) bDeviceSuspended = OMAP_FALSE; } + +#if !defined (SUPPORT_DRI_DRM) static struct platform_driver omaplfb_driver = { .driver = { .name = DRVNAME, - .owner = THIS_MODULE, - }, - .probe = omaplfb_probe, - .remove = omaplfb_remove, -}; - -static struct early_suspend omaplfb_early_suspend = { - .suspend = OMAPLFBDriverSuspend_Entry, - .resume = OMAPLFBDriverResume_Entry, - .level = EARLY_SUSPEND_LEVEL_STOP_DRAWING, + } }; +#endif #else /* defined(SGX_EARLYSUSPEND) && defined(CONFIG_HAS_EARLYSUSPEND) */ +#if !defined (SUPPORT_DRI_DRM) /* * Function called when the driver is requested to be suspended * in: pDevice, state @@ -444,14 +418,12 @@ static IMG_VOID OMAPLFBDriverShutdown_Entry( static struct platform_driver omaplfb_driver = { .driver = { .name = DRVNAME, - .owner = THIS_MODULE, }, - .probe = omaplfb_probe, - .remove = omaplfb_remove, .suspend = OMAPLFBDriverSuspend_Entry, .resume = OMAPLFBDriverResume_Entry, .shutdown = OMAPLFBDriverShutdown_Entry, }; +#endif /* !defined (SUPPORT_DRI_DRM)*/ #endif /* defined(SGX_EARLYSUSPEND) && defined(CONFIG_HAS_EARLYSUSPEND) */ @@ -460,12 +432,29 @@ static struct platform_driver omaplfb_driver = { /* * Driver init function */ +#if defined(SUPPORT_DRI_DRM) +int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Init)(struct drm_device *dev) +#else static int __init OMAPLFB_Init(void) +#endif { + if(OMAPLFBInit() != OMAP_OK) + { + WARNING_PRINTK("Driver init failed"); + return -ENODEV; + } + #if defined(LDM_PLATFORM) DEBUG_PRINTK("Registering platform driver"); +#if !defined(SUPPORT_DRI_DRM) if (platform_driver_register(&omaplfb_driver)) + { + WARNING_PRINTK("Unable to register platform driver"); + if(OMAPLFBDeinit() != OMAP_OK) + WARNING_PRINTK("Driver cleanup failed\n"); return -ENODEV; + } +#endif #if 0 DEBUG_PRINTK("Registering device driver"); if (platform_device_register(&omaplfb_device)) @@ -479,7 +468,10 @@ static int __init OMAPLFB_Init(void) #endif #if defined(SGX_EARLYSUSPEND) && defined(CONFIG_HAS_EARLYSUSPEND) - register_early_suspend(&omaplfb_early_suspend); + omaplfb_early_suspend.suspend = OMAPLFBDriverSuspend_Entry; + omaplfb_early_suspend.resume = OMAPLFBDriverResume_Entry; + omaplfb_early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB; + register_early_suspend(&omaplfb_early_suspend); DEBUG_PRINTK("Registered early suspend support"); #endif @@ -490,22 +482,30 @@ static int __init OMAPLFB_Init(void) /* * Driver exit function */ +#if defined(SUPPORT_DRI_DRM) +void PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Cleanup)(struct drm_device unref__ *dev) +#else static IMG_VOID __exit OMAPLFB_Cleanup(IMG_VOID) -{ +#endif +{ #if defined(LDM_PLATFORM) #if 0 DEBUG_PRINTK(format,...)("Removing platform device"); platform_device_unregister(&omaplfb_device); #endif +#if !defined(SUPPORT_DRI_DRM) DEBUG_PRINTK("Removing platform driver"); platform_driver_unregister(&omaplfb_driver); +#endif #if defined(SGX_EARLYSUSPEND) && defined(CONFIG_HAS_EARLYSUSPEND) - DEBUG_PRINTK("Removed early suspend support"); - unregister_early_suspend(&omaplfb_early_suspend); + unregister_early_suspend(&omaplfb_early_suspend); #endif #endif + if(OMAPLFBDeinit() != OMAP_OK) + WARNING_PRINTK("Driver cleanup failed"); } +#if !defined(SUPPORT_DRI_DRM) late_initcall(OMAPLFB_Init); module_exit(OMAPLFB_Cleanup); - +#endif |