Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2151399ybm; Thu, 23 May 2019 12:12:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxq/+mNmyLVfUT5noS2FPc+j3j1WWHwuf4wTpl7SjmnuRw5iAAWiJXivExUUvA/v0EuCbLh X-Received: by 2002:a62:38d8:: with SMTP id f207mr46259931pfa.131.1558638745518; Thu, 23 May 2019 12:12:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558638745; cv=none; d=google.com; s=arc-20160816; b=ePF35wwd7Y6zW8+zkaBE3xDeZn50XO+cn3jPo2qgaYbZm4CMyto4JV+BBliRkMkg/m 14BZP4/p0ucgmvaeIkz2kMOXpnVnvBuf0HtxQI5/NHt4VKoyibrcqy1bBsZ3zkI/8n+O 2Rbg65iQXs2ZAiSj++FAQH5Apsk/lMsrRjk+wXsFYr52Ae7AQzbEkXfG997s9y84wX7I dac9SF8AsiYZpDbHyCKS7EtMsbRMp2/tGEn+1aw/DZRRJvw8wlKV7vCn3dSZBs8ek1eF BXQ6EVIeTVR96fLUeCeRBQFDU+8gm4y+5rF6XuAS296KzwH+EfyF9xOZ7BkrSChGHEZL VGEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Y0CPJ+EP63f+K0qtTgFksF2M+Q0gSwTqgh0c7IIDE0I=; b=SgBJR0WQnd+EuW3+utzO3gqRxjp/8fH8/cKdEx5evwOtbpLdMqf5Ra90+pG7ZlaaY4 aKRwJB5Re2agDMNpm5lwpCOUP4z751LyZp57CPl7toB2QM7mAcs04TXIaUAXimwESn0D s1dhITXL2VSugKbrLdxEoLIfrdgs+Ifn2v3BytE6fbcNs6kwOxVtj9gdaGjJcGf7NgAq gvus5lT4o2m0BWLImQelV7Ts3dk3luaDavIO+P3t3BiTxpy/jlTA1sgkXPtgXgXsRnZq C6BmJdBefSRIFAsudXbGIgVnxZCS06/pkGDNeKADzTPYjETcHQgKVsFem0cFvf0F5Bgn 3TiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="z/ACv82L"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z13si378828pfr.6.2019.05.23.12.12.09; Thu, 23 May 2019 12:12:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="z/ACv82L"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732213AbfEWTJc (ORCPT + 99 others); Thu, 23 May 2019 15:09:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:42510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732171AbfEWTJ0 (ORCPT ); Thu, 23 May 2019 15:09:26 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0CD93217F9; Thu, 23 May 2019 19:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558638565; bh=T85Jjxk0NgM73sAqGZhoIIV7gjVXYl/ORklZiPJt03s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z/ACv82LLxrlE/6pgF3eYEa1URsiTCY7S+lMHwPF28TVrEYAiEQGXt1cw1G9A+t7R bq1Q+YmNL8GabXYfMxA43S4R/Yq0+sQ8viUmugWABQAUDrl525edz+PT5V0mx9G7Yq Q0M87y+BiCHDaEQOjNstEp/qpxmvNE5W2HSooV+I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yifeng Li , Sudip Mukherjee , Teddy Wang , Bartlomiej Zolnierkiewicz Subject: [PATCH 4.9 36/53] fbdev: sm712fb: use 1024x768 by default on non-MIPS, fix garbled display Date: Thu, 23 May 2019 21:06:00 +0200 Message-Id: <20190523181716.527809065@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523181710.981455400@linuxfoundation.org> References: <20190523181710.981455400@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yifeng Li commit 4ed7d2ccb7684510ec5f7a8f7ef534bc6a3d55b2 upstream. Loongson MIPS netbooks use 1024x600 LCD panels, which is the original target platform of this driver, but nearly all old x86 laptops have 1024x768. Lighting 768 panels using 600's timings would partially garble the display. Since it's not possible to distinguish them reliably, we change the default to 768, but keep 600 as-is on MIPS. Further, earlier laptops, such as IBM Thinkpad 240X, has a 800x600 LCD panel, this driver would probably garbled those display. As we don't have one for testing, the original behavior of the driver is kept as-is, but the problem has been documented is the comments. Signed-off-by: Yifeng Li Tested-by: Sudip Mukherjee Cc: Teddy Wang Cc: # v4.4+ Signed-off-by: Bartlomiej Zolnierkiewicz Signed-off-by: Greg Kroah-Hartman --- drivers/video/fbdev/sm712.h | 7 +++-- drivers/video/fbdev/sm712fb.c | 53 +++++++++++++++++++++++++++++++----------- 2 files changed, 44 insertions(+), 16 deletions(-) --- a/drivers/video/fbdev/sm712.h +++ b/drivers/video/fbdev/sm712.h @@ -15,9 +15,10 @@ #define FB_ACCEL_SMI_LYNX 88 -#define SCREEN_X_RES 1024 -#define SCREEN_Y_RES 600 -#define SCREEN_BPP 16 +#define SCREEN_X_RES 1024 +#define SCREEN_Y_RES_PC 768 +#define SCREEN_Y_RES_NETBOOK 600 +#define SCREEN_BPP 16 #define dac_reg (0x3c8) #define dac_val (0x3c9) --- a/drivers/video/fbdev/sm712fb.c +++ b/drivers/video/fbdev/sm712fb.c @@ -1462,6 +1462,43 @@ static u_long sm7xx_vram_probe(struct sm return 0; /* unknown hardware */ } +static void sm7xx_resolution_probe(struct smtcfb_info *sfb) +{ + /* get mode parameter from smtc_scr_info */ + if (smtc_scr_info.lfb_width != 0) { + sfb->fb->var.xres = smtc_scr_info.lfb_width; + sfb->fb->var.yres = smtc_scr_info.lfb_height; + sfb->fb->var.bits_per_pixel = smtc_scr_info.lfb_depth; + goto final; + } + + /* + * No parameter, default resolution is 1024x768-16. + * + * FIXME: earlier laptops, such as IBM Thinkpad 240X, has a 800x600 + * panel, also see the comments about Thinkpad 240X above. + */ + sfb->fb->var.xres = SCREEN_X_RES; + sfb->fb->var.yres = SCREEN_Y_RES_PC; + sfb->fb->var.bits_per_pixel = SCREEN_BPP; + +#ifdef CONFIG_MIPS + /* + * Loongson MIPS netbooks use 1024x600 LCD panels, which is the original + * target platform of this driver, but nearly all old x86 laptops have + * 1024x768. Lighting 768 panels using 600's timings would partially + * garble the display, so we don't want that. But it's not possible to + * distinguish them reliably. + * + * So we change the default to 768, but keep 600 as-is on MIPS. + */ + sfb->fb->var.yres = SCREEN_Y_RES_NETBOOK; +#endif + +final: + big_pixel_depth(sfb->fb->var.bits_per_pixel, smtc_scr_info.lfb_depth); +} + static int smtcfb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -1507,19 +1544,6 @@ static int smtcfb_pci_probe(struct pci_d sm7xx_init_hw(); - /* get mode parameter from smtc_scr_info */ - if (smtc_scr_info.lfb_width != 0) { - sfb->fb->var.xres = smtc_scr_info.lfb_width; - sfb->fb->var.yres = smtc_scr_info.lfb_height; - sfb->fb->var.bits_per_pixel = smtc_scr_info.lfb_depth; - } else { - /* default resolution 1024x600 16bit mode */ - sfb->fb->var.xres = SCREEN_X_RES; - sfb->fb->var.yres = SCREEN_Y_RES; - sfb->fb->var.bits_per_pixel = SCREEN_BPP; - } - - big_pixel_depth(sfb->fb->var.bits_per_pixel, smtc_scr_info.lfb_depth); /* Map address and memory detection */ mmio_base = pci_resource_start(pdev, 0); pci_read_config_byte(pdev, PCI_REVISION_ID, &sfb->chip_rev_id); @@ -1581,6 +1605,9 @@ static int smtcfb_pci_probe(struct pci_d goto failed_fb; } + /* probe and decide resolution */ + sm7xx_resolution_probe(sfb); + /* can support 32 bpp */ if (15 == sfb->fb->var.bits_per_pixel) sfb->fb->var.bits_per_pixel = 16;