From patchwork Tue Jul 18 14:43:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 9848629 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 4D66C602A7 for ; Tue, 18 Jul 2017 14:44:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DA2D237F1 for ; Tue, 18 Jul 2017 14:44:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32461262AE; Tue, 18 Jul 2017 14:44:00 +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 C6E3A237F1 for ; Tue, 18 Jul 2017 14:43:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C95B6E377; Tue, 18 Jul 2017 14:43:28 +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 58F4A6E36F for ; Tue, 18 Jul 2017 14:43:26 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C4FDCAE01; Tue, 18 Jul 2017 14:43:23 +0000 (UTC) From: Takashi Iwai To: dri-devel@lists.freedesktop.org Subject: [PATCH 11/14] drm/mgag200: Consolidate depth/bpp handling Date: Tue, 18 Jul 2017 16:43:17 +0200 Message-Id: <20170718144320.8354-12-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 The depth/bpp handling for chips with limited memory in commit 918be888d613 ("drm/mgag200: on cards with < 2MB VRAM default to 16-bit") was incomplete: the bpp limits were applied to mode validation. This consolidates dpeth/bpp handling, adds it to mode validation and moves the code which reads the command line specified depth into the correct location. Fixes: 918be888d613 ("drm/mgag200: on cards with < 2MB VRAM default to 16-bit") Signed-off-by: Egbert Eich Signed-off-by: Takashi Iwai --- drivers/gpu/drm/mgag200/mgag200_drv.h | 2 ++ drivers/gpu/drm/mgag200/mgag200_fb.c | 7 +------ drivers/gpu/drm/mgag200/mgag200_main.c | 9 ++++++--- drivers/gpu/drm/mgag200/mgag200_mode.c | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 1ba559c93b8f..9d7ae61ce915 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -209,6 +209,8 @@ struct mga_device { int has_sdram; struct drm_display_mode mode; + int preferred_bpp; + int bpp_shifts[4]; int fb_mtrr; diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c index bb9a4c409dc0..173aed918183 100644 --- a/drivers/gpu/drm/mgag200/mgag200_fb.c +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c @@ -267,11 +267,6 @@ int mgag200_fbdev_init(struct mga_device *mdev) { struct mga_fbdev *mfbdev; int ret; - int bpp_sel = 32; - - /* prefer 16bpp on low end gpus with limited VRAM */ - if (IS_G200_SE(mdev) && mdev->mc.vram_size < (2048*1024)) - bpp_sel = 16; mfbdev = devm_kzalloc(mdev->dev->dev, sizeof(struct mga_fbdev), GFP_KERNEL); if (!mfbdev) @@ -294,7 +289,7 @@ int mgag200_fbdev_init(struct mga_device *mdev) /* disable all the possible outputs/crtcs before entering KMS mode */ drm_helper_disable_unused_functions(mdev->dev); - ret = drm_fb_helper_initial_config(&mfbdev->helper, bpp_sel); + ret = drm_fb_helper_initial_config(&mfbdev->helper, mdev->preferred_bpp); if (ret) goto err_fb_setup; diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 73614154a5ef..2ec76d6615a8 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -339,10 +339,13 @@ 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)) - dev->mode_config.preferred_depth = 16; - else + if (IS_G200_SE(mdev) && mdev->mc.vram_size < (2048*1024)) { + /* prefer 16bpp on low end gpus with limited VRAM */ + mdev->preferred_bpp = dev->mode_config.preferred_depth = 16; + } else { + mdev->preferred_bpp = 32; dev->mode_config.preferred_depth = 24; + } dev->mode_config.prefer_shadow = 1; r = mgag200_modeset_init(mdev); diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c index a07f67ed6e4a..77b8efcd3c65 100644 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c @@ -1705,9 +1705,15 @@ static int mga_vga_mode_valid(struct drm_connector *connector, { struct drm_device *dev = connector->dev; struct mga_device *mdev = (struct mga_device*)dev->dev_private; - int bpp = 32; + int bpp; int lace; + bpp = mdev->preferred_bpp; + /* Validate the mode input by the user */ + if (connector->cmdline_mode.specified && + connector->cmdline_mode.bpp_specified) + bpp = connector->cmdline_mode.bpp; + lace = (mode->flags & DRM_MODE_FLAG_INTERLACE) ? 2 : 1; if (IS_G200_SE(mdev)) { if (mdev->unique_rev_id == 0x01) { @@ -1767,12 +1773,6 @@ static int mga_vga_mode_valid(struct drm_connector *connector, return MODE_BAD; } - /* Validate the mode input by the user */ - if (connector->cmdline_mode.specified) { - if (connector->cmdline_mode.bpp_specified) - bpp = connector->cmdline_mode.bpp; - } - if ((mode->hdisplay * mode->vdisplay * (bpp/8)) > mdev->mc.vram_size) { if (connector->cmdline_mode.specified) connector->cmdline_mode.specified = false;