diff options
author | Dave Airlie <airlied@starflyer.(none)> | 2005-11-12 05:52:46 -0500 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2005-11-12 05:52:46 -0500 |
commit | 925142431bd653175b80ae153bd7a8bc13628bde (patch) | |
tree | 594c1e65d3bf25b10961ea2b97dee5704b4f6cb5 /drivers/char/drm | |
parent | 792d2b9a12594522111fbe2a7f17460a4d7edff7 (diff) |
drm: update VIA driver to 2.7.2
Add PCI DMA blitengine to VIA DRM
Add portability code for porting VIA to FreeBSD.
Sync via_drm.h with 3d driver
From: Thomas Hellstrom <unichrome@shipmail.org>, Eric Anholt <anholt@freebsd.org>
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm')
-rw-r--r-- | drivers/char/drm/Makefile | 2 | ||||
-rw-r--r-- | drivers/char/drm/drm_os_linux.h | 1 | ||||
-rw-r--r-- | drivers/char/drm/via_dma.c | 36 | ||||
-rw-r--r-- | drivers/char/drm/via_drm.h | 60 | ||||
-rw-r--r-- | drivers/char/drm/via_drv.c | 21 | ||||
-rw-r--r-- | drivers/char/drm/via_drv.h | 56 | ||||
-rw-r--r-- | drivers/char/drm/via_irq.c | 53 | ||||
-rw-r--r-- | drivers/char/drm/via_map.c | 47 | ||||
-rw-r--r-- | drivers/char/drm/via_mm.c | 16 | ||||
-rw-r--r-- | drivers/char/drm/via_verifier.c | 6 | ||||
-rw-r--r-- | drivers/char/drm/via_verifier.h | 4 | ||||
-rw-r--r-- | drivers/char/drm/via_video.c | 7 |
12 files changed, 211 insertions, 98 deletions
diff --git a/drivers/char/drm/Makefile b/drivers/char/drm/Makefile index f1898cd96597..9d180c42816c 100644 --- a/drivers/char/drm/Makefile +++ b/drivers/char/drm/Makefile | |||
@@ -18,7 +18,7 @@ radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o | |||
18 | ffb-objs := ffb_drv.o ffb_context.o | 18 | ffb-objs := ffb_drv.o ffb_context.o |
19 | sis-objs := sis_drv.o sis_ds.o sis_mm.o | 19 | sis-objs := sis_drv.o sis_ds.o sis_mm.o |
20 | savage-objs := savage_drv.o savage_bci.o savage_state.o | 20 | savage-objs := savage_drv.o savage_bci.o savage_state.o |
21 | via-objs := via_irq.o via_drv.o via_ds.o via_map.o via_mm.o via_dma.o via_verifier.o via_video.o | 21 | via-objs := via_irq.o via_drv.o via_ds.o via_map.o via_mm.o via_dma.o via_verifier.o via_video.o via_dmablit.o |
22 | 22 | ||
23 | ifeq ($(CONFIG_COMPAT),y) | 23 | ifeq ($(CONFIG_COMPAT),y) |
24 | drm-objs += drm_ioc32.o | 24 | drm-objs += drm_ioc32.o |
diff --git a/drivers/char/drm/drm_os_linux.h b/drivers/char/drm/drm_os_linux.h index d51aeb4966f4..695115d70382 100644 --- a/drivers/char/drm/drm_os_linux.h +++ b/drivers/char/drm/drm_os_linux.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #define DRM_ERR(d) -(d) | 13 | #define DRM_ERR(d) -(d) |
14 | /** Current process ID */ | 14 | /** Current process ID */ |
15 | #define DRM_CURRENTPID current->pid | 15 | #define DRM_CURRENTPID current->pid |
16 | #define DRM_SUSER(p) capable(CAP_SYS_ADMIN) | ||
16 | #define DRM_UDELAY(d) udelay(d) | 17 | #define DRM_UDELAY(d) udelay(d) |
17 | /** Read a byte from a MMIO region */ | 18 | /** Read a byte from a MMIO region */ |
18 | #define DRM_READ8(map, offset) readb(((void __iomem *)(map)->handle) + (offset)) | 19 | #define DRM_READ8(map, offset) readb(((void __iomem *)(map)->handle) + (offset)) |
diff --git a/drivers/char/drm/via_dma.c b/drivers/char/drm/via_dma.c index d4b1766608b0..1acbeeb28069 100644 --- a/drivers/char/drm/via_dma.c +++ b/drivers/char/drm/via_dma.c | |||
@@ -213,7 +213,9 @@ static int via_initialize(drm_device_t * dev, | |||
213 | dev_priv->dma_wrap = init->size; | 213 | dev_priv->dma_wrap = init->size; |
214 | dev_priv->dma_offset = init->offset; | 214 | dev_priv->dma_offset = init->offset; |
215 | dev_priv->last_pause_ptr = NULL; | 215 | dev_priv->last_pause_ptr = NULL; |
216 | dev_priv->hw_addr_ptr = dev_priv->mmio->handle + init->reg_pause_addr; | 216 | dev_priv->hw_addr_ptr = |
217 | (volatile uint32_t *)((char *)dev_priv->mmio->handle + | ||
218 | init->reg_pause_addr); | ||
217 | 219 | ||
218 | via_cmdbuf_start(dev_priv); | 220 | via_cmdbuf_start(dev_priv); |
219 | 221 | ||
@@ -232,13 +234,13 @@ int via_dma_init(DRM_IOCTL_ARGS) | |||
232 | 234 | ||
233 | switch (init.func) { | 235 | switch (init.func) { |
234 | case VIA_INIT_DMA: | 236 | case VIA_INIT_DMA: |
235 | if (!capable(CAP_SYS_ADMIN)) | 237 | if (!DRM_SUSER(DRM_CURPROC)) |
236 | retcode = DRM_ERR(EPERM); | 238 | retcode = DRM_ERR(EPERM); |
237 | else | 239 | else |
238 | retcode = via_initialize(dev, dev_priv, &init); | 240 | retcode = via_initialize(dev, dev_priv, &init); |
239 | break; | 241 | break; |
240 | case VIA_CLEANUP_DMA: | 242 | case VIA_CLEANUP_DMA: |
241 | if (!capable(CAP_SYS_ADMIN)) | 243 | if (!DRM_SUSER(DRM_CURPROC)) |
242 | retcode = DRM_ERR(EPERM); | 244 | retcode = DRM_ERR(EPERM); |
243 | else | 245 | else |
244 | retcode = via_dma_cleanup(dev); | 246 | retcode = via_dma_cleanup(dev); |
@@ -349,9 +351,6 @@ int via_cmdbuffer(DRM_IOCTL_ARGS) | |||
349 | return 0; | 351 | return 0; |
350 | } | 352 | } |
351 | 353 | ||
352 | extern int | ||
353 | via_parse_command_stream(drm_device_t * dev, const uint32_t * buf, | ||
354 | unsigned int size); | ||
355 | static int via_dispatch_pci_cmdbuffer(drm_device_t * dev, | 354 | static int via_dispatch_pci_cmdbuffer(drm_device_t * dev, |
356 | drm_via_cmdbuffer_t * cmd) | 355 | drm_via_cmdbuffer_t * cmd) |
357 | { | 356 | { |
@@ -450,9 +449,9 @@ static int via_hook_segment(drm_via_private_t * dev_priv, | |||
450 | if ((count <= 8) && (count >= 0)) { | 449 | if ((count <= 8) && (count >= 0)) { |
451 | uint32_t rgtr, ptr; | 450 | uint32_t rgtr, ptr; |
452 | rgtr = *(dev_priv->hw_addr_ptr); | 451 | rgtr = *(dev_priv->hw_addr_ptr); |
453 | ptr = ((char *)dev_priv->last_pause_ptr - dev_priv->dma_ptr) + | 452 | ptr = ((volatile char *)dev_priv->last_pause_ptr - |
454 | dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4 - | 453 | dev_priv->dma_ptr) + dev_priv->dma_offset + |
455 | CMDBUF_ALIGNMENT_SIZE; | 454 | (uint32_t) dev_priv->agpAddr + 4 - CMDBUF_ALIGNMENT_SIZE; |
456 | if (rgtr <= ptr) { | 455 | if (rgtr <= ptr) { |
457 | DRM_ERROR | 456 | DRM_ERROR |
458 | ("Command regulator\npaused at count %d, address %x, " | 457 | ("Command regulator\npaused at count %d, address %x, " |
@@ -472,7 +471,7 @@ static int via_hook_segment(drm_via_private_t * dev_priv, | |||
472 | && count--) ; | 471 | && count--) ; |
473 | 472 | ||
474 | rgtr = *(dev_priv->hw_addr_ptr); | 473 | rgtr = *(dev_priv->hw_addr_ptr); |
475 | ptr = ((char *)paused_at - dev_priv->dma_ptr) + | 474 | ptr = ((volatile char *)paused_at - dev_priv->dma_ptr) + |
476 | dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4; | 475 | dev_priv->dma_offset + (uint32_t) dev_priv->agpAddr + 4; |
477 | 476 | ||
478 | ptr_low = (ptr > 3 * CMDBUF_ALIGNMENT_SIZE) ? | 477 | ptr_low = (ptr > 3 * CMDBUF_ALIGNMENT_SIZE) ? |
@@ -724,3 +723,20 @@ int via_cmdbuf_size(DRM_IOCTL_ARGS) | |||
724 | sizeof(d_siz)); | 723 | sizeof(d_siz)); |
725 | return ret; | 724 | return ret; |
726 | } | 725 | } |
726 | |||
727 | drm_ioctl_desc_t via_ioctls[] = { | ||
728 | [DRM_IOCTL_NR(DRM_VIA_ALLOCMEM)] = {via_mem_alloc, 1, 0}, | ||
729 | [DRM_IOCTL_NR(DRM_VIA_FREEMEM)] = {via_mem_free, 1, 0}, | ||
730 | [DRM_IOCTL_NR(DRM_VIA_AGP_INIT)] = {via_agp_init, 1, 0}, | ||
731 | [DRM_IOCTL_NR(DRM_VIA_FB_INIT)] = {via_fb_init, 1, 0}, | ||
732 | [DRM_IOCTL_NR(DRM_VIA_MAP_INIT)] = {via_map_init, 1, 0}, | ||
733 | [DRM_IOCTL_NR(DRM_VIA_DEC_FUTEX)] = {via_decoder_futex, 1, 0}, | ||
734 | [DRM_IOCTL_NR(DRM_VIA_DMA_INIT)] = {via_dma_init, 1, 0}, | ||
735 | [DRM_IOCTL_NR(DRM_VIA_CMDBUFFER)] = {via_cmdbuffer, 1, 0}, | ||
736 | [DRM_IOCTL_NR(DRM_VIA_FLUSH)] = {via_flush_ioctl, 1, 0}, | ||
737 | [DRM_IOCTL_NR(DRM_VIA_PCICMD)] = {via_pci_cmdbuffer, 1, 0}, | ||
738 | [DRM_IOCTL_NR(DRM_VIA_CMDBUF_SIZE)] = {via_cmdbuf_size, 1, 0}, | ||
739 | [DRM_IOCTL_NR(DRM_VIA_WAIT_IRQ)] = {via_wait_irq, 1, 0} | ||
740 | }; | ||
741 | |||
742 | int via_max_ioctl = DRM_ARRAY_SIZE(via_ioctls); | ||
diff --git a/drivers/char/drm/via_drm.h b/drivers/char/drm/via_drm.h index ebde9206115e..556d80722fd0 100644 --- a/drivers/char/drm/via_drm.h +++ b/drivers/char/drm/via_drm.h | |||
@@ -75,6 +75,8 @@ | |||
75 | #define DRM_VIA_CMDBUF_SIZE 0x0b | 75 | #define DRM_VIA_CMDBUF_SIZE 0x0b |
76 | #define NOT_USED | 76 | #define NOT_USED |
77 | #define DRM_VIA_WAIT_IRQ 0x0d | 77 | #define DRM_VIA_WAIT_IRQ 0x0d |
78 | #define DRM_VIA_DMA_BLIT 0x0e | ||
79 | #define DRM_VIA_BLIT_SYNC 0x0f | ||
78 | 80 | ||
79 | #define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t) | 81 | #define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t) |
80 | #define DRM_IOCTL_VIA_FREEMEM DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t) | 82 | #define DRM_IOCTL_VIA_FREEMEM DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t) |
@@ -89,6 +91,8 @@ | |||
89 | #define DRM_IOCTL_VIA_CMDBUF_SIZE DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_CMDBUF_SIZE, \ | 91 | #define DRM_IOCTL_VIA_CMDBUF_SIZE DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_CMDBUF_SIZE, \ |
90 | drm_via_cmdbuf_size_t) | 92 | drm_via_cmdbuf_size_t) |
91 | #define DRM_IOCTL_VIA_WAIT_IRQ DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_WAIT_IRQ, drm_via_irqwait_t) | 93 | #define DRM_IOCTL_VIA_WAIT_IRQ DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_WAIT_IRQ, drm_via_irqwait_t) |
94 | #define DRM_IOCTL_VIA_DMA_BLIT DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_DMA_BLIT, drm_via_dmablit_t) | ||
95 | #define DRM_IOCTL_VIA_BLIT_SYNC DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_BLIT_SYNC, drm_via_blitsync_t) | ||
92 | 96 | ||
93 | /* Indices into buf.Setup where various bits of state are mirrored per | 97 | /* Indices into buf.Setup where various bits of state are mirrored per |
94 | * context and per buffer. These can be fired at the card as a unit, | 98 | * context and per buffer. These can be fired at the card as a unit, |
@@ -103,8 +107,12 @@ | |||
103 | #define VIA_BACK 0x2 | 107 | #define VIA_BACK 0x2 |
104 | #define VIA_DEPTH 0x4 | 108 | #define VIA_DEPTH 0x4 |
105 | #define VIA_STENCIL 0x8 | 109 | #define VIA_STENCIL 0x8 |
106 | #define VIDEO 0 | 110 | #define VIA_MEM_VIDEO 0 /* matches drm constant */ |
107 | #define AGP 1 | 111 | #define VIA_MEM_AGP 1 /* matches drm constant */ |
112 | #define VIA_MEM_SYSTEM 2 | ||
113 | #define VIA_MEM_MIXED 3 | ||
114 | #define VIA_MEM_UNKNOWN 4 | ||
115 | |||
108 | typedef struct { | 116 | typedef struct { |
109 | uint32_t offset; | 117 | uint32_t offset; |
110 | uint32_t size; | 118 | uint32_t size; |
@@ -192,6 +200,9 @@ typedef struct _drm_via_sarea { | |||
192 | unsigned int XvMCSubPicOn[VIA_NR_XVMC_PORTS]; | 200 | unsigned int XvMCSubPicOn[VIA_NR_XVMC_PORTS]; |
193 | unsigned int XvMCCtxNoGrabbed; /* Last context to hold decoder */ | 201 | unsigned int XvMCCtxNoGrabbed; /* Last context to hold decoder */ |
194 | 202 | ||
203 | /* Used bt the 3d driver only at this point, for pageflipping: | ||
204 | */ | ||
205 | unsigned int pfCurrentOffset; | ||
195 | } drm_via_sarea_t; | 206 | } drm_via_sarea_t; |
196 | 207 | ||
197 | typedef struct _drm_via_cmdbuf_size { | 208 | typedef struct _drm_via_cmdbuf_size { |
@@ -212,6 +223,16 @@ typedef enum { | |||
212 | 223 | ||
213 | #define VIA_IRQ_FLAGS_MASK 0xF0000000 | 224 | #define VIA_IRQ_FLAGS_MASK 0xF0000000 |
214 | 225 | ||
226 | enum drm_via_irqs { | ||
227 | drm_via_irq_hqv0 = 0, | ||
228 | drm_via_irq_hqv1, | ||
229 | drm_via_irq_dma0_dd, | ||
230 | drm_via_irq_dma0_td, | ||
231 | drm_via_irq_dma1_dd, | ||
232 | drm_via_irq_dma1_td, | ||
233 | drm_via_irq_num | ||
234 | }; | ||
235 | |||
215 | struct drm_via_wait_irq_request { | 236 | struct drm_via_wait_irq_request { |
216 | unsigned irq; | 237 | unsigned irq; |
217 | via_irq_seq_type_t type; | 238 | via_irq_seq_type_t type; |
@@ -224,20 +245,25 @@ typedef union drm_via_irqwait { | |||
224 | struct drm_wait_vblank_reply reply; | 245 | struct drm_wait_vblank_reply reply; |
225 | } drm_via_irqwait_t; | 246 | } drm_via_irqwait_t; |
226 | 247 | ||
227 | #ifdef __KERNEL__ | 248 | typedef struct drm_via_blitsync { |
228 | 249 | uint32_t sync_handle; | |
229 | int via_fb_init(DRM_IOCTL_ARGS); | 250 | unsigned engine; |
230 | int via_mem_alloc(DRM_IOCTL_ARGS); | 251 | } drm_via_blitsync_t; |
231 | int via_mem_free(DRM_IOCTL_ARGS); | 252 | |
232 | int via_agp_init(DRM_IOCTL_ARGS); | 253 | typedef struct drm_via_dmablit { |
233 | int via_map_init(DRM_IOCTL_ARGS); | 254 | uint32_t num_lines; |
234 | int via_decoder_futex(DRM_IOCTL_ARGS); | 255 | uint32_t line_length; |
235 | int via_dma_init(DRM_IOCTL_ARGS); | 256 | |
236 | int via_cmdbuffer(DRM_IOCTL_ARGS); | 257 | uint32_t fb_addr; |
237 | int via_flush_ioctl(DRM_IOCTL_ARGS); | 258 | uint32_t fb_stride; |
238 | int via_pci_cmdbuffer(DRM_IOCTL_ARGS); | 259 | |
239 | int via_cmdbuf_size(DRM_IOCTL_ARGS); | 260 | unsigned char *mem_addr; |
240 | int via_wait_irq(DRM_IOCTL_ARGS); | 261 | uint32_t mem_stride; |
262 | |||
263 | int bounce_buffer; | ||
264 | int to_fb; | ||
265 | |||
266 | drm_via_blitsync_t sync; | ||
267 | } drm_via_dmablit_t; | ||
241 | 268 | ||
242 | #endif | ||
243 | #endif /* _VIA_DRM_H_ */ | 269 | #endif /* _VIA_DRM_H_ */ |
diff --git a/drivers/char/drm/via_drv.c b/drivers/char/drm/via_drv.c index e8adebdba127..3f012255d315 100644 --- a/drivers/char/drm/via_drv.c +++ b/drivers/char/drm/via_drv.c | |||
@@ -38,25 +38,12 @@ static struct pci_device_id pciidlist[] = { | |||
38 | viadrv_PCI_IDS | 38 | viadrv_PCI_IDS |
39 | }; | 39 | }; |
40 | 40 | ||
41 | static drm_ioctl_desc_t ioctls[] = { | ||
42 | [DRM_IOCTL_NR(DRM_VIA_ALLOCMEM)] = {via_mem_alloc, 1, 0}, | ||
43 | [DRM_IOCTL_NR(DRM_VIA_FREEMEM)] = {via_mem_free, 1, 0}, | ||
44 | [DRM_IOCTL_NR(DRM_VIA_AGP_INIT)] = {via_agp_init, 1, 0}, | ||
45 | [DRM_IOCTL_NR(DRM_VIA_FB_INIT)] = {via_fb_init, 1, 0}, | ||
46 | [DRM_IOCTL_NR(DRM_VIA_MAP_INIT)] = {via_map_init, 1, 0}, | ||
47 | [DRM_IOCTL_NR(DRM_VIA_DEC_FUTEX)] = {via_decoder_futex, 1, 0}, | ||
48 | [DRM_IOCTL_NR(DRM_VIA_DMA_INIT)] = {via_dma_init, 1, 0}, | ||
49 | [DRM_IOCTL_NR(DRM_VIA_CMDBUFFER)] = {via_cmdbuffer, 1, 0}, | ||
50 | [DRM_IOCTL_NR(DRM_VIA_FLUSH)] = {via_flush_ioctl, 1, 0}, | ||
51 | [DRM_IOCTL_NR(DRM_VIA_PCICMD)] = {via_pci_cmdbuffer, 1, 0}, | ||
52 | [DRM_IOCTL_NR(DRM_VIA_CMDBUF_SIZE)] = {via_cmdbuf_size, 1, 0}, | ||
53 | [DRM_IOCTL_NR(DRM_VIA_WAIT_IRQ)] = {via_wait_irq, 1, 0} | ||
54 | }; | ||
55 | |||
56 | static struct drm_driver driver = { | 41 | static struct drm_driver driver = { |
57 | .driver_features = | 42 | .driver_features = |
58 | DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ | | 43 | DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ | |
59 | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL, | 44 | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL, |
45 | .load = via_driver_load, | ||
46 | .unload = via_driver_unload, | ||
60 | .context_ctor = via_init_context, | 47 | .context_ctor = via_init_context, |
61 | .context_dtor = via_final_context, | 48 | .context_dtor = via_final_context, |
62 | .vblank_wait = via_driver_vblank_wait, | 49 | .vblank_wait = via_driver_vblank_wait, |
@@ -69,8 +56,7 @@ static struct drm_driver driver = { | |||
69 | .reclaim_buffers = drm_core_reclaim_buffers, | 56 | .reclaim_buffers = drm_core_reclaim_buffers, |
70 | .get_map_ofs = drm_core_get_map_ofs, | 57 | .get_map_ofs = drm_core_get_map_ofs, |
71 | .get_reg_ofs = drm_core_get_reg_ofs, | 58 | .get_reg_ofs = drm_core_get_reg_ofs, |
72 | .ioctls = ioctls, | 59 | .ioctls = via_ioctls, |
73 | .num_ioctls = DRM_ARRAY_SIZE(ioctls), | ||
74 | .fops = { | 60 | .fops = { |
75 | .owner = THIS_MODULE, | 61 | .owner = THIS_MODULE, |
76 | .open = drm_open, | 62 | .open = drm_open, |
@@ -95,6 +81,7 @@ static struct drm_driver driver = { | |||
95 | 81 | ||
96 | static int __init via_init(void) | 82 | static int __init via_init(void) |
97 | { | 83 | { |
84 | driver.num_ioctls = via_max_ioctl; | ||
98 | via_init_command_verifier(); | 85 | via_init_command_verifier(); |
99 | return drm_init(&driver); | 86 | return drm_init(&driver); |
100 | } | 87 | } |
diff --git a/drivers/char/drm/via_drv.h b/drivers/char/drm/via_drv.h index 7d5daf43797e..0606c752dccb 100644 --- a/drivers/char/drm/via_drv.h +++ b/drivers/char/drm/via_drv.h | |||
@@ -24,24 +24,26 @@ | |||
24 | #ifndef _VIA_DRV_H_ | 24 | #ifndef _VIA_DRV_H_ |
25 | #define _VIA_DRV_H_ | 25 | #define _VIA_DRV_H_ |
26 | 26 | ||
27 | #define DRIVER_AUTHOR "VIA" | 27 | #define DRIVER_AUTHOR "Various" |
28 | 28 | ||
29 | #define DRIVER_NAME "via" | 29 | #define DRIVER_NAME "via" |
30 | #define DRIVER_DESC "VIA Unichrome / Pro" | 30 | #define DRIVER_DESC "VIA Unichrome / Pro" |
31 | #define DRIVER_DATE "20050523" | 31 | #define DRIVER_DATE "20051022" |
32 | 32 | ||
33 | #define DRIVER_MAJOR 2 | 33 | #define DRIVER_MAJOR 2 |
34 | #define DRIVER_MINOR 6 | 34 | #define DRIVER_MINOR 7 |
35 | #define DRIVER_PATCHLEVEL 3 | 35 | #define DRIVER_PATCHLEVEL 2 |
36 | 36 | ||
37 | #include "via_verifier.h" | 37 | #include "via_verifier.h" |
38 | 38 | ||
39 | #include "via_dmablit.h" | ||
40 | |||
39 | #define VIA_PCI_BUF_SIZE 60000 | 41 | #define VIA_PCI_BUF_SIZE 60000 |
40 | #define VIA_FIRE_BUF_SIZE 1024 | 42 | #define VIA_FIRE_BUF_SIZE 1024 |
41 | #define VIA_NUM_IRQS 2 | 43 | #define VIA_NUM_IRQS 4 |
42 | 44 | ||
43 | typedef struct drm_via_ring_buffer { | 45 | typedef struct drm_via_ring_buffer { |
44 | drm_map_t map; | 46 | drm_local_map_t map; |
45 | char *virtual_start; | 47 | char *virtual_start; |
46 | } drm_via_ring_buffer_t; | 48 | } drm_via_ring_buffer_t; |
47 | 49 | ||
@@ -56,9 +58,9 @@ typedef struct drm_via_irq { | |||
56 | 58 | ||
57 | typedef struct drm_via_private { | 59 | typedef struct drm_via_private { |
58 | drm_via_sarea_t *sarea_priv; | 60 | drm_via_sarea_t *sarea_priv; |
59 | drm_map_t *sarea; | 61 | drm_local_map_t *sarea; |
60 | drm_map_t *fb; | 62 | drm_local_map_t *fb; |
61 | drm_map_t *mmio; | 63 | drm_local_map_t *mmio; |
62 | unsigned long agpAddr; | 64 | unsigned long agpAddr; |
63 | wait_queue_head_t decoder_queue[VIA_NR_XVMC_LOCKS]; | 65 | wait_queue_head_t decoder_queue[VIA_NR_XVMC_LOCKS]; |
64 | char *dma_ptr; | 66 | char *dma_ptr; |
@@ -82,8 +84,15 @@ typedef struct drm_via_private { | |||
82 | maskarray_t *irq_masks; | 84 | maskarray_t *irq_masks; |
83 | uint32_t irq_enable_mask; | 85 | uint32_t irq_enable_mask; |
84 | uint32_t irq_pending_mask; | 86 | uint32_t irq_pending_mask; |
87 | int *irq_map; | ||
88 | drm_via_blitq_t blit_queues[VIA_NUM_BLIT_ENGINES]; | ||
85 | } drm_via_private_t; | 89 | } drm_via_private_t; |
86 | 90 | ||
91 | enum via_family { | ||
92 | VIA_OTHER = 0, | ||
93 | VIA_PRO_GROUP_A, | ||
94 | }; | ||
95 | |||
87 | /* VIA MMIO register access */ | 96 | /* VIA MMIO register access */ |
88 | #define VIA_BASE ((dev_priv->mmio)) | 97 | #define VIA_BASE ((dev_priv->mmio)) |
89 | 98 | ||
@@ -92,12 +101,31 @@ typedef struct drm_via_private { | |||
92 | #define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg) | 101 | #define VIA_READ8(reg) DRM_READ8(VIA_BASE, reg) |
93 | #define VIA_WRITE8(reg,val) DRM_WRITE8(VIA_BASE, reg, val) | 102 | #define VIA_WRITE8(reg,val) DRM_WRITE8(VIA_BASE, reg, val) |
94 | 103 | ||
104 | extern drm_ioctl_desc_t via_ioctls[]; | ||
105 | extern int via_max_ioctl; | ||
106 | |||
107 | extern int via_fb_init(DRM_IOCTL_ARGS); | ||
108 | extern int via_mem_alloc(DRM_IOCTL_ARGS); | ||
109 | extern int via_mem_free(DRM_IOCTL_ARGS); | ||
110 | extern int via_agp_init(DRM_IOCTL_ARGS); | ||
111 | extern int via_map_init(DRM_IOCTL_ARGS); | ||
112 | extern int via_decoder_futex(DRM_IOCTL_ARGS); | ||
113 | extern int via_dma_init(DRM_IOCTL_ARGS); | ||
114 | extern int via_cmdbuffer(DRM_IOCTL_ARGS); | ||
115 | extern int via_flush_ioctl(DRM_IOCTL_ARGS); | ||
116 | extern int via_pci_cmdbuffer(DRM_IOCTL_ARGS); | ||
117 | extern int via_cmdbuf_size(DRM_IOCTL_ARGS); | ||
118 | extern int via_wait_irq(DRM_IOCTL_ARGS); | ||
119 | extern int via_dma_blit_sync( DRM_IOCTL_ARGS ); | ||
120 | extern int via_dma_blit( DRM_IOCTL_ARGS ); | ||
121 | |||
122 | extern int via_driver_load(drm_device_t *dev, unsigned long chipset); | ||
123 | extern int via_driver_unload(drm_device_t *dev); | ||
124 | |||
95 | extern int via_init_context(drm_device_t * dev, int context); | 125 | extern int via_init_context(drm_device_t * dev, int context); |
96 | extern int via_final_context(drm_device_t * dev, int context); | 126 | extern int via_final_context(drm_device_t * dev, int context); |
97 | 127 | ||
98 | extern int via_do_cleanup_map(drm_device_t * dev); | 128 | extern int via_do_cleanup_map(drm_device_t * dev); |
99 | extern int via_map_init(struct inode *inode, struct file *filp, | ||
100 | unsigned int cmd, unsigned long arg); | ||
101 | extern int via_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence); | 129 | extern int via_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence); |
102 | 130 | ||
103 | extern irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS); | 131 | extern irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS); |
@@ -111,8 +139,10 @@ extern int via_driver_dma_quiescent(drm_device_t * dev); | |||
111 | extern void via_init_futex(drm_via_private_t * dev_priv); | 139 | extern void via_init_futex(drm_via_private_t * dev_priv); |
112 | extern void via_cleanup_futex(drm_via_private_t * dev_priv); | 140 | extern void via_cleanup_futex(drm_via_private_t * dev_priv); |
113 | extern void via_release_futex(drm_via_private_t * dev_priv, int context); | 141 | extern void via_release_futex(drm_via_private_t * dev_priv, int context); |
142 | extern int via_driver_irq_wait(drm_device_t * dev, unsigned int irq, | ||
143 | int force_sequence, unsigned int *sequence); | ||
114 | 144 | ||
115 | extern int via_parse_command_stream(drm_device_t * dev, const uint32_t * buf, | 145 | extern void via_dmablit_handler(drm_device_t *dev, int engine, int from_irq); |
116 | unsigned int size); | 146 | extern void via_init_dmablit(drm_device_t *dev); |
117 | 147 | ||
118 | #endif | 148 | #endif |
diff --git a/drivers/char/drm/via_irq.c b/drivers/char/drm/via_irq.c index d023add1929b..56d7e3daea12 100644 --- a/drivers/char/drm/via_irq.c +++ b/drivers/char/drm/via_irq.c | |||
@@ -50,6 +50,15 @@ | |||
50 | #define VIA_IRQ_HQV1_ENABLE (1 << 25) | 50 | #define VIA_IRQ_HQV1_ENABLE (1 << 25) |
51 | #define VIA_IRQ_HQV0_PENDING (1 << 9) | 51 | #define VIA_IRQ_HQV0_PENDING (1 << 9) |
52 | #define VIA_IRQ_HQV1_PENDING (1 << 10) | 52 | #define VIA_IRQ_HQV1_PENDING (1 << 10) |
53 | #define VIA_IRQ_DMA0_DD_ENABLE (1 << 20) | ||
54 | #define VIA_IRQ_DMA0_TD_ENABLE (1 << 21) | ||
55 | #define VIA_IRQ_DMA1_DD_ENABLE (1 << 22) | ||
56 | #define VIA_IRQ_DMA1_TD_ENABLE (1 << 23) | ||
57 | #define VIA_IRQ_DMA0_DD_PENDING (1 << 4) | ||
58 | #define VIA_IRQ_DMA0_TD_PENDING (1 << 5) | ||
59 | #define VIA_IRQ_DMA1_DD_PENDING (1 << 6) | ||
60 | #define VIA_IRQ_DMA1_TD_PENDING (1 << 7) | ||
61 | |||
53 | 62 | ||
54 | /* | 63 | /* |
55 | * Device-specific IRQs go here. This type might need to be extended with | 64 | * Device-specific IRQs go here. This type might need to be extended with |
@@ -61,13 +70,24 @@ static maskarray_t via_pro_group_a_irqs[] = { | |||
61 | {VIA_IRQ_HQV0_ENABLE, VIA_IRQ_HQV0_PENDING, 0x000003D0, 0x00008010, | 70 | {VIA_IRQ_HQV0_ENABLE, VIA_IRQ_HQV0_PENDING, 0x000003D0, 0x00008010, |
62 | 0x00000000}, | 71 | 0x00000000}, |
63 | {VIA_IRQ_HQV1_ENABLE, VIA_IRQ_HQV1_PENDING, 0x000013D0, 0x00008010, | 72 | {VIA_IRQ_HQV1_ENABLE, VIA_IRQ_HQV1_PENDING, 0x000013D0, 0x00008010, |
64 | 0x00000000} | 73 | 0x00000000}, |
74 | {VIA_IRQ_DMA0_TD_ENABLE, VIA_IRQ_DMA0_TD_PENDING, VIA_PCI_DMA_CSR0, | ||
75 | VIA_DMA_CSR_TA | VIA_DMA_CSR_TD, 0x00000008}, | ||
76 | {VIA_IRQ_DMA1_TD_ENABLE, VIA_IRQ_DMA1_TD_PENDING, VIA_PCI_DMA_CSR1, | ||
77 | VIA_DMA_CSR_TA | VIA_DMA_CSR_TD, 0x00000008}, | ||
65 | }; | 78 | }; |
66 | static int via_num_pro_group_a = | 79 | static int via_num_pro_group_a = |
67 | sizeof(via_pro_group_a_irqs) / sizeof(maskarray_t); | 80 | sizeof(via_pro_group_a_irqs) / sizeof(maskarray_t); |
81 | static int via_irqmap_pro_group_a[] = {0, 1, -1, 2, -1, 3}; | ||
68 | 82 | ||
69 | static maskarray_t via_unichrome_irqs[] = { }; | 83 | static maskarray_t via_unichrome_irqs[] = { |
84 | {VIA_IRQ_DMA0_TD_ENABLE, VIA_IRQ_DMA0_TD_PENDING, VIA_PCI_DMA_CSR0, | ||
85 | VIA_DMA_CSR_TA | VIA_DMA_CSR_TD, 0x00000008}, | ||
86 | {VIA_IRQ_DMA1_TD_ENABLE, VIA_IRQ_DMA1_TD_PENDING, VIA_PCI_DMA_CSR1, | ||
87 | VIA_DMA_CSR_TA | VIA_DMA_CSR_TD, 0x00000008} | ||
88 | }; | ||
70 | static int via_num_unichrome = sizeof(via_unichrome_irqs) / sizeof(maskarray_t); | 89 | static int via_num_unichrome = sizeof(via_unichrome_irqs) / sizeof(maskarray_t); |
90 | static int via_irqmap_unichrome[] = {-1, -1, -1, 0, -1, 1}; | ||
71 | 91 | ||
72 | static unsigned time_diff(struct timeval *now, struct timeval *then) | 92 | static unsigned time_diff(struct timeval *now, struct timeval *then) |
73 | { | 93 | { |
@@ -113,6 +133,11 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS) | |||
113 | atomic_inc(&cur_irq->irq_received); | 133 | atomic_inc(&cur_irq->irq_received); |
114 | DRM_WAKEUP(&cur_irq->irq_queue); | 134 | DRM_WAKEUP(&cur_irq->irq_queue); |
115 | handled = 1; | 135 | handled = 1; |
136 | if (dev_priv->irq_map[drm_via_irq_dma0_td] == i) { | ||
137 | via_dmablit_handler(dev, 0, 1); | ||
138 | } else if (dev_priv->irq_map[drm_via_irq_dma1_td] == i) { | ||
139 | via_dmablit_handler(dev, 1, 1); | ||
140 | } | ||
116 | } | 141 | } |
117 | cur_irq++; | 142 | cur_irq++; |
118 | } | 143 | } |
@@ -165,7 +190,7 @@ int via_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence) | |||
165 | return ret; | 190 | return ret; |
166 | } | 191 | } |
167 | 192 | ||
168 | static int | 193 | int |
169 | via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence, | 194 | via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence, |
170 | unsigned int *sequence) | 195 | unsigned int *sequence) |
171 | { | 196 | { |
@@ -174,6 +199,7 @@ via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence, | |||
174 | drm_via_irq_t *cur_irq = dev_priv->via_irqs; | 199 | drm_via_irq_t *cur_irq = dev_priv->via_irqs; |
175 | int ret = 0; | 200 | int ret = 0; |
176 | maskarray_t *masks = dev_priv->irq_masks; | 201 | maskarray_t *masks = dev_priv->irq_masks; |
202 | int real_irq; | ||
177 | 203 | ||
178 | DRM_DEBUG("%s\n", __FUNCTION__); | 204 | DRM_DEBUG("%s\n", __FUNCTION__); |
179 | 205 | ||
@@ -182,15 +208,23 @@ via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence, | |||
182 | return DRM_ERR(EINVAL); | 208 | return DRM_ERR(EINVAL); |
183 | } | 209 | } |
184 | 210 | ||
185 | if (irq >= dev_priv->num_irqs) { | 211 | if (irq >= drm_via_irq_num) { |
186 | DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__, | 212 | DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__, |
187 | irq); | 213 | irq); |
188 | return DRM_ERR(EINVAL); | 214 | return DRM_ERR(EINVAL); |
189 | } | 215 | } |
190 | 216 | ||
191 | cur_irq += irq; | 217 | real_irq = dev_priv->irq_map[irq]; |
218 | |||
219 | if (real_irq < 0) { | ||
220 | DRM_ERROR("%s Video IRQ %d not available on this hardware.\n", | ||
221 | __FUNCTION__, irq); | ||
222 | return DRM_ERR(EINVAL); | ||
223 | } | ||
224 | |||
225 | cur_irq += real_irq; | ||
192 | 226 | ||
193 | if (masks[irq][2] && !force_sequence) { | 227 | if (masks[real_irq][2] && !force_sequence) { |
194 | DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ, | 228 | DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ, |
195 | ((VIA_READ(masks[irq][2]) & masks[irq][3]) == | 229 | ((VIA_READ(masks[irq][2]) & masks[irq][3]) == |
196 | masks[irq][4])); | 230 | masks[irq][4])); |
@@ -226,6 +260,8 @@ void via_driver_irq_preinstall(drm_device_t * dev) | |||
226 | via_pro_group_a_irqs : via_unichrome_irqs; | 260 | via_pro_group_a_irqs : via_unichrome_irqs; |
227 | dev_priv->num_irqs = (dev_priv->pro_group_a) ? | 261 | dev_priv->num_irqs = (dev_priv->pro_group_a) ? |
228 | via_num_pro_group_a : via_num_unichrome; | 262 | via_num_pro_group_a : via_num_unichrome; |
263 | dev_priv->irq_map = (dev_priv->pro_group_a) ? | ||
264 | via_irqmap_pro_group_a : via_irqmap_unichrome; | ||
229 | 265 | ||
230 | for (i = 0; i < dev_priv->num_irqs; ++i) { | 266 | for (i = 0; i < dev_priv->num_irqs; ++i) { |
231 | atomic_set(&cur_irq->irq_received, 0); | 267 | atomic_set(&cur_irq->irq_received, 0); |
@@ -241,7 +277,7 @@ void via_driver_irq_preinstall(drm_device_t * dev) | |||
241 | 277 | ||
242 | dev_priv->last_vblank_valid = 0; | 278 | dev_priv->last_vblank_valid = 0; |
243 | 279 | ||
244 | // Clear VSync interrupt regs | 280 | /* Clear VSync interrupt regs */ |
245 | status = VIA_READ(VIA_REG_INTERRUPT); | 281 | status = VIA_READ(VIA_REG_INTERRUPT); |
246 | VIA_WRITE(VIA_REG_INTERRUPT, status & | 282 | VIA_WRITE(VIA_REG_INTERRUPT, status & |
247 | ~(dev_priv->irq_enable_mask)); | 283 | ~(dev_priv->irq_enable_mask)); |
@@ -291,8 +327,7 @@ void via_driver_irq_uninstall(drm_device_t * dev) | |||
291 | 327 | ||
292 | int via_wait_irq(DRM_IOCTL_ARGS) | 328 | int via_wait_irq(DRM_IOCTL_ARGS) |
293 | { | 329 | { |
294 | drm_file_t *priv = filp->private_data; | 330 | DRM_DEVICE; |
295 | drm_device_t *dev = priv->head->dev; | ||
296 | drm_via_irqwait_t __user *argp = (void __user *)data; | 331 | drm_via_irqwait_t __user *argp = (void __user *)data; |
297 | drm_via_irqwait_t irqwait; | 332 | drm_via_irqwait_t irqwait; |
298 | struct timeval now; | 333 | struct timeval now; |
diff --git a/drivers/char/drm/via_map.c b/drivers/char/drm/via_map.c index 6bd6ac52ad1b..c6a08e96285b 100644 --- a/drivers/char/drm/via_map.c +++ b/drivers/char/drm/via_map.c | |||
@@ -27,16 +27,10 @@ | |||
27 | 27 | ||
28 | static int via_do_init_map(drm_device_t * dev, drm_via_init_t * init) | 28 | static int via_do_init_map(drm_device_t * dev, drm_via_init_t * init) |
29 | { | 29 | { |
30 | drm_via_private_t *dev_priv; | 30 | drm_via_private_t *dev_priv = dev->dev_private; |
31 | 31 | ||
32 | DRM_DEBUG("%s\n", __FUNCTION__); | 32 | DRM_DEBUG("%s\n", __FUNCTION__); |
33 | 33 | ||
34 | dev_priv = drm_alloc(sizeof(drm_via_private_t), DRM_MEM_DRIVER); | ||
35 | if (dev_priv == NULL) | ||
36 | return -ENOMEM; | ||
37 | |||
38 | memset(dev_priv, 0, sizeof(drm_via_private_t)); | ||
39 | |||
40 | DRM_GETSAREA(); | 34 | DRM_GETSAREA(); |
41 | if (!dev_priv->sarea) { | 35 | if (!dev_priv->sarea) { |
42 | DRM_ERROR("could not find sarea!\n"); | 36 | DRM_ERROR("could not find sarea!\n"); |
@@ -67,7 +61,8 @@ static int via_do_init_map(drm_device_t * dev, drm_via_init_t * init) | |||
67 | dev_priv->agpAddr = init->agpAddr; | 61 | dev_priv->agpAddr = init->agpAddr; |
68 | 62 | ||
69 | via_init_futex(dev_priv); | 63 | via_init_futex(dev_priv); |
70 | dev_priv->pro_group_a = (dev->pdev->device == 0x3118); | 64 | |
65 | via_init_dmablit(dev); | ||
71 | 66 | ||
72 | dev->dev_private = (void *)dev_priv; | 67 | dev->dev_private = (void *)dev_priv; |
73 | return 0; | 68 | return 0; |
@@ -75,15 +70,7 @@ static int via_do_init_map(drm_device_t * dev, drm_via_init_t * init) | |||
75 | 70 | ||
76 | int via_do_cleanup_map(drm_device_t * dev) | 71 | int via_do_cleanup_map(drm_device_t * dev) |
77 | { | 72 | { |
78 | if (dev->dev_private) { | 73 | via_dma_cleanup(dev); |
79 | |||
80 | drm_via_private_t *dev_priv = dev->dev_private; | ||
81 | |||
82 | via_dma_cleanup(dev); | ||
83 | |||
84 | drm_free(dev_priv, sizeof(drm_via_private_t), DRM_MEM_DRIVER); | ||
85 | dev->dev_private = NULL; | ||
86 | } | ||
87 | 74 | ||
88 | return 0; | 75 | return 0; |
89 | } | 76 | } |
@@ -107,3 +94,29 @@ int via_map_init(DRM_IOCTL_ARGS) | |||
107 | 94 | ||
108 | return -EINVAL; | 95 | return -EINVAL; |
109 | } | 96 | } |
97 | |||
98 | int via_driver_load(drm_device_t *dev, unsigned long chipset) | ||
99 | { | ||
100 | drm_via_private_t *dev_priv; | ||
101 | |||
102 | dev_priv = drm_calloc(1, sizeof(drm_via_private_t), DRM_MEM_DRIVER); | ||
103 | if (dev_priv == NULL) | ||
104 | return DRM_ERR(ENOMEM); | ||
105 | |||
106 | dev->dev_private = (void *)dev_priv; | ||
107 | |||
108 | if (chipset == VIA_PRO_GROUP_A) | ||
109 | dev_priv->pro_group_a = 1; | ||
110 | |||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | int via_driver_unload(drm_device_t *dev) | ||
115 | { | ||
116 | drm_via_private_t *dev_priv = dev->dev_private; | ||
117 | |||
118 | drm_free(dev_priv, sizeof(drm_via_private_t), DRM_MEM_DRIVER); | ||
119 | |||
120 | return 0; | ||
121 | } | ||
122 | |||
diff --git a/drivers/char/drm/via_mm.c b/drivers/char/drm/via_mm.c index 3baddacdff26..62e692556a1d 100644 --- a/drivers/char/drm/via_mm.c +++ b/drivers/char/drm/via_mm.c | |||
@@ -199,13 +199,13 @@ int via_mem_alloc(DRM_IOCTL_ARGS) | |||
199 | sizeof(mem)); | 199 | sizeof(mem)); |
200 | 200 | ||
201 | switch (mem.type) { | 201 | switch (mem.type) { |
202 | case VIDEO: | 202 | case VIA_MEM_VIDEO: |
203 | if (via_fb_alloc(&mem) < 0) | 203 | if (via_fb_alloc(&mem) < 0) |
204 | return -EFAULT; | 204 | return -EFAULT; |
205 | DRM_COPY_TO_USER_IOCTL((drm_via_mem_t __user *) data, mem, | 205 | DRM_COPY_TO_USER_IOCTL((drm_via_mem_t __user *) data, mem, |
206 | sizeof(mem)); | 206 | sizeof(mem)); |
207 | return 0; | 207 | return 0; |
208 | case AGP: | 208 | case VIA_MEM_AGP: |
209 | if (via_agp_alloc(&mem) < 0) | 209 | if (via_agp_alloc(&mem) < 0) |
210 | return -EFAULT; | 210 | return -EFAULT; |
211 | DRM_COPY_TO_USER_IOCTL((drm_via_mem_t __user *) data, mem, | 211 | DRM_COPY_TO_USER_IOCTL((drm_via_mem_t __user *) data, mem, |
@@ -232,7 +232,7 @@ static int via_fb_alloc(drm_via_mem_t * mem) | |||
232 | if (block) { | 232 | if (block) { |
233 | fb.offset = block->ofs; | 233 | fb.offset = block->ofs; |
234 | fb.free = (unsigned long)block; | 234 | fb.free = (unsigned long)block; |
235 | if (!add_alloc_set(fb.context, VIDEO, fb.free)) { | 235 | if (!add_alloc_set(fb.context, VIA_MEM_VIDEO, fb.free)) { |
236 | DRM_DEBUG("adding to allocation set fails\n"); | 236 | DRM_DEBUG("adding to allocation set fails\n"); |
237 | via_mmFreeMem((PMemBlock) fb.free); | 237 | via_mmFreeMem((PMemBlock) fb.free); |
238 | retval = -1; | 238 | retval = -1; |
@@ -269,7 +269,7 @@ static int via_agp_alloc(drm_via_mem_t * mem) | |||
269 | if (block) { | 269 | if (block) { |
270 | agp.offset = block->ofs; | 270 | agp.offset = block->ofs; |
271 | agp.free = (unsigned long)block; | 271 | agp.free = (unsigned long)block; |
272 | if (!add_alloc_set(agp.context, AGP, agp.free)) { | 272 | if (!add_alloc_set(agp.context, VIA_MEM_AGP, agp.free)) { |
273 | DRM_DEBUG("adding to allocation set fails\n"); | 273 | DRM_DEBUG("adding to allocation set fails\n"); |
274 | via_mmFreeMem((PMemBlock) agp.free); | 274 | via_mmFreeMem((PMemBlock) agp.free); |
275 | retval = -1; | 275 | retval = -1; |
@@ -297,11 +297,11 @@ int via_mem_free(DRM_IOCTL_ARGS) | |||
297 | 297 | ||
298 | switch (mem.type) { | 298 | switch (mem.type) { |
299 | 299 | ||
300 | case VIDEO: | 300 | case VIA_MEM_VIDEO: |
301 | if (via_fb_free(&mem) == 0) | 301 | if (via_fb_free(&mem) == 0) |
302 | return 0; | 302 | return 0; |
303 | break; | 303 | break; |
304 | case AGP: | 304 | case VIA_MEM_AGP: |
305 | if (via_agp_free(&mem) == 0) | 305 | if (via_agp_free(&mem) == 0) |
306 | return 0; | 306 | return 0; |
307 | break; | 307 | break; |
@@ -329,7 +329,7 @@ static int via_fb_free(drm_via_mem_t * mem) | |||
329 | 329 | ||
330 | via_mmFreeMem((PMemBlock) fb.free); | 330 | via_mmFreeMem((PMemBlock) fb.free); |
331 | 331 | ||
332 | if (!del_alloc_set(fb.context, VIDEO, fb.free)) { | 332 | if (!del_alloc_set(fb.context, VIA_MEM_VIDEO, fb.free)) { |
333 | retval = -1; | 333 | retval = -1; |
334 | } | 334 | } |
335 | 335 | ||
@@ -352,7 +352,7 @@ static int via_agp_free(drm_via_mem_t * mem) | |||
352 | 352 | ||
353 | via_mmFreeMem((PMemBlock) agp.free); | 353 | via_mmFreeMem((PMemBlock) agp.free); |
354 | 354 | ||
355 | if (!del_alloc_set(agp.context, AGP, agp.free)) { | 355 | if (!del_alloc_set(agp.context, VIA_MEM_AGP, agp.free)) { |
356 | retval = -1; | 356 | retval = -1; |
357 | } | 357 | } |
358 | 358 | ||
diff --git a/drivers/char/drm/via_verifier.c b/drivers/char/drm/via_verifier.c index 4ac495f297f7..70c897c88766 100644 --- a/drivers/char/drm/via_verifier.c +++ b/drivers/char/drm/via_verifier.c | |||
@@ -237,7 +237,7 @@ static hazard_t table3[256]; | |||
237 | static __inline__ int | 237 | static __inline__ int |
238 | eat_words(const uint32_t ** buf, const uint32_t * buf_end, unsigned num_words) | 238 | eat_words(const uint32_t ** buf, const uint32_t * buf_end, unsigned num_words) |
239 | { | 239 | { |
240 | if ((*buf - buf_end) >= num_words) { | 240 | if ((buf_end - *buf) >= num_words) { |
241 | *buf += num_words; | 241 | *buf += num_words; |
242 | return 0; | 242 | return 0; |
243 | } | 243 | } |
@@ -249,14 +249,14 @@ eat_words(const uint32_t ** buf, const uint32_t * buf_end, unsigned num_words) | |||
249 | * Partially stolen from drm_memory.h | 249 | * Partially stolen from drm_memory.h |
250 | */ | 250 | */ |
251 | 251 | ||
252 | static __inline__ drm_map_t *via_drm_lookup_agp_map(drm_via_state_t * seq, | 252 | static __inline__ drm_local_map_t *via_drm_lookup_agp_map(drm_via_state_t *seq, |
253 | unsigned long offset, | 253 | unsigned long offset, |
254 | unsigned long size, | 254 | unsigned long size, |
255 | drm_device_t * dev) | 255 | drm_device_t * dev) |
256 | { | 256 | { |
257 | struct list_head *list; | 257 | struct list_head *list; |
258 | drm_map_list_t *r_list; | 258 | drm_map_list_t *r_list; |
259 | drm_map_t *map = seq->map_cache; | 259 | drm_local_map_t *map = seq->map_cache; |
260 | 260 | ||
261 | if (map && map->offset <= offset | 261 | if (map && map->offset <= offset |
262 | && (offset + size) <= (map->offset + map->size)) { | 262 | && (offset + size) <= (map->offset + map->size)) { |
diff --git a/drivers/char/drm/via_verifier.h b/drivers/char/drm/via_verifier.h index eb4eda344345..256590fcc22a 100644 --- a/drivers/char/drm/via_verifier.h +++ b/drivers/char/drm/via_verifier.h | |||
@@ -47,7 +47,7 @@ typedef struct { | |||
47 | int agp_texture; | 47 | int agp_texture; |
48 | int multitex; | 48 | int multitex; |
49 | drm_device_t *dev; | 49 | drm_device_t *dev; |
50 | drm_map_t *map_cache; | 50 | drm_local_map_t *map_cache; |
51 | uint32_t vertex_count; | 51 | uint32_t vertex_count; |
52 | int agp; | 52 | int agp; |
53 | const uint32_t *buf_start; | 53 | const uint32_t *buf_start; |
@@ -55,5 +55,7 @@ typedef struct { | |||
55 | 55 | ||
56 | extern int via_verify_command_stream(const uint32_t * buf, unsigned int size, | 56 | extern int via_verify_command_stream(const uint32_t * buf, unsigned int size, |
57 | drm_device_t * dev, int agp); | 57 | drm_device_t * dev, int agp); |
58 | extern int via_parse_command_stream(drm_device_t *dev, const uint32_t *buf, | ||
59 | unsigned int size); | ||
58 | 60 | ||
59 | #endif | 61 | #endif |
diff --git a/drivers/char/drm/via_video.c b/drivers/char/drm/via_video.c index 7fab9fbdf424..300ac61b09ed 100644 --- a/drivers/char/drm/via_video.c +++ b/drivers/char/drm/via_video.c | |||
@@ -50,8 +50,11 @@ void via_release_futex(drm_via_private_t * dev_priv, int context) | |||
50 | unsigned int i; | 50 | unsigned int i; |
51 | volatile int *lock; | 51 | volatile int *lock; |
52 | 52 | ||
53 | if (!dev_priv->sarea_priv) | ||
54 | return; | ||
55 | |||
53 | for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) { | 56 | for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) { |
54 | lock = (int *)XVMCLOCKPTR(dev_priv->sarea_priv, i); | 57 | lock = (volatile int *)XVMCLOCKPTR(dev_priv->sarea_priv, i); |
55 | if ((_DRM_LOCKING_CONTEXT(*lock) == context)) { | 58 | if ((_DRM_LOCKING_CONTEXT(*lock) == context)) { |
56 | if (_DRM_LOCK_IS_HELD(*lock) | 59 | if (_DRM_LOCK_IS_HELD(*lock) |
57 | && (*lock & _DRM_LOCK_CONT)) { | 60 | && (*lock & _DRM_LOCK_CONT)) { |
@@ -79,7 +82,7 @@ int via_decoder_futex(DRM_IOCTL_ARGS) | |||
79 | if (fx.lock > VIA_NR_XVMC_LOCKS) | 82 | if (fx.lock > VIA_NR_XVMC_LOCKS) |
80 | return -EFAULT; | 83 | return -EFAULT; |
81 | 84 | ||
82 | lock = (int *)XVMCLOCKPTR(sAPriv, fx.lock); | 85 | lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx.lock); |
83 | 86 | ||
84 | switch (fx.func) { | 87 | switch (fx.func) { |
85 | case VIA_FUTEX_WAIT: | 88 | case VIA_FUTEX_WAIT: |