2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
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:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
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.
28 #define DRIVER_AUTHOR "Various"
30 #define DRIVER_NAME "via"
31 #define DRIVER_DESC "VIA Unichrome / Pro"
32 #define DRIVER_DATE "20060529"
34 #define DRIVER_MAJOR 2
35 #define DRIVER_MINOR 10
36 #define DRIVER_PATCHLEVEL 0
38 #include "via_verifier.h"
40 #include "via_dmablit.h"
42 #define VIA_PCI_BUF_SIZE 60000
43 #define VIA_FIRE_BUF_SIZE 1024
44 #define VIA_NUM_IRQS 4
46 typedef struct drm_via_ring_buffer
{
49 } drm_via_ring_buffer_t
;
51 typedef uint32_t maskarray_t
[5];
53 typedef struct drm_via_irq
{
54 atomic_t irq_received
;
55 uint32_t pending_mask
;
57 wait_queue_head_t irq_queue
;
60 typedef struct drm_via_private
{
61 drm_via_sarea_t
*sarea_priv
;
62 drm_local_map_t
*sarea
;
64 drm_local_map_t
*mmio
;
65 unsigned long agpAddr
;
66 wait_queue_head_t decoder_queue
[VIA_NR_XVMC_LOCKS
];
69 unsigned int dma_high
;
70 unsigned int dma_offset
;
72 volatile uint32_t *last_pause_ptr
;
73 volatile uint32_t *hw_addr_ptr
;
74 drm_via_ring_buffer_t ring
;
75 struct timeval last_vblank
;
76 int last_vblank_valid
;
77 unsigned usec_per_vblank
;
78 drm_via_state_t hc_state
;
79 char pci_buf
[VIA_PCI_BUF_SIZE
];
80 const uint32_t *fire_offsets
[VIA_FIRE_BUF_SIZE
];
81 uint32_t num_fire_offsets
;
83 drm_via_irq_t via_irqs
[VIA_NUM_IRQS
];
85 maskarray_t
*irq_masks
;
86 uint32_t irq_enable_mask
;
87 uint32_t irq_pending_mask
;
89 unsigned int idle_fault
;
93 unsigned long vram_offset
;
94 unsigned long agp_offset
;
95 drm_via_blitq_t blit_queues
[VIA_NUM_BLIT_ENGINES
];
103 /* VIA MMIO register access */
104 #define VIA_BASE ((dev_priv->mmio))
106 #define VIA_READ(reg) DRM_READ32(VIA_BASE, reg)
107 #define VIA_WRITE(reg,val) DRM_WRITE32(VIA_BASE, reg, val)
108 #define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg)
109 #define VIA_WRITE8(reg,val) DRM_WRITE8(VIA_BASE, reg, val)
111 extern drm_ioctl_desc_t via_ioctls
[];
112 extern int via_max_ioctl
;
114 extern int via_fb_init(DRM_IOCTL_ARGS
);
115 extern int via_mem_alloc(DRM_IOCTL_ARGS
);
116 extern int via_mem_free(DRM_IOCTL_ARGS
);
117 extern int via_agp_init(DRM_IOCTL_ARGS
);
118 extern int via_map_init(DRM_IOCTL_ARGS
);
119 extern int via_decoder_futex(DRM_IOCTL_ARGS
);
120 extern int via_wait_irq(DRM_IOCTL_ARGS
);
121 extern int via_dma_blit_sync( DRM_IOCTL_ARGS
);
122 extern int via_dma_blit( DRM_IOCTL_ARGS
);
124 extern int via_driver_load(drm_device_t
*dev
, unsigned long chipset
);
125 extern int via_driver_unload(drm_device_t
*dev
);
127 extern int via_init_context(drm_device_t
* dev
, int context
);
128 extern int via_final_context(drm_device_t
* dev
, int context
);
130 extern int via_do_cleanup_map(drm_device_t
* dev
);
131 extern int via_driver_vblank_wait(drm_device_t
* dev
, unsigned int *sequence
);
133 extern irqreturn_t
via_driver_irq_handler(DRM_IRQ_ARGS
);
134 extern void via_driver_irq_preinstall(drm_device_t
* dev
);
135 extern void via_driver_irq_postinstall(drm_device_t
* dev
);
136 extern void via_driver_irq_uninstall(drm_device_t
* dev
);
138 extern int via_dma_cleanup(drm_device_t
* dev
);
139 extern void via_init_command_verifier(void);
140 extern int via_driver_dma_quiescent(drm_device_t
* dev
);
141 extern void via_init_futex(drm_via_private_t
* dev_priv
);
142 extern void via_cleanup_futex(drm_via_private_t
* dev_priv
);
143 extern void via_release_futex(drm_via_private_t
* dev_priv
, int context
);
145 extern void via_reclaim_buffers_locked(drm_device_t
*dev
, struct file
*filp
);
146 extern void via_lastclose(drm_device_t
*dev
);
148 extern void via_dmablit_handler(drm_device_t
*dev
, int engine
, int from_irq
);
149 extern void via_init_dmablit(drm_device_t
*dev
);