/*
* drm_irq.c -- IRQ IOCTL and function support
* Created: Fri Oct 18 2003 by anholt@FreeBSD.org
*/
/*
* Copyright 2003 Eric Anholt
* Copyright (c) 2009, Intel Corporation.
* 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,
* 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
* ERIC ANHOLT 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:
* Eric Anholt <anholt@FreeBSD.org>
*
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include "drmP.h"
#include "drm.h"
#include "drm_io32.h"
/*ARGSUSED*/
int
{
return (EINVAL);
DRM_DEBUG("%d:%d:%d => IRQ %d\n",
return (0);
}
static irqreturn_t
{
int ret;
return (ret);
}
{
int i;
if (!dev->vblank_disable_allowed)
return;
dev->last_vblank[i] =
DRM_DEBUG("disable vblank");
}
}
}
void
{
/* Bail if the driver didn't call drm_vblank_init() */
return;
vblank_disable_fn((void *)dev);
}
int
{
if (!dev->vbl_queues)
goto err;
goto err;
if (!dev->_vblank_count)
goto err;
if (!dev->vblank_refcount)
goto err;
if (!dev->vblank_enabled)
goto err;
if (!dev->last_vblank)
goto err;
if (!dev->vblank_inmodeset)
goto err;
/* Zero per-crtc vblank stuff */
for (i = 0; i < num_crtcs; i++) {
}
return (0);
err:
DRM_ERROR("drm_vblank_init: alloc error");
return (ret);
}
/*ARGSUSED*/
static int
{
DRM_ERROR("drm_install_irq_handle: cannot get vgatext's dip");
return (DDI_FAILURE);
}
if (ddi_intr_hilevel(dip, 0) != 0) {
DRM_ERROR("drm_install_irq_handle: "
"high-level interrupts are not supported");
return (DDI_FAILURE);
}
DRM_ERROR("drm_install_irq_handle: cannot get iblock cookie");
return (DDI_FAILURE);
}
/* setup the interrupt handler */
DRM_ERROR("drm_install_irq_handle: ddi_add_intr failed");
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
/*ARGSUSED*/
int
{
int ret;
DRM_ERROR("drm_irq_install: dev_private is NULL");
return (EINVAL);
}
if (dev->irq_enabled) {
DRM_ERROR("drm_irq_install: irq already enabled");
return (EBUSY);
}
/* before installing handler */
if (ret)
return (EINVAL);
/* install handler */
if (ret != DDI_SUCCESS) {
DRM_ERROR("drm_irq_install: drm_install_irq_handle failed");
return (ret);
}
/* after installing handler */
dev->context_flag = 0;
return (0);
}
static void
{
}
/*ARGSUSED*/
int
{
int i;
if (!dev->irq_enabled) {
return (EINVAL);
}
dev->irq_enabled = 0;
/*
* Wake up any waiters so they don't hang.
*/
dev->vblank_enabled[i] = 0;
}
return (DDI_SUCCESS);
}
/*ARGSUSED*/
int
{
int err;
case DRM_INST_HANDLER:
/*
* Handle drivers whose DRM used to require IRQ setup but the
* no longer does.
*/
return (drm_irq_install(dev));
case DRM_UNINST_HANDLER:
return (err);
default:
return (EINVAL);
}
}
{
}
{
/*
* Interrupts were disabled prior to this call, so deal with counter
* wrap if needed.
* NOTE! It's possible we lost a full dev->max_vblank_count events
* here if the register is small or we had vblank interrupts off for
* a long time.
*/
DRM_DEBUG("last_vblank[%d]=0x%x, cur_vblank=0x%x => diff=0x%x\n",
}
}
int
{
int ret = 0;
}
/* Going from 0->1 means we have to enable interrupts again */
if (ret)
else {
}
}
return (ret);
}
void
{
/* Last user schedules interrupt disable */
}
/*
* drm_modeset_ctl - handle vblank event counter changes across mode switch
* @DRM_IOCTL_ARGS: standard ioctl arguments
*
* Applications should call the %_DRM_PRE_MODESET and %_DRM_POST_MODESET
* ioctls around modesetting so that any lost vblank events are accounted for.
*
* Generally the counter will reset across mode sets. If interrupts are
* enabled around this call, we don't have to do anything since the counter
* will have already been incremented.
*/
/*ARGSUSED*/
int
{
/* If drm_vblank_init() hasn't been called yet, just no-op */
goto out;
sizeof (modeset));
goto out;
}
/*
* To avoid all the problems that might happen if interrupts
* have the kernel take a reference on the CRTC (just once though
* to avoid corrupting the count if multiple, mismatch calls occur),
* so that interrupts remain enabled in the interim.
*/
case _DRM_PRE_MODESET:
}
break;
case _DRM_POST_MODESET:
}
break;
default:
break;
}
out:
return (ret);
}
/*ARGSUSED*/
int
{
unsigned int sequence;
if (!dev->irq_enabled) {
DRM_ERROR("wait vblank, EINVAL");
return (EINVAL);
}
#ifdef _MULTI_DATAMODEL
sizeof (vblwait32));
} else {
#endif
sizeof (vblwait));
#ifdef _MULTI_DATAMODEL
}
#endif
DRM_ERROR("drm_wait_vblank: wrong request type 0x%x",
return (EINVAL);
}
DRM_ERROR("wait vblank operation not support");
return (ENOTSUP);
}
if (ret) {
return (ret);
}
case _DRM_VBLANK_RELATIVE:
/*FALLTHROUGH*/
case _DRM_VBLANK_ABSOLUTE:
break;
default:
DRM_DEBUG("wait vblank return EINVAL");
return (EINVAL);
}
if ((flags & _DRM_VBLANK_NEXTONMISS) &&
}
if (flags & _DRM_VBLANK_SIGNAL) {
/*
* Don't block process, send signal when vblank interrupt
*/
DRM_ERROR("NOT SUPPORT YET, SHOULD BE ADDED");
goto done;
} else {
/* block until vblank interupt */
/* shared code returns -errno */
!dev->irq_enabled));
}
}
done:
#ifdef _MULTI_DATAMODEL
sizeof (vblwait32));
} else {
#endif
sizeof (vblwait));
#ifdef _MULTI_DATAMODEL
}
#endif
return (ret);
}
/*ARGSUSED*/
void
{
DRM_DEBUG("drm_vbl_send_signals");
}
void
{
}