2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2014-08-29 10:12:40 +00:00
|
|
|
* Internal Header for the Direct Rendering Manager
|
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
|
|
|
|
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
2010-05-27 19:40:25 +00:00
|
|
|
* Copyright (c) 2009-2010, Code Aurora Forum.
|
2005-04-16 22:20:36 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2014-08-29 10:12:40 +00:00
|
|
|
* Author: Rickard E. (Rik) Faith <faith@valinux.com>
|
|
|
|
* Author: Gareth Hughes <gareth@valinux.com>
|
|
|
|
*
|
2005-04-16 22:20:36 +00: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_
|
|
|
|
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/agp_backend.h>
|
|
|
|
#include <linux/cdev.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/file.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/fs.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/highmem.h>
|
|
|
|
#include <linux/idr.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/init.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/io.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/jiffies.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/kref.h>
|
|
|
|
#include <linux/miscdevice.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/mm.h>
|
2006-02-02 08:37:46 +00:00
|
|
|
#include <linux/mutex.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/poll.h>
|
2013-11-21 19:29:51 +00:00
|
|
|
#include <linux/ratelimit.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/slab.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/types.h>
|
2014-08-29 10:12:35 +00:00
|
|
|
#include <linux/vmalloc.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <linux/workqueue.h>
|
2016-10-25 12:00:45 +00:00
|
|
|
#include <linux/dma-fence.h>
|
2017-03-08 14:12:35 +00:00
|
|
|
#include <linux/module.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
|
|
|
|
#include <asm/mman.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/pgalloc.h>
|
2016-12-24 19:46:01 +00:00
|
|
|
#include <linux/uaccess.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
|
2014-08-29 10:12:40 +00:00
|
|
|
#include <uapi/drm/drm.h>
|
|
|
|
#include <uapi/drm/drm_mode.h>
|
|
|
|
|
|
|
|
#include <drm/drm_agpsupport.h>
|
|
|
|
#include <drm/drm_crtc.h>
|
2016-06-09 09:54:08 +00:00
|
|
|
#include <drm/drm_fourcc.h>
|
2014-08-29 10:12:40 +00:00
|
|
|
#include <drm/drm_global.h>
|
2014-08-29 10:12:37 +00:00
|
|
|
#include <drm/drm_hashtab.h>
|
|
|
|
#include <drm/drm_mm.h>
|
|
|
|
#include <drm/drm_os_linux.h>
|
2012-10-02 17:01:03 +00:00
|
|
|
#include <drm/drm_sarea.h>
|
2016-11-14 11:58:19 +00:00
|
|
|
#include <drm/drm_drv.h>
|
2017-03-08 14:12:35 +00:00
|
|
|
#include <drm/drm_prime.h>
|
2017-10-18 04:30:07 +00:00
|
|
|
#include <drm/drm_print.h>
|
2017-03-08 14:12:37 +00:00
|
|
|
#include <drm/drm_pci.h>
|
2017-03-08 14:12:42 +00:00
|
|
|
#include <drm/drm_file.h>
|
2017-03-22 20:53:36 +00:00
|
|
|
#include <drm/drm_debugfs.h>
|
2017-03-22 20:54:47 +00:00
|
|
|
#include <drm/drm_ioctl.h>
|
2017-04-04 09:52:55 +00:00
|
|
|
#include <drm/drm_sysfs.h>
|
2017-05-31 09:21:46 +00:00
|
|
|
#include <drm/drm_vblank.h>
|
|
|
|
#include <drm/drm_irq.h>
|
2017-08-02 11:56:01 +00:00
|
|
|
#include <drm/drm_device.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-05-26 17:46:22 +00:00
|
|
|
struct module;
|
|
|
|
|
2012-10-28 17:28:06 +00:00
|
|
|
struct device_node;
|
2012-11-14 10:22:52 +00:00
|
|
|
struct videomode;
|
2014-07-01 10:57:26 +00:00
|
|
|
struct reservation_object;
|
2014-01-09 10:03:14 +00:00
|
|
|
struct dma_buf_attachment;
|
2012-11-14 10:22:52 +00:00
|
|
|
|
2017-03-08 14:12:37 +00:00
|
|
|
struct pci_dev;
|
|
|
|
struct pci_controller;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
|
|
|
|
|
2016-12-22 08:50:42 +00:00
|
|
|
/**
|
|
|
|
* drm_drv_uses_atomic_modeset - check if the driver implements
|
|
|
|
* atomic_commit()
|
|
|
|
* @dev: DRM device
|
|
|
|
*
|
|
|
|
* This check is useful if drivers do not have DRIVER_ATOMIC set but
|
|
|
|
* have atomic modesetting internally implemented.
|
|
|
|
*/
|
|
|
|
static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
|
|
|
|
{
|
|
|
|
return dev->mode_config.funcs->atomic_commit != NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-06 23:20:40 +00:00
|
|
|
#define DRM_SWITCH_POWER_ON 0
|
|
|
|
#define DRM_SWITCH_POWER_OFF 1
|
|
|
|
#define DRM_SWITCH_POWER_CHANGING 2
|
2012-09-12 05:55:05 +00:00
|
|
|
#define DRM_SWITCH_POWER_DYNAMIC_OFF 3
|
2010-12-06 23:20:40 +00:00
|
|
|
|
2018-03-27 20:47:22 +00:00
|
|
|
static inline bool drm_core_check_feature(struct drm_device *dev, int feature)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-03-27 20:47:22 +00:00
|
|
|
return dev->driver->driver_features & feature;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-01-05 09:55:22 +00:00
|
|
|
/* returns true if currently okay to sleep */
|
2018-03-27 20:47:20 +00:00
|
|
|
static inline bool drm_can_sleep(void)
|
2012-01-05 09:55:22 +00:00
|
|
|
{
|
|
|
|
if (in_atomic() || in_dbg_master() || irqs_disabled())
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
drm: fix potential dangling else problems in for_each_ macros
We have serious dangling else bugs waiting to happen in our for_each_
style macros with ifs. Consider, for example,
#define drm_for_each_plane_mask(plane, dev, plane_mask) \
list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
if ((plane_mask) & (1 << drm_plane_index(plane)))
If this is used in context:
if (condition)
drm_for_each_plane_mask(plane, dev, plane_mask);
else
foo();
foo() will be called for each plane *not* in plane_mask, if condition
holds, and not at all if condition doesn't hold.
Fix this by reversing the conditions in the macros, and adding an else
branch for the "for each" block, so that other if/else blocks can't
interfere. Provide a "for_each_if" helper macro to make it easier to get
this right.
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1448392916-2281-1-git-send-email-jani.nikula@intel.com
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-11-24 19:21:55 +00:00
|
|
|
/* helper for handling conditionals in various for_each macros */
|
|
|
|
#define for_each_if(condition) if (!(condition)) {} else
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|