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.
27 #define DRIVER_AUTHOR "VIA"
29 #define DRIVER_NAME "via"
30 #define DRIVER_DESC "VIA Unichrome / Pro"
31 #define DRIVER_DATE "20050523"
33 #define DRIVER_MAJOR 2
34 #define DRIVER_MINOR 6
35 #define DRIVER_PATCHLEVEL 3
37 #include "via_verifier.h"
39 #define VIA_PCI_BUF_SIZE 60000
40 #define VIA_FIRE_BUF_SIZE 1024
41 #define VIA_NUM_IRQS 2
43 typedef struct drm_via_ring_buffer
{
46 } drm_via_ring_buffer_t
;
48 typedef uint32_t maskarray_t
[5];
50 typedef struct drm_via_irq
{
51 atomic_t irq_received
;
52 uint32_t pending_mask
;
54 wait_queue_head_t irq_queue
;
57 typedef struct drm_via_private
{
58 drm_via_sarea_t
*sarea_priv
;
62 unsigned long agpAddr
;
63 wait_queue_head_t decoder_queue
[VIA_NR_XVMC_LOCKS
];
66 unsigned int dma_high
;
67 unsigned int dma_offset
;
69 volatile uint32_t *last_pause_ptr
;
70 volatile uint32_t *hw_addr_ptr
;
71 drm_via_ring_buffer_t ring
;
72 struct timeval last_vblank
;
73 int last_vblank_valid
;
74 unsigned usec_per_vblank
;
75 drm_via_state_t hc_state
;
76 char pci_buf
[VIA_PCI_BUF_SIZE
];
77 const uint32_t *fire_offsets
[VIA_FIRE_BUF_SIZE
];
78 uint32_t num_fire_offsets
;
80 drm_via_irq_t via_irqs
[VIA_NUM_IRQS
];
82 maskarray_t
*irq_masks
;
83 uint32_t irq_enable_mask
;
84 uint32_t irq_pending_mask
;
87 /* VIA MMIO register access */
88 #define VIA_BASE ((dev_priv->mmio))
90 #define VIA_READ(reg) DRM_READ32(VIA_BASE, reg)
91 #define VIA_WRITE(reg,val) DRM_WRITE32(VIA_BASE, reg, val)
92 #define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg)
93 #define VIA_WRITE8(reg,val) DRM_WRITE8(VIA_BASE, reg, val)
95 extern int via_init_context(drm_device_t
* dev
, int context
);
96 extern int via_final_context(drm_device_t
* dev
, int context
);
98 extern int via_do_cleanup_map(drm_device_t
* dev
);
99 extern int via_map_init(struct inode
*inode
, struct file
*filp
,
100 unsigned int cmd
, unsigned long arg
);
101 extern int via_driver_vblank_wait(drm_device_t
* dev
, unsigned int *sequence
);
103 extern irqreturn_t
via_driver_irq_handler(DRM_IRQ_ARGS
);
104 extern void via_driver_irq_preinstall(drm_device_t
* dev
);
105 extern void via_driver_irq_postinstall(drm_device_t
* dev
);
106 extern void via_driver_irq_uninstall(drm_device_t
* dev
);
108 extern int via_dma_cleanup(drm_device_t
* dev
);
109 extern void via_init_command_verifier(void);
110 extern int via_driver_dma_quiescent(drm_device_t
* dev
);
111 extern void via_init_futex(drm_via_private_t
* dev_priv
);
112 extern void via_cleanup_futex(drm_via_private_t
* dev_priv
);
113 extern void via_release_futex(drm_via_private_t
* dev_priv
, int context
);
115 extern int via_parse_command_stream(drm_device_t
* dev
, const uint32_t * buf
,