]>
Commit | Line | Data |
---|---|---|
2874c5fd | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
5e0df3a0 RZ |
2 | /* Hisilicon Hibmc SoC drm driver |
3 | * | |
4 | * Based on the bochs drm driver. | |
5 | * | |
6 | * Copyright (c) 2016 Huawei Limited. | |
7 | * | |
8 | * Author: | |
9 | * Rongrong Zou <zourongrong@huawei.com> | |
10 | * Rongrong Zou <zourongrong@gmail.com> | |
11 | * Jianhua Li <lijianhua@huawei.com> | |
5e0df3a0 RZ |
12 | */ |
13 | ||
14 | #ifndef HIBMC_DRM_DRV_H | |
15 | #define HIBMC_DRM_DRV_H | |
16 | ||
17 | #include <drm/drmP.h> | |
da52605e | 18 | #include <drm/drm_atomic.h> |
d1667b86 | 19 | #include <drm/drm_fb_helper.h> |
e4daebc7 RZ |
20 | #include <drm/drm_gem.h> |
21 | #include <drm/ttm/ttm_bo_driver.h> | |
5e0df3a0 | 22 | |
d1667b86 RZ |
23 | struct hibmc_framebuffer { |
24 | struct drm_framebuffer fb; | |
25 | struct drm_gem_object *obj; | |
26 | }; | |
27 | ||
28 | struct hibmc_fbdev { | |
2b617b14 | 29 | struct drm_fb_helper helper; /* must be first */ |
d1667b86 RZ |
30 | struct hibmc_framebuffer *fb; |
31 | int size; | |
32 | }; | |
33 | ||
5e0df3a0 RZ |
34 | struct hibmc_drm_private { |
35 | /* hw */ | |
36 | void __iomem *mmio; | |
37 | void __iomem *fb_map; | |
38 | unsigned long fb_base; | |
39 | unsigned long fb_size; | |
1d98b916 | 40 | bool msi_enabled; |
5e0df3a0 RZ |
41 | |
42 | /* drm */ | |
43 | struct drm_device *dev; | |
da52605e | 44 | bool mode_config_initialized; |
5e0df3a0 | 45 | |
e4daebc7 | 46 | /* ttm */ |
e4daebc7 RZ |
47 | struct ttm_bo_device bdev; |
48 | bool initialized; | |
49 | ||
d1667b86 RZ |
50 | /* fbdev */ |
51 | struct hibmc_fbdev *fbdev; | |
e4daebc7 RZ |
52 | bool mm_inited; |
53 | }; | |
54 | ||
d1667b86 RZ |
55 | #define to_hibmc_framebuffer(x) container_of(x, struct hibmc_framebuffer, fb) |
56 | ||
e4daebc7 RZ |
57 | struct hibmc_bo { |
58 | struct ttm_buffer_object bo; | |
59 | struct ttm_placement placement; | |
60 | struct ttm_bo_kmap_obj kmap; | |
61 | struct drm_gem_object gem; | |
62 | struct ttm_place placements[3]; | |
63 | int pin_count; | |
5e0df3a0 RZ |
64 | }; |
65 | ||
e4daebc7 RZ |
66 | static inline struct hibmc_bo *hibmc_bo(struct ttm_buffer_object *bo) |
67 | { | |
68 | return container_of(bo, struct hibmc_bo, bo); | |
69 | } | |
70 | ||
71 | static inline struct hibmc_bo *gem_to_hibmc_bo(struct drm_gem_object *gem) | |
72 | { | |
73 | return container_of(gem, struct hibmc_bo, gem); | |
74 | } | |
75 | ||
5e0df3a0 RZ |
76 | void hibmc_set_power_mode(struct hibmc_drm_private *priv, |
77 | unsigned int power_mode); | |
78 | void hibmc_set_current_gate(struct hibmc_drm_private *priv, | |
79 | unsigned int gate); | |
80 | ||
da52605e | 81 | int hibmc_de_init(struct hibmc_drm_private *priv); |
5294967f | 82 | int hibmc_vdac_init(struct hibmc_drm_private *priv); |
d1667b86 RZ |
83 | int hibmc_fbdev_init(struct hibmc_drm_private *priv); |
84 | void hibmc_fbdev_fini(struct hibmc_drm_private *priv); | |
85 | ||
e4daebc7 RZ |
86 | int hibmc_gem_create(struct drm_device *dev, u32 size, bool iskernel, |
87 | struct drm_gem_object **obj); | |
d1667b86 RZ |
88 | struct hibmc_framebuffer * |
89 | hibmc_framebuffer_init(struct drm_device *dev, | |
90 | const struct drm_mode_fb_cmd2 *mode_cmd, | |
91 | struct drm_gem_object *obj); | |
92 | ||
e4daebc7 RZ |
93 | int hibmc_mm_init(struct hibmc_drm_private *hibmc); |
94 | void hibmc_mm_fini(struct hibmc_drm_private *hibmc); | |
95 | int hibmc_bo_pin(struct hibmc_bo *bo, u32 pl_flag, u64 *gpu_addr); | |
96 | int hibmc_bo_unpin(struct hibmc_bo *bo); | |
97 | void hibmc_gem_free_object(struct drm_gem_object *obj); | |
98 | int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev, | |
99 | struct drm_mode_create_dumb *args); | |
100 | int hibmc_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev, | |
101 | u32 handle, u64 *offset); | |
102 | int hibmc_mmap(struct file *filp, struct vm_area_struct *vma); | |
103 | ||
da52605e RZ |
104 | extern const struct drm_mode_config_funcs hibmc_mode_funcs; |
105 | ||
5e0df3a0 | 106 | #endif |