From patchwork Thu Dec 12 03:39:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 11286933 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D033C138D for ; Thu, 12 Dec 2019 03:44:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A986C214D8 for ; Thu, 12 Dec 2019 03:44:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ur+iuzAI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A986C214D8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bMrVpEZOIYxpCY+s5yEnamgXOfWbldu4CFFCks3Y4UM=; b=Ur+iuzAIaZXbEq BtUeC6cSpgJ3EfrWGHSdleoKgvL9gLHHBqySCmS725c+upX+URvT/F8L2nYKYH064DC8L27s0CWnZ tVXsRDNk7BD/1f2wEIU+hcp+aDjysLrw0yS87aq4h4ZhdAsJvTyXYOtRmUWynKjqZ5Y7MGzgNP37g s8lZ53mBcQ3WTcUBlFZ1gh6rVcakvl97cYCS3XuIMHclbLInDVfobLwsXiaqC2NHaeSKNQe5yaT52 K9WIkuwpe73yC9x4RYamb/TbLPUlCAXkffPui6u698/2C8BsExd+mCr/ETdMM8m/EHUqvk496kmBw Tdv4Fi5GBiSMvtp57j0Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifFP9-00060j-Ie; Thu, 12 Dec 2019 03:44:43 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ifFKj-0000tc-AZ; Thu, 12 Dec 2019 03:40:15 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 66D56AF43; Thu, 12 Dec 2019 03:40:07 +0000 (UTC) From: =?utf-8?q?Andreas_F=C3=A4rber?= To: linux-realtek-soc@lists.infradead.org, linux-leds@vger.kernel.org Subject: [RFC 22/25] leds: tm1826: Add combined glyph support Date: Thu, 12 Dec 2019 04:39:49 +0100 Message-Id: <20191212033952.5967-23-afaerber@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20191212033952.5967-1-afaerber@suse.de> References: <20191212033952.5967-1-afaerber@suse.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191211_194009_638467_053758E7 X-CRM114-Status: GOOD ( 11.81 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [195.135.220.15 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, Jacek Anaszewski , Pavel Machek , =?utf-8?q?Andreas_F=C3=A4rber?= , linux-arm-kernel@lists.infradead.org, Dan Murphy Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Allow to squeeze the text "HEllO" into a 4-digit display, as seen on MeLE V9 TV box. Enable this combining mode only if the text would overflow. Signed-off-by: Andreas Färber --- drivers/leds/leds-tm1628.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds-tm1628.c b/drivers/leds/leds-tm1628.c index e2c2a5d91596..0c0d099de8b0 100644 --- a/drivers/leds/leds-tm1628.c +++ b/drivers/leds/leds-tm1628.c @@ -347,6 +347,28 @@ static u8 tm1628_get_char_ssd_map(char ch) return 0x0; } +struct tm1628_ssd_glyph { + char *str; + u8 segs; +}; + +static const struct tm1628_ssd_glyph tm1628_glyph_ssd_map[] = { + { "ll", SSD_TOP_LEFT | SSD_BOTTOM_LEFT | + SSD_TOP_RIGHT | SSD_BOTTOM_RIGHT }, +}; + +static u8 tm1628_get_glyph_ssd_map(const char *str) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(tm1628_glyph_ssd_map); i++) { + if (!strncmp(tm1628_glyph_ssd_map[i].str, str, 2)) + return tm1628_glyph_ssd_map[i].segs; + } + + return 0x0; +} + static int tm1628_display_apply_map(struct tm1628 *s, struct tm1628_display *display, u8 map) { @@ -366,7 +388,7 @@ static ssize_t text_store(struct device *dev, { struct tm1628 *s = dev_get_drvdata(dev); size_t offset, len = count; - u8 map; + u8 map, glyph_map; int i, ret; if (len > 0 && buf[len - 1] == '\n') @@ -375,6 +397,13 @@ static ssize_t text_store(struct device *dev, for (i = 0, offset = 0; i < s->num_displays; i++) { if (offset < len) { map = tm1628_get_char_ssd_map(buf[offset]); + if (offset + 1 < len && len > s->num_displays) { + glyph_map = tm1628_get_glyph_ssd_map(buf + offset); + if (glyph_map) { + map = glyph_map; + offset++; + } + } offset++; } else map = 0x0;