]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152
[mirror_ubuntu-eoan-kernel.git] / drivers / gpu / drm / hisilicon / hibmc / hibmc_drm_drv.h
CommitLineData
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
23struct hibmc_framebuffer {
24 struct drm_framebuffer fb;
25 struct drm_gem_object *obj;
26};
27
28struct 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
34struct 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
57struct 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
66static inline struct hibmc_bo *hibmc_bo(struct ttm_buffer_object *bo)
67{
68 return container_of(bo, struct hibmc_bo, bo);
69}
70
71static 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
76void hibmc_set_power_mode(struct hibmc_drm_private *priv,
77 unsigned int power_mode);
78void hibmc_set_current_gate(struct hibmc_drm_private *priv,
79 unsigned int gate);
80
da52605e 81int hibmc_de_init(struct hibmc_drm_private *priv);
5294967f 82int hibmc_vdac_init(struct hibmc_drm_private *priv);
d1667b86
RZ
83int hibmc_fbdev_init(struct hibmc_drm_private *priv);
84void hibmc_fbdev_fini(struct hibmc_drm_private *priv);
85
e4daebc7
RZ
86int hibmc_gem_create(struct drm_device *dev, u32 size, bool iskernel,
87 struct drm_gem_object **obj);
d1667b86
RZ
88struct hibmc_framebuffer *
89hibmc_framebuffer_init(struct drm_device *dev,
90 const struct drm_mode_fb_cmd2 *mode_cmd,
91 struct drm_gem_object *obj);
92
e4daebc7
RZ
93int hibmc_mm_init(struct hibmc_drm_private *hibmc);
94void hibmc_mm_fini(struct hibmc_drm_private *hibmc);
95int hibmc_bo_pin(struct hibmc_bo *bo, u32 pl_flag, u64 *gpu_addr);
96int hibmc_bo_unpin(struct hibmc_bo *bo);
97void hibmc_gem_free_object(struct drm_gem_object *obj);
98int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev,
99 struct drm_mode_create_dumb *args);
100int hibmc_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev,
101 u32 handle, u64 *offset);
102int hibmc_mmap(struct file *filp, struct vm_area_struct *vma);
103
da52605e
RZ
104extern const struct drm_mode_config_funcs hibmc_mode_funcs;
105
5e0df3a0 106#endif