Lines Matching +full:display +full:- +full:height +full:- +full:chars
1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu>
6 * Copyright (C) 2016-2017 Glider bvba
27 #define LCD_ESCAPE_LEN 24 /* Max chars for LCD escape command */
42 /* Current escape sequence and it's length or -1 if outside */
53 /* Device single-open policy control */
61 if (!lcd->ops->backlight) in charlcd_backlight()
64 mutex_lock(&priv->bl_tempo_lock); in charlcd_backlight()
65 if (!priv->bl_tempo) in charlcd_backlight()
66 lcd->ops->backlight(lcd, on); in charlcd_backlight()
67 mutex_unlock(&priv->bl_tempo_lock); in charlcd_backlight()
77 mutex_lock(&priv->bl_tempo_lock); in charlcd_bl_off()
78 if (priv->bl_tempo) { in charlcd_bl_off()
79 priv->bl_tempo = false; in charlcd_bl_off()
80 if (!(priv->flags & LCD_FLAG_L)) in charlcd_bl_off()
81 priv->lcd.ops->backlight(&priv->lcd, CHARLCD_OFF); in charlcd_bl_off()
83 mutex_unlock(&priv->bl_tempo_lock); in charlcd_bl_off()
91 if (!lcd->ops->backlight) in charlcd_poke()
94 cancel_delayed_work_sync(&priv->bl_work); in charlcd_poke()
96 mutex_lock(&priv->bl_tempo_lock); in charlcd_poke()
97 if (!priv->bl_tempo && !(priv->flags & LCD_FLAG_L)) in charlcd_poke()
98 lcd->ops->backlight(lcd, CHARLCD_ON); in charlcd_poke()
99 priv->bl_tempo = true; in charlcd_poke()
100 schedule_delayed_work(&priv->bl_work, LCD_BL_TEMPO_PERIOD * HZ); in charlcd_poke()
101 mutex_unlock(&priv->bl_tempo_lock); in charlcd_poke()
107 lcd->addr.x = 0; in charlcd_home()
108 lcd->addr.y = 0; in charlcd_home()
109 lcd->ops->home(lcd); in charlcd_home()
114 if (lcd->addr.x >= lcd->width) in charlcd_print()
117 if (lcd->char_conv) in charlcd_print()
118 c = lcd->char_conv[(unsigned char)c]; in charlcd_print()
120 if (!lcd->ops->print(lcd, c)) in charlcd_print()
121 lcd->addr.x++; in charlcd_print()
124 if (lcd->addr.x == lcd->width) in charlcd_print()
125 lcd->ops->gotoxy(lcd, lcd->addr.x - 1, lcd->addr.y); in charlcd_print()
130 lcd->ops->clear_display(lcd); in charlcd_clear_display()
131 lcd->addr.x = 0; in charlcd_clear_display()
132 lcd->addr.y = 0; in charlcd_clear_display()
137 * any number of subcommands of the form "(x|y)[0-9]+".
143 * - ";" returns (<original x>, <original y>).
144 * - "x1;" returns (1, <original y>).
145 * - "y2x1;" returns (1, 2).
146 * - "x12y34x56;" returns (56, 34).
147 * - "" fails.
148 * - "x" fails.
149 * - "x;" fails.
150 * - "x1" fails.
151 * - "xy12;" fails.
152 * - "x12yy12;" fails.
153 * - "xx" fails.
203 char *esc = priv->esc_seq.buf + 2; in handle_lcd_special_code()
204 int oldflags = priv->flags; in handle_lcd_special_code()
206 /* check for display mode flags */ in handle_lcd_special_code()
208 case 'D': /* Display ON */ in handle_lcd_special_code()
209 priv->flags |= LCD_FLAG_D; in handle_lcd_special_code()
210 if (priv->flags != oldflags) in handle_lcd_special_code()
211 lcd->ops->display(lcd, CHARLCD_ON); in handle_lcd_special_code()
215 case 'd': /* Display OFF */ in handle_lcd_special_code()
216 priv->flags &= ~LCD_FLAG_D; in handle_lcd_special_code()
217 if (priv->flags != oldflags) in handle_lcd_special_code()
218 lcd->ops->display(lcd, CHARLCD_OFF); in handle_lcd_special_code()
223 priv->flags |= LCD_FLAG_C; in handle_lcd_special_code()
224 if (priv->flags != oldflags) in handle_lcd_special_code()
225 lcd->ops->cursor(lcd, CHARLCD_ON); in handle_lcd_special_code()
230 priv->flags &= ~LCD_FLAG_C; in handle_lcd_special_code()
231 if (priv->flags != oldflags) in handle_lcd_special_code()
232 lcd->ops->cursor(lcd, CHARLCD_OFF); in handle_lcd_special_code()
237 priv->flags |= LCD_FLAG_B; in handle_lcd_special_code()
238 if (priv->flags != oldflags) in handle_lcd_special_code()
239 lcd->ops->blink(lcd, CHARLCD_ON); in handle_lcd_special_code()
244 priv->flags &= ~LCD_FLAG_B; in handle_lcd_special_code()
245 if (priv->flags != oldflags) in handle_lcd_special_code()
246 lcd->ops->blink(lcd, CHARLCD_OFF); in handle_lcd_special_code()
251 priv->flags |= LCD_FLAG_L; in handle_lcd_special_code()
252 if (priv->flags != oldflags) in handle_lcd_special_code()
257 case '-': /* Back light OFF */ in handle_lcd_special_code()
258 priv->flags &= ~LCD_FLAG_L; in handle_lcd_special_code()
259 if (priv->flags != oldflags) in handle_lcd_special_code()
269 priv->flags &= ~LCD_FLAG_F; in handle_lcd_special_code()
270 if (priv->flags != oldflags) in handle_lcd_special_code()
271 lcd->ops->fontsize(lcd, CHARLCD_FONTSIZE_SMALL); in handle_lcd_special_code()
276 priv->flags |= LCD_FLAG_F; in handle_lcd_special_code()
277 if (priv->flags != oldflags) in handle_lcd_special_code()
278 lcd->ops->fontsize(lcd, CHARLCD_FONTSIZE_LARGE); in handle_lcd_special_code()
283 priv->flags &= ~LCD_FLAG_N; in handle_lcd_special_code()
284 if (priv->flags != oldflags) in handle_lcd_special_code()
285 lcd->ops->lines(lcd, CHARLCD_LINES_1); in handle_lcd_special_code()
290 priv->flags |= LCD_FLAG_N; in handle_lcd_special_code()
291 if (priv->flags != oldflags) in handle_lcd_special_code()
292 lcd->ops->lines(lcd, CHARLCD_LINES_2); in handle_lcd_special_code()
297 if (lcd->addr.x > 0) { in handle_lcd_special_code()
298 if (!lcd->ops->shift_cursor(lcd, CHARLCD_SHIFT_LEFT)) in handle_lcd_special_code()
299 lcd->addr.x--; in handle_lcd_special_code()
305 if (lcd->addr.x < lcd->width) { in handle_lcd_special_code()
306 if (!lcd->ops->shift_cursor(lcd, CHARLCD_SHIFT_RIGHT)) in handle_lcd_special_code()
307 lcd->addr.x++; in handle_lcd_special_code()
312 case 'L': /* shift display left */ in handle_lcd_special_code()
313 lcd->ops->shift_display(lcd, CHARLCD_SHIFT_LEFT); in handle_lcd_special_code()
316 case 'R': /* shift display right */ in handle_lcd_special_code()
317 lcd->ops->shift_display(lcd, CHARLCD_SHIFT_RIGHT); in handle_lcd_special_code()
323 xs = lcd->addr.x; in handle_lcd_special_code()
324 ys = lcd->addr.y; in handle_lcd_special_code()
325 for (x = lcd->addr.x; x < lcd->width; x++) in handle_lcd_special_code()
326 lcd->ops->print(lcd, ' '); in handle_lcd_special_code()
329 lcd->addr.x = xs; in handle_lcd_special_code()
330 lcd->addr.y = ys; in handle_lcd_special_code()
331 lcd->ops->gotoxy(lcd, lcd->addr.x, lcd->addr.y); in handle_lcd_special_code()
335 case 'I': /* reinitialize display */ in handle_lcd_special_code()
336 lcd->ops->init_display(lcd); in handle_lcd_special_code()
337 priv->flags = ((lcd->height > 1) ? LCD_FLAG_N : 0) | LCD_FLAG_D | in handle_lcd_special_code()
342 if (lcd->ops->redefine_char) in handle_lcd_special_code()
343 processed = lcd->ops->redefine_char(lcd, esc); in handle_lcd_special_code()
350 if (priv->esc_seq.buf[priv->esc_seq.len - 1] != ';') in handle_lcd_special_code()
354 if (parse_xy(esc, &lcd->addr.x, &lcd->addr.y)) in handle_lcd_special_code()
355 lcd->ops->gotoxy(lcd, lcd->addr.x, lcd->addr.y); in handle_lcd_special_code()
370 if ((c != '\n') && priv->esc_seq.len >= 0) { in charlcd_write_char()
372 priv->esc_seq.buf[priv->esc_seq.len++] = c; in charlcd_write_char()
373 priv->esc_seq.buf[priv->esc_seq.len] = '\0'; in charlcd_write_char()
376 priv->esc_seq.len = -1; in charlcd_write_char()
381 priv->esc_seq.len = 0; in charlcd_write_char()
382 priv->esc_seq.buf[priv->esc_seq.len] = '\0'; in charlcd_write_char()
386 if (lcd->addr.x > 0) { in charlcd_write_char()
388 if (!lcd->ops->shift_cursor(lcd, in charlcd_write_char()
390 lcd->addr.x--; in charlcd_write_char()
395 if (!lcd->ops->shift_cursor(lcd, CHARLCD_SHIFT_LEFT)) in charlcd_write_char()
396 lcd->addr.x--; in charlcd_write_char()
400 /* quickly clear the display */ in charlcd_write_char()
408 for (; lcd->addr.x < lcd->width; lcd->addr.x++) in charlcd_write_char()
409 lcd->ops->print(lcd, ' '); in charlcd_write_char()
411 lcd->addr.x = 0; in charlcd_write_char()
412 lcd->addr.y = (lcd->addr.y + 1) % lcd->height; in charlcd_write_char()
413 lcd->ops->gotoxy(lcd, lcd->addr.x, lcd->addr.y); in charlcd_write_char()
417 lcd->addr.x = 0; in charlcd_write_char()
418 lcd->ops->gotoxy(lcd, lcd->addr.x, lcd->addr.y); in charlcd_write_char()
435 if (priv->esc_seq.len >= 2) { in charlcd_write_char()
438 if (!strcmp(priv->esc_seq.buf, "[2J")) { in charlcd_write_char()
439 /* clear the display */ in charlcd_write_char()
442 } else if (!strcmp(priv->esc_seq.buf, "[H")) { in charlcd_write_char()
448 else if ((priv->esc_seq.len >= 3) && in charlcd_write_char()
449 (priv->esc_seq.buf[0] == '[') && in charlcd_write_char()
450 (priv->esc_seq.buf[1] == 'L')) { in charlcd_write_char()
459 if (processed || (priv->esc_seq.len >= LCD_ESCAPE_LEN)) in charlcd_write_char()
460 priv->esc_seq.len = -1; in charlcd_write_char()
472 for (; count-- > 0; (*ppos)++, tmp++) { in charlcd_write()
475 * charlcd_write() is invoked as a VFS->write() callback in charlcd_write()
483 return -EFAULT; in charlcd_write()
488 return tmp - buf; in charlcd_write()
496 ret = -EBUSY; in charlcd_open()
500 ret = -EPERM; in charlcd_open()
501 if (file->f_mode & FMODE_READ) /* device is write-only */ in charlcd_open()
504 if (priv->must_clear) { in charlcd_open()
505 priv->lcd.ops->clear_display(&priv->lcd); in charlcd_open()
506 priv->must_clear = false; in charlcd_open()
507 priv->lcd.addr.x = 0; in charlcd_open()
508 priv->lcd.addr.y = 0; in charlcd_open()
541 for (; count-- > 0; tmp++) { in charlcd_puts()
552 #define LCD_INIT_TEXT "Linux-" UTS_RELEASE "\n"
560 #define LCD_INIT_BL "\x1b[L-"
569 priv->flags = ((lcd->height > 1) ? LCD_FLAG_N : 0) | LCD_FLAG_D | in charlcd_init()
571 if (lcd->ops->backlight) { in charlcd_init()
572 mutex_init(&priv->bl_tempo_lock); in charlcd_init()
573 INIT_DELAYED_WORK(&priv->bl_work, charlcd_bl_off); in charlcd_init()
577 * before this line, we must NOT send anything to the display. in charlcd_init()
581 if (WARN_ON(!lcd->ops->init_display)) in charlcd_init()
582 return -EINVAL; in charlcd_init()
584 ret = lcd->ops->init_display(lcd); in charlcd_init()
588 /* display a short message */ in charlcd_init()
591 /* clear the display on the next device opening */ in charlcd_init()
592 priv->must_clear = true; in charlcd_init()
606 priv->esc_seq.len = -1; in charlcd_alloc()
608 lcd = &priv->lcd; in charlcd_alloc()
669 charlcd_puts(lcd, "\x0cLCD driver unloaded.\x1b[Lc\x1b[Lb\x1b[L-"); in charlcd_unregister()
672 if (lcd->ops->backlight) { in charlcd_unregister()
673 cancel_delayed_work_sync(&priv->bl_work); in charlcd_unregister()
674 priv->lcd.ops->backlight(&priv->lcd, CHARLCD_OFF); in charlcd_unregister()