On the pseries machine type, qemu puts a default mode in the device-tree based on the user request (-g option) which the firmware uses to setup the boot screen. Currently cirrusdrmfb ignores this and always ends up using 1280x1024. This adds support for retrieving this information and using it to set the default mode and depth. Signed-off-by: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/cirrus/cirrus_fbdev.c | 3 +-- drivers/gpu/drm/cirrus/cirrus_mode.c | 37 +++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c index 1345215..b0e4080 100644 --- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c +++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c @@ -296,9 +296,8 @@ int cirrus_fbdev_init(struct cirrus_device *cdev) { struct cirrus_fbdev *gfbdev; int ret; - int bpp_sel = 24; + int bpp_sel = cdev->dev->mode_config.preferred_depth; - /*bpp_sel = 8;*/ gfbdev = kzalloc(sizeof(struct cirrus_fbdev), GFP_KERNEL); if (!gfbdev) return -ENOMEM; diff --git a/drivers/gpu/drm/cirrus/cirrus_mode.c b/drivers/gpu/drm/cirrus/cirrus_mode.c index 1566853..1ba73b0 100644 --- a/drivers/gpu/drm/cirrus/cirrus_mode.c +++ b/drivers/gpu/drm/cirrus/cirrus_mode.c @@ -19,6 +19,8 @@ #include "drm_crtc_helper.h" #include <video/cirrus.h> +#include <linux/pci.h> +#include <linux/of.h> #include "cirrus_drv.h" @@ -498,15 +500,25 @@ int cirrus_vga_get_modes(struct drm_connector *connector) { int count = 0; +#ifdef CONFIG_OF + /* + * Add qemu default mode as preferred on machines where it's + * indicated in the device-tree + */ + if (of_chosen) { + u32 width, height; + + if (of_property_read_u32(of_chosen, "qemu,graphic-width", &width) == 0 && + of_property_read_u32(of_chosen, "qemu,graphic-height", &height) == 0) + count += drm_add_modes_noedid(connector, width, height, true); + } +#endif /* CONFIG_OF */ + /* Just add a static list of modes */ count += drm_add_modes_noedid(connector, 640, 480, false); count += drm_add_modes_noedid(connector, 800, 600, false); count += drm_add_modes_noedid(connector, 1024, 768, false); count += drm_add_modes_noedid(connector, 1280, 1024, false); - drm_add_modes_noedid(connector, 640, 480); - drm_add_modes_noedid(connector, 800, 600); - drm_add_modes_noedid(connector, 1024, 768); - drm_add_modes_noedid(connector, 1280, 1024); return count; } @@ -597,6 +609,23 @@ int cirrus_modeset_init(struct cirrus_device *cdev) cdev->dev->mode_config.fb_base = cdev->mc.vram_base; cdev->dev->mode_config.preferred_depth = 24; + +#ifdef CONFIG_OF + /* + * Add qemu default depth as preferred on machines where it's + * indicated in the device-tree + */ + if (of_chosen) { + u32 depth; + + if (!of_property_read_u32(of_chosen, "qemu,graphic-depth", &depth)) { + if (depth == 8 || depth == 15 || depth == 16 || + depth == 24 || depth == 32) + cdev->dev->mode_config.preferred_depth = depth; + } + } +#endif /* CONFIG_OF */ + /* don't prefer a shadow on virt GPU */ cdev->dev->mode_config.prefer_shadow = 0; _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel