2010-02-12 21:11:35 +01:00
|
|
|
/*
|
2014-12-27 16:42:08 +01:00
|
|
|
* Internal Header for the Direct Rendering Manager
|
|
|
|
*
|
2010-02-12 21:11:35 +01:00
|
|
|
* 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.
|
|
|
|
*
|
2014-12-27 16:42:08 +01:00
|
|
|
* Author: Rickard E. (Rik) Faith <faith@valinux.com>
|
|
|
|
* Author: Gareth Hughes <gareth@valinux.com>
|
|
|
|
*
|
2010-02-12 21:11:35 +01:00
|
|
|
* 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_
|
|
|
|
|
2012-09-04 23:42:08 +02:00
|
|
|
#include <syscall.h>
|
2014-12-27 16:42:08 +01:00
|
|
|
#include <linux/agp_backend.h>
|
2012-09-04 23:42:08 +02:00
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/file.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/idr.h>
|
|
|
|
#include <linux/jiffies.h>
|
2010-02-12 21:11:35 +01:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/kref.h>
|
2014-12-27 16:42:08 +01:00
|
|
|
#include <linux/mm.h>
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
#include <linux/spinlock.h>
|
2014-12-27 16:42:08 +01:00
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/pci.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-08-23 12:29:27 +02:00
|
|
|
|
2013-07-02 18:05:26 +02:00
|
|
|
#include <linux/irqreturn.h>
|
2014-08-23 12:29:27 +02:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/types.h>
|
2014-12-27 16:42:08 +01:00
|
|
|
#include <linux/vmalloc.h>
|
2013-04-26 13:01:23 +02:00
|
|
|
#include <linux/workqueue.h>
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
#include <uapi/drm/drm.h>
|
|
|
|
#include <uapi/drm/drm_mode.h>
|
2013-04-26 13:01:23 +02:00
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
#include <drm/drm_agpsupport.h>
|
|
|
|
#include <drm/drm_crtc.h>
|
|
|
|
#include <drm/drm_global.h>
|
|
|
|
#include <drm/drm_hashtab.h>
|
|
|
|
#include <drm/drm_mem_util.h>
|
|
|
|
#include <drm/drm_mm.h>
|
|
|
|
#include <drm/drm_os_linux.h>
|
|
|
|
#include <drm/drm_sarea.h>
|
2013-10-26 15:31:36 +02:00
|
|
|
#include <drm/drm_vma_manager.h>
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2012-11-12 22:22:52 +01:00
|
|
|
struct module;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
struct drm_file;
|
|
|
|
struct drm_device;
|
2014-12-27 16:42:08 +01:00
|
|
|
struct drm_agp_head;
|
|
|
|
struct drm_local_map;
|
|
|
|
struct drm_device_dma;
|
|
|
|
struct drm_dma_handle;
|
|
|
|
struct drm_gem_object;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2013-03-19 07:14:59 +01:00
|
|
|
struct device_node;
|
|
|
|
struct videomode;
|
2014-08-23 12:29:27 +02:00
|
|
|
struct reservation_object;
|
2014-12-27 16:42:08 +01:00
|
|
|
struct dma_buf_attachment;
|
2013-10-26 15:31:36 +02:00
|
|
|
|
|
|
|
struct inode;
|
|
|
|
struct poll_table_struct;
|
|
|
|
struct sg_table;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
#define KHZ2PICOS(a) (1000000000UL/(a))
|
|
|
|
|
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
|
|
|
*
|
2016-01-20 05:19:53 +01:00
|
|
|
* ATOMIC: used in the atomic code.
|
|
|
|
* This is the category used by the DRM_DEBUG_ATOMIC() macro.
|
|
|
|
*
|
|
|
|
* VBL: used for verbose debug message in the vblank code
|
|
|
|
* This is the category used by the DRM_DEBUG_VBL() macro.
|
|
|
|
*
|
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
|
|
|
|
* ...
|
2016-01-20 05:19:53 +01:00
|
|
|
* drm.debug=0x3f will enable all messages
|
2014-08-23 12:29:27 +02:00
|
|
|
*
|
|
|
|
* 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
|
2016-01-20 05:19:53 +01:00
|
|
|
#define DRM_UT_KMS 0x04
|
2014-08-23 12:29:27 +02:00
|
|
|
#define DRM_UT_PRIME 0x08
|
2016-01-20 05:19:53 +01:00
|
|
|
#define DRM_UT_ATOMIC 0x10
|
|
|
|
#define DRM_UT_VBL 0x20
|
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,
|
2016-01-20 05:19:53 +01:00
|
|
|
const char *format, ...);
|
2014-12-27 16:42:08 +01:00
|
|
|
extern __printf(1, 2)
|
|
|
|
void drm_err(const char *format, ...);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/** \name DRM template customization defaults */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
/* driver capabilities and requirements mask */
|
2016-01-20 05:19:53 +01:00
|
|
|
#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
|
|
|
|
#define DRIVER_PRIME 0x4000
|
|
|
|
#define DRIVER_RENDER 0x8000
|
|
|
|
#define DRIVER_ATOMIC 0x10000
|
|
|
|
#define DRIVER_KMS_LEGACY_CONTEXT 0x20000
|
2012-09-04 23:42:08 +02:00
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
/***********************************************************************/
|
|
|
|
/** \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, ...) \
|
2016-01-20 05:19:53 +01:00
|
|
|
printk("DRM Error" 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)) \
|
2014-12-27 16:42:08 +01:00
|
|
|
drm_err(fmt, ##__VA_ARGS__); \
|
2014-02-06 07:52:49 +01:00
|
|
|
})
|
|
|
|
|
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)
|
2016-01-20 05:19:53 +01:00
|
|
|
#define DRM_DEBUG_ATOMIC(fmt, args...) \
|
|
|
|
do { \
|
|
|
|
printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \
|
|
|
|
} while (0)
|
|
|
|
#define DRM_DEBUG_VBL(fmt, args...) \
|
|
|
|
do { \
|
|
|
|
printk(KERN_INFO "[" DRM_NAME "] " fmt, ##args); \
|
|
|
|
} while (0)
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
#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)
|
2016-01-20 05:19:53 +01:00
|
|
|
#define DRM_DEBUG_ATOMIC(fmt, args...) do { } while (0)
|
|
|
|
#define DRM_DEBUG_VBL(fmt, args...) do { } while (0)
|
2010-02-12 21:11:35 +01:00
|
|
|
#endif
|
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/** \name Internal types and structures */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
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
|
|
|
|
2016-01-20 05:19:53 +01:00
|
|
|
#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \
|
|
|
|
[DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = { \
|
|
|
|
.cmd = DRM_IOCTL_##ioctl, \
|
|
|
|
.func = _func, \
|
|
|
|
.flags = _flags, \
|
|
|
|
.name = #ioctl \
|
|
|
|
}
|
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;
|
2016-01-20 05:19:53 +01:00
|
|
|
/* true if client understands atomic properties */
|
|
|
|
unsigned atomic:1;
|
2010-02-12 21:11:35 +01:00
|
|
|
struct list_head lhead;
|
2016-01-20 05:19:53 +01:00
|
|
|
struct drm_minor *minor;
|
2010-02-12 21:11:35 +01:00
|
|
|
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
|
|
|
|
2016-01-20 05:19:53 +01:00
|
|
|
/** User-created blob properties; this retains a reference on the
|
|
|
|
* property. */
|
|
|
|
struct list_head blobs;
|
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
wait_queue_head_t event_wait;
|
|
|
|
struct list_head event_list;
|
|
|
|
int event_space;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
};
|
|
|
|
|
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.
|
2016-01-20 05:19:53 +01:00
|
|
|
* @magic_map: Map of used authentication tokens. Protected by struct_mutex.
|
2014-08-23 12:29:27 +02:00
|
|
|
* @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;
|
2016-01-20 05:19:53 +01:00
|
|
|
struct idr magic_map;
|
2014-12-27 16:42:08 +01:00
|
|
|
struct drm_lock_data lock;
|
2014-08-23 12:29:27 +02:00
|
|
|
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)
|
2014-12-27 16:42:08 +01:00
|
|
|
#define DRM_VBLANKTIME_IN_VBLANK (1 << 1)
|
2011-06-24 12:45:58 +02:00
|
|
|
|
|
|
|
/* get_scanout_position() return flags */
|
|
|
|
#define DRM_SCANOUTPOS_VALID (1 << 0)
|
2014-12-27 16:42:08 +01:00
|
|
|
#define DRM_SCANOUTPOS_IN_VBLANK (1 << 1)
|
2011-06-24 12:45:58 +02:00
|
|
|
#define DRM_SCANOUTPOS_ACCURATE (1 << 2)
|
|
|
|
|
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
|
2016-01-20 05:19:53 +01:00
|
|
|
* @pipe: counter to fetch
|
2010-02-12 21:11:35 +01:00
|
|
|
*
|
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.
|
|
|
|
*/
|
2016-01-20 05:19:53 +01:00
|
|
|
u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* enable_vblank - enable vblank interrupt events
|
|
|
|
* @dev: DRM device
|
2016-01-20 05:19:53 +01:00
|
|
|
* @pipe: which irq to enable
|
2010-02-12 21:11:35 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-01-20 05:19:53 +01:00
|
|
|
int (*enable_vblank) (struct drm_device *dev, unsigned int pipe);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* disable_vblank - disable vblank interrupt events
|
|
|
|
* @dev: DRM device
|
2016-01-20 05:19:53 +01:00
|
|
|
* @pipe: which irq to enable
|
2010-02-12 21:11:35 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-01-20 05:19:53 +01:00
|
|
|
void (*disable_vblank) (struct drm_device *dev, unsigned int pipe);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by \c drm_device_is_agp. Typically used to determine if a
|
|
|
|
* card is really attached to AGP or not.
|
|
|
|
*
|
|
|
|
* \param dev DRM device handle
|
|
|
|
*
|
|
|
|
* \returns
|
|
|
|
* One of three values is returned depending on whether or not the
|
|
|
|
* card is absolutely \b not AGP (return of 0), absolutely \b is AGP
|
|
|
|
* (return of 1), or may or may not be AGP (return of 2).
|
|
|
|
*/
|
|
|
|
int (*device_is_agp) (struct drm_device *dev);
|
|
|
|
|
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.
|
2016-01-20 05:19:53 +01:00
|
|
|
* \param pipe 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.
|
2016-01-20 05:19:53 +01:00
|
|
|
* \param mode Current display timings.
|
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.
|
|
|
|
*
|
|
|
|
*/
|
2016-01-20 05:19:53 +01:00
|
|
|
int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
|
|
|
|
unsigned int flags, int *vpos, int *hpos,
|
|
|
|
ktime_t *stime, ktime_t *etime,
|
|
|
|
const struct drm_display_mode *mode);
|
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.
|
2016-01-20 05:19:53 +01:00
|
|
|
* \param pipe crtc for which timestamp should be returned.
|
2011-06-24 12:45:58 +02:00
|
|
|
* \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.
|
|
|
|
*/
|
2016-01-20 05:19:53 +01:00
|
|
|
int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
|
2011-06-24 12:45:58 +02:00
|
|
|
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 */
|
2016-01-20 05:19:53 +01: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;
|
2011-06-24 12:45:58 +02:00
|
|
|
};
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
struct drm_pending_vblank_event {
|
|
|
|
struct drm_pending_event base;
|
2016-01-20 05:19:53 +01:00
|
|
|
unsigned int pipe;
|
2014-12-27 16:42:08 +01:00
|
|
|
struct drm_event_vblank event;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct drm_vblank_crtc {
|
|
|
|
struct drm_device *dev; /* pointer to the drm_device */
|
|
|
|
wait_queue_head_t queue; /**< VBLANK wait queue */
|
|
|
|
struct timer_list disable_timer; /* delayed disable timer */
|
2016-01-20 05:19:53 +01:00
|
|
|
|
|
|
|
/* vblank counter, protected by dev->vblank_time_lock for writes */
|
|
|
|
u32 count;
|
|
|
|
/* vblank timestamps, protected by dev->vblank_time_lock for writes */
|
|
|
|
struct timeval time[DRM_VBLANKTIME_RBSIZE];
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
atomic_t refcount; /* number of users of vblank interruptsper crtc */
|
|
|
|
u32 last; /* protected by dev->vbl_lock, used */
|
|
|
|
/* for wraparound handling */
|
|
|
|
u32 last_wait; /* Last vblank seqno waited per CRTC */
|
|
|
|
unsigned int inmodeset; /* Display driver is setting mode */
|
2016-01-20 05:19:53 +01:00
|
|
|
unsigned int pipe; /* crtc index */
|
|
|
|
int framedur_ns; /* frame/field duration in ns */
|
|
|
|
int linedur_ns; /* line duration in ns */
|
2014-12-27 16:42:08 +01:00
|
|
|
bool enabled; /* so we don't call enable more than
|
|
|
|
once per disable */
|
|
|
|
};
|
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-12-27 16:42:08 +01:00
|
|
|
/** \name Lifetime Management */
|
|
|
|
/*@{ */
|
|
|
|
struct kref ref; /**< Object ref-count */
|
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 */
|
2016-01-20 05:19:53 +01:00
|
|
|
struct drm_minor *control; /**< Control node */
|
2014-08-23 12:29:27 +02:00
|
|
|
struct drm_minor *primary; /**< Primary node */
|
2016-01-20 05:19:53 +01:00
|
|
|
struct drm_minor *render; /**< Render node */
|
2014-08-23 12:29:27 +02:00
|
|
|
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 */
|
2016-01-20 05:19:53 +01:00
|
|
|
atomic_t buf_alloc; /**< Buffer allocation in progress */
|
2010-02-12 21:11:35 +01:00
|
|
|
/*@} */
|
|
|
|
|
|
|
|
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-08-23 12:29:27 +02:00
|
|
|
|
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 */
|
|
|
|
/*@{ */
|
2016-01-20 05:19:53 +01:00
|
|
|
bool irq_enabled;
|
|
|
|
int irq;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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-12-27 16:42:08 +01:00
|
|
|
/*
|
|
|
|
* If true, vblank interrupt will be disabled immediately when the
|
|
|
|
* refcount drops to zero, as opposed to via the vblank disable
|
|
|
|
* timer.
|
|
|
|
* This can be set to true it the hardware has a working vblank
|
|
|
|
* counter and the driver uses drm_vblank_on() and drm_vblank_off()
|
|
|
|
* appropriately.
|
|
|
|
*/
|
|
|
|
bool vblank_disable_immediate;
|
|
|
|
|
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
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
struct {
|
|
|
|
int context;
|
|
|
|
struct drm_hw_lock *lock;
|
|
|
|
} sigdata;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2016-01-20 05:19:53 +01:00
|
|
|
struct drm_mode_config mode_config; /**< Current mode config */
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/** \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) */
|
2016-01-20 05:19:53 +01:00
|
|
|
extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern long drm_ioctl(struct file *filp,
|
2016-01-20 05:19:53 +01:00
|
|
|
unsigned int cmd, unsigned long arg);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern long drm_compat_ioctl(struct file *filp,
|
|
|
|
unsigned int cmd, unsigned long arg);
|
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) */
|
|
|
|
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);
|
2016-01-20 05:19:53 +01:00
|
|
|
extern int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/* Mapping support (drm_vm.h) */
|
|
|
|
extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
/* Misc. IOCTL support (drm_ioctl.c) */
|
|
|
|
int drm_noop(struct drm_device *dev, void *data,
|
2016-01-20 05:19:53 +01:00
|
|
|
struct drm_file *file_priv);
|
|
|
|
int drm_invalid_op(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *file_priv);
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* These are exported to drivers so that they can implement fencing using
|
|
|
|
* DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* IRQ support (drm_irq.h) */
|
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);
|
|
|
|
|
2016-01-20 05:19:53 +01:00
|
|
|
extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
|
2010-02-12 21:11:35 +01:00
|
|
|
extern int drm_wait_vblank(struct drm_device *dev, void *data,
|
|
|
|
struct drm_file *filp);
|
2016-01-20 05:19:53 +01:00
|
|
|
extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
|
|
|
|
extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
|
|
|
|
extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
|
2011-06-24 12:45:58 +02:00
|
|
|
struct timeval *vblanktime);
|
2016-01-20 05:19:53 +01:00
|
|
|
extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
|
|
|
|
struct timeval *vblanktime);
|
|
|
|
extern void drm_send_vblank_event(struct drm_device *dev, unsigned int pipe,
|
|
|
|
struct drm_pending_vblank_event *e);
|
|
|
|
extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
|
|
|
|
struct drm_pending_vblank_event *e);
|
|
|
|
extern bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe);
|
|
|
|
extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc);
|
|
|
|
extern int drm_vblank_get(struct drm_device *dev, unsigned int pipe);
|
|
|
|
extern void drm_vblank_put(struct drm_device *dev, unsigned int pipe);
|
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);
|
2016-01-20 05:19:53 +01:00
|
|
|
extern void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe);
|
2014-12-27 16:42:08 +01:00
|
|
|
extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc);
|
2016-01-20 05:19:53 +01:00
|
|
|
extern void drm_vblank_off(struct drm_device *dev, unsigned int pipe);
|
|
|
|
extern void drm_vblank_on(struct drm_device *dev, unsigned int pipe);
|
2014-08-23 12:29:27 +02:00
|
|
|
extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
|
2016-01-20 05:19:53 +01:00
|
|
|
extern void drm_crtc_vblank_reset(struct drm_crtc *crtc);
|
2014-08-23 12:29:27 +02:00
|
|
|
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);
|
2016-01-20 05:19:53 +01:00
|
|
|
extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe);
|
2014-08-23 12:29:27 +02:00
|
|
|
|
2011-06-24 12:45:58 +02:00
|
|
|
extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
|
2016-01-20 05:19:53 +01:00
|
|
|
unsigned int pipe, int *max_error,
|
2011-06-24 12:45:58 +02:00
|
|
|
struct timeval *vblank_time,
|
|
|
|
unsigned flags,
|
2014-02-06 07:52:49 +01:00
|
|
|
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
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
/**
|
|
|
|
* drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC
|
|
|
|
* @crtc: which CRTC's vblank waitqueue to retrieve
|
|
|
|
*
|
|
|
|
* This function returns a pointer to the vblank waitqueue for the CRTC.
|
|
|
|
* Drivers can use this to implement vblank waits using wait_event() & co.
|
|
|
|
*/
|
|
|
|
static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc)
|
|
|
|
{
|
|
|
|
return &crtc->dev->vblank[drm_crtc_index(crtc)].queue;
|
|
|
|
}
|
2013-03-19 07:14:59 +01:00
|
|
|
|
2010-02-12 21:11:35 +01:00
|
|
|
/* Modesetting support */
|
2016-01-20 05:19:53 +01:00
|
|
|
extern void drm_vblank_pre_modeset(struct drm_device *dev, unsigned int pipe);
|
|
|
|
extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/* Stub support (drm_stub.h) */
|
|
|
|
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;
|
2016-01-20 05:19:53 +01:00
|
|
|
extern bool drm_atomic;
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/* Debugfs support */
|
|
|
|
#if defined(CONFIG_DEBUG_FS)
|
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,
|
2016-01-20 05:19:53 +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);
|
|
|
|
#else
|
|
|
|
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;
|
|
|
|
}
|
2010-02-12 21:11:35 +01:00
|
|
|
#endif
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
|
|
|
|
struct drm_gem_object *obj, int flags);
|
|
|
|
extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
|
|
|
|
struct drm_file *file_priv, uint32_t handle, uint32_t flags,
|
|
|
|
int *prime_fd);
|
|
|
|
extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
|
|
|
|
struct dma_buf *dma_buf);
|
|
|
|
extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
|
|
|
|
struct drm_file *file_priv, int prime_fd, uint32_t *handle);
|
|
|
|
extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
|
|
|
|
dma_addr_t *addrs, int max_pages);
|
|
|
|
extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages);
|
|
|
|
extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
|
2014-12-27 16:42:08 +01:00
|
|
|
extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
|
2016-01-20 05:19:53 +01:00
|
|
|
size_t align);
|
2014-12-27 16:42:08 +01:00
|
|
|
extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
|
2010-02-12 21:11:35 +01:00
|
|
|
|
|
|
|
/* sysfs support (drm_sysfs.c) */
|
|
|
|
extern void drm_sysfs_hotplug_event(struct drm_device *dev);
|
|
|
|
|
|
|
|
|
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);
|
2014-12-27 16:42:08 +01:00
|
|
|
int drm_dev_register(struct drm_device *dev, unsigned long flags);
|
|
|
|
void drm_dev_unregister(struct drm_device *dev);
|
|
|
|
int drm_dev_set_unique(struct drm_device *dev, const char *fmt, ...);
|
|
|
|
|
|
|
|
struct drm_minor *drm_minor_acquire(unsigned int minor_id);
|
|
|
|
void drm_minor_release(struct drm_minor *minor);
|
2014-11-16 12:38:35 +01:00
|
|
|
|
2013-10-26 15:31:36 +02:00
|
|
|
/*@}*/
|
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);
|
|
|
|
}
|
2012-11-12 22:22:52 +01:00
|
|
|
|
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
|