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