if (priv->addr.x < hdc->bwidth) {
if (lcd->char_conv)
c = lcd->char_conv[(unsigned char)c];
- lcd->ops->write_data(lcd, c);
+ hdc->write_data(hdc, c);
priv->addr.x++;
/* prevents the cursor from wrapping onto the next line */
lcd->ops->clear_fast(lcd);
else
for (pos = 0; pos < min(2, lcd->height) * hdc->hwidth; pos++)
- lcd->ops->write_data(lcd, ' ');
+ hdc->write_data(hdc, ' ');
charlcd_home(lcd);
}
int x;
for (x = priv->addr.x; x < hdc->bwidth; x++)
- lcd->ops->write_data(lcd, ' ');
+ hdc->write_data(hdc, ' ');
/* restore cursor position */
charlcd_gotoxy(lcd);
lcd->ops->write_cmd(lcd, LCD_CMD_SET_CGRAM_ADDR | (cgaddr * 8));
for (addr = 0; addr < cgoffset; addr++)
- lcd->ops->write_data(lcd, cgbytes[addr]);
+ hdc->write_data(hdc, cgbytes[addr]);
/* ensures that we stop writing to CGRAM */
charlcd_gotoxy(lcd);
priv->addr.x--;
}
/* replace with a space */
- lcd->ops->write_data(lcd, ' ');
+ hdc->write_data(hdc, ' ');
/* back one char again */
lcd->ops->write_cmd(lcd, LCD_CMD_SHIFT);
break;
* go to the beginning of the next line
*/
for (; priv->addr.x < hdc->bwidth; priv->addr.x++)
- lcd->ops->write_data(lcd, ' ');
+ hdc->write_data(hdc, ' ');
priv->addr.x = 0;
priv->addr.y = (priv->addr.y + 1) % lcd->height;
charlcd_gotoxy(lcd);
struct charlcd_ops {
/* Required */
void (*write_cmd)(struct charlcd *lcd, int cmd);
- void (*write_data)(struct charlcd *lcd, int data);
/* Optional */
void (*write_cmd_raw4)(struct charlcd *lcd, int cmd); /* 4-bit only */
}
/* Send data to the LCD panel in 8 bit GPIO mode */
-static void hd44780_write_data_gpio8(struct charlcd *lcd, int data)
+static void hd44780_write_data_gpio8(struct hd44780_common *hdc, int data)
{
- struct hd44780_common *hdc = lcd->drvdata;
struct hd44780 *hd = hdc->hd44780;
hd44780_write_gpio8(hd, data, 1);
static const struct charlcd_ops hd44780_ops_gpio8 = {
.write_cmd = hd44780_write_cmd_gpio8,
- .write_data = hd44780_write_data_gpio8,
.backlight = hd44780_backlight,
};
}
/* Send data to the LCD panel in 4 bit GPIO mode */
-static void hd44780_write_data_gpio4(struct charlcd *lcd, int data)
+static void hd44780_write_data_gpio4(struct hd44780_common *hdc, int data)
{
- struct hd44780_common *hdc = lcd->drvdata;
struct hd44780 *hd = hdc->hd44780;
hd44780_write_gpio4(hd, data, 1);
static const struct charlcd_ops hd44780_ops_gpio4 = {
.write_cmd = hd44780_write_cmd_gpio4,
.write_cmd_raw4 = hd44780_write_cmd_raw_gpio4,
- .write_data = hd44780_write_data_gpio4,
.backlight = hd44780_backlight,
};
device_property_read_u32(dev, "internal-buffer-width", &hdc->bwidth);
hdc->ifwidth = ifwidth;
- lcd->ops = ifwidth == 8 ? &hd44780_ops_gpio8 : &hd44780_ops_gpio4;
+ if (ifwidth == 8) {
+ lcd->ops = &hd44780_ops_gpio8;
+ hdc->write_data = hd44780_write_data_gpio8;
+ } else {
+ lcd->ops = &hd44780_ops_gpio4;
+ hdc->write_data = hd44780_write_data_gpio4;
+ }
ret = charlcd_register(lcd);
if (ret)
int ifwidth; /* 4-bit or 8-bit (default) */
int bwidth; /* Default set by hd44780_alloc() */
int hwidth; /* Default set by hd44780_alloc() */
+ void (*write_data)(struct hd44780_common *hdc, int data);
void *hd44780;
};
}
/* send data to the LCD panel in serial mode */
-static void lcd_write_data_s(struct charlcd *charlcd, int data)
+static void lcd_write_data_s(struct hd44780_common *hdc, int data)
{
spin_lock_irq(&pprt_lock);
lcd_send_serial(0x5F); /* R/W=W, RS=1 */
}
/* send data to the LCD panel in 8 bits parallel mode */
-static void lcd_write_data_p8(struct charlcd *charlcd, int data)
+static void lcd_write_data_p8(struct hd44780_common *hdc, int data)
{
spin_lock_irq(&pprt_lock);
/* present the data to the data port */
}
/* send data to the TI LCD panel */
-static void lcd_write_data_tilcd(struct charlcd *charlcd, int data)
+static void lcd_write_data_tilcd(struct hd44780_common *hdc, int data)
{
spin_lock_irq(&pprt_lock);
/* present the data to the data port */
static const struct charlcd_ops charlcd_serial_ops = {
.write_cmd = lcd_write_cmd_s,
- .write_data = lcd_write_data_s,
.clear_fast = lcd_clear_fast_s,
.backlight = lcd_backlight,
};
static const struct charlcd_ops charlcd_parallel_ops = {
.write_cmd = lcd_write_cmd_p8,
- .write_data = lcd_write_data_p8,
.clear_fast = lcd_clear_fast_p8,
.backlight = lcd_backlight,
};
static const struct charlcd_ops charlcd_tilcd_ops = {
.write_cmd = lcd_write_cmd_tilcd,
- .write_data = lcd_write_data_tilcd,
.clear_fast = lcd_clear_fast_tilcd,
.backlight = lcd_backlight,
};
if (lcd.proto == LCD_PROTO_SERIAL) { /* SERIAL */
charlcd->ops = &charlcd_serial_ops;
+ hdc->write_data = lcd_write_data_s;
if (lcd.pins.cl == PIN_NOT_SET)
lcd.pins.cl = DEFAULT_LCD_PIN_SCL;
} else if (lcd.proto == LCD_PROTO_PARALLEL) { /* PARALLEL */
charlcd->ops = &charlcd_parallel_ops;
+ hdc->write_data = lcd_write_data_p8;
if (lcd.pins.e == PIN_NOT_SET)
lcd.pins.e = DEFAULT_LCD_PIN_E;
lcd.pins.rw = DEFAULT_LCD_PIN_RW;
} else {
charlcd->ops = &charlcd_tilcd_ops;
+ hdc->write_data = lcd_write_data_tilcd;
}
if (lcd.pins.bl == PIN_NOT_SET)