Beispiel #1
0
static int cobalt_lcdfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
{
	u32 x, y;
	int retval;

	switch (cursor->set) {
	case FB_CUR_SETPOS:
		x = cursor->image.dx;
		y = cursor->image.dy;
		if (x >= LCD_XRES_MAX || y >= LCD_YRES_MAX)
			return -EINVAL;

		retval = lcd_busy_wait(info);
		if (retval < 0)
			return retval;

		lcd_write_control(info,
				  LCD_TEXT_POS(info->fix.line_length * y + x));
		break;
	default:
		return -EINVAL;
	}

	retval = lcd_busy_wait(info);
	if (retval < 0)
		return retval;

	if (cursor->enable)
		lcd_write_control(info, LCD_CURSOR_ON);
	else
		lcd_write_control(info, LCD_CURSOR_OFF);

	return 0;
}
Beispiel #2
0
static ssize_t cobalt_lcdfb_write(struct fb_info *info, const char __user *buf,
				  size_t count, loff_t *ppos)
{
	char dst[LCD_CHARS_MAX];
	unsigned long pos;
	int len, retval = 0;

	pos = *ppos;
	if (pos >= LCD_CHARS_MAX || count == 0)
		return 0;

	if (count > LCD_CHARS_MAX)
		count = LCD_CHARS_MAX;

	if (pos + count > LCD_CHARS_MAX)
		count = LCD_CHARS_MAX - pos;

	if (copy_from_user(dst, buf, count))
		return -EFAULT;

	for (len = 0; len < count; len++) {
		retval = lcd_busy_wait(info);
		if (retval < 0)
			break;

		lcd_write_control(info, LCD_TEXT_POS(pos));

		retval = lcd_busy_wait(info);
		if (retval < 0)
			break;

		lcd_write_data(info, dst[len]);
		if (pos == 0x0f)
			pos = 0x40;
		else
			pos++;
	}

	if (retval < 0 && signal_pending(current))
		return -ERESTARTSYS;

	*ppos += len;

	return len;
}
Beispiel #3
0
//------------------------------------------------------------------------------------
// lcd_cmd
//------------------------------------------------------------------------------------
//
// write a command to the LCD controller
//
void lcd_cmd(char cmd)
{
	char SFRPAGE_SAVE;

	SFRPAGE_SAVE = SFRPAGE;			// Save Current SFR page
	SFRPAGE = CONFIG_PAGE;

	lcd_busy_wait();
	LCD_CTRL_PORT = LCD_CTRL_PORT & ~RS_MASK;	// RS = 0
	LCD_CTRL_PORT = LCD_CTRL_PORT & ~RW_MASK;	// RW = 0
	LCD_DAT_PORT = cmd;
	small_delay(1);		//RPK
	pulse_E();

	SFRPAGE = SFRPAGE_SAVE;			// Restore SFR page
}
// generic send
void lcd_send(uint8_t data, uint8_t type) {
	lcd_busy_wait();

	if (type) {
		lcd_set_data();
	} else {
		lcd_set_instruction();
	}

	lcd_set_write();
	lcd_set_enable_on();
	lcd_set_port_write();
	lcd_write(data);
	LCD_DELAY;
	LCD_DELAY;
	lcd_set_enable_off();
}
Beispiel #5
0
static int cobalt_lcdfb_blank(int blank_mode, struct fb_info *info)
{
	int retval;

	retval = lcd_busy_wait(info);
	if (retval < 0)
		return retval;

	switch (blank_mode) {
	case FB_BLANK_UNBLANK:
		lcd_write_control(info, LCD_ON);
		break;
	default:
		lcd_write_control(info, LCD_OFF);
		break;
	}

	return 0;
}
Beispiel #6
0
//------------------------------------------------------------------------------------
// lcd_dat (putchar)
//------------------------------------------------------------------------------------
//
// write a character to the LCD screen
//
char lcd_dat(char dat)
//char putchar(char dat)
{
	char SFRPAGE_SAVE;

	SFRPAGE_SAVE = SFRPAGE;			// Save Current SFR page
	SFRPAGE = CONFIG_PAGE;

	lcd_busy_wait();
	LCD_CTRL_PORT = LCD_CTRL_PORT | RS_MASK;	// RS = 1
	LCD_CTRL_PORT = LCD_CTRL_PORT & ~RW_MASK;	// RW = 0
	LCD_DAT_PORT = dat;
	small_delay(1);		//RPK
	pulse_E();

	SFRPAGE = SFRPAGE_SAVE;			// Restore SFR page

	return 1;
}
// generic get
uint8_t lcd_get(uint8_t type) {
	uint8_t data;

	lcd_busy_wait();
	lcd_set_port_read();
	lcd_write(0xFF);

	if (type) {
		lcd_set_data();
	} else {
		lcd_set_instruction();
	}

	lcd_set_read();
	lcd_set_enable_on();
	LCD_DELAY;
	LCD_DELAY;
	data = lcd_read();
	lcd_set_enable_off();

	return data;
}