drm/verisilicon: Add basic drm driver
[platform/kernel/linux-starfive.git] / drivers / gpu / drm / verisilicon / vs_drv.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2023 VeriSilicon Holdings Co., Ltd.
4  */
5
6 #ifndef __VS_DRV_H__
7 #define __VS_DRV_H__
8
9 #include <linux/module.h>
10 #include <linux/platform_device.h>
11 #include <linux/version.h>
12 #include <drm/drm_drv.h>
13 #include <drm/drm_gem.h>
14
15 /*
16  *
17  * @dma_dev: device for DMA API.
18  *      - use the first attached device if support iommu
19         else use drm device (only contiguous buffer support)
20  * @domain: iommu domain for DRM.
21  *      - all DC IOMMU share same domain to reduce mapping
22  * @pitch_alignment: buffer pitch alignment required by sub-devices.
23  *
24  */
25 struct vs_drm_private {
26         struct device *dma_dev;
27         struct iommu_domain *domain;
28         unsigned int pitch_alignment;
29 };
30
31 void vs_drm_update_pitch_alignment(struct drm_device *drm_dev,
32                                    unsigned int alignment);
33
34 static inline struct device *to_dma_dev(struct drm_device *dev)
35 {
36         struct vs_drm_private *priv = dev->dev_private;
37
38         return priv->dma_dev;
39 }
40
41 static inline bool is_iommu_enabled(struct drm_device *dev)
42 {
43         struct vs_drm_private *priv = dev->dev_private;
44
45         return priv->domain ? true : false;
46 }
47
48 #endif /* __VS_DRV_H__ */