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: 181399 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp371751ile; Wed, 11 Dec 2019 19:40:45 -0800 (PST) X-Google-Smtp-Source: APXvYqyzjK1C4tSQPPj725a5BbX6tVJ3/iqce4Pplv7fZWcLv3QVCc4xqgxwRE8F1NwTJS2OiGxR X-Received: by 2002:a05:6830:605:: with SMTP id w5mr5435477oti.298.1576122045129; Wed, 11 Dec 2019 19:40:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576122045; cv=none; d=google.com; s=arc-20160816; b=A01fG5DcYcrsxl4s2DGs9LGK7uS0krTnzpnMHdmeYkxV6Sf+aTw+pOVRw9/SmdW6k/ PboFwvVucbX/moK3tQQ7VD18JxQeOoMaWpp5sAIOpzSWZE072JNiqDhcbFar49V5Nq0B KZ+X2E6kHmGXv1PtIPB8YrZzc/n6Ctw4VfYL4oCS8feTZmABbtzYF1Ii6YKCd6/NLnlE BB13chQ9E0uBhzE1IWknaD4QwGwVZf/c0Zi7CuQQLi7rkNo5fR2leSG4iRjNwjvwML6I xsutcDTMfpJhXVedVRiXnnxAvoFyuCKcQ+CMTzCHctv4z2tMYUq31aW97ZjPeVta1cWt f2QQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7riM3QntIGxsBscvH7VR6JZkfjkw590/IAaL9Jv9vMA=; b=XeoAFWY0vT/bvmSVxFLDOxvQ2GMWx3rMDpVKRYq6RP3lJSkVMNzr1sZJw2REK+pChY JSKwr3Ksz5odaodN0xaocFguM0raUGn2xk58xSmnQsy4jRgpkgDUyU5ANsM26hYBUW37 27GL8R3l5vDT/3G+JWf2bSOle0bViPd6hb0CN2sA6ML0MVCS9F9ncbBA45tbHgJlNHoK 4YbDG0gA2LYALnLCR/gR+pIm384QsV9fTFEvkpVrwFe3JVxJV8Dle9nVpAE8z09BlB/v PV2NZw2/5Wih78v0pMWOyDXiTutaMdwZwNcvBN5C2uc4eQGmYohRPmjiMTLKHETPYEt4 bG+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-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 k8si2823909otf.76.2019.12.11.19.40.44; Wed, 11 Dec 2019 19:40:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-leds-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-leds-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727952AbfLLDko (ORCPT + 1 other); Wed, 11 Dec 2019 22:40:44 -0500 Received: from mx2.suse.de ([195.135.220.15]:58556 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727784AbfLLDkJ (ORCPT ); Wed, 11 Dec 2019 22:40:09 -0500 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 Cc: Jacek Anaszewski , Pavel Machek , Dan Murphy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?q?Andreas_F=C3=A4rber?= 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 Sender: linux-leds-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.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(-) -- 2.16.4 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;