Commit a278724a authored by Thomas Hellstrom's avatar Thomas Hellstrom

drm/vmwgfx: Implement fbdev on kms v2

With screen targets the old legacy display system fbdev doesn't work
satisfactory anymore. At best the resolution is severely restricted.
Therefore implement fbdev on top of the kms system. With this change, fbdev
will be using whatever KMS backend is chosen.

There are helpers available for this, so in the future we'd probably want
to implement the helper callbacks instead of calling into our KMS
implementation directly.

v2: Make sure we take the mode_config mutex around modesetting,
Also clear the initial framebuffer using vzalloc instead of vmalloc.
Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: default avatarSinclair Yeh <syeh@vmware.com>
parent fd006a43
...@@ -1120,23 +1120,6 @@ static long vmw_compat_ioctl(struct file *filp, unsigned int cmd, ...@@ -1120,23 +1120,6 @@ static long vmw_compat_ioctl(struct file *filp, unsigned int cmd,
static void vmw_lastclose(struct drm_device *dev) static void vmw_lastclose(struct drm_device *dev)
{ {
struct drm_crtc *crtc;
struct drm_mode_set set;
int ret;
set.x = 0;
set.y = 0;
set.fb = NULL;
set.mode = NULL;
set.connectors = NULL;
set.num_connectors = 0;
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
set.crtc = crtc;
ret = drm_mode_set_config_internal(&set);
WARN_ON(ret != 0);
}
} }
static void vmw_master_init(struct vmw_master *vmaster) static void vmw_master_init(struct vmw_master *vmaster)
...@@ -1321,6 +1304,8 @@ static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val, ...@@ -1321,6 +1304,8 @@ static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
switch (val) { switch (val) {
case PM_HIBERNATION_PREPARE: case PM_HIBERNATION_PREPARE:
if (dev_priv->enable_fb)
vmw_fb_off(dev_priv);
ttm_suspend_lock(&dev_priv->reservation_sem); ttm_suspend_lock(&dev_priv->reservation_sem);
/* /*
...@@ -1337,7 +1322,8 @@ static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val, ...@@ -1337,7 +1322,8 @@ static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
case PM_POST_RESTORE: case PM_POST_RESTORE:
vmw_fence_fifo_up(dev_priv->fman); vmw_fence_fifo_up(dev_priv->fman);
ttm_suspend_unlock(&dev_priv->reservation_sem); ttm_suspend_unlock(&dev_priv->reservation_sem);
if (dev_priv->enable_fb)
vmw_fb_on(dev_priv);
break; break;
case PM_RESTORE_PREPARE: case PM_RESTORE_PREPARE:
break; break;
......
This diff is collapsed.
...@@ -372,7 +372,8 @@ static void vmw_framebuffer_surface_destroy(struct drm_framebuffer *framebuffer) ...@@ -372,7 +372,8 @@ static void vmw_framebuffer_surface_destroy(struct drm_framebuffer *framebuffer)
drm_framebuffer_cleanup(framebuffer); drm_framebuffer_cleanup(framebuffer);
vmw_surface_unreference(&vfbs->surface); vmw_surface_unreference(&vfbs->surface);
ttm_base_object_unref(&vfbs->base.user_obj); if (vfbs->base.user_obj)
ttm_base_object_unref(&vfbs->base.user_obj);
kfree(vfbs); kfree(vfbs);
} }
...@@ -582,7 +583,8 @@ static void vmw_framebuffer_dmabuf_destroy(struct drm_framebuffer *framebuffer) ...@@ -582,7 +583,8 @@ static void vmw_framebuffer_dmabuf_destroy(struct drm_framebuffer *framebuffer)
drm_framebuffer_cleanup(framebuffer); drm_framebuffer_cleanup(framebuffer);
vmw_dmabuf_unreference(&vfbd->buffer); vmw_dmabuf_unreference(&vfbd->buffer);
ttm_base_object_unref(&vfbd->base.user_obj); if (vfbd->base.user_obj)
ttm_base_object_unref(&vfbd->base.user_obj);
kfree(vfbd); kfree(vfbd);
} }
...@@ -1462,7 +1464,7 @@ static struct drm_display_mode vmw_kms_connector_builtin[] = { ...@@ -1462,7 +1464,7 @@ static struct drm_display_mode vmw_kms_connector_builtin[] = {
* @mode - Pointer to a struct drm_display_mode with hdisplay and vdisplay * @mode - Pointer to a struct drm_display_mode with hdisplay and vdisplay
* members filled in. * members filled in.
*/ */
static void vmw_guess_mode_timing(struct drm_display_mode *mode) void vmw_guess_mode_timing(struct drm_display_mode *mode)
{ {
mode->hsync_start = mode->hdisplay + 50; mode->hsync_start = mode->hdisplay + 50;
mode->hsync_end = mode->hsync_start + 50; mode->hsync_end = mode->hsync_start + 50;
...@@ -2001,3 +2003,58 @@ int vmw_kms_update_proxy(struct vmw_resource *res, ...@@ -2001,3 +2003,58 @@ int vmw_kms_update_proxy(struct vmw_resource *res,
return 0; return 0;
} }
int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv,
unsigned unit,
u32 max_width,
u32 max_height,
struct drm_connector **p_con,
struct drm_crtc **p_crtc,
struct drm_display_mode **p_mode)
{
struct drm_connector *con;
struct vmw_display_unit *du;
struct drm_display_mode *mode;
int i = 0;
list_for_each_entry(con, &dev_priv->dev->mode_config.connector_list,
head) {
if (i == unit)
break;
++i;
}
if (i != unit) {
DRM_ERROR("Could not find initial display unit.\n");
return -EINVAL;
}
if (list_empty(&con->modes))
(void) vmw_du_connector_fill_modes(con, max_width, max_height);
if (list_empty(&con->modes)) {
DRM_ERROR("Could not find initial display mode.\n");
return -EINVAL;
}
du = vmw_connector_to_du(con);
*p_con = con;
*p_crtc = &du->crtc;
list_for_each_entry(mode, &con->modes, head) {
if (mode->type & DRM_MODE_TYPE_PREFERRED)
break;
}
if (mode->type & DRM_MODE_TYPE_PREFERRED)
*p_mode = mode;
else {
WARN_ONCE(true, "Could not find initial preferred mode.\n");
*p_mode = list_first_entry(&con->modes,
struct drm_display_mode,
head);
}
return 0;
}
...@@ -243,6 +243,14 @@ vmw_kms_new_framebuffer(struct vmw_private *dev_priv, ...@@ -243,6 +243,14 @@ vmw_kms_new_framebuffer(struct vmw_private *dev_priv,
struct vmw_surface *surface, struct vmw_surface *surface,
bool only_2d, bool only_2d,
const struct drm_mode_fb_cmd *mode_cmd); const struct drm_mode_fb_cmd *mode_cmd);
int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv,
unsigned unit,
u32 max_width,
u32 max_height,
struct drm_connector **p_con,
struct drm_crtc **p_crtc,
struct drm_display_mode **p_mode);
void vmw_guess_mode_timing(struct drm_display_mode *mode);
/* /*
* Legacy display unit functions - vmwgfx_ldu.c * Legacy display unit functions - vmwgfx_ldu.c
......
...@@ -279,7 +279,6 @@ static int vmw_ldu_crtc_set_config(struct drm_mode_set *set) ...@@ -279,7 +279,6 @@ static int vmw_ldu_crtc_set_config(struct drm_mode_set *set)
return -EINVAL; return -EINVAL;
} }
vmw_fb_off(dev_priv);
vmw_svga_enable(dev_priv); vmw_svga_enable(dev_priv);
crtc->primary->fb = fb; crtc->primary->fb = fb;
......
...@@ -369,7 +369,6 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set) ...@@ -369,7 +369,6 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set)
return -EINVAL; return -EINVAL;
} }
vmw_fb_off(dev_priv);
vmw_svga_enable(dev_priv); vmw_svga_enable(dev_priv);
if (mode->hdisplay != crtc->mode.hdisplay || if (mode->hdisplay != crtc->mode.hdisplay ||
......
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