Commit 6579c395 authored by Gerd Hoffmann's avatar Gerd Hoffmann

drm/bochs: atomic: switch planes to atomic, wire up helpers.

Conversion to atomic modesetting, step three.
Wire up atomic helpers.  Switch planes to atomic.

We are late to the party, the transitional helpers are gone,
so this can't be splitted into smaller steps any more.
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-6-kraxel@redhat.com
parent 63092001
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
#include "bochs.h" #include "bochs.h"
#include <drm/drm_atomic_helper.h>
#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
...@@ -149,6 +150,8 @@ bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file, ...@@ -149,6 +150,8 @@ bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file,
const struct drm_mode_config_funcs bochs_mode_funcs = { const struct drm_mode_config_funcs bochs_mode_funcs = {
.fb_create = bochs_gem_fb_create, .fb_create = bochs_gem_fb_create,
.atomic_check = drm_atomic_helper_check,
.atomic_commit = drm_atomic_helper_commit,
}; };
int bochs_fbdev_init(struct bochs_device *bochs) int bochs_fbdev_init(struct bochs_device *bochs)
......
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
*/ */
#include "bochs.h" #include "bochs.h"
#include <drm/drm_atomic_helper.h>
#include <drm/drm_plane_helper.h> #include <drm/drm_plane_helper.h>
#include <drm/drm_atomic_uapi.h>
static int defx = 1024; static int defx = 1024;
static int defy = 768; static int defy = 768;
...@@ -113,7 +115,7 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc, ...@@ -113,7 +115,7 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc,
struct drm_framebuffer *old_fb = crtc->primary->fb; struct drm_framebuffer *old_fb = crtc->primary->fb;
unsigned long irqflags; unsigned long irqflags;
crtc->primary->fb = fb; drm_atomic_set_fb_for_plane(crtc->primary->state, fb);
bochs_crtc_mode_set_base(crtc, 0, 0, old_fb); bochs_crtc_mode_set_base(crtc, 0, 0, old_fb);
if (event) { if (event) {
spin_lock_irqsave(&bochs->dev->event_lock, irqflags); spin_lock_irqsave(&bochs->dev->event_lock, irqflags);
...@@ -151,6 +153,9 @@ static const struct drm_crtc_funcs bochs_crtc_funcs = { ...@@ -151,6 +153,9 @@ static const struct drm_crtc_funcs bochs_crtc_funcs = {
.set_config = drm_crtc_helper_set_config, .set_config = drm_crtc_helper_set_config,
.destroy = drm_crtc_cleanup, .destroy = drm_crtc_cleanup,
.page_flip = bochs_crtc_page_flip, .page_flip = bochs_crtc_page_flip,
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
}; };
static const struct drm_crtc_helper_funcs bochs_helper_funcs = { static const struct drm_crtc_helper_funcs bochs_helper_funcs = {
...@@ -169,6 +174,71 @@ static const uint32_t bochs_formats[] = { ...@@ -169,6 +174,71 @@ static const uint32_t bochs_formats[] = {
DRM_FORMAT_BGRX8888, DRM_FORMAT_BGRX8888,
}; };
static void bochs_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
{
struct bochs_device *bochs = plane->dev->dev_private;
struct bochs_bo *bo;
if (!plane->state->fb)
return;
bo = gem_to_bochs_bo(plane->state->fb->obj[0]);
bochs_hw_setbase(bochs,
plane->state->crtc_x,
plane->state->crtc_y,
bo->bo.offset);
bochs_hw_setformat(bochs, plane->state->fb->format);
}
static int bochs_plane_prepare_fb(struct drm_plane *plane,
struct drm_plane_state *new_state)
{
struct bochs_bo *bo;
int ret;
if (!new_state->fb)
return 0;
bo = gem_to_bochs_bo(new_state->fb->obj[0]);
ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
if (ret)
return ret;
ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM, NULL);
ttm_bo_unreserve(&bo->bo);
return ret;
}
static void bochs_plane_cleanup_fb(struct drm_plane *plane,
struct drm_plane_state *old_state)
{
struct bochs_bo *bo;
int ret;
if (!old_state->fb)
return;
bo = gem_to_bochs_bo(old_state->fb->obj[0]);
ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
if (ret)
return;
bochs_bo_unpin(bo);
ttm_bo_unreserve(&bo->bo);
}
static const struct drm_plane_helper_funcs bochs_plane_helper_funcs = {
.atomic_update = bochs_plane_atomic_update,
.prepare_fb = bochs_plane_prepare_fb,
.cleanup_fb = bochs_plane_cleanup_fb,
};
static const struct drm_plane_funcs bochs_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
.destroy = drm_primary_helper_destroy,
.reset = drm_atomic_helper_plane_reset,
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
};
static struct drm_plane *bochs_primary_plane(struct drm_device *dev) static struct drm_plane *bochs_primary_plane(struct drm_device *dev)
{ {
struct drm_plane *primary; struct drm_plane *primary;
...@@ -181,16 +251,17 @@ static struct drm_plane *bochs_primary_plane(struct drm_device *dev) ...@@ -181,16 +251,17 @@ static struct drm_plane *bochs_primary_plane(struct drm_device *dev)
} }
ret = drm_universal_plane_init(dev, primary, 0, ret = drm_universal_plane_init(dev, primary, 0,
&drm_primary_helper_funcs, &bochs_plane_funcs,
bochs_formats, bochs_formats,
ARRAY_SIZE(bochs_formats), ARRAY_SIZE(bochs_formats),
NULL, NULL,
DRM_PLANE_TYPE_PRIMARY, NULL); DRM_PLANE_TYPE_PRIMARY, NULL);
if (ret) { if (ret) {
kfree(primary); kfree(primary);
primary = NULL; return NULL;
} }
drm_plane_helper_add(primary, &bochs_plane_helper_funcs);
return primary; return primary;
} }
...@@ -275,6 +346,9 @@ static const struct drm_connector_funcs bochs_connector_connector_funcs = { ...@@ -275,6 +346,9 @@ static const struct drm_connector_funcs bochs_connector_connector_funcs = {
.dpms = drm_helper_connector_dpms, .dpms = drm_helper_connector_dpms,
.fill_modes = drm_helper_probe_single_connector_modes, .fill_modes = drm_helper_probe_single_connector_modes,
.destroy = drm_connector_cleanup, .destroy = drm_connector_cleanup,
.reset = drm_atomic_helper_connector_reset,
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
}; };
static void bochs_connector_init(struct drm_device *dev) static void bochs_connector_init(struct drm_device *dev)
...@@ -318,6 +392,8 @@ int bochs_kms_init(struct bochs_device *bochs) ...@@ -318,6 +392,8 @@ int bochs_kms_init(struct bochs_device *bochs)
drm_connector_attach_encoder(&bochs->connector, drm_connector_attach_encoder(&bochs->connector,
&bochs->encoder); &bochs->encoder);
drm_mode_config_reset(bochs->dev);
return 0; return 0;
} }
......
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