Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Character LCD driver for Linux
0004  *
0005  * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu>
0006  * Copyright (C) 2016-2017 Glider bvba
0007  */
0008 
0009 #ifndef _CHARLCD_H
0010 #define _CHARLCD_H
0011 
0012 #define LCD_FLAG_B      0x0004  /* Blink on */
0013 #define LCD_FLAG_C      0x0008  /* Cursor on */
0014 #define LCD_FLAG_D      0x0010  /* Display on */
0015 #define LCD_FLAG_F      0x0020  /* Large font mode */
0016 #define LCD_FLAG_N      0x0040  /* 2-rows mode */
0017 #define LCD_FLAG_L      0x0080  /* Backlight enabled */
0018 
0019 enum charlcd_onoff {
0020     CHARLCD_OFF = 0,
0021     CHARLCD_ON,
0022 };
0023 
0024 enum charlcd_shift_dir {
0025     CHARLCD_SHIFT_LEFT,
0026     CHARLCD_SHIFT_RIGHT,
0027 };
0028 
0029 enum charlcd_fontsize {
0030     CHARLCD_FONTSIZE_SMALL,
0031     CHARLCD_FONTSIZE_LARGE,
0032 };
0033 
0034 enum charlcd_lines {
0035     CHARLCD_LINES_1,
0036     CHARLCD_LINES_2,
0037 };
0038 
0039 struct charlcd {
0040     const struct charlcd_ops *ops;
0041     const unsigned char *char_conv; /* Optional */
0042 
0043     int height;
0044     int width;
0045 
0046     /* Contains the LCD X and Y offset */
0047     struct {
0048         unsigned long x;
0049         unsigned long y;
0050     } addr;
0051 
0052     void *drvdata;
0053 };
0054 
0055 /**
0056  * struct charlcd_ops - Functions used by charlcd. Drivers have to implement
0057  * these.
0058  * @backlight: Turn backlight on or off. Optional.
0059  * @print: Print one character to the display at current cursor position.
0060  * The buffered cursor position is advanced by charlcd. The cursor should not
0061  * wrap to the next line at the end of a line.
0062  * @gotoxy: Set cursor to x, y. The x and y values to set the cursor to are
0063  * previously set in addr.x and addr.y by charlcd.
0064  * @home: Set cursor to 0, 0. The values in addr.x and addr.y are set to 0, 0 by
0065  * charlcd prior to calling this function.
0066  * @clear_display: Clear the whole display and set the cursor to 0, 0. The
0067  * values in addr.x and addr.y are set to 0, 0 by charlcd after to calling this
0068  * function.
0069  * @init_display: Initialize the display.
0070  * @shift_cursor: Shift cursor left or right one position.
0071  * @shift_display: Shift whole display content left or right.
0072  * @display: Turn display on or off.
0073  * @cursor: Turn cursor on or off.
0074  * @blink: Turn cursor blink on or off.
0075  * @lines: One or two lines.
0076  * @redefine_char: Redefine the actual pixel matrix of character.
0077  */
0078 struct charlcd_ops {
0079     void (*backlight)(struct charlcd *lcd, enum charlcd_onoff on);
0080     int (*print)(struct charlcd *lcd, int c);
0081     int (*gotoxy)(struct charlcd *lcd, unsigned int x, unsigned int y);
0082     int (*home)(struct charlcd *lcd);
0083     int (*clear_display)(struct charlcd *lcd);
0084     int (*init_display)(struct charlcd *lcd);
0085     int (*shift_cursor)(struct charlcd *lcd, enum charlcd_shift_dir dir);
0086     int (*shift_display)(struct charlcd *lcd, enum charlcd_shift_dir dir);
0087     int (*display)(struct charlcd *lcd, enum charlcd_onoff on);
0088     int (*cursor)(struct charlcd *lcd, enum charlcd_onoff on);
0089     int (*blink)(struct charlcd *lcd, enum charlcd_onoff on);
0090     int (*fontsize)(struct charlcd *lcd, enum charlcd_fontsize size);
0091     int (*lines)(struct charlcd *lcd, enum charlcd_lines lines);
0092     int (*redefine_char)(struct charlcd *lcd, char *esc);
0093 };
0094 
0095 void charlcd_backlight(struct charlcd *lcd, enum charlcd_onoff on);
0096 struct charlcd *charlcd_alloc(void);
0097 void charlcd_free(struct charlcd *lcd);
0098 
0099 int charlcd_register(struct charlcd *lcd);
0100 int charlcd_unregister(struct charlcd *lcd);
0101 
0102 void charlcd_poke(struct charlcd *lcd);
0103 
0104 #endif /* CHARLCD_H */