drm_accel.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0
  2. *
  3. * Copyright 2022 HabanaLabs, Ltd.
  4. * All Rights Reserved.
  5. *
  6. */
  7. #ifndef DRM_ACCEL_H_
  8. #define DRM_ACCEL_H_
  9. #include <drm/drm_file.h>
  10. #define ACCEL_MAJOR 261
  11. #define ACCEL_MAX_MINORS 256
  12. /**
  13. * DRM_ACCEL_FOPS - Default drm accelerators file operations
  14. *
  15. * This macro provides a shorthand for setting the accelerator file ops in the
  16. * &file_operations structure. If all you need are the default ops, use
  17. * DEFINE_DRM_ACCEL_FOPS instead.
  18. */
  19. #define DRM_ACCEL_FOPS \
  20. .open = accel_open,\
  21. .release = drm_release,\
  22. .unlocked_ioctl = drm_ioctl,\
  23. .compat_ioctl = drm_compat_ioctl,\
  24. .poll = drm_poll,\
  25. .read = drm_read,\
  26. .llseek = noop_llseek, \
  27. .mmap = drm_gem_mmap, \
  28. .fop_flags = FOP_UNSIGNED_OFFSET
  29. /**
  30. * DEFINE_DRM_ACCEL_FOPS() - macro to generate file operations for accelerators drivers
  31. * @name: name for the generated structure
  32. *
  33. * This macro autogenerates a suitable &struct file_operations for accelerators based
  34. * drivers, which can be assigned to &drm_driver.fops. Note that this structure
  35. * cannot be shared between drivers, because it contains a reference to the
  36. * current module using THIS_MODULE.
  37. *
  38. * Note that the declaration is already marked as static - if you need a
  39. * non-static version of this you're probably doing it wrong and will break the
  40. * THIS_MODULE reference by accident.
  41. */
  42. #define DEFINE_DRM_ACCEL_FOPS(name) \
  43. static const struct file_operations name = {\
  44. .owner = THIS_MODULE,\
  45. DRM_ACCEL_FOPS,\
  46. }
  47. #if IS_ENABLED(CONFIG_DRM_ACCEL)
  48. extern struct xarray accel_minors_xa;
  49. void accel_core_exit(void);
  50. int accel_core_init(void);
  51. void accel_set_device_instance_params(struct device *kdev, int index);
  52. int accel_open(struct inode *inode, struct file *filp);
  53. void accel_debugfs_register(struct drm_device *dev);
  54. #else
  55. static inline void accel_core_exit(void)
  56. {
  57. }
  58. static inline int __init accel_core_init(void)
  59. {
  60. /* Return 0 to allow drm_core_init to complete successfully */
  61. return 0;
  62. }
  63. static inline void accel_set_device_instance_params(struct device *kdev, int index)
  64. {
  65. }
  66. static inline void accel_debugfs_register(struct drm_device *dev)
  67. {
  68. }
  69. #endif /* IS_ENABLED(CONFIG_DRM_ACCEL) */
  70. #endif /* DRM_ACCEL_H_ */