Skip to content

Commit

Permalink
correct C & indendt
Browse files Browse the repository at this point in the history
u know me
  • Loading branch information
Apaczer committed Nov 18, 2023
1 parent d412504 commit 4df77a8
Showing 1 changed file with 91 additions and 95 deletions.
186 changes: 91 additions & 95 deletions drivers/video/sunxi/sunxi_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -2241,108 +2241,104 @@ static enum sunxi_monitor sunxi_get_default_mon(bool allow_hdmi)

void load_bmp_logo(void)
{
bmp = (struct bmp_image *)map_sysmem(0x80000000, 0);
if (!bmp || !(bmp->header.signature[0] == 'B' &&
bmp->header.signature[1] == 'M')) {
bmp_logo = 1;
return;
}
width = get_unaligned_le32(&bmp->header.width);
height = get_unaligned_le32(&bmp->header.height);
bmp_bpix = get_unaligned_le16(&bmp->header.bit_count);
file_size = get_unaligned_le32(&bmp->header.file_size);
data_offset = file_size / 2 - width * height;
image_size = file_size / 2 - data_offset;

if (bmp_bpix != 16){
bmp_logo = 1;
return;
}
p = (uint16_t*) bmp;
cnt = image_size;
bmp = (struct bmp_image *)map_sysmem(0x80000000, 0);
if (!bmp || !(bmp->header.signature[0] == 'B' && bmp->header.signature[1] == 'M')) {
bmp_logo = 1;
return;
}
width = get_unaligned_le32(&bmp->header.width);
height = get_unaligned_le32(&bmp->header.height);
bmp_bpix = get_unaligned_le16(&bmp->header.bit_count);
file_size = get_unaligned_le32(&bmp->header.file_size);
data_offset = file_size / 2 - width * height;
image_size = file_size / 2 - data_offset;

if (bmp_bpix != 16) {
bmp_logo = 1;
return;
}
p = (uint16_t*) bmp;
cnt = image_size;
}

static void setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1,
uint16_t y1) {

uint16_t x_start = x0, x_end = x1;
uint16_t y_start = y0, y_end = y1;
lcd_wr_cmd(0x2a); // Column addr set
lcd_wr_dat(x_start >> 8);
lcd_wr_dat(x_start & 0xFF); // XSTART
lcd_wr_dat(x_end >> 8);
lcd_wr_dat(x_end & 0xFF); // XEND

lcd_wr_cmd(0x2b); // Row addr set
lcd_wr_dat(y_start >> 8);
lcd_wr_dat(y_start & 0xFF); // YSTART
lcd_wr_dat(y_end >> 8);
lcd_wr_dat(y_end & 0xFF); // YEND
lcd_wr_cmd(writeScreenReg); // write to RAM
static void setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
uint16_t x_start = x0, x_end = x1;
uint16_t y_start = y0, y_end = y1;
lcd_wr_cmd(0x2a); // Column addr set
lcd_wr_dat(x_start >> 8);
lcd_wr_dat(x_start & 0xFF); // XSTART
lcd_wr_dat(x_end >> 8);
lcd_wr_dat(x_end & 0xFF); // XEND

lcd_wr_cmd(0x2b); // Row addr set
lcd_wr_dat(y_start >> 8);
lcd_wr_dat(y_start & 0xFF); // YSTART
lcd_wr_dat(y_end >> 8);
lcd_wr_dat(y_end & 0xFF); // YEND
lcd_wr_cmd(writeScreenReg); // write to RAM
}

static void lcd_draw_char(uint16_t x, uint16_t y, uint8_t* start) {
uint16_t xpos = 0;
uint16_t ypos = 0;
if(font->type == 0) {
uint16_t byte_num = font->char_w * font->char_h / 8;
for(uint16_t byte_cnt = 0; byte_cnt < byte_num; byte_cnt++) {
for(uint8_t bit_cnt = 0; bit_cnt < 8; bit_cnt++) {
if((start[byte_cnt] << bit_cnt) & 0x80) {
setAddrWindow(x + xpos, y + ypos, x + xpos + 1, y + ypos + 1);
lcd_wr_dat(text_color & 0xFFFF);
}
else {
setAddrWindow(x + xpos, y + ypos, x + xpos + 1, y + ypos + 1);
lcd_wr_dat(bg_color & 0xFFFF);
}
if((++xpos) >= font->char_w) {
xpos = 0;
ypos++;
}
}
}
}
uint16_t xpos = 0;
uint16_t ypos = 0;
if (font->type == 0) {
uint16_t byte_num = font->char_w * font->char_h / 8;
for (uint16_t byte_cnt = 0; byte_cnt < byte_num; byte_cnt++) {
for (uint8_t bit_cnt = 0; bit_cnt < 8; bit_cnt++) {
if ((start[byte_cnt] << bit_cnt) & 0x80) {
setAddrWindow(x + xpos, y + ypos, x + xpos + 1, y + ypos + 1);
lcd_wr_dat(text_color & 0xFFFF);
} else {
setAddrWindow(x + xpos, y + ypos, x + xpos + 1, y + ypos + 1);
lcd_wr_dat(bg_color & 0xFFFF);
}
if ((++xpos) >= font->char_w) {
xpos = 0;
ypos++;
}
}
}
}
}

void lcd_putchar(char chr) {
uint16_t cur_X = text_x;
uint16_t cur_Y = text_y;
if(chr == '\n') {
uint16_t cur_X = text_x;
uint16_t cur_Y = text_y;
if (chr == '\n') {
#ifdef SAVE_X_OFFSET
text_x = text_x_start;
text_x = text_x_start;
#else
text_x = 0;
text_x = 0;
#endif
text_y += font->char_h;
chr = 0;
} else {
text_x += font->char_w;
if(text_x > (DISPLAY_W - font->char_w)) {
text_y += font->char_h;
chr = 0;
} else {
text_x += font->char_w;
if (text_x > (DISPLAY_W - font->char_w)) {
#ifdef SAVE_X_OFFSET
text_x = text_x_start;
text_x = text_x_start;
#else
text_x = 0;
text_x = 0;
#endif
text_y += font->char_h;
}
}
if(text_y > (DISPLAY_H - font->char_h)) text_y = 0;
if(chr < font->offset) chr = font->offset;
uint8_t* chardata = NULL;
if(font->type == 0) {
if(chr < font->offset) chr = font->offset;
chardata = (uint8_t*)&(font->data[(font->char_w * font->char_h / 8) * (chr - font->offset)]);
}
lcd_draw_char(cur_X, cur_Y, chardata);
text_y += font->char_h;
}
}
if (text_y > (DISPLAY_H - font->char_h)) text_y = 0;
if (chr < font->offset) chr = font->offset;
uint8_t* chardata = NULL;
if (font->type == 0) {
if (chr < font->offset) chr = font->offset;
chardata = (uint8_t*)&(font->data[(font->char_w * font->char_h / 8) * (chr - font->offset)]);
}
lcd_draw_char(cur_X, cur_Y, chardata);
}

static void lcd_set_font(const lcd_font_t* fnt) {
font = (lcd_font_t*)fnt;
font = (lcd_font_t*)fnt;
}

void lcd_print(char* str) {
while(*str) lcd_putchar(*str++);
while (*str) lcd_putchar(*str++);
}

void *video_hw_init(void)
Expand Down Expand Up @@ -2499,14 +2495,14 @@ void *video_hw_init(void)
graphic_device->winSizeY = mode->yres - 2 * overscan_y;
graphic_device->plnSizeX = mode->xres * graphic_device->gdfBytesPP;

sunxi_lcdc_gpio_config();
lcd_init();
sunxi_lcdc_gpio_config();
lcd_init();

uint16_t bug=3;
bmp_logo = run_command("load mmc 0:1 0x80000000 miyoo-boot.bmp", 0);
if (bmp_logo == 0){
load_bmp_logo();
}
uint16_t bug=3;
bmp_logo = run_command("load mmc 0:1 0x80000000 miyoo-boot.bmp", 0);
if (bmp_logo == 0) {
load_bmp_logo();
}

while (bug--) {
uint16_t x, y;
Expand All @@ -2529,12 +2525,12 @@ void *video_hw_init(void)
}
}
}
console_variant = env_get("DETECTED_VERSION");
if (console_variant && miyoo_ver <= 4) { // panel ver 5 and 6 have different row/col registers
lcd_set_font(&t_8x16_full);
lcd_print("Detected device: ");
lcd_print(console_variant);
}
console_variant = env_get("DETECTED_VERSION");
if (console_variant && miyoo_ver <= 4) { // panel ver 5 and 6 have different row/col registers
lcd_set_font(&t_8x16_full);
lcd_print("Detected device: ");
lcd_print(console_variant);
}

if (miyoo_ver != 3)
lcd_wr_cmd(writeScreenReg);
Expand Down

0 comments on commit 4df77a8

Please sign in to comment.