aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpu/pvr/omaplfb_linux.c
blob: bba3bbd345f3819f8f107bcec64ceb000c4eb0d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/**********************************************************************
 *
 * Copyright(c) 2008 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/module.h>

#include <linux/pci.h>
#include <linux/uaccess.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/interrupt.h>

#include <linux/platform_device.h>

#include <linux/io.h>

#include "img_defs.h"
#include "servicesext.h"
#include "kerneldisplay.h"
#include "omaplfb.h"
#include "pvrmodule.h"

#include <video/omapdss.h>

MODULE_SUPPORTED_DEVICE(DEVNAME);

#define unref__ __attribute__ ((unused))

void *OMAPLFBAllocKernelMem(u32 ui32Size)
{
	return kmalloc(ui32Size, GFP_KERNEL);
}

void OMAPLFBFreeKernelMem(void *pvMem)
{
	kfree(pvMem);
}

enum PVRSRV_ERROR OMAPLFBGetLibFuncAddr(char *szFunctionName,
	       IMG_BOOL (**ppfnFuncTable)(struct PVRSRV_DC_DISP2SRV_KMJTABLE *))
{
	if (strcmp("PVRGetDisplayClassJTable", szFunctionName) != 0)
		return PVRSRV_ERROR_INVALID_PARAMS;

	*ppfnFuncTable = PVRGetDisplayClassJTable;

	return PVRSRV_OK;
}

static int OMAPLFBDriverSuspend_Entry(struct platform_device unref__ * pDevice,
				      pm_message_t unref__ state)
{
	DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX
		      ": OMAPLFBDriverSuspend_Entry\n"));
	return 0;
}

static int OMAPLFBDriverResume_Entry(struct platform_device unref__ * pDevice)
{
	DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": OMAPLFBDriverResume_Entry\n"));
	return 0;
}

static void OMAPLFBDriverShutdown_Entry(struct platform_device unref__ *
					pDevice)
{
	DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX
		      ": OMAPLFBDriverShutdown_Entry\n"));
}

static void OMAPLFBDeviceRelease_Entry(struct device unref__ * pDevice)
{
	DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX
		      ": OMAPLFBDriverRelease_Entry\n"));
}

static struct platform_driver omaplfb_driver = {
	.driver		= {
		   .name = DRVNAME,
	},
	.suspend	= OMAPLFBDriverSuspend_Entry,
	.resume		= OMAPLFBDriverResume_Entry,
	.shutdown	= OMAPLFBDriverShutdown_Entry,
};

static struct platform_device omaplfb_device = {
	.name		= DEVNAME,
	.id		= -1,
	.dev		= {
		.release = OMAPLFBDeviceRelease_Entry
	}
};

static int __init OMAPLFB_Init(void)
{
	int error;

	if (OMAPLFBInit() != PVRSRV_OK) {
		printk(KERN_WARNING DRIVER_PREFIX
		       ": OMAPLFB_Init: OMAPLFBInit failed\n");
		return -ENODEV;
	}
	error = platform_driver_register(&omaplfb_driver);
	if (error) {
		printk(KERN_WARNING DRIVER_PREFIX
		    ": OMAPLFB_Init: Unable to register platform driver (%d)\n",
		       error);

		goto ExitDeinit;
	}

	error = platform_device_register(&omaplfb_device);
	if (error) {
		printk(KERN_WARNING DRIVER_PREFIX
		   ": OMAPLFB_Init:  Unable to register platform device (%d)\n",
		       error);

		goto ExitDriverUnregister;
	}

	return 0;

ExitDriverUnregister:
	platform_driver_unregister(&omaplfb_driver);

ExitDeinit:
	if (OMAPLFBDeinit() != PVRSRV_OK)
		printk(KERN_WARNING DRIVER_PREFIX
		       ": OMAPLFB_Init: OMAPLFBDeinit failed\n");

	return -ENODEV;
}

static void __exit OMAPLFB_Cleanup(void)
{
	platform_device_unregister(&omaplfb_device);
	platform_driver_unregister(&omaplfb_driver);

	if (OMAPLFBDeinit() != PVRSRV_OK)
		printk(KERN_WARNING DRIVER_PREFIX
		       ": OMAPLFB_Cleanup: OMAPLFBDeinit failed\n");
}

module_init(OMAPLFB_Init);
module_exit(OMAPLFB_Cleanup);