[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230904195724.633404-8-sui.jingfeng@linux.dev>
Date: Tue, 5 Sep 2023 03:57:22 +0800
From: Sui Jingfeng <sui.jingfeng@...ux.dev>
To: Bjorn Helgaas <bhelgaas@...gle.com>
Cc: amd-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, intel-gfx@...ts.freedesktop.org,
nouveau@...ts.freedesktop.org, linux-pci@...r.kernel.org,
Sui Jingfeng <suijingfeng@...ngson.cn>,
Thomas Zimmermann <tzimmermann@...e.de>,
Jocelyn Falempe <jfalempe@...hat.com>
Subject: [RFC,drm-misc-next v4 7/9] drm/ast: Register as a VGA client by calling vga_client_register()
From: Sui Jingfeng <suijingfeng@...ngson.cn>
Becasuse the display controller in the ASpeed BMC chip is a VGA-compatible
device, the software programming guide of AST2400 say that it is fully
IBM VGA compliant. Thus, it should also participate in the arbitration.
Cc: Thomas Zimmermann <tzimmermann@...e.de>
Cc: Jocelyn Falempe <jfalempe@...hat.com>
Signed-off-by: Sui Jingfeng <suijingfeng@...ngson.cn>
---
drivers/gpu/drm/ast/ast_drv.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index e1224ef4ad83..1349f7bb5dfb 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -28,6 +28,7 @@
#include <linux/module.h>
#include <linux/pci.h>
+#include <linux/vgaarb.h>
#include <drm/drm_aperture.h>
#include <drm/drm_atomic_helper.h>
@@ -89,6 +90,34 @@ static const struct pci_device_id ast_pciidlist[] = {
MODULE_DEVICE_TABLE(pci, ast_pciidlist);
+static bool ast_want_to_be_primary(struct pci_dev *pdev)
+{
+ if (ast_modeset == 10)
+ return true;
+
+ return false;
+}
+
+static unsigned int ast_vga_set_decode(struct pci_dev *pdev, bool state)
+{
+ struct drm_device *drm = pci_get_drvdata(pdev);
+ struct ast_device *ast = to_ast_device(drm);
+ unsigned int decode;
+
+ if (state) {
+ /* Enable standard VGA decode and Enable normal VGA decode */
+ ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04);
+
+ decode = VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM |
+ VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
+ } else {
+ ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x07);
+ decode = VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
+ }
+
+ return decode;
+}
+
static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct ast_device *ast;
@@ -112,6 +141,8 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret)
return ret;
+ vga_client_register(pdev, ast_vga_set_decode, ast_want_to_be_primary);
+
drm_fbdev_generic_setup(dev, 32);
return 0;
--
2.34.1
Powered by blists - more mailing lists