static void mio283qt2_setarea(FAR struct mio283qt2_lcd_s *lcd, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { mio283qt2_putreg(lcd, 0x03, (x0 & 0x00ff)); /* set x0 */ mio283qt2_putreg(lcd, 0x02, (x0 >> 8)); /* set x0 */ mio283qt2_putreg(lcd, 0x05, (x1 & 0x00ff)); /* set x1 */ mio283qt2_putreg(lcd, 0x04, (x1 >> 8)); /* set x1 */ mio283qt2_putreg(lcd, 0x07, (y0 & 0x00ff)); /* set y0 */ mio283qt2_putreg(lcd, 0x06, (y0 >> 8)); /* set y0 */ mio283qt2_putreg(lcd, 0x09, (y1 & 0x00ff)); /* set y1 */ mio283qt2_putreg(lcd, 0x08, (y1 >> 8)); /* set y1 */ }
static int mio283qt2_setpower(FAR struct lcd_dev_s *dev, int power) { FAR struct mio283qt2_dev_s *priv = (FAR struct mio283qt2_dev_s *)dev; FAR struct mio283qt2_lcd_s *lcd = priv->lcd; lcdvdbg("power: %d\n", power); DEBUGASSERT((unsigned)power <= CONFIG_LCD_MAXPOWER); /* Set new power level */ if (power > 0) { /* Select the LCD */ lcd->select(lcd); /* Set the backlight level */ lcd->backlight(lcd, power); /* Then turn the display on: * D=ON(3) CM=0 DTE=1 GON=1 SPT=0 VLE=0 PT=0 */ mio283qt2_putreg(lcd, 0x28, 0x0038); /* GON=1, DTE=1, D=2 */ up_mdelay(40); mio283qt2_putreg(lcd, 0x28, 0x003c); /* GON=1, DTE=1, D=3 */ /* Deselect the LCD */ lcd->deselect(lcd); /* Remember the power on state */ g_lcddev.power = power; } else { /* Turn the display off */ mio283qt2_poweroff(lcd); } return OK; }
static int mio283qt2_poweroff(FAR struct mio283qt2_lcd_s *lcd) { /* Set the backlight off */ lcd->backlight(lcd, 0); /* Turn the display off */ mio283qt2_putreg(lcd, 0x28, 0x0000); /* GON=0, DTE=0, D=0 */ /* Remember the power off state */ g_lcddev.power = 0; return OK; }
static inline int mio283qt2_hwinitialize(FAR struct mio283qt2_dev_s *priv) { FAR struct mio283qt2_lcd_s *lcd = priv->lcd; #ifndef CONFIG_LCD_NOGETRUN uint16_t id; #endif int ret; /* Select the LCD */ lcd->select(lcd); /* Read the HIMAX ID registger (0x00) */ #ifndef CONFIG_LCD_NOGETRUN id = mio283qt2_readreg(lcd, 0x00); lcddbg("LCD ID: %04x\n", id); /* Check if the ID is for the MIO283QT2 */ if (id == HIMAX_ID) #endif { /* Driving ability */ mio283qt2_putreg(lcd, 0xea, 0x0000); /* PTBA[15:8] */ mio283qt2_putreg(lcd, 0xeb, 0x0020); /* PTBA[7:0] */ mio283qt2_putreg(lcd, 0xec, 0x000c); /* STBA[15:8] */ mio283qt2_putreg(lcd, 0xed, 0x00c4); /* STBA[7:0] */ mio283qt2_putreg(lcd, 0xe8, 0x0040); /* OPON[7:0] */ mio283qt2_putreg(lcd, 0xe9, 0x0038); /* OPON1[7:0] */ mio283qt2_putreg(lcd, 0xf1, 0x0001); /* OTPS1B */ mio283qt2_putreg(lcd, 0xf2, 0x0010); /* GEN */ mio283qt2_putreg(lcd, 0x27, 0x00a3); /* Power voltage */ mio283qt2_putreg(lcd, 0x1b, 0x001b); /* VRH = 4.65 */ mio283qt2_putreg(lcd, 0x1a, 0x0001); /* BT */ mio283qt2_putreg(lcd, 0x24, 0x002f); /* VMH */ mio283qt2_putreg(lcd, 0x25, 0x0057); /* VML */ /* Vcom offset */ mio283qt2_putreg(lcd, 0x23, 0x008d); /* For flicker adjust */ /* Power on */ mio283qt2_putreg(lcd, 0x18, 0x0036); mio283qt2_putreg(lcd, 0x19, 0x0001); /* Start oscillator */ mio283qt2_putreg(lcd, 0x01, 0x0000); /* Wakeup */ mio283qt2_putreg(lcd, 0x1f, 0x0088); up_mdelay(5); mio283qt2_putreg(lcd, 0x1f, 0x0080); up_mdelay(5); mio283qt2_putreg(lcd, 0x1f, 0x0090); up_mdelay(5); mio283qt2_putreg(lcd, 0x1f, 0x00d0); up_mdelay(5); /* Gamma 2.8 setting */ mio283qt2_putreg(lcd, 0x40, 0x0000); mio283qt2_putreg(lcd, 0x41, 0x0000); mio283qt2_putreg(lcd, 0x42, 0x0001); mio283qt2_putreg(lcd, 0x43, 0x0013); mio283qt2_putreg(lcd, 0x44, 0x0010); mio283qt2_putreg(lcd, 0x45, 0x0026); mio283qt2_putreg(lcd, 0x46, 0x0008); mio283qt2_putreg(lcd, 0x47, 0x0051); mio283qt2_putreg(lcd, 0x48, 0x0002); mio283qt2_putreg(lcd, 0x49, 0x0012); mio283qt2_putreg(lcd, 0x4a, 0x0018); mio283qt2_putreg(lcd, 0x4b, 0x0019); mio283qt2_putreg(lcd, 0x4c, 0x0014); mio283qt2_putreg(lcd, 0x50, 0x0019); mio283qt2_putreg(lcd, 0x51, 0x002f); mio283qt2_putreg(lcd, 0x52, 0x002c); mio283qt2_putreg(lcd, 0x53, 0x003e); mio283qt2_putreg(lcd, 0x54, 0x003f); mio283qt2_putreg(lcd, 0x55, 0x003f); mio283qt2_putreg(lcd, 0x56, 0x002e); mio283qt2_putreg(lcd, 0x57, 0x0077); mio283qt2_putreg(lcd, 0x58, 0x000b); mio283qt2_putreg(lcd, 0x59, 0x0006); mio283qt2_putreg(lcd, 0x5a, 0x0007); mio283qt2_putreg(lcd, 0x5b, 0x000d); mio283qt2_putreg(lcd, 0x5c, 0x001d); mio283qt2_putreg(lcd, 0x5d, 0x00cc); /* 4K Color Selection */ mio283qt2_putreg(lcd, 0x17, 0x0003); mio283qt2_putreg(lcd, 0x17, 0x0005); /* 0x0005=65k, 0x0006=262k */ /* Panel characteristics */ mio283qt2_putreg(lcd, 0x36, 0x0000); /* Display Setting */ mio283qt2_putreg(lcd, 0x01, 0x0000); /* IDMON=0, INVON=0, NORON=0, PTLON=0 */ #if defined(CONFIG_LCD_LANDSCAPE) mio283qt2_putreg(lcd, 0x16, 0x00a8); /* MY=1, MX=0, MV=1, ML=0, BGR=1 */ #elif defined(CONFIG_LCD_PORTRAIT) mio283qt2_putreg(lcd, 0x16, 0x0008); /* MY=0, MX=0, MV=0, ML=0, BGR=1 */ #elif defined(CONFIG_LCD_RLANDSCAPE) mio283qt2_putreg(lcd, 0x16, 0x0068); /* MY=0, MX=1, MV=1, ML=0, BGR=1 */ #elif defined(CONFIG_LCD_RPORTRAIT) mio283qt2_putreg(lcd, 0x16, 0x00c8); /* MY=1, MX=0, MV=1, ML=0, BGR=1 */ #endif /* Window setting */ mio283qt2_setarea(lcd, 0, 0, (MIO283QT2_XRES-1), (MIO283QT2_YRES-1)); ret = OK; } #ifndef CONFIG_LCD_NOGETRUN else { lcddbg("Unsupported LCD type\n"); ret = -ENODEV; } #endif /* De-select the LCD */ lcd->deselect(lcd); return ret; }