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