mga_drv.c revision 95746
1/* mga_drv.c -- Matrox G200/G400 driver -*- linux-c -*-
2 * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
3 *
4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
6 * All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
17 * Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 *
27 * Authors:
28 *    Rickard E. (Rik) Faith <faith@valinux.com>
29 *    Gareth Hughes <gareth@valinux.com>
30 *
31 * $FreeBSD: head/sys/dev/drm/mga_drv.c 95746 2002-04-29 18:18:42Z anholt $
32 */
33
34#ifdef __linux__
35#include <linux/config.h>
36#endif /* __linux__ */
37
38#ifdef __FreeBSD__
39#include <sys/types.h>
40#include <sys/bus.h>
41#include <pci/pcivar.h>
42#endif /* __FreeBSD__ */
43
44#include "dev/drm/mga.h"
45#include "dev/drm/drmP.h"
46#include "dev/drm/mga_drm.h"
47#include "dev/drm/mga_drv.h"
48
49#define DRIVER_AUTHOR		"Gareth Hughes, VA Linux Systems Inc."
50
51#define DRIVER_NAME		"mga"
52#define DRIVER_DESC		"Matrox G200/G400"
53#define DRIVER_DATE		"20010321"
54
55#define DRIVER_MAJOR		3
56#define DRIVER_MINOR		0
57#define DRIVER_PATCHLEVEL	2
58
59#ifdef __FreeBSD__
60/* List acquired from xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
61 * Please report to eanholt@gladstone.uoregon.edu if your chip isn't
62 * represented in the list or if the information is incorrect.
63 */
64/* PCI cards are not supported with DRI under FreeBSD.
65 */
66drm_chipinfo_t DRM(devicelist)[] = {
67	{0x102b, 0x0520, 0, "Matrox G200 (PCI)"},
68	{0x102b, 0x0521, 1, "Matrox G200 (AGP)"},
69	{0x102b, 0x0525, 1, "Matrox G400/G450 (AGP)"},
70	{0x102b, 0x2527, 1, "Matrox G550 (AGP)"},
71	{0, 0, 0, NULL}
72};
73#endif /* __FreeBSD__ */
74
75#define DRIVER_IOCTLS							   \
76	[DRM_IOCTL_NR(DRM_IOCTL_DMA)]	      = { mga_dma_buffers, 1, 0 }, \
77	[DRM_IOCTL_NR(DRM_IOCTL_MGA_INIT)]    = { mga_dma_init,    1, 1 }, \
78	[DRM_IOCTL_NR(DRM_IOCTL_MGA_FLUSH)]   = { mga_dma_flush,   1, 0 }, \
79	[DRM_IOCTL_NR(DRM_IOCTL_MGA_RESET)]   = { mga_dma_reset,   1, 0 }, \
80	[DRM_IOCTL_NR(DRM_IOCTL_MGA_SWAP)]    = { mga_dma_swap,    1, 0 }, \
81	[DRM_IOCTL_NR(DRM_IOCTL_MGA_CLEAR)]   = { mga_dma_clear,   1, 0 }, \
82	[DRM_IOCTL_NR(DRM_IOCTL_MGA_VERTEX)]  = { mga_dma_vertex,  1, 0 }, \
83	[DRM_IOCTL_NR(DRM_IOCTL_MGA_INDICES)] = { mga_dma_indices, 1, 0 }, \
84	[DRM_IOCTL_NR(DRM_IOCTL_MGA_ILOAD)]   = { mga_dma_iload,   1, 0 }, \
85	[DRM_IOCTL_NR(DRM_IOCTL_MGA_BLIT)]    = { mga_dma_blit,    1, 0 },
86
87
88#define __HAVE_COUNTERS         3
89#define __HAVE_COUNTER6         _DRM_STAT_IRQ
90#define __HAVE_COUNTER7         _DRM_STAT_PRIMARY
91#define __HAVE_COUNTER8         _DRM_STAT_SECONDARY
92
93
94#include "dev/drm/drm_agpsupport.h"
95#include "dev/drm/drm_auth.h"
96#include "dev/drm/drm_bufs.h"
97#include "dev/drm/drm_context.h"
98#include "dev/drm/drm_dma.h"
99#include "dev/drm/drm_drawable.h"
100#include "dev/drm/drm_drv.h"
101
102#ifdef __linux__
103#ifndef MODULE
104/* DRM(options) is called by the kernel to parse command-line options
105 * passed via the boot-loader (e.g., LILO).  It calls the insmod option
106 * routine, drm_parse_drm.
107 */
108
109/* JH- We have to hand expand the string ourselves because of the cpp.  If
110 * anyone can think of a way that we can fit into the __setup macro without
111 * changing it, then please send the solution my way.
112 */
113static int __init mga_options( char *str )
114{
115	DRM(parse_options)( str );
116	return 1;
117}
118
119__setup( DRIVER_NAME "=", mga_options );
120#endif
121#endif /* __linux__ */
122
123#include "dev/drm/drm_fops.h"
124#include "dev/drm/drm_init.h"
125#include "dev/drm/drm_ioctl.h"
126#include "dev/drm/drm_lock.h"
127#include "dev/drm/drm_memory.h"
128#include "dev/drm/drm_vm.h"
129#ifdef __linux__
130#include "dev/drm/drm_proc.h"
131#include "dev/drm/drm_stub.h"
132#endif /* __linux__ */
133#ifdef __FreeBSD__
134#include "dev/drm/drm_sysctl.h"
135
136DRIVER_MODULE(mga, pci, mga_driver, mga_devclass, 0, 0);
137#endif /* __FreeBSD__ */
138