/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ /* * Copyright (C) 2021 Glider bv * * Based on include/uapi/linux/map_to_7segment.h: * Copyright (c) 2005 Henk Vergonet <[email protected]> */ #ifndef MAP_TO_14SEGMENT_H #define MAP_TO_14SEGMENT_H /* This file provides translation primitives and tables for the conversion * of (ASCII) characters to a 14-segments notation. * * The 14 segment's wikipedia notation below is used as standard. * See: https://en.wikipedia.org/wiki/Fourteen-segment_display * * Notation: +---a---+ * |\ | /| * f h i j b * | \|/ | * +-g1+-g2+ * | /|\ | * e k l m c * |/ | \| * +---d---+ * * Usage: * * Register a map variable, and fill it with a character set: * static SEG14_DEFAULT_MAP(map_seg14); * * * Then use for conversion: * seg14 = map_to_seg14(&map_seg14, some_char); * ... * * In device drivers it is recommended, if required, to make the char map * accessible via the sysfs interface using the following scheme: * * static ssize_t map_seg14_show(struct device *dev, * struct device_attribute *attr, char *buf) * { * memcpy(buf, &map_seg14, sizeof(map_seg14)); * return sizeof(map_seg14); * } * static ssize_t map_seg14_store(struct device *dev, * struct device_attribute *attr, * const char *buf, size_t cnt) * { * if (cnt != sizeof(map_seg14)) * return -EINVAL; * memcpy(&map_seg14, buf, cnt); * return cnt; * } * static DEVICE_ATTR_RW(map_seg14); */ #include <linux/errno.h> #include <linux/types.h> #include <asm/byteorder.h> #define BIT_SEG14_A … #define BIT_SEG14_B … #define BIT_SEG14_C … #define BIT_SEG14_D … #define BIT_SEG14_E … #define BIT_SEG14_F … #define BIT_SEG14_G1 … #define BIT_SEG14_G2 … #define BIT_SEG14_H … #define BIT_SEG14_I … #define BIT_SEG14_J … #define BIT_SEG14_K … #define BIT_SEG14_L … #define BIT_SEG14_M … #define BIT_SEG14_RESERVED1 … #define BIT_SEG14_RESERVED2 … struct seg14_conversion_map { … }; static __inline__ int map_to_seg14(struct seg14_conversion_map *map, int c) { … } #define SEG14_CONVERSION_MAP(_name, _map) … /* * It is recommended to use a facility that allows user space to redefine * custom character sets for LCD devices. Please use a sysfs interface * as described above. */ #define MAP_TO_SEG14_SYSFS_FILE … /******************************************************************************* * ASCII conversion table ******************************************************************************/ #define _SEG14(sym, a, b, c, d, e, f, g1, g2, h, j, k, l, m, n) … #define _MAP_0_32_ASCII_SEG14_NON_PRINTABLE … #define _MAP_33_47_ASCII_SEG14_SYMBOL … #define _MAP_48_57_ASCII_SEG14_NUMERIC … #define _MAP_58_64_ASCII_SEG14_SYMBOL … #define _MAP_65_90_ASCII_SEG14_ALPHA_UPPER … #define _MAP_91_96_ASCII_SEG14_SYMBOL … #define _MAP_97_122_ASCII_SEG14_ALPHA_LOWER … #define _MAP_123_126_ASCII_SEG14_SYMBOL … /* Maps */ #define MAP_ASCII14SEG_ALPHANUM … #define SEG14_DEFAULT_MAP(_name) … #endif /* MAP_TO_14SEGMENT_H */