summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2003-10-20Clean up BSD MTRR handling. The NetBSD code is untested, but it's my bestEric Anholt
2003-10-19- SMPng lock the DRM. This is only partial -- there are a few code pathsEric Anholt
2003-10-19Clean up extra zeroing of dev->dma, and use calloc to take advantage ofEric Anholt
2003-10-19Fix probing on 2.5+ kernels, which require that drivers have .id_table set.Eric Anholt
2003-10-17- Move IRQ functions from drm_dma.h to new drm_irq.h and disentangle themEric Anholt
2003-10-17- Converted Linux drivers to initialize DRM instances based on PCI IDs, notEric Anholt
2003-10-16Introduce COMMIT_RING() as in radeon DRM, stop using error prone writebackMichel Daenzer
2003-10-16Try that again. It's a long.Eric Anholt
2003-10-16Debug printf format fix.Eric Anholt
2003-10-03Some code cleanups done while working on locking. Reduces always-trueEric Anholt
2003-10-03Stylistic preparation for SMPng locking work: DRM_LOCK/DRM_UNLOCK have sideEric Anholt
2003-10-02Add an MIT-style copyright, assigned to myself, to these files. I thinkEric Anholt
2003-10-02Axe more old gamma DMA infrastructure.Eric Anholt
2003-10-02Mostly whitespace cleanups and style(9) fixes focused on "if(" -> "if ("Eric Anholt
2003-10-02Wrap sys/endian.h usage with __FreeBSD_version >= 480000.Eric Anholt
2003-10-02Allow the DRM to attach to a "drmsub" device. This will be provided by theEric Anholt
2003-10-02MTRR issue with SMP and -stable seems to be resolved. Re-enable MTRRs onEric Anholt
2003-09-30file via_drm.h was initially added on branch cle266-0-0-1-branch.Jose Fonseca
2003-09-30file via.h was initially added on branch cle266-0-0-1-branch.Jose Fonseca
2003-09-30file via_drv.c was initially added on branch cle266-0-0-1-branch.Jose Fonseca
2003-09-30file via_drv.h was initially added on branch cle266-0-0-1-branch.Jose Fonseca
2003-09-30file via_ds.c was initially added on branch cle266-0-0-1-branch.Jose Fonseca
2003-09-30file via_ds.h was initially added on branch cle266-0-0-1-branch.Jose Fonseca
2003-09-30file via_map.c was initially added on branch cle266-0-0-1-branch.Jose Fonseca
2003-09-30file via_mm.c was initially added on branch cle266-0-0-1-branch.Jose Fonseca
2003-09-30file via_mm.h was initially added on branch cle266-0-0-1-branch.Jose Fonseca
2003-09-28Fix typo in SiS help message (and testing cvs commit toLeif Delgass
2003-09-25Whitespace cleanup (spaces before tabs or instead of tabs).Eric Anholt
2003-09-25Whitespace cleanup.Eric Anholt
2003-09-25Fix Kconfig for SiS DRM now that it doesn't require sisfb.Eric Anholt
2003-09-24post merge fixAlan Hourihane
2003-09-13compatibility layer still uses agp (not gart)Alan Hourihane
2003-09-12bsd drm fixesAlan Hourihane
2003-09-12linux drm fixesAlan Hourihane
2003-09-12resolve merge conflictsAlan Hourihane
2003-09-09Use spldrm/splx around tsleep() in DRM_WAIT_ONKeith Whitwell
2003-09-07Correct format in debug printfs (free is a pointer, not an int).Eric Anholt
2003-09-07Fix for older -stable.Eric Anholt
2003-08-29Update to reflect renaming of SIS ioctls.Eric Anholt
2003-08-29These files were missed in the SiS DRM commit.Eric Anholt
2003-08-29Port the SiS DRM to FreeBSD. This includes the ability for the DRM toEric Anholt
2003-08-29Add DRM(calloc), which is convenient, used by the new sis code, and takesEric Anholt
2003-08-29Update radeon PCI IDs.Eric Anholt
2003-08-29This PCI header has been living in dev/pci/ for a while now.Eric Anholt
2003-08-28Remove superfluous TLB flushMichel Daenzer
2003-08-26Rename agp to gart for radeonMichel Daenzer
2003-08-26Remove artificial PCI GART limitations, rename AGP to GART whereMichel Daenzer
2003-08-19Fix the debug build.Eric Anholt
2003-08-19- Remove $FreeBSD$ tags as they weren't too useful and merges are now beingEric Anholt
2003-08-18Clean up Radeon DRI resume codeMichel Daenzer
(including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * Authors: * Keith Whitwell <keith@tungstengraphics.com> * Michel D�zer <michel@daenzer.net> */ #include "drmP.h" #include "drm.h" #include "radeon_drm.h" #include "radeon_drv.h" static __inline__ u32 radeon_acknowledge_irqs(drm_radeon_private_t * dev_priv, u32 mask) { u32 irqs = RADEON_READ(RADEON_GEN_INT_STATUS) & mask; if (irqs) RADEON_WRITE(RADEON_GEN_INT_STATUS, irqs); return irqs; } /* Interrupts - Used for device synchronization and flushing in the * following circumstances: * * - Exclusive FB access with hw idle: * - Wait for GUI Idle (?) interrupt, then do normal flush. * * - Frame throttling, NV_fence: * - Drop marker irq's into command stream ahead of time. * - Wait on irq's with lock *not held* * - Check each for termination condition * * - Internally in cp_getbuffer, etc: * - as above, but wait with lock held??? * * NOTE: These functions are misleadingly named -- the irq's aren't * tied to dma at all, this is just a hangover from dri prehistory. */ irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS) { struct drm_device *dev = (struct drm_device *) arg; drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; u32 stat; /* Only consider the bits we're interested in - others could be used * outside the DRM */ stat = radeon_acknowledge_irqs(dev_priv, (RADEON_SW_INT_TEST_ACK | RADEON_CRTC_VBLANK_STAT | RADEON_CRTC2_VBLANK_STAT)); if (!stat) return IRQ_NONE; stat &= dev_priv->irq_enable_reg; /* SW interrupt */ if (stat & RADEON_SW_INT_TEST) { DRM_WAKEUP(&dev_priv->swi_queue); } /* VBLANK interrupt */ if (stat & (RADEON_CRTC_VBLANK_STAT|RADEON_CRTC2_VBLANK_STAT)) { int vblank_crtc = dev_priv->vblank_crtc; if ((vblank_crtc & (DRM_RADEON_VBLANK_CRTC1 | DRM_RADEON_VBLANK_CRTC2)) == (DRM_RADEON_VBLANK_CRTC1 | DRM_RADEON_VBLANK_CRTC2)) { if (stat & RADEON_CRTC_VBLANK_STAT) atomic_inc(&dev->vbl_received); if (stat & RADEON_CRTC2_VBLANK_STAT) atomic_inc(&dev->vbl_received2); } else if (((stat & RADEON_CRTC_VBLANK_STAT) && (vblank_crtc & DRM_RADEON_VBLANK_CRTC1)) || ((stat & RADEON_CRTC2_VBLANK_STAT) && (vblank_crtc & DRM_RADEON_VBLANK_CRTC2))) atomic_inc(&dev->vbl_received); DRM_WAKEUP(&dev->vbl_queue); drm_vbl_send_signals(dev); } return IRQ_HANDLED; } static int radeon_emit_irq(struct drm_device * dev) { drm_radeon_private_t *dev_priv = dev->dev_private; unsigned int ret; RING_LOCALS; atomic_inc(&dev_priv->swi_emitted); ret = atomic_read(&dev_priv->swi_emitted); BEGIN_RING(4); OUT_RING_REG(RADEON_LAST_SWI_REG, ret); OUT_RING_REG(RADEON_GEN_INT_STATUS, RADEON_SW_INT_FIRE); ADVANCE_RING(); COMMIT_RING(); return ret; } static int radeon_wait_irq(struct drm_device * dev, int swi_nr) { drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; int ret = 0; if (RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr) return 0; dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE; DRM_WAIT_ON(ret, dev_priv->swi_queue, 3 * DRM_HZ, RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr); return ret; } static int radeon_driver_vblank_do_wait(struct drm_device * dev, unsigned int *sequence, int crtc) { drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; unsigned int cur_vblank; int ret = 0; int ack = 0; atomic_t *counter; if (!dev_priv) { DRM_ERROR("%s called with no initialization\n", __FUNCTION__); return -EINVAL; } if (crtc == DRM_RADEON_VBLANK_CRTC1) { counter = &dev->vbl_received; ack |= RADEON_CRTC_VBLANK_STAT; } else if (crtc == DRM_RADEON_VBLANK_CRTC2) { counter = &dev->vbl_received2; ack |= RADEON_CRTC2_VBLANK_STAT; } else return -EINVAL; radeon_acknowledge_irqs(dev_priv, ack); dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE; /* Assume that the user has missed the current sequence number * by about a day rather than she wants to wait for years * using vertical blanks... */ DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ, (((cur_vblank = atomic_read(counter)) - *sequence) <= (1 << 23))); *sequence = cur_vblank; return ret; } int radeon_driver_vblank_wait(struct drm_device *dev, unsigned int *sequence) { return radeon_driver_vblank_do_wait(dev, sequence, DRM_RADEON_VBLANK_CRTC1); } int radeon_driver_vblank_wait2(struct drm_device *dev, unsigned int *sequence) { return radeon_driver_vblank_do_wait(dev, sequence, DRM_RADEON_VBLANK_CRTC2); } /* Needs the lock as it touches the ring. */ int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_irq_emit_t *emit = data; int result; LOCK_TEST_WITH_RETURN(dev, file_priv); if (!dev_priv) { DRM_ERROR("%s called with no initialization\n", __FUNCTION__); return -EINVAL; } result = radeon_emit_irq(dev); if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) { DRM_ERROR("copy_to_user\n"); return -EFAULT; } return 0; } /* Doesn't need the hardware lock. */ int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_irq_wait_t *irqwait = data; if (!dev_priv) { DRM_ERROR("%s called with no initialization\n", __FUNCTION__); return -EINVAL; } return radeon_wait_irq(dev, irqwait->irq_seq); } static void radeon_enable_interrupt(struct drm_device *dev) { drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; dev_priv->irq_enable_reg = RADEON_SW_INT_ENABLE; if (dev_priv->vblank_crtc & DRM_RADEON_VBLANK_CRTC1) dev_priv->irq_enable_reg |= RADEON_CRTC_VBLANK_MASK; if (dev_priv->vblank_crtc & DRM_RADEON_VBLANK_CRTC2) dev_priv->irq_enable_reg |= RADEON_CRTC2_VBLANK_MASK; RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg); dev_priv->irq_enabled = 1; } /* drm_dma.h hooks */ void radeon_driver_irq_preinstall(struct drm_device * dev) { drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; /* Disable *all* interrupts */ RADEON_WRITE(RADEON_GEN_INT_CNTL, 0); /* Clear bits if they're already high */ radeon_acknowledge_irqs(dev_priv, (RADEON_SW_INT_TEST_ACK | RADEON_CRTC_VBLANK_STAT | RADEON_CRTC2_VBLANK_STAT)); } void radeon_driver_irq_postinstall(struct drm_device * dev) { drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; atomic_set(&dev_priv->swi_emitted, 0); DRM_INIT_WAITQUEUE(&dev_priv->swi_queue); radeon_enable_interrupt(dev); } void radeon_driver_irq_uninstall(struct drm_device * dev) { drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; if (!dev_priv) return; dev_priv->irq_enabled = 0; /* Disable *all* interrupts */ RADEON_WRITE(RADEON_GEN_INT_CNTL, 0); } int radeon_vblank_crtc_get(struct drm_device *dev) { drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; u32 flag; u32 value; flag = RADEON_READ(RADEON_GEN_INT_CNTL); value = 0; if (flag & RADEON_CRTC_VBLANK_MASK) value |= DRM_RADEON_VBLANK_CRTC1; if (flag & RADEON_CRTC2_VBLANK_MASK) value |= DRM_RADEON_VBLANK_CRTC2; return value; } int radeon_vblank_crtc_set(struct drm_device *dev, int64_t value) { drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; if (value & ~(DRM_RADEON_VBLANK_CRTC1 | DRM_RADEON_VBLANK_CRTC2)) { DRM_ERROR("called with invalid crtc 0x%x\n", (unsigned int)value); return -EINVAL; } dev_priv->vblank_crtc = (unsigned int)value; radeon_enable_interrupt(dev); return 0; }