1098 lines · 35.0 KB · C
RawDownload
/* * Internal Header for the Direct Rendering Manager * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * Copyright (c) 2009-2010, Code Aurora Forum. * All rights reserved. * * Author: Rickard E. (Rik) Faith <faith@valinux.com> * Author: Gareth Hughes <gareth@valinux.com> * * 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_ #include <linux/agp_backend.h>#include <linux/cdev.h>#include <linux/dma-mapping.h>#include <linux/file.h>#include <linux/fs.h>#include <linux/highmem.h>#include <linux/idr.h>#include <linux/init.h>#include <linux/io.h>#include <linux/jiffies.h>#include <linux/kernel.h>#include <linux/kref.h>#include <linux/miscdevice.h>#include <linux/mm.h>#include <linux/mutex.h>#include <linux/pci.h>#include <linux/platform_device.h>#include <linux/poll.h>#include <linux/ratelimit.h>#include <linux/sched.h>#include <linux/slab.h>#include <linux/types.h>#include <linux/vmalloc.h>#include <linux/workqueue.h> #include <asm/mman.h>#include <asm/pgalloc.h>#include <asm/uaccess.h> #include <uapi/drm/drm.h>#include <uapi/drm/drm_mode.h> #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>#include <drm/drm_vma_manager.h> struct module; struct drm_file;struct drm_device;struct drm_agp_head;struct drm_local_map;struct drm_device_dma;struct drm_dma_handle;struct drm_gem_object; struct device_node;struct videomode;struct reservation_object;struct dma_buf_attachment; /* * 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. * * KMS: used in the modesetting code. *	This is the category used by the DRM_DEBUG_KMS() macro. * * PRIME: used in the prime code. *	  This is the category used by the DRM_DEBUG_PRIME() macro. * * ATOMIC: used in the atomic code. *	  This is the category used by the DRM_DEBUG_ATOMIC() macro. * * 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 */#define DRM_UT_CORE 		0x01#define DRM_UT_DRIVER		0x02#define DRM_UT_KMS		0x04#define DRM_UT_PRIME		0x08#define DRM_UT_ATOMIC		0x10 extern __printf(2, 3)void drm_ut_debug_printk(const char *function_name,			 const char *format, ...);extern __printf(1, 2)void drm_err(const char *format, ...); /***********************************************************************//** \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#define DRIVER_PRIME       0x4000#define DRIVER_RENDER      0x8000#define DRIVER_ATOMIC      0x10000 /***********************************************************************//** \name Macros to make printk easier *//*@{*/ /** * Error output. * * \param fmt printf() like format string. * \param arg arguments */#define DRM_ERROR(fmt, ...)				\	drm_err(fmt, ##__VA_ARGS__) /** * 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(fmt, ##__VA_ARGS__);				\}) #define DRM_INFO(fmt, ...)				\	printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) #define DRM_INFO_ONCE(fmt, ...)				\	printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) /** * Debug output. * * \param fmt printf() like format string. * \param arg arguments */#define DRM_DEBUG(fmt, args...)						\	do {								\		if (unlikely(drm_debug & DRM_UT_CORE))			\			drm_ut_debug_printk(__func__, fmt, ##args);	\	} while (0) #define DRM_DEBUG_DRIVER(fmt, args...)					\	do {								\		if (unlikely(drm_debug & DRM_UT_DRIVER))		\			drm_ut_debug_printk(__func__, fmt, ##args);	\	} while (0)#define DRM_DEBUG_KMS(fmt, args...)					\	do {								\		if (unlikely(drm_debug & DRM_UT_KMS))			\			drm_ut_debug_printk(__func__, fmt, ##args);	\	} while (0)#define DRM_DEBUG_PRIME(fmt, args...)					\	do {								\		if (unlikely(drm_debug & DRM_UT_PRIME))			\			drm_ut_debug_printk(__func__, fmt, ##args);	\	} while (0)#define DRM_DEBUG_ATOMIC(fmt, args...)					\	do {								\		if (unlikely(drm_debug & DRM_UT_ATOMIC))		\			drm_ut_debug_printk(__func__, fmt, ##args);	\	} while (0) /*@}*/ /***********************************************************************//** \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#define DRM_RENDER_ALLOW 0x20 struct drm_ioctl_desc {	unsigned int cmd;	int flags;	drm_ioctl_t *func;	const char *name;}; /** * Creates a driver or general drm_ioctl_desc array entry for the given * ioctl, for use by drm_ioctl(). */ #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						\	 } /* Event queued up for userspace to read */struct drm_pending_event {	struct drm_event *event;	struct list_head link;	struct drm_file *file_priv;	pid_t pid; /* pid of requester, no guarantee it's valid by the time		      we deliver the event, for tracing only */	void (*destroy)(struct drm_pending_event *event);}; /* initial implementaton using a linked list - todo hashtab */struct drm_prime_file_private {	struct list_head head;	struct mutex lock;}; /** File private data */struct drm_file {	unsigned authenticated :1;	/* Whether we're master for a minor. Protected by master_mutex */	unsigned is_master :1;	/* true when the client has asked us to expose stereo 3D mode flags */	unsigned stereo_allowed :1;	/*	 * true if client understands CRTC primary planes and cursor planes	 * in the plane list	 */	unsigned universal_planes:1;	/* true if client understands atomic properties */	unsigned atomic:1; 	struct pid *pid;	kuid_t uid;	drm_magic_t magic;	struct list_head lhead;	struct drm_minor *minor;	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; 	struct file *filp;	void *driver_priv; 	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.	 */	struct list_head fbs;	struct mutex fbs_lock; 	/** User-created blob properties; this retains a reference on the	 *  property. */	struct list_head blobs; 	wait_queue_head_t event_wait;	struct list_head event_list;	int event_space; 	struct drm_prime_file_private prime;}; /** * 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;}; /** * 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. * @magic_map: Map of used authentication tokens. Protected by struct_mutex. * @lock: DRI lock information. * @driver_priv: Pointer to driver-private information. */struct drm_master {	struct kref refcount;	struct drm_minor *minor;	char *unique;	int unique_len;	struct idr magic_map;	struct drm_lock_data lock;	void *driver_priv;}; /* 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_IN_VBLANK         (1 << 1) /* get_scanout_position() return flags */#define DRM_SCANOUTPOS_VALID        (1 << 0)#define DRM_SCANOUTPOS_IN_VBLANK    (1 << 1)#define DRM_SCANOUTPOS_ACCURATE     (1 << 2) /** * 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 (*firstopen) (struct drm_device *);	int (*open) (struct drm_device *, struct drm_file *);	void (*preclose) (struct drm_device *, struct drm_file *file_priv);	void (*postclose) (struct drm_device *, struct drm_file *);	void (*lastclose) (struct drm_device *);	int (*unload) (struct drm_device *);	int (*suspend) (struct drm_device *, pm_message_t state);	int (*resume) (struct drm_device *);	int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);	int (*dma_quiescent) (struct drm_device *);	int (*context_dtor) (struct drm_device *dev, int context);	int (*set_busid)(struct drm_device *dev, struct drm_master *master); 	/**	 * get_vblank_counter - get raw hardware vblank counter	 * @dev: DRM device	 * @crtc: counter to fetch	 *	 * 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.	 *	 * 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); 	/**	 * 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); 	/**	 * Called by vblank timestamping code.	 *	 * Return the current display scanout position from a crtc, and an	 * optional accurate ktime_get timestamp of when position was measured.	 *	 * \param dev  DRM device.	 * \param crtc Id of the crtc to query.	 * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).	 * \param *vpos Target location for current vertical scanout position.	 * \param *hpos Target location for current horizontal scanout position.	 * \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.	 *	 * 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,				     unsigned int flags,

Lines 1–500 of 1098.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t