via_drv.h revision 1.1.1.3 1 /* $NetBSD: via_drv.h,v 1.1.1.3 2018/08/27 01:34:59 riastradh Exp $ */
2
3 /*
4 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
5 * Copyright 2001-2003 S3 Graphics, Inc. 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, sub license,
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
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
21 * VIA, S3 GRAPHICS, 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 OTHER
24 * DEALINGS IN THE SOFTWARE.
25 */
26 #ifndef _VIA_DRV_H_
27 #define _VIA_DRV_H_
28
29 #include <drm/drm_mm.h>
30 #include <drm/drm_legacy.h>
31
32 #define DRIVER_AUTHOR "Various"
33
34 #define DRIVER_NAME "via"
35 #define DRIVER_DESC "VIA Unichrome / Pro"
36 #define DRIVER_DATE "20070202"
37
38 #define DRIVER_MAJOR 2
39 #define DRIVER_MINOR 11
40 #define DRIVER_PATCHLEVEL 1
41
42 #include "via_verifier.h"
43
44 #include "via_dmablit.h"
45
46 #define VIA_PCI_BUF_SIZE 60000
47 #define VIA_FIRE_BUF_SIZE 1024
48 #define VIA_NUM_IRQS 4
49
50 typedef struct drm_via_ring_buffer {
51 drm_local_map_t map;
52 char *virtual_start;
53 } drm_via_ring_buffer_t;
54
55 typedef uint32_t maskarray_t[5];
56
57 typedef struct drm_via_irq {
58 atomic_t irq_received;
59 uint32_t pending_mask;
60 uint32_t enable_mask;
61 wait_queue_head_t irq_queue;
62 } drm_via_irq_t;
63
64 typedef struct drm_via_private {
65 drm_via_sarea_t *sarea_priv;
66 drm_local_map_t *sarea;
67 drm_local_map_t *fb;
68 drm_local_map_t *mmio;
69 unsigned long agpAddr;
70 wait_queue_head_t decoder_queue[VIA_NR_XVMC_LOCKS];
71 char *dma_ptr;
72 unsigned int dma_low;
73 unsigned int dma_high;
74 unsigned int dma_offset;
75 uint32_t dma_wrap;
76 volatile uint32_t *last_pause_ptr;
77 volatile uint32_t *hw_addr_ptr;
78 drm_via_ring_buffer_t ring;
79 struct timeval last_vblank;
80 int last_vblank_valid;
81 unsigned usec_per_vblank;
82 atomic_t vbl_received;
83 drm_via_state_t hc_state;
84 char pci_buf[VIA_PCI_BUF_SIZE];
85 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
86 uint32_t num_fire_offsets;
87 int chipset;
88 drm_via_irq_t via_irqs[VIA_NUM_IRQS];
89 unsigned num_irqs;
90 maskarray_t *irq_masks;
91 uint32_t irq_enable_mask;
92 uint32_t irq_pending_mask;
93 int *irq_map;
94 unsigned int idle_fault;
95 int vram_initialized;
96 struct drm_mm vram_mm;
97 int agp_initialized;
98 struct drm_mm agp_mm;
99 /** Mapping of userspace keys to mm objects */
100 struct idr object_idr;
101 unsigned long vram_offset;
102 unsigned long agp_offset;
103 drm_via_blitq_t blit_queues[VIA_NUM_BLIT_ENGINES];
104 uint32_t dma_diff;
105 } drm_via_private_t;
106
107 struct via_file_private {
108 struct list_head obj_list;
109 };
110
111 enum via_family {
112 VIA_OTHER = 0, /* Baseline */
113 VIA_PRO_GROUP_A, /* Another video engine and DMA commands */
114 VIA_DX9_0 /* Same video as pro_group_a, but 3D is unsupported */
115 };
116
117 /* VIA MMIO register access */
118 #define VIA_BASE ((dev_priv->mmio))
119
120 #define VIA_READ(reg) DRM_READ32(VIA_BASE, reg)
121 #define VIA_WRITE(reg, val) DRM_WRITE32(VIA_BASE, reg, val)
122 #define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg)
123 #define VIA_WRITE8(reg, val) DRM_WRITE8(VIA_BASE, reg, val)
124
125 extern const struct drm_ioctl_desc via_ioctls[];
126 extern int via_max_ioctl;
127
128 extern int via_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
129 extern int via_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv);
130 extern int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv);
131 extern int via_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
132 extern int via_map_init(struct drm_device *dev, void *data, struct drm_file *file_priv);
133 extern int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_priv);
134 extern int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv);
135 extern int via_dma_blit_sync(struct drm_device *dev, void *data, struct drm_file *file_priv);
136 extern int via_dma_blit(struct drm_device *dev, void *data, struct drm_file *file_priv);
137
138 extern int via_driver_load(struct drm_device *dev, unsigned long chipset);
139 extern int via_driver_unload(struct drm_device *dev);
140
141 extern int via_init_context(struct drm_device *dev, int context);
142 extern int via_final_context(struct drm_device *dev, int context);
143
144 extern int via_do_cleanup_map(struct drm_device *dev);
145 extern u32 via_get_vblank_counter(struct drm_device *dev, unsigned int pipe);
146 extern int via_enable_vblank(struct drm_device *dev, unsigned int pipe);
147 extern void via_disable_vblank(struct drm_device *dev, unsigned int pipe);
148
149 extern irqreturn_t via_driver_irq_handler(int irq, void *arg);
150 extern void via_driver_irq_preinstall(struct drm_device *dev);
151 extern int via_driver_irq_postinstall(struct drm_device *dev);
152 extern void via_driver_irq_uninstall(struct drm_device *dev);
153
154 extern int via_dma_cleanup(struct drm_device *dev);
155 extern void via_init_command_verifier(void);
156 extern int via_driver_dma_quiescent(struct drm_device *dev);
157 extern void via_init_futex(drm_via_private_t *dev_priv);
158 extern void via_cleanup_futex(drm_via_private_t *dev_priv);
159 extern void via_release_futex(drm_via_private_t *dev_priv, int context);
160
161 extern void via_reclaim_buffers_locked(struct drm_device *dev,
162 struct drm_file *file_priv);
163 extern void via_lastclose(struct drm_device *dev);
164
165 extern void via_dmablit_handler(struct drm_device *dev, int engine, int from_irq);
166 extern void via_init_dmablit(struct drm_device *dev);
167
168 #endif
169