1
- /**
2
- * Copyright (C) 2010 ARM Limited. All rights reserved.
3
- *
1
+ /*
2
+ * Copyright (C) 2010, 2012 ARM Limited. All rights reserved.
3
+ *
4
4
* This program is free software and is provided to you under the terms of the GNU General Public License version 2
5
5
* as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6
- *
6
+ *
7
7
* A copy of the licence is included with the program, and can also be obtained from Free Software
8
8
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9
9
*/
10
10
11
- /**
12
- * @file mali_drv.c
13
- * Implementation of the Linux device driver entrypoints for Mali DRM
14
- */
15
- #include <linux/vermagic.h>
16
- #include <drm/drmP.h>
11
+
12
+ #include "mali_drm.h"
17
13
#include "mali_drv.h"
18
14
19
- static struct platform_device * dev0 ;
20
- static struct platform_device * dev1 ;
15
+ static struct platform_device * pdev ;
21
16
22
- void mali_drm_preclose (struct drm_device * dev , struct drm_file * file_priv )
17
+ static int mali_platform_drm_probe (struct platform_device * dev )
23
18
{
19
+ printk (KERN_INFO "DRM: mali_platform_drm_probe()\n" );
20
+ return mali_drm_init (dev );
24
21
}
25
22
26
- void mali_drm_lastclose (struct drm_device * dev )
23
+ static int mali_platform_drm_remove (struct platform_device * dev )
27
24
{
25
+ printk (KERN_INFO "DRM: mali_platform_drm_remove()\n" );
26
+ mali_drm_exit (dev );
27
+ return 0 ;
28
28
}
29
29
30
- static int mali_drm_suspend (struct drm_device * dev , pm_message_t state )
30
+ static int mali_platform_drm_suspend (struct platform_device * dev , pm_message_t state )
31
31
{
32
+ printk (KERN_INFO "DRM: mali_platform_drm_suspend()\n" );
32
33
return 0 ;
33
34
}
34
35
35
- static int mali_drm_resume (struct drm_device * dev )
36
+ static int mali_platform_drm_resume (struct platform_device * dev )
36
37
{
38
+ printk (KERN_INFO "DRM: mali_platform_drm_resume()\n" );
37
39
return 0 ;
38
40
}
39
41
40
- static int mali_drm_load (struct drm_device * dev , unsigned long chipset )
42
+ static char mali_drm_device_name [] = "mali_drm" ;
43
+ static struct platform_driver platform_drm_driver = {
44
+ .probe = mali_platform_drm_probe ,
45
+ .remove = mali_platform_drm_remove ,
46
+ .suspend = mali_platform_drm_suspend ,
47
+ .resume = mali_platform_drm_resume ,
48
+ .driver = {
49
+ .name = mali_drm_device_name ,
50
+ .owner = THIS_MODULE ,
51
+ }
52
+ };
53
+
54
+ static int mali_driver_load (struct drm_device * dev , unsigned long flags )
41
55
{
42
- return 0 ;
56
+ int ret ;
57
+ //unsigned long base, size;
58
+ drm_mali_private_t * dev_priv ;
59
+ printk (KERN_INFO "DRM: mali_driver_load()\n" );
60
+
61
+ dev_priv = kmalloc (sizeof (drm_mali_private_t ), GFP_KERNEL );
62
+ if (dev_priv != NULL )
63
+ memset ((void * )dev_priv , 0 , sizeof (drm_mali_private_t ));
64
+
65
+ if (dev_priv == NULL )
66
+ {
67
+ printk (KERN_INFO "DRM: No memory!\n" );
68
+ return - ENOMEM ;
69
+ }
70
+
71
+ dev -> dev_private = (void * )dev_priv ;
72
+
73
+ if ( NULL == dev -> platformdev )
74
+ {
75
+ dev -> platformdev = platform_device_register_simple (mali_drm_device_name , 0 , NULL , 0 );
76
+ pdev = dev -> platformdev ;
77
+ }
78
+
79
+ #if 0
80
+ base = drm_get_resource_start (dev , 1 );
81
+ size = drm_get_resource_len (dev , 1 );
82
+ #endif
83
+ ret = drm_sman_init (& dev_priv -> sman , 2 , 12 , 8 );
84
+ //if ( ret ) drm_free(dev_priv, sizeof(dev_priv), DRM_MEM_DRIVER);
85
+ if ( ret )
86
+ kfree ( dev_priv );
87
+
88
+ return ret ;
43
89
}
44
90
45
- static int mali_drm_unload ( struct drm_device * dev )
91
+ static int mali_driver_unload ( struct drm_device * dev )
46
92
{
93
+ drm_mali_private_t * dev_priv = dev -> dev_private ;
94
+
95
+ drm_sman_takedown (& dev_priv -> sman );
96
+ //drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
97
+ kfree ( dev_priv );
47
98
return 0 ;
48
99
}
49
100
50
- static struct drm_driver driver =
51
- {
52
- .driver_features = DRIVER_BUS_PLATFORM ,
53
- .load = mali_drm_load ,
54
- .unload = mali_drm_unload ,
55
- .context_dtor = NULL ,
56
- .reclaim_buffers = NULL ,
57
- .reclaim_buffers_idlelocked = NULL ,
58
- .preclose = mali_drm_preclose ,
59
- .lastclose = mali_drm_lastclose ,
60
- .suspend = mali_drm_suspend ,
61
- .resume = mali_drm_resume ,
62
- .ioctls = NULL ,
63
- .fops = {
64
- .owner = THIS_MODULE ,
65
- .open = drm_open ,
66
- .release = drm_release ,
67
- .unlocked_ioctl = drm_ioctl ,
68
- .mmap = drm_mmap ,
69
- .poll = drm_poll ,
70
- .fasync = drm_fasync ,
71
- },
72
- .name = DRIVER_NAME ,
73
- .desc = DRIVER_DESC ,
74
- .date = DRIVER_DATE ,
75
- .major = DRIVER_MAJOR ,
76
- .minor = DRIVER_MINOR ,
77
- .patchlevel = DRIVER_PATCHLEVEL ,
78
- };
79
-
80
- static struct drm_driver driver1 =
101
+ static struct drm_driver driver =
81
102
{
82
103
.driver_features = DRIVER_BUS_PLATFORM ,
83
- .load = mali_drm_load ,
84
- .unload = mali_drm_unload ,
104
+ .load = mali_driver_load ,
105
+ .unload = mali_driver_unload ,
85
106
.context_dtor = NULL ,
107
+ .dma_quiescent = mali_idle ,
86
108
.reclaim_buffers = NULL ,
87
- .reclaim_buffers_idlelocked = NULL ,
88
- .preclose = mali_drm_preclose ,
89
- .lastclose = mali_drm_lastclose ,
90
- .suspend = mali_drm_suspend ,
91
- .resume = mali_drm_resume ,
92
- .ioctls = NULL ,
109
+ .reclaim_buffers_idlelocked = mali_reclaim_buffers_locked ,
110
+ .lastclose = mali_lastclose ,
111
+ .ioctls = mali_ioctls ,
93
112
.fops = {
94
113
.owner = THIS_MODULE ,
95
114
.open = drm_open ,
96
115
.release = drm_release ,
116
+ #if LINUX_VERSION_CODE < KERNEL_VERSION (2 ,6 ,39 )
117
+ .ioctl = drm_ioctl ,
118
+ #else
97
119
.unlocked_ioctl = drm_ioctl ,
120
+ #endif
98
121
.mmap = drm_mmap ,
99
122
.poll = drm_poll ,
100
123
.fasync = drm_fasync ,
@@ -109,74 +132,27 @@ static struct drm_driver driver1 =
109
132
110
133
int mali_drm_init (struct platform_device * dev )
111
134
{
112
- printk (KERN_INFO "Mali DRM initialize, driver name: %s, version %d.%d\n" , DRIVER_NAME , DRIVER_MAJOR , DRIVER_MINOR );
113
- if (dev == dev0 ) {
114
- driver .num_ioctls = 0 ;
115
- driver .kdriver .platform_device = dev ;
116
- return drm_platform_init (& driver , dev );
117
- } else if (dev == dev1 ) {
118
- driver1 .num_ioctls = 0 ;
119
- driver1 .kdriver .platform_device = dev ;
120
- return drm_platform_init (& driver1 , dev );
121
- }
122
- return 0 ;
135
+ printk (KERN_INFO "mali_drm_init(), driver name: %s, version %d.%d\n" , DRIVER_NAME , DRIVER_MAJOR , DRIVER_MINOR );
136
+ driver .num_ioctls = mali_max_ioctl ;
137
+ driver .kdriver .platform_device = dev ;
138
+ return drm_platform_init (& driver , dev );
123
139
}
124
140
125
141
void mali_drm_exit (struct platform_device * dev )
126
142
{
127
- if (driver .kdriver .platform_device == dev ) {
128
- drm_platform_exit (& driver , dev );
129
- } else if (driver1 .kdriver .platform_device == dev ) {
130
- drm_platform_exit (& driver1 , dev );
131
- }
132
- }
133
-
134
- static int __devinit mali_platform_drm_probe (struct platform_device * dev )
135
- {
136
- return mali_drm_init (dev );
143
+ drm_platform_exit (& driver , dev );
137
144
}
138
145
139
- static int mali_platform_drm_remove (struct platform_device * dev )
140
- {
141
- mali_drm_exit (dev );
142
-
143
- return 0 ;
144
- }
145
-
146
- static int mali_platform_drm_suspend (struct platform_device * dev , pm_message_t state )
147
- {
148
- return 0 ;
149
- }
150
-
151
- static int mali_platform_drm_resume (struct platform_device * dev )
152
- {
153
- return 0 ;
154
- }
155
-
156
-
157
- static struct platform_driver platform_drm_driver = {
158
- .probe = mali_platform_drm_probe ,
159
- .remove = __devexit_p (mali_platform_drm_remove ),
160
- .suspend = mali_platform_drm_suspend ,
161
- .resume = mali_platform_drm_resume ,
162
- .driver = {
163
- .owner = THIS_MODULE ,
164
- .name = DRIVER_NAME ,
165
- },
166
- };
167
-
168
146
static int __init mali_platform_drm_init (void )
169
147
{
170
- dev0 = platform_device_register_simple ("mali_drm" , 0 , NULL , 0 );
171
- dev1 = platform_device_register_simple ("mali_drm" , 1 , NULL , 0 );
172
- return platform_driver_register ( & platform_drm_driver );
148
+ pdev = platform_device_register_simple (mali_drm_device_name , 0 , NULL , 0 );
149
+ return platform_driver_register (& platform_drm_driver );
173
150
}
174
151
175
152
static void __exit mali_platform_drm_exit (void )
176
153
{
177
- platform_driver_unregister ( & platform_drm_driver );
178
- platform_device_unregister (dev0 );
179
- platform_device_unregister (dev1 );
154
+ platform_driver_unregister (& platform_drm_driver );
155
+ platform_device_unregister (pdev );
180
156
}
181
157
182
158
#ifdef MODULE
@@ -186,9 +162,7 @@ late_initcall(mali_platform_drm_init);
186
162
#endif
187
163
module_exit (mali_platform_drm_exit );
188
164
189
- MODULE_DESCRIPTION (DRIVER_DESC );
190
- MODULE_VERSION (DRIVER_VERSION );
191
- MODULE_AUTHOR (DRIVER_AUTHOR );
192
- MODULE_LICENSE (DRIVER_LICENSE );
193
- MODULE_ALIAS (DRIVER_ALIAS );
194
165
MODULE_INFO (vermagic , VERMAGIC_STRING );
166
+ MODULE_AUTHOR ("ARM Ltd." );
167
+ MODULE_DESCRIPTION (DRIVER_DESC );
168
+ MODULE_LICENSE ("GPL and additional rights" );
0 commit comments