2005-06-28 06:48:56 -06:00
|
|
|
/* via_irq.c
|
|
|
|
*
|
|
|
|
* Copyright 2004 BEAM Ltd.
|
|
|
|
* Copyright 2002 Tungsten Graphics, Inc.
|
|
|
|
* Copyright 2005 Thomas Hellstrom.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (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
|
|
|
|
* BEAM LTD, TUNGSTEN GRAPHICS 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:
|
|
|
|
* Terry Barnaby <terry1@beam.ltd.uk>
|
|
|
|
* Keith Whitwell <keith@tungstengraphics.com>
|
|
|
|
* Thomas Hellstrom <unichrome@shipmail.org>
|
|
|
|
*
|
|
|
|
* This code provides standard DRM access to the Via Unichrome / Pro Vertical blank
|
|
|
|
* interrupt, as well as an infrastructure to handle other interrupts of the chip.
|
|
|
|
* The refresh rate is also calculated for video playback sync purposes.
|
|
|
|
*/
|
|
|
|
|
2012-10-02 11:01:07 -06:00
|
|
|
#include <drm/drmP.h>
|
|
|
|
#include <drm/via_drm.h>
|
2005-06-28 06:48:56 -06:00
|
|
|
#include "via_drv.h"
|
|
|
|
|
|
|
|
#define VIA_REG_INTERRUPT 0x200
|
|
|
|
|
|
|
|
/* VIA_REG_INTERRUPT */
|
2008-09-30 13:14:26 -06:00
|
|
|
#define VIA_IRQ_GLOBAL (1 << 31)
|
2005-06-28 06:48:56 -06:00
|
|
|
#define VIA_IRQ_VBLANK_ENABLE (1 << 19)
|
|
|
|
#define VIA_IRQ_VBLANK_PENDING (1 << 3)
|
|
|
|
#define VIA_IRQ_HQV0_ENABLE (1 << 11)
|
|
|
|
#define VIA_IRQ_HQV1_ENABLE (1 << 25)
|
|
|
|
#define VIA_IRQ_HQV0_PENDING (1 << 9)
|
|
|
|
#define VIA_IRQ_HQV1_PENDING (1 << 10)
|
2005-11-12 03:52:46 -07:00
|
|
|
#define VIA_IRQ_DMA0_DD_ENABLE (1 << 20)
|
|
|
|
#define VIA_IRQ_DMA0_TD_ENABLE (1 << 21)
|
|
|
|
#define VIA_IRQ_DMA1_DD_ENABLE (1 << 22)
|
|
|
|
#define VIA_IRQ_DMA1_TD_ENABLE (1 << 23)
|
|
|
|
#define VIA_IRQ_DMA0_DD_PENDING (1 << 4)
|
|
|
|
#define VIA_IRQ_DMA0_TD_PENDING (1 << 5)
|
|
|
|
#define VIA_IRQ_DMA1_DD_PENDING (1 << 6)
|
|
|
|
#define VIA_IRQ_DMA1_TD_PENDING (1 << 7)
|
|
|
|
|
2005-06-28 06:48:56 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Device-specific IRQs go here. This type might need to be extended with
|
|
|
|
* the register if there are multiple IRQ control registers.
|
2005-09-24 22:28:13 -06:00
|
|
|
* Currently we activate the HQV interrupts of Unichrome Pro group A.
|
2005-06-28 06:48:56 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
static maskarray_t via_pro_group_a_irqs[] = {
|
2005-09-24 22:28:13 -06:00
|
|
|
{VIA_IRQ_HQV0_ENABLE, VIA_IRQ_HQV0_PENDING, 0x000003D0, 0x00008010,
|
2008-09-30 13:14:26 -06:00
|
|
|
0x00000000 },
|
2005-09-24 22:28:13 -06:00
|
|
|
{VIA_IRQ_HQV1_ENABLE, VIA_IRQ_HQV1_PENDING, 0x000013D0, 0x00008010,
|
2008-09-30 13:14:26 -06:00
|
|
|
0x00000000 },
|
2005-11-12 03:52:46 -07:00
|
|
|
{VIA_IRQ_DMA0_TD_ENABLE, VIA_IRQ_DMA0_TD_PENDING, VIA_PCI_DMA_CSR0,
|
|
|
|
VIA_DMA_CSR_TA | VIA_DMA_CSR_TD, 0x00000008},
|
|
|
|
{VIA_IRQ_DMA1_TD_ENABLE, VIA_IRQ_DMA1_TD_PENDING, VIA_PCI_DMA_CSR1,
|
|
|
|
VIA_DMA_CSR_TA | VIA_DMA_CSR_TD, 0x00000008},
|
2005-09-24 22:28:13 -06:00
|
|
|
};
|
2008-09-30 13:14:26 -06:00
|
|
|
static int via_num_pro_group_a = ARRAY_SIZE(via_pro_group_a_irqs);
|
2005-11-12 03:52:46 -07:00
|
|
|
static int via_irqmap_pro_group_a[] = {0, 1, -1, 2, -1, 3};
|
2005-09-24 22:28:13 -06:00
|
|
|
|
2005-11-12 03:52:46 -07:00
|
|
|
static maskarray_t via_unichrome_irqs[] = {
|
|
|
|
{VIA_IRQ_DMA0_TD_ENABLE, VIA_IRQ_DMA0_TD_PENDING, VIA_PCI_DMA_CSR0,
|
|
|
|
VIA_DMA_CSR_TA | VIA_DMA_CSR_TD, 0x00000008},
|
|
|
|
{VIA_IRQ_DMA1_TD_ENABLE, VIA_IRQ_DMA1_TD_PENDING, VIA_PCI_DMA_CSR1,
|
|
|
|
VIA_DMA_CSR_TA | VIA_DMA_CSR_TD, 0x00000008}
|
|
|
|
};
|
2008-09-30 13:14:26 -06:00
|
|
|
static int via_num_unichrome = ARRAY_SIZE(via_unichrome_irqs);
|
2005-11-12 03:52:46 -07:00
|
|
|
static int via_irqmap_unichrome[] = {-1, -1, -1, 0, -1, 1};
|
2005-09-24 22:28:13 -06:00
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
|
2005-09-24 22:28:13 -06:00
|
|
|
static unsigned time_diff(struct timeval *now, struct timeval *then)
|
2005-06-28 06:48:56 -06:00
|
|
|
{
|
2005-09-24 22:28:13 -06:00
|
|
|
return (now->tv_usec >= then->tv_usec) ?
|
2008-09-30 13:14:26 -06:00
|
|
|
now->tv_usec - then->tv_usec :
|
|
|
|
1000000 - (then->tv_usec - now->tv_usec);
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
|
|
|
|
{
|
|
|
|
drm_via_private_t *dev_priv = dev->dev_private;
|
|
|
|
if (crtc != 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return atomic_read(&dev_priv->vbl_received);
|
2005-06-28 06:48:56 -06:00
|
|
|
}
|
|
|
|
|
2013-12-11 03:34:42 -07:00
|
|
|
irqreturn_t via_driver_irq_handler(int irq, void *arg)
|
2005-06-28 06:48:56 -06:00
|
|
|
{
|
2007-07-10 23:53:27 -06:00
|
|
|
struct drm_device *dev = (struct drm_device *) arg;
|
2005-06-28 06:48:56 -06:00
|
|
|
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
|
|
|
u32 status;
|
|
|
|
int handled = 0;
|
|
|
|
struct timeval cur_vblank;
|
|
|
|
drm_via_irq_t *cur_irq = dev_priv->via_irqs;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
status = VIA_READ(VIA_REG_INTERRUPT);
|
|
|
|
if (status & VIA_IRQ_VBLANK_PENDING) {
|
2008-09-30 13:14:26 -06:00
|
|
|
atomic_inc(&dev_priv->vbl_received);
|
|
|
|
if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
|
2005-06-28 06:48:56 -06:00
|
|
|
do_gettimeofday(&cur_vblank);
|
2005-09-24 22:28:13 -06:00
|
|
|
if (dev_priv->last_vblank_valid) {
|
|
|
|
dev_priv->usec_per_vblank =
|
2008-09-30 13:14:26 -06:00
|
|
|
time_diff(&cur_vblank,
|
|
|
|
&dev_priv->last_vblank) >> 4;
|
2005-06-28 06:48:56 -06:00
|
|
|
}
|
|
|
|
dev_priv->last_vblank = cur_vblank;
|
|
|
|
dev_priv->last_vblank_valid = 1;
|
2005-09-24 22:28:13 -06:00
|
|
|
}
|
2008-09-30 13:14:26 -06:00
|
|
|
if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
|
2005-06-28 06:48:56 -06:00
|
|
|
DRM_DEBUG("US per vblank is: %u\n",
|
2005-09-24 22:28:13 -06:00
|
|
|
dev_priv->usec_per_vblank);
|
2005-06-28 06:48:56 -06:00
|
|
|
}
|
2008-09-30 13:14:26 -06:00
|
|
|
drm_handle_vblank(dev, 0);
|
2005-06-28 06:48:56 -06:00
|
|
|
handled = 1;
|
|
|
|
}
|
|
|
|
|
2005-09-24 22:28:13 -06:00
|
|
|
for (i = 0; i < dev_priv->num_irqs; ++i) {
|
2005-06-28 06:48:56 -06:00
|
|
|
if (status & cur_irq->pending_mask) {
|
2005-09-24 22:28:13 -06:00
|
|
|
atomic_inc(&cur_irq->irq_received);
|
2013-12-11 03:34:43 -07:00
|
|
|
wake_up(&cur_irq->irq_queue);
|
2005-06-28 06:48:56 -06:00
|
|
|
handled = 1;
|
2010-07-11 07:32:42 -06:00
|
|
|
if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
|
2005-11-12 03:52:46 -07:00
|
|
|
via_dmablit_handler(dev, 0, 1);
|
2010-07-11 07:32:42 -06:00
|
|
|
else if (dev_priv->irq_map[drm_via_irq_dma1_td] == i)
|
2005-11-12 03:52:46 -07:00
|
|
|
via_dmablit_handler(dev, 1, 1);
|
2005-06-28 06:48:56 -06:00
|
|
|
}
|
|
|
|
cur_irq++;
|
|
|
|
}
|
2005-09-24 22:28:13 -06:00
|
|
|
|
tree-wide: Assorted spelling fixes
In particular, several occurances of funny versions of 'success',
'unknown', 'therefore', 'acknowledge', 'argument', 'achieve', 'address',
'beginning', 'desirable', 'separate' and 'necessary' are fixed.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Joe Perches <joe@perches.com>
Cc: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-02-02 17:01:28 -07:00
|
|
|
/* Acknowledge interrupts */
|
2005-06-28 06:48:56 -06:00
|
|
|
VIA_WRITE(VIA_REG_INTERRUPT, status);
|
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
|
2005-06-28 06:48:56 -06:00
|
|
|
if (handled)
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
else
|
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
|
|
|
|
2010-07-11 07:32:42 -06:00
|
|
|
static __inline__ void viadrv_acknowledge_irqs(drm_via_private_t *dev_priv)
|
2005-06-28 06:48:56 -06:00
|
|
|
{
|
|
|
|
u32 status;
|
|
|
|
|
|
|
|
if (dev_priv) {
|
tree-wide: Assorted spelling fixes
In particular, several occurances of funny versions of 'success',
'unknown', 'therefore', 'acknowledge', 'argument', 'achieve', 'address',
'beginning', 'desirable', 'separate' and 'necessary' are fixed.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Joe Perches <joe@perches.com>
Cc: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-02-02 17:01:28 -07:00
|
|
|
/* Acknowledge interrupts */
|
2005-06-28 06:48:56 -06:00
|
|
|
status = VIA_READ(VIA_REG_INTERRUPT);
|
2005-09-24 22:28:13 -06:00
|
|
|
VIA_WRITE(VIA_REG_INTERRUPT, status |
|
2005-06-28 06:48:56 -06:00
|
|
|
dev_priv->irq_pending_mask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
int via_enable_vblank(struct drm_device *dev, int crtc)
|
2005-06-28 06:48:56 -06:00
|
|
|
{
|
2008-09-30 13:14:26 -06:00
|
|
|
drm_via_private_t *dev_priv = dev->dev_private;
|
|
|
|
u32 status;
|
2005-06-28 06:48:56 -06:00
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
if (crtc != 0) {
|
|
|
|
DRM_ERROR("%s: bad crtc %d\n", __func__, crtc);
|
2005-06-28 06:48:56 -06:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
status = VIA_READ(VIA_REG_INTERRUPT);
|
2009-07-10 04:25:16 -06:00
|
|
|
VIA_WRITE(VIA_REG_INTERRUPT, status | VIA_IRQ_VBLANK_ENABLE);
|
2008-09-30 13:14:26 -06:00
|
|
|
|
|
|
|
VIA_WRITE8(0x83d4, 0x11);
|
|
|
|
VIA_WRITE8(0x83d5, VIA_READ8(0x83d5) | 0x30);
|
2005-06-28 06:48:56 -06:00
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
return 0;
|
|
|
|
}
|
2005-06-28 06:48:56 -06:00
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
void via_disable_vblank(struct drm_device *dev, int crtc)
|
|
|
|
{
|
|
|
|
drm_via_private_t *dev_priv = dev->dev_private;
|
2009-07-10 04:25:16 -06:00
|
|
|
u32 status;
|
|
|
|
|
|
|
|
status = VIA_READ(VIA_REG_INTERRUPT);
|
|
|
|
VIA_WRITE(VIA_REG_INTERRUPT, status & ~VIA_IRQ_VBLANK_ENABLE);
|
2005-09-24 22:28:13 -06:00
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
VIA_WRITE8(0x83d4, 0x11);
|
|
|
|
VIA_WRITE8(0x83d5, VIA_READ8(0x83d5) & ~0x30);
|
|
|
|
|
|
|
|
if (crtc != 0)
|
|
|
|
DRM_ERROR("%s: bad crtc %d\n", __func__, crtc);
|
2005-06-28 06:48:56 -06:00
|
|
|
}
|
|
|
|
|
2006-02-02 01:21:38 -07:00
|
|
|
static int
|
2010-07-11 07:32:42 -06:00
|
|
|
via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence,
|
2005-06-28 06:48:56 -06:00
|
|
|
unsigned int *sequence)
|
|
|
|
{
|
|
|
|
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
|
|
|
unsigned int cur_irq_sequence;
|
2006-04-11 00:18:28 -06:00
|
|
|
drm_via_irq_t *cur_irq;
|
2005-06-28 06:48:56 -06:00
|
|
|
int ret = 0;
|
2006-04-05 02:10:11 -06:00
|
|
|
maskarray_t *masks;
|
2005-11-12 03:52:46 -07:00
|
|
|
int real_irq;
|
2005-06-28 06:48:56 -06:00
|
|
|
|
2008-01-23 22:58:57 -07:00
|
|
|
DRM_DEBUG("\n");
|
2005-06-28 06:48:56 -06:00
|
|
|
|
|
|
|
if (!dev_priv) {
|
2008-01-23 22:58:57 -07:00
|
|
|
DRM_ERROR("called with no initialization\n");
|
2007-08-25 03:22:43 -06:00
|
|
|
return -EINVAL;
|
2005-06-28 06:48:56 -06:00
|
|
|
}
|
|
|
|
|
2005-11-12 03:52:46 -07:00
|
|
|
if (irq >= drm_via_irq_num) {
|
2008-01-23 22:58:57 -07:00
|
|
|
DRM_ERROR("Trying to wait on unknown irq %d\n", irq);
|
2007-08-25 03:22:43 -06:00
|
|
|
return -EINVAL;
|
2005-06-28 06:48:56 -06:00
|
|
|
}
|
2005-09-24 22:28:13 -06:00
|
|
|
|
2005-11-12 03:52:46 -07:00
|
|
|
real_irq = dev_priv->irq_map[irq];
|
|
|
|
|
|
|
|
if (real_irq < 0) {
|
2008-01-23 22:58:57 -07:00
|
|
|
DRM_ERROR("Video IRQ %d not available on this hardware.\n",
|
|
|
|
irq);
|
2007-08-25 03:22:43 -06:00
|
|
|
return -EINVAL;
|
2005-11-12 03:52:46 -07:00
|
|
|
}
|
2006-04-05 02:10:11 -06:00
|
|
|
|
|
|
|
masks = dev_priv->irq_masks;
|
2006-04-11 00:18:28 -06:00
|
|
|
cur_irq = dev_priv->via_irqs + real_irq;
|
2005-06-28 06:48:56 -06:00
|
|
|
|
2005-11-12 03:52:46 -07:00
|
|
|
if (masks[real_irq][2] && !force_sequence) {
|
2013-12-11 03:34:41 -07:00
|
|
|
DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
|
2005-09-24 22:28:13 -06:00
|
|
|
((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
|
|
|
|
masks[irq][4]));
|
2005-06-28 06:48:56 -06:00
|
|
|
cur_irq_sequence = atomic_read(&cur_irq->irq_received);
|
|
|
|
} else {
|
2013-12-11 03:34:41 -07:00
|
|
|
DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * HZ,
|
2005-09-24 22:28:13 -06:00
|
|
|
(((cur_irq_sequence =
|
|
|
|
atomic_read(&cur_irq->irq_received)) -
|
|
|
|
*sequence) <= (1 << 23)));
|
2005-06-28 06:48:56 -06:00
|
|
|
}
|
|
|
|
*sequence = cur_irq_sequence;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
|
2005-06-28 06:48:56 -06:00
|
|
|
/*
|
|
|
|
* drm_dma.h hooks
|
|
|
|
*/
|
|
|
|
|
2010-07-11 07:32:42 -06:00
|
|
|
void via_driver_irq_preinstall(struct drm_device *dev)
|
2005-06-28 06:48:56 -06:00
|
|
|
{
|
|
|
|
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
|
|
|
u32 status;
|
2006-04-11 00:18:28 -06:00
|
|
|
drm_via_irq_t *cur_irq;
|
2005-06-28 06:48:56 -06:00
|
|
|
int i;
|
|
|
|
|
2008-01-23 22:58:57 -07:00
|
|
|
DRM_DEBUG("dev_priv: %p\n", dev_priv);
|
2005-06-28 06:48:56 -06:00
|
|
|
if (dev_priv) {
|
2006-04-11 00:18:28 -06:00
|
|
|
cur_irq = dev_priv->via_irqs;
|
2005-06-28 06:48:56 -06:00
|
|
|
|
|
|
|
dev_priv->irq_enable_mask = VIA_IRQ_VBLANK_ENABLE;
|
|
|
|
dev_priv->irq_pending_mask = VIA_IRQ_VBLANK_PENDING;
|
|
|
|
|
2007-01-08 03:19:57 -07:00
|
|
|
if (dev_priv->chipset == VIA_PRO_GROUP_A ||
|
|
|
|
dev_priv->chipset == VIA_DX9_0) {
|
|
|
|
dev_priv->irq_masks = via_pro_group_a_irqs;
|
|
|
|
dev_priv->num_irqs = via_num_pro_group_a;
|
|
|
|
dev_priv->irq_map = via_irqmap_pro_group_a;
|
|
|
|
} else {
|
|
|
|
dev_priv->irq_masks = via_unichrome_irqs;
|
|
|
|
dev_priv->num_irqs = via_num_unichrome;
|
|
|
|
dev_priv->irq_map = via_irqmap_unichrome;
|
|
|
|
}
|
2005-09-24 22:28:13 -06:00
|
|
|
|
|
|
|
for (i = 0; i < dev_priv->num_irqs; ++i) {
|
2005-06-28 06:48:56 -06:00
|
|
|
atomic_set(&cur_irq->irq_received, 0);
|
2005-09-24 22:28:13 -06:00
|
|
|
cur_irq->enable_mask = dev_priv->irq_masks[i][0];
|
2005-06-28 06:48:56 -06:00
|
|
|
cur_irq->pending_mask = dev_priv->irq_masks[i][1];
|
2013-12-11 03:34:43 -07:00
|
|
|
init_waitqueue_head(&cur_irq->irq_queue);
|
2005-06-28 06:48:56 -06:00
|
|
|
dev_priv->irq_enable_mask |= cur_irq->enable_mask;
|
|
|
|
dev_priv->irq_pending_mask |= cur_irq->pending_mask;
|
|
|
|
cur_irq++;
|
2005-09-24 22:28:13 -06:00
|
|
|
|
2005-06-28 06:48:56 -06:00
|
|
|
DRM_DEBUG("Initializing IRQ %d\n", i);
|
|
|
|
}
|
2005-09-24 22:28:13 -06:00
|
|
|
|
|
|
|
dev_priv->last_vblank_valid = 0;
|
2005-06-28 06:48:56 -06:00
|
|
|
|
2005-11-12 03:52:46 -07:00
|
|
|
/* Clear VSync interrupt regs */
|
2005-06-28 06:48:56 -06:00
|
|
|
status = VIA_READ(VIA_REG_INTERRUPT);
|
2005-09-24 22:28:13 -06:00
|
|
|
VIA_WRITE(VIA_REG_INTERRUPT, status &
|
2005-06-28 06:48:56 -06:00
|
|
|
~(dev_priv->irq_enable_mask));
|
2005-09-24 22:28:13 -06:00
|
|
|
|
2005-06-28 06:48:56 -06:00
|
|
|
/* Clear bits if they're already high */
|
|
|
|
viadrv_acknowledge_irqs(dev_priv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
int via_driver_irq_postinstall(struct drm_device *dev)
|
2005-06-28 06:48:56 -06:00
|
|
|
{
|
|
|
|
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
|
|
|
u32 status;
|
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
DRM_DEBUG("via_driver_irq_postinstall\n");
|
|
|
|
if (!dev_priv)
|
|
|
|
return -EINVAL;
|
2005-06-28 06:48:56 -06:00
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
status = VIA_READ(VIA_REG_INTERRUPT);
|
|
|
|
VIA_WRITE(VIA_REG_INTERRUPT, status | VIA_IRQ_GLOBAL
|
|
|
|
| dev_priv->irq_enable_mask);
|
2005-06-28 06:48:56 -06:00
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
/* Some magic, oh for some data sheets ! */
|
|
|
|
VIA_WRITE8(0x83d4, 0x11);
|
|
|
|
VIA_WRITE8(0x83d5, VIA_READ8(0x83d5) | 0x30);
|
2005-09-24 22:28:13 -06:00
|
|
|
|
2008-09-30 13:14:26 -06:00
|
|
|
return 0;
|
2005-06-28 06:48:56 -06:00
|
|
|
}
|
|
|
|
|
2010-07-11 07:32:42 -06:00
|
|
|
void via_driver_irq_uninstall(struct drm_device *dev)
|
2005-06-28 06:48:56 -06:00
|
|
|
{
|
|
|
|
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
|
|
|
u32 status;
|
|
|
|
|
2008-01-23 22:58:57 -07:00
|
|
|
DRM_DEBUG("\n");
|
2005-06-28 06:48:56 -06:00
|
|
|
if (dev_priv) {
|
|
|
|
|
|
|
|
/* Some more magic, oh for some data sheets ! */
|
|
|
|
|
|
|
|
VIA_WRITE8(0x83d4, 0x11);
|
|
|
|
VIA_WRITE8(0x83d5, VIA_READ8(0x83d5) & ~0x30);
|
|
|
|
|
|
|
|
status = VIA_READ(VIA_REG_INTERRUPT);
|
2005-09-24 22:28:13 -06:00
|
|
|
VIA_WRITE(VIA_REG_INTERRUPT, status &
|
2005-06-28 06:48:56 -06:00
|
|
|
~(VIA_IRQ_VBLANK_ENABLE | dev_priv->irq_enable_mask));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-02 20:06:45 -06:00
|
|
|
int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
|
2005-06-28 06:48:56 -06:00
|
|
|
{
|
2007-09-02 20:06:45 -06:00
|
|
|
drm_via_irqwait_t *irqwait = data;
|
2005-06-28 06:48:56 -06:00
|
|
|
struct timeval now;
|
|
|
|
int ret = 0;
|
|
|
|
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
|
|
|
|
drm_via_irq_t *cur_irq = dev_priv->via_irqs;
|
|
|
|
int force_sequence;
|
|
|
|
|
2007-09-02 20:06:45 -06:00
|
|
|
if (irqwait->request.irq >= dev_priv->num_irqs) {
|
2008-01-23 22:58:57 -07:00
|
|
|
DRM_ERROR("Trying to wait on unknown irq %d\n",
|
2007-09-02 20:06:45 -06:00
|
|
|
irqwait->request.irq);
|
2007-08-25 03:22:43 -06:00
|
|
|
return -EINVAL;
|
2005-06-28 06:48:56 -06:00
|
|
|
}
|
|
|
|
|
2007-09-02 20:06:45 -06:00
|
|
|
cur_irq += irqwait->request.irq;
|
2005-06-28 06:48:56 -06:00
|
|
|
|
2007-09-02 20:06:45 -06:00
|
|
|
switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
|
2005-06-28 06:48:56 -06:00
|
|
|
case VIA_IRQ_RELATIVE:
|
2008-09-30 13:14:26 -06:00
|
|
|
irqwait->request.sequence +=
|
|
|
|
atomic_read(&cur_irq->irq_received);
|
2007-09-02 20:06:45 -06:00
|
|
|
irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
|
2005-06-28 06:48:56 -06:00
|
|
|
case VIA_IRQ_ABSOLUTE:
|
|
|
|
break;
|
|
|
|
default:
|
2007-08-25 03:22:43 -06:00
|
|
|
return -EINVAL;
|
2005-06-28 06:48:56 -06:00
|
|
|
}
|
|
|
|
|
2007-09-02 20:06:45 -06:00
|
|
|
if (irqwait->request.type & VIA_IRQ_SIGNAL) {
|
2008-01-23 22:58:57 -07:00
|
|
|
DRM_ERROR("Signals on Via IRQs not implemented yet.\n");
|
2007-08-25 03:22:43 -06:00
|
|
|
return -EINVAL;
|
2005-06-28 06:48:56 -06:00
|
|
|
}
|
|
|
|
|
2007-09-02 20:06:45 -06:00
|
|
|
force_sequence = (irqwait->request.type & VIA_IRQ_FORCE_SEQUENCE);
|
2005-06-28 06:48:56 -06:00
|
|
|
|
2007-09-02 20:06:45 -06:00
|
|
|
ret = via_driver_irq_wait(dev, irqwait->request.irq, force_sequence,
|
|
|
|
&irqwait->request.sequence);
|
2005-06-28 06:48:56 -06:00
|
|
|
do_gettimeofday(&now);
|
2007-09-02 20:06:45 -06:00
|
|
|
irqwait->reply.tval_sec = now.tv_sec;
|
|
|
|
irqwait->reply.tval_usec = now.tv_usec;
|
2005-06-28 06:48:56 -06:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|