Lines Matching full:lcd

3  * Character LCD driver for Linux
27 #define LCD_ESCAPE_LEN 24 /* Max chars for LCD escape command */
31 struct charlcd lcd; member
39 /* contains the LCD config state */
51 #define charlcd_to_priv(p) container_of(p, struct charlcd_priv, lcd)
57 void charlcd_backlight(struct charlcd *lcd, enum charlcd_onoff on) in charlcd_backlight() argument
59 struct charlcd_priv *priv = charlcd_to_priv(lcd); in charlcd_backlight()
61 if (!lcd->ops->backlight) in charlcd_backlight()
66 lcd->ops->backlight(lcd, on); in charlcd_backlight()
81 priv->lcd.ops->backlight(&priv->lcd, CHARLCD_OFF); in charlcd_bl_off()
87 void charlcd_poke(struct charlcd *lcd) in charlcd_poke() argument
89 struct charlcd_priv *priv = charlcd_to_priv(lcd); in charlcd_poke()
91 if (!lcd->ops->backlight) in charlcd_poke()
98 lcd->ops->backlight(lcd, CHARLCD_ON); in charlcd_poke()
105 static void charlcd_home(struct charlcd *lcd) in charlcd_home() argument
107 lcd->addr.x = 0; in charlcd_home()
108 lcd->addr.y = 0; in charlcd_home()
109 lcd->ops->home(lcd); in charlcd_home()
112 static void charlcd_print(struct charlcd *lcd, char c) in charlcd_print() argument
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()
128 static void charlcd_clear_display(struct charlcd *lcd) in charlcd_clear_display() argument
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()
189 * These are the file operation function for user access to /dev/lcd
195 static inline int handle_lcd_special_code(struct charlcd *lcd) in handle_lcd_special_code() argument
197 struct charlcd_priv *priv = charlcd_to_priv(lcd); in handle_lcd_special_code()
199 /* LCD special codes */ in handle_lcd_special_code()
211 lcd->ops->display(lcd, CHARLCD_ON); in handle_lcd_special_code()
218 lcd->ops->display(lcd, CHARLCD_OFF); in handle_lcd_special_code()
225 lcd->ops->cursor(lcd, CHARLCD_ON); in handle_lcd_special_code()
232 lcd->ops->cursor(lcd, CHARLCD_OFF); in handle_lcd_special_code()
239 lcd->ops->blink(lcd, CHARLCD_ON); in handle_lcd_special_code()
246 lcd->ops->blink(lcd, CHARLCD_OFF); in handle_lcd_special_code()
253 charlcd_backlight(lcd, CHARLCD_ON); in handle_lcd_special_code()
260 charlcd_backlight(lcd, CHARLCD_OFF); in handle_lcd_special_code()
265 charlcd_poke(lcd); in handle_lcd_special_code()
271 lcd->ops->fontsize(lcd, CHARLCD_FONTSIZE_SMALL); in handle_lcd_special_code()
278 lcd->ops->fontsize(lcd, CHARLCD_FONTSIZE_LARGE); in handle_lcd_special_code()
285 lcd->ops->lines(lcd, CHARLCD_LINES_1); 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()
313 lcd->ops->shift_display(lcd, CHARLCD_SHIFT_LEFT); 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()
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()
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()
365 static void charlcd_write_char(struct charlcd *lcd, char c) in charlcd_write_char() argument
367 struct charlcd_priv *priv = charlcd_to_priv(lcd); 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()
393 charlcd_print(lcd, ' '); 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()
401 charlcd_clear_display(lcd); 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()
422 charlcd_print(lcd, ' '); in charlcd_write_char()
426 charlcd_print(lcd, c); in charlcd_write_char()
440 charlcd_clear_display(lcd); in charlcd_write_char()
444 charlcd_home(lcd); in charlcd_write_char()
451 processed = handle_lcd_special_code(lcd); in charlcd_write_char()
454 /* LCD special escape codes */ in charlcd_write_char()
505 priv->lcd.ops->clear_display(&priv->lcd); in charlcd_open()
507 priv->lcd.addr.x = 0; in charlcd_open()
508 priv->lcd.addr.y = 0; in charlcd_open()
532 .name = "lcd",
536 static void charlcd_puts(struct charlcd *lcd, const char *s) in charlcd_puts() argument
545 charlcd_write_char(lcd, *tmp); in charlcd_puts()
563 /* initialize the LCD driver */
564 static int charlcd_init(struct charlcd *lcd) in charlcd_init() argument
566 struct charlcd_priv *priv = charlcd_to_priv(lcd); in charlcd_init()
569 priv->flags = ((lcd->height > 1) ? LCD_FLAG_N : 0) | LCD_FLAG_D | in charlcd_init()
571 if (lcd->ops->backlight) { in charlcd_init()
579 * enable mark the LCD initialized just before. in charlcd_init()
581 if (WARN_ON(!lcd->ops->init_display)) in charlcd_init()
584 ret = lcd->ops->init_display(lcd); in charlcd_init()
589 charlcd_puts(lcd, "\x1b[Lc\x1b[Lb" LCD_INIT_BL LCD_INIT_TEXT); in charlcd_init()
593 charlcd_home(lcd); in charlcd_init()
600 struct charlcd *lcd; in charlcd_alloc() local
608 lcd = &priv->lcd; in charlcd_alloc()
610 return lcd; in charlcd_alloc()
614 void charlcd_free(struct charlcd *lcd) in charlcd_free() argument
616 kfree(charlcd_to_priv(lcd)); in charlcd_free()
623 struct charlcd *lcd = the_charlcd; in panel_notify_sys() local
627 charlcd_puts(lcd, in panel_notify_sys()
631 charlcd_puts(lcd, "\x0cSystem Halted.\x1b[Lc\x1b[Lb\x1b[L+"); in panel_notify_sys()
634 charlcd_puts(lcd, "\x0cPower off.\x1b[Lc\x1b[Lb\x1b[L+"); in panel_notify_sys()
646 int charlcd_register(struct charlcd *lcd) in charlcd_register() argument
650 ret = charlcd_init(lcd); in charlcd_register()
658 the_charlcd = lcd; in charlcd_register()
664 int charlcd_unregister(struct charlcd *lcd) in charlcd_unregister() argument
666 struct charlcd_priv *priv = charlcd_to_priv(lcd); in charlcd_unregister()
669 charlcd_puts(lcd, "\x0cLCD driver unloaded.\x1b[Lc\x1b[Lb\x1b[L-"); in charlcd_unregister()
672 if (lcd->ops->backlight) { in charlcd_unregister()
674 priv->lcd.ops->backlight(&priv->lcd, CHARLCD_OFF); in charlcd_unregister()