hd44780_common.c (b26deabb1d915fe87d395081bbd3058b938dee89) | hd44780_common.c (d3a2fb810f273b7a2c393d4de28ae91a3f76985d) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2#include <linux/module.h> 3#include <linux/slab.h> 4 5#include "charlcd.h" 6#include "hd44780_common.h" 7 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2#include <linux/module.h> 3#include <linux/slab.h> 4 5#include "charlcd.h" 6#include "hd44780_common.h" 7 |
8/* LCD commands */ 9#define LCD_CMD_SET_DDRAM_ADDR 0x80 /* Set display data RAM address */ 10 |
|
8int hd44780_common_print(struct charlcd *lcd, int c) 9{ 10 struct hd44780_common *hdc = lcd->drvdata; 11 12 if (lcd->addr.x < hdc->bwidth) { 13 hdc->write_data(hdc, c); 14 return 0; 15 } 16 17 return 1; 18} 19EXPORT_SYMBOL_GPL(hd44780_common_print); 20 | 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 } 19 20 return 1; 21} 22EXPORT_SYMBOL_GPL(hd44780_common_print); 23 |
24int hd44780_common_gotoxy(struct charlcd *lcd) 25{ 26 struct hd44780_common *hdc = lcd->drvdata; 27 unsigned int addr; 28 29 /* 30 * we force the cursor to stay at the end of the 31 * line if it wants to go farther 32 */ 33 addr = lcd->addr.x < hdc->bwidth ? lcd->addr.x & (hdc->hwidth - 1) 34 : hdc->bwidth - 1; 35 if (lcd->addr.y & 1) 36 addr += hdc->hwidth; 37 if (lcd->addr.y & 2) 38 addr += hdc->bwidth; 39 hdc->write_cmd(hdc, LCD_CMD_SET_DDRAM_ADDR | addr); 40 return 0; 41} 42EXPORT_SYMBOL_GPL(hd44780_common_gotoxy); 43 |
|
21struct hd44780_common *hd44780_common_alloc(void) 22{ 23 struct hd44780_common *hd; 24 25 hd = kzalloc(sizeof(*hd), GFP_KERNEL); 26 if (!hd) 27 return NULL; 28 29 hd->ifwidth = 8; 30 hd->bwidth = DEFAULT_LCD_BWIDTH; 31 hd->hwidth = DEFAULT_LCD_HWIDTH; 32 return hd; 33} 34EXPORT_SYMBOL_GPL(hd44780_common_alloc); 35 36MODULE_LICENSE("GPL"); | 44struct hd44780_common *hd44780_common_alloc(void) 45{ 46 struct hd44780_common *hd; 47 48 hd = kzalloc(sizeof(*hd), GFP_KERNEL); 49 if (!hd) 50 return NULL; 51 52 hd->ifwidth = 8; 53 hd->bwidth = DEFAULT_LCD_BWIDTH; 54 hd->hwidth = DEFAULT_LCD_HWIDTH; 55 return hd; 56} 57EXPORT_SYMBOL_GPL(hd44780_common_alloc); 58 59MODULE_LICENSE("GPL"); |