static void lcd_display_off(void) { /* LQV shutdown sequence */ lcd_write_reg(LTV_PWRCTL1, (LTV_VCOMOUT_ENABLE | LTV_DRIVE_CURRENT(5) | LTV_SUPPLY_CURRENT(5))); sleep_ms(20); lcd_write_reg(LTV_PWRCTL1, (LTV_DRIVE_CURRENT(5) | LTV_SUPPLY_CURRENT(5))); lcd_write_reg(LTV_GATECTL2, (LTV_NW_INV_1LINE | LTV_FTI(3) | LTV_FWI(3))); lcd_write_reg(LTV_PWRCTL2, 0); sleep_ms(20); lcd_write_reg(LTV_PWRCTL1, 0); sleep_ms(10); unsigned char temp[1]; temp[0] = 0; spi_block_transfer(SPI_target_LTV250QV, temp, sizeof(temp), NULL, 0); IO_GIO_BITCLR2 = (1 << 4); sleep_ms(5); IO_GIO_BITCLR2 = (1 << 7); sleep_ms(5); IO_GIO_BITCLR2 = (1 << 0); sleep_ms(2); IO_GIO_BITCLR2 = (1 << 8); IO_GIO_BITCLR2 = (1 << 5); /* Disable main power */ IO_GIO_BITCLR2 |= (1 << 3); enable_venc(false); lcd_on = false; }
/* void lcd_update_rect(int, int, int, int) ICODE_ATTR; */ void lcd_update_rect(int x, int y, int width, int height) { const fb_data *addr; int ymax; /* The Y coordinates have to work on even 8 pixel rows */ ymax = (y + height-1) >> 2; y >>= 2; if(x + width > LCD_WIDTH) width = LCD_WIDTH - x; if (width <= 0) return; /* nothing left to do, 0 is harmful to lcd_write_data() */ if(ymax >= LCD_FBHEIGHT) ymax = LCD_FBHEIGHT-1; /* Copy specified rectange bitmap to hardware */ for (; y <= ymax; y++) { lcd_write_reg(LCD_CNTL_PAGE, y); lcd_write_reg(LCD_CNTL_COLUMN, x); addr = &lcd_framebuffer[y][x]; lcd_send_cmd(LCD_CNTL_DATA_WRITE); lcd_write_data(addr, width); } }
void unknown02(void) { /* BOOT: 0x6308 OF: 0x88D0C */ lcd_write_reg(0x7, 0x160); lcd_write_reg(0x10, 0x17B1); }
/* unknown 01 and 02 - sleep or enable on and off funcs? */ void unknown01(void) { /* BOOT: 0x62C4 OF: 0x88CA0 */ lcd_write_reg(0x10, 0x17B0); udelay(100); lcd_write_reg(0x7, 0x173); }
static void lcd_set_cursor(uint16_t x, uint16_t y){ uint16_t temp; temp = y; y = x; x = MAX_Y - 1 - temp; lcd_write_reg(0x0020, x); lcd_write_reg(0x0021, y); lcd_write_index(0x0022); }
static void lcd_sync_settings(void) { #ifdef HAVE_LCD_CONTRAST lcd_write_reg(0x0b, reg0x0b); #endif #ifdef HAVE_LCD_INVERT lcd_write_reg(0x27, reg0x27); #endif #ifdef HAVE_LCD_FLIP lcd_write_reg(0x06, reg0x06); #endif }
static void lcd_enable_seq(bool enable) { if(enable) { lcd_write_reg(0x11, NULL, 0); lcd_write_reg(0x29, NULL, 0); } else { lcd_write_reg(0x28, NULL, 0); lcd_write_reg(0x10, NULL, 0); } }
static void lcd_v1_set_gram_area(int x, int y, int width, int height) { lcdctrl_bypass(1); LCDC_CTRL |= RGB24B; lcd_write_reg(0x03, x); lcd_write_reg(0x05, width-1); lcd_write_reg(0x07, y); lcd_write_reg(0x09, height-1); lcd_cmd(0x22); LCDC_CTRL &= ~RGB24B; }
void lcd_update_rect(int x, int y, int w, int h) { #ifdef HAVE_LCD_ENABLE if(!lcd_on) return; #endif imx233_lcdif_wait_ready(); lcd_write_reg(0x16, x | (x + w - 1) << 8); lcd_write_reg(0x17, y | (y + h - 1) << 8); lcd_write_reg(0x21, y * LCD_WIDTH + x); lcd_write_reg(0x22, 0); for(int yy = y; yy < y + h; yy++) imx233_lcdif_pio_send(true, 2 * w, FBADDR(x, yy)); }
void lcd_set_contrast(int val) { reg0x0b = val & 0x3f; if (!lcd_on) return; lcd_write_reg(0x0b, reg0x0b); }
void lcd_set_invert_display(bool yesno) { reg0x27 = yesno ? 0x10 : 0x00; if (!lcd_on) return; lcd_write_reg(0x27, reg0x27); }
void lcd_set_point(uint16_t x, uint16_t y, uint16_t color){ if( (x >= MAX_X) || (y >= MAX_Y)){ return; } lcd_set_cursor(x, y); lcd_write_reg(0x0022,color); }
void lcd_set_flip(bool yesno) { reg0x06 = yesno ? 0x02 : 0x04; if (!lcd_on) return; lcd_write_reg(0x06, reg0x06); }
void lcd_update(void) { const fb_data *addr; addr = FBADDR(LCD_WIDTH,LCD_HEIGHT); lcd_write_reg(0x20, 0x0); lcd_write_reg(0x21, 0x0); int i,j; for(i=0; i < LCD_HEIGHT; i++) { for(j=0; j < LCD_WIDTH; j++) { lcd_write_reg(0x22, *addr); addr++; } } }
static void lcd_set_power(bool powered) { if (powered) { lcd_powered = false; lcd_write_reg(0x04, 0x00); lcd_enable_interface(false); bitclr32(&GPIO3_DR, (1 << 12)); mc13783_clear(MC13783_REGULATOR_MODE1, MC13783_VCAMEN); } else { mc13783_set(MC13783_REGULATOR_MODE1, MC13783_VCAMEN); bitset32(&GPIO3_DR, (1 << 12)); lcd_enable_interface(true); lcd_write_reg(0x04, 0x01); lcd_powered = true; } }
void lcd_update(void) { const fb_data *addr; addr = &lcd_framebuffer[LCD_HEIGHT][LCD_WIDTH]; lcd_write_reg(0x20, 0x0); lcd_write_reg(0x21, 0x0); int i,j; for(i=0; i < LCD_HEIGHT; i++) { for(j=0; j < LCD_WIDTH; j++) { lcd_write_reg(0x22, *addr); addr++; } } }
static void lcd_init_seq(void) { // seems compatible with ILI9163 lcd_write_reg(1, NULL, 0); // software reset lcd_write_reg(0x11, NULL, 0); // sleep out mdelay(150); /* format: (<cmd> <data size> <data0> <dataN>)+ */ static uint8_t init_seq[] = { /* cmd sz data... */ 0x26, 1, 4, /* Gamma Set */ 0xb1, 2, 9, 0xd, /* Frame Rate */ 0xc0, 2, 8, 0, /* Power Control 1 */ 0xc1, 1, 5, /* Power Control 2 */ 0xc5, 2, 0x31, 0x40, /* VCOM Control 1 */ 0xc7, 1, 0xc8, /* VCOM Offset Control */ 0xec, 1, 0xc, /* Unknown */ 0x3a, 1, 5, /* Interface Pixel Format */ 0x2a, 4, 0, 0, 0, 0x7f, /* Column Address */ 0x2b, 4, 0, 0, 0, 0x9f, /* Page Address Set */ 0x35, 1, 0, /* Tear Effect Line On */ 0x36, 1, 0xc8, /* Memory access Control */ 0xb4, 1, 0, /* Display Inversion */ 0xb7, 1, 0, /* Source Driver Direction Control */ 0xb8, 1, 0, /* Gate Driver Direction Control */ 0xf2, 1, 1, /* Gamma Adjustment */ 0xe0, 15, 0x3f, 0x20, 0x1d, 0x2d, 0x26, 0x0c, 0x4b, 0xb7, 0x39, 0x17, 0x1d, 0x16, 0x16, 0x10, 0x00, /* Positive Gamma */ 0xe1, 15, 0x00, 0x1f, 0x21, 0x12, 0x18, 0x13, 0x34, 0x48, 0x46, 0x08, 0x21, 0x29, 0x28, 0x2f, 0x3f, /* Negative Gamma */ 0x29, 0, /* Display On */ }; for(unsigned i = 0; i < sizeof(init_seq); ) { lcd_write_reg(init_seq[i], &init_seq[i + 2], init_seq[i + 1]); i += 2 + init_seq[i + 1]; } }
static void lcd_v1_enable (bool on) { if (on == display_on) return; lcdctrl_bypass(1); LCDC_CTRL |= RGB24B; if (on) { lcd_write_reg(0x18, 0x44); lcd_write_reg(0x21, 0x01); lcd_write_reg(0x01, 0x00); lcd_write_reg(0x1C, 0x03); lcd_write_reg(0x19, 0x06); udelay(5); lcd_write_reg(0x26, 0x84); udelay(40); lcd_write_reg(0x26, 0xB8); udelay(40); lcd_write_reg(0x26, 0xBC); } else { lcd_write_reg(0x26, 0xB8); udelay(40); lcd_write_reg(0x19, 0x01); udelay(40); lcd_write_reg(0x26, 0xA4); udelay(40); lcd_write_reg(0x26, 0x84); udelay(40); lcd_write_reg(0x1C, 0x00); lcd_write_reg(0x01, 0x02); lcd_write_reg(0x21, 0x00); } display_on = on; LCDC_CTRL &= ~RGB24B; }
void lcd_init_device(void) { #if 0 /* This is the init sequence from the yh820 OF bootloader */ unsigned long tmp; DEV_INIT2 |= 0x400; DEV_INIT1 &= ~0x3000; tmp = DEV_INIT1; DEV_INIT1 = tmp; DEV_INIT2 &= ~0x400; LCD1_CONTROL &= ~0x4; udelay(15); LCD1_CONTROL |= 0x4; LCD1_CONTROL = 0x680; LCD1_CONTROL = 0x684; LCD1_CONTROL |= 0x1; lcd_send_cmd(LCD_CNTL_RESET); lcd_send_cmd(LCD_CNTL_DISCHARGE_ON_OFF | 0); lcd_send_cmd(LCD_CNTL_ON_OFF | 0); /* LCD OFF */ lcd_send_cmd(LCD_CNTL_COLUMN_ADDRESS_DIR | 0); /* Normal */ lcd_send_cmd(LCD_CNTL_COMMON_OUTPUT_STATUS | 0); /* Normal */ lcd_send_cmd(LCD_CNTL_REVERSE | 0); /* Reverse OFF */ lcd_send_cmd(LCD_CNTL_ALL_LIGHTING | 0); /* Normal */ lcd_write_reg_ex(LCD_CNTL_DUTY_SET, 0x1f, 0x00); lcd_send_cmd(LCD_CNTL_OFF_MODE | 1); /* OFF -> VCC on drivers */ lcd_write_reg(LCD_CNTL_VOLTAGE_SELECT, 0x03); lcd_write_reg(LCD_CNTL_ELECTRONIC_VOLUME, 0x40); lcd_write_reg(LCD_CNTL_TEMP_GRADIENT_SELECT, 0x00); lcd_write_reg(LCD_CNTL_LINE_INVERT_DRIVE, 0x1f); lcd_send_cmd(LCD_CNTL_NLINE_ON_OFF | 1); /* N-line ON */ lcd_write_reg(LCD_CNTL_OSC_FREQUENCY, 0x00); lcd_send_cmd(LCD_CNTL_OSC_ON_OFF | 1); /* Oscillator ON */ lcd_write_reg(LCD_CNTL_STEPUP_CK_FREQ, 0x03); lcd_write_reg(LCD_CNTL_POWER_CONTROL, 0x1c); lcd_write_reg(LCD_CNTL_POWER_CONTROL, 0x1e); lcd_write_reg(LCD_CNTL_DISPLAY_START_LINE, 0x00); lcd_send_cmd(LCD_CNTL_DATA_INPUT_DIR | 0); /* Column mode */ lcd_send_cmd(LCD_CNTL_DISPLAY_MODE, 0); /* Greyscale mode */ lcd_write_reg(LCD_CNTL_GRAY_SCALE_PATTERN, 0x52); lcd_send_cmd(LCD_CNTL_PARTIAL_DISPLAY_ON_OFF | 0); lcd_write_reg(LCD_CNTL_POWER_CONTROL, 0x1f); lcd_send_cmd(LCD_CNTL_ON_OFF | 1); /* LCD ON */ #endif }
static void lcd_v2_display_init(void) { unsigned int x, y; lcd_write_reg(0xD0, 0x0003); lcd_write_reg(0xEB, 0x0B00); lcd_write_reg(0xEC, 0x00CF); lcd_write_reg(0xC7, 0x030F); lcd_write_reg(0x01, 0x001C); lcd_write_reg(0x02, 0x0100); lcd_write_reg(0x03, 0x1038); lcd_write_reg(0x07, 0x0000); lcd_write_reg(0x08, 0x0808); lcd_write_reg(0x0F, 0x0901); lcd_write_reg(0x10, 0x0000); lcd_write_reg(0x11, 0x1B41); lcd_write_reg(0x12, 0x2010); lcd_write_reg(0x13, 0x0009); lcd_write_reg(0x14, 0x4C65); lcd_write_reg(0x30, 0x0000); lcd_write_reg(0x31, 0x00DB); lcd_write_reg(0x32, 0x0000); lcd_write_reg(0x33, 0x0000); lcd_write_reg(0x34, 0x00DB); lcd_write_reg(0x35, 0x0000); lcd_write_reg(0x36, 0x00AF); lcd_write_reg(0x37, 0x0000); lcd_write_reg(0x38, 0x00DB); lcd_write_reg(0x39, 0x0000); lcd_write_reg(0x50, 0x0000); lcd_write_reg(0x51, 0x0705); lcd_write_reg(0x52, 0x0C0A); lcd_write_reg(0x53, 0x0401); lcd_write_reg(0x54, 0x040C); lcd_write_reg(0x55, 0x0608); lcd_write_reg(0x56, 0x0000); lcd_write_reg(0x57, 0x0104); lcd_write_reg(0x58, 0x0E06); lcd_write_reg(0x59, 0x060E); lcd_write_reg(0x20, 0x0000); lcd_write_reg(0x21, 0x0000); lcd_write_reg(0x07, 0x1017); lcd_write_reg(0x20, 0x00AF); lcd_write_reg(0x21, 0x0000); lcd_cmd(0x22); for (x=0; x<LCD_WIDTH; x++) for(y=0; y<LCD_HEIGHT; y++) lcd_data(0x00); display_on = true; }
void lcd_v1_display_init(void) { unsigned int x, y; /* Driving ability setting */ lcd_write_reg(0x60, 0x00); lcd_write_reg(0x61, 0x06); lcd_write_reg(0x62, 0x00); lcd_write_reg(0x63, 0xC8); /* Gamma 2.2 Setting */ lcd_write_reg(0x40, 0x00); lcd_write_reg(0x41, 0x40); lcd_write_reg(0x42, 0x45); lcd_write_reg(0x43, 0x01); lcd_write_reg(0x44, 0x60); lcd_write_reg(0x45, 0x05); lcd_write_reg(0x46, 0x0C); lcd_write_reg(0x47, 0xD1); lcd_write_reg(0x48, 0x05); lcd_write_reg(0x50, 0x75); lcd_write_reg(0x51, 0x01); lcd_write_reg(0x52, 0x67); lcd_write_reg(0x53, 0x14); lcd_write_reg(0x54, 0xF2); lcd_write_reg(0x55, 0x07); lcd_write_reg(0x56, 0x03); lcd_write_reg(0x57, 0x49); /* Power voltage setting */ lcd_write_reg(0x1F, 0x03); lcd_write_reg(0x20, 0x00); lcd_write_reg(0x24, 0x28); lcd_write_reg(0x25, 0x45); lcd_write_reg(0x23, 0x2F); /* Power on setting */ lcd_write_reg(0x18, 0x44); lcd_write_reg(0x21, 0x01); lcd_write_reg(0x01, 0x00); lcd_write_reg(0x1C, 0x03); lcd_write_reg(0x19, 0x06); udelay(5); /* Display on setting */ lcd_write_reg(0x26, 0x84); udelay(40); lcd_write_reg(0x26, 0xB8); udelay(40); lcd_write_reg(0x26, 0xBC); udelay(40); /* Memmory access setting */ lcd_write_reg(0x16, 0x68); /* Setup 16bit mode */ lcd_write_reg(0x17, 0x05); /* Set GRAM area */ lcd_write_reg(0x02, 0x00); lcd_write_reg(0x03, 0x00); lcd_write_reg(0x04, 0x00); lcd_write_reg(0x05, LCD_WIDTH - 1); lcd_write_reg(0x06, 0x00); lcd_write_reg(0x07, 0x00); lcd_write_reg(0x08, 0x00); lcd_write_reg(0x09, LCD_HEIGHT - 1); /* Start GRAM write */ lcd_cmd(0x22); for (x=0; x<LCD_WIDTH; x++) for(y=0; y<LCD_HEIGHT; y++) lcd_data(0x00); display_on = true; }
/* Run the powerup sequence for the driver IC */ static void lcd_power_on(void) { lcd_reset(); /* OF: 0x5DC0 * * r2: cmd * * r3: data */ lcd_write_reg(0xE5, 0x8000); lcd_write_reg(0x0, 0x1); lcd_write_reg(0x1, 0x100); lcd_write_reg(0x2, 0x700); lcd_write_reg(0x3, 0x1230); lcd_write_reg(0x4, 0x0); lcd_write_reg(0x8, 0x408); lcd_write_reg(0x9, 0x0); lcd_write_reg(0xa, 0x0); lcd_write_reg(0xd, 0x0); lcd_write_reg(0xf, 0x2); lcd_write_reg(0x10, 0x0); lcd_write_reg(0x11, 0x0); lcd_write_reg(0x12, 0x0); lcd_write_reg(0x13, 0x0); sleep(HZ/5); lcd_write_reg(0x10, 0x17B0); lcd_write_reg(0x11, 0x7); sleep(HZ/20); lcd_write_reg(0x12, 0x13c); sleep(HZ/20); /* BOOT: BNE 0x5fb2 */ if (lcd_type == 0) { lcd_write_reg(0x13, 0x1700); lcd_write_reg(0x29, 0x10); sleep(HZ/10); lcd_write_reg(0x20, 0x0); lcd_write_reg(0x21, 0x0); lcd_write_reg(0x30, 0x7); lcd_write_reg(0x31, 0x403); lcd_write_reg(0x32, 0x400); lcd_write_reg(0x35, 0x3); lcd_write_reg(0x36, 0xF07); lcd_write_reg(0x37, 0x606); lcd_write_reg(0x38, 0x106); lcd_write_reg(0x39, 0x7); } else { lcd_write_reg(0x13, 0x1800); lcd_write_reg(0x29, 0x13); sleep(HZ/10); lcd_write_reg(0x20, 0x0); lcd_write_reg(0x21, 0x0); lcd_write_reg(0x30, 0x2); lcd_write_reg(0x31, 0x606); lcd_write_reg(0x32, 0x501); lcd_write_reg(0x35, 0x206); lcd_write_reg(0x36, 0x504); lcd_write_reg(0x37, 0x707); lcd_write_reg(0x38, 0x306); lcd_write_reg(0x39, 0x9); } /* BOOT: 0x6066 */ lcd_write_reg(0x3c, 0x700); lcd_write_reg(0x3d, 0x700); lcd_write_reg(0x50, 0x0); lcd_write_reg(0x51, 0xef); /* 239 - LCD_WIDTH */ lcd_write_reg(0x52, 0x0); lcd_write_reg(0x53, 0x13f); /* 319 - LCD_HEIGHT */ /* BOOT: b 0x6114 */ lcd_write_reg(0x60, 0x2700); lcd_write_reg(0x61, 0x1); lcd_write_reg(0x6a, 0x0); lcd_write_reg(0x80, 0x0); lcd_write_reg(0x81, 0x0); lcd_write_reg(0x82, 0x0); lcd_write_reg(0x83, 0x0); lcd_write_reg(0x84, 0x0); lcd_write_reg(0x85, 0x0); /* BOOT: 0x61A8 */ lcd_write_reg(0x90, 0x10); lcd_write_reg(0x92, 0x0); lcd_write_reg(0x93, 0x3); lcd_write_reg(0x95, 0x110); lcd_write_reg(0x97, 0x0); lcd_write_reg(0x98, 0x0); lcd_write_reg(0xc, 0x110); lcd_write_reg(0x7, 0x173); sleep(HZ/10); power_on = true; }
void lcd_update_rect(int x, int y, int w, int h) { #ifdef HAVE_LCD_ENABLE if(!lcd_on) return; #endif /* make sure the rectangle is included in the screen */ x = MIN(x, LCD_WIDTH); y = MIN(y, LCD_HEIGHT); w = MIN(w, LCD_WIDTH - x); h = MIN(h, LCD_HEIGHT - y); imx233_lcdif_wait_ready(); uint32_t window = x << 8 | (x + w - 1) << 24; lcd_write_reg(0x2a, &window, sizeof(window)); window = y << 8 | (y + h - 1) << 24; lcd_write_reg(0x2b, &window, sizeof(window)); lcd_write_reg(0x2c, NULL, 0); imx233_lcdif_wait_ready(); imx233_lcdif_set_data_swizzle(3); imx233_lcdif_set_word_length(8); /* there are two cases here: * - either width = LCD_WIDTH and we can directly memcopy a part of lcd_framebuffer to FRAME * and send it * - either width != LCD_WIDTH and we have to build a contiguous copy of the rectangular area * into FRAME before sending it (which is slower and doesn't use the hardware) * In all cases, FRAME just acts as a temporary buffer. * NOTE It's more interesting to do a copy to FRAME in all cases since in system mode * the clock runs at 24MHz which provides barely 10MB/s bandwidth compared to >100MB/s * for memcopy operations */ if(w == LCD_WIDTH) { memcpy((void *)FRAME, FBADDR(x,y), w * h * sizeof(fb_data)); } else { for(int i = 0; i < h; i++) memcpy((fb_data *)FRAME + i * w, FBADDR(x,y + i), w * sizeof(fb_data)); } /* WARNING The LCDIF has a limitation on the vertical count ! In 16-bit packed mode * (which we used, ie 16-bit per pixel, 2 pixels per 32-bit words), the v_count * field must be a multiple of 2. Furthermore, it seems the lcd controller doesn't * really like when both w and h are even, probably because the writes to the GRAM * are done on several words and the controller requires dummy writes. * The workaround is to always make sure that we send a number of pixels which is * a multiple of 4 so that both the lcdif and the controller are happy. If any * of w or h is odd, we will send a copy of the first pixels as dummy writes. We will * send at most 3 bytes. We then send (w * h + 3) / 4 x 4 bytes. */ if(w % 2 == 1 || h % 2 == 1) { /* copy three pixel after the last one */ for(int i = 0; i < 3; i++) *((fb_data *)FRAME + w * h + i) = *((fb_data *)FRAME + i); /* WARNING we need to update w and h to reflect the pixel count BUT it * has no relation to w * h (it can even be 2 * prime). Hopefully, w <= 240 and * h <= 320 so w * h <= 76800 and (w * h + 3) / 4 <= 38400 which fits into * a 16-bit integer (horizontal count). */ h = (w * h + 3) / 4; w = 4; } imx233_lcdif_dma_send((void *)FRAME_PHYS_ADDR, w * 2, h); }
void lcd_init_device(void) { /* clock at 24MHZ */ imx233_clkctrl_enable(CLK_PIX, false); imx233_clkctrl_set_div(CLK_PIX, 3); imx233_clkctrl_set_bypass(CLK_PIX, true); /* use XTAL */ imx233_clkctrl_enable(CLK_PIX, true); imx233_lcdif_init(); imx233_lcdif_setup_system_pins(8); imx233_lcdif_set_timings(2, 2, 2, 2); imx233_lcdif_set_word_length(8); lcd_write_reg(0, 1); lcd_write_reg(3, 0); lcd_write_reg(3, 0x510); lcd_write_reg(9, 8); lcd_write_reg(0xc, 0); lcd_write_reg(0xd, 0); lcd_write_reg(0xe, 0); lcd_write_reg(0x5b, 4); lcd_write_reg(0xd, 0x10); lcd_write_reg(9, 0); lcd_write_reg(3, 0x10); lcd_write_reg(0xd, 0x14); lcd_write_reg(0xe, 0x2b12); lcd_write_reg(1, 0x21f); lcd_write_reg(2, 0x700); lcd_write_reg(5, 0x30); lcd_write_reg(6, 0); lcd_write_reg(8, 0x202); lcd_write_reg(0xa, 0x3); // OF uses 0xc0003 with 3 transfers/pixels lcd_write_reg(0xb, 0); lcd_write_reg(0xf, 0); lcd_write_reg(0x10, 0); lcd_write_reg(0x11, 0); lcd_write_reg(0x14, 0x9f00); lcd_write_reg(0x15, 0x9f00); lcd_write_reg(0x16, 0x7f00); lcd_write_reg(0x17, 0x9f00); lcd_write_reg(0x20, 0); lcd_write_reg(0x21, 0); lcd_write_reg(0x23, 0); lcd_write_reg(0x24, 0); lcd_write_reg(0x25, 0); lcd_write_reg(0x26, 0); lcd_write_reg(0x30, 0x707); lcd_write_reg(0x31, 0x504); lcd_write_reg(0x32, 7); lcd_write_reg(0x33, 0x307); lcd_write_reg(0x34, 7); lcd_write_reg(0x35, 0x400); lcd_write_reg(0x36, 0x607); lcd_write_reg(0x37, 0x703); lcd_write_reg(0x3a, 0x1a0d); lcd_write_reg(0x3b, 0x1309); lcd_write_reg(9, 4); lcd_write_reg(7, 5); lcd_write_reg(7, 0x25); lcd_write_reg(7, 0x27); lcd_write_reg(0x5b, 0); lcd_write_reg(7, 0x37); #ifdef HAVE_LCD_ENABLE lcd_on = true; #endif }
void lcd_initialize(void){ uint32_t i = 0x1fffff; lcd_line_init(); lcd_fsmc_initialize(); while(i--); lcd_write_reg(0x00e7,0x0010); lcd_write_reg(0x0000,0x0001); lcd_write_reg(0x0001,(0<<10)|(1<<8)); lcd_write_reg(0x0002,0x0700); lcd_write_reg(0x0003,(1<<12)|(1<<5)|(0<<4)|(1<<3)); lcd_write_reg(0x0004,0x0000); lcd_write_reg(0x0008,0x0207); lcd_write_reg(0x0009,0x0000); lcd_write_reg(0x000a,0x0000); lcd_write_reg(0x000c,0x0001); lcd_write_reg(0x000d,0x0000); lcd_write_reg(0x000f,0x0000); lcd_write_reg(0x0010,0x0000); lcd_write_reg(0x0011,0x0007); lcd_write_reg(0x0012,0x0000); lcd_write_reg(0x0013,0x0000); lcd_delay(50); lcd_write_reg(0x0010,0x1590); lcd_write_reg(0x0011,0x0227); lcd_delay(50); lcd_write_reg(0x0012,0x009c); lcd_delay(50); lcd_write_reg(0x0013,0x1900); lcd_write_reg(0x0029,0x0023); lcd_write_reg(0x002b,0x000e); lcd_delay(50); lcd_delay(50); lcd_write_reg(0x0030,0x0007); lcd_write_reg(0x0031,0x0707); lcd_write_reg(0x0032,0x0006); lcd_write_reg(0x0035,0x0704); lcd_write_reg(0x0036,0x1f04); lcd_write_reg(0x0037,0x0004); lcd_write_reg(0x0038,0x0000); lcd_write_reg(0x0039,0x0706); lcd_write_reg(0x003c,0x0701); lcd_write_reg(0x003d,0x000f); lcd_delay(50); lcd_write_reg(0x0050,0x0000); lcd_write_reg(0x0051,0x00ef); lcd_write_reg(0x0052,0x0000); lcd_write_reg(0x0053,0x013f); lcd_write_reg(0x0060,0xa700); lcd_write_reg(0x0061,0x0001); lcd_write_reg(0x006a,0x0000); lcd_write_reg(0x0080,0x0000); lcd_write_reg(0x0081,0x0000); lcd_write_reg(0x0082,0x0000); lcd_write_reg(0x0083,0x0000); lcd_write_reg(0x0084,0x0000); lcd_write_reg(0x0085,0x0000); lcd_write_reg(0x0090,0x0010); lcd_write_reg(0x0092,0x0600); lcd_write_reg(0x0093,0x0003); lcd_write_reg(0x0095,0x0110); lcd_write_reg(0x0097,0x0000); lcd_write_reg(0x0098,0x0000); lcd_write_reg(0x0007,0x0133); }
void lcd_set_cursor(u16 x, u16 y) { lcd_write_reg(0x20, x); lcd_write_reg(0x21, y); }
void lcd_set_window(u16 left, u16 top, u16 right, u16 bottom) { lcd_write_reg(0x50, sat(left, 0, LCD_WIDTH-1)); lcd_write_reg(0x51, sat(right-1, 0, LCD_WIDTH-1)); lcd_write_reg(0x52, sat(top, 0, LCD_HEIGHT-1)); lcd_write_reg(0x53, sat(bottom-1, 0, LCD_HEIGHT-1)); }
static void lcd_display_on(bool reset) { /* Enable main power */ IO_GIO_BITSET2 |= (1 << 3); /* power on sequence as per the ZVM firmware */ sleep_ms(250); IO_GIO_BITSET1 = (1 << 13); sleep_ms(5); IO_GIO_BITSET2 = (1 << 5); IO_GIO_BITSET2 = (1 << 8); sleep_ms(1); /*Init SPI here... */ sleep_ms(32); IO_GIO_BITSET2 = (1 << 0); sleep_ms(5); IO_GIO_BITSET2 = (1 << 7); sleep_ms(5); IO_GIO_BITSET2 = (1 << 4); sleep_ms(5); IO_GIO_BITCLR2 = (1 << 8); /*TODO: figure out what OF does after this... */ IO_GIO_BITSET2 = (1 << 8); sleep_ms(1); lcd_write_reg(LTV_IFCTL, LTV_NL(29)); lcd_write_reg(LTV_DATACTL, 0); lcd_write_reg(LTV_ENTRY_MODE,0); lcd_write_reg(LTV_GATECTL1, 0); lcd_write_reg(LTV_GATECTL2, (LTV_NW_INV_1LINE | LTV_FHN | LTV_FTI(2) | LTV_FWI(3))); lcd_write_reg(LTV_VBP, 0); lcd_write_reg(LTV_HBP, 0); lcd_write_reg(LTV_SOTCTL, 0); lcd_write_reg(LTV_PWRCTL1, 0); lcd_write_reg(LTV_PWRCTL2, 0); lcd_write_reg(LTV_GAMMA(0), 0); lcd_write_reg(LTV_GAMMA(1), 0); lcd_write_reg(LTV_GAMMA(2), 0); lcd_write_reg(LTV_GAMMA(3), 0); lcd_write_reg(LTV_GAMMA(4), 0); lcd_write_reg(LTV_GAMMA(5), 0); lcd_write_reg(LTV_GAMMA(6), 0); lcd_write_reg(LTV_GAMMA(7), 0); lcd_write_reg(LTV_GAMMA(8), 0); lcd_write_reg(LTV_GAMMA(9), 0); sleep_ms(10); lcd_write_reg(LTV_PWRCTL1, (LTV_VCOM_DISABLE | LTV_DRIVE_CURRENT(5) | LTV_SUPPLY_CURRENT(5))); lcd_write_reg(LTV_PWRCTL2, 0); sleep_ms(40); lcd_write_reg(LTV_PWRCTL2, LTV_VCOML_ENABLE); sleep_ms(40); lcd_write_reg(LTV_IFCTL, (LTV_NMD | LTV_NL(29))); lcd_write_reg(LTV_DATACTL, (LTV_DS_SAME | LTV_CHS_480 | LTV_DF_RGB | LTV_RGB_BGR)); lcd_write_reg(LTV_ENTRY_MODE,(LTV_VSPL_ACTIVE_LOW | LTV_HSPL_ACTIVE_LOW | LTV_DPL_SAMPLE_RISING | LTV_EPL_ACTIVE_LOW | LTV_SS_RIGHT_TO_LEFT)); lcd_write_reg(LTV_GATECTL1, LTV_CLW(1)); lcd_write_reg(LTV_GATECTL2, (LTV_NW_INV_1LINE | LTV_DSC | LTV_FTI(3) | LTV_FWI(3))); lcd_write_reg(LTV_VBP, 0x5); lcd_write_reg(LTV_HBP, 0x1B); lcd_write_reg(LTV_SOTCTL, LTV_SDT(2)); lcd_write_reg(LTV_GAMMA(0), 0x203); lcd_write_reg(LTV_GAMMA(1), 0x302); lcd_write_reg(LTV_GAMMA(2), 0xC08); lcd_write_reg(LTV_GAMMA(3), 0xC08); lcd_write_reg(LTV_GAMMA(4), 0x707); lcd_write_reg(LTV_GAMMA(5), 0x707); lcd_write_reg(LTV_GAMMA(6), 0x104); lcd_write_reg(LTV_GAMMA(7), 0x306); lcd_write_reg(LTV_GAMMA(8), 0); lcd_write_reg(LTV_GAMMA(9), 0); sleep_ms(60); lcd_write_reg(LTV_PWRCTL1, (LTV_VCOMOUT_ENABLE | LTV_POWER_ON | LTV_DRIVE_CURRENT(5) | LTV_SUPPLY_CURRENT(5))); lcd_write_reg(LTV_PWRCTL2, (LTV_VCOML_VOLTAGE(17) | LTV_VCOMH_VOLTAGE(26))); /* VCOML=0,0625V VCOMH=1,21875V */ sleep_ms(10); if(!reset) { enable_venc(true); /* Re-enable video encoder */ IO_VID_ENC_VMOD |= VENC_VMOD_VENC; } /* tell that we're on now */ lcd_on = true; }