1 /* Hisilicon Hibmc SoC drm driver
3 * Based on the bochs drm driver.
5 * Copyright (c) 2016 Huawei Limited.
8 * Rongrong Zou <zourongrong@huawei.com>
9 * Rongrong Zou <zourongrong@gmail.com>
10 * Jianhua Li <lijianhua@huawei.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
19 #ifndef HIBMC_DRM_DRV_H
20 #define HIBMC_DRM_DRV_H
23 #include <drm/drm_atomic.h>
24 #include <drm/drm_fb_helper.h>
25 #include <drm/drm_gem.h>
26 #include <drm/ttm/ttm_bo_driver.h>
28 struct hibmc_framebuffer
{
29 struct drm_framebuffer fb
;
30 struct drm_gem_object
*obj
;
34 struct drm_fb_helper helper
;
35 struct hibmc_framebuffer
*fb
;
39 struct hibmc_drm_private
{
43 unsigned long fb_base
;
44 unsigned long fb_size
;
48 struct drm_device
*dev
;
49 bool mode_config_initialized
;
50 struct drm_atomic_state
*suspend_state
;
53 struct drm_global_reference mem_global_ref
;
54 struct ttm_bo_global_ref bo_global_ref
;
55 struct ttm_bo_device bdev
;
59 struct hibmc_fbdev
*fbdev
;
63 #define to_hibmc_framebuffer(x) container_of(x, struct hibmc_framebuffer, fb)
66 struct ttm_buffer_object bo
;
67 struct ttm_placement placement
;
68 struct ttm_bo_kmap_obj kmap
;
69 struct drm_gem_object gem
;
70 struct ttm_place placements
[3];
74 static inline struct hibmc_bo
*hibmc_bo(struct ttm_buffer_object
*bo
)
76 return container_of(bo
, struct hibmc_bo
, bo
);
79 static inline struct hibmc_bo
*gem_to_hibmc_bo(struct drm_gem_object
*gem
)
81 return container_of(gem
, struct hibmc_bo
, gem
);
84 void hibmc_set_power_mode(struct hibmc_drm_private
*priv
,
85 unsigned int power_mode
);
86 void hibmc_set_current_gate(struct hibmc_drm_private
*priv
,
89 int hibmc_de_init(struct hibmc_drm_private
*priv
);
90 int hibmc_vdac_init(struct hibmc_drm_private
*priv
);
91 int hibmc_fbdev_init(struct hibmc_drm_private
*priv
);
92 void hibmc_fbdev_fini(struct hibmc_drm_private
*priv
);
94 int hibmc_gem_create(struct drm_device
*dev
, u32 size
, bool iskernel
,
95 struct drm_gem_object
**obj
);
96 struct hibmc_framebuffer
*
97 hibmc_framebuffer_init(struct drm_device
*dev
,
98 const struct drm_mode_fb_cmd2
*mode_cmd
,
99 struct drm_gem_object
*obj
);
101 int hibmc_mm_init(struct hibmc_drm_private
*hibmc
);
102 void hibmc_mm_fini(struct hibmc_drm_private
*hibmc
);
103 int hibmc_bo_pin(struct hibmc_bo
*bo
, u32 pl_flag
, u64
*gpu_addr
);
104 int hibmc_bo_unpin(struct hibmc_bo
*bo
);
105 void hibmc_gem_free_object(struct drm_gem_object
*obj
);
106 int hibmc_dumb_create(struct drm_file
*file
, struct drm_device
*dev
,
107 struct drm_mode_create_dumb
*args
);
108 int hibmc_dumb_mmap_offset(struct drm_file
*file
, struct drm_device
*dev
,
109 u32 handle
, u64
*offset
);
110 int hibmc_mmap(struct file
*filp
, struct vm_area_struct
*vma
);
112 extern const struct drm_mode_config_funcs hibmc_mode_funcs
;