tdfx_drv.c revision 95584
195584Sanholt/* tdfx_drv.c -- tdfx driver -*- linux-c -*-
295584Sanholt * Created: Thu Oct  7 10:38:32 1999 by faith@precisioninsight.com
395584Sanholt *
495584Sanholt * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
595584Sanholt * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
695584Sanholt * All Rights Reserved.
795584Sanholt *
895584Sanholt * Permission is hereby granted, free of charge, to any person obtaining a
995584Sanholt * copy of this software and associated documentation files (the "Software"),
1095584Sanholt * to deal in the Software without restriction, including without limitation
1195584Sanholt * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1295584Sanholt * and/or sell copies of the Software, and to permit persons to whom the
1395584Sanholt * Software is furnished to do so, subject to the following conditions:
1495584Sanholt *
1595584Sanholt * The above copyright notice and this permission notice (including the next
1695584Sanholt * paragraph) shall be included in all copies or substantial portions of the
1795584Sanholt * Software.
1895584Sanholt *
1995584Sanholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2095584Sanholt * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2195584Sanholt * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
2295584Sanholt * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
2395584Sanholt * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2495584Sanholt * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2595584Sanholt * DEALINGS IN THE SOFTWARE.
2695584Sanholt *
2795584Sanholt * Authors:
2895584Sanholt *    Rickard E. (Rik) Faith <faith@valinux.com>
2995584Sanholt *    Daryll Strauss <daryll@valinux.com>
3095584Sanholt *    Gareth Hughes <gareth@valinux.com>
3195584Sanholt *
3295584Sanholt * $FreeBSD: head/sys/dev/drm/tdfx_drv.c 95584 2002-04-27 20:47:57Z anholt $
3395584Sanholt */
3495584Sanholt
3595584Sanholt#ifdef __linux__
3695584Sanholt#include <linux/config.h>
3795584Sanholt#endif /* __linux__ */
3895584Sanholt
3995584Sanholt#ifdef __FreeBSD__
4095584Sanholt#include <sys/types.h>
4195584Sanholt#include <sys/bus.h>
4295584Sanholt#include <pci/pcivar.h>
4395584Sanholt#include <opt_drm_linux.h>
4495584Sanholt#endif /* __FreeBSD__ */
4595584Sanholt
4695584Sanholt#include "dev/drm/tdfx.h"
4795584Sanholt#include "dev/drm/drmP.h"
4895584Sanholt
4995584Sanholt#define DRIVER_AUTHOR		"VA Linux Systems Inc."
5095584Sanholt
5195584Sanholt#define DRIVER_NAME		"tdfx"
5295584Sanholt#define DRIVER_DESC		"3dfx Banshee/Voodoo3+"
5395584Sanholt#define DRIVER_DATE		"20010216"
5495584Sanholt
5595584Sanholt#define DRIVER_MAJOR		1
5695584Sanholt#define DRIVER_MINOR		0
5795584Sanholt#define DRIVER_PATCHLEVEL	0
5895584Sanholt
5995584Sanholt#ifndef PCI_VENDOR_ID_3DFX
6095584Sanholt#define PCI_VENDOR_ID_3DFX 0x121A
6195584Sanholt#endif
6295584Sanholt#ifndef PCI_DEVICE_ID_3DFX_VOODOO5
6395584Sanholt#define PCI_DEVICE_ID_3DFX_VOODOO5 0x0009
6495584Sanholt#endif
6595584Sanholt#ifndef PCI_DEVICE_ID_3DFX_VOODOO4
6695584Sanholt#define PCI_DEVICE_ID_3DFX_VOODOO4 0x0007
6795584Sanholt#endif
6895584Sanholt#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_3000 /* Voodoo3 3000 */
6995584Sanholt#define PCI_DEVICE_ID_3DFX_VOODOO3_3000 0x0005
7095584Sanholt#endif
7195584Sanholt#ifndef PCI_DEVICE_ID_3DFX_VOODOO3_2000 /* Voodoo3 3000 */
7295584Sanholt#define PCI_DEVICE_ID_3DFX_VOODOO3_2000 0x0004
7395584Sanholt#endif
7495584Sanholt#ifndef PCI_DEVICE_ID_3DFX_BANSHEE
7595584Sanholt#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003
7695584Sanholt#endif
7795584Sanholt
7895584Sanholt#ifdef __FreeBSD__
7995584Sanholt/* List acquired from xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
8095584Sanholt * Please report to eanholt@gladstone.uoregon.edu if your chip isn't
8195584Sanholt * represented in the list or if the information is incorrect.
8295584Sanholt */
8395584Sanholtdrm_chipinfo_t DRM(devicelist)[] = {
8495584Sanholt	{0x121a, 0x0003, 1, "3dfx Voodoo Banshee"},
8595584Sanholt	{0x121a, 0x0004, 1, "3dfx Voodoo3 2000"},
8695584Sanholt	{0x121a, 0x0005, 1, "3dfx Voodoo3 3000"},
8795584Sanholt	{0x121a, 0x0007, 1, "3dfx Voodoo4"},
8895584Sanholt	{0x121a, 0x0009, 1, "3dfx Voodoo5"},
8995584Sanholt	{0, 0, 0, NULL}
9095584Sanholt};
9195584Sanholt#endif /* __FreeBSD__ */
9295584Sanholt
9395584Sanholt#ifdef __linux__
9495584Sanholt/* For now, we'll only support multihead on Linux */
9595584Sanholt/* Uncomment this, and fixup drm_count_cards */
9695584Sanholtstatic drm_pci_list_t DRM(idlist)[] = {
9795584Sanholt	{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_BANSHEE },
9895584Sanholt	{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3_2000 },
9995584Sanholt	{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO3_3000 },
10095584Sanholt	{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO4 },
10195584Sanholt	{ PCI_VENDOR_ID_3DFX, PCI_DEVICE_ID_3DFX_VOODOO5 },
10295584Sanholt	{ 0, 0 }
10395584Sanholt};
10495584Sanholt
10595584Sanholt#define DRIVER_CARD_LIST DRM(idlist)
10695584Sanholt#endif /* __linux__ */
10795584Sanholt
10895584Sanholt#include "dev/drm/drm_auth.h"
10995584Sanholt#include "dev/drm/drm_bufs.h"
11095584Sanholt#include "dev/drm/drm_context.h"
11195584Sanholt#include "dev/drm/drm_dma.h"
11295584Sanholt#include "dev/drm/drm_drawable.h"
11395584Sanholt#include "dev/drm/drm_drv.h"
11495584Sanholt
11595584Sanholt#ifdef __linux__
11695584Sanholt#ifndef MODULE
11795584Sanholt/* DRM(options) is called by the kernel to parse command-line options
11895584Sanholt * passed via the boot-loader (e.g., LILO).  It calls the insmod option
11995584Sanholt * routine, drm_parse_drm.
12095584Sanholt */
12195584Sanholt
12295584Sanholt/* JH- We have to hand expand the string ourselves because of the cpp.  If
12395584Sanholt * anyone can think of a way that we can fit into the __setup macro without
12495584Sanholt * changing it, then please send the solution my way.
12595584Sanholt */
12695584Sanholtstatic int __init tdfx_options( char *str )
12795584Sanholt{
12895584Sanholt	DRM(parse_options)( str );
12995584Sanholt	return 1;
13095584Sanholt}
13195584Sanholt
13295584Sanholt__setup( DRIVER_NAME "=", tdfx_options );
13395584Sanholt#endif
13495584Sanholt#endif /* __linux__ */
13595584Sanholt
13695584Sanholt#include "dev/drm/drm_fops.h"
13795584Sanholt#include "dev/drm/drm_init.h"
13895584Sanholt#include "dev/drm/drm_ioctl.h"
13995584Sanholt#include "dev/drm/drm_lock.h"
14095584Sanholt#include "dev/drm/drm_memory.h"
14195584Sanholt#ifdef __linux__
14295584Sanholt#include "dev/drm/drm_proc.h"
14395584Sanholt#endif /* __linux__ */
14495584Sanholt#include "dev/drm/drm_vm.h"
14595584Sanholt#ifdef __linux__
14695584Sanholt#include "dev/drm/drm_stub.h"
14795584Sanholt#endif /* __linux__ */
14895584Sanholt#ifdef __FreeBSD__
14995584Sanholt#include "dev/drm/drm_sysctl.h"
15095584Sanholt
15195584SanholtDRIVER_MODULE(tdfx, pci, tdfx_driver, tdfx_devclass, 0, 0);
15295584Sanholt#endif /* __FreeBSD__ */
153