From patchwork Tue Jul 18 14:43:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 9848631 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 373CD602A7 for ; Tue, 18 Jul 2017 14:44:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27ACC237F1 for ; Tue, 18 Jul 2017 14:44:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C84B262AE; Tue, 18 Jul 2017 14:44:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AC928237F1 for ; Tue, 18 Jul 2017 14:44:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 178E26E37F; Tue, 18 Jul 2017 14:43:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 40EAF6E368 for ; Tue, 18 Jul 2017 14:43:26 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C0D57ACA3; Tue, 18 Jul 2017 14:43:23 +0000 (UTC) From: Takashi Iwai To: dri-devel@lists.freedesktop.org Subject: [PATCH 12/14] drm/mgag200: Add command line option to specify preferred depth Date: Tue, 18 Jul 2017 16:43:18 +0200 Message-Id: <20170718144320.8354-13-tiwai@suse.de> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170718144320.8354-1-tiwai@suse.de> References: <20170718144320.8354-1-tiwai@suse.de> Cc: Egbert Eich , Dave Airlie , Mathieu Larouche , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Egbert Eich G200 is old hardware. When KMS was designed around 2007 none of the chipsets current at this time had any restrictions to video modes depending on the depth. Thus video modes are validated independent of the depth which is purely a property of the scanout buffer. The mgag200 driver however has some bandwidth limitations and the bandwidth required depends on the bpp. Since the video mode is validated before the depth/bpp is actually known we are missing an important piece of information at validation time. So far we assumed the highest possible bpp value (except for systems with video memory <= 2MB). Unfortunately this will kill some badly needed higher res modes at lower depths. This patch adds a cludge which allows to set the desired depth for the mgag200 driver with the boot option mgag200.preferreddepth=16|24. This is a KLUDGE(!) to get around the shortcomings of the mode setting model for older hardware. Signed-off-by: Egbert Eich Signed-off-by: Takashi Iwai --- drivers/gpu/drm/mgag200/mgag200_drv.c | 11 +++++++++++ drivers/gpu/drm/mgag200/mgag200_drv.h | 2 ++ drivers/gpu/drm/mgag200/mgag200_main.c | 17 +++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c index 03258e9fc6c0..7a71ac729a81 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.c +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c @@ -22,9 +22,12 @@ * functions */ int mgag200_modeset = -1; +int mgag200_preferred_depth __read_mostly; MODULE_PARM_DESC(modeset, "Disable/Enable modesetting"); module_param_named(modeset, mgag200_modeset, int, 0400); +MODULE_PARM_DESC(preferreddepth, "Set preferred bpp"); +module_param_named(preferreddepth, mgag200_preferred_depth, int, 0400); static struct drm_driver driver; @@ -122,6 +125,14 @@ static int __init mgag200_init(void) if (mgag200_modeset == 0) return -EINVAL; + switch (mgag200_preferred_depth) { + case 0: /* driver default */ + case 16: + case 24: + break; + default: + return -EINVAL; + } return drm_pci_init(&driver, &mgag200_pci_driver); } diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 9d7ae61ce915..949bbcbf9d19 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -318,4 +318,6 @@ int mga_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, uint32_t handle, uint32_t width, uint32_t height); int mga_crtc_cursor_move(struct drm_crtc *crtc, int x, int y); +extern int mgag200_preferred_depth __read_mostly; + #endif /* __MGAG200_DRV_H__ */ diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 2ec76d6615a8..56970eced8d7 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -339,12 +339,21 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags) drm_mode_config_init(dev); dev->mode_config.funcs = (void *)&mga_mode_funcs; - if (IS_G200_SE(mdev) && mdev->mc.vram_size < (2048*1024)) { + if (mgag200_preferred_depth == 0) { /* prefer 16bpp on low end gpus with limited VRAM */ - mdev->preferred_bpp = dev->mode_config.preferred_depth = 16; + if (IS_G200_SE(mdev) && mdev->mc.vram_size <= 2048 * 1024) { + mdev->preferred_bpp = + dev->mode_config.preferred_depth = 16; + } else { + mdev->preferred_bpp = 32; + dev->mode_config.preferred_depth = 24; + } } else { - mdev->preferred_bpp = 32; - dev->mode_config.preferred_depth = 24; + if (mgag200_preferred_depth == 16) + mdev->preferred_bpp = 16; + else /* mgag200_preferred_depth == 24 */ + mdev->preferred_bpp = 32; + dev->mode_config.preferred_depth = mgag200_preferred_depth; } dev->mode_config.prefer_shadow = 1;