hd44780_common.c (88645a86e3420cddfe5bb9cd8d7c15aff8f54b46) | hd44780_common.c (45421ffefbb5f195de02ead952755329ef8576d8) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2#include <linux/module.h> | 1// SPDX-License-Identifier: GPL-2.0-or-later 2#include <linux/module.h> |
3#include <linux/sched.h> |
|
3#include <linux/slab.h> 4 5#include "charlcd.h" 6#include "hd44780_common.h" 7 8/* LCD commands */ | 4#include <linux/slab.h> 5 6#include "charlcd.h" 7#include "hd44780_common.h" 8 9/* LCD commands */ |
10#define LCD_CMD_DISPLAY_CLEAR 0x01 /* Clear entire display */ 11 |
|
9#define LCD_CMD_SET_DDRAM_ADDR 0x80 /* Set display data RAM address */ 10 | 12#define LCD_CMD_SET_DDRAM_ADDR 0x80 /* Set display data RAM address */ 13 |
14/* sleeps that many milliseconds with a reschedule */ 15static void long_sleep(int ms) 16{ 17 schedule_timeout_interruptible(msecs_to_jiffies(ms)); 18} 19 |
|
11int hd44780_common_print(struct charlcd *lcd, int c) 12{ 13 struct hd44780_common *hdc = lcd->drvdata; 14 15 if (lcd->addr.x < hdc->bwidth) { 16 hdc->write_data(hdc, c); 17 return 0; 18 } --- 25 unchanged lines hidden (view full) --- 44int hd44780_common_home(struct charlcd *lcd) 45{ 46 lcd->addr.x = 0; 47 lcd->addr.y = 0; 48 return hd44780_common_gotoxy(lcd); 49} 50EXPORT_SYMBOL_GPL(hd44780_common_home); 51 | 20int hd44780_common_print(struct charlcd *lcd, int c) 21{ 22 struct hd44780_common *hdc = lcd->drvdata; 23 24 if (lcd->addr.x < hdc->bwidth) { 25 hdc->write_data(hdc, c); 26 return 0; 27 } --- 25 unchanged lines hidden (view full) --- 53int hd44780_common_home(struct charlcd *lcd) 54{ 55 lcd->addr.x = 0; 56 lcd->addr.y = 0; 57 return hd44780_common_gotoxy(lcd); 58} 59EXPORT_SYMBOL_GPL(hd44780_common_home); 60 |
61/* clears the display and resets X/Y */ 62int hd44780_common_clear_display(struct charlcd *lcd) 63{ 64 struct hd44780_common *hdc = lcd->drvdata; 65 66 hdc->write_cmd(hdc, LCD_CMD_DISPLAY_CLEAR); 67 /* we must wait a few milliseconds (15) */ 68 long_sleep(15); 69 return 0; 70} 71EXPORT_SYMBOL_GPL(hd44780_common_clear_display); 72 |
|
52struct hd44780_common *hd44780_common_alloc(void) 53{ 54 struct hd44780_common *hd; 55 56 hd = kzalloc(sizeof(*hd), GFP_KERNEL); 57 if (!hd) 58 return NULL; 59 60 hd->ifwidth = 8; 61 hd->bwidth = DEFAULT_LCD_BWIDTH; 62 hd->hwidth = DEFAULT_LCD_HWIDTH; 63 return hd; 64} 65EXPORT_SYMBOL_GPL(hd44780_common_alloc); 66 67MODULE_LICENSE("GPL"); | 73struct hd44780_common *hd44780_common_alloc(void) 74{ 75 struct hd44780_common *hd; 76 77 hd = kzalloc(sizeof(*hd), GFP_KERNEL); 78 if (!hd) 79 return NULL; 80 81 hd->ifwidth = 8; 82 hd->bwidth = DEFAULT_LCD_BWIDTH; 83 hd->hwidth = DEFAULT_LCD_HWIDTH; 84 return hd; 85} 86EXPORT_SYMBOL_GPL(hd44780_common_alloc); 87 88MODULE_LICENSE("GPL"); |