linux/drivers/gpu/drm/drm_legacy.h
<<
>>
Prefs
   1#ifndef __DRM_LEGACY_H__
   2#define __DRM_LEGACY_H__
   3
   4/*
   5 * Copyright (c) 2014 David Herrmann <dh.herrmann@gmail.com>
   6 *
   7 * Permission is hereby granted, free of charge, to any person obtaining a
   8 * copy of this software and associated documentation files (the "Software"),
   9 * to deal in the Software without restriction, including without limitation
  10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11 * and/or sell copies of the Software, and to permit persons to whom the
  12 * Software is furnished to do so, subject to the following conditions:
  13 *
  14 * The above copyright notice and this permission notice shall be included in
  15 * all copies or substantial portions of the Software.
  16 *
  17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  20 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  23 * OTHER DEALINGS IN THE SOFTWARE.
  24 */
  25
  26/*
  27 * This file contains legacy interfaces that modern drm drivers
  28 * should no longer be using. They cannot be removed as legacy
  29 * drivers use them, and removing them are API breaks.
  30 */
  31#include <linux/list.h>
  32
  33#include <drm/drm.h>
  34#include <drm/drm_device.h>
  35#include <drm/drm_legacy.h>
  36
  37struct agp_memory;
  38struct drm_device;
  39struct drm_file;
  40struct drm_buf_desc;
  41
  42/*
  43 * Generic DRM Contexts
  44 */
  45
  46#define DRM_KERNEL_CONTEXT              0
  47#define DRM_RESERVED_CONTEXTS           1
  48
  49#if IS_ENABLED(CONFIG_DRM_LEGACY)
  50void drm_legacy_ctxbitmap_init(struct drm_device *dev);
  51void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev);
  52void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file);
  53#else
  54static inline void drm_legacy_ctxbitmap_init(struct drm_device *dev) {}
  55static inline void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev) {}
  56static inline void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) {}
  57#endif
  58
  59void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
  60
  61#if IS_ENABLED(CONFIG_DRM_LEGACY)
  62int drm_legacy_resctx(struct drm_device *d, void *v, struct drm_file *f);
  63int drm_legacy_addctx(struct drm_device *d, void *v, struct drm_file *f);
  64int drm_legacy_getctx(struct drm_device *d, void *v, struct drm_file *f);
  65int drm_legacy_switchctx(struct drm_device *d, void *v, struct drm_file *f);
  66int drm_legacy_newctx(struct drm_device *d, void *v, struct drm_file *f);
  67int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f);
  68
  69int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f);
  70int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
  71#endif
  72
  73/*
  74 * Generic Buffer Management
  75 */
  76
  77#define DRM_MAP_HASH_OFFSET 0x10000000
  78
  79#if IS_ENABLED(CONFIG_DRM_LEGACY)
  80static inline int drm_legacy_create_map_hash(struct drm_device *dev)
  81{
  82        return drm_ht_create(&dev->map_hash, 12);
  83}
  84
  85static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
  86{
  87        drm_ht_remove(&dev->map_hash);
  88}
  89#else
  90static inline int drm_legacy_create_map_hash(struct drm_device *dev)
  91{
  92        return 0;
  93}
  94
  95static inline void drm_legacy_remove_map_hash(struct drm_device *dev) {}
  96#endif
  97
  98
  99#if IS_ENABLED(CONFIG_DRM_LEGACY)
 100int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
 101                            struct drm_file *file_priv);
 102int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
 103int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
 104
 105int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);
 106int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f);
 107int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f);
 108int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f);
 109int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f);
 110int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f);
 111#endif
 112
 113int __drm_legacy_infobufs(struct drm_device *, void *, int *,
 114                          int (*)(void *, int, struct drm_buf_entry *));
 115int __drm_legacy_mapbufs(struct drm_device *, void *, int *,
 116                          void __user **,
 117                          int (*)(void *, int, unsigned long, struct drm_buf *),
 118                          struct drm_file *);
 119
 120#if IS_ENABLED(CONFIG_DRM_LEGACY)
 121void drm_legacy_master_rmmaps(struct drm_device *dev,
 122                              struct drm_master *master);
 123void drm_legacy_rmmaps(struct drm_device *dev);
 124#else
 125static inline void drm_legacy_master_rmmaps(struct drm_device *dev,
 126                                            struct drm_master *master) {}
 127static inline void drm_legacy_rmmaps(struct drm_device *dev) {}
 128#endif
 129
 130#if IS_ENABLED(CONFIG_DRM_LEGACY)
 131void drm_legacy_vma_flush(struct drm_device *d);
 132#else
 133static inline void drm_legacy_vma_flush(struct drm_device *d)
 134{
 135        /* do nothing */
 136}
 137#endif
 138
 139/*
 140 * AGP Support
 141 */
 142
 143struct drm_agp_mem {
 144        unsigned long handle;
 145        struct agp_memory *memory;
 146        unsigned long bound;
 147        int pages;
 148        struct list_head head;
 149};
 150
 151/* drm_agpsupport.c */
 152#if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_AGP)
 153void drm_legacy_agp_clear(struct drm_device *dev);
 154
 155int drm_legacy_agp_acquire_ioctl(struct drm_device *dev, void *data,
 156                                 struct drm_file *file_priv);
 157int drm_legacy_agp_release_ioctl(struct drm_device *dev, void *data,
 158                                 struct drm_file *file_priv);
 159int drm_legacy_agp_enable_ioctl(struct drm_device *dev, void *data,
 160                                struct drm_file *file_priv);
 161int drm_legacy_agp_info_ioctl(struct drm_device *dev, void *data,
 162                              struct drm_file *file_priv);
 163int drm_legacy_agp_alloc_ioctl(struct drm_device *dev, void *data,
 164                               struct drm_file *file_priv);
 165int drm_legacy_agp_free_ioctl(struct drm_device *dev, void *data,
 166                              struct drm_file *file_priv);
 167int drm_legacy_agp_unbind_ioctl(struct drm_device *dev, void *data,
 168                                struct drm_file *file_priv);
 169int drm_legacy_agp_bind_ioctl(struct drm_device *dev, void *data,
 170                              struct drm_file *file_priv);
 171#else
 172static inline void drm_legacy_agp_clear(struct drm_device *dev) {}
 173#endif
 174
 175/* drm_lock.c */
 176#if IS_ENABLED(CONFIG_DRM_LEGACY)
 177int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f);
 178int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f);
 179void drm_legacy_lock_release(struct drm_device *dev, struct file *filp);
 180#else
 181static inline void drm_legacy_lock_release(struct drm_device *dev, struct file *filp) {}
 182#endif
 183
 184/* DMA support */
 185#if IS_ENABLED(CONFIG_DRM_LEGACY)
 186int drm_legacy_dma_setup(struct drm_device *dev);
 187void drm_legacy_dma_takedown(struct drm_device *dev);
 188#else
 189static inline int drm_legacy_dma_setup(struct drm_device *dev)
 190{
 191        return 0;
 192}
 193#endif
 194
 195void drm_legacy_free_buffer(struct drm_device *dev,
 196                            struct drm_buf * buf);
 197#if IS_ENABLED(CONFIG_DRM_LEGACY)
 198void drm_legacy_reclaim_buffers(struct drm_device *dev,
 199                                struct drm_file *filp);
 200#else
 201static inline void drm_legacy_reclaim_buffers(struct drm_device *dev,
 202                                              struct drm_file *filp) {}
 203#endif
 204
 205/* Scatter Gather Support */
 206#if IS_ENABLED(CONFIG_DRM_LEGACY)
 207void drm_legacy_sg_cleanup(struct drm_device *dev);
 208int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
 209                        struct drm_file *file_priv);
 210int drm_legacy_sg_free(struct drm_device *dev, void *data,
 211                       struct drm_file *file_priv);
 212#endif
 213
 214#if IS_ENABLED(CONFIG_DRM_LEGACY)
 215void drm_legacy_init_members(struct drm_device *dev);
 216void drm_legacy_destroy_members(struct drm_device *dev);
 217void drm_legacy_dev_reinit(struct drm_device *dev);
 218int drm_legacy_setup(struct drm_device * dev);
 219#else
 220static inline void drm_legacy_init_members(struct drm_device *dev) {}
 221static inline void drm_legacy_destroy_members(struct drm_device *dev) {}
 222static inline void drm_legacy_dev_reinit(struct drm_device *dev) {}
 223static inline int drm_legacy_setup(struct drm_device * dev) { return 0; }
 224#endif
 225
 226#if IS_ENABLED(CONFIG_DRM_LEGACY)
 227void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
 228#else
 229static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {}
 230#endif
 231
 232#if IS_ENABLED(CONFIG_DRM_LEGACY)
 233void drm_master_legacy_init(struct drm_master *master);
 234#else
 235static inline void drm_master_legacy_init(struct drm_master *master) {}
 236#endif
 237
 238/* drm_pci.c */
 239#if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_PCI)
 240int drm_legacy_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file_priv);
 241void drm_legacy_pci_agp_destroy(struct drm_device *dev);
 242#else
 243static inline int drm_legacy_irq_by_busid(struct drm_device *dev, void *data,
 244                                          struct drm_file *file_priv)
 245{
 246        return -EINVAL;
 247}
 248
 249static inline void drm_legacy_pci_agp_destroy(struct drm_device *dev) {}
 250#endif
 251
 252#endif /* __DRM_LEGACY_H__ */
 253