charlcd.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #ifndef _CHARLCD_H
  9. #define _CHARLCD_H
  10. #define LCD_FLAG_B 0x0004 /* Blink on */
  11. #define LCD_FLAG_C 0x0008 /* Cursor on */
  12. #define LCD_FLAG_D 0x0010 /* Display on */
  13. #define LCD_FLAG_F 0x0020 /* Large font mode */
  14. #define LCD_FLAG_N 0x0040 /* 2-rows mode */
  15. #define LCD_FLAG_L 0x0080 /* Backlight enabled */
  16. enum charlcd_onoff {
  17. CHARLCD_OFF = 0,
  18. CHARLCD_ON,
  19. };
  20. enum charlcd_shift_dir {
  21. CHARLCD_SHIFT_LEFT,
  22. CHARLCD_SHIFT_RIGHT,
  23. };
  24. enum charlcd_fontsize {
  25. CHARLCD_FONTSIZE_SMALL,
  26. CHARLCD_FONTSIZE_LARGE,
  27. };
  28. enum charlcd_lines {
  29. CHARLCD_LINES_1,
  30. CHARLCD_LINES_2,
  31. };
  32. struct charlcd_ops;
  33. struct charlcd {
  34. const struct charlcd_ops *ops;
  35. const unsigned char *char_conv; /* Optional */
  36. int height;
  37. int width;
  38. /* Contains the LCD X and Y offset */
  39. struct {
  40. unsigned long x;
  41. unsigned long y;
  42. } addr;
  43. void *drvdata; /* Set by charlcd_alloc() */
  44. };
  45. /**
  46. * struct charlcd_ops - Functions used by charlcd. Drivers have to implement
  47. * these.
  48. * @backlight: Turn backlight on or off. Optional.
  49. * @print: Print one character to the display at current cursor position.
  50. * The buffered cursor position is advanced by charlcd. The cursor should not
  51. * wrap to the next line at the end of a line.
  52. * @gotoxy: Set cursor to x, y. The x and y values to set the cursor to are
  53. * previously set in addr.x and addr.y by charlcd.
  54. * @home: Set cursor to 0, 0. The values in addr.x and addr.y are set to 0, 0 by
  55. * charlcd prior to calling this function.
  56. * @clear_display: Clear the whole display and set the cursor to 0, 0. The
  57. * values in addr.x and addr.y are set to 0, 0 by charlcd after to calling this
  58. * function.
  59. * @init_display: Initialize the display.
  60. * @shift_cursor: Shift cursor left or right one position.
  61. * @shift_display: Shift whole display content left or right.
  62. * @display: Turn display on or off.
  63. * @cursor: Turn cursor on or off.
  64. * @blink: Turn cursor blink on or off.
  65. * @lines: One or two lines.
  66. * @redefine_char: Redefine the actual pixel matrix of character.
  67. */
  68. struct charlcd_ops {
  69. void (*backlight)(struct charlcd *lcd, enum charlcd_onoff on);
  70. int (*print)(struct charlcd *lcd, int c);
  71. int (*gotoxy)(struct charlcd *lcd, unsigned int x, unsigned int y);
  72. int (*home)(struct charlcd *lcd);
  73. int (*clear_display)(struct charlcd *lcd);
  74. int (*init_display)(struct charlcd *lcd);
  75. int (*shift_cursor)(struct charlcd *lcd, enum charlcd_shift_dir dir);
  76. int (*shift_display)(struct charlcd *lcd, enum charlcd_shift_dir dir);
  77. int (*display)(struct charlcd *lcd, enum charlcd_onoff on);
  78. int (*cursor)(struct charlcd *lcd, enum charlcd_onoff on);
  79. int (*blink)(struct charlcd *lcd, enum charlcd_onoff on);
  80. int (*fontsize)(struct charlcd *lcd, enum charlcd_fontsize size);
  81. int (*lines)(struct charlcd *lcd, enum charlcd_lines lines);
  82. int (*redefine_char)(struct charlcd *lcd, char *esc);
  83. };
  84. void charlcd_backlight(struct charlcd *lcd, enum charlcd_onoff on);
  85. struct charlcd *charlcd_alloc(unsigned int drvdata_size);
  86. void charlcd_free(struct charlcd *lcd);
  87. int charlcd_register(struct charlcd *lcd);
  88. int charlcd_unregister(struct charlcd *lcd);
  89. void charlcd_poke(struct charlcd *lcd);
  90. #endif /* CHARLCD_H */