1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Hisilicon Hibmc SoC drm driver
4 * Based on the bochs drm driver.
6 * Copyright (c) 2016 Huawei Limited.
9 * Rongrong Zou <zourongrong@huawei.com>
10 * Rongrong Zou <zourongrong@gmail.com>
11 * Jianhua Li <lijianhua@huawei.com>
14 #include <linux/pci.h>
16 #include <drm/drm_atomic_helper.h>
17 #include <drm/drm_gem.h>
18 #include <drm/drm_gem_framebuffer_helper.h>
19 #include <drm/drm_gem_vram_helper.h>
20 #include <drm/drm_print.h>
22 #include "hibmc_drm_drv.h"
24 int hibmc_mm_init(struct hibmc_drm_private
*hibmc
)
26 struct drm_vram_mm
*vmm
;
28 struct drm_device
*dev
= hibmc
->dev
;
30 vmm
= drm_vram_helper_alloc_mm(dev
,
31 pci_resource_start(dev
->pdev
, 0),
35 drm_err(dev
, "Error initializing VRAM MM; %d\n", ret
);
42 void hibmc_mm_fini(struct hibmc_drm_private
*hibmc
)
44 if (!hibmc
->dev
->vram_mm
)
47 drm_vram_helper_release_mm(hibmc
->dev
);
50 int hibmc_dumb_create(struct drm_file
*file
, struct drm_device
*dev
,
51 struct drm_mode_create_dumb
*args
)
53 return drm_gem_vram_fill_create_dumb(file
, dev
, 0, 128, args
);
56 const struct drm_mode_config_funcs hibmc_mode_funcs
= {
57 .mode_valid
= drm_vram_helper_mode_valid
,
58 .atomic_check
= drm_atomic_helper_check
,
59 .atomic_commit
= drm_atomic_helper_commit
,
60 .fb_create
= drm_gem_fb_create
,