2019-05-27 13:55:01 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2016-11-16 20:31:51 +07:00
|
|
|
/* Hisilicon Hibmc SoC drm driver
|
|
|
|
*
|
|
|
|
* Based on the bochs drm driver.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016 Huawei Limited.
|
|
|
|
*
|
|
|
|
* Author:
|
|
|
|
* Rongrong Zou <zourongrong@huawei.com>
|
|
|
|
* Rongrong Zou <zourongrong@gmail.com>
|
|
|
|
* Jianhua Li <lijianhua@huawei.com>
|
|
|
|
*/
|
|
|
|
|
2019-06-30 13:19:22 +07:00
|
|
|
#include <linux/pci.h>
|
|
|
|
|
2016-11-16 19:52:37 +07:00
|
|
|
#include <drm/drm_atomic_helper.h>
|
2019-06-30 13:19:22 +07:00
|
|
|
#include <drm/drm_gem.h>
|
2019-12-03 15:38:16 +07:00
|
|
|
#include <drm/drm_gem_framebuffer_helper.h>
|
2019-06-30 13:19:22 +07:00
|
|
|
#include <drm/drm_gem_vram_helper.h>
|
|
|
|
#include <drm/drm_print.h>
|
2016-11-16 20:31:51 +07:00
|
|
|
|
|
|
|
#include "hibmc_drm_drv.h"
|
|
|
|
|
|
|
|
int hibmc_mm_init(struct hibmc_drm_private *hibmc)
|
|
|
|
{
|
2019-05-08 15:26:30 +07:00
|
|
|
struct drm_vram_mm *vmm;
|
2016-11-16 20:31:51 +07:00
|
|
|
int ret;
|
|
|
|
struct drm_device *dev = hibmc->dev;
|
|
|
|
|
2019-05-08 15:26:30 +07:00
|
|
|
vmm = drm_vram_helper_alloc_mm(dev,
|
|
|
|
pci_resource_start(dev->pdev, 0),
|
2019-09-11 18:09:08 +07:00
|
|
|
hibmc->fb_size);
|
2019-05-08 15:26:30 +07:00
|
|
|
if (IS_ERR(vmm)) {
|
|
|
|
ret = PTR_ERR(vmm);
|
|
|
|
DRM_ERROR("Error initializing VRAM MM; %d\n", ret);
|
2016-11-16 20:31:51 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void hibmc_mm_fini(struct hibmc_drm_private *hibmc)
|
|
|
|
{
|
2019-05-08 15:26:30 +07:00
|
|
|
if (!hibmc->dev->vram_mm)
|
2016-11-16 20:31:51 +07:00
|
|
|
return;
|
|
|
|
|
2019-05-08 15:26:30 +07:00
|
|
|
drm_vram_helper_release_mm(hibmc->dev);
|
2016-11-16 20:31:51 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev,
|
|
|
|
struct drm_mode_create_dumb *args)
|
|
|
|
{
|
2020-03-06 10:43:01 +07:00
|
|
|
return drm_gem_vram_fill_create_dumb(file, dev, 0, 128, args);
|
2016-11-16 20:31:51 +07:00
|
|
|
}
|
|
|
|
|
2016-11-16 19:54:52 +07:00
|
|
|
const struct drm_mode_config_funcs hibmc_mode_funcs = {
|
2020-02-03 22:52:57 +07:00
|
|
|
.mode_valid = drm_vram_helper_mode_valid,
|
2016-11-16 19:54:52 +07:00
|
|
|
.atomic_check = drm_atomic_helper_check,
|
|
|
|
.atomic_commit = drm_atomic_helper_commit,
|
2019-12-03 15:38:16 +07:00
|
|
|
.fb_create = drm_gem_fb_create,
|
2016-11-16 19:54:52 +07:00
|
|
|
};
|