From 1acf566195e135bc0b557ecb8ad5395b47d9ad27 Mon Sep 17 00:00:00 2001
From: Max Staudt <mstaudt@suse.de>
Date: Wed, 18 Jan 2017 19:10:12 +0100
Subject: [PATCH] drm/bochs: Implement nomodeset
Git-commit: 1acf566195e135bc0b557ecb8ad5395b47d9ad27
Patch-mainline: 4.11-rc1
References: bsc#1047096

Up until now, the bochsdrm driver didn't handle the nomodeset option
at boot, and didn't provide a "modeset" module option either.

This patch implements both.

The new parameter can be used by specifying bochs-drm.modeset=0
at boot time.

Signed-off-by: Max Staudt <mstaudt@suse.de>
Link: http://patchwork.freedesktop.org/patch/msgid/1484763012-17783-1-git-send-email-mstaudt@suse.de
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/gpu/drm/bochs/bochs_drv.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

--- a/drivers/gpu/drm/bochs/bochs_drv.c
+++ b/drivers/gpu/drm/bochs/bochs_drv.c
@@ -11,6 +11,10 @@
 
 #include "bochs.h"
 
+static int bochs_modeset = -1;
+module_param_named(modeset, bochs_modeset, int, 0444);
+MODULE_PARM_DESC(modeset, "enable/disable kernel modesetting");
+
 static bool enable_fbdev = true;
 module_param_named(fbdev, enable_fbdev, bool, 0444);
 MODULE_PARM_DESC(fbdev, "register fbdev device");
@@ -209,6 +213,14 @@ static struct pci_driver bochs_pci_drive
 
 static int __init bochs_init(void)
 {
+#ifdef CONFIG_VGA_CONSOLE
+	if (vgacon_text_force() && bochs_modeset == -1)
+		return -EINVAL;
+#endif
+
+	if (bochs_modeset == 0)
+		return -EINVAL;
+
 	return drm_pci_init(&bochs_driver, &bochs_pci_driver);
 }
 
