Commit | Line | Data |
---|---|---|
22f579c6 DA |
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 | ||
760285e7 | 27 | #include <drm/drm_mm.h> |
4f03b1fc DV |
28 | #include <drm/drm_legacy.h> |
29 | ||
92514243 | 30 | #define DRIVER_AUTHOR "Various" |
22f579c6 DA |
31 | |
32 | #define DRIVER_NAME "via" | |
33 | #define DRIVER_DESC "VIA Unichrome / Pro" | |
a0a6dd0b | 34 | #define DRIVER_DATE "20070202" |
22f579c6 DA |
35 | |
36 | #define DRIVER_MAJOR 2 | |
9b8d9d0e | 37 | #define DRIVER_MINOR 11 |
a0a6dd0b | 38 | #define DRIVER_PATCHLEVEL 1 |
22f579c6 DA |
39 | |
40 | #include "via_verifier.h" | |
41 | ||
92514243 DA |
42 | #include "via_dmablit.h" |
43 | ||
22f579c6 DA |
44 | #define VIA_PCI_BUF_SIZE 60000 |
45 | #define VIA_FIRE_BUF_SIZE 1024 | |
92514243 | 46 | #define VIA_NUM_IRQS 4 |
22f579c6 | 47 | |
22f579c6 | 48 | typedef struct drm_via_ring_buffer { |
92514243 | 49 | drm_local_map_t map; |
22f579c6 DA |
50 | char *virtual_start; |
51 | } drm_via_ring_buffer_t; | |
52 | ||
53 | typedef uint32_t maskarray_t[5]; | |
54 | ||
55 | typedef struct drm_via_irq { | |
56 | atomic_t irq_received; | |
57 | uint32_t pending_mask; | |
58 | uint32_t enable_mask; | |
59 | wait_queue_head_t irq_queue; | |
60 | } drm_via_irq_t; | |
b5e89ed5 | 61 | |
22f579c6 DA |
62 | typedef struct drm_via_private { |
63 | drm_via_sarea_t *sarea_priv; | |
92514243 DA |
64 | drm_local_map_t *sarea; |
65 | drm_local_map_t *fb; | |
66 | drm_local_map_t *mmio; | |
22f579c6 DA |
67 | unsigned long agpAddr; |
68 | wait_queue_head_t decoder_queue[VIA_NR_XVMC_LOCKS]; | |
69 | char *dma_ptr; | |
70 | unsigned int dma_low; | |
71 | unsigned int dma_high; | |
72 | unsigned int dma_offset; | |
73 | uint32_t dma_wrap; | |
74 | volatile uint32_t *last_pause_ptr; | |
75 | volatile uint32_t *hw_addr_ptr; | |
76 | drm_via_ring_buffer_t ring; | |
b5e89ed5 DA |
77 | struct timeval last_vblank; |
78 | int last_vblank_valid; | |
79 | unsigned usec_per_vblank; | |
0a3e67a4 | 80 | atomic_t vbl_received; |
22f579c6 DA |
81 | drm_via_state_t hc_state; |
82 | char pci_buf[VIA_PCI_BUF_SIZE]; | |
83 | const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE]; | |
84 | uint32_t num_fire_offsets; | |
689692e7 | 85 | int chipset; |
22f579c6 DA |
86 | drm_via_irq_t via_irqs[VIA_NUM_IRQS]; |
87 | unsigned num_irqs; | |
88 | maskarray_t *irq_masks; | |
b5e89ed5 DA |
89 | uint32_t irq_enable_mask; |
90 | uint32_t irq_pending_mask; | |
92514243 | 91 | int *irq_map; |
ce65a44d | 92 | unsigned int idle_fault; |
ce65a44d | 93 | int vram_initialized; |
977b4f6e | 94 | struct drm_mm vram_mm; |
ce65a44d | 95 | int agp_initialized; |
977b4f6e | 96 | struct drm_mm agp_mm; |
77ee8f38 DV |
97 | /** Mapping of userspace keys to mm objects */ |
98 | struct idr object_idr; | |
ce65a44d TH |
99 | unsigned long vram_offset; |
100 | unsigned long agp_offset; | |
92514243 | 101 | drm_via_blitq_t blit_queues[VIA_NUM_BLIT_ENGINES]; |
a0a6dd0b | 102 | uint32_t dma_diff; |
22f579c6 DA |
103 | } drm_via_private_t; |
104 | ||
c76af02d MR |
105 | struct via_file_private { |
106 | struct list_head obj_list; | |
107 | }; | |
108 | ||
92514243 | 109 | enum via_family { |
689692e7 TH |
110 | VIA_OTHER = 0, /* Baseline */ |
111 | VIA_PRO_GROUP_A, /* Another video engine and DMA commands */ | |
112 | VIA_DX9_0 /* Same video as pro_group_a, but 3D is unsupported */ | |
92514243 DA |
113 | }; |
114 | ||
22f579c6 DA |
115 | /* VIA MMIO register access */ |
116 | #define VIA_BASE ((dev_priv->mmio)) | |
117 | ||
118 | #define VIA_READ(reg) DRM_READ32(VIA_BASE, reg) | |
58c1e85a | 119 | #define VIA_WRITE(reg, val) DRM_WRITE32(VIA_BASE, reg, val) |
22f579c6 | 120 | #define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg) |
58c1e85a | 121 | #define VIA_WRITE8(reg, val) DRM_WRITE8(VIA_BASE, reg, val) |
22f579c6 | 122 | |
baa70943 | 123 | extern const struct drm_ioctl_desc via_ioctls[]; |
92514243 DA |
124 | extern int via_max_ioctl; |
125 | ||
c153f45f EA |
126 | extern int via_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv); |
127 | extern int via_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv); | |
128 | extern int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv); | |
129 | extern int via_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv); | |
130 | extern int via_map_init(struct drm_device *dev, void *data, struct drm_file *file_priv); | |
131 | extern int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_priv); | |
132 | extern int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv); | |
58c1e85a NK |
133 | extern int via_dma_blit_sync(struct drm_device *dev, void *data, struct drm_file *file_priv); |
134 | extern int via_dma_blit(struct drm_device *dev, void *data, struct drm_file *file_priv); | |
92514243 | 135 | |
84b1fd10 DA |
136 | extern int via_driver_load(struct drm_device *dev, unsigned long chipset); |
137 | extern int via_driver_unload(struct drm_device *dev); | |
92514243 | 138 | |
58c1e85a NK |
139 | extern int via_init_context(struct drm_device *dev, int context); |
140 | extern int via_final_context(struct drm_device *dev, int context); | |
22f579c6 | 141 | |
58c1e85a | 142 | extern int via_do_cleanup_map(struct drm_device *dev); |
88e72717 TR |
143 | extern u32 via_get_vblank_counter(struct drm_device *dev, unsigned int pipe); |
144 | extern int via_enable_vblank(struct drm_device *dev, unsigned int pipe); | |
145 | extern void via_disable_vblank(struct drm_device *dev, unsigned int pipe); | |
22f579c6 | 146 | |
e9f0d76f | 147 | extern irqreturn_t via_driver_irq_handler(int irq, void *arg); |
58c1e85a | 148 | extern void via_driver_irq_preinstall(struct drm_device *dev); |
0a3e67a4 | 149 | extern int via_driver_irq_postinstall(struct drm_device *dev); |
58c1e85a | 150 | extern void via_driver_irq_uninstall(struct drm_device *dev); |
22f579c6 | 151 | |
58c1e85a | 152 | extern int via_dma_cleanup(struct drm_device *dev); |
22f579c6 | 153 | extern void via_init_command_verifier(void); |
58c1e85a | 154 | extern int via_driver_dma_quiescent(struct drm_device *dev); |
0a3e67a4 JB |
155 | extern void via_init_futex(drm_via_private_t *dev_priv); |
156 | extern void via_cleanup_futex(drm_via_private_t *dev_priv); | |
157 | extern void via_release_futex(drm_via_private_t *dev_priv, int context); | |
22f579c6 | 158 | |
0a3e67a4 JB |
159 | extern void via_reclaim_buffers_locked(struct drm_device *dev, |
160 | struct drm_file *file_priv); | |
84b1fd10 | 161 | extern void via_lastclose(struct drm_device *dev); |
ce65a44d | 162 | |
84b1fd10 DA |
163 | extern void via_dmablit_handler(struct drm_device *dev, int engine, int from_irq); |
164 | extern void via_init_dmablit(struct drm_device *dev); | |
b3a83639 | 165 | |
22f579c6 | 166 | #endif |