blob: 4bbef061c9c0c9f99e663190dcbe96f92e0c3801 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
David Herrmannd7d2c482014-08-29 12:12:40 +02002 * Internal Header for the Direct Rendering Manager
3 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
Jordan Crousedcdb1672010-05-27 13:40:25 -06006 * Copyright (c) 2009-2010, Code Aurora Forum.
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * All rights reserved.
8 *
David Herrmannd7d2c482014-08-29 12:12:40 +02009 * Author: Rickard E. (Rik) Faith <faith@valinux.com>
10 * Author: Gareth Hughes <gareth@valinux.com>
11 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice (including the next
20 * paragraph) shall be included in all copies or substantial portions of the
21 * Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
27 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29 * OTHER DEALINGS IN THE SOFTWARE.
30 */
31
32#ifndef _DRM_P_H_
33#define _DRM_P_H_
34
David Herrmann96993902014-08-29 12:12:37 +020035#include <linux/agp_backend.h>
36#include <linux/cdev.h>
37#include <linux/dma-mapping.h>
38#include <linux/file.h>
39#include <linux/fs.h>
40#include <linux/highmem.h>
41#include <linux/idr.h>
42#include <linux/init.h>
43#include <linux/io.h>
44#include <linux/jiffies.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/kernel.h>
David Herrmann099d1c22014-01-29 10:21:36 +010046#include <linux/kref.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include <linux/miscdevice.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <linux/mm.h>
Dave Airlie30e2fb12006-02-02 19:37:46 +110049#include <linux/mutex.h>
David Herrmann96993902014-08-29 12:12:37 +020050#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#include <linux/poll.h>
David Herrmann96993902014-08-29 12:12:37 +020052#include <linux/ratelimit.h>
53#include <linux/sched.h>
54#include <linux/slab.h>
55#include <linux/types.h>
David Herrmannd6db6562014-08-29 12:12:35 +020056#include <linux/vmalloc.h>
David Herrmann96993902014-08-29 12:12:37 +020057#include <linux/workqueue.h>
Chris Wilsonf54d1862016-10-25 13:00:45 +010058#include <linux/dma-fence.h>
Daniel Vetterc6bb9ba2017-03-08 15:12:35 +010059#include <linux/module.h>
David Herrmann96993902014-08-29 12:12:37 +020060
61#include <asm/mman.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#include <asm/pgalloc.h>
Linus Torvalds7c0f6ba2016-12-24 11:46:01 -080063#include <linux/uaccess.h>
David Herrmann96993902014-08-29 12:12:37 +020064
David Herrmannd7d2c482014-08-29 12:12:40 +020065#include <uapi/drm/drm.h>
66#include <uapi/drm/drm_mode.h>
67
68#include <drm/drm_agpsupport.h>
69#include <drm/drm_crtc.h>
Laurent Pinchartae4df112016-06-09 12:54:08 +030070#include <drm/drm_fourcc.h>
David Herrmannd7d2c482014-08-29 12:12:40 +020071#include <drm/drm_global.h>
David Herrmann96993902014-08-29 12:12:37 +020072#include <drm/drm_hashtab.h>
73#include <drm/drm_mm.h>
74#include <drm/drm_os_linux.h>
David Howells19218e42012-10-02 18:01:03 +010075#include <drm/drm_sarea.h>
Daniel Vetter85e634b2016-11-14 12:58:19 +010076#include <drm/drm_drv.h>
Daniel Vetterc6bb9ba2017-03-08 15:12:35 +010077#include <drm/drm_prime.h>
Haneen Mohammed02c96562017-10-17 22:30:07 -060078#include <drm/drm_print.h>
Daniel Vetter23ef59e2017-03-08 15:12:37 +010079#include <drm/drm_pci.h>
Daniel Vettera8f8b1d2017-03-08 15:12:42 +010080#include <drm/drm_file.h>
Daniel Vetter48344422017-03-22 21:53:36 +010081#include <drm/drm_debugfs.h>
Daniel Vetter7cfdf712017-03-22 21:54:47 +010082#include <drm/drm_ioctl.h>
Daniel Vettere2271702017-04-04 11:52:55 +020083#include <drm/drm_sysfs.h>
Daniel Vetter3ed43512017-05-31 11:21:46 +020084#include <drm/drm_vblank.h>
85#include <drm/drm_irq.h>
Daniel Vettere4672e52017-08-02 13:56:01 +020086#include <drm/drm_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
Paul Gortmakerde477252011-05-26 13:46:22 -040088struct module;
89
Steffen Trumtraredb37a92012-10-28 18:28:06 +010090struct device_node;
Steffen Trumtrarebc64e42012-11-14 11:22:52 +010091struct videomode;
Maarten Lankhorst3aac4502014-07-01 12:57:26 +020092struct reservation_object;
Maarten Lankhorstb5e9c1a2014-01-09 11:03:14 +010093struct dma_buf_attachment;
Steffen Trumtrarebc64e42012-11-14 11:22:52 +010094
Daniel Vetter23ef59e2017-03-08 15:12:37 +010095struct pci_dev;
96struct pci_controller;
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098/***********************************************************************/
99/** \name DRM template customization defaults */
100/*@{*/
101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102/***********************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103/** \name Internal types and structures */
104/*@{*/
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
Ben Gamari955b12d2009-02-17 20:08:49 -0500108/**
Dhinakaran Pandiyana743d752016-12-22 00:50:42 -0800109 * drm_drv_uses_atomic_modeset - check if the driver implements
110 * atomic_commit()
111 * @dev: DRM device
112 *
113 * This check is useful if drivers do not have DRIVER_ATOMIC set but
114 * have atomic modesetting internally implemented.
115 */
116static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
117{
118 return dev->mode_config.funcs->atomic_commit != NULL;
119}
120
Dave Airlie5bcf7192010-12-07 09:20:40 +1000121#define DRM_SWITCH_POWER_ON 0
122#define DRM_SWITCH_POWER_OFF 1
123#define DRM_SWITCH_POWER_CHANGING 2
Dave Airlie13bb9cc2012-09-12 15:55:05 +1000124#define DRM_SWITCH_POWER_DYNAMIC_OFF 3
Dave Airlie5bcf7192010-12-07 09:20:40 +1000125
Jani Nikulad1a9d712018-03-27 23:47:20 +0300126static inline int drm_core_check_feature(struct drm_device *dev, int feature)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127{
128 return ((dev->driver->driver_features & feature) ? 1 : 0);
129}
130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131/******************************************************************/
132/** \name Internal function definitions */
133/*@{*/
134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 /* Driver support (drm_drv.h) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
Thomas Hellstrom040ac322007-03-23 13:28:33 +1100137/*
138 * These are exported to drivers so that they can implement fencing using
139 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
140 */
141
Dave Airlie8410ea32010-12-15 03:16:38 +1000142/*@}*/
143
Dave Airliecc1f7192012-01-05 09:55:22 +0000144/* returns true if currently okay to sleep */
Jani Nikulad1a9d712018-03-27 23:47:20 +0300145static inline bool drm_can_sleep(void)
Dave Airliecc1f7192012-01-05 09:55:22 +0000146{
147 if (in_atomic() || in_dbg_master() || irqs_disabled())
148 return false;
149 return true;
150}
151
Jani Nikula373701b2015-11-24 21:21:55 +0200152/* helper for handling conditionals in various for_each macros */
153#define for_each_if(condition) if (!(condition)) {} else
154
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155#endif