summaryrefslogtreecommitdiff
path: root/bsd/.cvsignore
diff options
context:
space:
mode:
authorFelix Kuehling <fxkuehl@gmx.de>2004-09-22 22:51:18 +0000
committerFelix Kuehling <fxkuehl@gmx.de>2004-09-22 22:51:18 +0000
commitaf326f6f0c26191b4aef2183fb485e58495b29a5 (patch)
tree5f107ae2a9aa33ea5bc971618bf8e84824b89770 /bsd/.cvsignore
parent27fc998f7d16e7197f38b2d7d1ce65938e06423d (diff)
Create permanent maps of framebuffer, aperture and MMIO registers. Added
chipset-type information in driver data field of Savage PCI-IDs. Added missing PCI-ID 0x8d03 (ProSavageDDR on Pentium boards). Don't require AGP.
Diffstat (limited to 'bsd/.cvsignore')
0 files changed, 0 insertions, 0 deletions
>104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
/* via_irq.c
 *
 * Copyright 2004 BEAM Ltd.
 * Copyright 2002 Tungsten Graphics, Inc.
 * 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>
 *
 *
 * This code provides standard DRM access to the Via CLE266's Vertical blank
 * interrupt.
 */

#include "via.h"
#include "drmP.h"
#include "drm.h"
#include "via_drm.h"
#include "via_drv.h"

#define VIA_REG_INTERRUPT       0x200

/* VIA_REG_INTERRUPT */
#define VIA_IRQ_GLOBAL          (1 << 31)
#define VIA_IRQ_VBI_ENABLE      (1 << 19)
#define VIA_IRQ_VBI_PENDING     (1 << 3)



static unsigned time_diff(struct timeval *now,struct timeval *then) 
{
    return (now->tv_usec >= then->tv_usec) ?
        now->tv_usec - then->tv_usec :
        1000000 - (then->tv_usec - now->tv_usec);
}

irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
{
	drm_device_t *dev = (drm_device_t *) arg;
	drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
	u32 status;
	int handled = 0;
	struct timeval cur_vblank;

	status = VIA_READ(VIA_REG_INTERRUPT);
	if (status & VIA_IRQ_VBI_PENDING) {
		atomic_inc(&dev->vbl_received);
                if (!(atomic_read(&dev->vbl_received) & 0x0F)) {
			do_gettimeofday(&cur_vblank);
                        if (dev_priv->last_vblank_valid) {
				dev_priv->usec_per_vblank = 
					time_diff( &cur_vblank,&dev_priv->last_vblank) >> 4;
			}
			dev_priv->last_vblank = cur_vblank;
			dev_priv->last_vblank_valid = 1;
                }
                if (!(atomic_read(&dev->vbl_received) & 0xFF)) {
			DRM_DEBUG("US per vblank is: %u\n",
				dev_priv->usec_per_vblank);
		}
		DRM_WAKEUP(&dev->vbl_queue);
		DRM(vbl_send_signals) (dev);
		handled = 1;
	}

	/* Acknowlege interrupts ?? */
	VIA_WRITE(VIA_REG_INTERRUPT, status);

	if (handled)
		return IRQ_HANDLED;
	else
		return IRQ_NONE;
}