via_drv.h 5.9 KB

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