XenevaOS
Loading...
Searching...
No Matches
drm_drv.h
Go to the documentation of this file.
1/*
2 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
3 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
4 * Copyright (c) 2009-2010, Code Aurora Forum.
5 * Copyright 2016 Intel Corp.
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 (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
16 * Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27#ifndef _DRM_DRV_H_
28#define _DRM_DRV_H_
29
30#include <linux/list.h>
31#include <linux/irqreturn.h>
32
33/*
34 * <linux/capability.h> for capable(), which the drm sources reach through
35 * this header without naming it: drm_framebuffer.c:557 and :635 write
36 * `capable(CAP_SYS_ADMIN)` and include neither capability.h nor pci.h -- and
37 * pci.h is the carrier for the other two consumers, drm_file.c:149 and
38 * drm_ioctl.c:152.
39 *
40 * In mainline the chain is longer and automatic: this header includes
41 * <linux/fs.h>, and mainline's fs.h includes <linux/capability.h>. DCL's
42 * fs.h is a pinned ABI blob that includes nothing, so the chain has no last
43 * link and this header names the source itself. mainline's drm_drv.h does
44 * include <linux/fs.h> (for struct file's role in drm_driver), which is why
45 * this is the faithful place for it rather than a bolt-on.
46 *
47 * Leaf: capability.h includes only <stdbool.h>.
48 */
49#include <linux/capability.h>
50
51#include <video/nomodeset.h>
52
53#include <drm/drm_device.h>
54
55struct dmem_cgroup_region;
56struct drm_fb_helper;
58struct drm_file;
59struct drm_gem_object;
60struct drm_master;
61struct drm_minor;
62struct dma_buf;
64struct drm_display_mode;
66struct drm_printer;
67struct sg_table;
68
189
216 int (*load) (struct drm_device *, unsigned long flags);
217
236 int (*open) (struct drm_device *, struct drm_file *);
237
250 void (*postclose) (struct drm_device *, struct drm_file *);
251
267 void (*unload) (struct drm_device *);
268
279 void (*release) (struct drm_device *);
280
286 void (*master_set)(struct drm_device *dev, struct drm_file *file_priv,
287 bool from_open);
293 void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv);
294
300 void (*debugfs_init)(struct drm_minor *minor);
301
309 struct drm_gem_object *(*gem_create_object)(struct drm_device *dev,
310 size_t size);
311
317 int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
318 uint32_t handle, uint32_t flags, int *prime_fd);
324 int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv,
325 int prime_fd, uint32_t *handle);
326
334 struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
335 struct dma_buf *dma_buf);
342 struct drm_gem_object *(*gem_prime_import_sg_table)(
343 struct drm_device *dev,
344 struct dma_buf_attachment *attach,
345 struct sg_table *sgt);
346
368 int (*dumb_create)(struct drm_file *file_priv,
369 struct drm_device *dev,
370 struct drm_mode_create_dumb *args);
386 int (*dumb_map_offset)(struct drm_file *file_priv,
387 struct drm_device *dev, uint32_t handle,
389
403 int (*fbdev_probe)(struct drm_fb_helper *fbdev_helper,
404 struct drm_fb_helper_surface_size *sizes);
405
411 void (*show_fdinfo)(struct drm_printer *p, struct drm_file *f);
412
414 int major;
416 int minor;
420 char *name;
422 char *desc;
423
431
440 const struct drm_ioctl_desc *ioctls;
443
451 const struct file_operations *fops;
452};
453
455 const struct drm_driver *driver,
456 size_t size, size_t offset);
457
458struct dmem_cgroup_region *
460 const char *region_name, u64 size);
461
488#define devm_drm_dev_alloc(parent, driver, type, member) \
489 ((type *) __devm_drm_dev_alloc(parent, driver, sizeof(type), \
490 offsetof(type, member)))
491
493 struct device *parent);
494
496 const struct drm_driver *driver,
497 size_t size, size_t offset);
498
499int drm_dev_register(struct drm_device *dev, unsigned long flags);
501
505bool drm_dev_enter(struct drm_device *dev, int *idx);
506void drm_dev_exit(int idx);
508int drm_dev_wedged_event(struct drm_device *dev, unsigned long method,
509 struct drm_wedge_task_info *info);
510
524static inline bool drm_dev_is_unplugged(struct drm_device *dev)
525{
526 int idx;
527
528 if (drm_dev_enter(dev, &idx)) {
529 drm_dev_exit(idx);
530 return false;
531 }
532
533 return true;
534}
535
547static inline bool drm_core_check_all_features(const struct drm_device *dev,
548 u32 features)
549{
550 u32 supported = dev->driver->driver_features & dev->driver_features;
551
552 return features && (supported & features) == features;
553}
554
565static inline bool drm_core_check_feature(const struct drm_device *dev,
566 enum drm_driver_feature feature)
567{
568 return drm_core_check_all_features(dev, feature);
569}
570
579static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
580{
581 return drm_core_check_feature(dev, DRIVER_ATOMIC) ||
582 (dev->mode_config.funcs && dev->mode_config.funcs->atomic_commit != NULL);
583}
584
585
586/* TODO: Inline drm_firmware_drivers_only() in all its callers. */
587static inline bool drm_firmware_drivers_only(void)
588{
590}
591
592#if defined(CONFIG_DEBUG_FS)
593void drm_debugfs_dev_init(struct drm_device *dev);
594void drm_debugfs_init_root(void);
595void drm_debugfs_remove_root(void);
596void drm_debugfs_bridge_params(void);
597#else
598static inline void drm_debugfs_dev_init(struct drm_device *dev)
599{
600}
601
602static inline void drm_debugfs_init_root(void)
603{
604}
605
606static inline void drm_debugfs_remove_root(void)
607{
608}
609
610static inline void drm_debugfs_bridge_params(void)
611{
612}
613#endif
614
615#endif
uint8_t flags
Definition virtio.h:0
unsigned int uint32_t
Definition acefiex.h:163
COMPILER_DEPENDENT_UINT64 uint64_t
Definition acefiex.h:165
#define NULL
Definition actypes.h:561
#define BIT(nr)
Definition bitops.h:112
size_t size
Definition drm_bridge.h:1299
size_t size_t offset
Definition drm_bridge.h:1299
int drm_dev_wedged_event(struct drm_device *dev, unsigned long method, struct drm_wedge_task_info *info)
void drm_dev_exit(int idx)
void drm_dev_get(struct drm_device *dev)
bool drm_dev_enter(struct drm_device *dev, int *idx)
struct drm_device * drm_dev_alloc(const struct drm_driver *driver, struct device *parent)
void drm_dev_put(struct drm_device *dev)
void drm_dev_unplug(struct drm_device *dev)
void * __devm_drm_dev_alloc(struct device *parent, const struct drm_driver *driver, size_t size, size_t offset)
void drm_dev_unregister(struct drm_device *dev)
void * __drm_dev_alloc(struct device *parent, const struct drm_driver *driver, size_t size, size_t offset)
struct dmem_cgroup_region * drmm_cgroup_register_region(struct drm_device *dev, const char *region_name, u64 size)
int drm_dev_register(struct drm_device *dev, unsigned long flags)
drm_driver_feature
Definition drm_drv.h:75
@ DRIVER_RENDER
Definition drm_drv.h:95
@ DRIVER_MODESET
Definition drm_drv.h:88
@ DRIVER_SYNCOBJ_TIMELINE
Definition drm_drv.h:119
@ DRIVER_GEM
Definition drm_drv.h:82
@ DRIVER_SYNCOBJ
Definition drm_drv.h:112
@ DRIVER_HAVE_IRQ
Definition drm_drv.h:187
@ DRIVER_SG
Definition drm_drv.h:173
@ DRIVER_PCI_DMA
Definition drm_drv.h:165
@ DRIVER_ATOMIC
Definition drm_drv.h:105
@ DRIVER_USE_AGP
Definition drm_drv.h:152
@ DRIVER_LEGACY
Definition drm_drv.h:158
@ DRIVER_CURSOR_HOTSPOT
Definition drm_drv.h:142
@ DRIVER_GEM_GPUVA
Definition drm_drv.h:133
@ DRIVER_HAVE_DMA
Definition drm_drv.h:181
@ DRIVER_COMPUTE_ACCEL
Definition drm_drv.h:127
void drm_put_dev(struct drm_device *dev)
const struct device * dev
Definition drm_print.h:519
const char * f
Definition drm_print.h:205
struct kobject * parent
Definition kobject.h:91
uint64_t u64
Definition kernel.h:17
uint32_t u32
Definition kernel.h:16
bool video_firmware_drivers_only(void)
const char const char va_list args
Definition seq_buf.h:182
Definition fs.h:255
Definition dma-buf.h:494
Definition dma-buf.h:303
Definition drm_device.h:75
const struct drm_driver * driver
Definition drm_device.h:123
Definition drm_modes.h:252
Definition drm_drv.h:199
int(* dumb_create)(struct drm_file *file_priv, struct drm_device *dev, struct drm_mode_create_dumb *args)
Definition drm_drv.h:368
int(* fbdev_probe)(struct drm_fb_helper *fbdev_helper, struct drm_fb_helper_surface_size *sizes)
Definition drm_drv.h:403
int minor
Definition drm_drv.h:416
int patchlevel
Definition drm_drv.h:418
u32 driver_features
Definition drm_drv.h:430
void(* postclose)(struct drm_device *, struct drm_file *)
Definition drm_drv.h:250
void(* master_drop)(struct drm_device *dev, struct drm_file *file_priv)
Definition drm_drv.h:293
const struct drm_ioctl_desc * ioctls
Definition drm_drv.h:440
int(* prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv, uint32_t handle, uint32_t flags, int *prime_fd)
Definition drm_drv.h:317
const struct file_operations * fops
Definition drm_drv.h:451
void(* unload)(struct drm_device *)
Definition drm_drv.h:267
void(* debugfs_init)(struct drm_minor *minor)
Definition drm_drv.h:300
int(* dumb_map_offset)(struct drm_file *file_priv, struct drm_device *dev, uint32_t handle, uint64_t *offset)
Definition drm_drv.h:386
void(* show_fdinfo)(struct drm_printer *p, struct drm_file *f)
Definition drm_drv.h:411
int major
Definition drm_drv.h:414
int num_ioctls
Definition drm_drv.h:442
int(* load)(struct drm_device *, unsigned long flags)
Definition drm_drv.h:216
int(* prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv, int prime_fd, uint32_t *handle)
Definition drm_drv.h:324
int(* open)(struct drm_device *, struct drm_file *)
Definition drm_drv.h:236
void(* release)(struct drm_device *)
Definition drm_drv.h:279
char * desc
Definition drm_drv.h:422
char * name
Definition drm_drv.h:420
void(* master_set)(struct drm_device *dev, struct drm_file *file_priv, bool from_open)
Definition drm_drv.h:286
Definition drm_fb_helper.h:57
Definition drm_fb_helper.h:132
Definition drm_file.h:165
Definition drm_gem.h:277
Definition drm_ioctl.h:134
Definition drm_auth.h:47
Definition drm_file.h:78
Definition drm_mode.h:1249
Definition drm_print.h:181
Definition drm_device.h:44
Definition fs.h:67
Definition scatterlist.h:135