/*
*/
/**
* \file drm_agpsupport.c
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* Copyright (c) 2009, 2013, 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
* 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.
*/
#include "drm.h"
#include "drmP.h"
#ifndef AGP_PAGE_SIZE
#endif
/*
* The agpa_key field of struct agp_allocate_t actually is
* an index to an array. It can be zero. But we will use
* this agpa_key as a handle returned to userland. Generally,
* 0 is not a valid value for a handle, so we add an offset
* to the key to get a handle.
*/
{
}
/**
* Get AGP information.
*
* \param inode device inode.
* \param file_priv DRM file private.
* \param cmd command.
* \param arg pointer to a (output) drm_agp_info structure.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device has been initialized and acquired and fills in the
* drm_agp_info structure with the information in drm_agp_head::agp_info.
*/
{
return -EINVAL;
return 0;
}
/* LINTED */
{
int err;
if (err)
return err;
return 0;
}
/**
* Acquire the AGP device.
*
* \param dev DRM device that is to acquire AGP.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device hasn't been acquired before and calls
* \c agp_backend_acquire.
*/
{
return -ENODEV;
return -EBUSY;
{
DRM_ERROR("AGPIOC_ACQUIRE failed");
return -ret;
}
}
return 0;
}
/**
* Acquire the AGP device (ioctl).
*
* \param inode device inode.
* \param file_priv DRM file private.
* \param cmd command.
* \param arg user argument.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device hasn't been acquired before and calls
* \c agp_backend_acquire.
*/
/* LINTED */
{
}
/**
* Release the AGP device.
*
* \param dev DRM device that is to release AGP.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device has been acquired and calls \c agp_backend_release.
*/
{
return -EINVAL;
{
DRM_ERROR("AGPIOC_RELEASE failed");
return -ret;
}
}
return 0;
}
/* LINTED */
{
return drm_agp_release(dev);
}
/**
* Enable the AGP bus.
*
* \param dev DRM device that has previously acquired AGP.
* \param mode Requested AGP mode.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device has been acquired but not enabled, and calls
* \c agp_enable.
*/
{
return -EINVAL;
{
DRM_ERROR("AGPIOC_SETUP failed");
return -ret;
}
}
return 0;
}
/* LINTED */
{
}
/**
* Allocate AGP memory.
*
* \param inode device inode.
* \param file_priv file private pointer.
* \param cmd command.
* \param arg pointer to a drm_agp_buffer structure.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device is present and has been acquired, allocates the
* memory via alloc_agp() and creates a drm_agp_mem entry for it.
*/
{
unsigned long pages;
return -EINVAL;
return -ENOMEM;
if (ret) {
DRM_ERROR("AGPIOC_ALLOCATE failed");
return -ret;
}
return 0;
}
/* LINTED */
{
}
/**
* Search for the AGP memory entry associated with a handle.
*
* \param dev DRM device structure.
* \param handle AGP memory handle.
* \return pointer to the drm_agp_mem structure associated with \p handle.
*
* Walks through drm_agp_head::memory until finding a matching handle.
*/
unsigned long handle)
{
return entry;
}
return NULL;
}
/**
* Unbind AGP memory from the GATT (ioctl).
*
* \param inode device inode.
* \param file_priv DRM file private.
* \param cmd command.
* \param arg pointer to a drm_agp_binding structure.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device is present and acquired, looks-up the AGP memory
* entry and passes it to the unbind_agp() function.
*/
{
int ret;
return -EINVAL;
return -EINVAL;
return -EINVAL;
{
int rval;
DRM_ERROR("AGPIOC_UNBIND failed");
return -ret;
}
}
return ret;
}
/* LINTED */
{
}
/**
* Bind AGP memory into the GATT (ioctl)
*
* \param inode device inode.
* \param file_priv DRM file private.
* \param cmd command.
* \param arg pointer to a drm_agp_binding structure.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device is present and has been acquired and that no memory
* is currently bound into the GATT. Looks-up the AGP memory entry and passes
* it to bind_agp() function.
*/
{
int retcode;
int page;
return -EINVAL;
return -EINVAL;
return -EINVAL;
{
DRM_ERROR("failed key=0x%x, page=0x%x, "
return retcode;
}
}
DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n",
return 0;
}
/* LINTED */
{
}
/**
* Free AGP memory (ioctl).
*
* \param inode device inode.
* \param file_priv DRM file private.
* \param cmd command.
* \param arg pointer to a drm_agp_buffer structure.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device is present and has been acquired and looks up the
* AGP memory entry. If the memory it's currently bound, unbind it via
* unbind_agp(). Frees it via free_agp() as well as the entry itself
* and unlinks from the doubly linked list it's inserted in.
*/
{
return -EINVAL;
return -EINVAL;
{
if (ret) {
DRM_ERROR("AGPIOC_DEALLOCATE failed,"
return -ret;
}
}
return 0;
}
/* LINTED */
{
}
/**
* Initialize the AGP resources.
*
* \return pointer to a drm_agp_head structure.
*
* Gets the drm_agp_t structure which is made available by the agpgart module
* via the inter_module_* functions. Creates and initializes a drm_agp_head
* structure.
*/
{
return NULL;
if (ret) {
goto err_1;
}
if (ret) {
goto err_2;
}
if (ret) {
goto err_3;
}
return head;
return NULL;
}
/* LINTED */
{
return NULL;
}
/* LINTED */
{
return 1;
}
{
DRM_DEBUG("AGPIOC_BIND failed");
return -ret;
}
return 0;
}
{
return -EINVAL;
return -EINVAL;
DRM_ERROR("AGPIO_UNBIND failed");
return -ret;
}
return 0;
}
/**
* Binds a collection of pages into AGP memory at the given offset, returning
* the AGP memory structure containing them.
*
* No reference is held on the pages during this time -- it is up to the
* caller to handle that.
*/
int
unsigned long num_pages,
unsigned int agp_type)
{
if (ret) {
return -ret;
}
return 0;
}
int
unsigned long num_pages,
{
if (ret) {
return -ret;
}
return 0;
}
{
if (ret)
}
int
unsigned long num_pages,
void *gttp,
{
/* read = 0 write = 1 */
if (ret) {
return -ret;
}
return 0;
}