1/* i810.h -- Intel i810/i815 DRM template customization -*- linux-c -*-
2 * Created: Thu Feb 15 00:01:12 2001 by gareth@valinux.com
3 *
4 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
5 * All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
16 * Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
25 *
26 * Authors:
27 *    Gareth Hughes <gareth@valinux.com>
28 */
29
30#ifndef __I810_H__
31#define __I810_H__
32
33/* This remains constant for all DRM template files.
34 */
35#define DRM(x) i810_##x
36
37/* General customization:
38 */
39#define __HAVE_AGP		1
40#define __MUST_HAVE_AGP		1
41#define __HAVE_MTRR		1
42#define __HAVE_CTX_BITMAP	1
43
44/* Driver customization:
45 */
46#define __HAVE_RELEASE		1
47#define DRIVER_RELEASE() do {						\
48	i810_reclaim_buffers( dev, priv->pid );				\
49} while (0)
50
51/* DMA customization:
52 */
53#define __HAVE_DMA		1
54#define __HAVE_DMA_QUEUE	1
55#define __HAVE_DMA_WAITLIST	1
56#define __HAVE_DMA_RECLAIM	1
57
58#define __HAVE_DMA_QUIESCENT	1
59#define DRIVER_DMA_QUIESCENT() do {					\
60	i810_dma_quiescent( dev );					\
61} while (0)
62
63#define __HAVE_DMA_IRQ		1
64#define __HAVE_DMA_IRQ_BH	1
65#define __HAVE_SHARED_IRQ       1
66#define DRIVER_PREINSTALL() do {					\
67	drm_i810_private_t *dev_priv =					\
68		(drm_i810_private_t *)dev->dev_private;			\
69	u16 tmp;							\
70   	tmp = I810_READ16( I810REG_HWSTAM );				\
71   	tmp = tmp & 0x6000;						\
72   	I810_WRITE16( I810REG_HWSTAM, tmp );				\
73									\
74      	tmp = I810_READ16( I810REG_INT_MASK_R );			\
75   	tmp = tmp & 0x6000;		/* Unmask interrupts */		\
76   	I810_WRITE16( I810REG_INT_MASK_R, tmp );			\
77   	tmp = I810_READ16( I810REG_INT_ENABLE_R );			\
78   	tmp = tmp & 0x6000;		/* Disable all interrupts */	\
79      	I810_WRITE16( I810REG_INT_ENABLE_R, tmp );			\
80} while (0)
81
82#define DRIVER_POSTINSTALL() do {					\
83	drm_i810_private_t *dev_priv =					\
84		(drm_i810_private_t *)dev->dev_private;			\
85	u16 tmp;							\
86   	tmp = I810_READ16( I810REG_INT_ENABLE_R );			\
87   	tmp = tmp & 0x6000;						\
88   	tmp = tmp | 0x0003;	/* Enable bp & user interrupts */	\
89   	I810_WRITE16( I810REG_INT_ENABLE_R, tmp );			\
90} while (0)
91
92#define DRIVER_UNINSTALL() do {						\
93	drm_i810_private_t *dev_priv =					\
94		(drm_i810_private_t *)dev->dev_private;			\
95	u16 tmp;							\
96	if ( dev_priv ) {						\
97		tmp = I810_READ16( I810REG_INT_IDENTITY_R );		\
98		tmp = tmp & ~(0x6000);	/* Clear all interrupts */	\
99		if ( tmp != 0 )						\
100			I810_WRITE16( I810REG_INT_IDENTITY_R, tmp );	\
101									\
102		tmp = I810_READ16( I810REG_INT_ENABLE_R );		\
103		tmp = tmp & 0x6000;	/* Disable all interrupts */	\
104		I810_WRITE16( I810REG_INT_ENABLE_R, tmp );		\
105	}								\
106} while (0)
107
108/* Buffer customization:
109 */
110
111#define DRIVER_BUF_PRIV_T	drm_i810_buf_priv_t
112
113#define DRIVER_AGP_BUFFERS_MAP( dev )					\
114	((drm_i810_private_t *)((dev)->dev_private))->buffer_map
115
116#endif
117