mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-19 11:07:39 +07:00
drm/vboxvideo: Replace struct vram_framebuffer with generic implemenation
The vboxvideo driver's struct vram_framebuffer stores a DRM framebuffer with an assiciated GEM object. This functionality is also provided by generic code. Switch vboxvideo over. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Sam Ravnborg <sam@ravnborg.org> Link: https://patchwork.freedesktop.org/patch/msgid/20191011134808.3955-4-tzimmermann@suse.de
This commit is contained in:
parent
1a74ccfac5
commit
7d79aa8628
@ -45,11 +45,6 @@
|
||||
sizeof(struct hgsmi_host_flags))
|
||||
#define HOST_FLAGS_OFFSET GUEST_HEAP_USABLE_SIZE
|
||||
|
||||
struct vbox_framebuffer {
|
||||
struct drm_framebuffer base;
|
||||
struct drm_gem_object *obj;
|
||||
};
|
||||
|
||||
struct vbox_private {
|
||||
/* Must be first; or we must define our own release callback */
|
||||
struct drm_device ddev;
|
||||
@ -132,7 +127,6 @@ struct vbox_encoder {
|
||||
#define to_vbox_crtc(x) container_of(x, struct vbox_crtc, base)
|
||||
#define to_vbox_connector(x) container_of(x, struct vbox_connector, base)
|
||||
#define to_vbox_encoder(x) container_of(x, struct vbox_encoder, base)
|
||||
#define to_vbox_framebuffer(x) container_of(x, struct vbox_framebuffer, base)
|
||||
|
||||
bool vbox_check_supported(u16 id);
|
||||
int vbox_hw_init(struct vbox_private *vbox);
|
||||
@ -143,17 +137,9 @@ void vbox_mode_fini(struct vbox_private *vbox);
|
||||
|
||||
void vbox_report_caps(struct vbox_private *vbox);
|
||||
|
||||
int vbox_framebuffer_init(struct vbox_private *vbox,
|
||||
struct vbox_framebuffer *vbox_fb,
|
||||
const struct drm_mode_fb_cmd2 *mode_cmd,
|
||||
struct drm_gem_object *obj);
|
||||
|
||||
int vbox_mm_init(struct vbox_private *vbox);
|
||||
void vbox_mm_fini(struct vbox_private *vbox);
|
||||
|
||||
int vbox_gem_create(struct vbox_private *vbox,
|
||||
u32 size, bool iskernel, struct drm_gem_object **obj);
|
||||
|
||||
/* vbox_irq.c */
|
||||
int vbox_irq_init(struct vbox_private *vbox);
|
||||
void vbox_irq_fini(struct vbox_private *vbox);
|
||||
|
@ -17,17 +17,6 @@
|
||||
#include "vboxvideo_guest.h"
|
||||
#include "vboxvideo_vbe.h"
|
||||
|
||||
static void vbox_user_framebuffer_destroy(struct drm_framebuffer *fb)
|
||||
{
|
||||
struct vbox_framebuffer *vbox_fb = to_vbox_framebuffer(fb);
|
||||
|
||||
if (vbox_fb->obj)
|
||||
drm_gem_object_put_unlocked(vbox_fb->obj);
|
||||
|
||||
drm_framebuffer_cleanup(fb);
|
||||
kfree(fb);
|
||||
}
|
||||
|
||||
void vbox_report_caps(struct vbox_private *vbox)
|
||||
{
|
||||
u32 caps = VBVACAPS_DISABLE_CURSOR_INTEGRATION |
|
||||
@ -39,29 +28,6 @@ void vbox_report_caps(struct vbox_private *vbox)
|
||||
hgsmi_send_caps_info(vbox->guest_pool, caps);
|
||||
}
|
||||
|
||||
static const struct drm_framebuffer_funcs vbox_fb_funcs = {
|
||||
.destroy = vbox_user_framebuffer_destroy,
|
||||
.dirty = drm_atomic_helper_dirtyfb,
|
||||
};
|
||||
|
||||
int vbox_framebuffer_init(struct vbox_private *vbox,
|
||||
struct vbox_framebuffer *vbox_fb,
|
||||
const struct drm_mode_fb_cmd2 *mode_cmd,
|
||||
struct drm_gem_object *obj)
|
||||
{
|
||||
int ret;
|
||||
|
||||
drm_helper_mode_fill_fb_struct(&vbox->ddev, &vbox_fb->base, mode_cmd);
|
||||
vbox_fb->obj = obj;
|
||||
ret = drm_framebuffer_init(&vbox->ddev, &vbox_fb->base, &vbox_fb_funcs);
|
||||
if (ret) {
|
||||
DRM_ERROR("framebuffer init failed %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vbox_accel_init(struct vbox_private *vbox)
|
||||
{
|
||||
struct vbva_buffer *vbva;
|
||||
@ -213,29 +179,3 @@ void vbox_hw_fini(struct vbox_private *vbox)
|
||||
gen_pool_destroy(vbox->guest_pool);
|
||||
pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
|
||||
}
|
||||
|
||||
int vbox_gem_create(struct vbox_private *vbox,
|
||||
u32 size, bool iskernel, struct drm_gem_object **obj)
|
||||
{
|
||||
struct drm_gem_vram_object *gbo;
|
||||
int ret;
|
||||
|
||||
*obj = NULL;
|
||||
|
||||
size = roundup(size, PAGE_SIZE);
|
||||
if (size == 0)
|
||||
return -EINVAL;
|
||||
|
||||
gbo = drm_gem_vram_create(&vbox->ddev, &vbox->ddev.vram_mm->bdev,
|
||||
size, 0, false);
|
||||
if (IS_ERR(gbo)) {
|
||||
ret = PTR_ERR(gbo);
|
||||
if (ret != -ERESTARTSYS)
|
||||
DRM_ERROR("failed to allocate GEM object\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
*obj = &gbo->bo.base;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <drm/drm_atomic_helper.h>
|
||||
#include <drm/drm_fb_helper.h>
|
||||
#include <drm/drm_fourcc.h>
|
||||
#include <drm/drm_gem_framebuffer_helper.h>
|
||||
#include <drm/drm_plane_helper.h>
|
||||
#include <drm/drm_probe_helper.h>
|
||||
#include <drm/drm_vblank.h>
|
||||
@ -173,8 +174,7 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
|
||||
struct drm_framebuffer *fb,
|
||||
int x, int y)
|
||||
{
|
||||
struct drm_gem_vram_object *gbo =
|
||||
drm_gem_vram_of_gem(to_vbox_framebuffer(fb)->obj);
|
||||
struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(fb->obj[0]);
|
||||
struct vbox_private *vbox = crtc->dev->dev_private;
|
||||
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
|
||||
bool needs_modeset = drm_atomic_crtc_needs_modeset(crtc->state);
|
||||
@ -343,7 +343,7 @@ static int vbox_primary_prepare_fb(struct drm_plane *plane,
|
||||
if (!new_state->fb)
|
||||
return 0;
|
||||
|
||||
gbo = drm_gem_vram_of_gem(to_vbox_framebuffer(new_state->fb)->obj);
|
||||
gbo = drm_gem_vram_of_gem(new_state->fb->obj[0]);
|
||||
ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM);
|
||||
if (ret)
|
||||
DRM_WARN("Error %d pinning new fb, out of video mem?\n", ret);
|
||||
@ -359,7 +359,7 @@ static void vbox_primary_cleanup_fb(struct drm_plane *plane,
|
||||
if (!old_state->fb)
|
||||
return;
|
||||
|
||||
gbo = drm_gem_vram_of_gem(to_vbox_framebuffer(old_state->fb)->obj);
|
||||
gbo = drm_gem_vram_of_gem(old_state->fb->obj[0]);
|
||||
drm_gem_vram_unpin(gbo);
|
||||
}
|
||||
|
||||
@ -420,8 +420,7 @@ static void vbox_cursor_atomic_update(struct drm_plane *plane,
|
||||
container_of(plane->dev, struct vbox_private, ddev);
|
||||
struct vbox_crtc *vbox_crtc = to_vbox_crtc(plane->state->crtc);
|
||||
struct drm_framebuffer *fb = plane->state->fb;
|
||||
struct drm_gem_vram_object *gbo =
|
||||
drm_gem_vram_of_gem(to_vbox_framebuffer(fb)->obj);
|
||||
struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(fb->obj[0]);
|
||||
u32 width = plane->state->crtc_w;
|
||||
u32 height = plane->state->crtc_h;
|
||||
size_t data_size, mask_size;
|
||||
@ -501,7 +500,7 @@ static int vbox_cursor_prepare_fb(struct drm_plane *plane,
|
||||
if (!new_state->fb)
|
||||
return 0;
|
||||
|
||||
gbo = drm_gem_vram_of_gem(to_vbox_framebuffer(new_state->fb)->obj);
|
||||
gbo = drm_gem_vram_of_gem(new_state->fb->obj[0]);
|
||||
return drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_SYSTEM);
|
||||
}
|
||||
|
||||
@ -513,7 +512,7 @@ static void vbox_cursor_cleanup_fb(struct drm_plane *plane,
|
||||
if (!plane->state->fb)
|
||||
return;
|
||||
|
||||
gbo = drm_gem_vram_of_gem(to_vbox_framebuffer(plane->state->fb)->obj);
|
||||
gbo = drm_gem_vram_of_gem(plane->state->fb->obj[0]);
|
||||
drm_gem_vram_unpin(gbo);
|
||||
}
|
||||
|
||||
@ -890,40 +889,8 @@ static int vbox_connector_init(struct drm_device *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct drm_framebuffer *vbox_user_framebuffer_create(
|
||||
struct drm_device *dev,
|
||||
struct drm_file *filp,
|
||||
const struct drm_mode_fb_cmd2 *mode_cmd)
|
||||
{
|
||||
struct vbox_private *vbox =
|
||||
container_of(dev, struct vbox_private, ddev);
|
||||
struct drm_gem_object *obj;
|
||||
struct vbox_framebuffer *vbox_fb;
|
||||
int ret = -ENOMEM;
|
||||
|
||||
obj = drm_gem_object_lookup(filp, mode_cmd->handles[0]);
|
||||
if (!obj)
|
||||
return ERR_PTR(-ENOENT);
|
||||
|
||||
vbox_fb = kzalloc(sizeof(*vbox_fb), GFP_KERNEL);
|
||||
if (!vbox_fb)
|
||||
goto err_unref_obj;
|
||||
|
||||
ret = vbox_framebuffer_init(vbox, vbox_fb, mode_cmd, obj);
|
||||
if (ret)
|
||||
goto err_free_vbox_fb;
|
||||
|
||||
return &vbox_fb->base;
|
||||
|
||||
err_free_vbox_fb:
|
||||
kfree(vbox_fb);
|
||||
err_unref_obj:
|
||||
drm_gem_object_put_unlocked(obj);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
static const struct drm_mode_config_funcs vbox_mode_funcs = {
|
||||
.fb_create = vbox_user_framebuffer_create,
|
||||
.fb_create = drm_gem_fb_create,
|
||||
.atomic_check = drm_atomic_helper_check,
|
||||
.atomic_commit = drm_atomic_helper_commit,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user