blob: 94922e3c1c4c24ff39bd1b77fbecb1a0c9a4c60b [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Geert Uytterhoeven39f8ea42017-03-10 15:15:17 +01002/*
3 * Character LCD driver for Linux
4 *
5 * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu>
6 * Copyright (C) 2016-2017 Glider bvba
Geert Uytterhoeven39f8ea42017-03-10 15:15:17 +01007 */
8
Masahiro Yamada390235c2019-08-06 16:14:45 +09009#ifndef _CHARLCD_H
10#define _CHARLCD_H
11
Lars Poeschel66ce7d52020-11-03 10:58:04 +010012enum charlcd_onoff {
13 CHARLCD_OFF = 0,
14 CHARLCD_ON,
15};
16
Geert Uytterhoeven39f8ea42017-03-10 15:15:17 +010017struct charlcd {
18 const struct charlcd_ops *ops;
19 const unsigned char *char_conv; /* Optional */
20
21 int height;
22 int width;
Geert Uytterhoeven39f8ea42017-03-10 15:15:17 +010023
Lars Poeschel11588b52020-11-03 10:58:10 +010024 /* Contains the LCD X and Y offset */
25 struct {
26 unsigned long x;
27 unsigned long y;
28 } addr;
29
Lars Poeschel2545c1c2020-11-03 10:58:06 +010030 void *drvdata;
Geert Uytterhoeven39f8ea42017-03-10 15:15:17 +010031};
32
Lars Poeschelb26deab2020-11-03 10:58:11 +010033/**
34 * struct charlcd_ops - Functions used by charlcd. Drivers have to implement
35 * these.
36 * @clear_fast: Clear the whole display and set cursor to position 0, 0.
37 * Optional.
38 * @backlight: Turn backlight on or off. Optional.
39 * @print: Print one character to the display at current cursor position.
40 * The cursor is advanced by charlcd.
41 * The buffered cursor position is advanced by charlcd. The cursor should not
42 * wrap to the next line at the end of a line.
43 */
Geert Uytterhoeven39f8ea42017-03-10 15:15:17 +010044struct charlcd_ops {
Geert Uytterhoeven39f8ea42017-03-10 15:15:17 +010045 void (*clear_fast)(struct charlcd *lcd);
Lars Poeschel66ce7d52020-11-03 10:58:04 +010046 void (*backlight)(struct charlcd *lcd, enum charlcd_onoff on);
Lars Poeschelb26deab2020-11-03 10:58:11 +010047 int (*print)(struct charlcd *lcd, int c);
Geert Uytterhoeven39f8ea42017-03-10 15:15:17 +010048};
49
Lars Poeschel2545c1c2020-11-03 10:58:06 +010050struct charlcd *charlcd_alloc(void);
Andy Shevchenko8e44fc82019-03-12 16:44:30 +020051void charlcd_free(struct charlcd *lcd);
Geert Uytterhoeven39f8ea42017-03-10 15:15:17 +010052
53int charlcd_register(struct charlcd *lcd);
54int charlcd_unregister(struct charlcd *lcd);
55
56void charlcd_poke(struct charlcd *lcd);
Masahiro Yamada390235c2019-08-06 16:14:45 +090057
58#endif /* CHARLCD_H */