Subversion Repositories Kolibri OS

Rev

Rev 3260 | Rev 5060 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3260 Rev 4104
1
/**
1
/**
2
 * \file drm_stub.h
2
 * \file drm_stub.h
3
 * Stub support
3
 * Stub support
4
 *
4
 *
5
 * \author Rickard E. (Rik) Faith 
5
 * \author Rickard E. (Rik) Faith 
6
 */
6
 */
7
 
7
 
8
/*
8
/*
9
 * Created: Fri Jan 19 10:48:35 2001 by faith@acm.org
9
 * Created: Fri Jan 19 10:48:35 2001 by faith@acm.org
10
 *
10
 *
11
 * Copyright 2001 VA Linux Systems, Inc., Sunnyvale, California.
11
 * Copyright 2001 VA Linux Systems, Inc., Sunnyvale, California.
12
 * All Rights Reserved.
12
 * All Rights Reserved.
13
 *
13
 *
14
 * Permission is hereby granted, free of charge, to any person obtaining a
14
 * Permission is hereby granted, free of charge, to any person obtaining a
15
 * copy of this software and associated documentation files (the "Software"),
15
 * copy of this software and associated documentation files (the "Software"),
16
 * to deal in the Software without restriction, including without limitation
16
 * to deal in the Software without restriction, including without limitation
17
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18
 * and/or sell copies of the Software, and to permit persons to whom the
18
 * and/or sell copies of the Software, and to permit persons to whom the
19
 * Software is furnished to do so, subject to the following conditions:
19
 * Software is furnished to do so, subject to the following conditions:
20
 *
20
 *
21
 * The above copyright notice and this permission notice (including the next
21
 * The above copyright notice and this permission notice (including the next
22
 * paragraph) shall be included in all copies or substantial portions of the
22
 * paragraph) shall be included in all copies or substantial portions of the
23
 * Software.
23
 * Software.
24
 *
24
 *
25
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
27
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
28
 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
28
 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
29
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
29
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
30
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
31
 * DEALINGS IN THE SOFTWARE.
31
 * DEALINGS IN THE SOFTWARE.
32
 */
32
 */
33
 
33
 
34
#include 
34
#include 
35
 
35
 
36
#include 
36
#include 
37
#include 
37
#include 
-
 
38
#include 
38
 
39
 
39
struct va_format {
40
struct va_format {
40
    const char *fmt;
41
    const char *fmt;
41
    va_list *va;
42
    va_list *va;
42
};
43
};
43
 
44
 
44
unsigned int drm_debug = 0;	/* 1 to enable debug output */
45
unsigned int drm_debug = 0;	/* 1 to enable debug output */
45
EXPORT_SYMBOL(drm_debug);
46
EXPORT_SYMBOL(drm_debug);
-
 
47
 
-
 
48
unsigned int drm_rnodes = 0;	/* 1 to enable experimental render nodes API */
-
 
49
EXPORT_SYMBOL(drm_rnodes);
46
 
50
 
47
unsigned int drm_vblank_offdelay = 5000;    /* Default to 5000 msecs. */
51
unsigned int drm_vblank_offdelay = 5000;    /* Default to 5000 msecs. */
48
EXPORT_SYMBOL(drm_vblank_offdelay);
52
EXPORT_SYMBOL(drm_vblank_offdelay);
49
 
53
 
50
unsigned int drm_timestamp_precision = 20;  /* Default to 20 usecs. */
54
unsigned int drm_timestamp_precision = 20;  /* Default to 20 usecs. */
51
EXPORT_SYMBOL(drm_timestamp_precision);
55
EXPORT_SYMBOL(drm_timestamp_precision);
-
 
56
 
52
 
57
struct idr drm_minors_idr;
53
int drm_err(const char *func, const char *format, ...)
58
int drm_err(const char *func, const char *format, ...)
54
{
59
{
55
	struct va_format vaf;
60
	struct va_format vaf;
56
	va_list args;
61
	va_list args;
57
	int r;
62
	int r;
58
 
63
 
59
	va_start(args, format);
64
	va_start(args, format);
60
 
65
 
61
	vaf.fmt = format;
66
	vaf.fmt = format;
62
	vaf.va = &args;
67
	vaf.va = &args;
63
 
68
 
64
	r = printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* %pV", func, &vaf);
69
	r = printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* %pV", func, &vaf);
65
 
70
 
66
	va_end(args);
71
	va_end(args);
67
 
72
 
68
	return r;
73
	return r;
69
}
74
}
70
EXPORT_SYMBOL(drm_err);
75
EXPORT_SYMBOL(drm_err);
71
 
76
 
72
void drm_ut_debug_printk(unsigned int request_level,
77
void drm_ut_debug_printk(unsigned int request_level,
73
			 const char *prefix,
78
			 const char *prefix,
74
			 const char *function_name,
79
			 const char *function_name,
75
			 const char *format, ...)
80
			 const char *format, ...)
76
{
81
{
77
	va_list args;
82
	va_list args;
78
 
83
 
79
//   if (drm_debug & request_level) {
84
//   if (drm_debug & request_level) {
80
//       if (function_name)
85
//       if (function_name)
81
//           printk(KERN_DEBUG "[%s:%s], ", prefix, function_name);
86
//           printk(KERN_DEBUG "[%s:%s], ", prefix, function_name);
82
//       va_start(args, format);
87
//       va_start(args, format);
83
//       vprintk(format, args);
88
//       vprintk(format, args);
84
//       va_end(args);
89
//       va_end(args);
85
//   }
90
//   }
86
}
91
}
87
EXPORT_SYMBOL(drm_ut_debug_printk);
92
EXPORT_SYMBOL(drm_ut_debug_printk);
-
 
93
 
-
 
94
int drm_fill_in_dev(struct drm_device *dev,
-
 
95
			   const struct pci_device_id *ent,
-
 
96
			   struct drm_driver *driver)
-
 
97
{
-
 
98
	int retcode;
-
 
99
 
-
 
100
	INIT_LIST_HEAD(&dev->filelist);
-
 
101
	INIT_LIST_HEAD(&dev->ctxlist);
-
 
102
	INIT_LIST_HEAD(&dev->vmalist);
-
 
103
	INIT_LIST_HEAD(&dev->maplist);
-
 
104
	INIT_LIST_HEAD(&dev->vblank_event_list);
-
 
105
 
-
 
106
	spin_lock_init(&dev->count_lock);
-
 
107
	spin_lock_init(&dev->event_lock);
-
 
108
	mutex_init(&dev->struct_mutex);
-
 
109
	mutex_init(&dev->ctxlist_mutex);
-
 
110
 
-
 
111
//	if (drm_ht_create(&dev->map_hash, 12)) {
-
 
112
//		return -ENOMEM;
-
 
113
//	}
-
 
114
 
-
 
115
    dev->driver = driver;
-
 
116
 
-
 
117
	if (driver->driver_features & DRIVER_GEM) {
-
 
118
		retcode = drm_gem_init(dev);
-
 
119
		if (retcode) {
-
 
120
			DRM_ERROR("Cannot initialize graphics execution "
-
 
121
				  "manager (GEM)\n");
-
 
122
			goto error_out_unreg;
-
 
123
		}
-
 
124
	}
-
 
125
 
-
 
126
	return 0;
-
 
127
 
-
 
128
error_out_unreg:
-
 
129
//   drm_lastclose(dev);
-
 
130
	return retcode;
-
 
131
}
88
 
132
EXPORT_SYMBOL(drm_fill_in_dev);
89
/**
133
/**
90
 * Compute size order.  Returns the exponent of the smaller power of two which
134
 * Compute size order.  Returns the exponent of the smaller power of two which
91
 * is greater or equal to given number.
135
 * is greater or equal to given number.
92
 *
136
 *
93
 * \param size size.
137
 * \param size size.
94
 * \return order.
138
 * \return order.
95
 *
139
 *
96
 * \todo Can be made faster.
140
 * \todo Can be made faster.
97
 */
141
 */
98
int drm_order(unsigned long size)
142
int drm_order(unsigned long size)
99
{
143
{
100
    int order;
144
    int order;
101
    unsigned long tmp;
145
    unsigned long tmp;
102
 
146
 
103
    for (order = 0, tmp = size >> 1; tmp; tmp >>= 1, order++) ;
147
    for (order = 0, tmp = size >> 1; tmp; tmp >>= 1, order++) ;
104
 
148
 
105
    if (size & (size - 1))
149
    if (size & (size - 1))
106
        ++order;
150
        ++order;
107
 
151
 
108
    return order;
152
    return order;
109
}
153
}
110
 
154
 
111
extern int x86_clflush_size;
155
extern int x86_clflush_size;
112
 
156
 
113
static inline void clflush(volatile void *__p)
157
static inline void clflush(volatile void *__p)
114
{
158
{
115
    asm volatile("clflush %0" : "+m" (*(volatile char*)__p));
159
    asm volatile("clflush %0" : "+m" (*(volatile char*)__p));
116
}
160
}
117
 
161
 
118
void
162
void
119
drm_clflush_virt_range(char *addr, unsigned long length)
163
drm_clflush_virt_range(char *addr, unsigned long length)
120
{
164
{
121
    char *end = addr + length;
165
    char *end = addr + length;
122
    mb();
166
    mb();
123
    for (; addr < end; addr += x86_clflush_size)
167
    for (; addr < end; addr += x86_clflush_size)
124
        clflush(addr);
168
        clflush(addr);
125
    clflush(end - 1);
169
    clflush(end - 1);
126
    mb();
170
    mb();
127
    return;
171
    return;
128
}
172
}