gpu: pvr: pdump: review use of PDumpSuspended
[sgx.git] / pvr / omaplfb_linux.c
1 /**********************************************************************
2  *
3  * Copyright(c) 2008 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 #include <linux/version.h>
28 #include <linux/module.h>
29
30 #include <linux/pci.h>
31 #include <linux/uaccess.h>
32 #include <linux/slab.h>
33 #include <linux/errno.h>
34 #include <linux/interrupt.h>
35
36 #include <linux/platform_device.h>
37
38 #include <linux/io.h>
39
40 #include "img_defs.h"
41 #include "servicesext.h"
42 #include "kerneldisplay.h"
43 #include "omaplfb.h"
44 #include "pvrmodule.h"
45
46 #include <plat/display.h>
47
48 MODULE_SUPPORTED_DEVICE(DEVNAME);
49
50 #define unref__ __attribute__ ((unused))
51
52 void *OMAPLFBAllocKernelMem(u32 ui32Size)
53 {
54         return kmalloc(ui32Size, GFP_KERNEL);
55 }
56
57 void OMAPLFBFreeKernelMem(void *pvMem)
58 {
59         kfree(pvMem);
60 }
61
62 enum PVRSRV_ERROR OMAPLFBGetLibFuncAddr(char *szFunctionName,
63                IMG_BOOL (**ppfnFuncTable)(struct PVRSRV_DC_DISP2SRV_KMJTABLE *))
64 {
65         if (strcmp("PVRGetDisplayClassJTable", szFunctionName) != 0)
66                 return PVRSRV_ERROR_INVALID_PARAMS;
67
68         *ppfnFuncTable = PVRGetDisplayClassJTable;
69
70         return PVRSRV_OK;
71 }
72
73 static int OMAPLFBDriverSuspend_Entry(struct platform_device unref__ * pDevice,
74                                       pm_message_t unref__ state)
75 {
76         DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX
77                       ": OMAPLFBDriverSuspend_Entry\n"));
78         return 0;
79 }
80
81 static int OMAPLFBDriverResume_Entry(struct platform_device unref__ * pDevice)
82 {
83         DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": OMAPLFBDriverResume_Entry\n"));
84         return 0;
85 }
86
87 static void OMAPLFBDriverShutdown_Entry(struct platform_device unref__ *
88                                         pDevice)
89 {
90         DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX
91                       ": OMAPLFBDriverShutdown_Entry\n"));
92 }
93
94 static void OMAPLFBDeviceRelease_Entry(struct device unref__ * pDevice)
95 {
96         DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX
97                       ": OMAPLFBDriverRelease_Entry\n"));
98 }
99
100 static struct platform_driver omaplfb_driver = {
101         .driver         = {
102                    .name = DRVNAME,
103         },
104         .suspend        = OMAPLFBDriverSuspend_Entry,
105         .resume         = OMAPLFBDriverResume_Entry,
106         .shutdown       = OMAPLFBDriverShutdown_Entry,
107 };
108
109 static struct platform_device omaplfb_device = {
110         .name           = DEVNAME,
111         .id             = -1,
112         .dev            = {
113                 .release = OMAPLFBDeviceRelease_Entry
114         }
115 };
116
117 static int __init OMAPLFB_Init(void)
118 {
119         int error;
120
121         if (OMAPLFBInit() != PVRSRV_OK) {
122                 printk(KERN_WARNING DRIVER_PREFIX
123                        ": OMAPLFB_Init: OMAPLFBInit failed\n");
124                 return -ENODEV;
125         }
126         error = platform_driver_register(&omaplfb_driver);
127         if (error) {
128                 printk(KERN_WARNING DRIVER_PREFIX
129                     ": OMAPLFB_Init: Unable to register platform driver (%d)\n",
130                        error);
131
132                 goto ExitDeinit;
133         }
134
135         error = platform_device_register(&omaplfb_device);
136         if (error) {
137                 printk(KERN_WARNING DRIVER_PREFIX
138                    ": OMAPLFB_Init:  Unable to register platform device (%d)\n",
139                        error);
140
141                 goto ExitDriverUnregister;
142         }
143
144         return 0;
145
146 ExitDriverUnregister:
147         platform_driver_unregister(&omaplfb_driver);
148
149 ExitDeinit:
150         if (OMAPLFBDeinit() != PVRSRV_OK)
151                 printk(KERN_WARNING DRIVER_PREFIX
152                        ": OMAPLFB_Init: OMAPLFBDeinit failed\n");
153
154         return -ENODEV;
155 }
156
157 static void __exit OMAPLFB_Cleanup(void)
158 {
159         platform_device_unregister(&omaplfb_device);
160         platform_driver_unregister(&omaplfb_driver);
161
162         if (OMAPLFBDeinit() != PVRSRV_OK)
163                 printk(KERN_WARNING DRIVER_PREFIX
164                        ": OMAPLFB_Cleanup: OMAPLFBDeinit failed\n");
165 }
166
167 module_init(OMAPLFB_Init);
168 module_exit(OMAPLFB_Cleanup);