vs_drv.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2020 VeriSilicon Holdings Co., Ltd.
  4. */
  5. #ifndef __VS_DRV_H__
  6. #define __VS_DRV_H__
  7. #include <linux/module.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/version.h>
  10. #include <drm/drm_gem.h>
  11. #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0)
  12. #include <drm/drmP.h>
  13. #endif
  14. #include "vs_plane.h"
  15. #ifdef CONFIG_VERISILICON_MMU
  16. #include "vs_dc_mmu.h"
  17. #endif
  18. /*
  19. *
  20. * @dma_dev: device for DMA API.
  21. * - use the first attached device if support iommu
  22. else use drm device (only contiguous buffer support)
  23. * @domain: iommu domain for DRM.
  24. * - all DC IOMMU share same domain to reduce mapping
  25. * @pitch_alignment: buffer pitch alignment required by sub-devices.
  26. *
  27. */
  28. struct vs_drm_private {
  29. struct device *dma_dev;
  30. struct iommu_domain *domain;
  31. #ifdef CONFIG_VERISILICON_MMU
  32. dc_mmu *mmu;
  33. #endif
  34. unsigned int pitch_alignment;
  35. };
  36. int vs_drm_iommu_attach_device(struct drm_device *drm_dev,
  37. struct device *dev);
  38. void vs_drm_iommu_detach_device(struct drm_device *drm_dev,
  39. struct device *dev);
  40. void vs_drm_update_pitch_alignment(struct drm_device *drm_dev,
  41. unsigned int alignment);
  42. static inline struct device *to_dma_dev(struct drm_device *dev)
  43. {
  44. struct vs_drm_private *priv = dev->dev_private;
  45. return priv->dma_dev;
  46. }
  47. static inline bool is_iommu_enabled(struct drm_device *dev)
  48. {
  49. struct vs_drm_private *priv = dev->dev_private;
  50. return priv->domain != NULL ? true : false;
  51. }
  52. #endif /* __VS_DRV_H__ */