i915_drv.c revision 60405de4d8688d96dd05157c28db3ade5c9bc234
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* BEGIN CSTYLED */
/*
* i915_drv.c -- ATI Radeon driver -*- linux-c -*-
* Created: Wed Feb 14 17:10:04 2001 by gareth@valinux.com
*/
/*
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* 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
* 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:
* Gareth Hughes <gareth@valinux.com>
*
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
#include "i915_drv.h"
#include "drm_pciids.h"
#define i915_max_ioctl 15
/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
static drm_pci_id_list_t i915_pciidlist[] = {
};
extern drm_ioctl_desc_t drm_ioctls[];
extern void i915_init_ioctl_arrays(void);
{
}
extern int
struct drm_softstate *softc)
{
int minor;
int cloneminor, cleanpass;
DRM_ERROR("i915_open: NULL soft state");
return (ENXIO);
}
DDI_SUCCESS) {
DRM_ERROR("i915_open: "
"DRM current don't support this graphics card");
return (ENXIO);
}
}
cleanpass = 1;
cleanpass = 0;
break;
}
}
if (cleanpass) {
goto gotminor;
}
}
softc->cloneopens++;
}
extern int
struct drm_softstate *softc)
{
int minor;
DRM_ERROR("i915_close: NULL soft state");
return (ENXIO);
}
if (dev_priv) {
{
}
}
return (ENXIO);
}
} else {
}
softc->cloneopens--;
break;
} else {
}
}
}
int
{
DRM_LOCK();
DRM_UNLOCK();
DRM_ERROR("i915_ioctl : can't find authenticator");
return (EINVAL);
}
++priv->ioctl_count;
/* It's not a core DRM ioctl, try driver-specific. */
/* The array entries begin at DRM_COMMAND_BASE ioctl nr */
nr -= DRM_COMMAND_BASE;
DRM_ERROR("Bad driver ioctl number, 0x%x (of 0x%x)",
return (EINVAL);
}
}
!priv->authenticated))
return (EACCES);
DRM_ERROR("i915_ioctl: no function ");
return (EINVAL);
}
return (retcode);
}
/*ARGSUSED*/
int
{
int ret;
DRM_ERROR("i915_devmap: NULL soft state");
return (EINVAL);
}
DRM_LOCK();
DRM_DEBUG("i915_devmap: offset is 0x%llx map->offset is 0x%llx",
/*
* use low 32-bit to search only, since 32-bit user app is
* incapable of passing in 64-bit offset when doing mmap.
*/
(u_offset_t)(unsigned int)offset
break;
}
DRM_UNLOCK();
DRM_ERROR("can't find map\n");
return (-1);
}
DRM_UNLOCK();
DRM_ERROR("restricted map\n");
return (-1);
}
DRM_UNLOCK();
case _DRM_FRAME_BUFFER:
case _DRM_REGISTERS:
case _DRM_AGP:
{
int err;
int regno;
0, accattrp);
if (err != 0) {
*maplen = 0;
DRM_ERROR("i915_devmap: devmap failed");
return (err);
}
return (err);
}
case _DRM_SHM:
{
DRM_DEBUG("i915_devmap: map type is _DRM_SHM");
DRM_ERROR("i915_devmap: "
"Fatal error! sarea_cookie is NULL");
return (EINVAL);
}
koff = 0;
if (ret != 0) {
*maplen = 0;
return (ret);
}
return (DDI_SUCCESS);
}
default:
return (DDI_FAILURE);
}
}
int
struct drm_softstate **drm_softcp,
{
int instance;
int ret;
char buf[80];
if (cmd != DDI_ATTACH) {
"i915_attach: only attach op supported");
return (DDI_FAILURE);
}
softc = (drm_softstate_t *)
/* call common attach code */
if (ret != DDI_SUCCESS) {
"i915_attach: drm attach ops failed");
goto err1;
}
/* create minor node for DRM access */
minor, DDI_NT_DISPLAY_DRM, 0)) {
DRM_ERROR("i915_attach: create minor node failed");
goto err2;
}
*drm_softcp = softc;
return (DDI_SUCCESS);
err2:
err1:
*drm_softcp = NULL;
return (DDI_FAILURE);
}
int
{
if (cmd != DDI_DETACH)
return (DDI_FAILURE);
(void) drm_detach(softc);
*drm_softcp = NULL;
return (DDI_SUCCESS);
}