Miguel Ojeda | 351f683b | 2018-02-17 20:33:13 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 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 |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/atomic.h> |
Miguel Ojeda | b34050f | 2018-02-27 23:09:52 +0100 | [diff] [blame] | 10 | #include <linux/ctype.h> |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 11 | #include <linux/fs.h> |
| 12 | #include <linux/miscdevice.h> |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/notifier.h> |
| 15 | #include <linux/reboot.h> |
| 16 | #include <linux/slab.h> |
| 17 | #include <linux/uaccess.h> |
| 18 | #include <linux/workqueue.h> |
| 19 | |
| 20 | #include <generated/utsrelease.h> |
| 21 | |
Masahiro Yamada | 7535428 | 2019-08-06 16:14:44 +0900 | [diff] [blame] | 22 | #include "charlcd.h" |
Lars Poeschel | 2545c1c | 2020-11-03 10:58:06 +0100 | [diff] [blame] | 23 | #include "hd44780_common.h" |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 24 | |
| 25 | /* Keep the backlight on this many seconds for each flash */ |
| 26 | #define LCD_BL_TEMPO_PERIOD 4 |
| 27 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 28 | #define LCD_ESCAPE_LEN 24 /* Max chars for LCD escape command */ |
| 29 | #define LCD_ESCAPE_CHAR 27 /* Use char 27 for escape command */ |
| 30 | |
| 31 | struct charlcd_priv { |
| 32 | struct charlcd lcd; |
| 33 | |
| 34 | struct delayed_work bl_work; |
| 35 | struct mutex bl_tempo_lock; /* Protects access to bl_tempo */ |
| 36 | bool bl_tempo; |
| 37 | |
| 38 | bool must_clear; |
| 39 | |
| 40 | /* contains the LCD config state */ |
| 41 | unsigned long int flags; |
| 42 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 43 | /* Current escape sequence and it's length or -1 if outside */ |
| 44 | struct { |
| 45 | char buf[LCD_ESCAPE_LEN + 1]; |
| 46 | int len; |
| 47 | } esc_seq; |
| 48 | |
Gustavo A. R. Silva | 2f920c0 | 2020-02-12 13:52:31 -0600 | [diff] [blame] | 49 | unsigned long long drvdata[]; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 50 | }; |
| 51 | |
Andy Shevchenko | b658a21 | 2019-03-12 16:44:29 +0200 | [diff] [blame] | 52 | #define charlcd_to_priv(p) container_of(p, struct charlcd_priv, lcd) |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 53 | |
| 54 | /* Device single-open policy control */ |
| 55 | static atomic_t charlcd_available = ATOMIC_INIT(1); |
| 56 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 57 | /* turn the backlight on or off */ |
Lars Poeschel | 2bf82b5 | 2020-11-03 10:58:15 +0100 | [diff] [blame] | 58 | void charlcd_backlight(struct charlcd *lcd, enum charlcd_onoff on) |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 59 | { |
Andy Shevchenko | b658a21 | 2019-03-12 16:44:29 +0200 | [diff] [blame] | 60 | struct charlcd_priv *priv = charlcd_to_priv(lcd); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 61 | |
| 62 | if (!lcd->ops->backlight) |
| 63 | return; |
| 64 | |
| 65 | mutex_lock(&priv->bl_tempo_lock); |
| 66 | if (!priv->bl_tempo) |
| 67 | lcd->ops->backlight(lcd, on); |
| 68 | mutex_unlock(&priv->bl_tempo_lock); |
| 69 | } |
Lars Poeschel | 2bf82b5 | 2020-11-03 10:58:15 +0100 | [diff] [blame] | 70 | EXPORT_SYMBOL_GPL(charlcd_backlight); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 71 | |
| 72 | static void charlcd_bl_off(struct work_struct *work) |
| 73 | { |
| 74 | struct delayed_work *dwork = to_delayed_work(work); |
| 75 | struct charlcd_priv *priv = |
| 76 | container_of(dwork, struct charlcd_priv, bl_work); |
| 77 | |
| 78 | mutex_lock(&priv->bl_tempo_lock); |
| 79 | if (priv->bl_tempo) { |
| 80 | priv->bl_tempo = false; |
| 81 | if (!(priv->flags & LCD_FLAG_L)) |
Lars Poeschel | bd26b18 | 2020-11-03 10:58:16 +0100 | [diff] [blame] | 82 | priv->lcd.ops->backlight(&priv->lcd, CHARLCD_OFF); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 83 | } |
| 84 | mutex_unlock(&priv->bl_tempo_lock); |
| 85 | } |
| 86 | |
| 87 | /* turn the backlight on for a little while */ |
| 88 | void charlcd_poke(struct charlcd *lcd) |
| 89 | { |
Andy Shevchenko | b658a21 | 2019-03-12 16:44:29 +0200 | [diff] [blame] | 90 | struct charlcd_priv *priv = charlcd_to_priv(lcd); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 91 | |
| 92 | if (!lcd->ops->backlight) |
| 93 | return; |
| 94 | |
| 95 | cancel_delayed_work_sync(&priv->bl_work); |
| 96 | |
| 97 | mutex_lock(&priv->bl_tempo_lock); |
| 98 | if (!priv->bl_tempo && !(priv->flags & LCD_FLAG_L)) |
Lars Poeschel | bd26b18 | 2020-11-03 10:58:16 +0100 | [diff] [blame] | 99 | lcd->ops->backlight(lcd, CHARLCD_ON); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 100 | priv->bl_tempo = true; |
| 101 | schedule_delayed_work(&priv->bl_work, LCD_BL_TEMPO_PERIOD * HZ); |
| 102 | mutex_unlock(&priv->bl_tempo_lock); |
| 103 | } |
| 104 | EXPORT_SYMBOL_GPL(charlcd_poke); |
| 105 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 106 | static void charlcd_home(struct charlcd *lcd) |
| 107 | { |
Lars Poeschel | 11588b5 | 2020-11-03 10:58:10 +0100 | [diff] [blame] | 108 | lcd->addr.x = 0; |
| 109 | lcd->addr.y = 0; |
Lars Poeschel | 88645a8 | 2020-11-03 10:58:13 +0100 | [diff] [blame] | 110 | lcd->ops->home(lcd); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | static void charlcd_print(struct charlcd *lcd, char c) |
| 114 | { |
Lars Poeschel | d3a2fb8 | 2020-11-03 10:58:12 +0100 | [diff] [blame] | 115 | struct hd44780_common *hdc = lcd->drvdata; |
| 116 | |
Lars Poeschel | b26deab | 2020-11-03 10:58:11 +0100 | [diff] [blame] | 117 | if (lcd->char_conv) |
| 118 | c = lcd->char_conv[(unsigned char)c]; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 119 | |
Lars Poeschel | b26deab | 2020-11-03 10:58:11 +0100 | [diff] [blame] | 120 | if (!lcd->ops->print(lcd, c)) |
Lars Poeschel | 11588b5 | 2020-11-03 10:58:10 +0100 | [diff] [blame] | 121 | lcd->addr.x++; |
Sean Young | 54bc937f | 2018-01-15 09:43:48 +0000 | [diff] [blame] | 122 | |
Lars Poeschel | b26deab | 2020-11-03 10:58:11 +0100 | [diff] [blame] | 123 | /* prevents the cursor from wrapping onto the next line */ |
Lars Poeschel | d3a2fb8 | 2020-11-03 10:58:12 +0100 | [diff] [blame] | 124 | if (lcd->addr.x == hdc->bwidth) |
| 125 | lcd->ops->gotoxy(lcd); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | static void charlcd_clear_fast(struct charlcd *lcd) |
| 129 | { |
Lars Poeschel | 2545c1c | 2020-11-03 10:58:06 +0100 | [diff] [blame] | 130 | struct hd44780_common *hdc = lcd->drvdata; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 131 | int pos; |
| 132 | |
| 133 | charlcd_home(lcd); |
| 134 | |
| 135 | if (lcd->ops->clear_fast) |
| 136 | lcd->ops->clear_fast(lcd); |
| 137 | else |
Lars Poeschel | 2545c1c | 2020-11-03 10:58:06 +0100 | [diff] [blame] | 138 | for (pos = 0; pos < min(2, lcd->height) * hdc->hwidth; pos++) |
Lars Poeschel | b26deab | 2020-11-03 10:58:11 +0100 | [diff] [blame] | 139 | lcd->ops->print(lcd, ' '); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 140 | |
| 141 | charlcd_home(lcd); |
| 142 | } |
| 143 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 144 | /* |
Miguel Ojeda | b34050f | 2018-02-27 23:09:52 +0100 | [diff] [blame] | 145 | * Parses a movement command of the form "(.*);", where the group can be |
| 146 | * any number of subcommands of the form "(x|y)[0-9]+". |
| 147 | * |
| 148 | * Returns whether the command is valid. The position arguments are |
| 149 | * only written if the parsing was successful. |
| 150 | * |
| 151 | * For instance: |
| 152 | * - ";" returns (<original x>, <original y>). |
| 153 | * - "x1;" returns (1, <original y>). |
| 154 | * - "y2x1;" returns (1, 2). |
| 155 | * - "x12y34x56;" returns (56, 34). |
| 156 | * - "" fails. |
| 157 | * - "x" fails. |
| 158 | * - "x;" fails. |
| 159 | * - "x1" fails. |
| 160 | * - "xy12;" fails. |
| 161 | * - "x12yy12;" fails. |
| 162 | * - "xx" fails. |
| 163 | */ |
| 164 | static bool parse_xy(const char *s, unsigned long *x, unsigned long *y) |
| 165 | { |
| 166 | unsigned long new_x = *x; |
| 167 | unsigned long new_y = *y; |
Andy Shevchenko | d717e7d | 2019-12-04 16:50:36 -0800 | [diff] [blame] | 168 | char *p; |
Miguel Ojeda | b34050f | 2018-02-27 23:09:52 +0100 | [diff] [blame] | 169 | |
| 170 | for (;;) { |
| 171 | if (!*s) |
| 172 | return false; |
| 173 | |
| 174 | if (*s == ';') |
| 175 | break; |
| 176 | |
| 177 | if (*s == 'x') { |
Andy Shevchenko | d717e7d | 2019-12-04 16:50:36 -0800 | [diff] [blame] | 178 | new_x = simple_strtoul(s + 1, &p, 10); |
| 179 | if (p == s + 1) |
Miguel Ojeda | b34050f | 2018-02-27 23:09:52 +0100 | [diff] [blame] | 180 | return false; |
Andy Shevchenko | d717e7d | 2019-12-04 16:50:36 -0800 | [diff] [blame] | 181 | s = p; |
Miguel Ojeda | b34050f | 2018-02-27 23:09:52 +0100 | [diff] [blame] | 182 | } else if (*s == 'y') { |
Andy Shevchenko | d717e7d | 2019-12-04 16:50:36 -0800 | [diff] [blame] | 183 | new_y = simple_strtoul(s + 1, &p, 10); |
| 184 | if (p == s + 1) |
Miguel Ojeda | b34050f | 2018-02-27 23:09:52 +0100 | [diff] [blame] | 185 | return false; |
Andy Shevchenko | d717e7d | 2019-12-04 16:50:36 -0800 | [diff] [blame] | 186 | s = p; |
Miguel Ojeda | b34050f | 2018-02-27 23:09:52 +0100 | [diff] [blame] | 187 | } else { |
| 188 | return false; |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | *x = new_x; |
| 193 | *y = new_y; |
| 194 | return true; |
| 195 | } |
| 196 | |
| 197 | /* |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 198 | * These are the file operation function for user access to /dev/lcd |
| 199 | * This function can also be called from inside the kernel, by |
| 200 | * setting file and ppos to NULL. |
| 201 | * |
| 202 | */ |
| 203 | |
| 204 | static inline int handle_lcd_special_code(struct charlcd *lcd) |
| 205 | { |
Andy Shevchenko | b658a21 | 2019-03-12 16:44:29 +0200 | [diff] [blame] | 206 | struct charlcd_priv *priv = charlcd_to_priv(lcd); |
Lars Poeschel | 2545c1c | 2020-11-03 10:58:06 +0100 | [diff] [blame] | 207 | struct hd44780_common *hdc = lcd->drvdata; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 208 | |
| 209 | /* LCD special codes */ |
| 210 | |
| 211 | int processed = 0; |
| 212 | |
| 213 | char *esc = priv->esc_seq.buf + 2; |
| 214 | int oldflags = priv->flags; |
| 215 | |
| 216 | /* check for display mode flags */ |
| 217 | switch (*esc) { |
| 218 | case 'D': /* Display ON */ |
| 219 | priv->flags |= LCD_FLAG_D; |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 220 | if (priv->flags != oldflags) |
| 221 | lcd->ops->display(lcd, CHARLCD_ON); |
| 222 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 223 | processed = 1; |
| 224 | break; |
| 225 | case 'd': /* Display OFF */ |
| 226 | priv->flags &= ~LCD_FLAG_D; |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 227 | if (priv->flags != oldflags) |
| 228 | lcd->ops->display(lcd, CHARLCD_OFF); |
| 229 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 230 | processed = 1; |
| 231 | break; |
| 232 | case 'C': /* Cursor ON */ |
| 233 | priv->flags |= LCD_FLAG_C; |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 234 | if (priv->flags != oldflags) |
| 235 | lcd->ops->cursor(lcd, CHARLCD_ON); |
| 236 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 237 | processed = 1; |
| 238 | break; |
| 239 | case 'c': /* Cursor OFF */ |
| 240 | priv->flags &= ~LCD_FLAG_C; |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 241 | if (priv->flags != oldflags) |
| 242 | lcd->ops->cursor(lcd, CHARLCD_OFF); |
| 243 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 244 | processed = 1; |
| 245 | break; |
| 246 | case 'B': /* Blink ON */ |
| 247 | priv->flags |= LCD_FLAG_B; |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 248 | if (priv->flags != oldflags) |
| 249 | lcd->ops->blink(lcd, CHARLCD_ON); |
| 250 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 251 | processed = 1; |
| 252 | break; |
| 253 | case 'b': /* Blink OFF */ |
| 254 | priv->flags &= ~LCD_FLAG_B; |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 255 | if (priv->flags != oldflags) |
| 256 | lcd->ops->blink(lcd, CHARLCD_OFF); |
| 257 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 258 | processed = 1; |
| 259 | break; |
| 260 | case '+': /* Back light ON */ |
| 261 | priv->flags |= LCD_FLAG_L; |
| 262 | processed = 1; |
| 263 | break; |
| 264 | case '-': /* Back light OFF */ |
| 265 | priv->flags &= ~LCD_FLAG_L; |
| 266 | processed = 1; |
| 267 | break; |
| 268 | case '*': /* Flash back light */ |
| 269 | charlcd_poke(lcd); |
| 270 | processed = 1; |
| 271 | break; |
| 272 | case 'f': /* Small Font */ |
| 273 | priv->flags &= ~LCD_FLAG_F; |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 274 | if (priv->flags != oldflags) |
| 275 | lcd->ops->fontsize(lcd, CHARLCD_FONTSIZE_SMALL); |
| 276 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 277 | processed = 1; |
| 278 | break; |
| 279 | case 'F': /* Large Font */ |
| 280 | priv->flags |= LCD_FLAG_F; |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 281 | if (priv->flags != oldflags) |
| 282 | lcd->ops->fontsize(lcd, CHARLCD_FONTSIZE_LARGE); |
| 283 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 284 | processed = 1; |
| 285 | break; |
| 286 | case 'n': /* One Line */ |
| 287 | priv->flags &= ~LCD_FLAG_N; |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 288 | if (priv->flags != oldflags) |
| 289 | lcd->ops->lines(lcd, CHARLCD_LINES_1); |
| 290 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 291 | processed = 1; |
| 292 | break; |
| 293 | case 'N': /* Two Lines */ |
| 294 | priv->flags |= LCD_FLAG_N; |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 295 | if (priv->flags != oldflags) |
| 296 | lcd->ops->lines(lcd, CHARLCD_LINES_2); |
| 297 | |
Robert Abel | 99b9b49 | 2018-02-26 00:54:29 +0100 | [diff] [blame] | 298 | processed = 1; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 299 | break; |
| 300 | case 'l': /* Shift Cursor Left */ |
Lars Poeschel | 11588b5 | 2020-11-03 10:58:10 +0100 | [diff] [blame] | 301 | if (lcd->addr.x > 0) { |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 302 | if (!lcd->ops->shift_cursor(lcd, CHARLCD_SHIFT_LEFT)) |
| 303 | lcd->addr.x--; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 304 | } |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 305 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 306 | processed = 1; |
| 307 | break; |
| 308 | case 'r': /* shift cursor right */ |
Lars Poeschel | 11588b5 | 2020-11-03 10:58:10 +0100 | [diff] [blame] | 309 | if (lcd->addr.x < lcd->width) { |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 310 | if (!lcd->ops->shift_cursor(lcd, CHARLCD_SHIFT_RIGHT)) |
| 311 | lcd->addr.x++; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 312 | } |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 313 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 314 | processed = 1; |
| 315 | break; |
| 316 | case 'L': /* shift display left */ |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 317 | lcd->ops->shift_display(lcd, CHARLCD_SHIFT_LEFT); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 318 | processed = 1; |
| 319 | break; |
| 320 | case 'R': /* shift display right */ |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 321 | lcd->ops->shift_display(lcd, CHARLCD_SHIFT_RIGHT); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 322 | processed = 1; |
| 323 | break; |
| 324 | case 'k': { /* kill end of line */ |
Lars Poeschel | b26deab | 2020-11-03 10:58:11 +0100 | [diff] [blame] | 325 | int x, xs, ys; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 326 | |
Lars Poeschel | b26deab | 2020-11-03 10:58:11 +0100 | [diff] [blame] | 327 | xs = lcd->addr.x; |
| 328 | ys = lcd->addr.y; |
Lars Poeschel | 11588b5 | 2020-11-03 10:58:10 +0100 | [diff] [blame] | 329 | for (x = lcd->addr.x; x < hdc->bwidth; x++) |
Lars Poeschel | b26deab | 2020-11-03 10:58:11 +0100 | [diff] [blame] | 330 | lcd->ops->print(lcd, ' '); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 331 | |
| 332 | /* restore cursor position */ |
Lars Poeschel | b26deab | 2020-11-03 10:58:11 +0100 | [diff] [blame] | 333 | lcd->addr.x = xs; |
| 334 | lcd->addr.y = ys; |
Lars Poeschel | d3a2fb8 | 2020-11-03 10:58:12 +0100 | [diff] [blame] | 335 | lcd->ops->gotoxy(lcd); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 336 | processed = 1; |
| 337 | break; |
| 338 | } |
| 339 | case 'I': /* reinitialize display */ |
Lars Poeschel | 01ec46d | 2020-11-03 10:58:17 +0100 | [diff] [blame] | 340 | lcd->ops->init_display(lcd); |
| 341 | priv->flags = ((lcd->height > 1) ? LCD_FLAG_N : 0) | LCD_FLAG_D | |
| 342 | LCD_FLAG_C | LCD_FLAG_B; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 343 | processed = 1; |
| 344 | break; |
Lars Poeschel | 339acb0 | 2020-11-03 10:58:20 +0100 | [diff] [blame^] | 345 | case 'G': |
| 346 | if (lcd->ops->redefine_char) |
| 347 | processed = lcd->ops->redefine_char(lcd, esc); |
| 348 | else |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 349 | processed = 1; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 350 | break; |
Lars Poeschel | 339acb0 | 2020-11-03 10:58:20 +0100 | [diff] [blame^] | 351 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 352 | case 'x': /* gotoxy : LxXXX[yYYY]; */ |
| 353 | case 'y': /* gotoxy : LyYYY[xXXX]; */ |
Mans Rullgard | 9bc30ab | 2018-12-05 13:52:47 +0000 | [diff] [blame] | 354 | if (priv->esc_seq.buf[priv->esc_seq.len - 1] != ';') |
| 355 | break; |
| 356 | |
Miguel Ojeda | b34050f | 2018-02-27 23:09:52 +0100 | [diff] [blame] | 357 | /* If the command is valid, move to the new address */ |
Lars Poeschel | 11588b5 | 2020-11-03 10:58:10 +0100 | [diff] [blame] | 358 | if (parse_xy(esc, &lcd->addr.x, &lcd->addr.y)) |
Lars Poeschel | d3a2fb8 | 2020-11-03 10:58:12 +0100 | [diff] [blame] | 359 | lcd->ops->gotoxy(lcd); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 360 | |
Miguel Ojeda | b34050f | 2018-02-27 23:09:52 +0100 | [diff] [blame] | 361 | /* Regardless of its validity, mark as processed */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 362 | processed = 1; |
| 363 | break; |
| 364 | } |
| 365 | |
| 366 | /* TODO: This indent party here got ugly, clean it! */ |
| 367 | /* Check whether one flag was changed */ |
| 368 | if (oldflags == priv->flags) |
| 369 | return processed; |
| 370 | |
Lars Poeschel | 8a86270 | 2020-11-03 10:58:19 +0100 | [diff] [blame] | 371 | if ((oldflags ^ priv->flags) & LCD_FLAG_L) |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 372 | charlcd_backlight(lcd, !!(priv->flags & LCD_FLAG_L)); |
| 373 | |
| 374 | return processed; |
| 375 | } |
| 376 | |
| 377 | static void charlcd_write_char(struct charlcd *lcd, char c) |
| 378 | { |
Andy Shevchenko | b658a21 | 2019-03-12 16:44:29 +0200 | [diff] [blame] | 379 | struct charlcd_priv *priv = charlcd_to_priv(lcd); |
Lars Poeschel | 2545c1c | 2020-11-03 10:58:06 +0100 | [diff] [blame] | 380 | struct hd44780_common *hdc = lcd->drvdata; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 381 | |
| 382 | /* first, we'll test if we're in escape mode */ |
| 383 | if ((c != '\n') && priv->esc_seq.len >= 0) { |
| 384 | /* yes, let's add this char to the buffer */ |
| 385 | priv->esc_seq.buf[priv->esc_seq.len++] = c; |
Robert Abel | 8c48375 | 2018-02-10 00:50:11 +0100 | [diff] [blame] | 386 | priv->esc_seq.buf[priv->esc_seq.len] = '\0'; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 387 | } else { |
| 388 | /* aborts any previous escape sequence */ |
| 389 | priv->esc_seq.len = -1; |
| 390 | |
| 391 | switch (c) { |
| 392 | case LCD_ESCAPE_CHAR: |
| 393 | /* start of an escape sequence */ |
| 394 | priv->esc_seq.len = 0; |
Robert Abel | 8c48375 | 2018-02-10 00:50:11 +0100 | [diff] [blame] | 395 | priv->esc_seq.buf[priv->esc_seq.len] = '\0'; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 396 | break; |
| 397 | case '\b': |
| 398 | /* go back one char and clear it */ |
Lars Poeschel | 11588b5 | 2020-11-03 10:58:10 +0100 | [diff] [blame] | 399 | if (lcd->addr.x > 0) { |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 400 | /* back one char */ |
| 401 | if (!lcd->ops->shift_cursor(lcd, |
| 402 | CHARLCD_SHIFT_LEFT)) |
| 403 | lcd->addr.x--; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 404 | } |
| 405 | /* replace with a space */ |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 406 | charlcd_print(lcd, ' '); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 407 | /* back one char again */ |
Lars Poeschel | d2f2187 | 2020-11-03 10:58:18 +0100 | [diff] [blame] | 408 | if (!lcd->ops->shift_cursor(lcd, CHARLCD_SHIFT_LEFT)) |
| 409 | lcd->addr.x--; |
| 410 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 411 | break; |
Robert Abel | 9629ccc | 2018-02-10 00:50:12 +0100 | [diff] [blame] | 412 | case '\f': |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 413 | /* quickly clear the display */ |
| 414 | charlcd_clear_fast(lcd); |
| 415 | break; |
| 416 | case '\n': |
| 417 | /* |
| 418 | * flush the remainder of the current line and |
| 419 | * go to the beginning of the next line |
| 420 | */ |
Lars Poeschel | 11588b5 | 2020-11-03 10:58:10 +0100 | [diff] [blame] | 421 | for (; lcd->addr.x < hdc->bwidth; lcd->addr.x++) |
Lars Poeschel | b26deab | 2020-11-03 10:58:11 +0100 | [diff] [blame] | 422 | lcd->ops->print(lcd, ' '); |
| 423 | |
Lars Poeschel | 11588b5 | 2020-11-03 10:58:10 +0100 | [diff] [blame] | 424 | lcd->addr.x = 0; |
| 425 | lcd->addr.y = (lcd->addr.y + 1) % lcd->height; |
Lars Poeschel | d3a2fb8 | 2020-11-03 10:58:12 +0100 | [diff] [blame] | 426 | lcd->ops->gotoxy(lcd); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 427 | break; |
| 428 | case '\r': |
| 429 | /* go to the beginning of the same line */ |
Lars Poeschel | 11588b5 | 2020-11-03 10:58:10 +0100 | [diff] [blame] | 430 | lcd->addr.x = 0; |
Lars Poeschel | d3a2fb8 | 2020-11-03 10:58:12 +0100 | [diff] [blame] | 431 | lcd->ops->gotoxy(lcd); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 432 | break; |
| 433 | case '\t': |
| 434 | /* print a space instead of the tab */ |
| 435 | charlcd_print(lcd, ' '); |
| 436 | break; |
| 437 | default: |
| 438 | /* simply print this char */ |
| 439 | charlcd_print(lcd, c); |
| 440 | break; |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | /* |
| 445 | * now we'll see if we're in an escape mode and if the current |
| 446 | * escape sequence can be understood. |
| 447 | */ |
| 448 | if (priv->esc_seq.len >= 2) { |
| 449 | int processed = 0; |
| 450 | |
| 451 | if (!strcmp(priv->esc_seq.buf, "[2J")) { |
| 452 | /* clear the display */ |
| 453 | charlcd_clear_fast(lcd); |
| 454 | processed = 1; |
| 455 | } else if (!strcmp(priv->esc_seq.buf, "[H")) { |
| 456 | /* cursor to home */ |
| 457 | charlcd_home(lcd); |
| 458 | processed = 1; |
| 459 | } |
| 460 | /* codes starting with ^[[L */ |
| 461 | else if ((priv->esc_seq.len >= 3) && |
| 462 | (priv->esc_seq.buf[0] == '[') && |
| 463 | (priv->esc_seq.buf[1] == 'L')) { |
| 464 | processed = handle_lcd_special_code(lcd); |
| 465 | } |
| 466 | |
| 467 | /* LCD special escape codes */ |
| 468 | /* |
| 469 | * flush the escape sequence if it's been processed |
| 470 | * or if it is getting too long. |
| 471 | */ |
| 472 | if (processed || (priv->esc_seq.len >= LCD_ESCAPE_LEN)) |
| 473 | priv->esc_seq.len = -1; |
| 474 | } /* escape codes */ |
| 475 | } |
| 476 | |
| 477 | static struct charlcd *the_charlcd; |
| 478 | |
| 479 | static ssize_t charlcd_write(struct file *file, const char __user *buf, |
| 480 | size_t count, loff_t *ppos) |
| 481 | { |
| 482 | const char __user *tmp = buf; |
| 483 | char c; |
| 484 | |
| 485 | for (; count-- > 0; (*ppos)++, tmp++) { |
| 486 | if (!in_interrupt() && (((count + 1) & 0x1f) == 0)) |
| 487 | /* |
| 488 | * let's be a little nice with other processes |
| 489 | * that need some CPU |
| 490 | */ |
| 491 | schedule(); |
| 492 | |
| 493 | if (get_user(c, tmp)) |
| 494 | return -EFAULT; |
| 495 | |
| 496 | charlcd_write_char(the_charlcd, c); |
| 497 | } |
| 498 | |
| 499 | return tmp - buf; |
| 500 | } |
| 501 | |
| 502 | static int charlcd_open(struct inode *inode, struct file *file) |
| 503 | { |
Andy Shevchenko | b658a21 | 2019-03-12 16:44:29 +0200 | [diff] [blame] | 504 | struct charlcd_priv *priv = charlcd_to_priv(the_charlcd); |
Willy Tarreau | 93dc177 | 2017-09-07 15:37:30 +0200 | [diff] [blame] | 505 | int ret; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 506 | |
Willy Tarreau | 93dc177 | 2017-09-07 15:37:30 +0200 | [diff] [blame] | 507 | ret = -EBUSY; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 508 | if (!atomic_dec_and_test(&charlcd_available)) |
Willy Tarreau | 93dc177 | 2017-09-07 15:37:30 +0200 | [diff] [blame] | 509 | goto fail; /* open only once at a time */ |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 510 | |
Willy Tarreau | 93dc177 | 2017-09-07 15:37:30 +0200 | [diff] [blame] | 511 | ret = -EPERM; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 512 | if (file->f_mode & FMODE_READ) /* device is write-only */ |
Willy Tarreau | 93dc177 | 2017-09-07 15:37:30 +0200 | [diff] [blame] | 513 | goto fail; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 514 | |
| 515 | if (priv->must_clear) { |
Lars Poeschel | 45421ff | 2020-11-03 10:58:14 +0100 | [diff] [blame] | 516 | priv->lcd.ops->clear_display(&priv->lcd); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 517 | priv->must_clear = false; |
Lars Poeschel | 45421ff | 2020-11-03 10:58:14 +0100 | [diff] [blame] | 518 | priv->lcd.addr.x = 0; |
| 519 | priv->lcd.addr.y = 0; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 520 | } |
| 521 | return nonseekable_open(inode, file); |
Willy Tarreau | 93dc177 | 2017-09-07 15:37:30 +0200 | [diff] [blame] | 522 | |
| 523 | fail: |
| 524 | atomic_inc(&charlcd_available); |
| 525 | return ret; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | static int charlcd_release(struct inode *inode, struct file *file) |
| 529 | { |
| 530 | atomic_inc(&charlcd_available); |
| 531 | return 0; |
| 532 | } |
| 533 | |
| 534 | static const struct file_operations charlcd_fops = { |
| 535 | .write = charlcd_write, |
| 536 | .open = charlcd_open, |
| 537 | .release = charlcd_release, |
| 538 | .llseek = no_llseek, |
| 539 | }; |
| 540 | |
| 541 | static struct miscdevice charlcd_dev = { |
| 542 | .minor = LCD_MINOR, |
| 543 | .name = "lcd", |
| 544 | .fops = &charlcd_fops, |
| 545 | }; |
| 546 | |
| 547 | static void charlcd_puts(struct charlcd *lcd, const char *s) |
| 548 | { |
| 549 | const char *tmp = s; |
| 550 | int count = strlen(s); |
| 551 | |
| 552 | for (; count-- > 0; tmp++) { |
| 553 | if (!in_interrupt() && (((count + 1) & 0x1f) == 0)) |
| 554 | /* |
| 555 | * let's be a little nice with other processes |
| 556 | * that need some CPU |
| 557 | */ |
| 558 | schedule(); |
| 559 | |
| 560 | charlcd_write_char(lcd, *tmp); |
| 561 | } |
| 562 | } |
| 563 | |
Mans Rullgard | c917172 | 2019-03-01 18:48:15 +0000 | [diff] [blame] | 564 | #ifdef CONFIG_PANEL_BOOT_MESSAGE |
| 565 | #define LCD_INIT_TEXT CONFIG_PANEL_BOOT_MESSAGE |
| 566 | #else |
| 567 | #define LCD_INIT_TEXT "Linux-" UTS_RELEASE "\n" |
| 568 | #endif |
| 569 | |
Mans Rullgard | cc5d04d | 2019-03-01 18:48:16 +0000 | [diff] [blame] | 570 | #ifdef CONFIG_CHARLCD_BL_ON |
| 571 | #define LCD_INIT_BL "\x1b[L+" |
| 572 | #elif defined(CONFIG_CHARLCD_BL_FLASH) |
| 573 | #define LCD_INIT_BL "\x1b[L*" |
| 574 | #else |
| 575 | #define LCD_INIT_BL "\x1b[L-" |
| 576 | #endif |
| 577 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 578 | /* initialize the LCD driver */ |
| 579 | static int charlcd_init(struct charlcd *lcd) |
| 580 | { |
Andy Shevchenko | b658a21 | 2019-03-12 16:44:29 +0200 | [diff] [blame] | 581 | struct charlcd_priv *priv = charlcd_to_priv(lcd); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 582 | int ret; |
| 583 | |
Lars Poeschel | 01ec46d | 2020-11-03 10:58:17 +0100 | [diff] [blame] | 584 | priv->flags = ((lcd->height > 1) ? LCD_FLAG_N : 0) | LCD_FLAG_D | |
| 585 | LCD_FLAG_C | LCD_FLAG_B; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 586 | if (lcd->ops->backlight) { |
| 587 | mutex_init(&priv->bl_tempo_lock); |
| 588 | INIT_DELAYED_WORK(&priv->bl_work, charlcd_bl_off); |
| 589 | } |
| 590 | |
| 591 | /* |
| 592 | * before this line, we must NOT send anything to the display. |
| 593 | * Since charlcd_init_display() needs to write data, we have to |
| 594 | * enable mark the LCD initialized just before. |
| 595 | */ |
Lars Poeschel | 01ec46d | 2020-11-03 10:58:17 +0100 | [diff] [blame] | 596 | ret = lcd->ops->init_display(lcd); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 597 | if (ret) |
| 598 | return ret; |
| 599 | |
| 600 | /* display a short message */ |
Mans Rullgard | cc5d04d | 2019-03-01 18:48:16 +0000 | [diff] [blame] | 601 | charlcd_puts(lcd, "\x1b[Lc\x1b[Lb" LCD_INIT_BL LCD_INIT_TEXT); |
Mans Rullgard | c917172 | 2019-03-01 18:48:15 +0000 | [diff] [blame] | 602 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 603 | /* clear the display on the next device opening */ |
| 604 | priv->must_clear = true; |
| 605 | charlcd_home(lcd); |
| 606 | return 0; |
| 607 | } |
| 608 | |
Lars Poeschel | 2545c1c | 2020-11-03 10:58:06 +0100 | [diff] [blame] | 609 | struct charlcd *charlcd_alloc(void) |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 610 | { |
| 611 | struct charlcd_priv *priv; |
| 612 | struct charlcd *lcd; |
| 613 | |
Lars Poeschel | 2545c1c | 2020-11-03 10:58:06 +0100 | [diff] [blame] | 614 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 615 | if (!priv) |
| 616 | return NULL; |
| 617 | |
| 618 | priv->esc_seq.len = -1; |
| 619 | |
| 620 | lcd = &priv->lcd; |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 621 | |
| 622 | return lcd; |
| 623 | } |
| 624 | EXPORT_SYMBOL_GPL(charlcd_alloc); |
| 625 | |
Andy Shevchenko | 8e44fc8 | 2019-03-12 16:44:30 +0200 | [diff] [blame] | 626 | void charlcd_free(struct charlcd *lcd) |
| 627 | { |
| 628 | kfree(charlcd_to_priv(lcd)); |
| 629 | } |
| 630 | EXPORT_SYMBOL_GPL(charlcd_free); |
| 631 | |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 632 | static int panel_notify_sys(struct notifier_block *this, unsigned long code, |
| 633 | void *unused) |
| 634 | { |
| 635 | struct charlcd *lcd = the_charlcd; |
| 636 | |
| 637 | switch (code) { |
| 638 | case SYS_DOWN: |
| 639 | charlcd_puts(lcd, |
| 640 | "\x0cReloading\nSystem...\x1b[Lc\x1b[Lb\x1b[L+"); |
| 641 | break; |
| 642 | case SYS_HALT: |
| 643 | charlcd_puts(lcd, "\x0cSystem Halted.\x1b[Lc\x1b[Lb\x1b[L+"); |
| 644 | break; |
| 645 | case SYS_POWER_OFF: |
| 646 | charlcd_puts(lcd, "\x0cPower off.\x1b[Lc\x1b[Lb\x1b[L+"); |
| 647 | break; |
| 648 | default: |
| 649 | break; |
| 650 | } |
| 651 | return NOTIFY_DONE; |
| 652 | } |
| 653 | |
| 654 | static struct notifier_block panel_notifier = { |
| 655 | panel_notify_sys, |
| 656 | NULL, |
| 657 | 0 |
| 658 | }; |
| 659 | |
| 660 | int charlcd_register(struct charlcd *lcd) |
| 661 | { |
| 662 | int ret; |
| 663 | |
| 664 | ret = charlcd_init(lcd); |
| 665 | if (ret) |
| 666 | return ret; |
| 667 | |
| 668 | ret = misc_register(&charlcd_dev); |
| 669 | if (ret) |
| 670 | return ret; |
| 671 | |
| 672 | the_charlcd = lcd; |
| 673 | register_reboot_notifier(&panel_notifier); |
| 674 | return 0; |
| 675 | } |
| 676 | EXPORT_SYMBOL_GPL(charlcd_register); |
| 677 | |
| 678 | int charlcd_unregister(struct charlcd *lcd) |
| 679 | { |
Andy Shevchenko | b658a21 | 2019-03-12 16:44:29 +0200 | [diff] [blame] | 680 | struct charlcd_priv *priv = charlcd_to_priv(lcd); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 681 | |
| 682 | unregister_reboot_notifier(&panel_notifier); |
| 683 | charlcd_puts(lcd, "\x0cLCD driver unloaded.\x1b[Lc\x1b[Lb\x1b[L-"); |
| 684 | misc_deregister(&charlcd_dev); |
| 685 | the_charlcd = NULL; |
| 686 | if (lcd->ops->backlight) { |
| 687 | cancel_delayed_work_sync(&priv->bl_work); |
Lars Poeschel | bd26b18 | 2020-11-03 10:58:16 +0100 | [diff] [blame] | 688 | priv->lcd.ops->backlight(&priv->lcd, CHARLCD_OFF); |
Geert Uytterhoeven | 39f8ea4 | 2017-03-10 15:15:17 +0100 | [diff] [blame] | 689 | } |
| 690 | |
| 691 | return 0; |
| 692 | } |
| 693 | EXPORT_SYMBOL_GPL(charlcd_unregister); |
| 694 | |
| 695 | MODULE_LICENSE("GPL"); |