Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 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 | |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 27 | #include <drm/drm_mm.h> |
Daniel Vetter | 4f03b1f | 2014-09-10 12:43:49 +0200 | [diff] [blame] | 28 | #include <drm/drm_legacy.h> |
| 29 | |
Dave Airlie | 9251424 | 2005-11-12 21:52:46 +1100 | [diff] [blame] | 30 | #define DRIVER_AUTHOR "Various" |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 31 | |
| 32 | #define DRIVER_NAME "via" |
| 33 | #define DRIVER_DESC "VIA Unichrome / Pro" |
Thomas Hellstrom | a0a6dd0 | 2007-05-08 15:47:41 +1000 | [diff] [blame] | 34 | #define DRIVER_DATE "20070202" |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 35 | |
| 36 | #define DRIVER_MAJOR 2 |
Thomas Hellstrom | 9b8d9d0 | 2007-01-08 21:21:41 +1100 | [diff] [blame] | 37 | #define DRIVER_MINOR 11 |
Thomas Hellstrom | a0a6dd0 | 2007-05-08 15:47:41 +1000 | [diff] [blame] | 38 | #define DRIVER_PATCHLEVEL 1 |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 39 | |
| 40 | #include "via_verifier.h" |
| 41 | |
Dave Airlie | 9251424 | 2005-11-12 21:52:46 +1100 | [diff] [blame] | 42 | #include "via_dmablit.h" |
| 43 | |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 44 | #define VIA_PCI_BUF_SIZE 60000 |
| 45 | #define VIA_FIRE_BUF_SIZE 1024 |
Dave Airlie | 9251424 | 2005-11-12 21:52:46 +1100 | [diff] [blame] | 46 | #define VIA_NUM_IRQS 4 |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 47 | |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 48 | typedef struct drm_via_ring_buffer { |
Dave Airlie | 9251424 | 2005-11-12 21:52:46 +1100 | [diff] [blame] | 49 | drm_local_map_t map; |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 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; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 61 | |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 62 | typedef struct drm_via_private { |
| 63 | drm_via_sarea_t *sarea_priv; |
Dave Airlie | 9251424 | 2005-11-12 21:52:46 +1100 | [diff] [blame] | 64 | drm_local_map_t *sarea; |
| 65 | drm_local_map_t *fb; |
| 66 | drm_local_map_t *mmio; |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 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; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 77 | struct timeval last_vblank; |
| 78 | int last_vblank_valid; |
| 79 | unsigned usec_per_vblank; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 80 | atomic_t vbl_received; |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 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; |
Thomas Hellstrom | 689692e | 2007-01-08 21:19:57 +1100 | [diff] [blame] | 85 | int chipset; |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 86 | drm_via_irq_t via_irqs[VIA_NUM_IRQS]; |
| 87 | unsigned num_irqs; |
| 88 | maskarray_t *irq_masks; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 89 | uint32_t irq_enable_mask; |
| 90 | uint32_t irq_pending_mask; |
Dave Airlie | 9251424 | 2005-11-12 21:52:46 +1100 | [diff] [blame] | 91 | int *irq_map; |
Thomas Hellstrom | ce65a44 | 2006-08-07 22:03:22 +1000 | [diff] [blame] | 92 | unsigned int idle_fault; |
Thomas Hellstrom | ce65a44 | 2006-08-07 22:03:22 +1000 | [diff] [blame] | 93 | int vram_initialized; |
Daniel Vetter | 977b4f6 | 2011-10-26 22:21:13 +0200 | [diff] [blame] | 94 | struct drm_mm vram_mm; |
Thomas Hellstrom | ce65a44 | 2006-08-07 22:03:22 +1000 | [diff] [blame] | 95 | int agp_initialized; |
Daniel Vetter | 977b4f6 | 2011-10-26 22:21:13 +0200 | [diff] [blame] | 96 | struct drm_mm agp_mm; |
Daniel Vetter | 77ee8f3 | 2011-10-25 17:55:31 +0200 | [diff] [blame] | 97 | /** Mapping of userspace keys to mm objects */ |
| 98 | struct idr object_idr; |
Thomas Hellstrom | ce65a44 | 2006-08-07 22:03:22 +1000 | [diff] [blame] | 99 | unsigned long vram_offset; |
| 100 | unsigned long agp_offset; |
Dave Airlie | 9251424 | 2005-11-12 21:52:46 +1100 | [diff] [blame] | 101 | drm_via_blitq_t blit_queues[VIA_NUM_BLIT_ENGINES]; |
Thomas Hellstrom | a0a6dd0 | 2007-05-08 15:47:41 +1000 | [diff] [blame] | 102 | uint32_t dma_diff; |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 103 | } drm_via_private_t; |
| 104 | |
Dave Airlie | 9251424 | 2005-11-12 21:52:46 +1100 | [diff] [blame] | 105 | enum via_family { |
Thomas Hellstrom | 689692e | 2007-01-08 21:19:57 +1100 | [diff] [blame] | 106 | VIA_OTHER = 0, /* Baseline */ |
| 107 | VIA_PRO_GROUP_A, /* Another video engine and DMA commands */ |
| 108 | VIA_DX9_0 /* Same video as pro_group_a, but 3D is unsupported */ |
Dave Airlie | 9251424 | 2005-11-12 21:52:46 +1100 | [diff] [blame] | 109 | }; |
| 110 | |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 111 | /* VIA MMIO register access */ |
| 112 | #define VIA_BASE ((dev_priv->mmio)) |
| 113 | |
| 114 | #define VIA_READ(reg) DRM_READ32(VIA_BASE, reg) |
Nicolas Kaiser | 58c1e85 | 2010-07-11 15:32:42 +0200 | [diff] [blame] | 115 | #define VIA_WRITE(reg, val) DRM_WRITE32(VIA_BASE, reg, val) |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 116 | #define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg) |
Nicolas Kaiser | 58c1e85 | 2010-07-11 15:32:42 +0200 | [diff] [blame] | 117 | #define VIA_WRITE8(reg, val) DRM_WRITE8(VIA_BASE, reg, val) |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 118 | |
Rob Clark | baa7094 | 2013-08-02 13:27:49 -0400 | [diff] [blame] | 119 | extern const struct drm_ioctl_desc via_ioctls[]; |
Dave Airlie | 9251424 | 2005-11-12 21:52:46 +1100 | [diff] [blame] | 120 | extern int via_max_ioctl; |
| 121 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 122 | extern int via_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv); |
| 123 | extern int via_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv); |
| 124 | extern int via_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv); |
| 125 | extern int via_agp_init(struct drm_device *dev, void *data, struct drm_file *file_priv); |
| 126 | extern int via_map_init(struct drm_device *dev, void *data, struct drm_file *file_priv); |
| 127 | extern int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_priv); |
| 128 | extern int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv); |
Nicolas Kaiser | 58c1e85 | 2010-07-11 15:32:42 +0200 | [diff] [blame] | 129 | extern int via_dma_blit_sync(struct drm_device *dev, void *data, struct drm_file *file_priv); |
| 130 | extern int via_dma_blit(struct drm_device *dev, void *data, struct drm_file *file_priv); |
Dave Airlie | 9251424 | 2005-11-12 21:52:46 +1100 | [diff] [blame] | 131 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 132 | extern int via_driver_load(struct drm_device *dev, unsigned long chipset); |
| 133 | extern int via_driver_unload(struct drm_device *dev); |
Dave Airlie | 9251424 | 2005-11-12 21:52:46 +1100 | [diff] [blame] | 134 | |
Nicolas Kaiser | 58c1e85 | 2010-07-11 15:32:42 +0200 | [diff] [blame] | 135 | extern int via_init_context(struct drm_device *dev, int context); |
| 136 | extern int via_final_context(struct drm_device *dev, int context); |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 137 | |
Nicolas Kaiser | 58c1e85 | 2010-07-11 15:32:42 +0200 | [diff] [blame] | 138 | extern int via_do_cleanup_map(struct drm_device *dev); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 139 | extern u32 via_get_vblank_counter(struct drm_device *dev, int crtc); |
| 140 | extern int via_enable_vblank(struct drm_device *dev, int crtc); |
| 141 | extern void via_disable_vblank(struct drm_device *dev, int crtc); |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 142 | |
Daniel Vetter | e9f0d76 | 2013-12-11 11:34:42 +0100 | [diff] [blame] | 143 | extern irqreturn_t via_driver_irq_handler(int irq, void *arg); |
Nicolas Kaiser | 58c1e85 | 2010-07-11 15:32:42 +0200 | [diff] [blame] | 144 | extern void via_driver_irq_preinstall(struct drm_device *dev); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 145 | extern int via_driver_irq_postinstall(struct drm_device *dev); |
Nicolas Kaiser | 58c1e85 | 2010-07-11 15:32:42 +0200 | [diff] [blame] | 146 | extern void via_driver_irq_uninstall(struct drm_device *dev); |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 147 | |
Nicolas Kaiser | 58c1e85 | 2010-07-11 15:32:42 +0200 | [diff] [blame] | 148 | extern int via_dma_cleanup(struct drm_device *dev); |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 149 | extern void via_init_command_verifier(void); |
Nicolas Kaiser | 58c1e85 | 2010-07-11 15:32:42 +0200 | [diff] [blame] | 150 | extern int via_driver_dma_quiescent(struct drm_device *dev); |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 151 | extern void via_init_futex(drm_via_private_t *dev_priv); |
| 152 | extern void via_cleanup_futex(drm_via_private_t *dev_priv); |
| 153 | extern void via_release_futex(drm_via_private_t *dev_priv, int context); |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 154 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 155 | extern void via_reclaim_buffers_locked(struct drm_device *dev, |
| 156 | struct drm_file *file_priv); |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 157 | extern void via_lastclose(struct drm_device *dev); |
Thomas Hellstrom | ce65a44 | 2006-08-07 22:03:22 +1000 | [diff] [blame] | 158 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 159 | extern void via_dmablit_handler(struct drm_device *dev, int engine, int from_irq); |
| 160 | extern void via_init_dmablit(struct drm_device *dev); |
Dave Airlie | b3a8363 | 2005-09-30 18:37:36 +1000 | [diff] [blame] | 161 | |
Dave Airlie | 22f579c | 2005-06-28 22:48:56 +1000 | [diff] [blame] | 162 | #endif |