xref: /linux/drivers/auxdisplay/line-display.h (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Character line display core support
4  *
5  * Copyright (C) 2016 Imagination Technologies
6  * Author: Paul Burton <paul.burton@mips.com>
7  *
8  * Copyright (C) 2021 Glider bv
9  */
10 
11 #ifndef _LINEDISP_H
12 #define _LINEDISP_H
13 
14 #include <linux/device.h>
15 #include <linux/timer_types.h>
16 
17 #include <linux/map_to_7segment.h>
18 #include <linux/map_to_14segment.h>
19 
20 struct linedisp;
21 
22 /**
23  * enum linedisp_map_type - type of the character mapping
24  * @LINEDISP_MAP_SEG7: Map characters to 7 segment display
25  * @LINEDISP_MAP_SEG14: Map characters to 14 segment display
26  */
27 enum linedisp_map_type {
28 	LINEDISP_MAP_SEG7,
29 	LINEDISP_MAP_SEG14,
30 };
31 
32 /**
33  * struct linedisp_map - character mapping
34  * @type: type of the character mapping
35  * @map: conversion character mapping
36  * @size: size of the @map
37  */
38 struct linedisp_map {
39 	enum linedisp_map_type type;
40 	union {
41 		struct seg7_conversion_map seg7;
42 		struct seg14_conversion_map seg14;
43 	} map;
44 	unsigned int size;
45 };
46 
47 /**
48  * struct linedisp_ops - character line display operations
49  * @get_map_type: Function called to get the character mapping, if required
50  * @update: Function called to update the display. This must not sleep!
51  */
52 struct linedisp_ops {
53 	int (*get_map_type)(struct linedisp *linedisp);
54 	void (*update)(struct linedisp *linedisp);
55 };
56 
57 /**
58  * struct linedisp - character line display private data structure
59  * @dev: the line display device
60  * @timer: timer used to implement scrolling
61  * @ops: character line display operations
62  * @buf: pointer to the buffer for the string currently displayed
63  * @message: the full message to display or scroll on the display
64  * @num_chars: the number of characters that can be displayed
65  * @message_len: the length of the @message string
66  * @scroll_pos: index of the first character of @message currently displayed
67  * @scroll_rate: scroll interval in jiffies
68  * @id: instance id of this display
69  */
70 struct linedisp {
71 	struct device dev;
72 	struct timer_list timer;
73 	const struct linedisp_ops *ops;
74 	struct linedisp_map *map;
75 	char *buf;
76 	char *message;
77 	unsigned int num_chars;
78 	unsigned int message_len;
79 	unsigned int scroll_pos;
80 	unsigned int scroll_rate;
81 	unsigned int id;
82 };
83 
84 int linedisp_register(struct linedisp *linedisp, struct device *parent,
85 		      unsigned int num_chars, const struct linedisp_ops *ops);
86 void linedisp_unregister(struct linedisp *linedisp);
87 
88 #endif /* LINEDISP_H */
89