aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/pvr/module.c
diff options
context:
space:
mode:
authorChristopher Kenna <cjk@cs.unc.edu>2012-09-20 13:33:17 -0400
committerChristopher Kenna <cjk@cs.unc.edu>2012-09-20 13:33:17 -0400
commit5e0a4919ccb230ab449826ef91bdf38a4ed283e5 (patch)
tree3790db1aa69ed50b08f34c21c1796785df6a0304 /drivers/gpu/pvr/module.c
parentc00613f1fad38acec00ef2c009ae4e73110084ac (diff)
parent5dd038629bdedef22d5ecad2d5e75ad81f4dc694 (diff)
Merge remote-tracking branch 'oneiric-ubuntu/pandaboard' into pandaboard-litmus
Remote branch is from Ubuntu Oneiric (tag Ubuntu-3.0.0-1215.27) with minor patch to the TWL-RTC code. Trying to pull this into LITMUS^RT staging (as of 9/20/2012) to get LITMUS^RT running on the PandaBoard. Conflicts: Makefile fs/exec.c include/linux/fs.h kernel/fork.c
Diffstat (limited to 'drivers/gpu/pvr/module.c')
-rw-r--r--drivers/gpu/pvr/module.c797
1 files changed, 797 insertions, 0 deletions
diff --git a/drivers/gpu/pvr/module.c b/drivers/gpu/pvr/module.c
new file mode 100644
index 00000000000..2cfc77d1d86
--- /dev/null
+++ b/drivers/gpu/pvr/module.c
@@ -0,0 +1,797 @@
1/**********************************************************************
2 *
3 * Copyright (C) Imagination Technologies Ltd. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful but, except
10 * as otherwise stated in writing, without any warranty; without even the
11 * implied warranty of merchantability or fitness for a particular purpose.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
20 *
21 * Contact Information:
22 * Imagination Technologies Ltd. <gpl-support@imgtec.com>
23 * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
24 *
25 ******************************************************************************/
26
27#if defined(SUPPORT_DRI_DRM)
28#define PVR_MOD_STATIC
29#else
30
31 #if defined(LDM_PLATFORM)
32 #define PVR_LDM_PLATFORM_MODULE
33 #define PVR_LDM_MODULE
34 #else
35 #if defined(LDM_PCI)
36 #define PVR_LDM_PCI_MODULE
37 #define PVR_LDM_MODULE
38 #endif
39 #endif
40#define PVR_MOD_STATIC static
41#endif
42
43#if defined(PVR_LDM_PLATFORM_PRE_REGISTERED)
44#if !defined(NO_HARDWARE)
45
46#define PVR_USE_PRE_REGISTERED_PLATFORM_DEV
47#endif
48#endif
49
50#include <linux/init.h>
51#include <linux/kernel.h>
52#include <linux/module.h>
53#include <linux/version.h>
54#include <linux/fs.h>
55#include <linux/proc_fs.h>
56
57#if defined(SUPPORT_DRI_DRM)
58#include <drm/drmP.h>
59#if defined(PVR_SECURE_DRM_AUTH_EXPORT)
60#include "env_perproc.h"
61#endif
62#endif
63
64#if defined(PVR_LDM_PLATFORM_MODULE)
65#include <linux/platform_device.h>
66#endif
67
68#if defined(PVR_LDM_PCI_MODULE)
69#include <linux/pci.h>
70#endif
71
72#if defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL)
73#include <asm/uaccess.h>
74#endif
75
76#include "img_defs.h"
77#include "services.h"
78#include "kerneldisplay.h"
79#include "kernelbuffer.h"
80#include "syscommon.h"
81#include "pvrmmap.h"
82#include "mutils.h"
83#include "mm.h"
84#include "mmap.h"
85#include "mutex.h"
86#include "pvr_debug.h"
87#include "srvkm.h"
88#include "perproc.h"
89#include "handle.h"
90#include "pvr_bridge_km.h"
91#include "proc.h"
92#include "pvrmodule.h"
93#include "private_data.h"
94#include "lock.h"
95#include "linkage.h"
96
97#if defined(SUPPORT_DRI_DRM)
98#include "pvr_drm.h"
99#endif
100#define DRVNAME PVRSRV_MODNAME
101#define DEVNAME PVRSRV_MODNAME
102
103#if defined(SUPPORT_DRI_DRM)
104#define PRIVATE_DATA(pFile) ((pFile)->driver_priv)
105#else
106#define PRIVATE_DATA(pFile) ((pFile)->private_data)
107#endif
108
109MODULE_SUPPORTED_DEVICE(DEVNAME);
110
111#if defined(PVRSRV_NEED_PVR_DPF)
112#include <linux/moduleparam.h>
113extern IMG_UINT32 gPVRDebugLevel;
114module_param(gPVRDebugLevel, uint, 0644);
115MODULE_PARM_DESC(gPVRDebugLevel, "Sets the level of debug output (default 0x7)");
116#endif
117
118
119EXPORT_SYMBOL(PVRGetDisplayClassJTable);
120EXPORT_SYMBOL(PVRGetBufferClassJTable);
121
122#if defined(PVR_LDM_MODULE)
123static struct class *psPvrClass;
124#endif
125
126#if !defined(SUPPORT_DRI_DRM)
127static int AssignedMajorNumber;
128
129static int PVRSRVOpen(struct inode* pInode, struct file* pFile);
130static int PVRSRVRelease(struct inode* pInode, struct file* pFile);
131
132static struct file_operations pvrsrv_fops =
133{
134 .owner=THIS_MODULE,
135 .unlocked_ioctl = PVRSRV_BridgeDispatchKM,
136 .open=PVRSRVOpen,
137 .release=PVRSRVRelease,
138 .mmap=PVRMMap,
139};
140#endif
141
142PVRSRV_LINUX_MUTEX gPVRSRVLock;
143
144IMG_UINT32 gui32ReleasePID;
145
146#if defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL)
147static IMG_UINT32 gPVRPowerLevel;
148#endif
149
150#if defined(PVR_LDM_MODULE)
151
152#if defined(PVR_LDM_PLATFORM_MODULE)
153#define LDM_DEV struct platform_device
154#define LDM_DRV struct platform_driver
155#endif
156
157#if defined(PVR_LDM_PCI_MODULE)
158#define LDM_DEV struct pci_dev
159#define LDM_DRV struct pci_driver
160#endif
161#if defined(PVR_LDM_PLATFORM_MODULE)
162static int PVRSRVDriverRemove(LDM_DEV *device);
163static int PVRSRVDriverProbe(LDM_DEV *device);
164#endif
165#if defined(PVR_LDM_PCI_MODULE)
166static void PVRSRVDriverRemove(LDM_DEV *device);
167static int PVRSRVDriverProbe(LDM_DEV *device, const struct pci_device_id *id);
168#endif
169static int PVRSRVDriverSuspend(LDM_DEV *device, pm_message_t state);
170static void PVRSRVDriverShutdown(LDM_DEV *device);
171static int PVRSRVDriverResume(LDM_DEV *device);
172
173#if defined(PVR_LDM_PCI_MODULE)
174struct pci_device_id powervr_id_table[] __devinitdata = {
175 {PCI_DEVICE(SYS_SGX_DEV_VENDOR_ID, SYS_SGX_DEV_DEVICE_ID)},
176#if defined (SYS_SGX_DEV1_DEVICE_ID)
177 {PCI_DEVICE(SYS_SGX_DEV_VENDOR_ID, SYS_SGX_DEV1_DEVICE_ID)},
178#endif
179 {0}
180};
181
182MODULE_DEVICE_TABLE(pci, powervr_id_table);
183#endif
184
185#if defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)
186static struct platform_device_id powervr_id_table[] __devinitdata = {
187 {SYS_SGX_DEV_NAME, 0},
188 {}
189};
190#endif
191
192static LDM_DRV powervr_driver = {
193#if defined(PVR_LDM_PLATFORM_MODULE)
194 .driver = {
195 .name = DRVNAME,
196 },
197#endif
198#if defined(PVR_LDM_PCI_MODULE)
199 .name = DRVNAME,
200#endif
201#if defined(PVR_LDM_PCI_MODULE) || defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)
202 .id_table = powervr_id_table,
203#endif
204 .probe = PVRSRVDriverProbe,
205#if defined(PVR_LDM_PLATFORM_MODULE)
206 .remove = PVRSRVDriverRemove,
207#endif
208#if defined(PVR_LDM_PCI_MODULE)
209 .remove = __devexit_p(PVRSRVDriverRemove),
210#endif
211 .suspend = PVRSRVDriverSuspend,
212 .resume = PVRSRVDriverResume,
213 .shutdown = PVRSRVDriverShutdown,
214};
215
216LDM_DEV *gpsPVRLDMDev;
217
218// #if defined(MODULE) &&
219#if defined(PVR_LDM_PLATFORM_MODULE) && \
220 !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)
221static void PVRSRVDeviceRelease(struct device unref__ *pDevice)
222{
223}
224
225static struct platform_device powervr_device = {
226 .name = DEVNAME,
227 .id = -1,
228 .dev = {
229 .release = PVRSRVDeviceRelease
230 }
231};
232#endif
233
234#if defined(PVR_LDM_PLATFORM_MODULE)
235static int PVRSRVDriverProbe(LDM_DEV *pDevice)
236#endif
237#if defined(PVR_LDM_PCI_MODULE)
238static int __devinit PVRSRVDriverProbe(LDM_DEV *pDevice, const struct pci_device_id *id)
239#endif
240{
241 SYS_DATA *psSysData;
242
243 pr_err("*********** PVRSRVDriverProbe\n");
244
245 PVR_TRACE(("PVRSRVDriverProbe(pDevice=%p)", pDevice));
246
247#if 0
248
249 if (PerDeviceSysInitialise((IMG_PVOID)pDevice) != PVRSRV_OK)
250 {
251 return -EINVAL;
252 }
253#endif
254
255 psSysData = SysAcquireDataNoCheck();
256 if ( psSysData == IMG_NULL)
257 {
258 gpsPVRLDMDev = pDevice;
259
260 pr_err("********** calling SysInitialise\n");
261
262
263 if (SysInitialise() != PVRSRV_OK)
264 {
265 return -ENODEV;
266 }
267 }
268
269 return 0;
270}
271
272
273#if defined (PVR_LDM_PLATFORM_MODULE)
274static int PVRSRVDriverRemove(LDM_DEV *pDevice)
275#endif
276#if defined(PVR_LDM_PCI_MODULE)
277static void __devexit PVRSRVDriverRemove(LDM_DEV *pDevice)
278#endif
279{
280 SYS_DATA *psSysData;
281
282 PVR_TRACE(("PVRSRVDriverRemove(pDevice=%p)", pDevice));
283
284 SysAcquireData(&psSysData);
285
286#if defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL)
287 if (gPVRPowerLevel != 0)
288 {
289 if (PVRSRVSetPowerStateKM(PVRSRV_SYS_POWER_STATE_D0) == PVRSRV_OK)
290 {
291 gPVRPowerLevel = 0;
292 }
293 }
294#endif
295 (void) SysDeinitialise(psSysData);
296
297 gpsPVRLDMDev = IMG_NULL;
298
299#if 0
300 if (PerDeviceSysDeInitialise((IMG_PVOID)pDevice) != PVRSRV_OK)
301 {
302 return -EINVAL;
303 }
304#endif
305
306#if defined (PVR_LDM_PLATFORM_MODULE)
307 return 0;
308#endif
309#if defined (PVR_LDM_PCI_MODULE)
310 return;
311#endif
312}
313#endif
314
315
316#if defined(PVR_LDM_MODULE) || defined(PVR_DRI_DRM_PLATFORM_DEV)
317PVR_MOD_STATIC void PVRSRVDriverShutdown(LDM_DEV *pDevice)
318{
319 PVR_TRACE(("PVRSRVDriverShutdown(pDevice=%p)", pDevice));
320
321 (void) PVRSRVSetPowerStateKM(PVRSRV_SYS_POWER_STATE_D3);
322}
323
324#endif
325
326
327#if defined(PVR_LDM_MODULE) || defined(SUPPORT_DRI_DRM)
328#if defined(SUPPORT_DRI_DRM) && !defined(PVR_DRI_DRM_PLATFORM_DEV)
329int PVRSRVDriverSuspend(struct drm_device *pDevice, pm_message_t state)
330#else
331PVR_MOD_STATIC int PVRSRVDriverSuspend(LDM_DEV *pDevice, pm_message_t state)
332#endif
333{
334#if !(defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL) && !defined(SUPPORT_DRI_DRM))
335 PVR_TRACE(( "PVRSRVDriverSuspend(pDevice=%p)", pDevice));
336
337 if (PVRSRVSetPowerStateKM(PVRSRV_SYS_POWER_STATE_D3) != PVRSRV_OK)
338 {
339 return -EINVAL;
340 }
341#endif
342 return 0;
343}
344
345
346#if defined(SUPPORT_DRI_DRM) && !defined(PVR_DRI_DRM_PLATFORM_DEV)
347int PVRSRVDriverResume(struct drm_device *pDevice)
348#else
349PVR_MOD_STATIC int PVRSRVDriverResume(LDM_DEV *pDevice)
350#endif
351{
352#if !(defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL) && !defined(SUPPORT_DRI_DRM))
353 PVR_TRACE(("PVRSRVDriverResume(pDevice=%p)", pDevice));
354
355 if (PVRSRVSetPowerStateKM(PVRSRV_SYS_POWER_STATE_D0) != PVRSRV_OK)
356 {
357 return -EINVAL;
358 }
359#endif
360 return 0;
361}
362#endif
363
364
365#if defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL) && !defined(SUPPORT_DRI_DRM)
366IMG_INT PVRProcSetPowerLevel(struct file *file, const IMG_CHAR *buffer, IMG_UINT32 count, IMG_VOID *data)
367{
368 IMG_CHAR data_buffer[2];
369 IMG_UINT32 PVRPowerLevel;
370
371 if (count != sizeof(data_buffer))
372 {
373 return -EINVAL;
374 }
375 else
376 {
377 if (copy_from_user(data_buffer, buffer, count))
378 return -EINVAL;
379 if (data_buffer[count - 1] != '\n')
380 return -EINVAL;
381 PVRPowerLevel = data_buffer[0] - '0';
382 if (PVRPowerLevel != gPVRPowerLevel)
383 {
384 if (PVRPowerLevel != 0)
385 {
386 if (PVRSRVSetPowerStateKM(PVRSRV_SYS_POWER_STATE_D3) != PVRSRV_OK)
387 {
388 return -EINVAL;
389 }
390 }
391 else
392 {
393 if (PVRSRVSetPowerStateKM(PVRSRV_SYS_POWER_STATE_D0) != PVRSRV_OK)
394 {
395 return -EINVAL;
396 }
397 }
398
399 gPVRPowerLevel = PVRPowerLevel;
400 }
401 }
402 return (count);
403}
404
405void ProcSeqShowPowerLevel(struct seq_file *sfile,void* el)
406{
407 seq_printf(sfile, "%lu\n", gPVRPowerLevel);
408}
409
410#endif
411
412#if defined(SUPPORT_DRI_DRM)
413int PVRSRVOpen(struct drm_device unref__ *dev, struct drm_file *pFile)
414#else
415static int PVRSRVOpen(struct inode unref__ * pInode, struct file *pFile)
416#endif
417{
418 PVRSRV_FILE_PRIVATE_DATA *psPrivateData;
419 IMG_HANDLE hBlockAlloc;
420 int iRet = -ENOMEM;
421 PVRSRV_ERROR eError;
422 IMG_UINT32 ui32PID;
423#if defined(SUPPORT_DRI_DRM) && defined(PVR_SECURE_DRM_AUTH_EXPORT)
424 PVRSRV_ENV_PER_PROCESS_DATA *psEnvPerProc;
425#endif
426
427 LinuxLockMutex(&gPVRSRVLock);
428
429 ui32PID = OSGetCurrentProcessIDKM();
430
431 if (PVRSRVProcessConnect(ui32PID, 0) != PVRSRV_OK)
432 goto err_unlock;
433
434#if defined(SUPPORT_DRI_DRM) && defined(PVR_SECURE_DRM_AUTH_EXPORT)
435 psEnvPerProc = PVRSRVPerProcessPrivateData(ui32PID);
436 if (psEnvPerProc == IMG_NULL)
437 {
438 PVR_DPF((PVR_DBG_ERROR, "%s: No per-process private data", __FUNCTION__));
439 goto err_unlock;
440 }
441#endif
442
443 eError = OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
444 sizeof(PVRSRV_FILE_PRIVATE_DATA),
445 (IMG_PVOID *)&psPrivateData,
446 &hBlockAlloc,
447 "File Private Data");
448
449 if(eError != PVRSRV_OK)
450 goto err_unlock;
451
452#if defined (SUPPORT_SID_INTERFACE)
453 psPrivateData->hKernelMemInfo = 0;
454#else
455 psPrivateData->hKernelMemInfo = NULL;
456#endif
457#if defined(SUPPORT_DRI_DRM) && defined(PVR_SECURE_DRM_AUTH_EXPORT)
458 psPrivateData->psDRMFile = pFile;
459
460 list_add_tail(&psPrivateData->sDRMAuthListItem, &psEnvPerProc->sDRMAuthListHead);
461#endif
462 psPrivateData->ui32OpenPID = ui32PID;
463 psPrivateData->hBlockAlloc = hBlockAlloc;
464 PRIVATE_DATA(pFile) = psPrivateData;
465 iRet = 0;
466err_unlock:
467 LinuxUnLockMutex(&gPVRSRVLock);
468 return iRet;
469}
470
471
472#if defined(SUPPORT_DRI_DRM)
473void PVRSRVRelease(void *pvPrivData)
474#else
475static int PVRSRVRelease(struct inode unref__ * pInode, struct file *pFile)
476#endif
477{
478 PVRSRV_FILE_PRIVATE_DATA *psPrivateData;
479
480 LinuxLockMutex(&gPVRSRVLock);
481
482#if defined(SUPPORT_DRI_DRM)
483 psPrivateData = (PVRSRV_FILE_PRIVATE_DATA *)pvPrivData;
484#else
485 psPrivateData = PRIVATE_DATA(pFile);
486#endif
487 if (psPrivateData != IMG_NULL)
488 {
489#if defined(SUPPORT_DRI_DRM) && defined(PVR_SECURE_DRM_AUTH_EXPORT)
490 list_del(&psPrivateData->sDRMAuthListItem);
491#endif
492
493
494 gui32ReleasePID = psPrivateData->ui32OpenPID;
495 PVRSRVProcessDisconnect(psPrivateData->ui32OpenPID);
496 gui32ReleasePID = 0;
497
498 OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
499 sizeof(PVRSRV_FILE_PRIVATE_DATA),
500 psPrivateData, psPrivateData->hBlockAlloc);
501
502#if !defined(SUPPORT_DRI_DRM)
503 PRIVATE_DATA(pFile) = IMG_NULL;
504#endif
505 }
506
507 LinuxUnLockMutex(&gPVRSRVLock);
508
509#if !defined(SUPPORT_DRI_DRM)
510 return 0;
511#endif
512}
513
514
515//#if defined(SUPPORT_DRI_DRM)
516int PVRCore_Init(void)
517//#else
518//static int __init PVRCore_Init(void)
519//#endif
520{
521 int error;
522#if !defined(PVR_LDM_MODULE)
523 PVRSRV_ERROR eError;
524#else
525 struct device *psDev;
526#endif
527
528#if !defined(SUPPORT_DRI_DRM)
529
530 PVRDPFInit();
531#endif
532 pr_err("************************ PVRCore_Init\n");
533
534 LinuxInitMutex(&gPVRSRVLock);
535
536 if (CreateProcEntries ())
537 {
538 error = -ENOMEM;
539 return error;
540 }
541
542 pr_err("************************ PVRCore_Init 2\n");
543
544 if (PVROSFuncInit() != PVRSRV_OK)
545 {
546 error = -ENOMEM;
547 goto init_failed;
548 }
549
550 pr_err("************************ PVRCore_Init 3\n");
551
552
553 PVRLinuxMUtilsInit();
554
555 pr_err("************************ PVRCore_Init 4\n");
556
557
558 if(LinuxMMInit() != PVRSRV_OK)
559 {
560 error = -ENOMEM;
561 goto init_failed;
562 }
563
564 pr_err("************************ PVRCore_Init 5\n");
565
566
567 LinuxBridgeInit();
568
569 pr_err("************************ PVRCore_Init 6\n");
570
571
572 PVRMMapInit();
573
574#if defined(PVR_LDM_MODULE)
575
576#if defined(PVR_LDM_PLATFORM_MODULE)
577 if ((error = platform_driver_register(&powervr_driver)) != 0)
578 {
579 PVR_DPF((PVR_DBG_ERROR, "PVRCore_Init: unable to register platform driver (%d)", error));
580
581 goto init_failed;
582 }
583
584//#if defined(MODULE) && !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)
585#if !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)
586
587 pr_err("****************** Registering device\n");
588
589 if ((error = platform_device_register(&powervr_device)) != 0)
590 {
591 platform_driver_unregister(&powervr_driver);
592
593 PVR_DPF((PVR_DBG_ERROR, "PVRCore_Init: unable to register platform device (%d)", error));
594
595 goto init_failed;
596 }
597#endif
598#endif
599
600 pr_err("************************ PVRCore_Init 7\n");
601
602
603#if defined(PVR_LDM_PCI_MODULE)
604 if ((error = pci_register_driver(&powervr_driver)) != 0)
605 {
606 PVR_DPF((PVR_DBG_ERROR, "PVRCore_Init: unable to register PCI driver (%d)", error));
607
608 goto init_failed;
609 }
610#endif
611
612#else
613
614 pr_err("************************ PVRCore_Init 8\n");
615
616
617 if ((eError = SysInitialise()) != PVRSRV_OK)
618 {
619 error = -ENODEV;
620#if defined(TCF_REV) && (TCF_REV == 110)
621 if(eError == PVRSRV_ERROR_NOT_SUPPORTED)
622 {
623 printk("\nAtlas wrapper (FPGA image) version mismatch");
624 error = -ENODEV;
625 }
626#endif
627 goto init_failed;
628 }
629#endif
630
631#if !defined(SUPPORT_DRI_DRM)
632 AssignedMajorNumber = register_chrdev(0, DEVNAME, &pvrsrv_fops);
633
634 if (AssignedMajorNumber <= 0)
635 {
636 PVR_DPF((PVR_DBG_ERROR, "PVRCore_Init: unable to get major number"));
637
638 error = -EBUSY;
639 goto sys_deinit;
640 }
641
642 PVR_TRACE(("PVRCore_Init: major device %d", AssignedMajorNumber));
643#endif
644
645#if defined(PVR_LDM_MODULE)
646
647 psPvrClass = class_create(THIS_MODULE, "pvr");
648
649 if (IS_ERR(psPvrClass))
650 {
651 PVR_DPF((PVR_DBG_ERROR, "PVRCore_Init: unable to create class (%ld)", PTR_ERR(psPvrClass)));
652 error = -EBUSY;
653 goto unregister_device;
654 }
655
656 psDev = device_create(psPvrClass, NULL, MKDEV(AssignedMajorNumber, 0),
657#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26))
658 NULL,
659#endif
660 DEVNAME);
661 if (IS_ERR(psDev))
662 {
663 PVR_DPF((PVR_DBG_ERROR, "PVRCore_Init: unable to create device (%ld)", PTR_ERR(psDev)));
664 error = -EBUSY;
665 goto destroy_class;
666 }
667#endif
668
669 return 0;
670
671#if defined(PVR_LDM_MODULE)
672destroy_class:
673 class_destroy(psPvrClass);
674unregister_device:
675 unregister_chrdev((IMG_UINT)AssignedMajorNumber, DRVNAME);
676#endif
677#if !defined(SUPPORT_DRI_DRM)
678sys_deinit:
679#endif
680#if defined(PVR_LDM_MODULE)
681#if defined(PVR_LDM_PCI_MODULE)
682 pci_unregister_driver(&powervr_driver);
683#endif
684
685#if defined (PVR_LDM_PLATFORM_MODULE)
686#if defined(MODULE) && !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)
687 platform_device_unregister(&powervr_device);
688#endif
689 platform_driver_unregister(&powervr_driver);
690#endif
691
692#else
693
694 {
695 SYS_DATA *psSysData;
696
697 psSysData = SysAcquireDataNoCheck();
698 if (psSysData != IMG_NULL)
699 {
700 (void) SysDeinitialise(psSysData);
701 }
702 }
703#endif
704init_failed:
705
706 pr_err("************************ PVRCore_Init FAILED\n");
707
708 PVRMMapCleanup();
709 LinuxMMCleanup();
710 LinuxBridgeDeInit();
711 PVROSFuncDeInit();
712 RemoveProcEntries();
713
714 return error;
715
716}
717
718
719#if defined(SUPPORT_DRI_DRM)
720void PVRCore_Cleanup(void)
721#else
722static void __exit PVRCore_Cleanup(void)
723#endif
724{
725#if !defined(PVR_LDM_MODULE)
726 SYS_DATA *psSysData;
727#endif
728 PVR_TRACE(("PVRCore_Cleanup"));
729
730#if !defined(PVR_LDM_MODULE)
731 SysAcquireData(&psSysData);
732#endif
733
734#if defined(PVR_LDM_MODULE)
735 device_destroy(psPvrClass, MKDEV(AssignedMajorNumber, 0));
736 class_destroy(psPvrClass);
737#endif
738
739#if !defined(SUPPORT_DRI_DRM)
740#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,22))
741 if (
742#endif
743 unregister_chrdev((IMG_UINT)AssignedMajorNumber, DRVNAME)
744#if !(LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,22))
745 ;
746#else
747 )
748 {
749 PVR_DPF((PVR_DBG_ERROR," can't unregister device major %d", AssignedMajorNumber));
750 }
751#endif
752#endif
753
754#if defined(PVR_LDM_MODULE)
755
756#if defined(PVR_LDM_PCI_MODULE)
757 pci_unregister_driver(&powervr_driver);
758#endif
759
760#if defined (PVR_LDM_PLATFORM_MODULE)
761#if defined(MODULE) && !defined(PVR_USE_PRE_REGISTERED_PLATFORM_DEV)
762 platform_device_unregister(&powervr_device);
763#endif
764 platform_driver_unregister(&powervr_driver);
765#endif
766
767#else
768#if defined(DEBUG) && defined(PVR_MANUAL_POWER_CONTROL)
769 if (gPVRPowerLevel != 0)
770 {
771 if (PVRSRVSetPowerStateKM(PVRSRV_SYS_POWER_STATE_D0) == PVRSRV_OK)
772 {
773 gPVRPowerLevel = 0;
774 }
775 }
776#endif
777
778 (void) SysDeinitialise(psSysData);
779#endif
780
781 PVRMMapCleanup();
782
783 LinuxMMCleanup();
784
785 LinuxBridgeDeInit();
786
787 PVROSFuncDeInit();
788
789 RemoveProcEntries();
790
791 PVR_TRACE(("PVRCore_Cleanup: unloading"));
792}
793
794#if !defined(SUPPORT_DRI_DRM)
795module_init(PVRCore_Init);
796module_exit(PVRCore_Cleanup);
797#endif