Moar optimizations

This commit is contained in:
Jeroen Domburg 2017-05-30 00:57:59 +08:00
parent 31c98d83b7
commit 8876dde0f4
3 changed files with 26 additions and 18 deletions

View File

@ -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;

View File

@ -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

View File

@ -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;