summaryrefslogtreecommitdiff
path: root/tests/mode/modetest.c
blob: bb91e832e56c982f8afea5a3319f6dd69de85238 (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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>

#include "xf86drm.h"
#include "xf86drmMode.h"

int dpms_prop_id = 0;
const char* getConnectionText(drmModeConnection conn)
{
	switch (conn) {
	case DRM_MODE_CONNECTED:
		return "connected";
	case DRM_MODE_DISCONNECTED:
		return "disconnected";
	default:
		return "unknown";
	}

}

int printMode(struct drm_mode_modeinfo *mode)
{
#if 1
	printf("Mode: %s\n", mode->name);
	printf("\tclock       : %i\n", mode->clock);
	printf("\thdisplay    : %i\n", mode->hdisplay);
	printf("\thsync_start : %i\n", mode->hsync_start);
	printf("\thsync_end   : %i\n", mode->hsync_end);
	printf("\thtotal      : %i\n", mode->htotal);
	printf("\thskew       : %i\n", mode->hskew);
	printf("\tvdisplay    : %i\n", mode->vdisplay);
	printf("\tvsync_start : %i\n", mode->vsync_start);
	printf("\tvsync_end   : %i\n", mode->vsync_end);
	printf("\tvtotal      : %i\n", mode->vtotal);
	printf("\tvscan       : %i\n", mode->vscan);
	printf("\tvrefresh    : %i\n", mode->vrefresh);
	printf("\tflags       : %i\n", mode->flags);
#else
	printf("Mode: \"%s\" %ix%i %.0f\n", mode->name,
		mode->hdisplay, mode->vdisplay, mode->vrefresh / 1000.0);
#endif
	return 0;
}

int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connector, uint32_t id)
{
	int i = 0, j;
	struct drm_mode_modeinfo *mode = NULL;
	drmModePropertyPtr props;
	drmModeEncoderPtr enc;
	unsigned char *name = NULL;

	printf("Connector: %d-%d\n", connector->connector_type, connector->connector_type_id);
	printf("\tid           : %i\n", id);
	printf("\tencoder id      : %i\n", connector->encoder);
	printf("\tconn         : %s\n", getConnectionText(connector->connection));
	printf("\tsize         : %ix%i (mm)\n", connector->mmWidth, connector->mmHeight);
	printf("\tcount_modes  : %i\n", connector->count_modes);
	printf("\tcount_props  : %i\n", connector->count_props);
	printf("\tcount_encs   : %i\n", connector->count_encoders);

	for (i = 0; i < connector->count_encoders; i++) {
		enc = drmModeGetEncoder(fd, connector->encoders[i]);
		if (enc) {
			printf("Encoder: %d %d %d %d %d\n", enc->crtc, enc->encoder_id, enc->encoder_type, enc->crtcs, enc->clones);
		}
	}

	for (i = 0; i < connector->count_props; i++) {
		props = drmModeGetProperty(fd, connector->props[i]);
		name = NULL;
		if (props) {
			printf("Property: %s\n", props->name);
			printf("\tid:        %i\n", props->prop_id);
			printf("\tflags:     %i\n", props->flags);
			printf("\tvalues %d: ", props->count_values);
			for (j = 0; j < props->count_values; j++)
				printf("%lld ", props->values[j]);

			printf("\n\tenums %d: \n", props->count_enums);
			
			if (props->flags & DRM_MODE_PROP_BLOB) {
				drmModePropertyBlobPtr blob;

				blob = drmModeGetPropertyBlob(fd, connector->prop_values[i]);
				if (blob) {
					printf("blob is %d length, %08X\n", blob->length, *(uint32_t *)blob->data);
					drmModeFreePropertyBlob(blob);
				}

			} else {
				if (!strncmp(props->name, "DPMS", 4))
					dpms_prop_id = props->prop_id;

				for (j = 0; j < props->count_enums; j++) {
				  printf("\t\t%lld = %s\n", props->enums[j].value, props->enums[j].name);
					if (connector->prop_values[i] == props->enums[j].value)
						name = props->enums[j].name;

				}

				if (props->count_enums && name) {
					printf("\tconnector property name %s %s\n", props->name, name);
				} else {
					printf("\tconnector property id %s %lli\n", props->name, connector->prop_values[i]);
				}
			}

			drmModeFreeProperty(props);
		}
	}

	for (i = 0; i < connector->count_modes; i++) {
		mode = &connector->modes[i];
		if (mode)
			printMode(mode);
		else
			printf("\t\tmode: Invalid mode %p\n", &connector->modes[i]);
	}

	return 0;
}

int printEncoder(int fd, drmModeResPtr res, drmModeEncoderPtr encoder, uint32_t id)
{
	printf("Encoder\n");
	printf("\tid            :%i\n", id);
	printf("\ttype          :%d\n", encoder->encoder_type);
	printf("\tcrtcs          :%d\n", encoder->crtcs);
	printf("\tclones          :%d\n", encoder->clones);
	return 0;
}

int printCrtc(int fd, drmModeResPtr res, drmModeCrtcPtr crtc, uint32_t id)
{
	printf("Crtc\n");
	printf("\tid           : %i\n", id);
	printf("\tx            : %i\n", crtc->x);
	printf("\ty            : %i\n", crtc->y);
	printf("\twidth        : %i\n", crtc->width);
	printf("\theight       : %i\n", crtc->height);
	printf("\tmode         : %p\n", &crtc->mode);
	printf("\tgamma size   : %d\n", crtc->gamma_size);
	printf("\tnum connectors  : %i\n", crtc->count_connectors);
	printf("\tconnectors      : %i\n", crtc->connectors);
	printf("\tnum possible : %i\n", crtc->count_possibles);
	printf("\tpossibles    : %i\n", crtc->possibles);

	return 0;
}

int printFrameBuffer(int fd, drmModeResPtr res, drmModeFBPtr fb)
{
	printf("Framebuffer\n");
	printf("\thandle    : %i\n", fb->handle);
	printf("\twidth     : %i\n", fb->width);
	printf("\theight    : %i\n", fb->height);
	printf("\tpitch     : %i\n", fb->pitch);;
	printf("\tbpp       : %i\n", fb->bpp);
	printf("\tdepth     : %i\n", fb->depth);
	printf("\tbuffer_id : %i\n", fb->buffer_id);

	return 0;
}

int printRes(int fd, drmModeResPtr res)
{
	int i;
	drmModeConnectorPtr connector;
	drmModeCrtcPtr crtc;
	drmModeFBPtr fb;
	drmModeEncoderPtr encoder;

	for (i = 0; i < res->count_connectors; i++) {
		connector = drmModeGetConnector(fd, res->connectors[i]);

		if (!connector)
			printf("Could not get connector %i\n", i);
		else {
			printConnector(fd, res, connector, res->connectors[i]);
			drmModeFreeConnector(connector);
		}
	}

	for (i = 0; i < res->count_encoders; i++) {
		encoder = drmModeGetEncoder(fd, res->encoders[i]);

		if (!encoder)
			printf("Could not get encoder %i\n", i);
		else {
			printEncoder(fd, res, encoder, res->encoders[i]);
			drmModeFreeEncoder(encoder);
		}
	}


	for (i = 0; i < res->count_crtcs; i++) {
		crtc = drmModeGetCrtc(fd, res->crtcs[i]);

		if (!crtc)
			printf("Could not get crtc %i\n", i);
		else {
			printCrtc(fd, res, crtc, res->crtcs[i]);
			drmModeFreeCrtc(crtc);
		}
	}

	for (i = 0; i < res->count_fbs; i++) {
		fb = drmModeGetFB(fd, res->fbs[i]);

		if (!fb)
			printf("Could not get fb %i\n", res->fbs[i]);
		else {
			printFrameBuffer(fd, res, fb);
			drmModeFreeFB(fb);
		}
	}

	return 0;
}

static struct drm_mode_modeinfo mode = {
	.name = "Test mode",
	.clock = 25200,
	.hdisplay = 640,
	.hsync_start = 656,
	.hsync_end = 752,
	.htotal = 800,
	.hskew = 0,
	.vdisplay = 480,
	.vsync_start = 490,
	.vsync_end = 492,
	.vtotal = 525,
	.vscan = 0,
	.vrefresh = 60000, /* vertical refresh * 1000 */
	.flags = 10,
};

int testMode(int fd, drmModeResPtr res)
{
	uint32_t connector = res->connectors[0];
	uint32_t newMode = 0;
	int ret = 0;
	int error = 0;

	printf("Test: adding mode to connector %i\n", connector);

	/* printMode(&mode); */

	printf("\tAttaching mode %i to connector %i\n", newMode, connector);

	ret = drmModeAttachMode(fd, connector, &mode);

	if (ret)
		goto err_mode;

	printf("\tDetaching mode %i from connector %i\n", newMode, connector);
	ret = drmModeDetachMode(fd, connector, &mode);

	if (ret)
		goto err_mode;
	return 0;

err_mode:

	printf("\tFailed\n");

	if (error)
		printf("\tFailed to delete mode %i\n", newMode);
	return 1;
}

/*
int testFrameBufferGet(int fd, uint32_t fb)
{
	drmModeFBPtr frame;

	printf("Test: get framebuffer %i\n", fb);

	frame = drmModeGetFB(fd, fb);

	if (!frame) {
		printf("\tFailed\n");
	} else {
		printFrameBuffer(fd, frame);
		drmModeFreeFB(frame);
	}

	return 0;
}
*/

int testFrameBufferAdd(int fd, drmModeResPtr res)
{
	uint32_t fb = 0;
	int ret = 0;
	drmModeFBPtr frame = 0;
	drmBO bo;

	printf("Test: adding framebuffer\n");

	printf("\tCreating BO\n");

	/* TODO */
	ret = drmBOCreate(fd, 800 * 600 * 4, 0, 0,
		DRM_BO_FLAG_READ |
		DRM_BO_FLAG_WRITE |
		DRM_BO_FLAG_MEM_TT |
		DRM_BO_FLAG_MEM_VRAM |
		DRM_BO_FLAG_NO_EVICT,
		DRM_BO_HINT_DONT_FENCE, &bo);

	printf("\tgot %i\n", ret);
	if (ret)
		goto err;

	printf("\tAdding FB\n");
	ret = drmModeAddFB(fd, 800, 600, 32, 8, 0, bo.handle, &fb);
	if (ret)
		goto err_bo;

	frame = drmModeGetFB(fd, fb);

	if (!frame) {
		printf("Couldn't retrive created framebuffer\n");
	} else {
		printFrameBuffer(fd, res, frame);
		drmModeFreeFB(frame);
	}

	printf("\tRemoveing FB\n");

	ret = drmModeRmFB(fd, fb);

	if (ret) {
		printf("\tFailed this shouldn't happen!\n");
		goto err_bo;
	}

	printf("\tRemoveing BO\n");

	ret = drmBOUnreference(fb, &bo);

	return 0;
	
err_bo:
	drmBOUnreference(fd, &bo);

err:
	printf("\tFailed\n");

	return 1;
}

int testDPMS(int fd, drmModeResPtr res)
{
	int connector_id;
	int i;

	for (i = 0; i < res->count_connectors; i++) {
		connector_id = res->connectors[i];
		/* turn connector off */
		drmModeConnectorSetProperty(fd, connector_id, dpms_prop_id, 3);
		sleep(2);
		drmModeConnectorSetProperty(fd, connector_id, dpms_prop_id, 0);
	}
	return 1;

}

int main(int argc, char **argv)
{
	int fd;
	drmModeResPtr res;

	printf("Starting test\n");

	fd = drmOpen("i915", NULL);

	if (fd < 0) {
		printf("Failed to open the card fb (%d)\n",fd);
		return 1;
	}

	res = drmModeGetResources(fd);
	if (res == 0) {
		printf("Failed to get resources from card\n");
		drmClose(fd);
		return 1;
	}

	printRes(fd, res);

	testMode(fd, res);

	testFrameBufferAdd(fd, res);

	/* try dpms test */
	testDPMS(fd, res);
	drmModeFreeResources(res);
	printf("Ok\n");

	return 0;
}
pan> int cant_use_aperture; unsigned long page_mask; } drm_agp_head_t; #endif typedef struct drm_sg_mem { unsigned long handle; void *virtual; int pages; struct page **pagelist; dma_addr_t *busaddr; } drm_sg_mem_t; typedef struct drm_sigdata { int context; drm_hw_lock_t *lock; } drm_sigdata_t; typedef struct drm_map_list { struct list_head head; drm_map_t *map; } drm_map_list_t; typedef drm_map_t drm_local_map_t; #if __HAVE_VBL_IRQ typedef struct drm_vbl_sig { struct list_head head; unsigned int sequence; struct siginfo info; struct task_struct *task; } drm_vbl_sig_t; #endif typedef struct drm_device { const char *name; /* Simple driver name */ char *unique; /* Unique identifier: e.g., busid */ int unique_len; /* Length of unique field */ dev_t device; /* Device number for mknod */ char *devname; /* For /proc/interrupts */ int blocked; /* Blocked due to VC switch? */ struct proc_dir_entry *root; /* Root for this device's entries */ /* Locks */ spinlock_t count_lock; /* For inuse, open_count, buf_use */ struct semaphore struct_sem; /* For others */ /* Usage Counters */ int open_count; /* Outstanding files open */ atomic_t ioctl_count; /* Outstanding IOCTLs pending */ atomic_t vma_count; /* Outstanding vma areas open */ int buf_use; /* Buffers in use -- cannot alloc */ atomic_t buf_alloc; /* Buffer allocation in progress */ /* Performance counters */ unsigned long counters; drm_stat_type_t types[15]; atomic_t counts[15]; /* Authentication */ drm_file_t *file_first; drm_file_t *file_last; drm_magic_head_t magiclist[DRM_HASH_SIZE]; /* Memory management */ drm_map_list_t *maplist; /* Linked list of regions */ int map_count; /* Number of mappable regions */ drm_map_t **context_sareas; int max_context; drm_vma_entry_t *vmalist; /* List of vmas (for debugging) */ drm_lock_data_t lock; /* Information on hardware lock */ /* DMA queues (contexts) */ int queue_count; /* Number of active DMA queues */ int queue_reserved; /* Number of reserved DMA queues */ int queue_slots; /* Actual length of queuelist */ drm_queue_t **queuelist; /* Vector of pointers to DMA queues */ drm_device_dma_t *dma; /* Optional pointer for DMA support */ /* Context support */ int irq; /* Interrupt used by board */ __volatile__ long context_flag; /* Context swapping flag */ __volatile__ long interrupt_flag; /* Interruption handler flag */ __volatile__ long dma_flag; /* DMA dispatch flag */ struct timer_list timer; /* Timer for delaying ctx switch */ wait_queue_head_t context_wait; /* Processes waiting on ctx switch */ int last_checked; /* Last context checked for DMA */ int last_context; /* Last current context */ unsigned long last_switch; /* jiffies at last context switch */ struct tq_struct tq; #if __HAVE_VBL_IRQ wait_queue_head_t vbl_queue; atomic_t vbl_received; spinlock_t vbl_lock; drm_vbl_sig_t vbl_sigs; unsigned int vbl_pending; #endif cycles_t ctx_start; cycles_t lck_start; #if __HAVE_DMA_HISTOGRAM drm_histogram_t histo; #endif /* Callback to X server for context switch and for heavy-handed reset. */ char buf[DRM_BSZ]; /* Output buffer */ char *buf_rp; /* Read pointer */ char *buf_wp; /* Write pointer */ char *buf_end; /* End pointer */ struct fasync_struct *buf_async;/* Processes waiting for SIGIO */ wait_queue_head_t buf_readers; /* Processes waiting to read */ wait_queue_head_t buf_writers; /* Processes waiting to ctx switch */ #if __REALLY_HAVE_AGP drm_agp_head_t *agp; #endif struct pci_dev *pdev; #ifdef __alpha__ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3) struct pci_controler *hose; #else struct pci_controller *hose; #endif #endif drm_sg_mem_t *sg; /* Scatter gather memory */ unsigned long *ctx_bitmap; void *dev_private; drm_sigdata_t sigdata; /* For block_all_signals */ sigset_t sigmask; } drm_device_t; /* ================================================================ * Internal function definitions */ /* Misc. support (drm_init.h) */ extern int DRM(flags); extern void DRM(parse_options)( char *s ); extern int DRM(cpu_valid)( void ); /* Driver support (drm_drv.h) */ extern int DRM(version)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(open)(struct inode *inode, struct file *filp); extern int DRM(release)(struct inode *inode, struct file *filp); extern int DRM(ioctl)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(lock)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(unlock)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); /* Device support (drm_fops.h) */ extern int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev); extern int DRM(flush)(struct file *filp); extern int DRM(release_fuck)(struct inode *inode, struct file *filp); extern int DRM(fasync)(int fd, struct file *filp, int on); extern ssize_t DRM(read)(struct file *filp, char *buf, size_t count, loff_t *off); extern int DRM(write_string)(drm_device_t *dev, const char *s); extern unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait); /* Mapping support (drm_vm.h) */ extern struct page *DRM(vm_nopage)(struct vm_area_struct *vma, unsigned long address, int write_access); extern struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma, unsigned long address, int write_access); extern struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma, unsigned long address, int write_access); extern struct page *DRM(vm_sg_nopage)(struct vm_area_struct *vma, unsigned long address, int write_access); extern void DRM(vm_open)(struct vm_area_struct *vma); extern void DRM(vm_close)(struct vm_area_struct *vma); extern void DRM(vm_shm_close)(struct vm_area_struct *vma); extern int DRM(mmap_dma)(struct file *filp, struct vm_area_struct *vma); extern int DRM(mmap)(struct file *filp, struct vm_area_struct *vma); /* Memory management support (drm_memory.h) */ extern void DRM(mem_init)(void); extern int DRM(mem_info)(char *buf, char **start, off_t offset, int request, int *eof, void *data); extern void *DRM(alloc)(size_t size, int area); extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area); extern char *DRM(strdup)(const char *s, int area); extern void DRM(strfree)(const char *s, int area); extern void DRM(free)(void *pt, size_t size, int area); extern unsigned long DRM(alloc_pages)(int order, int area); extern void DRM(free_pages)(unsigned long address, int order, int area); extern void *DRM(ioremap)(unsigned long offset, unsigned long size); extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size); extern void DRM(ioremapfree)(void *pt, unsigned long size); #if __REALLY_HAVE_AGP extern agp_memory *DRM(alloc_agp)(int pages, u32 type); extern int DRM(free_agp)(agp_memory *handle, int pages); extern int DRM(bind_agp)(agp_memory *handle, unsigned int start); extern int DRM(unbind_agp)(agp_memory *handle); #endif /* Misc. IOCTL support (drm_ioctl.h) */ extern int DRM(irq_busid)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(getunique)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(setunique)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(getmap)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(getclient)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(getstats)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); /* Context IOCTL support (drm_context.h) */ extern int DRM(resctx)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(addctx)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(modctx)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(getctx)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(switchctx)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(newctx)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(rmctx)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(context_switch)(drm_device_t *dev, int old, int new); extern int DRM(context_switch_complete)(drm_device_t *dev, int new); #if __HAVE_CTX_BITMAP extern int DRM(ctxbitmap_init)( drm_device_t *dev ); extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev ); #endif extern int DRM(setsareactx)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(getsareactx)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); /* Drawable IOCTL support (drm_drawable.h) */ extern int DRM(adddraw)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(rmdraw)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); /* Authentication IOCTL support (drm_auth.h) */ extern int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic); extern int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic); extern int DRM(getmagic)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(authmagic)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); /* Locking IOCTL support (drm_lock.h) */ extern int DRM(block)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(unblock)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context); extern int DRM(lock_transfer)(drm_device_t *dev, __volatile__ unsigned int *lock, unsigned int context); extern int DRM(lock_free)(drm_device_t *dev, __volatile__ unsigned int *lock, unsigned int context); extern int DRM(finish)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(flush_unblock)(drm_device_t *dev, int context, drm_lock_flags_t flags); extern int DRM(flush_block_and_flush)(drm_device_t *dev, int context, drm_lock_flags_t flags); extern int DRM(notifier)(void *priv); /* Buffer management support (drm_bufs.h) */ extern int DRM(order)( unsigned long size ); extern int DRM(addmap)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(rmmap)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); #if __HAVE_DMA extern int DRM(addbufs)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(infobufs)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(markbufs)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(freebufs)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(mapbufs)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); /* DMA support (drm_dma.h) */ extern int DRM(dma_setup)(drm_device_t *dev); extern void DRM(dma_takedown)(drm_device_t *dev); extern void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf); extern void DRM(reclaim_buffers)(drm_device_t *dev, pid_t pid); #if __HAVE_OLD_DMA /* GH: This is a dirty hack for now... */ extern void DRM(clear_next_buffer)(drm_device_t *dev); extern int DRM(select_queue)(drm_device_t *dev, void (*wrapper)(unsigned long)); extern int DRM(dma_enqueue)(drm_device_t *dev, drm_dma_t *dma); extern int DRM(dma_get_buffers)(drm_device_t *dev, drm_dma_t *dma); #endif #if __HAVE_DMA_IRQ extern int DRM(control)( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg ); extern int DRM(irq_install)( drm_device_t *dev, int irq ); extern int DRM(irq_uninstall)( drm_device_t *dev ); extern void DRM(dma_service)( int irq, void *device, struct pt_regs *regs ); extern void DRM(driver_irq_preinstall)( drm_device_t *dev ); extern void DRM(driver_irq_postinstall)( drm_device_t *dev ); extern void DRM(driver_irq_uninstall)( drm_device_t *dev ); #if __HAVE_VBL_IRQ extern int DRM(wait_vblank)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq); extern void DRM(vbl_send_signals)( drm_device_t *dev ); #endif #if __HAVE_DMA_IRQ_BH extern void DRM(dma_immediate_bh)( void *dev ); #endif #endif #if DRM_DMA_HISTOGRAM extern int DRM(histogram_slot)(unsigned long count); extern void DRM(histogram_compute)(drm_device_t *dev, drm_buf_t *buf); #endif /* Buffer list support (drm_lists.h) */ #if __HAVE_DMA_WAITLIST extern int DRM(waitlist_create)(drm_waitlist_t *bl, int count); extern int DRM(waitlist_destroy)(drm_waitlist_t *bl); extern int DRM(waitlist_put)(drm_waitlist_t *bl, drm_buf_t *buf); extern drm_buf_t *DRM(waitlist_get)(drm_waitlist_t *bl); #endif #if __HAVE_DMA_FREELIST extern int DRM(freelist_create)(drm_freelist_t *bl, int count); extern int DRM(freelist_destroy)(drm_freelist_t *bl); extern int DRM(freelist_put)(drm_device_t *dev, drm_freelist_t *bl, drm_buf_t *buf); extern drm_buf_t *DRM(freelist_get)(drm_freelist_t *bl, int block); #endif #endif /* __HAVE_DMA */ #if __REALLY_HAVE_AGP /* AGP/GART support (drm_agpsupport.h) */ extern drm_agp_head_t *DRM(agp_init)(void); extern void DRM(agp_uninit)(void); extern int DRM(agp_acquire)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern void DRM(agp_do_release)(void); extern int DRM(agp_release)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(agp_enable)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(agp_info)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(agp_alloc)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(agp_free)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(agp_unbind)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int DRM(agp_bind)(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type); extern int DRM(agp_free_memory)(agp_memory *handle); extern int DRM(agp_bind_memory)(agp_memory *handle, off_t start); extern int DRM(agp_unbind_memory)(agp_memory *handle); #endif /* Stub support (drm_stub.h) */ int DRM(stub_register)(const char *name, struct file_operations *fops, drm_device_t *dev); int DRM(stub_unregister)(int minor);