summaryrefslogtreecommitdiff
path: root/drivers/auxdisplay/charlcd.h
blob: dd40fd814a57c6bc3d6705fc812a63dd25238bee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Character LCD driver for Linux
 *
 * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu>
 * Copyright (C) 2016-2017 Glider bvba
 */

#ifndef _CHARLCD_H
#define _CHARLCD_H

#define LCD_FLAG_B		0x0004	/* Blink on */
#define LCD_FLAG_C		0x0008	/* Cursor on */
#define LCD_FLAG_D		0x0010	/* Display on */
#define LCD_FLAG_F		0x0020	/* Large font mode */
#define LCD_FLAG_N		0x0040	/* 2-rows mode */
#define LCD_FLAG_L		0x0080	/* Backlight enabled */

enum charlcd_onoff {
	CHARLCD_OFF = 0,
	CHARLCD_ON,
};

struct charlcd {
	const struct charlcd_ops *ops;
	const unsigned char *char_conv;	/* Optional */

	int height;
	int width;

	/* Contains the LCD X and Y offset */
	struct {
		unsigned long x;
		unsigned long y;
	} addr;

	void *drvdata;
};

/**
 * struct charlcd_ops - Functions used by charlcd. Drivers have to implement
 * these.
 * @clear_fast: Clear the whole display and set cursor to position 0, 0.
 * Optional.
 * @backlight: Turn backlight on or off. Optional.
 * @print: Print one character to the display at current cursor position.
 * The buffered cursor position is advanced by charlcd. The cursor should not
 * wrap to the next line at the end of a line.
 * @gotoxy: Set cursor to x, y. The x and y values to set the cursor to are
 * previously set in addr.x and addr.y by charlcd.
 * @home: Set cursor to 0, 0. The values in addr.x and addr.y are set to 0, 0 by
 * charlcd prior to calling this function.
 * @clear_display: Again clear the whole display, set the cursor to 0, 0. The
 * values in addr.x and addr.y are set to 0, 0 by charlcd prior to calling this
 * function.
 * @init_display: Initialize the display.
 */
struct charlcd_ops {
	void (*clear_fast)(struct charlcd *lcd);
	void (*backlight)(struct charlcd *lcd, enum charlcd_onoff on);
	int (*print)(struct charlcd *lcd, int c);
	int (*gotoxy)(struct charlcd *lcd);
	int (*home)(struct charlcd *lcd);
	int (*clear_display)(struct charlcd *lcd);
	int (*init_display)(struct charlcd *lcd);
};

void charlcd_backlight(struct charlcd *lcd, enum charlcd_onoff on);
struct charlcd *charlcd_alloc(void);
void charlcd_free(struct charlcd *lcd);

int charlcd_register(struct charlcd *lcd);
int charlcd_unregister(struct charlcd *lcd);

void charlcd_poke(struct charlcd *lcd);

#endif /* CHARLCD_H */