diff --git a/components/mipidisp/mipi.c b/components/mipidisp/mipi.c index 504d3d0..31bfef5 100644 --- a/components/mipidisp/mipi.c +++ b/components/mipidisp/mipi.c @@ -120,10 +120,6 @@ Brings up the clock and data lines to LP11, resyncs the flipflop, restarts the c */ void mipiResync() { //Get clock and data transceivers back in idle state -// gpio_set_level(GPIO_D0N_LS, 1); -// SOTEOTWAIT(); -// gpio_set_level(GPIO_D0P_LS, 1); - gpio_set_level(GPIO_CLKN_LS, 1); SOTEOTWAIT(); gpio_set_level(GPIO_CLKP_LS, 1); @@ -157,13 +153,8 @@ void mipiResync() { spidev->dma_out_link.start=1; spidev->user.usr_mosi=1; spidev->cmd.usr=1; - - //Data pair is in LP11 now. We should go LP01, LP00 to enable HS receivers -// gpio_set_level(GPIO_D0P_LS, 0); -// SOTEOTWAIT(); -// gpio_set_level(GPIO_D0N_LS, 0); - } + void mipiInit() { esp_err_t ret; bool io_native=false; diff --git a/components/mipidisp/mipi_dsi.c b/components/mipidisp/mipi_dsi.c index d1b56a6..abe3066 100644 --- a/components/mipidisp/mipi_dsi.c +++ b/components/mipidisp/mipi_dsi.c @@ -6,6 +6,8 @@ #include "crc16-ccitt.h" #include "mipi.h" +#define NO_CRC 1 + //Reminder; MIPI is very LSB-first. typedef struct { uint8_t sot; //should be 0xB8 @@ -67,7 +69,11 @@ void mipiDsiSendLong(int type, uint8_t *data, int len) { p.datatype=type; p.wordcount=mipiword(len); p.ecc=calc_ecc((uint8_t*)&p.datatype); +#if NO_CRC + int crc=0; +#else int crc=crc16_ccitt(0xFFFF, data, len); +#endif footer[0]=(crc&0xff); footer[1]=(crc>>8); footer[2]=(crc&0x8000)?0:0xff; //need one last level transition at end diff --git a/components/tme-esp32/mipi_lcd.c b/components/tme-esp32/mipi_lcd.c index 94a4486..6f66bf0 100644 --- a/components/tme-esp32/mipi_lcd.c +++ b/components/tme-esp32/mipi_lcd.c @@ -66,6 +66,19 @@ const DispPacket initPackets[]={ {0,0,0,{0}} }; + + + +#define SCALE_FACT 51 //Floating-point number, actually x/32. Divide mac reso by this to get lcd reso. + + +static uint8_t mask[512]; + +static void calcLut() { + for (int i=0; i<512; i++) mask[i]=(1<<(7-(i&7))); +} + + //Returns 0-1024 int findMacVal(uint8_t *data, int x, int y) { int a,b,c,d; @@ -75,14 +88,14 @@ int findMacVal(uint8_t *data, int x, int y) { if (ry>=342) return 0; - a=data[ry*(512/8)+rx/8]&(1<<(7-(rx&7))); + a=data[ry*(512/8)+rx/8]&mask[rx]; rx++; - b=data[ry*(512/8)+rx/8]&(1<<(7-(rx&7))); + b=data[ry*(512/8)+rx/8]&mask[rx]; rx--; ry++; if (ry<342) { - c=data[ry*(512/8)+rx/8]&(1<<(7-(rx&7))); + c=data[ry*(512/8)+rx/8]&mask[rx]; rx++; - d=data[ry*(512/8)+rx/8]&(1<<(7-(rx&7))); + d=data[ry*(512/8)+rx/8]&mask[rx]; } else { c=1; d=1; @@ -109,8 +122,6 @@ int findMacVal(uint8_t *data, int x, int y) { // // Due to the weird buildup, a horizontal subpixel actually is 1/3rd real pixel wide! -#define SCALE_FACT 51 //Floating-point number, actually x/32. Divide mac reso by this to get lcd reso. - int findPixelVal(uint8_t *data, int x, int y) { int sx=(x*SCALE_FACT); //32th is 512/320 -> scale 512 mac screen to 320 width int sy=(y*SCALE_FACT); @@ -134,7 +145,7 @@ int findPixelVal(uint8_t *data, int x, int y) { volatile static uint8_t *currFbPtr=NULL; SemaphoreHandle_t dispSem = NULL; -#define LINESPERBUF 1 +#define LINESPERBUF 8 static void initLcd() { mipiInit(); @@ -160,7 +171,7 @@ static void initLcd() { void IRAM_ATTR displayTask(void *arg) { uint8_t *img=malloc((LINESPERBUF*320*2)+1); assert(img); - + calcLut(); while(1) { int l=0;