hd44780_common.c (7b231bb5d0bee86afc40db9ddfd50ba39ef73769) hd44780_common.c (40c2b72e4b11f0a80dff19b539fccf36472dc417)
1// SPDX-License-Identifier: GPL-2.0-or-later
2#include <linux/module.h>
3#include <linux/sched.h>
4#include <linux/slab.h>
5
6#include "charlcd.h"
7#include "hd44780_common.h"
8

--- 35 unchanged lines hidden (view full) ---

44 hdc->write_data(hdc, c);
45 return 0;
46 }
47
48 return 1;
49}
50EXPORT_SYMBOL_GPL(hd44780_common_print);
51
1// SPDX-License-Identifier: GPL-2.0-or-later
2#include <linux/module.h>
3#include <linux/sched.h>
4#include <linux/slab.h>
5
6#include "charlcd.h"
7#include "hd44780_common.h"
8

--- 35 unchanged lines hidden (view full) ---

44 hdc->write_data(hdc, c);
45 return 0;
46 }
47
48 return 1;
49}
50EXPORT_SYMBOL_GPL(hd44780_common_print);
51
52int hd44780_common_gotoxy(struct charlcd *lcd)
52int hd44780_common_gotoxy(struct charlcd *lcd, unsigned int x, unsigned int y)
53{
54 struct hd44780_common *hdc = lcd->drvdata;
55 unsigned int addr;
56
57 /*
58 * we force the cursor to stay at the end of the
59 * line if it wants to go farther
60 */
53{
54 struct hd44780_common *hdc = lcd->drvdata;
55 unsigned int addr;
56
57 /*
58 * we force the cursor to stay at the end of the
59 * line if it wants to go farther
60 */
61 addr = lcd->addr.x < hdc->bwidth ? lcd->addr.x & (hdc->hwidth - 1)
62 : hdc->bwidth - 1;
63 if (lcd->addr.y & 1)
61 addr = x < hdc->bwidth ? x & (hdc->hwidth - 1) : hdc->bwidth - 1;
62 if (y & 1)
64 addr += hdc->hwidth;
63 addr += hdc->hwidth;
65 if (lcd->addr.y & 2)
64 if (y & 2)
66 addr += hdc->bwidth;
67 hdc->write_cmd(hdc, LCD_CMD_SET_DDRAM_ADDR | addr);
68 return 0;
69}
70EXPORT_SYMBOL_GPL(hd44780_common_gotoxy);
71
72int hd44780_common_home(struct charlcd *lcd)
73{
65 addr += hdc->bwidth;
66 hdc->write_cmd(hdc, LCD_CMD_SET_DDRAM_ADDR | addr);
67 return 0;
68}
69EXPORT_SYMBOL_GPL(hd44780_common_gotoxy);
70
71int hd44780_common_home(struct charlcd *lcd)
72{
74 lcd->addr.x = 0;
75 lcd->addr.y = 0;
76 return hd44780_common_gotoxy(lcd);
73 return hd44780_common_gotoxy(lcd, 0, 0);
77}
78EXPORT_SYMBOL_GPL(hd44780_common_home);
79
80/* clears the display and resets X/Y */
81int hd44780_common_clear_display(struct charlcd *lcd)
82{
83 struct hd44780_common *hdc = lcd->drvdata;
84

--- 251 unchanged lines hidden (view full) ---

336 }
337 }
338
339 hdc->write_cmd(hdc, LCD_CMD_SET_CGRAM_ADDR | (cgaddr * 8));
340 for (addr = 0; addr < cgoffset; addr++)
341 hdc->write_data(hdc, cgbytes[addr]);
342
343 /* ensures that we stop writing to CGRAM */
74}
75EXPORT_SYMBOL_GPL(hd44780_common_home);
76
77/* clears the display and resets X/Y */
78int hd44780_common_clear_display(struct charlcd *lcd)
79{
80 struct hd44780_common *hdc = lcd->drvdata;
81

--- 251 unchanged lines hidden (view full) ---

333 }
334 }
335
336 hdc->write_cmd(hdc, LCD_CMD_SET_CGRAM_ADDR | (cgaddr * 8));
337 for (addr = 0; addr < cgoffset; addr++)
338 hdc->write_data(hdc, cgbytes[addr]);
339
340 /* ensures that we stop writing to CGRAM */
344 lcd->ops->gotoxy(lcd);
341 lcd->ops->gotoxy(lcd, lcd->addr.x, lcd->addr.y);
345 return 1;
346}
347EXPORT_SYMBOL_GPL(hd44780_common_redefine_char);
348
349struct hd44780_common *hd44780_common_alloc(void)
350{
351 struct hd44780_common *hd;
352

--- 12 unchanged lines hidden ---
342 return 1;
343}
344EXPORT_SYMBOL_GPL(hd44780_common_redefine_char);
345
346struct hd44780_common *hd44780_common_alloc(void)
347{
348 struct hd44780_common *hd;
349

--- 12 unchanged lines hidden ---