Linux Audio

Check our new training course

Linux kernel drivers training

Mar 31-Apr 9, 2025, special US time zones
Register
Loading...
v6.2
 1/* SPDX-License-Identifier: GPL-2.0
 2 *
 3 * Copyright 2022 HabanaLabs, Ltd.
 4 * All Rights Reserved.
 5 *
 6 */
 7
 8#ifndef DRM_ACCEL_H_
 9#define DRM_ACCEL_H_
10
11#include <drm/drm_file.h>
12
13#define ACCEL_MAJOR		261
14#define ACCEL_MAX_MINORS	256
15
16/**
17 * DRM_ACCEL_FOPS - Default drm accelerators file operations
18 *
19 * This macro provides a shorthand for setting the accelerator file ops in the
20 * &file_operations structure.  If all you need are the default ops, use
21 * DEFINE_DRM_ACCEL_FOPS instead.
22 */
23#define DRM_ACCEL_FOPS \
24	.open		= accel_open,\
25	.release	= drm_release,\
26	.unlocked_ioctl	= drm_ioctl,\
27	.compat_ioctl	= drm_compat_ioctl,\
28	.poll		= drm_poll,\
29	.read		= drm_read,\
30	.llseek		= noop_llseek
 
31
32/**
33 * DEFINE_DRM_ACCEL_FOPS() - macro to generate file operations for accelerators drivers
34 * @name: name for the generated structure
35 *
36 * This macro autogenerates a suitable &struct file_operations for accelerators based
37 * drivers, which can be assigned to &drm_driver.fops. Note that this structure
38 * cannot be shared between drivers, because it contains a reference to the
39 * current module using THIS_MODULE.
40 *
41 * Note that the declaration is already marked as static - if you need a
42 * non-static version of this you're probably doing it wrong and will break the
43 * THIS_MODULE reference by accident.
44 */
45#define DEFINE_DRM_ACCEL_FOPS(name) \
46	static const struct file_operations name = {\
47		.owner		= THIS_MODULE,\
48		DRM_ACCEL_FOPS,\
49	}
50
51#if IS_ENABLED(CONFIG_DRM_ACCEL)
52
53void accel_core_exit(void);
54int accel_core_init(void);
55void accel_minor_remove(int index);
56int accel_minor_alloc(void);
57void accel_minor_replace(struct drm_minor *minor, int index);
58void accel_set_device_instance_params(struct device *kdev, int index);
59int accel_open(struct inode *inode, struct file *filp);
60void accel_debugfs_init(struct drm_minor *minor, int minor_id);
 
61
62#else
63
64static inline void accel_core_exit(void)
65{
66}
67
68static inline int __init accel_core_init(void)
69{
70	/* Return 0 to allow drm_core_init to complete successfully */
71	return 0;
72}
73
74static inline void accel_minor_remove(int index)
75{
76}
77
78static inline int accel_minor_alloc(void)
79{
80	return -EOPNOTSUPP;
81}
82
83static inline void accel_minor_replace(struct drm_minor *minor, int index)
84{
85}
86
87static inline void accel_set_device_instance_params(struct device *kdev, int index)
88{
89}
90
91static inline void accel_debugfs_init(struct drm_minor *minor, int minor_id)
 
 
 
 
92{
93}
94
95#endif /* IS_ENABLED(CONFIG_DRM_ACCEL) */
96
97#endif /* DRM_ACCEL_H_ */
v6.9.4
  1/* SPDX-License-Identifier: GPL-2.0
  2 *
  3 * Copyright 2022 HabanaLabs, Ltd.
  4 * All Rights Reserved.
  5 *
  6 */
  7
  8#ifndef DRM_ACCEL_H_
  9#define DRM_ACCEL_H_
 10
 11#include <drm/drm_file.h>
 12
 13#define ACCEL_MAJOR		261
 14#define ACCEL_MAX_MINORS	256
 15
 16/**
 17 * DRM_ACCEL_FOPS - Default drm accelerators file operations
 18 *
 19 * This macro provides a shorthand for setting the accelerator file ops in the
 20 * &file_operations structure.  If all you need are the default ops, use
 21 * DEFINE_DRM_ACCEL_FOPS instead.
 22 */
 23#define DRM_ACCEL_FOPS \
 24	.open		= accel_open,\
 25	.release	= drm_release,\
 26	.unlocked_ioctl	= drm_ioctl,\
 27	.compat_ioctl	= drm_compat_ioctl,\
 28	.poll		= drm_poll,\
 29	.read		= drm_read,\
 30	.llseek		= noop_llseek, \
 31	.mmap		= drm_gem_mmap
 32
 33/**
 34 * DEFINE_DRM_ACCEL_FOPS() - macro to generate file operations for accelerators drivers
 35 * @name: name for the generated structure
 36 *
 37 * This macro autogenerates a suitable &struct file_operations for accelerators based
 38 * drivers, which can be assigned to &drm_driver.fops. Note that this structure
 39 * cannot be shared between drivers, because it contains a reference to the
 40 * current module using THIS_MODULE.
 41 *
 42 * Note that the declaration is already marked as static - if you need a
 43 * non-static version of this you're probably doing it wrong and will break the
 44 * THIS_MODULE reference by accident.
 45 */
 46#define DEFINE_DRM_ACCEL_FOPS(name) \
 47	static const struct file_operations name = {\
 48		.owner		= THIS_MODULE,\
 49		DRM_ACCEL_FOPS,\
 50	}
 51
 52#if IS_ENABLED(CONFIG_DRM_ACCEL)
 53
 54void accel_core_exit(void);
 55int accel_core_init(void);
 56void accel_minor_remove(int index);
 57int accel_minor_alloc(void);
 58void accel_minor_replace(struct drm_minor *minor, int index);
 59void accel_set_device_instance_params(struct device *kdev, int index);
 60int accel_open(struct inode *inode, struct file *filp);
 61void accel_debugfs_init(struct drm_device *dev);
 62void accel_debugfs_register(struct drm_device *dev);
 63
 64#else
 65
 66static inline void accel_core_exit(void)
 67{
 68}
 69
 70static inline int __init accel_core_init(void)
 71{
 72	/* Return 0 to allow drm_core_init to complete successfully */
 73	return 0;
 74}
 75
 76static inline void accel_minor_remove(int index)
 77{
 78}
 79
 80static inline int accel_minor_alloc(void)
 81{
 82	return -EOPNOTSUPP;
 83}
 84
 85static inline void accel_minor_replace(struct drm_minor *minor, int index)
 86{
 87}
 88
 89static inline void accel_set_device_instance_params(struct device *kdev, int index)
 90{
 91}
 92
 93static inline void accel_debugfs_init(struct drm_device *dev)
 94{
 95}
 96
 97static inline void accel_debugfs_register(struct drm_device *dev)
 98{
 99}
100
101#endif /* IS_ENABLED(CONFIG_DRM_ACCEL) */
102
103#endif /* DRM_ACCEL_H_ */