From patchwork Sat Feb 2 06:16:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Li X-Patchwork-Id: 10794127 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CEA4C6C2 for ; Sat, 2 Feb 2019 06:17:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFE5832B5F for ; Sat, 2 Feb 2019 06:17:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B434232B64; Sat, 2 Feb 2019 06:17:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F3FE32B5F for ; Sat, 2 Feb 2019 06:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726585AbfBBGRP (ORCPT ); Sat, 2 Feb 2019 01:17:15 -0500 Received: from tomli.me ([153.92.126.73]:45026 "EHLO tomli.me" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726495AbfBBGRP (ORCPT ); Sat, 2 Feb 2019 01:17:15 -0500 Received: from tomli.me (localhost [127.0.0.1]) by tomli.me (OpenSMTPD) with ESMTP id 97bcb32a; Sat, 2 Feb 2019 06:17:12 +0000 (UTC) X-HELO: localhost.lan Authentication-Results: tomli.me; auth=pass (login) smtp.auth=tomli Received: from Unknown (HELO localhost.lan) (2402:f000:1:1501:200:5efe:7b76:77ab) by tomli.me (qpsmtpd/0.95) with ESMTPSA (DHE-RSA-CHACHA20-POLY1305 encrypted); Sat, 02 Feb 2019 06:17:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=tomli.me; h=from:to:cc:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=1490979754; bh=qZXfYEYENCjnA/DvVJIMJSg9s4XjKAKMh812pgU//KU=; b=tBnSixkHgWdKXJtGZUOR0Y01acepItcjmfEu2bBwtFs3+XFZpDD/5eEezyYRZiLfkIrtEQR55ZoD/wXi0QJOovdbYN4PviJO8tixw5smBemY2+oN6B3sczijtKz0T9bcHV33Z6YGOOspYi4Dt3fciTegQkDSUOB2719LSJFjmcHWo2cnLu6uq4R+q1pTrZjqfh2jWUD0DYFuRK8OIsKu+nIvby4e7XthlJ2hZUXqXInLe8dyvG6KPoO4NrBfr3KVVrwKNmadWKRN6uO+oCmgw/8x4JGZoOckYwRXHTg4cs0A/NBVRVrkhjxgAMmUZuH2FMLW+ycJvsMA5p7bQov/ew== From: Yifeng Li To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Yifeng Li , Sudip Mukherjee , Teddy Wang , Bartlomiej Zolnierkiewicz Subject: [PATCH 1/8] fbdev: sm712fb: update copyright headers. Date: Sat, 2 Feb 2019 14:16:41 +0800 Message-Id: <20190202061648.30374-2-tomli@tomli.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190202061648.30374-1-tomli@tomli.me> References: <20190202061648.30374-1-tomli@tomli.me> MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP My implementation of 2D acceleration used the original buggy code in the staging tree (which had been removed due to a critical bug soon after its submission), also, OpenBSD's smfb.c driver written by Miodrag Vallat was another important source of reference, a hunk of hardware register definitions are taken verbatim. This commit appends my name to the list of authors, and included Miodrag Vallat's name and the ISC license of the original smfb.c driver. Signed-off-by: Yifeng Li --- drivers/video/fbdev/sm712.h | 20 ++++++++++++++++++++ drivers/video/fbdev/sm712fb.c | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/video/fbdev/sm712.h b/drivers/video/fbdev/sm712.h index aad1cc4be34a..99077e91ae10 100644 --- a/drivers/video/fbdev/sm712.h +++ b/drivers/video/fbdev/sm712.h @@ -8,9 +8,29 @@ * Copyright (C) 2009 Lemote, Inc. * Author: Wu Zhangjin, wuzhangjin@gmail.com * + * Copyright (C) 2014, 2019 Yifeng Li. + * Author: Yifeng Li + * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive for * more details. + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright (c) 2009, 2010 Miodrag Vallat. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #define FB_ACCEL_SMI_LYNX 88 diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c index 502d0de2feec..8d63bbfef9ea 100644 --- a/drivers/video/fbdev/sm712fb.c +++ b/drivers/video/fbdev/sm712fb.c @@ -11,11 +11,31 @@ * Copyright (C) 2011 Igalia, S.L. * Author: Javier M. Mellid * + * Copyright (C) 2014, 2019 Yifeng Li. + * Author: Yifeng Li + * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive for * more details. * * Framebuffer driver for Silicon Motion SM710, SM712, SM721 and SM722 chips + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright (c) 2009, 2010 Miodrag Vallat. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include From patchwork Sat Feb 2 06:16:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Li X-Patchwork-Id: 10794129 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E09CB6C2 for ; Sat, 2 Feb 2019 06:17:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2B3532B5F for ; Sat, 2 Feb 2019 06:17:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C708032B64; Sat, 2 Feb 2019 06:17:21 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65A5132B5F for ; Sat, 2 Feb 2019 06:17:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726761AbfBBGRV (ORCPT ); Sat, 2 Feb 2019 01:17:21 -0500 Received: from tomli.me ([153.92.126.73]:45026 "EHLO tomli.me" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726495AbfBBGRV (ORCPT ); Sat, 2 Feb 2019 01:17:21 -0500 Received: from tomli.me (localhost [127.0.0.1]) by tomli.me (OpenSMTPD) with ESMTP id 60300660; Sat, 2 Feb 2019 06:17:18 +0000 (UTC) X-HELO: localhost.lan Authentication-Results: tomli.me; auth=pass (login) smtp.auth=tomli Received: from Unknown (HELO localhost.lan) (2402:f000:1:1501:200:5efe:7b76:77ab) by tomli.me (qpsmtpd/0.95) with ESMTPSA (DHE-RSA-CHACHA20-POLY1305 encrypted); Sat, 02 Feb 2019 06:17:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=tomli.me; h=from:to:cc:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=1490979754; bh=sEFDZFlfDqKnYMQYk7vg5Y9I18fK+Xt8XdV3FTX5+0M=; b=jyFdyIc7VKf6ekP38FjjcyNFO7ZNH0+csscqp/3jG+SBtjegsYccFgnZH5S3WEevLZJO5XajWkAoi7eyBS+8ulq+MtSEyG+BIilpkThywIHMHqyXzGtd85/lTEDP+3/J6vZK8tHS8exdNdbj15ZCgPZ3xyHhIg8Zhurcafi4RClOfSo8EPjlwovcLaYL6L0ckyAf3yzlc2E3l4U5aNpsHvLeh0IRFNlySpgmDSFQB4JgBkBWJe34ssg9NqWBPLVnhksYj+Jj/rs79KknEEu5f235FxzPCNcHmbuSHmKq1JCad3pyK7IPB70tOSmNs0rDnrCA+useqMKnYQ6Rp2wt0A== From: Yifeng Li To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Yifeng Li , Sudip Mukherjee , Teddy Wang , Bartlomiej Zolnierkiewicz Subject: [PATCH 2/8] fbdev: sm712fb: use type "u8" for 8-bit I/O. Date: Sat, 2 Feb 2019 14:16:42 +0800 Message-Id: <20190202061648.30374-3-tomli@tomli.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190202061648.30374-1-tomli@tomli.me> References: <20190202061648.30374-1-tomli@tomli.me> MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit converts "unsigned int" and "int" in I/O wrappers to "u8". It improves readability since it's consistent with the prototypes of readb() and writeb(). More importantly, it reduces readers' confusion, since the upcoming 2D acceleration code will use a different wordsize. Signed-off-by: Yifeng Li --- drivers/video/fbdev/sm712.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/sm712.h b/drivers/video/fbdev/sm712.h index 99077e91ae10..942019dc816a 100644 --- a/drivers/video/fbdev/sm712.h +++ b/drivers/video/fbdev/sm712.h @@ -63,19 +63,19 @@ extern void __iomem *smtc_regbaseaddress; #define SIZE_CR30_CR4D (0x4D - 0x30 + 1) #define SIZE_CR90_CRA7 (0xA7 - 0x90 + 1) -static inline void smtc_crtcw(int reg, int val) +static inline void smtc_crtcw(u8 reg, u8 val) { smtc_mmiowb(reg, 0x3d4); smtc_mmiowb(val, 0x3d5); } -static inline void smtc_grphw(int reg, int val) +static inline void smtc_grphw(u8 reg, u8 val) { smtc_mmiowb(reg, 0x3ce); smtc_mmiowb(val, 0x3cf); } -static inline void smtc_attrw(int reg, int val) +static inline void smtc_attrw(u8 reg, u8 val) { smtc_mmiorb(0x3da); smtc_mmiowb(reg, 0x3c0); @@ -83,13 +83,13 @@ static inline void smtc_attrw(int reg, int val) smtc_mmiowb(val, 0x3c0); } -static inline void smtc_seqw(int reg, int val) +static inline void smtc_seqw(u8 reg, u8 val) { smtc_mmiowb(reg, 0x3c4); smtc_mmiowb(val, 0x3c5); } -static inline unsigned int smtc_seqr(int reg) +static inline u8 smtc_seqr(u8 reg) { smtc_mmiowb(reg, 0x3c4); return smtc_mmiorb(0x3c5); From patchwork Sat Feb 2 06:16:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Li X-Patchwork-Id: 10794131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A57A6C2 for ; Sat, 2 Feb 2019 06:17:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AF3432B5F for ; Sat, 2 Feb 2019 06:17:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E80F32B64; Sat, 2 Feb 2019 06:17:27 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E606632B5F for ; Sat, 2 Feb 2019 06:17:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726495AbfBBGR0 (ORCPT ); Sat, 2 Feb 2019 01:17:26 -0500 Received: from tomli.me ([153.92.126.73]:45026 "EHLO tomli.me" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbfBBGR0 (ORCPT ); Sat, 2 Feb 2019 01:17:26 -0500 Received: from tomli.me (localhost [127.0.0.1]) by tomli.me (OpenSMTPD) with ESMTP id a5ba1c07; Sat, 2 Feb 2019 06:17:24 +0000 (UTC) X-HELO: localhost.lan Authentication-Results: tomli.me; auth=pass (login) smtp.auth=tomli Received: from Unknown (HELO localhost.lan) (2402:f000:1:1501:200:5efe:7b76:77ab) by tomli.me (qpsmtpd/0.95) with ESMTPSA (DHE-RSA-CHACHA20-POLY1305 encrypted); Sat, 02 Feb 2019 06:17:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=tomli.me; h=from:to:cc:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=1490979754; bh=zS+qFKJ+ykWCn9siHyUTZoQDoSRi7BGV5qc6gtTuzXs=; b=uwCBX5KdK+IRmlyKmE31z9zkOMxjEhsXTQVnvdQZHrcAJecq3SJHKt5D3Hl/dS8liAFp/QoZNgkqWLDrjnCwf8Tnxl40EObpObjGw0tz9Xk5p5a+1s/rUtoN1+IGNt+8syY6i+FiHzwvaHnPPb7nQAl3zEEnqSy6tcgMNrSvfY85408EjbYtSTby5L/lv+6JveZPaemaGMBHvU7KNqTJRsL11Ac8gsUo4utiBDexZ8dmW/lhXvgdB7JgPZSkyKQfyPTXGgHtXzOR0I7+OtbAs0mRcbdDY6/Hri33WIzqJYgI4qY93fxPj8M0JIT6UVRwK4TiCZ4FFmRL7sFcp2oMCg== From: Yifeng Li To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Yifeng Li , Sudip Mukherjee , Teddy Wang , Bartlomiej Zolnierkiewicz Subject: [PATCH 3/8] fbdev: sm712fb: add 2D-related I/O headers and functions. Date: Sat, 2 Feb 2019 14:16:43 +0800 Message-Id: <20190202061648.30374-4-tomli@tomli.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190202061648.30374-1-tomli@tomli.me> References: <20190202061648.30374-1-tomli@tomli.me> MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit adds I/O macros and functions related to 2D opeartions. A hunk of hardware register definitions are taken verbatim from OpenBSD. In addition, a utility function pad_to_dword() is added to help padding data for the 2D engine. It accepts 3, 2, or 1 byte(s) of data, and pads it to a 32-bit word suitable for 2D Drawing Engine. Yes, we can set info->pixmap.scan_align/buf_align = 4 and forget about padding, but it's incompatible with cfb_imageblit() w/ depth == 1. In case we need to fallback (e.g. debugging), it would be inconvenient, so we pad it manually. Signed-off-by: Yifeng Li --- drivers/video/fbdev/sm712.h | 96 +++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/drivers/video/fbdev/sm712.h b/drivers/video/fbdev/sm712.h index 942019dc816a..6d096c1b254c 100644 --- a/drivers/video/fbdev/sm712.h +++ b/drivers/video/fbdev/sm712.h @@ -95,6 +95,102 @@ static inline u8 smtc_seqr(u8 reg) return smtc_mmiorb(0x3c5); } +/* + * DPR (2D drawing engine) + */ +#define DPR_COORDS(x, y) (((x) << 16) | (y)) + +#define SCR_DE_STATUS 0x16 +#define SCR_DE_STATUS_MASK 0x18 +#define SCR_DE_ENGINE_IDLE 0x10 + +#define DPR_BASE 0x00408000 +#define DPR_SRC_COORDS 0x00 +#define DPR_DST_COORDS 0x04 +#define DPR_SPAN_COORDS 0x08 +#define DPR_DE_CTRL 0x0c +#define DPR_PITCH 0x10 +#define DPR_FG_COLOR 0x14 +#define DPR_BG_COLOR 0x18 +#define DPR_STRETCH 0x1c +#define DPR_DE_FORMAT_SELECT 0x1e +#define DPR_COLOR_COMPARE 0x20 +#define DPR_COLOR_COMPARE_MASK 0x24 +#define DPR_BYTE_BIT_MASK 0x28 +#define DPR_CROP_TOPLEFT_COORDS 0x2c +#define DPR_CROP_BOTRIGHT_COORDS 0x30 +#define DPR_MONO_PATTERN_LO32 0x34 +#define DPR_MONO_PATTERN_HI32 0x38 +#define DPR_SRC_WINDOW 0x3c +#define DPR_SRC_BASE 0x40 +#define DPR_DST_BASE 0x44 + +#define DE_CTRL_START 0x80000000 +#define DE_CTRL_RTOL 0x08000000 +#define DE_CTRL_COMMAND_MASK 0x001f0000 +#define DE_CTRL_COMMAND_SHIFT 16 +#define DE_CTRL_COMMAND_BITBLT 0x00 +#define DE_CTRL_COMMAND_SOLIDFILL 0x01 +#define DE_CTRL_COMMAND_HOSTWRITE 0x08 +#define DE_CTRL_ROP2_SELECT 0x00008000 +#define DE_CTRL_ROP2_SRC_IS_PATTERN 0x00004000 +#define DE_CTRL_ROP2_SHIFT 0 +#define DE_CTRL_ROP2_COPY 0x0c +#define DE_CTRL_HOST_SHIFT 22 +#define DE_CTRL_HOST_SRC_IS_MONO 0x01 +#define DE_CTRL_FORMAT_XY 0x00 +#define DE_CTRL_FORMAT_24BIT 0x30 + +/* + * 32-bit I/O for 2D opeartions. + */ +extern void __iomem *smtc_dprbaseaddress; /* DPR, 2D control registers */ + +static inline u8 smtc_dprr(u8 reg) +{ + return readl(smtc_dprbaseaddress + reg); +} + +static inline void smtc_dprw(u8 reg, u32 val) +{ + writel(val, smtc_dprbaseaddress + reg); +} + +static inline void smtc_dprw_16(u8 reg, u16 val) +{ + writew(val, smtc_dprbaseaddress + reg); +} + +static inline u32 pad_to_dword(const u8 *bytes, int length) +{ + u32 dword = 0; + + switch (length) { +#ifdef __BIG_ENDIAN + case 3: + dword |= bytes[2] << 8; + /* fallthrough */ + case 2: + dword |= bytes[1] << 16; + /* fallthrough */ + case 1: + dword |= bytes[0] << 24; + break; +#else + case 3: + dword |= bytes[2] << 16; + /* fallthrough */ + case 2: + dword |= bytes[1] << 8; + /* fallthrough */ + case 1: + dword |= bytes[0]; + break; +#endif + } + return dword; +} + /* The next structure holds all information relevant for a specific video mode. */ From patchwork Sat Feb 2 06:16:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Li X-Patchwork-Id: 10794133 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D6AA0922 for ; Sat, 2 Feb 2019 06:17:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C643832B5F for ; Sat, 2 Feb 2019 06:17:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA92A32B64; Sat, 2 Feb 2019 06:17:35 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E1B732B5F for ; Sat, 2 Feb 2019 06:17:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726975AbfBBGRe (ORCPT ); Sat, 2 Feb 2019 01:17:34 -0500 Received: from tomli.me ([153.92.126.73]:45026 "EHLO tomli.me" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbfBBGRe (ORCPT ); Sat, 2 Feb 2019 01:17:34 -0500 Received: from tomli.me (localhost [127.0.0.1]) by tomli.me (OpenSMTPD) with ESMTP id e6c1c7bf; Sat, 2 Feb 2019 06:17:30 +0000 (UTC) X-HELO: localhost.lan Authentication-Results: tomli.me; auth=pass (login) smtp.auth=tomli Received: from Unknown (HELO localhost.lan) (2402:f000:1:1501:200:5efe:7b76:77ab) by tomli.me (qpsmtpd/0.95) with ESMTPSA (DHE-RSA-CHACHA20-POLY1305 encrypted); Sat, 02 Feb 2019 06:17:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=tomli.me; h=from:to:cc:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=1490979754; bh=zRRs+2REmb3uRgcDWxj43u5Ln6Xr+n114zN49vJ2tyE=; b=TMaPBTHUa0/0/rB6u1qmIxiXNbdw4AlqLYL5HBP10gU/+qkrGywGZdPoUpGmiqtW5nDFdyzFgMriNHzZ3KLWkIynt8jk+AIVKek3ny3/StHD8aFQMk5NMEf5Kcu2oI54Xuzlbt1In9+j8FEZkPfFgCpuhxyjHjnW1SHwM9buO3VDQEpL9Dc0d67ImStTZWjUkVf9y0o8RCv9FirFvyVzka0orz094sMwaE+m5dE/PT0o915nl1wYr3T/Xt3Ofg8Asj8002DWx22gw3rf2xRICSJCkHP4eA+LI6XCzvwcMK96ZH2Cvmo6tgasB2oJcOPiuIxgQINuGP2pK6FmWJcYww== From: Yifeng Li To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Yifeng Li , Sudip Mukherjee , Teddy Wang , Bartlomiej Zolnierkiewicz Subject: [PATCH 4/8] fbdev: sm712fb: support 2D acceleration on SM712 w/ Little-Endian CPU. Date: Sat, 2 Feb 2019 14:16:44 +0800 Message-Id: <20190202061648.30374-5-tomli@tomli.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190202061648.30374-1-tomli@tomli.me> References: <20190202061648.30374-1-tomli@tomli.me> MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Previously, in staging/sm7xxfb (now fbdev/sm712fb), 2D acceleration was implemented, but after its submission, a critical bug that causes total system hang was discovered, as a stopgap measure, 2D ops was completele removed in commit 3af805735a25 ("staging: sm7xx: remove the buggy 2D acceleration support") and never implemented again. It created a massive usability problem - on YeeLoong 8089, a notable MIPS platform which uses SM712 - even scrolling a single line of text on the console required an unaccelerated screen redraw, running "dmesg" typically takes 8-11 seconds, and absurdly, printf(), became a significant performance bottleneck that slows down GCC and "make", make the computer largely unusable. So I decided to take a look. Most of the my actual development was done in 2014 in a personal out-of-tree driver, I did not mainline it because 2D acceleration was not working properly in 24-bit color. I discovered the solution in early 2019 and now it's ready to be mainlined. This commit reimplements the 2D acceleration for sm712fb. Unlike the original implementation, which was messy and unnecessarily complicated by calling a 2D acceleration wrapper file with many unneeded functions, this is a minimum and (relatively) clean implementation. My tests have shown that running "dmesg" only takes 0.9 seconds, a performance boost of 950%. System hangs did not occur in my tests. Currently, 2D acceleration is only supported on SM712 with little-endian CPUs, it's disabled on Big Endian systems and SM720 chips as a safety measure, since I code for myself without any monetary or hardware support from any company or OEMs, I don't have the hardware and it's completely untested. I should be also to purchase a Big Endian test platform and add proper support soon. If you have a Big-Endian platform with SM7xx available for testing, please send an E-mail to me immediately! Thanks! Finally, thanks to Miodrag Vallat and other OpenBSD developers, this work would be impossible without their code, that served as a reference implementation for me. As a historical note, though I'm not extremely sure, but I believe the source of the original system hang was a type punning. unsigned char ajRemain[4]; SMTC_write2Ddataport(0, *(unsigned long *)ajRemain); Type punning is undefined behavior in C, and here it caused an unaligned memory access, which is illegal on MIPS, thus crashing the computer. Signed-off-by: Yifeng Li --- drivers/video/fbdev/sm712.h | 3 + drivers/video/fbdev/sm712fb.c | 396 +++++++++++++++++++++++++++++++++- 2 files changed, 392 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/sm712.h b/drivers/video/fbdev/sm712.h index 6d096c1b254c..b026bb3172aa 100644 --- a/drivers/video/fbdev/sm712.h +++ b/drivers/video/fbdev/sm712.h @@ -139,7 +139,10 @@ static inline u8 smtc_seqr(u8 reg) #define DE_CTRL_HOST_SHIFT 22 #define DE_CTRL_HOST_SRC_IS_MONO 0x01 #define DE_CTRL_FORMAT_XY 0x00 +#define DE_CTRL_FORMAT_8BIT 0x00 +#define DE_CTRL_FORMAT_16BIT 0x10 #define DE_CTRL_FORMAT_24BIT 0x30 +#define DE_CTRL_FORMAT_32BIT 0x20 /* * 32-bit I/O for 2D opeartions. diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c index 8d63bbfef9ea..133e31f75d67 100644 --- a/drivers/video/fbdev/sm712fb.c +++ b/drivers/video/fbdev/sm712fb.c @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -62,11 +63,14 @@ struct smtcfb_info { u8 chip_rev_id; void __iomem *lfb; /* linear frame buffer */ + void __iomem *dp_port; /* drawing processor data port */ void __iomem *dp_regs; /* drawing processor control regs */ void __iomem *vp_regs; /* video processor control regs */ void __iomem *cp_regs; /* capture processor control regs */ void __iomem *mmio; /* memory map IO port */ + bool accel; /* whether to actually use drawing processor */ + u_int width; u_int height; u_int hz; @@ -75,6 +79,7 @@ struct smtcfb_info { }; void __iomem *smtc_regbaseaddress; /* Memory Map IO starting address */ +void __iomem *smtc_dprbaseaddress; /* DPR, 2D control registers */ static const struct fb_var_screeninfo smtcfb_var = { .xres = 1024, @@ -789,14 +794,21 @@ static const struct modeinit vgamode[] = { }, }; -static struct screen_info smtc_scr_info; +/* prototypes of two cross-referenced functions */ +static void smtcfb_reset_accel(void); +static int smtcfb_init_accel(struct smtcfb_info *fb); + +static struct screen_info smtc_scr_info; static char *mode_option; +static bool accel = true; /* can be ignored if not supported */ +static bool accel_status_reported; -/* process command line options, get vga parameter */ +/* process command line options, get vga and accel parameter */ static void __init sm7xx_vga_setup(char *options) { int i; + char *this_opt; if (!options || !*options) return; @@ -813,9 +825,20 @@ static void __init sm7xx_vga_setup(char *options) smtc_scr_info.lfb_height = vesa_mode_table[i].lfb_height; smtc_scr_info.lfb_depth = vesa_mode_table[i].lfb_depth; - return; + break; } } + + while ((this_opt = strsep(&options, ",")) != NULL) { + if (!*this_opt) + continue; + + if (!strcmp(this_opt, "accel:0")) + accel = false; + else if (!strcmp(this_opt, "accel:1")) + accel = true; + } + accel_status_reported = false; } static void sm712_setpalette(int regno, unsigned int red, unsigned int green, @@ -1284,7 +1307,42 @@ static void smtcfb_setmode(struct smtcfb_info *sfb) sfb->width = sfb->fb->var.xres; sfb->height = sfb->fb->var.yres; sfb->hz = 60; + + /* + * We reset the 2D engine twice, once before the modesetting, once + * after the modesetting (mandatory), since users may chance the + * mode on-the-fly. Just be safe. + */ + smtcfb_reset_accel(); + smtc_set_timing(sfb); + + /* + * Currently, 2D acceleration is only supported on SM712 with + * little-endian CPUs, it's disabled on Big Endian systems and SM720 + * chips as a safety measure. Since I don't have monetary or hardware + * support from any company or OEMs, I don't have the hardware and + * it's completely untested. I should be also to purchase a Big Endian + * test platform and add proper support soon. I still have to spend + * 200 USD+ to purchase this piece of 1998's hardware, yikes! If you + * have a Big-Endian platform with SM7xx available for testing, please + * send an E-mail to Tom, thanks! + */ +#ifdef __BIG_ENDIAN + sfb->accel = false; + if (accel) + dev_info(&sfb->pdev->dev, + "2D acceleration is unsupported on Big Endian.\n"); +#endif + if (!accel) { + sfb->accel = false; + dev_info(&sfb->pdev->dev, + "2D acceleration is disabled by the user.\n"); + } + + /* reset 2D engine after a modesetting is mandatory */ + smtcfb_reset_accel(); + smtcfb_init_accel(sfb); } static int smtc_check_var(struct fb_var_screeninfo *var, struct fb_info *info) @@ -1324,6 +1382,317 @@ static struct fb_ops smtcfb_ops = { .fb_write = smtcfb_write, }; +static int smtcfb_wait(struct smtcfb_info *fb) +{ + int i; + u8 reg; + + smtc_dprr(DPR_DE_CTRL); + for (i = 0; i < 10000; i++) { + reg = smtc_seqr(SCR_DE_STATUS); + if ((reg & SCR_DE_STATUS_MASK) == SCR_DE_ENGINE_IDLE) + return 0; + udelay(1); + } + dev_err(&fb->pdev->dev, "2D engine hang detected!\n"); + return -EBUSY; +} + +static void +smtcfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) +{ + u32 width = rect->width, height = rect->height; + u32 dx = rect->dx, dy = rect->dy; + u32 color; + + struct smtcfb_info *sfb = info->par; + + if (unlikely(info->state != FBINFO_STATE_RUNNING)) + return; + + if (unlikely(rect->rop != ROP_COPY)) { + /* + * It must be ROP_XOR. It's only used to combine a hardware + * cursor with the screen, and should never occur. Included + * for completeness. If one wants to implement hardware cursor + * (you don't, hardware only has RGB332 cursor), ROP2_XOR + * should be implemented here. + */ + cfb_fillrect(info, rect); + return; + } + + if ((rect->dx >= info->var.xres_virtual) || + (rect->dy >= info->var.yres_virtual)) + return; + + if (info->fix.visual == FB_VISUAL_TRUECOLOR || + info->fix.visual == FB_VISUAL_DIRECTCOLOR) + color = ((u32 *) (info->pseudo_palette))[rect->color]; + else + color = rect->color; + + if (sfb->fb->var.bits_per_pixel == 24) { + /* + * In 24-bit mode, all x, y coordinates and widths (but not + * height) must be multipiled by three. + */ + dx *= 3; + dy *= 3; + width *= 3; + + /* + * In 24-bit color mode, SOLIDFILL will sometimes put random + * color stripes of garbage on the screen, it seems to be a + * hardware bug. Alternatively, we initialize MONO_PATTERN_LOW + * & HIGH with 0xffffffff (all ones, and we have already set + * that in smtcfb_init_accel). Since the color of this mono + * pattern is controlled by DPR_FG_COLOR, BITBLTing it with + * ROP_COPY is effectively a rectfill(). + */ + smtc_dprw(DPR_FG_COLOR, color); + smtc_dprw(DPR_DST_COORDS, DPR_COORDS(dx, dy)); + smtc_dprw(DPR_SPAN_COORDS, DPR_COORDS(width, height)); + smtc_dprw(DPR_DE_CTRL, DE_CTRL_START | DE_CTRL_ROP2_SELECT | + DE_CTRL_ROP2_SRC_IS_PATTERN | + (DE_CTRL_COMMAND_BITBLT << + DE_CTRL_COMMAND_SHIFT) | + (DE_CTRL_ROP2_COPY << + DE_CTRL_ROP2_SHIFT)); + } else { + smtc_dprw(DPR_FG_COLOR, color); + smtc_dprw(DPR_DST_COORDS, DPR_COORDS(dx, dy)); + smtc_dprw(DPR_SPAN_COORDS, DPR_COORDS(width, height)); + smtc_dprw(DPR_DE_CTRL, DE_CTRL_START | DE_CTRL_ROP2_SELECT | + (DE_CTRL_COMMAND_SOLIDFILL << + DE_CTRL_COMMAND_SHIFT) | + (DE_CTRL_ROP2_COPY << + DE_CTRL_ROP2_SHIFT)); + } + smtcfb_wait(sfb); +} + +static void +smtcfb_copyarea(struct fb_info *info, const struct fb_copyarea *area) +{ + u32 sx = area->sx, sy = area->sy; + u32 dx = area->dx, dy = area->dy; + u32 height = area->height, width = area->width; + u32 direction; + + struct smtcfb_info *sfb = info->par; + + if (unlikely(info->state != FBINFO_STATE_RUNNING)) + return; + if ((sx >= info->var.xres_virtual) || (sy >= info->var.yres_virtual)) + return; + + if (sy < dy || (sy == dy && sx <= dx)) { + sx += width - 1; + dx += width - 1; + sy += height - 1; + dy += height - 1; + direction = DE_CTRL_RTOL; + } else { + direction = 0; + } + + if (sfb->fb->var.bits_per_pixel == 24) { + sx *= 3; + sy *= 3; + dx *= 3; + dy *= 3; + width *= 3; + if (direction == DE_CTRL_RTOL) { + /* + * some hardware shenanigan from the original git + * commit, that is never clearly mentioned in the + * official datasheet. Not sure whether it even + * works correctly. + */ + sx += 2; + dx += 2; + } + } + + smtc_dprw(DPR_SRC_COORDS, DPR_COORDS(sx, sy)); + smtc_dprw(DPR_DST_COORDS, DPR_COORDS(dx, dy)); + smtc_dprw(DPR_SPAN_COORDS, DPR_COORDS(width, height)); + smtc_dprw(DPR_DE_CTRL, + DE_CTRL_START | DE_CTRL_ROP2_SELECT | direction | + (DE_CTRL_COMMAND_BITBLT << DE_CTRL_COMMAND_SHIFT) | + (DE_CTRL_ROP2_COPY << DE_CTRL_ROP2_SHIFT)); + smtcfb_wait(sfb); +} + +static void +smtcfb_imageblit(struct fb_info *info, const struct fb_image *image) +{ + u32 dx = image->dx, dy = image->dy; + u32 width = image->width, height = image->height; + u32 fg_color, bg_color; + + u32 total_bytes, total_dwords, leftovers; + u32 i; + u32 idx = 0; + u32 scanline = image->width >> 3; + + struct smtcfb_info *sfb = info->par; + + if (unlikely(info->state != FBINFO_STATE_RUNNING)) + return; + if ((image->dx >= info->var.xres_virtual) || + (image->dy >= info->var.yres_virtual)) + return; + + if (unlikely(image->depth != 1)) { + /* unsupported depth, fallback to draw Tux */ + cfb_imageblit(info, image); + return; + } + + if (info->fix.visual == FB_VISUAL_TRUECOLOR || + info->fix.visual == FB_VISUAL_DIRECTCOLOR) { + fg_color = ((u32 *) (info->pseudo_palette))[image->fg_color]; + bg_color = ((u32 *) (info->pseudo_palette))[image->bg_color]; + } else { + fg_color = image->fg_color; + bg_color = image->bg_color; + } + + /* total bytes we need to write */ + total_bytes = (width + 7) / 8; + total_dwords = (total_bytes & ~3) / 4; + leftovers = total_bytes & 3; + + if (sfb->fb->var.bits_per_pixel == 24) { + dx *= 3; + dy *= 3; + width *= 3; + } + smtc_dprw(DPR_SRC_COORDS, 0); + smtc_dprw(DPR_DST_COORDS, DPR_COORDS(dx, dy)); + smtc_dprw(DPR_SPAN_COORDS, DPR_COORDS(width, height)); + smtc_dprw(DPR_FG_COLOR, fg_color); + smtc_dprw(DPR_BG_COLOR, bg_color); + smtc_dprw(DPR_DE_CTRL, DE_CTRL_START | DE_CTRL_ROP2_SELECT | + (DE_CTRL_COMMAND_HOSTWRITE << DE_CTRL_COMMAND_SHIFT) | + (DE_CTRL_HOST_SRC_IS_MONO << DE_CTRL_HOST_SHIFT) | + (DE_CTRL_ROP2_COPY << DE_CTRL_ROP2_SHIFT)); + + for (i = 0; i < height; i++) { + iowrite32_rep(sfb->dp_port, &image->data[idx], total_dwords); + if (leftovers) { + /* + * We can set info->pixmap.scan_align/buf_align = 4 + * for automatic padding. But it would be sometimes + * incompatible with cfb_*(), especially imageblit() + * when depth = 1. In case we need to fallback (e.g. + * debugging), it would be inconvenient, so we pad it + * manually. + */ + writel_relaxed( + pad_to_dword( + &image->data[idx + total_dwords * 4], + leftovers), + sfb->dp_port); + } + idx += scanline; + } + mb(); /* ensure all writes to dp_port have finished */ + smtcfb_wait(sfb); +} + +static void smtcfb_reset_accel(void) +{ + u8 reg; + + /* enable Zoom Video Port, 2D Drawing Engine and Video Processor */ + smtc_seqw(0x21, smtc_seqr(0x21) & 0xf8); + + /* abort pending 2D Drawing Engine operations */ + reg = smtc_seqr(0x15); + smtc_seqw(0x15, reg | 0x30); + smtc_seqw(0x15, reg); +} + +/* + * Function smtcfb_reset_accel(); should be called before calling + * this function + */ +static int smtcfb_init_accel(struct smtcfb_info *fb) +{ + + if (accel && !fb->accel) { + fb->fb->flags |= FBINFO_HWACCEL_NONE; + return 0; + } else if (!accel && !fb->accel) { + fb->fb->flags |= FBINFO_HWACCEL_DISABLED; + return 0; + } + + if (smtcfb_wait(fb) != 0) { + fb->fb->flags |= FBINFO_HWACCEL_NONE; + dev_err(&fb->pdev->dev, + "2D acceleration initialization failed!\n"); + fb->accel = false; + return -1; + } + + smtc_dprw(DPR_CROP_TOPLEFT_COORDS, DPR_COORDS(0, 0)); + + /* same width for DPR_PITCH and DPR_SRC_WINDOW */ + smtc_dprw(DPR_PITCH, DPR_COORDS(fb->fb->var.xres, fb->fb->var.xres)); + smtc_dprw(DPR_SRC_WINDOW, + DPR_COORDS(fb->fb->var.xres, fb->fb->var.xres)); + + switch (fb->fb->var.bits_per_pixel) { + case 8: + smtc_dprw_16(DPR_DE_FORMAT_SELECT, + DE_CTRL_FORMAT_XY | DE_CTRL_FORMAT_8BIT); + break; + case 16: + smtc_dprw_16(DPR_DE_FORMAT_SELECT, + DE_CTRL_FORMAT_XY | DE_CTRL_FORMAT_16BIT); + break; + case 24: + smtc_dprw_16(DPR_DE_FORMAT_SELECT, + DE_CTRL_FORMAT_XY | DE_CTRL_FORMAT_24BIT); + smtc_dprw(DPR_PITCH, + DPR_COORDS(fb->fb->var.xres * 3, + fb->fb->var.xres * 3)); + break; + case 32: + smtc_dprw_16(DPR_DE_FORMAT_SELECT, + DE_CTRL_FORMAT_XY | DE_CTRL_FORMAT_32BIT); + break; + } + + smtc_dprw(DPR_BYTE_BIT_MASK, 0xffffffff); + smtc_dprw(DPR_COLOR_COMPARE_MASK, 0); + smtc_dprw(DPR_COLOR_COMPARE, 0); + smtc_dprw(DPR_SRC_BASE, 0); + smtc_dprw(DPR_DST_BASE, 0); + smtc_dprw(DPR_MONO_PATTERN_LO32, 0xffffffff); + smtc_dprw(DPR_MONO_PATTERN_HI32, 0xffffffff); + smtc_dprr(DPR_DST_BASE); + + smtcfb_ops.fb_copyarea = smtcfb_copyarea; + smtcfb_ops.fb_fillrect = smtcfb_fillrect; + smtcfb_ops.fb_imageblit = smtcfb_imageblit; + fb->fb->flags |= FBINFO_HWACCEL_COPYAREA | + FBINFO_HWACCEL_FILLRECT | + FBINFO_HWACCEL_IMAGEBLIT | + FBINFO_READS_FAST; + + /* don't spam the kernel log after each modesetting */ + if (!accel_status_reported) + dev_info(&fb->pdev->dev, "2D acceleration is enabled.\n"); + accel_status_reported = true; + + return 0; +} + /* * Unmap in the memory mapped IO registers */ @@ -1457,10 +1826,14 @@ static int smtcfb_pci_probe(struct pci_dev *pdev, goto failed_fb; } - sfb->mmio = (smtc_regbaseaddress = - sfb->lfb + 0x00700000); + sfb->mmio = sfb->lfb + 0x00700000; + sfb->dp_port = sfb->lfb + 0x00400000; sfb->dp_regs = sfb->lfb + 0x00408000; sfb->vp_regs = sfb->lfb + 0x0040c000; + + smtc_regbaseaddress = sfb->mmio; + smtc_dprbaseaddress = sfb->dp_regs; + sfb->accel = accel; if (sfb->fb->var.bits_per_pixel == 32) { sfb->lfb += big_addr; dev_info(&pdev->dev, "sfb->lfb=%p\n", sfb->lfb); @@ -1482,10 +1855,16 @@ static int smtcfb_pci_probe(struct pci_dev *pdev, smem_size = SM722_VIDEOMEMORYSIZE; sfb->dp_regs = ioremap(mmio_base, 0x00a00000); sfb->lfb = sfb->dp_regs + 0x00200000; - sfb->mmio = (smtc_regbaseaddress = - sfb->dp_regs + 0x000c0000); + sfb->mmio = sfb->dp_regs + 0x000c0000; sfb->vp_regs = sfb->dp_regs + 0x800; + smtc_regbaseaddress = sfb->mmio; + smtc_dprbaseaddress = sfb->dp_regs; + sfb->accel = false; + if (accel) + dev_info(&pdev->dev, + "2D acceleration is unsupported on SM720\n"); + smtc_seqw(0x62, 0xff); smtc_seqw(0x6a, 0x0d); smtc_seqw(0x6b, 0x02); @@ -1659,6 +2038,9 @@ static void __exit sm712fb_exit(void) module_exit(sm712fb_exit); +module_param(accel, bool, 0444); +MODULE_PARM_DESC(accel, "Use Acceleration (2D Drawing) Engine (default = 1)"); + MODULE_AUTHOR("Siliconmotion "); MODULE_DESCRIPTION("Framebuffer driver for SMI Graphic Cards"); MODULE_LICENSE("GPL"); From patchwork Sat Feb 2 06:16:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Li X-Patchwork-Id: 10794135 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D3DD922 for ; Sat, 2 Feb 2019 06:17:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E02C32B5F for ; Sat, 2 Feb 2019 06:17:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5216F32B64; Sat, 2 Feb 2019 06:17:40 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8766B32B5F for ; Sat, 2 Feb 2019 06:17:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727249AbfBBGRj (ORCPT ); Sat, 2 Feb 2019 01:17:39 -0500 Received: from tomli.me ([153.92.126.73]:45026 "EHLO tomli.me" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbfBBGRj (ORCPT ); Sat, 2 Feb 2019 01:17:39 -0500 Received: from tomli.me (localhost [127.0.0.1]) by tomli.me (OpenSMTPD) with ESMTP id 6ae1789f; Sat, 2 Feb 2019 06:17:35 +0000 (UTC) X-HELO: localhost.lan Authentication-Results: tomli.me; auth=pass (login) smtp.auth=tomli Received: from Unknown (HELO localhost.lan) (2402:f000:1:1501:200:5efe:7b76:77ab) by tomli.me (qpsmtpd/0.95) with ESMTPSA (DHE-RSA-CHACHA20-POLY1305 encrypted); Sat, 02 Feb 2019 06:17:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=tomli.me; h=from:to:cc:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=1490979754; bh=eESnIlzms/lXDJ8+ZfW4Pm3+rcBdmlNQmW0HjusPOLU=; b=LIkFXrNKztYk8PRlQDKhYW7sy4lJPC86csZOl3efS4FcvS9Knd0C+x47GEU4ro4OXX09dhVJm/b6S+pevLnCyMqNIxlQwbZKr/jU/Cw4sXPPkNJ35TA8OYq2EJyItXyPLTq2K7MVH6k/NkIpMS5JNpUWcykRuxGkGbnbUP8Pafm+J4WYxmBu3kUrKs/MkACcvyhsFrO3/KMAafnuTwmjuwwq6qk89z5XRz3KjGm6x3QYlNmBLIWzdYJQdpsAXHuP6gi2pRT7+RbSYjNAf9t5/UgXcuU7JgLbGZRZIDo1CVHMQ2DrT+bXGzLQ78C1lG5LxPQ59kOGClaH61OVMQUzTw== From: Yifeng Li To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Yifeng Li , Sudip Mukherjee , Teddy Wang , Bartlomiej Zolnierkiewicz Subject: [PATCH 5/8] fbdev: sm712fb: add 32-bit color modes, drops some other modes. Date: Sat, 2 Feb 2019 14:16:45 +0800 Message-Id: <20190202061648.30374-6-tomli@tomli.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190202061648.30374-1-tomli@tomli.me> References: <20190202061648.30374-1-tomli@tomli.me> MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The modesetting in sm712fb is an ugly hack. First, all the registers are programmed by hardcoded register arrays, which makes it difficult to support different variations of color depths, refresh rates, CRT/LCD panel, etc of the same resolution. Second, it means the standard fb_find_mode() cannot be used and a confusing non-standard "vga=" parameter is needed. Third, there's only minimum differences between some modes, yet around 70 lines of code and 100 registers are needed to be indepentently specified for each mode. Fourth, the register between some modes are inconsistent: the register configuration of different color depths in 640 x 480 modes are identical, but for 800 x 600 modes it's completely different. Also, some modes can drive the LCD panel properly yet some other modes will only show a white screen of death on the LCD panel. Fifth, there is a specific hack for Lemote Loongson 8089D laptop, the 1024x768, 16-bit color mode was modified to drive its LCD panel and changed to 1024x600, but the original mode was not preserved, so 1024x768 16-bit color mode is completely unsupported. Sixth, some modes, such as 32-bit color modes, are supported but never listed, and some modes are listed, such as 1280x1024 modes, but never supported by the register configuration arrays. And some modes are partially implemented but neither listed nor supported, i.e. the 8-bit color modes. Fixing these problems requires a complete rewrite of modesetting code, which is well-beyond my motivation. This commit only perform a minimum cleanup: 1. Remove the 320 x 240 register settings, since there are never listed and never actually being used. This resolution is not even supported by vesafb, so it's safe to assume that no one is using such hardware. Future developers who needs them can simply recover them from the git history. 2. Remove 1280x1024 modes and 8-bit color modes. They are listed but never supported by the register array. So it doesn't work in the beginning, and only gives a black screen. 3. Add 32-bit color modes. They are supported but never listed, and are useful to some users. Signed-off-by: Yifeng Li --- drivers/video/fbdev/sm712fb.c | 158 +++++++--------------------------- 1 file changed, 31 insertions(+), 127 deletions(-) diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c index 133e31f75d67..0cc395d52057 100644 --- a/drivers/video/fbdev/sm712fb.c +++ b/drivers/video/fbdev/sm712fb.c @@ -118,25 +118,48 @@ struct vesa_mode { }; static const struct vesa_mode vesa_mode_table[] = { - {"0x301", 640, 480, 8}, - {"0x303", 800, 600, 8}, - {"0x305", 1024, 768, 8}, - {"0x307", 1280, 1024, 8}, - {"0x311", 640, 480, 16}, {"0x314", 800, 600, 16}, {"0x317", 1024, 768, 16}, - {"0x31A", 1280, 1024, 16}, {"0x312", 640, 480, 24}, {"0x315", 800, 600, 24}, {"0x318", 1024, 768, 24}, - {"0x31B", 1280, 1024, 24}, + + {"0x329", 640, 480, 32}, + {"0x32e", 800, 600, 32}, + {"0x338", 1024, 768, 32}, }; /********************************************************************** SM712 Mode table. - **********************************************************************/ + + The modesetting in sm712fb is an ugly hack. First, all the registers + are programmed by hardcoded register arrays, which makes it difficult + to support different variations of color depths, refresh rates, CRT/LCD + panel, etc of the same resolution. Second, it means the standard + fb_find_mode() cannot be used and a confusing non-standard "vga=" + parameter is needed. Third, there's only minimum differences between + some modes, yet around 70 lines of code and 100 registers are needed to + be indepentently specified for each mode. Fourth, the register between + some modes are inconsistent: the register configuration of different + color depths in 640 x 480 modes are identical, but for 800 x 600 modes + it's completely different. Also, some modes can drive the LCD panel + properly yet some other modes will only show a white screen of death on + the LCD panel. Fifth, there is a specific hack for Lemote Loongson 8089D + laptop, the 1024x768, 16-bit color mode was modified to drive its LCD panel + and changed to 1024x600, but the original mode was not preserved, so + 1024x768 16-bit color mode is completely unsupported. And previously, + some modes are listed, such as 1280x1024 modes, but never supported by + the register configuration arrays, so they are now removed. And some modes + are partially implemented but neither listed nor supported, i.e. the 8-bit + color modes, so they have been removed from vesa_mode_table, too. + + I'm not the original author of the code, fixing these problems requires a + complete rewrite of modesetting code, which is well-beyond my motivation. + + See Documentation/fb/sm712fb.txt for more information. +**********************************************************************/ static const struct modeinit vgamode[] = { { /* mode#0: 640 x 480 16Bpp 60Hz */ @@ -673,125 +696,6 @@ static const struct modeinit vgamode[] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03, }, }, - { /* mode#6: 320 x 240 16Bpp 60Hz */ - 320, 240, 16, 60, - /* Init_MISC */ - 0xEB, - { /* Init_SR0_SR4 */ - 0x03, 0x01, 0x0F, 0x03, 0x0E, - }, - { /* Init_SR10_SR24 */ - 0xF3, 0xB6, 0xC0, 0xDD, 0x00, 0x0E, 0x17, 0x2C, - 0x99, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xC4, 0x32, 0x02, 0x01, 0x01, - }, - { /* Init_SR30_SR75 */ - 0x38, 0x03, 0x20, 0x09, 0xC0, 0x3A, 0x3A, 0x3A, - 0x3A, 0x3A, 0x3A, 0x3A, 0x00, 0x00, 0x03, 0xFF, - 0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC, - 0x20, 0x0C, 0x44, 0x20, 0x00, 0x00, 0x00, 0x3A, - 0x06, 0x68, 0xA7, 0x7F, 0x83, 0x24, 0xFF, 0x03, - 0x00, 0x60, 0x59, 0x3A, 0x3A, 0x00, 0x00, 0x3A, - 0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00, - 0x50, 0x03, 0x74, 0x14, 0x08, 0x43, 0x08, 0x43, - 0x04, 0x45, 0x30, 0x30, 0x40, 0x20, - }, - { /* Init_SR80_SR93 */ - 0xFF, 0x07, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x3A, - 0xF7, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3A, 0x3A, - 0x00, 0x00, 0x00, 0x00, - }, - { /* Init_SRA0_SRAF */ - 0x00, 0xFB, 0x9F, 0x01, 0x00, 0xED, 0xED, 0xED, - 0x7B, 0xFB, 0xFF, 0xFF, 0x97, 0xEF, 0xBF, 0xDF, - }, - { /* Init_GR00_GR08 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, - 0xFF, - }, - { /* Init_AR00_AR14 */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x41, 0x00, 0x0F, 0x00, 0x00, - }, - { /* Init_CR00_CR18 */ - 0xA3, 0x7F, 0x7F, 0x00, 0x85, 0x16, 0x24, 0xF5, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x09, 0xFF, 0x80, 0x40, 0xFF, 0x00, 0xE3, - 0xFF, - }, - { /* Init_CR30_CR4D */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20, - 0x00, 0x00, 0x30, 0x40, 0x00, 0xFF, 0xBF, 0xFF, - 0x2E, 0x27, 0x00, 0x2b, 0x0c, 0x0F, 0xEF, 0x00, - 0xFe, 0x0f, 0x01, 0xC0, 0x27, 0xEF, - }, - { /* Init_CR90_CRA7 */ - 0x55, 0xD9, 0x5D, 0xE1, 0x86, 0x1B, 0x8E, 0x26, - 0xDA, 0x8D, 0xDE, 0x94, 0x00, 0x00, 0x18, 0x00, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03, - }, - }, - - { /* mode#8: 320 x 240 32Bpp 60Hz */ - 320, 240, 32, 60, - /* Init_MISC */ - 0xEB, - { /* Init_SR0_SR4 */ - 0x03, 0x01, 0x0F, 0x03, 0x0E, - }, - { /* Init_SR10_SR24 */ - 0xF3, 0xB6, 0xC0, 0xDD, 0x00, 0x0E, 0x17, 0x2C, - 0x99, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xC4, 0x32, 0x02, 0x01, 0x01, - }, - { /* Init_SR30_SR75 */ - 0x38, 0x03, 0x20, 0x09, 0xC0, 0x3A, 0x3A, 0x3A, - 0x3A, 0x3A, 0x3A, 0x3A, 0x00, 0x00, 0x03, 0xFF, - 0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC, - 0x20, 0x0C, 0x44, 0x20, 0x00, 0x00, 0x00, 0x3A, - 0x06, 0x68, 0xA7, 0x7F, 0x83, 0x24, 0xFF, 0x03, - 0x00, 0x60, 0x59, 0x3A, 0x3A, 0x00, 0x00, 0x3A, - 0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00, - 0x50, 0x03, 0x74, 0x14, 0x08, 0x43, 0x08, 0x43, - 0x04, 0x45, 0x30, 0x30, 0x40, 0x20, - }, - { /* Init_SR80_SR93 */ - 0xFF, 0x07, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x3A, - 0xF7, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3A, 0x3A, - 0x00, 0x00, 0x00, 0x00, - }, - { /* Init_SRA0_SRAF */ - 0x00, 0xFB, 0x9F, 0x01, 0x00, 0xED, 0xED, 0xED, - 0x7B, 0xFB, 0xFF, 0xFF, 0x97, 0xEF, 0xBF, 0xDF, - }, - { /* Init_GR00_GR08 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, - 0xFF, - }, - { /* Init_AR00_AR14 */ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, - 0x41, 0x00, 0x0F, 0x00, 0x00, - }, - { /* Init_CR00_CR18 */ - 0xA3, 0x7F, 0x7F, 0x00, 0x85, 0x16, 0x24, 0xF5, - 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x09, 0xFF, 0x80, 0x40, 0xFF, 0x00, 0xE3, - 0xFF, - }, - { /* Init_CR30_CR4D */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20, - 0x00, 0x00, 0x30, 0x40, 0x00, 0xFF, 0xBF, 0xFF, - 0x2E, 0x27, 0x00, 0x2b, 0x0c, 0x0F, 0xEF, 0x00, - 0xFe, 0x0f, 0x01, 0xC0, 0x27, 0xEF, - }, - { /* Init_CR90_CRA7 */ - 0x55, 0xD9, 0x5D, 0xE1, 0x86, 0x1B, 0x8E, 0x26, - 0xDA, 0x8D, 0xDE, 0x94, 0x00, 0x00, 0x18, 0x00, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03, - }, - }, }; From patchwork Sat Feb 2 06:16:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Li X-Patchwork-Id: 10794137 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73F1F6C2 for ; Sat, 2 Feb 2019 06:17:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6496132B5F for ; Sat, 2 Feb 2019 06:17:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58DF632B64; Sat, 2 Feb 2019 06:17:46 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A233932B5F for ; Sat, 2 Feb 2019 06:17:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727276AbfBBGRp (ORCPT ); Sat, 2 Feb 2019 01:17:45 -0500 Received: from tomli.me ([153.92.126.73]:45026 "EHLO tomli.me" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbfBBGRp (ORCPT ); Sat, 2 Feb 2019 01:17:45 -0500 Received: from tomli.me (localhost [127.0.0.1]) by tomli.me (OpenSMTPD) with ESMTP id da4f8d5b; Sat, 2 Feb 2019 06:17:41 +0000 (UTC) X-HELO: localhost.lan Authentication-Results: tomli.me; auth=pass (login) smtp.auth=tomli Received: from Unknown (HELO localhost.lan) (2402:f000:1:1501:200:5efe:7b76:77ab) by tomli.me (qpsmtpd/0.95) with ESMTPSA (DHE-RSA-CHACHA20-POLY1305 encrypted); Sat, 02 Feb 2019 06:17:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=tomli.me; h=from:to:cc:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=1490979754; bh=ymwVquARYH25vOe0O0vYizscGzeglujnl89fDE4zx3I=; b=ppagsjEdIHvlB6sPrGfHd5Ve9YQfXFruWZX/MERpyFJoeBHogf+Nn5fWDR3ElZctsk1siYybgFmOotxP8jmnnyA/sRvC2rDbqmUHx2vi/TTQ8qrNFxGrHCAdFCvs1yDJedaNzpyyoFDnsar7lRD3nkh4MmotSUgydeCC2nHpnCcMZyb37rtn17d2xIvCFLniWDfy5WIkayfKv0RvPhmgu9xx1i3m49/7SmWesDzjlTpcb+Amh8pqJie4OrE9yiVuOBVhkTmDFjrrsyhY3bIFmbZVXs5AtYxaGbQAnpZpUeS1AY1krng2pcSAdm3cQNUXyn03wRF4RqOTNOjC4fTlnQ== From: Yifeng Li To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Yifeng Li , Sudip Mukherjee , Teddy Wang , Bartlomiej Zolnierkiewicz , Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH 6/8] Documentation: fb: sm712fb: add information mainly about 2D. Date: Sat, 2 Feb 2019 14:16:46 +0800 Message-Id: <20190202061648.30374-7-tomli@tomli.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190202061648.30374-1-tomli@tomli.me> References: <20190202061648.30374-1-tomli@tomli.me> MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commits add information about 32-bit color, 2D acceleration, as well as adding additional, general information about the hardware and many existing problems of the sm712fb driver. Signed-off-by: Yifeng Li --- Documentation/fb/sm712fb.txt | 123 +++++++++++++++++++++++++++++++---- 1 file changed, 110 insertions(+), 13 deletions(-) diff --git a/Documentation/fb/sm712fb.txt b/Documentation/fb/sm712fb.txt index c388442edf51..906b48aa40e4 100644 --- a/Documentation/fb/sm712fb.txt +++ b/Documentation/fb/sm712fb.txt @@ -1,31 +1,128 @@ What is sm712fb? ================= -This is a graphics framebuffer driver for Silicon Motion SM712 based processors. +"sm712fb" is a graphics framebuffer driver for Silicon Motion SM710 (LynxEM), +SM712 (LynxEM+), and SM720 (Lynx3DM, Lynx3DM+, aka. LynxEM4+) series of +video controllers. This series of video controller is a legacy from ~1998, +and was used on many classic, "prehistoric" laptops from 1998-2004, such as +IBM Thinkpad S30 and 240X. It was also used on some servers, industrial +computers, x86 and non-x86 embedded devices where only basic graphics was +needed. + +Notably, Lemote YeeLoong 8089, a MIPS laptop based on the Chinese Loongson +2F MIPS processor, is also using this chip because of hardware constraints, +and at a time, somewhat popular in the free software community due the +fact that it was the first laptop powered exclusively by free software, +and it was also an inexpensive platform for non-x86 hobbyists to explore. How to use it? ============== -Switching modes is done using the video=sm712fb:... boot parameter. - -If you want, for example, enable a resolution of 1280x1024x24bpp you should -pass to the kernel this command line: "video=sm712fb:0x31B". +You should not compile-in vesafb, since SM7xx can be used in a VGA +compatible mode, resulting conflicts with this driver. In addition, +the VGA compatible mode was never tested by the maintainers. -You should not compile-in vesafb. +Currently, the driver supports 3 modes: 640x480, 800x600, 1024x768, +at 16, 24 or 32-bit depth. Switching modes is done using the +`video=sm712fb:0x___` boot parameter. If you want, for example, +enable a resolution of 1280x1024x24bpp, you should pass to the kernel +this command line: "video=sm712fb:0x31B". -Currently supported video modes are: +Please consult the following table for the hexadecimal codes of +different modes. [Graphic modes] -bpp | 640x480 800x600 1024x768 1280x1024 -----+-------------------------------------------- - 8 | 0x301 0x303 0x305 0x307 - 16 | 0x311 0x314 0x317 0x31A - 24 | 0x312 0x315 0x318 0x31B +bpp | 640x480 800x600 1024x768 +----+--------------------------- + 16 | 0x311 0x314 0x317 + 24 | 0x312 0x315 0x318 + 32 | 0x329 0x32E 0x338 + +32-bit is really 8:8:8:8, but the final 8-bit number is an "empty" +alpha channel, it's otherwise equal to 24-bit color. However, they +could still be useful. For example, "fbterm" supports 32-bit mode +but not 24-bit mode. + +Notes about Modesetting +======================== + +The modesetting code in sm712fb has major problems. + +* Switching to 8-bit color mode will result in a black screen, so +they are removed from the list of supported graphic modes. But they +can still be switched to on-the-fly, don't do that then! + +* Only a refresh rate of 60 Hz is supported. + +* 1024x768 with 16-bit color is not really supported, because the +registers have been hacked by the original developer to adapt +the 1024x600 screen on Lemote YeeLoong 8089. + +* If you are using a Lemote YeeLoong 8089, please remember that only +the 1024x768 modes are guaranteed to drive the LCD panel properly. +Other modes are meant to drive a CRT, and may drive the LCD incorrectly +and result in a white screen with random garbage. External VGA output is +unaffected. + +Due to the way registers are hardcoded, it's impossible to fix them +without a major code rewrite. If you've been hit by these problems badly +and really need to get them fixed, please contact the driver maintainers. + +2D acceleration +============== + +Without 2D acceleration, the framebuffer suffers from extremely low performance, +even scrolling a single line of text on the console required an unaccelerated +screen redraw. Thus, 2D acceleration is enable by default. However, currently +it's only supported on SM710/712 with Little-Endian CPUs. Big-endian and +SM720 devices are currently not supported. + +2D acceleration can be controlled using the `video=sm712fb:accel:1` parameter. +The default option, "1" activate 2D acceleration. If you have problems, you can +set "0" to disable it. Different options can be separated by a comma, for +example, "video=sm712fb:0x31B,accel:0" set the resolution to 1280x1024x24bpp +while disabling the 2D acceleration. + +Although it has been extensively tested by the maintainer, 2D acceleration +in 24-bit color mode may still have minor issues. If you've encounter any +screen glitches in 24-bit mode in Linux framebuffer the framebuffer, don't +hurry disabling it, you should try switching to 32-bit mode first, normally +it should fix the problem. If you can reliably reproduce the screen glitches, +please report your method to the maintainers. Missing Features ================ (alias TODO list) - * 2D acceleratrion +The following features are not implemented in this driver, + + * 2D acceleration on SM720 and Big-Endian CPUs. + * More VGA modes. * dual-head support + * hardware cursor support + +The first feature is planned to be implemented soon, but the maintainer +does not receive any monetary or hardware support from any company or OEMs, +and he has to purchase a test platform personally. The 1998's hardware +still costs 200 USD+, so don't expected an ETA. If you have a Big-Endian +platform and willing to help testing, please contact the maintainer, thanks! + +Other VGA modes, dual-head, or hardware cursor support should be possible to +implement, but parts of the code must be rewritten, and there's little demand +for them on this legacy (retro?) platform, so there's no plan to implement them. +If you have a genuine need for them, please contact the maintainers. + +Maintainers +================ + +This driver is maintained by + + * Tom Li + * Sudip Mukherjee + * Teddy Wang + +Tom Li was the last contributor of this driver who implemented 2D acceleration, +and is the main author of this documentation, please send any bug reports or +requests to Tom, but don't forget to CC other maintainers as well to make everyone +be informed. From patchwork Sat Feb 2 06:16:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Li X-Patchwork-Id: 10794139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E2FB922 for ; Sat, 2 Feb 2019 06:17:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FA7D32B5F for ; Sat, 2 Feb 2019 06:17:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23C3D32B64; Sat, 2 Feb 2019 06:17:57 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6D3132B5F for ; Sat, 2 Feb 2019 06:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727290AbfBBGR4 (ORCPT ); Sat, 2 Feb 2019 01:17:56 -0500 Received: from tomli.me ([153.92.126.73]:45026 "EHLO tomli.me" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbfBBGR4 (ORCPT ); Sat, 2 Feb 2019 01:17:56 -0500 Received: from tomli.me (localhost [127.0.0.1]) by tomli.me (OpenSMTPD) with ESMTP id 2477a273; Sat, 2 Feb 2019 06:17:53 +0000 (UTC) X-HELO: localhost.lan Authentication-Results: tomli.me; auth=pass (login) smtp.auth=tomli Received: from Unknown (HELO localhost.lan) (2402:f000:1:1501:200:5efe:7b76:77ab) by tomli.me (qpsmtpd/0.95) with ESMTPSA (DHE-RSA-CHACHA20-POLY1305 encrypted); Sat, 02 Feb 2019 06:17:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=tomli.me; h=from:to:cc:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=1490979754; bh=8VKQSE7QUu2B2RUs/34CkwDT/6pGZ5n0b6W1DBUTy74=; b=vRdP6HIbOCtPI/IkULgEE9MZ/tj6P9Dyj+cI9kaxY5Me5LVI8wex2PONOKTT7KbviQJ1sPXpGHxip10aV69WyRPC+tSn+tLEKKC58d0Fw5Bp7Bw4M3WEmNzATuH4JmHFi0bGmSdTQREy2en2KemfT0KX8qIV46AbQTuTK5rEM1grpJT6afGpAgSKtbSszqdmLSN24qTDIu2suh7A+FB8jHsmzL4Uy1slCAEjL1FyaBxwoKiyRlziGZrs3eMdgFhAFbNqXok2rW4n0f4P8XgpPapBKX8ZRHMvvycGMnjbQYHtjZKoycj4WyjbdG8im9P4WqBJ6l8/ld/RUTmXfmk4Zw== From: Yifeng Li To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Yifeng Li , Bartlomiej Zolnierkiewicz , Sudip Mukherjee , Teddy Wang , Geert Uytterhoeven , Simon Horman , Laurent Pinchart , Randy Dunlap , Ulf Magnusson , Arnd Bergmann Subject: [PATCH 7/8] fbdev: sm712fb: Kconfig: add information about docs. Date: Sat, 2 Feb 2019 14:16:47 +0800 Message-Id: <20190202061648.30374-8-tomli@tomli.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190202061648.30374-1-tomli@tomli.me> References: <20190202061648.30374-1-tomli@tomli.me> MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commits update the Kconfig description of sm712fb, and inform the user about the existence of documentation. Signed-off-by: Yifeng Li --- drivers/video/fbdev/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index ae7712c9687a..4f3c0075352a 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -2302,6 +2302,10 @@ config FB_SM712 called sm712fb. If you want to compile it as a module, say M here and read . + Warning: this driver has many known problems and limitations, + please make sure you've checked the documentation, at + . + source "drivers/video/fbdev/omap/Kconfig" source "drivers/video/fbdev/omap2/Kconfig" source "drivers/video/fbdev/mmp/Kconfig" From patchwork Sat Feb 2 06:16:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yifeng Li X-Patchwork-Id: 10794141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB81D922 for ; Sat, 2 Feb 2019 06:18:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9B3E32B60 for ; Sat, 2 Feb 2019 06:18:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C89DC32B65; Sat, 2 Feb 2019 06:18:21 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CC7B32B60 for ; Sat, 2 Feb 2019 06:18:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726592AbfBBGSV (ORCPT ); Sat, 2 Feb 2019 01:18:21 -0500 Received: from tomli.me ([153.92.126.73]:45082 "EHLO tomli.me" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726011AbfBBGSU (ORCPT ); Sat, 2 Feb 2019 01:18:20 -0500 Received: from tomli.me (localhost [127.0.0.1]) by tomli.me (OpenSMTPD) with ESMTP id 28ea7a8a; Sat, 2 Feb 2019 06:18:18 +0000 (UTC) X-HELO: localhost.lan Authentication-Results: tomli.me; auth=pass (login) smtp.auth=tomli Received: from Unknown (HELO localhost.lan) (2402:f000:1:1501:200:5efe:7b76:77ab) by tomli.me (qpsmtpd/0.95) with ESMTPSA (DHE-RSA-CHACHA20-POLY1305 encrypted); Sat, 02 Feb 2019 06:18:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=tomli.me; h=from:to:cc:subject:date:message-id:in-reply-to:references:mime-version:content-transfer-encoding; s=1490979754; bh=Gmm5seB3OZi3kf409TzIneYpUn7FFA/oBWAnHfi8Z/o=; b=SVEHHSxkI3eRM4pTqrepvVSEnZunWAerrXdIEmEwfxE+oMHCUTsBNbmfddhu8uQifmMe/CyYGnrR61wA3tVWiggHUKH4+oYyb0pXXzycC9V03QrJV6aelyth6ztQI/Q8hWvZKmW6QIXFUR+CTf+/bDQb2hNfpLrrR4mSHeo8ZyhlK1W0I4V0OEzTb7Ip+nSGwvVVwBthqayAetjSG7fwTUTKzn7mkTqL1VkjQ8H9ZHlRDZcNilFJ//WBxIQYpKdz6asWHsY+zvxk/nd4wmeq9GgqhzFl36k2WXW+BqwwoLmb5+/kRejK7lLOcloVbVY8pQt0VADAxFVeKeR96wmTVg== From: Yifeng Li To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Yifeng Li , Sudip Mukherjee , Teddy Wang , Bartlomiej Zolnierkiewicz , Mauro Carvalho Chehab , "David S. Miller" , Greg Kroah-Hartman , Andrew Morton , Nicolas Ferre , Arnd Bergmann Subject: [PATCH 8/8] MAINTAINERS: sm712fb: list myself as one maintainer. Date: Sat, 2 Feb 2019 14:16:48 +0800 Message-Id: <20190202061648.30374-9-tomli@tomli.me> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190202061648.30374-1-tomli@tomli.me> References: <20190202061648.30374-1-tomli@tomli.me> MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I have working on the sm712fb driver for a while and have some familiarity with this hardware, I'll be helping working on and testing problems of this driver, so add myself to the MAINTAINERS file. Signed-off-by: Yifeng Li --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 51029a425dbe..d62adb2caa87 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13838,6 +13838,7 @@ F: drivers/input/touchscreen/silead.c F: drivers/platform/x86/touchscreen_dmi.c SILICON MOTION SM712 FRAME BUFFER DRIVER +M: Tom Li M: Sudip Mukherjee M: Teddy Wang M: Sudip Mukherjee