OSDN Git Service

Use headers copied from kernel instead of shared-core
[android-x86/external-libdrm.git] / shared-core / via_drv.h
1 /*
2  * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3  * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sub license,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19  * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _VIA_DRV_H_
25 #define _VIA_DRV_H_
26
27 #include "drm_sman.h"
28 #define DRIVER_AUTHOR   "Various"
29
30 #define DRIVER_NAME             "via"
31 #define DRIVER_DESC             "VIA Unichrome / Pro"
32
33 #include "via_verifier.h"
34
35 /*
36  * Registers go here.
37  */
38
39
40 #define CMDBUF_ALIGNMENT_SIZE   (0x100)
41 #define CMDBUF_ALIGNMENT_MASK   (0x0ff)
42
43 /* defines for VIA 3D registers */
44 #define VIA_REG_STATUS          0x400
45 #define VIA_REG_TRANSET         0x43C
46 #define VIA_REG_TRANSPACE       0x440
47
48 /* VIA_REG_STATUS(0x400): Engine Status */
49 #define VIA_CMD_RGTR_BUSY       0x00000080      /* Command Regulator is busy */
50 #define VIA_2D_ENG_BUSY         0x00000001      /* 2D Engine is busy */
51 #define VIA_3D_ENG_BUSY         0x00000002      /* 3D Engine is busy */
52 #define VIA_VR_QUEUE_BUSY       0x00020000      /* Virtual Queue is busy */
53
54
55
56 #if defined(__linux__)
57 #include "via_dmablit.h"
58
59 /*
60  * This define and all its references can be removed when
61  * the DMA blit code has been implemented for FreeBSD.
62  */
63 #define VIA_HAVE_DMABLIT 1
64 #define VIA_HAVE_CORE_MM 1
65 #endif
66
67 #define VIA_PCI_BUF_SIZE 60000
68 #define VIA_FIRE_BUF_SIZE  1024
69 #define VIA_NUM_IRQS 4
70
71 typedef struct drm_via_ring_buffer {
72         drm_local_map_t map;
73         char *virtual_start;
74 } drm_via_ring_buffer_t;
75
76 typedef uint32_t maskarray_t[5];
77
78 typedef struct drm_via_irq {
79         atomic_t irq_received;
80         uint32_t pending_mask;
81         uint32_t enable_mask;
82         wait_queue_head_t irq_queue;
83 } drm_via_irq_t;
84
85 typedef struct drm_via_private {
86         drm_via_sarea_t *sarea_priv;
87         drm_local_map_t *sarea;
88         drm_local_map_t *fb;
89         drm_local_map_t *mmio;
90         unsigned long agpAddr;
91         wait_queue_head_t decoder_queue[VIA_NR_XVMC_LOCKS];
92         char *dma_ptr;
93         unsigned int dma_low;
94         unsigned int dma_high;
95         unsigned int dma_offset;
96         uint32_t dma_wrap;
97         volatile uint32_t *last_pause_ptr;
98         volatile uint32_t *hw_addr_ptr;
99         drm_via_ring_buffer_t ring;
100         struct timeval last_vblank;
101         int last_vblank_valid;
102         unsigned usec_per_vblank;
103         atomic_t vbl_received;
104         drm_via_state_t hc_state;
105         char pci_buf[VIA_PCI_BUF_SIZE];
106         const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
107         uint32_t num_fire_offsets;
108         int chipset;
109         drm_via_irq_t via_irqs[VIA_NUM_IRQS];
110         unsigned num_irqs;
111         maskarray_t *irq_masks;
112         uint32_t irq_enable_mask;
113         uint32_t irq_pending_mask;
114         int *irq_map;
115         /* Memory manager stuff */
116 #ifdef VIA_HAVE_CORE_MM
117         unsigned int idle_fault;
118         struct drm_sman sman;
119         int vram_initialized;
120         int agp_initialized;
121         unsigned long vram_offset;
122         unsigned long agp_offset;
123 #endif
124 #ifdef VIA_HAVE_DMABLIT
125         drm_via_blitq_t blit_queues[VIA_NUM_BLIT_ENGINES];
126 #endif
127         uint32_t dma_diff;
128 #ifdef VIA_HAVE_FENCE
129         spinlock_t fence_lock;
130         uint32_t emit_0_sequence;
131         int have_idlelock;
132         struct timer_list fence_timer;
133 #endif
134 } drm_via_private_t;
135
136 enum via_family {
137   VIA_OTHER = 0,     /* Baseline */
138   VIA_PRO_GROUP_A,   /* Another video engine and DMA commands */
139   VIA_DX9_0          /* Same video as pro_group_a, but 3D is unsupported */
140 };
141
142 /* VIA MMIO register access */
143 #define VIA_BASE ((dev_priv->mmio))
144
145 #define VIA_READ(reg)           DRM_READ32(VIA_BASE, reg)
146 #define VIA_WRITE(reg,val)      DRM_WRITE32(VIA_BASE, reg, val)
147 #define VIA_READ8(reg)          DRM_READ8(VIA_BASE, reg)
148 #define VIA_WRITE8(reg,val)     DRM_WRITE8(VIA_BASE, reg, val)
149
150 extern struct drm_ioctl_desc via_ioctls[];
151 extern int via_max_ioctl;
152
153 extern int via_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
154 extern int via_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv);
155 extern int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv);
156 extern int via_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
157 extern int via_map_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
158 extern int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_priv);
159 extern int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv);
160 extern int via_dma_blit_sync( struct drm_device *dev, void *data, struct drm_file *file_priv );
161 extern int via_dma_blit( struct drm_device *dev, void *data, struct drm_file *file_priv );
162
163 extern int via_driver_load(struct drm_device *dev, unsigned long chipset);
164 extern int via_driver_unload(struct drm_device *dev);
165 extern int via_final_context(struct drm_device * dev, int context);
166
167 extern int via_do_cleanup_map(struct drm_device * dev);
168 extern u32 via_get_vblank_counter(struct drm_device *dev, int crtc);
169 extern int via_enable_vblank(struct drm_device *dev, int crtc);
170 extern void via_disable_vblank(struct drm_device *dev, int crtc);
171
172 extern irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS);
173 extern void via_driver_irq_preinstall(struct drm_device * dev);
174 extern int via_driver_irq_postinstall(struct drm_device * dev);
175 extern void via_driver_irq_uninstall(struct drm_device * dev);
176
177 extern int via_dma_cleanup(struct drm_device * dev);
178 extern void via_init_command_verifier(void);
179 extern int via_driver_dma_quiescent(struct drm_device * dev);
180 extern void via_init_futex(drm_via_private_t *dev_priv);
181 extern void via_cleanup_futex(drm_via_private_t *dev_priv);
182 extern void via_release_futex(drm_via_private_t *dev_priv, int context);
183
184 #ifdef VIA_HAVE_CORE_MM
185 extern void via_reclaim_buffers_locked(struct drm_device *dev,
186                                        struct drm_file *file_priv);
187 extern void via_lastclose(struct drm_device *dev);
188 #else
189 extern int via_init_context(struct drm_device * dev, int context);
190 #endif
191
192 #ifdef VIA_HAVE_DMABLIT
193 extern void via_dmablit_handler(struct drm_device *dev, int engine, int from_irq);
194 extern void via_init_dmablit(struct drm_device *dev);
195 #endif
196
197 #endif