1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * Character LCD driver for Linux 4 * 5 * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu> 6 * Copyright (C) 2016-2017 Glider bvba 7 */ 8 9 #ifndef _CHARLCD_H 10 #define _CHARLCD_H 11 12 enum charlcd_onoff { 13 CHARLCD_OFF = 0, 14 CHARLCD_ON, 15 }; 16 17 struct charlcd { 18 const struct charlcd_ops *ops; 19 const unsigned char *char_conv; /* Optional */ 20 21 int height; 22 int width; 23 24 /* Contains the LCD X and Y offset */ 25 struct { 26 unsigned long x; 27 unsigned long y; 28 } addr; 29 30 void *drvdata; 31 }; 32 33 /** 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 buffered cursor position is advanced by charlcd. The cursor should not 41 * wrap to the next line at the end of a line. 42 * @gotoxy: Set cursor to x, y. The x and y values to set the cursor to are 43 * previously set in addr.x and addr.y by charlcd. 44 * @home: Set cursor to 0, 0. The values in addr.x and addr.y are set to 0, 0 by 45 * charlcd prior to calling this function. 46 * @clear_display: Again clear the whole display, set the cursor to 0, 0. The 47 * values in addr.x and addr.y are set to 0, 0 by charlcd prior to calling this 48 * function. 49 */ 50 struct charlcd_ops { 51 void (*clear_fast)(struct charlcd *lcd); 52 void (*backlight)(struct charlcd *lcd, enum charlcd_onoff on); 53 int (*print)(struct charlcd *lcd, int c); 54 int (*gotoxy)(struct charlcd *lcd); 55 int (*home)(struct charlcd *lcd); 56 int (*clear_display)(struct charlcd *lcd); 57 }; 58 59 struct charlcd *charlcd_alloc(void); 60 void charlcd_free(struct charlcd *lcd); 61 62 int charlcd_register(struct charlcd *lcd); 63 int charlcd_unregister(struct charlcd *lcd); 64 65 void charlcd_poke(struct charlcd *lcd); 66 67 #endif /* CHARLCD_H */ 68