2010-02-12 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* \file drmP.h
|
|
|
|
* Private header for Direct Rendering Manager
|
|
|
|
*
|
|
|
|
* \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.
|
2011-06-24 12:45:58 +02:00
|
|
|
* Copyright (c) 2009-2010, Code Aurora Forum.
|
2010-02-12 21:11:35 +01:00
|
|
|
* 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
|
|
|
|
* VA LINUX SYSTEMS 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _DRM_P_H_
|
|
|
|
#define _DRM_P_H_
|
|
|
|
|
2013-07-02 18:05:26 +02:00
|
|
|
#define iowrite32(v, addr) writel((v), (addr))
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
#ifdef __KERNEL__
|
2012-11-12 22:22:52 +01:00
|
|
|
#ifdef __alpha__
|
|
|
|
/* add include of current.h so that "current" is defined
|
|
|
|
* before static inline funcs in wait.h. Doing this so we
|
|
|
|
* can build the DRM (part of PI DRI). 4/21/2000 S + B */
|
|
|
|
#include <asm/current.h>
|
|
|
|
#endif /* __alpha__ */
|
2012-09-04 23:42:08 +02:00
|
|
|
|
|
|
|
#include <syscall.h>
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
#include <linux/kernel.h>
|
2012-11-12 22:22:52 +01:00
|
|
|
#include <linux/export.h>
|
2012-09-04 23:42:08 +02:00
|
|
|
#include <linux/errno.h>
|
2010-02-12 21:11:35 +01:00
|
|
|
#include <linux/kref.h>
|
|
|
|
#include <linux/spinlock.h>
|
2012-09-04 23:42:08 +02:00
|
|
|
#include <linux/wait.h>
|
2012-11-12 22:22:52 +01:00
|
|
|
#include <linux/bug.h>
|
2013-03-19 07:14:59 +01:00
|
|
|
#include <linux/sched.h>
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2013-07-05 09:41:18 +02:00
|
|
|
#include <linux/firmware.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
|
2014-02-06 07:52:49 +01:00
|
|
|
#include <linux/fs.h>
|
2010-02-12 21:11:35 +01:00
|
|
|
//#include <linux/init.h>
|
2014-02-06 07:52:49 +01:00
|
|
|
#include <linux/file.h>
|
2010-02-12 21:11:35 +01:00
|
|
|
#include <linux/pci.h>
|
2012-09-04 23:42:08 +02:00
|
|
|
#include <linux/jiffies.h>
|
2014-08-23 12:29:27 +02:00
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
|
2013-07-02 18:05:26 +02:00
|
|
|
#include <linux/irqreturn.h>
|
2010-09-28 00:55:59 +02:00
|
|
|
#include <linux/mutex.h>
|
2010-02-12 21:11:35 +01:00
|
|
|
//#include <asm/io.h>
|
2014-08-23 12:29:27 +02:00
|
|
|
#include <linux/slab.h>
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
//#include <asm/uaccess.h>
|
|
|
|
//#include <linux/workqueue.h>
|
|
|
|
//#include <linux/poll.h>
|
|
|
|
//#include <asm/pgalloc.h>
|
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
#include <linux/types.h>
|
2013-04-26 13:01:23 +02:00
|
|
|
#include <linux/workqueue.h>
|
|
|
|
|
|
|
|
|
2013-10-26 15:31:36 +02:00
|
|
|
#include <drm/drm.h>
|
|
|
|
#include <drm/drm_vma_manager.h>
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
#include <linux/idr.h>
|
|
|
|
|
|
|
|
#define __OS_HAS_AGP (defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE)))
|
|
|
|
|
2012-11-12 22:22:52 +01:00
|
|
|
struct module;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
struct drm_file;
|
|
|
|
struct drm_device;
|
|
|
|
|
2013-03-19 07:14:59 +01:00
|
|
|
struct device_node;
|
|
|
|
struct videomode;
|
2014-08-23 12:29:27 +02:00
|
|
|
struct reservation_object;
|
2013-10-26 15:31:36 +02:00
|
|
|
|
|
|
|
struct inode;
|
|
|
|
struct poll_table_struct;
|
|
|
|
struct drm_lock_data;
|
|
|
|
|
|
|
|
struct sg_table;
|
|
|
|
struct dma_buf;
|
|
|
|
|
2012-11-12 22:22:52 +01:00
|
|
|
//#include <drm/drm_os_linux.h>
|
|
|
|
#include <drm/drm_hashtab.h>
|
|
|
|
#include <drm/drm_mm.h>
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
#define KHZ2PICOS(a) (1000000000UL/(a))
|
|
|
|
|
2014-02-06 07:52:49 +01:00
|
|
|
/* Flags and return codes for get_vblank_timestamp() driver function. */
|
|
|
|
#define DRM_CALLED_FROM_VBLIRQ 1
|
|
|
|
#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
|
|
|
|
#define DRM_VBLANKTIME_INVBL (1 << 1)
|
2014-08-23 12:29:27 +02:00
|
|
|
|
2014-02-06 07:52:49 +01:00
|
|
|
|
2011-06-24 12:45:58 +02:00
|
|
|
/* get_scanout_position() return flags */
|
|
|
|
#define DRM_SCANOUTPOS_VALID (1 << 0)
|
|
|
|
#define DRM_SCANOUTPOS_INVBL (1 << 1)
|
|
|
|
#define DRM_SCANOUTPOS_ACCURATE (1 << 2)
|
|
|
|
|
2012-11-12 22:22:52 +01:00
|
|
|
/*
|
2014-08-23 12:29:27 +02:00
|
|
|
* 4 debug categories are defined:
|
|
|
|
*
|
|
|
|
* CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ...
|
|
|
|
* This is the category used by the DRM_DEBUG() macro.
|
|
|
|
*
|
|
|
|
* DRIVER: Used in the vendor specific part of the driver: i915, radeon, ...
|
|
|
|
* This is the category used by the DRM_DEBUG_DRIVER() macro.
|
2012-11-12 22:22:52 +01:00
|
|
|
*
|
2014-08-23 12:29:27 +02:00
|
|
|
* KMS: used in the modesetting code.
|
|
|
|
* This is the category used by the DRM_DEBUG_KMS() macro.
|
2012-11-12 22:22:52 +01:00
|
|
|
*
|
2014-08-23 12:29:27 +02:00
|
|
|
* PRIME: used in the prime code.
|
|
|
|
* This is the category used by the DRM_DEBUG_PRIME() macro.
|
2012-11-12 22:22:52 +01:00
|
|
|
*
|
2014-08-23 12:29:27 +02:00
|
|
|
* Enabling verbose debug messages is done through the drm.debug parameter,
|
|
|
|
* each category being enabled by a bit.
|
|
|
|
*
|
|
|
|
* drm.debug=0x1 will enable CORE messages
|
|
|
|
* drm.debug=0x2 will enable DRIVER messages
|
|
|
|
* drm.debug=0x3 will enable CORE and DRIVER messages
|
|
|
|
* ...
|
|
|
|
* drm.debug=0xf will enable all messages
|
|
|
|
*
|
|
|
|
* An interesting feature is that it's possible to enable verbose logging at
|
|
|
|
* run-time by echoing the debug value in its sysfs node:
|
|
|
|
* # echo 0xf > /sys/module/drm/parameters/debug
|
2012-11-12 22:22:52 +01:00
|
|
|
*/
|
2014-08-23 12:29:27 +02:00
|
|
|
#define DRM_UT_CORE 0x01
|
|
|
|
#define DRM_UT_DRIVER 0x02
|
|
|
|
#define DRM_UT_KMS 0x04
|
|
|
|
#define DRM_UT_PRIME 0x08
|
2012-11-12 22:22:52 +01:00
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
extern __printf(2, 3)
|
|
|
|
void drm_ut_debug_printk(const char *function_name,
|
2010-02-12 21:11:35 +01:00
|
|
|
const char *format, ...);
|
2012-11-12 22:22:52 +01:00
|
|
|
extern __printf(2, 3)
|
|
|
|
int drm_err(const char *func, const char *format, ...);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/** \name DRM template customization defaults */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
/* driver capabilities and requirements mask */
|
|
|
|
#define DRIVER_USE_AGP 0x1
|
|
|
|
#define DRIVER_PCI_DMA 0x8
|
|
|
|
#define DRIVER_SG 0x10
|
|
|
|
#define DRIVER_HAVE_DMA 0x20
|
|
|
|
#define DRIVER_HAVE_IRQ 0x40
|
|
|
|
#define DRIVER_IRQ_SHARED 0x80
|
|
|
|
#define DRIVER_GEM 0x1000
|
|
|
|
#define DRIVER_MODESET 0x2000
|
2012-11-12 22:22:52 +01:00
|
|
|
#define DRIVER_PRIME 0x4000
|
2013-10-26 15:31:36 +02:00
|
|
|
#define DRIVER_RENDER 0x8000
|
2012-09-04 23:42:08 +02:00
|
|
|
|
|
|
|
#define DRIVER_BUS_PCI 0x1
|
|
|
|
#define DRIVER_BUS_PLATFORM 0x2
|
|
|
|
#define DRIVER_BUS_USB 0x3
|
2014-02-06 07:52:49 +01:00
|
|
|
#define DRIVER_BUS_HOST1X 0x4
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/** \name Begin the DRM... */
|
|
|
|
/*@{*/
|
|
|
|
|
2014-02-06 07:52:49 +01:00
|
|
|
#define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then
|
2010-02-12 21:11:35 +01:00
|
|
|
also include looping detection. */
|
|
|
|
|
|
|
|
#define DRM_MAGIC_HASH_ORDER 4 /**< Size of key hash table. Must be power of 2. */
|
|
|
|
|
|
|
|
#define DRM_MAP_HASH_OFFSET 0x10000000
|
|
|
|
|
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/** \name Macros to make printk easier */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Error output.
|
|
|
|
*
|
|
|
|
* \param fmt printf() like format string.
|
|
|
|
* \param arg arguments
|
|
|
|
*/
|
2012-11-12 22:22:52 +01:00
|
|
|
#define DRM_ERROR(fmt, ...) \
|
|
|
|
drm_err(__func__, fmt, ##__VA_ARGS__)
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2014-02-06 07:52:49 +01:00
|
|
|
/**
|
|
|
|
* Rate limited error output. Like DRM_ERROR() but won't flood the log.
|
|
|
|
*
|
|
|
|
* \param fmt printf() like format string.
|
|
|
|
* \param arg arguments
|
|
|
|
*/
|
|
|
|
#define DRM_ERROR_RATELIMITED(fmt, ...) \
|
|
|
|
({ \
|
|
|
|
static DEFINE_RATELIMIT_STATE(_rs, \
|
|
|
|
DEFAULT_RATELIMIT_INTERVAL, \
|
|
|
|
DEFAULT_RATELIMIT_BURST); \
|
|
|
|
\
|
|
|
|
if (__ratelimit(&_rs)) \
|
|
|
|
drm_err(__func__, fmt, ##__VA_ARGS__); \
|
|
|
|
})
|
|
|
|
|
2012-11-12 22:22:52 +01:00
|
|
|
#define DRM_INFO(fmt, ...) \
|
|
|
|
printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
#define DRM_INFO_ONCE(fmt, ...) \
|
|
|
|
printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* Debug output.
|
|
|
|
*
|
|
|
|
* \param fmt printf() like format string.
|
|
|
|
* \param arg arguments
|
|
|
|
*/
|
|
|
|
#if DRM_DEBUG_CODE
|
2014-08-23 12:29:27 +02:00
|
|
|
#define DRM_DEBUG(fmt, args...) \
|
2012-11-12 22:22:52 +01:00
|
|
|
do { \
|
2014-08-23 12:29:27 +02:00
|
|
|
printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \
|
2010-02-12 21:11:35 +01:00
|
|
|
} while (0)
|
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
#define DRM_DEBUG_DRIVER(fmt, args...) \
|
2012-11-12 22:22:52 +01:00
|
|
|
do { \
|
2014-08-23 12:29:27 +02:00
|
|
|
printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \
|
2010-02-12 21:11:35 +01:00
|
|
|
} while (0)
|
2014-08-23 12:29:27 +02:00
|
|
|
#define DRM_DEBUG_KMS(fmt, args...) \
|
2010-02-12 21:11:35 +01:00
|
|
|
do { \
|
2014-08-23 12:29:27 +02:00
|
|
|
printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \
|
2010-02-12 21:11:35 +01:00
|
|
|
} while (0)
|
2014-08-23 12:29:27 +02:00
|
|
|
#define DRM_DEBUG_PRIME(fmt, args...) \
|
2010-02-12 21:11:35 +01:00
|
|
|
do { \
|
2014-08-23 12:29:27 +02:00
|
|
|
printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \
|
2010-02-12 21:11:35 +01:00
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0)
|
|
|
|
#define DRM_DEBUG_KMS(fmt, args...) do { } while (0)
|
2012-11-12 22:22:52 +01:00
|
|
|
#define DRM_DEBUG_PRIME(fmt, args...) do { } while (0)
|
2010-02-12 21:11:35 +01:00
|
|
|
#define DRM_DEBUG(fmt, arg...) do { } while (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/** \name Internal types and structures */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
#define DRM_ARRAY_SIZE(x) ARRAY_SIZE(x)
|
|
|
|
|
|
|
|
#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that the hardware lock is held by the caller, returning otherwise.
|
|
|
|
*
|
|
|
|
* \param dev DRM device.
|
|
|
|
* \param filp file pointer of the caller.
|
|
|
|
*/
|
|
|
|
#define LOCK_TEST_WITH_RETURN( dev, _file_priv ) \
|
|
|
|
do { \
|
|
|
|
if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) || \
|
|
|
|
_file_priv->master->lock.file_priv != _file_priv) { \
|
|
|
|
DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\
|
|
|
|
__func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\
|
|
|
|
_file_priv->master->lock.file_priv, _file_priv); \
|
|
|
|
return -EINVAL; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ioctl function type.
|
|
|
|
*
|
|
|
|
* \param inode device inode.
|
|
|
|
* \param file_priv DRM file private pointer.
|
|
|
|
* \param cmd command.
|
|
|
|
* \param arg argument.
|
|
|
|
*/
|
|
|
|
typedef int drm_ioctl_t(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
|
|
|
|
typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
|
|
|
|
unsigned long arg);
|
|
|
|
|
|
|
|
#define DRM_IOCTL_NR(n) _IOC_NR(n)
|
|
|
|
#define DRM_MAJOR 226
|
|
|
|
|
|
|
|
#define DRM_AUTH 0x1
|
|
|
|
#define DRM_MASTER 0x2
|
|
|
|
#define DRM_ROOT_ONLY 0x4
|
|
|
|
#define DRM_CONTROL_ALLOW 0x8
|
|
|
|
#define DRM_UNLOCKED 0x10
|
2013-10-26 15:31:36 +02:00
|
|
|
#define DRM_RENDER_ALLOW 0x20
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
struct drm_ioctl_desc {
|
|
|
|
unsigned int cmd;
|
|
|
|
int flags;
|
|
|
|
drm_ioctl_t *func;
|
2011-06-24 12:45:58 +02:00
|
|
|
unsigned int cmd_drv;
|
2013-07-02 18:05:26 +02:00
|
|
|
const char *name;
|
2010-02-12 21:11:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a driver or general drm_ioctl_desc array entry for the given
|
|
|
|
* ioctl, for use by drm_ioctl().
|
|
|
|
*/
|
2011-06-24 12:45:58 +02:00
|
|
|
|
|
|
|
#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \
|
2013-07-02 18:05:26 +02:00
|
|
|
[DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl, .name = #ioctl}
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
#if 0
|
2010-02-12 21:11:35 +01:00
|
|
|
struct drm_magic_entry {
|
|
|
|
struct list_head head;
|
|
|
|
struct drm_hash_item hash_item;
|
|
|
|
struct drm_file *priv;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct drm_vma_entry {
|
|
|
|
struct list_head head;
|
|
|
|
struct vm_area_struct *vma;
|
|
|
|
pid_t pid;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DMA buffer.
|
|
|
|
*/
|
|
|
|
struct drm_buf {
|
|
|
|
int idx; /**< Index into master buflist */
|
|
|
|
int total; /**< Buffer size */
|
|
|
|
int order; /**< log-base-2(total) */
|
|
|
|
int used; /**< Amount of buffer in use (for DMA) */
|
|
|
|
unsigned long offset; /**< Byte offset (used internally) */
|
|
|
|
void *address; /**< Address of buffer */
|
|
|
|
unsigned long bus_address; /**< Bus address of buffer */
|
|
|
|
struct drm_buf *next; /**< Kernel-only: used for free list */
|
|
|
|
__volatile__ int waiting; /**< On kernel DMA queue */
|
|
|
|
__volatile__ int pending; /**< On hardware DMA queue */
|
|
|
|
struct drm_file *file_priv; /**< Private of holding file descr */
|
|
|
|
int context; /**< Kernel queue for this buffer */
|
|
|
|
int while_locked; /**< Dispatch this buffer while locked */
|
|
|
|
enum {
|
|
|
|
DRM_LIST_NONE = 0,
|
|
|
|
DRM_LIST_FREE = 1,
|
|
|
|
DRM_LIST_WAIT = 2,
|
|
|
|
DRM_LIST_PEND = 3,
|
|
|
|
DRM_LIST_PRIO = 4,
|
|
|
|
DRM_LIST_RECLAIM = 5
|
|
|
|
} list; /**< Which list we're on */
|
|
|
|
|
|
|
|
int dev_priv_size; /**< Size of buffer private storage */
|
|
|
|
void *dev_private; /**< Per-buffer private storage */
|
|
|
|
};
|
|
|
|
|
|
|
|
/** bufs is one longer than it has to be */
|
|
|
|
struct drm_waitlist {
|
|
|
|
int count; /**< Number of possible buffers */
|
|
|
|
struct drm_buf **bufs; /**< List of pointers to buffers */
|
|
|
|
struct drm_buf **rp; /**< Read pointer */
|
|
|
|
struct drm_buf **wp; /**< Write pointer */
|
|
|
|
struct drm_buf **end; /**< End pointer */
|
|
|
|
spinlock_t read_lock;
|
|
|
|
spinlock_t write_lock;
|
|
|
|
};
|
2013-10-21 01:07:47 +02:00
|
|
|
#endif
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct drm_dma_handle {
|
|
|
|
dma_addr_t busaddr;
|
|
|
|
void *vaddr;
|
|
|
|
size_t size;
|
|
|
|
} drm_dma_handle_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Buffer entry. There is one of this for each buffer size order.
|
|
|
|
*/
|
|
|
|
struct drm_buf_entry {
|
|
|
|
int buf_size; /**< size */
|
|
|
|
int buf_count; /**< number of buffers */
|
|
|
|
struct drm_buf *buflist; /**< buffer list */
|
|
|
|
int seg_count;
|
|
|
|
int page_order;
|
|
|
|
struct drm_dma_handle **seglist;
|
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
int low_mark; /**< Low water mark */
|
|
|
|
int high_mark; /**< High water mark */
|
2010-02-12 21:11:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Event queued up for userspace to read */
|
|
|
|
struct drm_pending_event {
|
|
|
|
struct drm_event *event;
|
|
|
|
struct list_head link;
|
|
|
|
struct drm_file *file_priv;
|
2011-06-24 12:45:58 +02:00
|
|
|
pid_t pid; /* pid of requester, no guarantee it's valid by the time
|
|
|
|
we deliver the event, for tracing only */
|
2010-02-12 21:11:35 +01:00
|
|
|
void (*destroy)(struct drm_pending_event *event);
|
|
|
|
};
|
|
|
|
|
2012-11-12 22:22:52 +01:00
|
|
|
/* initial implementaton using a linked list - todo hashtab */
|
|
|
|
struct drm_prime_file_private {
|
|
|
|
struct list_head head;
|
|
|
|
struct mutex lock;
|
|
|
|
};
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
/** File private data */
|
|
|
|
struct drm_file {
|
2014-02-06 07:52:49 +01:00
|
|
|
unsigned authenticated :1;
|
2014-08-23 12:29:27 +02:00
|
|
|
/* Whether we're master for a minor. Protected by master_mutex */
|
|
|
|
unsigned is_master :1;
|
2014-02-06 07:52:49 +01:00
|
|
|
/* true when the client has asked us to expose stereo 3D mode flags */
|
|
|
|
unsigned stereo_allowed :1;
|
2014-08-23 12:29:27 +02:00
|
|
|
/*
|
|
|
|
* true if client understands CRTC primary planes and cursor planes
|
|
|
|
* in the plane list
|
|
|
|
*/
|
|
|
|
unsigned universal_planes:1;
|
2010-02-12 21:11:35 +01:00
|
|
|
struct list_head lhead;
|
|
|
|
unsigned long lock_count;
|
|
|
|
|
|
|
|
/** Mapping of mm object handles to object pointers. */
|
|
|
|
struct idr object_idr;
|
|
|
|
/** Lock for synchronization of access to object_idr. */
|
|
|
|
spinlock_t table_lock;
|
|
|
|
|
|
|
|
void *driver_priv;
|
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
struct drm_master *master; /* master this node is currently associated with
|
|
|
|
N.B. not always minor->master */
|
|
|
|
/**
|
|
|
|
* fbs - List of framebuffers associated with this file.
|
|
|
|
*
|
|
|
|
* Protected by fbs_lock. Note that the fbs list holds a reference on
|
|
|
|
* the fb object to prevent it from untimely disappearing.
|
|
|
|
*/
|
2010-02-12 21:11:35 +01:00
|
|
|
struct list_head fbs;
|
2014-08-23 12:29:27 +02:00
|
|
|
struct mutex fbs_lock;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
wait_queue_head_t event_wait;
|
|
|
|
struct list_head event_list;
|
|
|
|
int event_space;
|
|
|
|
};
|
|
|
|
|
2013-02-18 15:33:08 +01:00
|
|
|
#if 0
|
2010-02-12 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* Lock data.
|
|
|
|
*/
|
|
|
|
struct drm_lock_data {
|
|
|
|
struct drm_hw_lock *hw_lock; /**< Hardware lock */
|
|
|
|
/** Private of lock holder's file (NULL=kernel) */
|
|
|
|
struct drm_file *file_priv;
|
|
|
|
wait_queue_head_t lock_queue; /**< Queue of blocked processes */
|
|
|
|
unsigned long lock_time; /**< Time of last lock in jiffies */
|
|
|
|
spinlock_t spinlock;
|
|
|
|
uint32_t kernel_waiters;
|
|
|
|
uint32_t user_waiters;
|
|
|
|
int idle_has_lock;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DMA data.
|
|
|
|
*/
|
|
|
|
struct drm_device_dma {
|
|
|
|
|
|
|
|
struct drm_buf_entry bufs[DRM_MAX_ORDER + 1]; /**< buffers, grouped by their size order */
|
|
|
|
int buf_count; /**< total number of buffers */
|
|
|
|
struct drm_buf **buflist; /**< Vector of pointers into drm_device_dma::bufs */
|
|
|
|
int seg_count;
|
|
|
|
int page_count; /**< number of pages */
|
|
|
|
unsigned long *pagelist; /**< page list */
|
|
|
|
unsigned long byte_count;
|
|
|
|
enum {
|
|
|
|
_DRM_DMA_USE_AGP = 0x01,
|
|
|
|
_DRM_DMA_USE_SG = 0x02,
|
|
|
|
_DRM_DMA_USE_FB = 0x04,
|
|
|
|
_DRM_DMA_USE_PCI_RO = 0x08
|
|
|
|
} flags;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AGP memory entry. Stored as a doubly linked list.
|
|
|
|
*/
|
|
|
|
struct drm_agp_mem {
|
|
|
|
unsigned long handle; /**< handle */
|
2014-02-06 07:52:49 +01:00
|
|
|
struct agp_memory *memory;
|
2010-02-12 21:11:35 +01:00
|
|
|
unsigned long bound; /**< address */
|
|
|
|
int pages;
|
|
|
|
struct list_head head;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AGP data.
|
|
|
|
*
|
|
|
|
* \sa drm_agp_init() and drm_device::agp.
|
|
|
|
*/
|
|
|
|
struct drm_agp_head {
|
2014-02-06 07:52:49 +01:00
|
|
|
struct agp_kern_info agp_info; /**< AGP device information */
|
2010-02-12 21:11:35 +01:00
|
|
|
struct list_head memory;
|
|
|
|
unsigned long mode; /**< AGP mode */
|
|
|
|
struct agp_bridge_data *bridge;
|
|
|
|
int enabled; /**< whether the AGP bus as been enabled */
|
|
|
|
int acquired; /**< whether the AGP device has been acquired */
|
|
|
|
unsigned long base;
|
|
|
|
int agp_mtrr;
|
|
|
|
int cant_use_aperture;
|
|
|
|
unsigned long page_mask;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scatter-gather memory.
|
|
|
|
*/
|
|
|
|
struct drm_sg_mem {
|
|
|
|
unsigned long handle;
|
|
|
|
void *virtual;
|
|
|
|
int pages;
|
|
|
|
struct page **pagelist;
|
|
|
|
dma_addr_t *busaddr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct drm_sigdata {
|
|
|
|
int context;
|
|
|
|
struct drm_hw_lock *lock;
|
|
|
|
};
|
|
|
|
|
2012-09-04 23:42:08 +02:00
|
|
|
#endif
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* Kernel side of a mapping
|
|
|
|
*/
|
|
|
|
struct drm_local_map {
|
|
|
|
resource_size_t offset; /**< Requested physical address (0 for SAREA)*/
|
|
|
|
unsigned long size; /**< Requested physical size (bytes) */
|
|
|
|
enum drm_map_type type; /**< Type of memory to map */
|
|
|
|
enum drm_map_flags flags; /**< Flags */
|
|
|
|
void *handle; /**< User-space: "Handle" to pass to mmap() */
|
|
|
|
/**< Kernel-space: kernel-virtual address */
|
|
|
|
int mtrr; /**< MTRR slot used */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct drm_local_map drm_local_map_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mappings list
|
|
|
|
*/
|
|
|
|
struct drm_map_list {
|
|
|
|
struct list_head head; /**< list head */
|
|
|
|
struct drm_hash_item hash;
|
|
|
|
struct drm_local_map *map; /**< mapping */
|
|
|
|
uint64_t user_token;
|
|
|
|
struct drm_master *master;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* location of GART table */
|
|
|
|
#define DRM_ATI_GART_MAIN 1
|
|
|
|
#define DRM_ATI_GART_FB 2
|
|
|
|
|
|
|
|
#define DRM_ATI_GART_PCI 1
|
|
|
|
#define DRM_ATI_GART_PCIE 2
|
|
|
|
#define DRM_ATI_GART_IGP 3
|
|
|
|
|
|
|
|
struct drm_ati_pcigart_info {
|
|
|
|
int gart_table_location;
|
|
|
|
int gart_reg_if;
|
|
|
|
void *addr;
|
|
|
|
dma_addr_t bus_addr;
|
|
|
|
dma_addr_t table_mask;
|
|
|
|
struct drm_dma_handle *table_handle;
|
|
|
|
struct drm_local_map mapping;
|
|
|
|
int table_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This structure defines the drm_mm memory object, which will be used by the
|
|
|
|
* DRM for its buffer objects.
|
|
|
|
*/
|
|
|
|
struct drm_gem_object {
|
|
|
|
/** Reference count of this object */
|
|
|
|
struct kref refcount;
|
|
|
|
|
2013-10-26 15:31:36 +02:00
|
|
|
/**
|
|
|
|
* handle_count - gem file_priv handle count of this object
|
|
|
|
*
|
|
|
|
* Each handle also holds a reference. Note that when the handle_count
|
|
|
|
* drops to 0 any global names (e.g. the id in the flink namespace) will
|
|
|
|
* be cleared.
|
|
|
|
*
|
|
|
|
* Protected by dev->object_name_lock.
|
|
|
|
* */
|
|
|
|
unsigned handle_count;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/** Related drm device */
|
|
|
|
struct drm_device *dev;
|
|
|
|
|
|
|
|
/** File representing the shmem storage */
|
|
|
|
struct file *filp;
|
|
|
|
|
|
|
|
/* Mapping info for this object */
|
2013-10-26 15:31:36 +02:00
|
|
|
struct drm_vma_offset_node vma_node;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Size of the object, in bytes. Immutable over the object's
|
|
|
|
* lifetime.
|
|
|
|
*/
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Global name for this object, starts at 1. 0 means unnamed.
|
|
|
|
* Access is covered by the object_name_lock in the related drm_device
|
|
|
|
*/
|
|
|
|
int name;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Memory domains. These monitor which caches contain read/write data
|
|
|
|
* related to the object. When transitioning from one set of domains
|
|
|
|
* to another, the driver is called to ensure that caches are suitably
|
|
|
|
* flushed and invalidated
|
|
|
|
*/
|
|
|
|
uint32_t read_domains;
|
|
|
|
uint32_t write_domain;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* While validating an exec operation, the
|
|
|
|
* new read/write domain values are computed here.
|
|
|
|
* They will be transferred to the above values
|
|
|
|
* at the point that any cache flushing occurs
|
|
|
|
*/
|
|
|
|
uint32_t pending_read_domains;
|
|
|
|
uint32_t pending_write_domain;
|
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
/**
|
|
|
|
* dma_buf - dma buf associated with this GEM object
|
|
|
|
*
|
|
|
|
* Pointer to the dma-buf associated with this gem object (either
|
|
|
|
* through importing or exporting). We break the resulting reference
|
|
|
|
* loop when the last gem handle for this object is released.
|
|
|
|
*
|
|
|
|
* Protected by obj->object_name_lock
|
|
|
|
*/
|
|
|
|
struct dma_buf *dma_buf;
|
2014-02-06 07:52:49 +01:00
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
};
|
|
|
|
|
2012-11-12 22:22:52 +01:00
|
|
|
#include <drm/drm_crtc.h>
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
/**
|
|
|
|
* struct drm_master - drm master structure
|
|
|
|
*
|
|
|
|
* @refcount: Refcount for this master object.
|
|
|
|
* @minor: Link back to minor char device we are master for. Immutable.
|
|
|
|
* @unique: Unique identifier: e.g. busid. Protected by drm_global_mutex.
|
|
|
|
* @unique_len: Length of unique field. Protected by drm_global_mutex.
|
|
|
|
* @unique_size: Amount allocated. Protected by drm_global_mutex.
|
|
|
|
* @magiclist: Hash of used authentication tokens. Protected by struct_mutex.
|
|
|
|
* @magicfree: List of used authentication tokens. Protected by struct_mutex.
|
|
|
|
* @lock: DRI lock information.
|
|
|
|
* @driver_priv: Pointer to driver-private information.
|
|
|
|
*/
|
2010-02-12 21:11:35 +01:00
|
|
|
struct drm_master {
|
2014-08-23 12:29:27 +02:00
|
|
|
struct kref refcount;
|
|
|
|
struct drm_minor *minor;
|
|
|
|
char *unique;
|
|
|
|
int unique_len;
|
|
|
|
int unique_size;
|
|
|
|
// struct drm_open_hash magiclist;
|
|
|
|
// struct list_head magicfree;
|
|
|
|
// struct drm_lock_data lock;
|
|
|
|
void *driver_priv;
|
2010-02-12 21:11:35 +01:00
|
|
|
};
|
|
|
|
|
2011-06-24 12:45:58 +02:00
|
|
|
/* Size of ringbuffer for vblank timestamps. Just double-buffer
|
|
|
|
* in initial implementation.
|
|
|
|
*/
|
|
|
|
#define DRM_VBLANKTIME_RBSIZE 2
|
|
|
|
|
|
|
|
/* Flags and return codes for get_vblank_timestamp() driver function. */
|
|
|
|
#define DRM_CALLED_FROM_VBLIRQ 1
|
|
|
|
#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
|
|
|
|
#define DRM_VBLANKTIME_INVBL (1 << 1)
|
|
|
|
|
|
|
|
/* get_scanout_position() return flags */
|
|
|
|
#define DRM_SCANOUTPOS_VALID (1 << 0)
|
|
|
|
#define DRM_SCANOUTPOS_INVBL (1 << 1)
|
|
|
|
#define DRM_SCANOUTPOS_ACCURATE (1 << 2)
|
|
|
|
|
|
|
|
struct drm_bus {
|
|
|
|
int (*set_busid)(struct drm_device *dev, struct drm_master *master);
|
|
|
|
};
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
/**
|
|
|
|
* DRM driver structure. This structure represent the common code for
|
|
|
|
* a family of cards. There will one drm_device for each card present
|
|
|
|
* in this family
|
|
|
|
*/
|
|
|
|
struct drm_driver {
|
|
|
|
int (*load) (struct drm_device *, unsigned long flags);
|
|
|
|
int (*open) (struct drm_device *, struct drm_file *);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get_vblank_counter - get raw hardware vblank counter
|
|
|
|
* @dev: DRM device
|
|
|
|
* @crtc: counter to fetch
|
|
|
|
*
|
2012-11-12 22:22:52 +01:00
|
|
|
* Driver callback for fetching a raw hardware vblank counter for @crtc.
|
|
|
|
* If a device doesn't have a hardware counter, the driver can simply
|
|
|
|
* return the value of drm_vblank_count. The DRM core will account for
|
|
|
|
* missed vblank events while interrupts where disabled based on system
|
|
|
|
* timestamps.
|
2010-02-12 21:11:35 +01:00
|
|
|
*
|
|
|
|
* Wraparound handling and loss of events due to modesetting is dealt
|
|
|
|
* with in the DRM core code.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Raw vblank counter value.
|
|
|
|
*/
|
|
|
|
u32 (*get_vblank_counter) (struct drm_device *dev, int crtc);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* enable_vblank - enable vblank interrupt events
|
|
|
|
* @dev: DRM device
|
|
|
|
* @crtc: which irq to enable
|
|
|
|
*
|
|
|
|
* Enable vblank interrupts for @crtc. If the device doesn't have
|
|
|
|
* a hardware vblank counter, this routine should be a no-op, since
|
|
|
|
* interrupts will have to stay on to keep the count accurate.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Zero on success, appropriate errno if the given @crtc's vblank
|
|
|
|
* interrupt cannot be enabled.
|
|
|
|
*/
|
|
|
|
int (*enable_vblank) (struct drm_device *dev, int crtc);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* disable_vblank - disable vblank interrupt events
|
|
|
|
* @dev: DRM device
|
|
|
|
* @crtc: which irq to enable
|
|
|
|
*
|
|
|
|
* Disable vblank interrupts for @crtc. If the device doesn't have
|
|
|
|
* a hardware vblank counter, this routine should be a no-op, since
|
|
|
|
* interrupts will have to stay on to keep the count accurate.
|
|
|
|
*/
|
|
|
|
void (*disable_vblank) (struct drm_device *dev, int crtc);
|
2011-06-24 12:45:58 +02:00
|
|
|
/**
|
|
|
|
* Called by vblank timestamping code.
|
|
|
|
*
|
2014-02-06 07:52:49 +01:00
|
|
|
* Return the current display scanout position from a crtc, and an
|
|
|
|
* optional accurate ktime_get timestamp of when position was measured.
|
2011-06-24 12:45:58 +02:00
|
|
|
*
|
|
|
|
* \param dev DRM device.
|
|
|
|
* \param crtc Id of the crtc to query.
|
2014-02-06 07:52:49 +01:00
|
|
|
* \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
|
2011-06-24 12:45:58 +02:00
|
|
|
* \param *vpos Target location for current vertical scanout position.
|
|
|
|
* \param *hpos Target location for current horizontal scanout position.
|
2014-02-06 07:52:49 +01:00
|
|
|
* \param *stime Target location for timestamp taken immediately before
|
|
|
|
* scanout position query. Can be NULL to skip timestamp.
|
|
|
|
* \param *etime Target location for timestamp taken immediately after
|
|
|
|
* scanout position query. Can be NULL to skip timestamp.
|
2011-06-24 12:45:58 +02:00
|
|
|
*
|
|
|
|
* Returns vpos as a positive number while in active scanout area.
|
|
|
|
* Returns vpos as a negative number inside vblank, counting the number
|
|
|
|
* of scanlines to go until end of vblank, e.g., -1 means "one scanline
|
|
|
|
* until start of active scanout / end of vblank."
|
|
|
|
*
|
|
|
|
* \return Flags, or'ed together as follows:
|
|
|
|
*
|
|
|
|
* DRM_SCANOUTPOS_VALID = Query successful.
|
|
|
|
* DRM_SCANOUTPOS_INVBL = Inside vblank.
|
|
|
|
* DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
|
|
|
|
* this flag means that returned position may be offset by a constant
|
|
|
|
* but unknown small number of scanlines wrt. real scanout position.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int (*get_scanout_position) (struct drm_device *dev, int crtc,
|
2014-02-06 07:52:49 +01:00
|
|
|
unsigned int flags,
|
|
|
|
int *vpos, int *hpos, void *stime,
|
|
|
|
void *etime);
|
2011-06-24 12:45:58 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by \c drm_get_last_vbltimestamp. Should return a precise
|
|
|
|
* timestamp when the most recent VBLANK interval ended or will end.
|
|
|
|
*
|
|
|
|
* Specifically, the timestamp in @vblank_time should correspond as
|
|
|
|
* closely as possible to the time when the first video scanline of
|
|
|
|
* the video frame after the end of VBLANK will start scanning out,
|
2012-09-04 23:42:08 +02:00
|
|
|
* the time immediately after end of the VBLANK interval. If the
|
2011-06-24 12:45:58 +02:00
|
|
|
* @crtc is currently inside VBLANK, this will be a time in the future.
|
|
|
|
* If the @crtc is currently scanning out a frame, this will be the
|
|
|
|
* past start time of the current scanout. This is meant to adhere
|
|
|
|
* to the OpenML OML_sync_control extension specification.
|
|
|
|
*
|
|
|
|
* \param dev dev DRM device handle.
|
|
|
|
* \param crtc crtc for which timestamp should be returned.
|
|
|
|
* \param *max_error Maximum allowable timestamp error in nanoseconds.
|
|
|
|
* Implementation should strive to provide timestamp
|
|
|
|
* with an error of at most *max_error nanoseconds.
|
|
|
|
* Returns true upper bound on error for timestamp.
|
|
|
|
* \param *vblank_time Target location for returned vblank timestamp.
|
|
|
|
* \param flags 0 = Defaults, no special treatment needed.
|
|
|
|
* \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
|
|
|
|
* irq handler. Some drivers need to apply some workarounds
|
|
|
|
* for gpu-specific vblank irq quirks if flag is set.
|
|
|
|
*
|
|
|
|
* \returns
|
|
|
|
* Zero if timestamping isn't supported in current display mode or a
|
|
|
|
* negative number on failure. A positive status code on success,
|
|
|
|
* which describes how the vblank_time timestamp was computed.
|
|
|
|
*/
|
|
|
|
int (*get_vblank_timestamp) (struct drm_device *dev, int crtc,
|
|
|
|
int *max_error,
|
|
|
|
struct timeval *vblank_time,
|
|
|
|
unsigned flags);
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
/* these have to be filled in */
|
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
irqreturn_t(*irq_handler) (int irq, void *arg);
|
2010-02-12 21:11:35 +01:00
|
|
|
void (*irq_preinstall) (struct drm_device *dev);
|
|
|
|
int (*irq_postinstall) (struct drm_device *dev);
|
|
|
|
void (*irq_uninstall) (struct drm_device *dev);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Driver-specific constructor for drm_gem_objects, to set up
|
|
|
|
* obj->driver_private.
|
|
|
|
*
|
|
|
|
* Returns 0 on success.
|
|
|
|
*/
|
|
|
|
void (*gem_free_object) (struct drm_gem_object *obj);
|
2012-09-04 23:42:08 +02:00
|
|
|
int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
|
|
|
|
void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
|
2013-04-26 13:01:23 +02:00
|
|
|
u32 driver_features;
|
2014-08-23 12:29:27 +02:00
|
|
|
int dev_priv_size;
|
2013-10-26 15:31:36 +02:00
|
|
|
};
|
2013-02-13 09:23:54 +01:00
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
enum drm_minor_type {
|
|
|
|
DRM_MINOR_LEGACY,
|
|
|
|
DRM_MINOR_CONTROL,
|
|
|
|
DRM_MINOR_RENDER,
|
|
|
|
DRM_MINOR_CNT,
|
|
|
|
};
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Info file list entry. This structure represents a debugfs or proc file to
|
|
|
|
* be created by the drm core
|
|
|
|
*/
|
|
|
|
struct drm_info_list {
|
|
|
|
const char *name; /** file name */
|
2012-09-04 23:42:08 +02:00
|
|
|
// int (*show)(struct seq_file*, void*); /** show callback */
|
2010-02-12 21:11:35 +01:00
|
|
|
u32 driver_features; /**< Required driver features for this entry */
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* debugfs node structure. This structure represents a debugfs file.
|
|
|
|
*/
|
|
|
|
struct drm_info_node {
|
|
|
|
struct list_head list;
|
|
|
|
struct drm_minor *minor;
|
2013-10-21 01:07:47 +02:00
|
|
|
const struct drm_info_list *info_ent;
|
2010-02-12 21:11:35 +01:00
|
|
|
struct dentry *dent;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DRM minor structure. This structure represents a drm minor number.
|
|
|
|
*/
|
|
|
|
struct drm_minor {
|
|
|
|
int index; /**< Minor device number */
|
|
|
|
int type; /**< Control or render */
|
2012-09-04 23:42:08 +02:00
|
|
|
// struct device kdev; /**< Linux device */
|
2010-02-12 21:11:35 +01:00
|
|
|
struct drm_device *dev;
|
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
struct dentry *debugfs_root;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
struct list_head debugfs_list;
|
|
|
|
struct mutex debugfs_lock; /* Protects debugfs_list. */
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
/* currently active master for this node. Protected by master_mutex */
|
|
|
|
struct drm_master *master;
|
|
|
|
struct drm_mode_group mode_group;
|
2011-06-24 12:45:58 +02:00
|
|
|
};
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DRM device structure. This structure represent a complete card that
|
|
|
|
* may contain multiple heads.
|
|
|
|
*/
|
|
|
|
struct drm_device {
|
2014-02-06 07:52:49 +01:00
|
|
|
struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */
|
2010-02-12 21:11:35 +01:00
|
|
|
int if_version; /**< Highest interface version set */
|
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
struct device *dev; /**< Device structure of bus-device */
|
|
|
|
struct drm_driver *driver; /**< DRM driver managing the device */
|
|
|
|
void *dev_private; /**< DRM driver private data */
|
|
|
|
struct drm_minor *primary; /**< Primary node */
|
|
|
|
atomic_t unplugged; /**< Flag whether dev is dead */
|
2010-02-12 21:11:35 +01:00
|
|
|
/** \name Locks */
|
|
|
|
/*@{ */
|
2010-09-28 00:55:59 +02:00
|
|
|
struct mutex struct_mutex; /**< For others */
|
2014-08-23 12:29:27 +02:00
|
|
|
struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */
|
2010-02-12 21:11:35 +01:00
|
|
|
/*@} */
|
|
|
|
|
|
|
|
/** \name Usage Counters */
|
|
|
|
/*@{ */
|
2014-08-23 12:29:27 +02:00
|
|
|
int open_count; /**< Outstanding files open, protected by drm_global_mutex. */
|
|
|
|
spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */
|
2010-02-12 21:11:35 +01:00
|
|
|
int buf_use; /**< Buffers in use -- cannot alloc */
|
|
|
|
atomic_t buf_alloc; /**< Buffer allocation in progress */
|
|
|
|
/*@} */
|
|
|
|
|
|
|
|
struct list_head filelist;
|
|
|
|
|
|
|
|
/** \name Memory management */
|
|
|
|
/*@{ */
|
|
|
|
struct list_head maplist; /**< Linked list of regions */
|
|
|
|
|
|
|
|
/** \name Context handle management */
|
|
|
|
/*@{ */
|
|
|
|
struct list_head ctxlist; /**< Linked list of context handles */
|
2010-09-28 00:55:59 +02:00
|
|
|
struct mutex ctxlist_mutex; /**< For ctxlist */
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2011-06-24 12:45:58 +02:00
|
|
|
struct idr ctx_idr;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
struct list_head vmalist; /**< List of vmas (for debugging) */
|
|
|
|
|
|
|
|
/*@} */
|
|
|
|
|
2012-11-12 22:22:52 +01:00
|
|
|
/** \name DMA support */
|
2010-02-12 21:11:35 +01:00
|
|
|
/*@{ */
|
|
|
|
// struct drm_device_dma *dma; /**< Optional pointer for DMA support */
|
|
|
|
/*@} */
|
|
|
|
|
|
|
|
/** \name Context support */
|
|
|
|
/*@{ */
|
2014-02-06 07:52:49 +01:00
|
|
|
bool irq_enabled; /**< True if irq handler is enabled */
|
2014-08-23 12:29:27 +02:00
|
|
|
int irq;
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
__volatile__ long context_flag; /**< Context swapping flag */
|
|
|
|
int last_context; /**< Last current context */
|
|
|
|
/*@} */
|
|
|
|
|
|
|
|
/** \name VBLANK IRQ support */
|
|
|
|
/*@{ */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* At load time, disabling the vblank interrupt won't be allowed since
|
|
|
|
* old clients may not call the modeset ioctl and therefore misbehave.
|
|
|
|
* Once the modeset ioctl *has* been called though, we can safely
|
|
|
|
* disable them when unused.
|
|
|
|
*/
|
2014-02-06 07:52:49 +01:00
|
|
|
bool vblank_disable_allowed;
|
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
/* array of size num_crtcs */
|
|
|
|
struct drm_vblank_crtc *vblank;
|
|
|
|
|
|
|
|
spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
|
|
|
|
spinlock_t vbl_lock;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
u32 max_vblank_count; /**< size of vblank counter register */
|
|
|
|
|
2011-06-24 12:45:58 +02:00
|
|
|
/**
|
|
|
|
* List of events
|
|
|
|
*/
|
|
|
|
struct list_head vblank_event_list;
|
|
|
|
spinlock_t event_lock;
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
/*@} */
|
|
|
|
|
|
|
|
// struct drm_agp_head *agp; /**< AGP data */
|
|
|
|
|
|
|
|
struct pci_dev *pdev; /**< PCI device structure */
|
2014-08-23 12:29:27 +02:00
|
|
|
|
2011-06-24 12:45:58 +02:00
|
|
|
unsigned int num_crtcs; /**< Number of CRTCs on this device */
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
struct drm_mode_config mode_config; /**< Current mode config */
|
|
|
|
|
|
|
|
/** \name GEM information */
|
|
|
|
/*@{ */
|
2013-10-26 15:31:36 +02:00
|
|
|
struct mutex object_name_lock;
|
2011-06-24 12:45:58 +02:00
|
|
|
struct idr object_name_idr;
|
2014-02-06 07:52:49 +01:00
|
|
|
struct drm_vma_offset_manager *vma_offset_manager;
|
2010-02-12 21:11:35 +01:00
|
|
|
/*@} */
|
2011-06-24 12:45:58 +02:00
|
|
|
int switch_power_state;
|
2010-02-12 21:11:35 +01:00
|
|
|
};
|
|
|
|
|
2011-06-24 12:45:58 +02:00
|
|
|
#define DRM_SWITCH_POWER_ON 0
|
|
|
|
#define DRM_SWITCH_POWER_OFF 1
|
|
|
|
#define DRM_SWITCH_POWER_CHANGING 2
|
2013-10-26 15:31:36 +02:00
|
|
|
#define DRM_SWITCH_POWER_DYNAMIC_OFF 3
|
2011-06-24 12:45:58 +02:00
|
|
|
|
2013-04-26 13:01:23 +02:00
|
|
|
static __inline__ int drm_core_check_feature(struct drm_device *dev,
|
|
|
|
int feature)
|
|
|
|
{
|
|
|
|
return ((dev->driver->driver_features & feature) ? 1 : 0);
|
|
|
|
}
|
2011-06-24 12:45:58 +02:00
|
|
|
|
2013-10-21 01:07:47 +02:00
|
|
|
static inline void drm_device_set_unplugged(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
smp_wmb();
|
|
|
|
atomic_set(&dev->unplugged, 1);
|
|
|
|
}
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2013-10-21 01:07:47 +02:00
|
|
|
static inline int drm_device_is_unplugged(struct drm_device *dev)
|
2010-02-12 21:11:35 +01:00
|
|
|
{
|
2013-10-21 01:07:47 +02:00
|
|
|
int ret = atomic_read(&dev->unplugged);
|
|
|
|
smp_rmb();
|
|
|
|
return ret;
|
2010-02-12 21:11:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************/
|
|
|
|
/** \name Internal function definitions */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
/* Driver support (drm_drv.h) */
|
|
|
|
extern long drm_ioctl(struct file *filp,
|
|
|
|
unsigned int cmd, unsigned long arg);
|
|
|
|
extern long drm_compat_ioctl(struct file *filp,
|
|
|
|
unsigned int cmd, unsigned long arg);
|
|
|
|
extern int drm_lastclose(struct drm_device *dev);
|
2014-08-23 12:29:27 +02:00
|
|
|
extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/* Device support (drm_fops.h) */
|
2011-06-24 12:45:58 +02:00
|
|
|
extern struct mutex drm_global_mutex;
|
2010-02-12 21:11:35 +01:00
|
|
|
extern int drm_open(struct inode *inode, struct file *filp);
|
|
|
|
extern ssize_t drm_read(struct file *filp, char __user *buffer,
|
|
|
|
size_t count, loff_t *offset);
|
|
|
|
extern int drm_release(struct inode *inode, struct file *filp);
|
|
|
|
|
|
|
|
/* Mapping support (drm_vm.h) */
|
|
|
|
extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
|
|
|
|
extern int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma);
|
2012-11-12 22:22:52 +01:00
|
|
|
extern void drm_vm_open_locked(struct drm_device *dev, struct vm_area_struct *vma);
|
|
|
|
extern void drm_vm_close_locked(struct drm_device *dev, struct vm_area_struct *vma);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
|
|
|
|
|
|
|
|
/* Memory management support (drm_memory.h) */
|
2012-11-12 22:22:52 +01:00
|
|
|
#include <drm/drm_memory.h>
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2014-02-06 07:52:49 +01:00
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
/* Misc. IOCTL support (drm_ioctl.h) */
|
|
|
|
extern int drm_irq_by_busid(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_getunique(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_setunique(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_getmap(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_getclient(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_getstats(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
2011-06-24 12:45:58 +02:00
|
|
|
extern int drm_getcap(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
2014-02-06 07:52:49 +01:00
|
|
|
extern int drm_setclientcap(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern int drm_setversion(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_noop(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
|
|
|
|
/* Authentication IOCTL support (drm_auth.h) */
|
|
|
|
extern int drm_getmagic(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_authmagic(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
2012-09-04 23:42:08 +02:00
|
|
|
extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/* Cache management (drm_cache.c) */
|
|
|
|
void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
|
2012-11-12 22:22:52 +01:00
|
|
|
void drm_clflush_sg(struct sg_table *st);
|
2014-08-23 12:29:27 +02:00
|
|
|
void drm_clflush_virt_range(void *addr, unsigned long length);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/* Locking IOCTL support (drm_lock.h) */
|
|
|
|
extern int drm_lock(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_unlock(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context);
|
|
|
|
extern void drm_idlelock_take(struct drm_lock_data *lock_data);
|
|
|
|
extern void drm_idlelock_release(struct drm_lock_data *lock_data);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These are exported to drivers so that they can implement fencing using
|
|
|
|
* DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv);
|
|
|
|
|
|
|
|
/* Buffer management support (drm_bufs.h) */
|
|
|
|
extern int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc * request);
|
|
|
|
extern int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc * request);
|
|
|
|
extern int drm_addmap(struct drm_device *dev, resource_size_t offset,
|
|
|
|
unsigned int size, enum drm_map_type type,
|
|
|
|
enum drm_map_flags flags, struct drm_local_map **map_ptr);
|
|
|
|
extern int drm_addmap_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_rmmap(struct drm_device *dev, struct drm_local_map *map);
|
|
|
|
extern int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map);
|
|
|
|
extern int drm_rmmap_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_addbufs(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_infobufs(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_markbufs(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_freebufs(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_mapbufs(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
2013-11-22 15:32:23 +01:00
|
|
|
extern int drm_dma_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/* DMA support (drm_dma.h) */
|
2013-10-26 15:31:36 +02:00
|
|
|
extern int drm_legacy_dma_setup(struct drm_device *dev);
|
|
|
|
extern void drm_legacy_dma_takedown(struct drm_device *dev);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern void drm_free_buffer(struct drm_device *dev, struct drm_buf * buf);
|
|
|
|
extern void drm_core_reclaim_buffers(struct drm_device *dev,
|
|
|
|
struct drm_file *filp);
|
|
|
|
|
|
|
|
/* IRQ support (drm_irq.h) */
|
|
|
|
extern int drm_control(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
2014-08-23 12:29:27 +02:00
|
|
|
extern int drm_irq_install(struct drm_device *dev, int irq);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern int drm_irq_uninstall(struct drm_device *dev);
|
|
|
|
|
|
|
|
extern int drm_vblank_init(struct drm_device *dev, int num_crtcs);
|
|
|
|
extern int drm_wait_vblank(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *filp);
|
|
|
|
extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
|
2011-06-24 12:45:58 +02:00
|
|
|
extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
|
|
|
|
struct timeval *vblanktime);
|
2013-03-19 07:14:59 +01:00
|
|
|
extern void drm_send_vblank_event(struct drm_device *dev, int crtc,
|
|
|
|
struct drm_pending_vblank_event *e);
|
2011-06-24 12:45:58 +02:00
|
|
|
extern bool drm_handle_vblank(struct drm_device *dev, int crtc);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern int drm_vblank_get(struct drm_device *dev, int crtc);
|
|
|
|
extern void drm_vblank_put(struct drm_device *dev, int crtc);
|
2014-08-23 12:29:27 +02:00
|
|
|
extern int drm_crtc_vblank_get(struct drm_crtc *crtc);
|
|
|
|
extern void drm_crtc_vblank_put(struct drm_crtc *crtc);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern void drm_vblank_off(struct drm_device *dev, int crtc);
|
2014-08-23 12:29:27 +02:00
|
|
|
extern void drm_vblank_on(struct drm_device *dev, int crtc);
|
|
|
|
extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
|
|
|
|
extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern void drm_vblank_cleanup(struct drm_device *dev);
|
2014-08-23 12:29:27 +02:00
|
|
|
|
2011-06-24 12:45:58 +02:00
|
|
|
extern u32 drm_get_last_vbltimestamp(struct drm_device *dev, int crtc,
|
|
|
|
struct timeval *tvblank, unsigned flags);
|
|
|
|
extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
|
|
|
|
int crtc, int *max_error,
|
|
|
|
struct timeval *vblank_time,
|
|
|
|
unsigned flags,
|
2014-02-06 07:52:49 +01:00
|
|
|
const struct drm_crtc *refcrtc,
|
|
|
|
const struct drm_display_mode *mode);
|
|
|
|
extern void drm_calc_timestamping_constants(struct drm_crtc *crtc,
|
|
|
|
const struct drm_display_mode *mode);
|
2011-06-24 12:45:58 +02:00
|
|
|
|
2013-03-19 07:14:59 +01:00
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
/* Modesetting support */
|
|
|
|
extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
|
|
|
|
extern void drm_vblank_post_modeset(struct drm_device *dev, int crtc);
|
|
|
|
extern int drm_modeset_ctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
|
|
|
|
/* AGP/GART support (drm_agpsupport.h) */
|
|
|
|
|
|
|
|
/* Stub support (drm_stub.h) */
|
|
|
|
extern int drm_setmaster_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
struct drm_master *drm_master_create(struct drm_minor *minor);
|
|
|
|
extern struct drm_master *drm_master_get(struct drm_master *master);
|
|
|
|
extern void drm_master_put(struct drm_master **master);
|
2011-06-24 12:45:58 +02:00
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
extern void drm_put_dev(struct drm_device *dev);
|
2012-11-12 22:22:52 +01:00
|
|
|
extern void drm_unplug_dev(struct drm_device *dev);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern unsigned int drm_debug;
|
|
|
|
|
2012-11-12 22:22:52 +01:00
|
|
|
#if 0
|
2011-06-24 12:45:58 +02:00
|
|
|
extern unsigned int drm_vblank_offdelay;
|
|
|
|
extern unsigned int drm_timestamp_precision;
|
2013-01-22 16:16:44 +01:00
|
|
|
extern unsigned int drm_timestamp_monotonic;
|
2011-06-24 12:45:58 +02:00
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
extern struct class *drm_class;
|
|
|
|
|
|
|
|
extern struct drm_local_map *drm_getsarea(struct drm_device *dev);
|
2014-08-23 12:29:27 +02:00
|
|
|
#endif
|
2010-02-12 21:11:35 +01:00
|
|
|
/* Debugfs support */
|
|
|
|
#if defined(CONFIG_DEBUG_FS)
|
|
|
|
extern int drm_debugfs_init(struct drm_minor *minor, int minor_id,
|
|
|
|
struct dentry *root);
|
2014-02-06 07:52:49 +01:00
|
|
|
extern int drm_debugfs_create_files(const struct drm_info_list *files,
|
|
|
|
int count, struct dentry *root,
|
2010-02-12 21:11:35 +01:00
|
|
|
struct drm_minor *minor);
|
2014-02-06 07:52:49 +01:00
|
|
|
extern int drm_debugfs_remove_files(const struct drm_info_list *files,
|
|
|
|
int count, struct drm_minor *minor);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern int drm_debugfs_cleanup(struct drm_minor *minor);
|
2014-08-23 12:29:27 +02:00
|
|
|
extern int drm_debugfs_connector_add(struct drm_connector *connector);
|
|
|
|
extern void drm_debugfs_connector_remove(struct drm_connector *connector);
|
2014-02-06 07:52:49 +01:00
|
|
|
#else
|
|
|
|
static inline int drm_debugfs_init(struct drm_minor *minor, int minor_id,
|
|
|
|
struct dentry *root)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int drm_debugfs_create_files(const struct drm_info_list *files,
|
|
|
|
int count, struct dentry *root,
|
|
|
|
struct drm_minor *minor)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
|
|
|
|
int count, struct drm_minor *minor)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int drm_debugfs_cleanup(struct drm_minor *minor)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2014-08-23 12:29:27 +02:00
|
|
|
|
|
|
|
static inline int drm_debugfs_connector_add(struct drm_connector *connector)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void drm_debugfs_connector_remove(struct drm_connector *connector)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Info file support */
|
|
|
|
extern int drm_name_info(struct seq_file *m, void *data);
|
|
|
|
extern int drm_vm_info(struct seq_file *m, void *data);
|
|
|
|
extern int drm_bufs_info(struct seq_file *m, void *data);
|
|
|
|
extern int drm_vblank_info(struct seq_file *m, void *data);
|
|
|
|
extern int drm_clients_info(struct seq_file *m, void* data);
|
|
|
|
extern int drm_gem_name_info(struct seq_file *m, void *data);
|
|
|
|
|
|
|
|
#if DRM_DEBUG_CODE
|
|
|
|
extern int drm_vma_info(struct seq_file *m, void *data);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Scatter Gather Support (drm_scatter.h) */
|
2013-10-26 15:31:36 +02:00
|
|
|
extern void drm_legacy_sg_cleanup(struct drm_device *dev);
|
|
|
|
extern int drm_sg_alloc(struct drm_device *dev, void *data,
|
2010-02-12 21:11:35 +01:00
|
|
|
struct drm_file *file_priv);
|
|
|
|
extern int drm_sg_free(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
|
|
|
|
/* ATI PCIGART support (ati_pcigart.h) */
|
|
|
|
extern int drm_ati_pcigart_init(struct drm_device *dev,
|
|
|
|
struct drm_ati_pcigart_info * gart_info);
|
|
|
|
extern int drm_ati_pcigart_cleanup(struct drm_device *dev,
|
|
|
|
struct drm_ati_pcigart_info * gart_info);
|
|
|
|
|
|
|
|
extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size,
|
2010-03-01 07:55:30 +01:00
|
|
|
size_t align);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
|
|
|
|
extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
|
|
|
|
|
2012-11-12 22:22:52 +01:00
|
|
|
#if 0
|
2010-02-12 21:11:35 +01:00
|
|
|
/* sysfs support (drm_sysfs.c) */
|
|
|
|
struct drm_sysfs_class;
|
|
|
|
extern struct class *drm_sysfs_create(struct module *owner, char *name);
|
|
|
|
extern void drm_sysfs_destroy(void);
|
2014-08-23 12:29:27 +02:00
|
|
|
extern struct device *drm_sysfs_minor_alloc(struct drm_minor *minor);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern void drm_sysfs_hotplug_event(struct drm_device *dev);
|
2013-10-26 15:31:36 +02:00
|
|
|
extern int drm_sysfs_connector_add(struct drm_connector *connector);
|
|
|
|
extern void drm_sysfs_connector_remove(struct drm_connector *connector);
|
2012-09-04 23:42:08 +02:00
|
|
|
#endif
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
/* Graphics Execution Manager library functions (drm_gem.c) */
|
|
|
|
int drm_gem_init(struct drm_device *dev);
|
|
|
|
void drm_gem_destroy(struct drm_device *dev);
|
2011-06-24 12:45:58 +02:00
|
|
|
void drm_gem_object_release(struct drm_gem_object *obj);
|
2010-02-12 21:11:35 +01:00
|
|
|
void drm_gem_object_free(struct kref *kref);
|
2011-06-24 12:45:58 +02:00
|
|
|
int drm_gem_object_init(struct drm_device *dev,
|
|
|
|
struct drm_gem_object *obj, size_t size);
|
2013-10-26 15:31:36 +02:00
|
|
|
void drm_gem_private_object_init(struct drm_device *dev,
|
2012-09-04 23:42:08 +02:00
|
|
|
struct drm_gem_object *obj, size_t size);
|
2010-02-12 21:11:35 +01:00
|
|
|
void drm_gem_vm_open(struct vm_area_struct *vma);
|
|
|
|
void drm_gem_vm_close(struct vm_area_struct *vma);
|
2013-10-26 15:31:36 +02:00
|
|
|
int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
|
|
|
|
struct vm_area_struct *vma);
|
2010-02-12 21:11:35 +01:00
|
|
|
int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
|
|
|
|
|
2013-10-26 15:31:36 +02:00
|
|
|
#include <drm/drm_global.h>
|
2012-09-04 23:42:08 +02:00
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
static inline void
|
|
|
|
drm_gem_object_reference(struct drm_gem_object *obj)
|
|
|
|
{
|
|
|
|
kref_get(&obj->refcount);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
drm_gem_object_unreference(struct drm_gem_object *obj)
|
|
|
|
{
|
2012-09-04 23:42:08 +02:00
|
|
|
if (obj != NULL)
|
|
|
|
kref_put(&obj->refcount, drm_gem_object_free);
|
|
|
|
}
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2012-09-04 23:42:08 +02:00
|
|
|
static inline void
|
|
|
|
drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
|
|
|
|
{
|
2013-10-26 15:31:36 +02:00
|
|
|
if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) {
|
2012-09-04 23:42:08 +02:00
|
|
|
struct drm_device *dev = obj->dev;
|
2013-10-26 15:31:36 +02:00
|
|
|
|
2012-09-04 23:42:08 +02:00
|
|
|
mutex_lock(&dev->struct_mutex);
|
2013-10-26 15:31:36 +02:00
|
|
|
if (likely(atomic_dec_and_test(&obj->refcount.refcount)))
|
|
|
|
drm_gem_object_free(&obj->refcount);
|
2012-09-04 23:42:08 +02:00
|
|
|
mutex_unlock(&dev->struct_mutex);
|
|
|
|
}
|
2010-02-12 21:11:35 +01:00
|
|
|
}
|
|
|
|
|
2013-10-26 15:31:36 +02:00
|
|
|
int drm_gem_handle_create_tail(struct drm_file *file_priv,
|
|
|
|
struct drm_gem_object *obj,
|
|
|
|
u32 *handlep);
|
2010-02-12 21:11:35 +01:00
|
|
|
int drm_gem_handle_create(struct drm_file *file_priv,
|
|
|
|
struct drm_gem_object *obj,
|
|
|
|
u32 *handlep);
|
2011-06-29 08:49:58 +02:00
|
|
|
int drm_gem_handle_delete(struct drm_file *filp, u32 handle);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2012-09-04 23:42:08 +02:00
|
|
|
|
2013-01-22 16:16:44 +01:00
|
|
|
void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
|
|
|
|
int drm_gem_create_mmap_offset(struct drm_gem_object *obj);
|
2013-10-26 15:31:36 +02:00
|
|
|
int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size);
|
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
struct page **drm_gem_get_pages(struct drm_gem_object *obj);
|
2013-10-26 15:31:36 +02:00
|
|
|
void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages,
|
|
|
|
bool dirty, bool accessed);
|
2012-09-04 23:42:08 +02:00
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev,
|
|
|
|
struct drm_file *filp,
|
|
|
|
u32 handle);
|
|
|
|
int drm_gem_close_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
int drm_gem_open_ioctl(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
|
|
|
void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
|
|
|
|
void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
|
|
|
|
|
|
|
|
extern void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev);
|
|
|
|
extern void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev);
|
|
|
|
extern void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev);
|
|
|
|
|
|
|
|
static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev,
|
|
|
|
unsigned int token)
|
|
|
|
{
|
|
|
|
struct drm_map_list *_entry;
|
|
|
|
list_for_each_entry(_entry, &dev->maplist, head)
|
|
|
|
if (_entry->user_token == token)
|
|
|
|
return _entry->map;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ void drm_core_dropmap(struct drm_local_map *map)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
#include <drm/drm_mem_util.h>
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2014-11-16 12:38:35 +01:00
|
|
|
struct drm_device *drm_dev_alloc(struct drm_driver *driver,
|
|
|
|
struct device *parent);
|
|
|
|
void drm_dev_ref(struct drm_device *dev);
|
|
|
|
void drm_dev_unref(struct drm_device *dev);
|
|
|
|
|
2013-10-26 15:31:36 +02:00
|
|
|
extern int drm_fill_in_dev(struct drm_device *dev,
|
|
|
|
const struct pci_device_id *ent,
|
|
|
|
struct drm_driver *driver);
|
|
|
|
int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type);
|
|
|
|
/*@}*/
|
2012-11-12 22:22:52 +01:00
|
|
|
|
2014-11-16 12:38:35 +01:00
|
|
|
/* PCI section */
|
|
|
|
static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
|
|
|
|
return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
|
|
|
|
}
|
|
|
|
void drm_pci_agp_destroy(struct drm_device *dev);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2014-08-23 12:29:27 +02:00
|
|
|
#if 0
|
|
|
|
extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
|
|
|
|
extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
|
2013-10-26 15:31:36 +02:00
|
|
|
extern int drm_get_pci_dev(struct pci_dev *pdev,
|
|
|
|
const struct pci_device_id *ent,
|
|
|
|
struct drm_driver *driver);
|
2014-08-23 12:29:27 +02:00
|
|
|
#endif
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2012-11-12 22:22:52 +01:00
|
|
|
#define DRM_PCIE_SPEED_25 1
|
|
|
|
#define DRM_PCIE_SPEED_50 2
|
|
|
|
#define DRM_PCIE_SPEED_80 4
|
|
|
|
|
|
|
|
extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2012-09-04 23:42:08 +02:00
|
|
|
|
|
|
|
static __inline__ int drm_device_is_pcie(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
|
|
|
|
}
|
2010-02-12 21:11:35 +01:00
|
|
|
#endif /* __KERNEL__ */
|
2012-11-12 22:22:52 +01:00
|
|
|
|
|
|
|
#define drm_sysfs_connector_add(connector)
|
|
|
|
#define drm_sysfs_connector_remove(connector)
|
|
|
|
|
2014-02-06 07:52:49 +01:00
|
|
|
#define LFB_SIZE 0x1000000
|
2013-10-26 15:31:36 +02:00
|
|
|
extern struct drm_device *main_device;
|
|
|
|
extern struct drm_file *drm_file_handlers[256];
|
2013-03-19 07:14:59 +01:00
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
#endif
|