Commit 4abe3520 authored by Dave Airlie's avatar Dave Airlie

drm/kms/fb: use slow work mechanism for normal hotplug also.

a) slow work is always used now for any fbcon hotplug, as its not
   a fast task and is more suited to being ran under slow work.

b) attempt to not do any fbdev changes when X is running as we'll
   just mess it up. This hooks set_par to hopefully do the changes
   once X hands control to fbdev.

This also adds the nouveau/intel hotplug support.
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 5c4426a7
This diff is collapsed.
......@@ -266,6 +266,7 @@ static void i915_hotplug_work_func(struct work_struct *work)
}
}
/* Just fire off a uevent and let userspace tell us what to do */
intelfb_hotplug(dev, false);
drm_sysfs_hotplug_event(dev);
}
......
......@@ -228,4 +228,6 @@ extern int intel_overlay_put_image(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int intel_overlay_attrs(struct drm_device *dev, void *data,
struct drm_file *file_priv);
void intelfb_hotplug(struct drm_device *dev, bool polled);
#endif /* __INTEL_DRV_H__ */
......@@ -65,12 +65,6 @@ static struct fb_ops intelfb_ops = {
.fb_setcmap = drm_fb_helper_setcmap,
};
static struct drm_fb_helper_funcs intel_fb_helper_funcs = {
.gamma_set = intel_crtc_fb_gamma_set,
.gamma_get = intel_crtc_fb_gamma_get,
};
static int intelfb_create(struct intel_fbdev *ifbdev,
struct drm_fb_helper_surface_size *sizes)
{
......@@ -129,7 +123,6 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
ifbdev->helper.fb = fb;
ifbdev->helper.fbdev = info;
ifbdev->helper.funcs = &intel_fb_helper_funcs;
strcpy(info->fix.id, "inteldrmfb");
......@@ -154,6 +147,12 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
ret = -ENOSPC;
goto out_unpin;
}
ret = fb_alloc_cmap(&info->cmap, 256, 0);
if (ret) {
ret = -ENOMEM;
goto out_unpin;
}
info->screen_size = size;
// memset(info->screen_base, 0, size);
......@@ -205,15 +204,18 @@ static int intel_fb_find_or_create_single(struct drm_fb_helper *helper,
return new_fb;
}
static int intelfb_probe(struct intel_fbdev *ifbdev)
void intelfb_hotplug(struct drm_device *dev, bool polled)
{
int ret;
DRM_DEBUG_KMS("\n");
ret = drm_fb_helper_single_fb_probe(&ifbdev->helper, 32);
return ret;
drm_i915_private_t *dev_priv = dev->dev_private;
drm_helper_fb_hpd_irq_event(&dev_priv->fbdev->helper);
}
static struct drm_fb_helper_funcs intel_fb_helper_funcs = {
.gamma_set = intel_crtc_fb_gamma_set,
.gamma_get = intel_crtc_fb_gamma_get,
.fb_probe = intel_fb_find_or_create_single,
};
int intel_fbdev_destroy(struct drm_device *dev,
struct intel_fbdev *ifbdev)
{
......@@ -224,10 +226,12 @@ int intel_fbdev_destroy(struct drm_device *dev,
info = ifbdev->helper.fbdev;
unregister_framebuffer(info);
iounmap(info->screen_base);
if (info->cmap.len)
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
}
drm_fb_helper_free(&ifbdev->helper);
drm_fb_helper_fini(&ifbdev->helper);
drm_framebuffer_cleanup(&ifb->base);
if (ifb->obj)
......@@ -246,13 +250,13 @@ int intel_fbdev_init(struct drm_device *dev)
return -ENOMEM;
dev_priv->fbdev = ifbdev;
ifbdev->helper.funcs = &intel_fb_helper_funcs;
drm_fb_helper_init(dev, &ifbdev->helper, 2,
INTELFB_CONN_LIMIT, false);
drm_fb_helper_init_crtc_count(dev, &ifbdev->helper, 2,
INTELFB_CONN_LIMIT);
drm_fb_helper_single_add_all_connectors(&ifbdev->helper);
ifbdev->helper.fb_probe = intel_fb_find_or_create_single;
drm_fb_helper_initial_config(&ifbdev->helper);
intelfb_probe(ifbdev);
drm_fb_helper_initial_config(&ifbdev->helper, 32);
return 0;
}
......
......@@ -156,11 +156,6 @@ static void nouveau_fbcon_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
*blue = nv_crtc->lut.b[regno];
}
static struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = {
.gamma_set = nouveau_fbcon_gamma_set,
.gamma_get = nouveau_fbcon_gamma_get
};
#if defined(__i386__) || defined(__x86_64__)
static bool
nouveau_fbcon_has_vesafb_or_efifb(struct drm_device *dev)
......@@ -272,6 +267,12 @@ nouveau_fbcon_create(struct nouveau_fbdev *nfbdev,
goto out_unref;
}
ret = fb_alloc_cmap(&info->cmap, 256, 0);
if (ret) {
ret = -ENOMEM;
goto out_unref;
}
info->par = nfbdev;
nouveau_framebuffer_init(dev, &nfbdev->nouveau_fb, &mode_cmd, nvbo);
......@@ -282,7 +283,6 @@ nouveau_fbcon_create(struct nouveau_fbdev *nfbdev,
/* setup helper */
nfbdev->helper.fb = fb;
nfbdev->helper.fbdev = info;
nfbdev->helper.funcs = &nouveau_fbcon_helper_funcs;
strcpy(info->fix.id, "nouveaufb");
if (nouveau_nofbaccel)
......@@ -381,12 +381,15 @@ nouveau_fbcon_find_or_create_single(struct drm_fb_helper *helper,
return new_fb;
}
static int
nouveau_fbcon_probe(struct nouveau_fbdev *nfbdev)
void nouveau_fbcon_hotplug(struct drm_device *dev)
{
NV_DEBUG_KMS(nfbdev->dev, "\n");
struct drm_nouveau_private *dev_priv = dev->dev_private;
drm_helper_fb_hpd_irq_event(&dev_priv->nfbdev->helper);
}
return drm_fb_helper_single_fb_probe(&nfbdev->helper, 32);
static void nouveau_fbcon_output_status_changed(struct drm_fb_helper *fb_helper)
{
drm_helper_fb_hotplug_event(fb_helper, true);
}
int
......@@ -398,6 +401,8 @@ nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *nfbdev)
if (nfbdev->helper.fbdev) {
info = nfbdev->helper.fbdev;
unregister_framebuffer(info);
if (info->cmap.len)
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
}
......@@ -406,7 +411,7 @@ nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *nfbdev)
drm_gem_object_unreference_unlocked(nouveau_fb->nvbo->gem);
nouveau_fb->nvbo = NULL;
}
drm_fb_helper_free(&nfbdev->helper);
drm_fb_helper_fini(&nfbdev->helper);
drm_framebuffer_cleanup(&nouveau_fb->base);
return 0;
}
......@@ -420,6 +425,14 @@ void nouveau_fbcon_gpu_lockup(struct fb_info *info)
info->flags |= FBINFO_HWACCEL_DISABLED;
}
static struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = {
.gamma_set = nouveau_fbcon_gamma_set,
.gamma_get = nouveau_fbcon_gamma_get,
.fb_probe = nouveau_fbcon_find_or_create_single,
.fb_output_status_changed = nouveau_fbcon_output_status_changed,
};
int nouveau_fbcon_init(struct drm_device *dev)
{
struct drm_nouveau_private *dev_priv = dev->dev_private;
......@@ -431,14 +444,12 @@ int nouveau_fbcon_init(struct drm_device *dev)
nfbdev->dev = dev;
dev_priv->nfbdev = nfbdev;
nfbdev->helper.funcs = &nouveau_fbcon_helper_funcs;
drm_fb_helper_init_crtc_count(dev, &nfbdev->helper,
2, 4);
nfbdev->helper.fb_probe = nouveau_fbcon_find_or_create_single;
drm_fb_helper_init(dev, &nfbdev->helper,
2, 4, true);
drm_fb_helper_single_add_all_connectors(&nfbdev->helper);
drm_fb_helper_initial_config(&nfbdev->helper);
nouveau_fbcon_probe(nfbdev);
drm_fb_helper_initial_config(&nfbdev->helper, 32);
return 0;
}
......
......@@ -57,5 +57,7 @@ void nouveau_fbcon_set_suspend(struct drm_device *dev, int state);
void nouveau_fbcon_zfill_all(struct drm_device *dev);
void nouveau_fbcon_save_disable_accel(struct drm_device *dev);
void nouveau_fbcon_restore_accel(struct drm_device *dev);
void nouveau_fbcon_hotplug(struct drm_device *dev);
#endif /* __NV50_FBCON_H__ */
......@@ -29,6 +29,7 @@
#include "nouveau_encoder.h"
#include "nouveau_connector.h"
#include "nouveau_fb.h"
#include "nouveau_fbcon.h"
#include "drm_crtc_helper.h"
static void
......@@ -941,6 +942,8 @@ nv50_display_irq_hotplug(struct drm_device *dev)
nv_wr32(dev, 0xe054, nv_rd32(dev, 0xe054));
if (dev_priv->chipset >= 0x90)
nv_wr32(dev, 0xe074, nv_rd32(dev, 0xe074));
nouveau_fbcon_hotplug(dev);
}
void
......
......@@ -86,11 +86,6 @@ static int radeon_align_pitch(struct radeon_device *rdev, int width, int bpp, bo
return aligned;
}
static struct drm_fb_helper_funcs radeon_fb_helper_funcs = {
.gamma_set = radeon_crtc_fb_gamma_set,
.gamma_get = radeon_crtc_fb_gamma_get,
};
static void radeonfb_destroy_pinned_object(struct drm_gem_object *gobj)
{
struct radeon_bo *rbo = gobj->driver_private;
......@@ -222,7 +217,6 @@ static int radeonfb_create(struct radeon_fbdev *rfbdev,
/* setup helper */
rfbdev->helper.fb = fb;
rfbdev->helper.fbdev = info;
rfbdev->helper.funcs = &radeon_fb_helper_funcs;
memset_io(rbo->kptr, 0x0, radeon_bo_size(rbo));
......@@ -252,10 +246,18 @@ static int radeonfb_create(struct radeon_fbdev *rfbdev,
info->pixmap.access_align = 32;
info->pixmap.flags = FB_PIXMAP_SYSTEM;
info->pixmap.scan_align = 1;
if (info->screen_base == NULL) {
ret = -ENOSPC;
goto out_unref;
}
ret = fb_alloc_cmap(&info->cmap, 256, 0);
if (ret) {
ret = -ENOMEM;
goto out_unref;
}
DRM_INFO("fb mappable at 0x%lX\n", info->fix.smem_start);
DRM_INFO("vram apper at 0x%lX\n", (unsigned long)rdev->mc.aper_base);
DRM_INFO("size %lu\n", (unsigned long)radeon_bo_size(rbo));
......@@ -309,33 +311,16 @@ int radeon_parse_options(char *options)
return 0;
}
static int radeonfb_probe(struct radeon_fbdev *rfbdev)
{
struct radeon_device *rdev = rfbdev->rdev;
int bpp_sel = 32;
/* select 8 bpp console on RN50 or 16MB cards */
if (ASIC_IS_RN50(rdev) || rdev->mc.real_vram_size <= (32*1024*1024))
bpp_sel = 8;
return drm_fb_helper_single_fb_probe(&rfbdev->helper, bpp_sel);
}
void radeonfb_hotplug(struct drm_device *dev, bool polled)
{
struct radeon_device *rdev = dev->dev_private;
int max_width, max_height;
max_width = rdev->mode_info.rfbdev->rfb.base.width;
max_height = rdev->mode_info.rfbdev->rfb.base.height;
drm_helper_fb_hotplug_event(&rdev->mode_info.rfbdev->helper, max_width, max_height, polled);
radeonfb_probe(rdev->mode_info.rfbdev);
drm_helper_fb_hpd_irq_event(&rdev->mode_info.rfbdev->helper);
}
static void radeon_fb_poll_changed(struct drm_fb_helper *fb_helper)
static void radeon_fb_output_status_changed(struct drm_fb_helper *fb_helper)
{
radeonfb_hotplug(fb_helper->dev, true);
drm_helper_fb_hotplug_event(fb_helper, true);
}
static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfbdev)
......@@ -347,7 +332,10 @@ static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfb
if (rfbdev->helper.fbdev) {
info = rfbdev->helper.fbdev;
unregister_framebuffer(info);
if (info->cmap.len)
fb_dealloc_cmap(&info->cmap);
framebuffer_release(info);
}
......@@ -361,16 +349,27 @@ static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfb
}
drm_gem_object_unreference_unlocked(rfb->obj);
}
drm_fb_helper_free(&rfbdev->helper);
drm_fb_helper_fini(&rfbdev->helper);
drm_framebuffer_cleanup(&rfb->base);
return 0;
}
MODULE_LICENSE("GPL");
static struct drm_fb_helper_funcs radeon_fb_helper_funcs = {
.gamma_set = radeon_crtc_fb_gamma_set,
.gamma_get = radeon_crtc_fb_gamma_get,
.fb_probe = radeon_fb_find_or_create_single,
.fb_output_status_changed = radeon_fb_output_status_changed,
};
int radeon_fbdev_init(struct radeon_device *rdev)
{
struct radeon_fbdev *rfbdev;
int bpp_sel = 32;
/* select 8 bpp console on RN50 or 16MB cards */
if (ASIC_IS_RN50(rdev) || rdev->mc.real_vram_size <= (32*1024*1024))
bpp_sel = 8;
rfbdev = kzalloc(sizeof(struct radeon_fbdev), GFP_KERNEL);
if (!rfbdev)
......@@ -378,20 +377,13 @@ int radeon_fbdev_init(struct radeon_device *rdev)
rfbdev->rdev = rdev;
rdev->mode_info.rfbdev = rfbdev;
rfbdev->helper.funcs = &radeon_fb_helper_funcs;
drm_fb_helper_init_crtc_count(rdev->ddev, &rfbdev->helper,
rdev->num_crtc,
RADEONFB_CONN_LIMIT);
rfbdev->helper.fb_probe = radeon_fb_find_or_create_single;
drm_fb_helper_init(rdev->ddev, &rfbdev->helper,
rdev->num_crtc,
RADEONFB_CONN_LIMIT, true);
drm_fb_helper_single_add_all_connectors(&rfbdev->helper);
rfbdev->helper.fb_poll_changed = radeon_fb_poll_changed;
drm_fb_helper_poll_init(&rfbdev->helper);
drm_fb_helper_initial_config(&rfbdev->helper);
radeonfb_probe(rfbdev);
drm_fb_helper_initial_config(&rfbdev->helper, bpp_sel);
return 0;
}
......@@ -401,7 +393,6 @@ void radeon_fbdev_fini(struct radeon_device *rdev)
if (!rdev->mode_info.rfbdev)
return;
drm_fb_helper_poll_fini(&rdev->mode_info.rfbdev->helper);
radeon_fbdev_destroy(rdev->ddev, rdev->mode_info.rfbdev);
kfree(rdev->mode_info.rfbdev);
rdev->mode_info.rfbdev = NULL;
......@@ -428,4 +419,3 @@ bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo *robj)
return true;
return false;
}
......@@ -32,20 +32,14 @@
#include <linux/slow-work.h>
struct drm_fb_helper;
struct drm_fb_helper_crtc {
uint32_t crtc_id;
struct drm_mode_set mode_set;
struct drm_display_mode *desired_mode;
};
struct drm_fb_helper_funcs {
void (*gamma_set)(struct drm_crtc *crtc, u16 red, u16 green,
u16 blue, int regno);
void (*gamma_get)(struct drm_crtc *crtc, u16 *red, u16 *green,
u16 *blue, int regno);
};
/* mode specified on the command line */
struct drm_fb_helper_cmdline_mode {
bool specified;
......@@ -69,6 +63,19 @@ struct drm_fb_helper_surface_size {
u32 surface_depth;
};
struct drm_fb_helper_funcs {
void (*gamma_set)(struct drm_crtc *crtc, u16 red, u16 green,
u16 blue, int regno);
void (*gamma_get)(struct drm_crtc *crtc, u16 *red, u16 *green,
u16 *blue, int regno);
int (*fb_probe)(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes);
void (*fb_output_status_changed)(struct drm_fb_helper *helper);
};
struct drm_fb_helper_connector {
struct drm_fb_helper_cmdline_mode cmdline_mode;
struct drm_connector *connector;
......@@ -88,21 +95,20 @@ struct drm_fb_helper {
u32 pseudo_palette[17];
struct list_head kernel_fb_list;
struct delayed_slow_work output_poll_slow_work;
struct delayed_slow_work output_status_change_slow_work;
bool poll_enabled;
int (*fb_probe)(struct drm_fb_helper *helper,
struct drm_fb_helper_surface_size *sizes);
void (*fb_poll_changed)(struct drm_fb_helper *helper);
/* we got a hotplug but fbdev wasn't running the console
delay until next set_par */
bool delayed_hotplug;
};
int drm_fb_helper_single_fb_probe(struct drm_fb_helper *helper,
int preferred_bpp);
int drm_fb_helper_init_crtc_count(struct drm_device *dev,
struct drm_fb_helper *helper, int crtc_count,
int max_conn);
void drm_fb_helper_free(struct drm_fb_helper *helper);
int drm_fb_helper_init(struct drm_device *dev,
struct drm_fb_helper *helper, int crtc_count,
int max_conn, bool polled);
void drm_fb_helper_fini(struct drm_fb_helper *helper);
int drm_fb_helper_blank(int blank, struct fb_info *info);
int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,
struct fb_info *info);
......@@ -125,10 +131,9 @@ void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch,
int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);
bool drm_helper_fb_hotplug_event(struct drm_fb_helper *fb_helper,
u32 max_width, u32 max_height, bool polled);
bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper);
bool polled);
bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel);
int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper);
void drm_fb_helper_poll_init(struct drm_fb_helper *fb_helper);
void drm_fb_helper_poll_fini(struct drm_fb_helper *fb_helper);
void drm_helper_fb_hpd_irq_event(struct drm_fb_helper *fb_helper);
#endif
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