diff options
author | Hemant Hariyani <hemanthariyani@ti.com> | 2011-06-16 10:57:14 +0100 |
---|---|---|
committer | Andy Green <andy.green@linaro.org> | 2011-06-16 10:57:14 +0100 |
commit | cf6f9cc6eb3f71f8b47fa5c9efd536e1114ac40e (patch) | |
tree | 08f98f4f9cd0ca8c9eafb31963bbd099a1ebbdc7 | |
parent | d65a8ef1151bfbf6d82ef814eea87e1b825f9c4e (diff) |
Subject: [PATCH 1/5] OMAP4: SGX-KM: Adding PVR DRM files to Android DDK KM (1.7.17.4403)
These files are required for DRI/DRM based implementation of the SGX
driver.
Change-Id: I513e31ab8d4c6efdcfb56dde8a485f51576ebeca
Signed-off-by: Hemant Hariyani <hemanthariyani@ti.com>
-rw-r--r-- | drivers/gpu/pvr/linux_drm/pvr_drm_mod.h | 34 | ||||
-rw-r--r-- | drivers/gpu/pvr/linux_drm/pvr_drm_stubs.c | 193 | ||||
-rw-r--r-- | drivers/gpu/pvr/pvr_drm.c | 467 | ||||
-rw-r--r-- | drivers/gpu/pvr/pvr_drm.h | 101 | ||||
-rw-r--r-- | drivers/gpu/pvr/pvr_drm_shared.h | 54 |
5 files changed, 849 insertions, 0 deletions
diff --git a/drivers/gpu/pvr/linux_drm/pvr_drm_mod.h b/drivers/gpu/pvr/linux_drm/pvr_drm_mod.h new file mode 100644 index 00000000000..70350fbcba2 --- /dev/null +++ b/drivers/gpu/pvr/linux_drm/pvr_drm_mod.h @@ -0,0 +1,34 @@ +/********************************************************************** + * + * 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 __PVR_DRM_MOD_H__ +#define __PVR_DRM_MOD_H__ + +int drm_pvr_dev_add(void); + +void drm_pvr_dev_remove(void); + +#endif diff --git a/drivers/gpu/pvr/linux_drm/pvr_drm_stubs.c b/drivers/gpu/pvr/linux_drm/pvr_drm_stubs.c new file mode 100644 index 00000000000..c3fc05db228 --- /dev/null +++ b/drivers/gpu/pvr/linux_drm/pvr_drm_stubs.c @@ -0,0 +1,193 @@ +/********************************************************************** + * + * 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 + * + ******************************************************************************/ + +#include <linux/version.h> +#include <linux/kernel.h> +#include <linux/pci.h> +#include <asm/system.h> + +#include "pvr_drm_mod.h" + +#define DRV_MSG_PREFIX_STR "pvr drm: " + +#define SGX_VENDOR_ID 1 +#define SGX_DEVICE_ID 1 +#define SGX_SUB_VENDOR_ID 1 +#define SGX_SUB_DEVICE_ID 1 + +#if defined(DEBUG) +#define DEBUG_PRINTK(format, args...) printk(format, ## args) +#else +#define DEBUG_PRINTK(format, args...) +#endif + +#define CLEAR_STRUCT(x) memset(&(x), 0, sizeof(x)) + +static struct pci_bus pvr_pci_bus; +static struct pci_dev pvr_pci_dev; + +static bool bDeviceIsRegistered; + +static void +release_device(struct device *dev) +{ +} + +int +drm_pvr_dev_add(void) +{ + int ret; + + DEBUG_PRINTK(KERN_INFO DRV_MSG_PREFIX_STR "%s\n", __FUNCTION__); + + if (bDeviceIsRegistered) + { + DEBUG_PRINTK(KERN_WARNING DRV_MSG_PREFIX_STR "%s: Device already registered\n", __FUNCTION__); + return 0; + } + + + pvr_pci_dev.vendor = SGX_VENDOR_ID; + pvr_pci_dev.device = SGX_DEVICE_ID; + pvr_pci_dev.subsystem_vendor = SGX_SUB_VENDOR_ID; + pvr_pci_dev.subsystem_device = SGX_SUB_DEVICE_ID; + + + pvr_pci_dev.bus = &pvr_pci_bus; + + dev_set_name(&pvr_pci_dev.dev, "%s", "SGX"); + pvr_pci_dev.dev.release = release_device; + + ret = device_register(&pvr_pci_dev.dev); + if (ret != 0) + { + printk(KERN_ERR DRV_MSG_PREFIX_STR "%s: device_register failed (%d)\n", __FUNCTION__, ret); + } + + bDeviceIsRegistered = true; + + return ret; +} +EXPORT_SYMBOL(drm_pvr_dev_add); + +void +drm_pvr_dev_remove(void) +{ + DEBUG_PRINTK(KERN_INFO DRV_MSG_PREFIX_STR "%s\n", __FUNCTION__); + + if (bDeviceIsRegistered) + { + DEBUG_PRINTK(KERN_INFO DRV_MSG_PREFIX_STR "%s: Unregistering device\n", __FUNCTION__); + + device_unregister(&pvr_pci_dev.dev); + bDeviceIsRegistered = false; + + + CLEAR_STRUCT(pvr_pci_dev); + CLEAR_STRUCT(pvr_pci_bus); + } + else + { + DEBUG_PRINTK(KERN_WARNING DRV_MSG_PREFIX_STR "%s: Device not registered\n", __FUNCTION__); + } +} +EXPORT_SYMBOL(drm_pvr_dev_remove); + +void +pci_disable_device(struct pci_dev *dev) +{ +} + +struct pci_dev * +pci_dev_get(struct pci_dev *dev) +{ + return dev; +} + +void +pci_set_master(struct pci_dev *dev) +{ +} + +#define PCI_ID_COMP(field, value) (((value) == PCI_ANY_ID) || \ + ((field) == (value))) + +struct pci_dev * +pci_get_subsys(unsigned int vendor, unsigned int device, + unsigned int ss_vendor, unsigned int ss_device, struct pci_dev *from) +{ + if (from == NULL && + PCI_ID_COMP(pvr_pci_dev.vendor, vendor) && + PCI_ID_COMP(pvr_pci_dev.device, device) && + PCI_ID_COMP(pvr_pci_dev.subsystem_vendor, ss_vendor) && + PCI_ID_COMP(pvr_pci_dev.subsystem_device, ss_device)) + { + DEBUG_PRINTK(KERN_INFO DRV_MSG_PREFIX_STR "%s: Found %x %x %x %x\n", __FUNCTION__, vendor, device, ss_vendor, ss_device); + + return &pvr_pci_dev; + } + + if (from == NULL) + { + DEBUG_PRINTK(KERN_INFO DRV_MSG_PREFIX_STR "%s: Couldn't find %x %x %x %x\n", __FUNCTION__, vendor, device, ss_vendor, ss_device); + } + + return NULL; +} + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) +int +pci_set_dma_mask(struct pci_dev *dev, u64 mask) +{ + return 0; +} +#endif + +void +pci_unregister_driver(struct pci_driver *drv) +{ +} + +int +__pci_register_driver(struct pci_driver *drv, struct module *owner, + const char *mod_name) +{ + return 0; +} + +int +pci_enable_device(struct pci_dev *dev) +{ + return 0; +} + +void +__bad_cmpxchg(volatile void *ptr, int size) +{ + printk(KERN_ERR DRV_MSG_PREFIX_STR "%s: ptr %p size %u\n", + __FUNCTION__, ptr, size); +} + diff --git a/drivers/gpu/pvr/pvr_drm.c b/drivers/gpu/pvr/pvr_drm.c new file mode 100644 index 00000000000..ed5a0ba5681 --- /dev/null +++ b/drivers/gpu/pvr/pvr_drm.c @@ -0,0 +1,467 @@ +/********************************************************************** + * + * 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 + * + ******************************************************************************/ + +#if defined(SUPPORT_DRI_DRM) + +#ifndef AUTOCONF_INCLUDED + #include <linux/config.h> +#endif + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/version.h> +#include <linux/fs.h> +#include <linux/proc_fs.h> +#include <linux/sched.h> +#include <asm/ioctl.h> +#include <drm/drmP.h> +#include <drm/drm.h> + +#include "img_defs.h" +#include "services.h" +#include "kerneldisplay.h" +#include "kernelbuffer.h" +#include "syscommon.h" +#include "pvrmmap.h" +#include "mm.h" +#include "mmap.h" +#include "mutex.h" +#include "pvr_debug.h" +#include "srvkm.h" +#include "perproc.h" +#include "handle.h" +#include "pvr_bridge_km.h" +#include "pvr_bridge.h" +#include "proc.h" +#include "pvrmodule.h" +#include "pvrversion.h" +#include "lock.h" +#include "linkage.h" +#include "pvr_drm.h" + +#if defined(PVR_DRI_DRM_NOT_PCI) +#include "pvr_drm_mod.h" +#endif + +#define PVR_DRM_NAME PVRSRV_MODNAME +#define PVR_DRM_DESC "Imagination Technologies PVR DRM" + +DECLARE_WAIT_QUEUE_HEAD(sWaitForInit); + +IMG_BOOL bInitComplete; +IMG_BOOL bInitFailed; + +#if !defined(PVR_DRI_DRM_NOT_PCI) +#if defined(PVR_DRI_DRM_PLATFORM_DEV) +struct platform_device *gpsPVRLDMDev; +#else +struct pci_dev *gpsPVRLDMDev; +#endif +#endif + +struct drm_device *gpsPVRDRMDev; + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,24)) +#error "Linux kernel version 2.6.25 or later required for PVR DRM support" +#endif + +#define PVR_DRM_FILE struct drm_file * + +#if !defined(SUPPORT_DRI_DRM_EXT) +#if defined(PVR_DRI_DRM_PLATFORM_DEV) +#if defined(PVR_LDM_PLATFORM_PRE_REGISTERED) +static struct platform_device_id asPlatIdList[] = { + {SYS_SGX_DEV_NAME, 0}, + {} +}; +#endif +#else +static struct pci_device_id asPciIdList[] = { +#if defined(PVR_DRI_DRM_NOT_PCI) + {1, 1, 1, 1, 0, 0, 0}, +#else + {SYS_SGX_DEV_VENDOR_ID, SYS_SGX_DEV_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, +#if defined(SYS_SGX_DEV1_DEVICE_ID) + {SYS_SGX_DEV_VENDOR_ID, SYS_SGX_DEV1_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, +#endif +#endif + {0} +}; +#endif +#endif + +DRI_DRM_STATIC int +PVRSRVDrmLoad(struct drm_device *dev, unsigned long flags) +{ + int iRes = 0; + + PVR_TRACE(("PVRSRVDrmLoad")); + + gpsPVRDRMDev = dev; +#if !defined(PVR_DRI_DRM_NOT_PCI) +#if defined(PVR_DRI_DRM_PLATFORM_DEV) + gpsPVRLDMDev = dev->platformdev; +#else + gpsPVRLDMDev = dev->pdev; +#endif +#endif + +#if defined(PDUMP) + iRes = dbgdrv_init(); + if (iRes != 0) + { + goto exit; + } +#endif + + iRes = PVRCore_Init(); + if (iRes != 0) + { + goto exit_dbgdrv_cleanup; + } + +#if defined(DISPLAY_CONTROLLER) + iRes = PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Init)(dev); + if (iRes != 0) + { + goto exit_pvrcore_cleanup; + } +#endif + goto exit; + +#if defined(DISPLAY_CONTROLLER) +exit_pvrcore_cleanup: + PVRCore_Cleanup(); +#endif +exit_dbgdrv_cleanup: +#if defined(PDUMP) + dbgdrv_cleanup(); +#endif +exit: + if (iRes != 0) + { + bInitFailed = IMG_TRUE; + } + bInitComplete = IMG_TRUE; + + wake_up_interruptible(&sWaitForInit); + + return iRes; +} + +DRI_DRM_STATIC int +PVRSRVDrmUnload(struct drm_device *dev) +{ + PVR_TRACE(("PVRSRVDrmUnload")); + +#if defined(DISPLAY_CONTROLLER) + PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Cleanup)(dev); +#endif + + PVRCore_Cleanup(); + +#if defined(PDUMP) + dbgdrv_cleanup(); +#endif + + return 0; +} + +DRI_DRM_STATIC int +PVRSRVDrmOpen(struct drm_device *dev, struct drm_file *file) +{ + while (!bInitComplete) + { + DEFINE_WAIT(sWait); + + prepare_to_wait(&sWaitForInit, &sWait, TASK_INTERRUPTIBLE); + + if (!bInitComplete) + { + PVR_TRACE(("%s: Waiting for module initialisation to complete", __FUNCTION__)); + + schedule(); + } + + finish_wait(&sWaitForInit, &sWait); + + if (signal_pending(current)) + { + return -ERESTARTSYS; + } + } + + if (bInitFailed) + { + PVR_DPF((PVR_DBG_ERROR, "%s: Module initialisation failed", __FUNCTION__)); + return -EINVAL; + } + + return PVRSRVOpen(dev, file); +} + +#if defined(SUPPORT_DRI_DRM_EXT) && !defined(PVR_LINUX_USING_WORKQUEUES) +DRI_DRM_STATIC void +PVRSRVDrmPostClose(struct drm_device *dev, struct drm_file *file) +{ + PVRSRVRelease(file->driver_priv); + + file->driver_priv = NULL; +} +#else +DRI_DRM_STATIC int +PVRSRVDrmRelease(struct inode *inode, struct file *filp) +{ + struct drm_file *file_priv = filp->private_data; + void *psDriverPriv = file_priv->driver_priv; + int ret; + + ret = drm_release(inode, filp); + + if (ret != 0) + { + + PVR_DPF((PVR_DBG_ERROR, "%s : drm_release failed: %d", + __FUNCTION__, ret)); + } + + PVRSRVRelease(psDriverPriv); + + return 0; +} +#endif + +DRI_DRM_STATIC int +PVRDRMIsMaster(struct drm_device *dev, void *arg, struct drm_file *pFile) +{ + return 0; +} + +#if defined(SUPPORT_DRI_DRM_EXT) +int +PVRDRM_Dummy_ioctl(struct drm_device *dev, void *arg, struct drm_file *pFile) +{ + return 0; +} +#endif + +DRI_DRM_STATIC int +PVRDRMUnprivCmd(struct drm_device *dev, void *arg, struct drm_file *pFile) +{ + int ret = 0; + + LinuxLockMutex(&gPVRSRVLock); + + if (arg == NULL) + { + ret = -EFAULT; + } + else + { + IMG_UINT32 *pui32Args = (IMG_UINT32 *)arg; + IMG_UINT32 ui32Cmd = pui32Args[0]; + IMG_UINT32 *pui32OutArg = (IMG_UINT32 *)arg; + + switch (ui32Cmd) + { + case PVR_DRM_UNPRIV_INIT_SUCCESFUL: + *pui32OutArg = PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL) ? 1 : 0; + break; + + default: + ret = -EFAULT; + } + + } + + LinuxUnLockMutex(&gPVRSRVLock); + + return ret; +} + +#if defined(DISPLAY_CONTROLLER) && defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL) +static int +PVRDRM_Display_ioctl(struct drm_device *dev, void *arg, struct drm_file *pFile) +{ + int res; + + LinuxLockMutex(&gPVRSRVLock); + + res = PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Ioctl)(dev, arg, pFile); + + LinuxUnLockMutex(&gPVRSRVLock); + + return res; +} +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) +#define PVR_DRM_FOPS_IOCTL .unlocked_ioctl +#define PVR_DRM_UNLOCKED DRM_UNLOCKED +#else +#define PVR_DRM_FOPS_IOCTL .ioctl +#define PVR_DRM_UNLOCKED 0 +#endif + +#if !defined(SUPPORT_DRI_DRM_EXT) +struct drm_ioctl_desc sPVRDrmIoctls[] = { + DRM_IOCTL_DEF(PVR_DRM_SRVKM_IOCTL, PVRSRV_BridgeDispatchKM, PVR_DRM_UNLOCKED), + DRM_IOCTL_DEF(PVR_DRM_IS_MASTER_IOCTL, PVRDRMIsMaster, DRM_MASTER | PVR_DRM_UNLOCKED), + DRM_IOCTL_DEF(PVR_DRM_UNPRIV_IOCTL, PVRDRMUnprivCmd, PVR_DRM_UNLOCKED), +#if defined(PDUMP) + DRM_IOCTL_DEF(PVR_DRM_DBGDRV_IOCTL, dbgdrv_ioctl, PVR_DRM_UNLOCKED), +#endif +#if defined(DISPLAY_CONTROLLER) && defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL) + DRM_IOCTL_DEF(PVR_DRM_DISP_IOCTL, PVRDRM_Display_ioctl, DRM_MASTER | PVR_DRM_UNLOCKED) +#endif +}; + +static int pvr_max_ioctl = DRM_ARRAY_SIZE(sPVRDrmIoctls); + +#if defined(PVR_DRI_DRM_PLATFORM_DEV) && !defined(SUPPORT_DRI_DRM_EXT) +static int PVRSRVDrmProbe(struct platform_device *pDevice); +static int PVRSRVDrmRemove(struct platform_device *pDevice); +#endif + +static struct drm_driver sPVRDrmDriver = +{ +#if defined(PVR_DRI_DRM_PLATFORM_DEV) + .driver_features = DRIVER_USE_PLATFORM_DEVICE, +#else + .driver_features = 0, +#endif + .dev_priv_size = 0, + .load = PVRSRVDrmLoad, + .unload = PVRSRVDrmUnload, + .open = PVRSRVDrmOpen, +#if !defined(PVR_DRI_DRM_PLATFORM_DEV) + .suspend = PVRSRVDriverSuspend, + .resume = PVRSRVDriverResume, +#endif + .get_map_ofs = drm_core_get_map_ofs, + .get_reg_ofs = drm_core_get_reg_ofs, + .ioctls = sPVRDrmIoctls, + .fops = + { + .owner = THIS_MODULE, + .open = drm_open, + .release = PVRSRVDrmRelease, + PVR_DRM_FOPS_IOCTL = drm_ioctl, + .mmap = PVRMMap, + .poll = drm_poll, + .fasync = drm_fasync, + }, +#if defined(PVR_DRI_DRM_PLATFORM_DEV) + .platform_driver = + { + .id_table = asPlatIdList, + .driver = + { + .name = PVR_DRM_NAME, + }, + .probe = PVRSRVDrmProbe, + .remove = PVRSRVDrmRemove, + .suspend = PVRSRVDriverSuspend, + .resume = PVRSRVDriverResume, + .shutdown = PVRSRVDriverShutdown, + }, +#else + .pci_driver = + { + .name = PVR_DRM_NAME, + .id_table = asPciIdList, + }, +#endif + .name = PVR_DRM_NAME, + .desc = PVR_DRM_DESC, + .date = PVR_BUILD_DATE, + .major = PVRVERSION_MAJ, + .minor = PVRVERSION_MIN, + .patchlevel = PVRVERSION_BUILD, +}; + +#if defined(PVR_DRI_DRM_PLATFORM_DEV) && !defined(SUPPORT_DRI_DRM_EXT) +static int +PVRSRVDrmProbe(struct platform_device *pDevice) +{ + PVR_TRACE(("PVRSRVDrmProbe")); + + return drm_get_platform_dev(pDevice, &sPVRDrmDriver); +} + +static int +PVRSRVDrmRemove(struct platform_device *pDevice) +{ + PVR_TRACE(("PVRSRVDrmRemove")); + + drm_put_dev(gpsPVRDRMDev); + + return 0; +} + +#endif +static int __init PVRSRVDrmInit(void) +{ + int iRes; + sPVRDrmDriver.num_ioctls = pvr_max_ioctl; + + + PVRDPFInit(); + +#if defined(PVR_DRI_DRM_NOT_PCI) + iRes = drm_pvr_dev_add(); + if (iRes != 0) + { + return iRes; + } +#endif + + iRes = drm_init(&sPVRDrmDriver); +#if defined(PVR_DRI_DRM_NOT_PCI) + if (iRes != 0) + { + drm_pvr_dev_remove(); + } +#endif + return iRes; +} + +static void __exit PVRSRVDrmExit(void) +{ + drm_exit(&sPVRDrmDriver); + +#if defined(PVR_DRI_DRM_NOT_PCI) + drm_pvr_dev_remove(); +#endif +} + +module_init(PVRSRVDrmInit); +module_exit(PVRSRVDrmExit); +#endif +#endif + + diff --git a/drivers/gpu/pvr/pvr_drm.h b/drivers/gpu/pvr/pvr_drm.h new file mode 100644 index 00000000000..4212fafea34 --- /dev/null +++ b/drivers/gpu/pvr/pvr_drm.h @@ -0,0 +1,101 @@ +/********************************************************************** + * + * 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 + * + ******************************************************************************/ + +#if !defined(__PVR_DRM_H__) +#define __PVR_DRM_H__ + +#include "pvr_drm_shared.h" + +#if defined(SUPPORT_DRI_DRM) +#define PVR_DRM_MAKENAME_HELPER(x, y) x ## y +#define PVR_DRM_MAKENAME(x, y) PVR_DRM_MAKENAME_HELPER(x, y) + +#if defined(PVR_DRI_DRM_PLATFORM_DEV) +#define LDM_DEV struct platform_device +#endif + +int PVRCore_Init(void); +void PVRCore_Cleanup(void); +int PVRSRVOpen(struct drm_device *dev, struct drm_file *pFile); +void PVRSRVRelease(void *pvPrivData); + +#if defined(PVR_DRI_DRM_PLATFORM_DEV) +void PVRSRVDriverShutdown(LDM_DEV *pDevice); +int PVRSRVDriverSuspend(LDM_DEV *pDevice, pm_message_t state); +int PVRSRVDriverResume(LDM_DEV *pDevice); +#else +int PVRSRVDriverSuspend(struct drm_device *pDevice, pm_message_t state); +int PVRSRVDriverResume(struct drm_device *pDevice); +#endif + +int PVRSRV_BridgeDispatchKM(struct drm_device *dev, void *arg, struct drm_file *pFile); + +#if defined(SUPPORT_DRI_DRM_EXT) +#define DRI_DRM_STATIC +int PVRSRVDrmLoad(struct drm_device *dev, unsigned long flags); +int PVRSRVDrmUnload(struct drm_device *dev); +int PVRSRVDrmOpen(struct drm_device *dev, struct drm_file *file); +#if defined(PVR_LINUX_USING_WORKQUEUES) +DRI_DRM_STATIC int PVRSRVDrmRelease(struct inode *inode, struct file *filp); +#else +void PVRSRVDrmPostClose(struct drm_device *dev, struct drm_file *file); +#endif +int PVRDRMIsMaster(struct drm_device *dev, IMG_VOID *arg, struct drm_file *pFile); +int PVRDRMUnprivCmd(struct drm_device *dev, IMG_VOID *arg, struct drm_file *pFile); +int PVRDRM_Dummy_ioctl(struct drm_device *dev, IMG_VOID *arg, struct drm_file *pFile); +#else +#define DRI_DRM_STATIC static +#endif + +#if defined(DISPLAY_CONTROLLER) +extern int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Init)(struct drm_device *); +extern void PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Cleanup)(struct drm_device *); +extern int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Suspend)(struct drm_device *); +extern int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Resume)(struct drm_device *); +#if defined(PVR_DISPLAY_CONTROLLER_DRM_IOCTL) +extern int PVR_DRM_MAKENAME(DISPLAY_CONTROLLER, _Ioctl)(struct drm_device *dev, void *arg, struct drm_file *pFile); +#endif +#endif + +#if defined(PDUMP) +int dbgdrv_init(void); +void dbgdrv_cleanup(void); +IMG_INT dbgdrv_ioctl(struct drm_device *dev, IMG_VOID *arg, struct drm_file *pFile); +#endif + +#if !defined(SUPPORT_DRI_DRM_EXT) +#define PVR_DRM_SRVKM_IOCTL _IO(0, PVR_DRM_SRVKM_CMD) +#define PVR_DRM_IS_MASTER_IOCTL _IO(0, PVR_DRM_IS_MASTER_CMD) +#define PVR_DRM_UNPRIV_IOCTL _IO(0, PVR_DRM_UNPRIV_CMD) +#define PVR_DRM_DBGDRV_IOCTL _IO(0, PVR_DRM_DBGDRV_CMD) +#define PVR_DRM_DISP_IOCTL _IO(0, PVR_DRM_DISP_CMD) +#endif + +#endif + +#endif + + diff --git a/drivers/gpu/pvr/pvr_drm_shared.h b/drivers/gpu/pvr/pvr_drm_shared.h new file mode 100644 index 00000000000..a7e9060f53f --- /dev/null +++ b/drivers/gpu/pvr/pvr_drm_shared.h @@ -0,0 +1,54 @@ +/********************************************************************** + * + * 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 + * + ******************************************************************************/ + +#if !defined(__PVR_DRM_SHARED_H__) +#define __PVR_DRM_SHARED_H__ + +#if defined(SUPPORT_DRI_DRM) + +#if defined(SUPPORT_DRI_DRM_EXT) +#define PVR_DRM_SRVKM_CMD DRM_PVR_RESERVED1 +#define PVR_DRM_DISP_CMD DRM_PVR_RESERVED2 +#define PVR_DRM_BC_CMD DRM_PVR_RESERVED3 +#define PVR_DRM_IS_MASTER_CMD DRM_PVR_RESERVED4 +#define PVR_DRM_UNPRIV_CMD DRM_PVR_RESERVED5 +#define PVR_DRM_DBGDRV_CMD DRM_PVR_RESERVED6 +#else +#define PVR_DRM_SRVKM_CMD 0 +#define PVR_DRM_DISP_CMD 1 +#define PVR_DRM_BC_CMD 2 +#define PVR_DRM_IS_MASTER_CMD 3 +#define PVR_DRM_UNPRIV_CMD 4 +#define PVR_DRM_DBGDRV_CMD 5 +#endif + +#define PVR_DRM_UNPRIV_INIT_SUCCESFUL 0 + +#endif + +#endif + + |