xref: /openbmc/linux/drivers/auxdisplay/charlcd.h (revision 339acb08)
175354284SMasahiro Yamada /* SPDX-License-Identifier: GPL-2.0-or-later */
275354284SMasahiro Yamada /*
375354284SMasahiro Yamada  * Character LCD driver for Linux
475354284SMasahiro Yamada  *
575354284SMasahiro Yamada  * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu>
675354284SMasahiro Yamada  * Copyright (C) 2016-2017 Glider bvba
775354284SMasahiro Yamada  */
875354284SMasahiro Yamada 
9390235c3SMasahiro Yamada #ifndef _CHARLCD_H
10390235c3SMasahiro Yamada #define _CHARLCD_H
11390235c3SMasahiro Yamada 
1201ec46dfSLars Poeschel #define LCD_FLAG_B		0x0004	/* Blink on */
1301ec46dfSLars Poeschel #define LCD_FLAG_C		0x0008	/* Cursor on */
1401ec46dfSLars Poeschel #define LCD_FLAG_D		0x0010	/* Display on */
1501ec46dfSLars Poeschel #define LCD_FLAG_F		0x0020	/* Large font mode */
1601ec46dfSLars Poeschel #define LCD_FLAG_N		0x0040	/* 2-rows mode */
1701ec46dfSLars Poeschel #define LCD_FLAG_L		0x0080	/* Backlight enabled */
1801ec46dfSLars Poeschel 
1966ce7d5cSLars Poeschel enum charlcd_onoff {
2066ce7d5cSLars Poeschel 	CHARLCD_OFF = 0,
2166ce7d5cSLars Poeschel 	CHARLCD_ON,
2266ce7d5cSLars Poeschel };
2366ce7d5cSLars Poeschel 
24d2f2187eSLars Poeschel enum charlcd_shift_dir {
25d2f2187eSLars Poeschel 	CHARLCD_SHIFT_LEFT,
26d2f2187eSLars Poeschel 	CHARLCD_SHIFT_RIGHT,
27d2f2187eSLars Poeschel };
28d2f2187eSLars Poeschel 
29d2f2187eSLars Poeschel enum charlcd_fontsize {
30d2f2187eSLars Poeschel 	CHARLCD_FONTSIZE_SMALL,
31d2f2187eSLars Poeschel 	CHARLCD_FONTSIZE_LARGE,
32d2f2187eSLars Poeschel };
33d2f2187eSLars Poeschel 
34d2f2187eSLars Poeschel enum charlcd_lines {
35d2f2187eSLars Poeschel 	CHARLCD_LINES_1,
36d2f2187eSLars Poeschel 	CHARLCD_LINES_2,
37d2f2187eSLars Poeschel };
38d2f2187eSLars Poeschel 
3975354284SMasahiro Yamada struct charlcd {
4075354284SMasahiro Yamada 	const struct charlcd_ops *ops;
4175354284SMasahiro Yamada 	const unsigned char *char_conv;	/* Optional */
4275354284SMasahiro Yamada 
4375354284SMasahiro Yamada 	int height;
4475354284SMasahiro Yamada 	int width;
4575354284SMasahiro Yamada 
4611588b59SLars Poeschel 	/* Contains the LCD X and Y offset */
4711588b59SLars Poeschel 	struct {
4811588b59SLars Poeschel 		unsigned long x;
4911588b59SLars Poeschel 		unsigned long y;
5011588b59SLars Poeschel 	} addr;
5111588b59SLars Poeschel 
522545c1c9SLars Poeschel 	void *drvdata;
5375354284SMasahiro Yamada };
5475354284SMasahiro Yamada 
55b26deabbSLars Poeschel /**
56b26deabbSLars Poeschel  * struct charlcd_ops - Functions used by charlcd. Drivers have to implement
57b26deabbSLars Poeschel  * these.
58b26deabbSLars Poeschel  * @clear_fast: Clear the whole display and set cursor to position 0, 0.
59b26deabbSLars Poeschel  * Optional.
60b26deabbSLars Poeschel  * @backlight: Turn backlight on or off. Optional.
61b26deabbSLars Poeschel  * @print: Print one character to the display at current cursor position.
62b26deabbSLars Poeschel  * The buffered cursor position is advanced by charlcd. The cursor should not
63b26deabbSLars Poeschel  * wrap to the next line at the end of a line.
64d3a2fb81SLars Poeschel  * @gotoxy: Set cursor to x, y. The x and y values to set the cursor to are
65d3a2fb81SLars Poeschel  * previously set in addr.x and addr.y by charlcd.
6688645a86SLars Poeschel  * @home: Set cursor to 0, 0. The values in addr.x and addr.y are set to 0, 0 by
6788645a86SLars Poeschel  * charlcd prior to calling this function.
6845421ffeSLars Poeschel  * @clear_display: Again clear the whole display, set the cursor to 0, 0. The
6945421ffeSLars Poeschel  * values in addr.x and addr.y are set to 0, 0 by charlcd prior to calling this
7045421ffeSLars Poeschel  * function.
7101ec46dfSLars Poeschel  * @init_display: Initialize the display.
72d2f2187eSLars Poeschel  * @shift_cursor: Shift cursor left or right one position.
73d2f2187eSLars Poeschel  * @shift_display: Shift whole display content left or right.
74d2f2187eSLars Poeschel  * @display: Turn display on or off.
75d2f2187eSLars Poeschel  * @cursor: Turn cursor on or off.
76d2f2187eSLars Poeschel  * @blink: Turn cursor blink on or off.
77d2f2187eSLars Poeschel  * @lines: One or two lines.
78*339acb08SLars Poeschel  * @redefine_char: Redefine the actual pixel matrix of character.
79b26deabbSLars Poeschel  */
8075354284SMasahiro Yamada struct charlcd_ops {
8175354284SMasahiro Yamada 	void (*clear_fast)(struct charlcd *lcd);
8266ce7d5cSLars Poeschel 	void (*backlight)(struct charlcd *lcd, enum charlcd_onoff on);
83b26deabbSLars Poeschel 	int (*print)(struct charlcd *lcd, int c);
84d3a2fb81SLars Poeschel 	int (*gotoxy)(struct charlcd *lcd);
8588645a86SLars Poeschel 	int (*home)(struct charlcd *lcd);
8645421ffeSLars Poeschel 	int (*clear_display)(struct charlcd *lcd);
8701ec46dfSLars Poeschel 	int (*init_display)(struct charlcd *lcd);
88d2f2187eSLars Poeschel 	int (*shift_cursor)(struct charlcd *lcd, enum charlcd_shift_dir dir);
89d2f2187eSLars Poeschel 	int (*shift_display)(struct charlcd *lcd, enum charlcd_shift_dir dir);
90d2f2187eSLars Poeschel 	int (*display)(struct charlcd *lcd, enum charlcd_onoff on);
91d2f2187eSLars Poeschel 	int (*cursor)(struct charlcd *lcd, enum charlcd_onoff on);
92d2f2187eSLars Poeschel 	int (*blink)(struct charlcd *lcd, enum charlcd_onoff on);
93d2f2187eSLars Poeschel 	int (*fontsize)(struct charlcd *lcd, enum charlcd_fontsize size);
94d2f2187eSLars Poeschel 	int (*lines)(struct charlcd *lcd, enum charlcd_lines lines);
95*339acb08SLars Poeschel 	int (*redefine_char)(struct charlcd *lcd, char *esc);
9675354284SMasahiro Yamada };
9775354284SMasahiro Yamada 
982bf82b5aSLars Poeschel void charlcd_backlight(struct charlcd *lcd, enum charlcd_onoff on);
992545c1c9SLars Poeschel struct charlcd *charlcd_alloc(void);
10075354284SMasahiro Yamada void charlcd_free(struct charlcd *lcd);
10175354284SMasahiro Yamada 
10275354284SMasahiro Yamada int charlcd_register(struct charlcd *lcd);
10375354284SMasahiro Yamada int charlcd_unregister(struct charlcd *lcd);
10475354284SMasahiro Yamada 
10575354284SMasahiro Yamada void charlcd_poke(struct charlcd *lcd);
106390235c3SMasahiro Yamada 
107390235c3SMasahiro Yamada #endif /* CHARLCD_H */
108