1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 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> 12 */ 13 14 #ifndef HIBMC_DRM_DRV_H 15 #define HIBMC_DRM_DRV_H 16 17 #include <drm/drmP.h> 18 #include <drm/drm_atomic.h> 19 #include <drm/drm_fb_helper.h> 20 #include <drm/drm_gem.h> 21 #include <drm/drm_gem_vram_helper.h> 22 #include <drm/drm_vram_mm_helper.h> 23 24 struct hibmc_framebuffer { 25 struct drm_framebuffer fb; 26 struct drm_gem_object *obj; 27 }; 28 29 struct hibmc_fbdev { 30 struct drm_fb_helper helper; /* must be first */ 31 struct hibmc_framebuffer *fb; 32 int size; 33 }; 34 35 struct hibmc_drm_private { 36 /* hw */ 37 void __iomem *mmio; 38 void __iomem *fb_map; 39 unsigned long fb_base; 40 unsigned long fb_size; 41 bool msi_enabled; 42 43 /* drm */ 44 struct drm_device *dev; 45 bool mode_config_initialized; 46 47 /* fbdev */ 48 struct hibmc_fbdev *fbdev; 49 }; 50 51 #define to_hibmc_framebuffer(x) container_of(x, struct hibmc_framebuffer, fb) 52 53 void hibmc_set_power_mode(struct hibmc_drm_private *priv, 54 unsigned int power_mode); 55 void hibmc_set_current_gate(struct hibmc_drm_private *priv, 56 unsigned int gate); 57 58 int hibmc_de_init(struct hibmc_drm_private *priv); 59 int hibmc_vdac_init(struct hibmc_drm_private *priv); 60 int hibmc_fbdev_init(struct hibmc_drm_private *priv); 61 void hibmc_fbdev_fini(struct hibmc_drm_private *priv); 62 63 int hibmc_gem_create(struct drm_device *dev, u32 size, bool iskernel, 64 struct drm_gem_object **obj); 65 struct hibmc_framebuffer * 66 hibmc_framebuffer_init(struct drm_device *dev, 67 const struct drm_mode_fb_cmd2 *mode_cmd, 68 struct drm_gem_object *obj); 69 70 int hibmc_mm_init(struct hibmc_drm_private *hibmc); 71 void hibmc_mm_fini(struct hibmc_drm_private *hibmc); 72 int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev, 73 struct drm_mode_create_dumb *args); 74 75 extern const struct drm_mode_config_funcs hibmc_mode_funcs; 76 77 #endif 78