Commit 132a4534 authored by Gerd Hoffmann's avatar Gerd Hoffmann

drm/bochs: add basic prime support

Just enough to make the generic framebuffer emulation happy.
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Reviewed-by: default avatarOleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20190111053752.4004-14-kraxel@redhat.com
parent 0bcdda5e
......@@ -145,6 +145,13 @@ int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev,
int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag);
int bochs_bo_unpin(struct bochs_bo *bo);
int bochs_gem_prime_pin(struct drm_gem_object *obj);
void bochs_gem_prime_unpin(struct drm_gem_object *obj);
void *bochs_gem_prime_vmap(struct drm_gem_object *obj);
void bochs_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
int bochs_gem_prime_mmap(struct drm_gem_object *obj,
struct vm_area_struct *vma);
/* bochs_kms.c */
int bochs_kms_init(struct bochs_device *bochs);
void bochs_kms_fini(struct bochs_device *bochs);
......
......@@ -81,7 +81,8 @@ static const struct file_operations bochs_fops = {
};
static struct drm_driver bochs_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
DRIVER_PRIME,
.fops = &bochs_fops,
.name = "bochs-drm",
.desc = "bochs dispi vga interface (qemu stdvga)",
......@@ -91,6 +92,14 @@ static struct drm_driver bochs_driver = {
.gem_free_object_unlocked = bochs_gem_free_object,
.dumb_create = bochs_dumb_create,
.dumb_map_offset = bochs_dumb_mmap_offset,
.gem_prime_export = drm_gem_prime_export,
.gem_prime_import = drm_gem_prime_import,
.gem_prime_pin = bochs_gem_prime_pin,
.gem_prime_unpin = bochs_gem_prime_unpin,
.gem_prime_vmap = bochs_gem_prime_vmap,
.gem_prime_vunmap = bochs_gem_prime_vunmap,
.gem_prime_mmap = bochs_gem_prime_mmap,
};
/* ---------------------------------------------------------------------- */
......
......@@ -395,3 +395,52 @@ int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev,
drm_gem_object_put_unlocked(obj);
return 0;
}
/* ---------------------------------------------------------------------- */
int bochs_gem_prime_pin(struct drm_gem_object *obj)
{
struct bochs_bo *bo = gem_to_bochs_bo(obj);
return bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
}
void bochs_gem_prime_unpin(struct drm_gem_object *obj)
{
struct bochs_bo *bo = gem_to_bochs_bo(obj);
bochs_bo_unpin(bo);
}
void *bochs_gem_prime_vmap(struct drm_gem_object *obj)
{
struct bochs_bo *bo = gem_to_bochs_bo(obj);
bool is_iomem;
int ret;
ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
if (ret)
return NULL;
ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
if (ret) {
bochs_bo_unpin(bo);
return NULL;
}
return ttm_kmap_obj_virtual(&bo->kmap, &is_iomem);
}
void bochs_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
{
struct bochs_bo *bo = gem_to_bochs_bo(obj);
ttm_bo_kunmap(&bo->kmap);
bochs_bo_unpin(bo);
}
int bochs_gem_prime_mmap(struct drm_gem_object *obj,
struct vm_area_struct *vma)
{
struct bochs_bo *bo = gem_to_bochs_bo(obj);
return ttm_fbdev_mmap(vma, &bo->bo);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment