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