xref: /openbmc/linux/drivers/auxdisplay/charlcd.h (revision 40c2b72e)
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  * @backlight: Turn backlight on or off. Optional.
59b26deabbSLars Poeschel  * @print: Print one character to the display at current cursor position.
60b26deabbSLars Poeschel  * The buffered cursor position is advanced by charlcd. The cursor should not
61b26deabbSLars Poeschel  * wrap to the next line at the end of a line.
62d3a2fb81SLars Poeschel  * @gotoxy: Set cursor to x, y. The x and y values to set the cursor to are
63d3a2fb81SLars Poeschel  * previously set in addr.x and addr.y by charlcd.
6488645a86SLars Poeschel  * @home: Set cursor to 0, 0. The values in addr.x and addr.y are set to 0, 0 by
6588645a86SLars Poeschel  * charlcd prior to calling this function.
66377cf2cbSLars Poeschel  * @clear_display: Clear the whole display and set the cursor to 0, 0. The
67377cf2cbSLars Poeschel  * values in addr.x and addr.y are set to 0, 0 by charlcd after to calling this
6845421ffeSLars Poeschel  * function.
6901ec46dfSLars Poeschel  * @init_display: Initialize the display.
70d2f2187eSLars Poeschel  * @shift_cursor: Shift cursor left or right one position.
71d2f2187eSLars Poeschel  * @shift_display: Shift whole display content left or right.
72d2f2187eSLars Poeschel  * @display: Turn display on or off.
73d2f2187eSLars Poeschel  * @cursor: Turn cursor on or off.
74d2f2187eSLars Poeschel  * @blink: Turn cursor blink on or off.
75d2f2187eSLars Poeschel  * @lines: One or two lines.
76339acb08SLars Poeschel  * @redefine_char: Redefine the actual pixel matrix of character.
77b26deabbSLars Poeschel  */
7875354284SMasahiro Yamada struct charlcd_ops {
7966ce7d5cSLars Poeschel 	void (*backlight)(struct charlcd *lcd, enum charlcd_onoff on);
80b26deabbSLars Poeschel 	int (*print)(struct charlcd *lcd, int c);
81*40c2b72eSLars Poeschel 	int (*gotoxy)(struct charlcd *lcd, unsigned int x, unsigned int y);
8288645a86SLars Poeschel 	int (*home)(struct charlcd *lcd);
8345421ffeSLars Poeschel 	int (*clear_display)(struct charlcd *lcd);
8401ec46dfSLars Poeschel 	int (*init_display)(struct charlcd *lcd);
85d2f2187eSLars Poeschel 	int (*shift_cursor)(struct charlcd *lcd, enum charlcd_shift_dir dir);
86d2f2187eSLars Poeschel 	int (*shift_display)(struct charlcd *lcd, enum charlcd_shift_dir dir);
87d2f2187eSLars Poeschel 	int (*display)(struct charlcd *lcd, enum charlcd_onoff on);
88d2f2187eSLars Poeschel 	int (*cursor)(struct charlcd *lcd, enum charlcd_onoff on);
89d2f2187eSLars Poeschel 	int (*blink)(struct charlcd *lcd, enum charlcd_onoff on);
90d2f2187eSLars Poeschel 	int (*fontsize)(struct charlcd *lcd, enum charlcd_fontsize size);
91d2f2187eSLars Poeschel 	int (*lines)(struct charlcd *lcd, enum charlcd_lines lines);
92339acb08SLars Poeschel 	int (*redefine_char)(struct charlcd *lcd, char *esc);
9375354284SMasahiro Yamada };
9475354284SMasahiro Yamada 
952bf82b5aSLars Poeschel void charlcd_backlight(struct charlcd *lcd, enum charlcd_onoff on);
962545c1c9SLars Poeschel struct charlcd *charlcd_alloc(void);
9775354284SMasahiro Yamada void charlcd_free(struct charlcd *lcd);
9875354284SMasahiro Yamada 
9975354284SMasahiro Yamada int charlcd_register(struct charlcd *lcd);
10075354284SMasahiro Yamada int charlcd_unregister(struct charlcd *lcd);
10175354284SMasahiro Yamada 
10275354284SMasahiro Yamada void charlcd_poke(struct charlcd *lcd);
103390235c3SMasahiro Yamada 
104390235c3SMasahiro Yamada #endif /* CHARLCD_H */
105