[DP/GFX/SDMMC] Bugfixes

- Sanitize framebuffer. Original idea from @StevenMattera
- Change clear framebuffer to memset (for grey colors), for performance (we don't use alpha blending, so it does not matter to set it to 0xFF).
- Enable screen backlight after gfx init
- Reduce wait time for emmc/sd read/write retries to 100ms.
This commit is contained in:
Kostas Missos 2018-06-06 13:29:38 +03:00
parent b299cb40c7
commit 16ac26f583
8 changed files with 43 additions and 21 deletions

View file

@ -14,6 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <string.h>
#include "di.h" #include "di.h"
#include "t210.h" #include "t210.h"
#include "util.h" #include "util.h"
@ -131,9 +133,14 @@ void display_init()
exec_cfg((u32 *)DISPLAY_A_BASE, _display_config_11, 113); exec_cfg((u32 *)DISPLAY_A_BASE, _display_config_11, 113);
} }
void display_backlight(u8 enable)
{
GPIO_6(0x24) = (GPIO_6(0x24) & 0xFFFFFFFE) | (enable & 1);
}
void display_end() void display_end()
{ {
GPIO_6(0x24) &= 0xFFFFFFFE; display_backlight(0);
DSI(_DSIREG(DSI_VIDEO_MODE_CONTROL)) = 1; DSI(_DSIREG(DSI_VIDEO_MODE_CONTROL)) = 1;
DSI(_DSIREG(DSI_WR_DATA)) = 0x2805; DSI(_DSIREG(DSI_WR_DATA)) = 0x2805;
@ -197,17 +204,20 @@ void display_color_screen(u32 color)
sleep(35000); sleep(35000);
GPIO_6(0x24) = GPIO_6(0x24) & 0xFFFFFFFE | 1; display_backlight(1);
} }
u32 *display_init_framebuffer(u32 *fb) u32 *display_init_framebuffer(u32 *fb)
{ {
//Sanitize framebuffer area. Aligned to 4MB.
memset((u32 *)0xC0000000, 0, 0x400000);
//This configures the framebuffer @ 0xC0000000 with a resolution of 1280x720 (line stride 768). //This configures the framebuffer @ 0xC0000000 with a resolution of 1280x720 (line stride 768).
exec_cfg((u32 *)DISPLAY_A_BASE, cfg_display_framebuffer, 32); exec_cfg((u32 *)DISPLAY_A_BASE, cfg_display_framebuffer, 32);
sleep(35000); sleep(35000);
GPIO_6(0x24) = GPIO_6(0x24) & 0xFFFFFFFE | 1; //Enable backlight
//display_backlight(1);
return (u32 *)0xC0000000; return (u32 *)0xC0000000;
} }

View file

@ -341,6 +341,9 @@ void display_end();
/*! Show one single color on the display. */ /*! Show one single color on the display. */
void display_color_screen(u32 color); void display_color_screen(u32 color);
/*! Switches screen backlight ON/OFF. */
void display_backlight(u8 enable);
/*! Init display in full 1280x720 resolution (32bpp, line stride 768, framebuffer size = 1280*768*4 bytes). */ /*! Init display in full 1280x720 resolution (32bpp, line stride 768, framebuffer size = 1280*768*4 bytes). */
u32 *display_init_framebuffer(); u32 *display_init_framebuffer();

View file

@ -15,6 +15,7 @@
*/ */
#include <stdarg.h> #include <stdarg.h>
#include <string.h>
#include "gfx.h" #include "gfx.h"
static const u8 _gfx_font[] = { static const u8 _gfx_font[] = {
@ -76,7 +77,12 @@ void gfx_init_ctxt(gfx_ctxt_t *ctxt, u32 *fb, u32 width, u32 height, u32 stride)
ctxt->stride = stride; ctxt->stride = stride;
} }
void gfx_clear(gfx_ctxt_t *ctxt, u32 color) void gfx_clear_grey(gfx_ctxt_t *ctxt, u8 color)
{
memset(ctxt->fb, color, 0x400000);
}
void gfx_clear_color(gfx_ctxt_t *ctxt, u32 color)
{ {
for (u32 i = 0; i < ctxt->height * ctxt->stride; i++) for (u32 i = 0; i < ctxt->height * ctxt->stride; i++)
ctxt->fb[i] = color; ctxt->fb[i] = color;

View file

@ -38,7 +38,8 @@ typedef struct _gfx_con_t
} gfx_con_t; } gfx_con_t;
void gfx_init_ctxt(gfx_ctxt_t *ctxt, u32 *fb, u32 width, u32 height, u32 stride); void gfx_init_ctxt(gfx_ctxt_t *ctxt, u32 *fb, u32 width, u32 height, u32 stride);
void gfx_clear(gfx_ctxt_t *ctxt, u32 color); void gfx_clear_grey(gfx_ctxt_t *ctxt, u8 color);
void gfx_clear_color(gfx_ctxt_t *ctxt, u32 color);
void gfx_con_init(gfx_con_t *con, gfx_ctxt_t *ctxt); void gfx_con_init(gfx_con_t *con, gfx_ctxt_t *ctxt);
void gfx_con_setcol(gfx_con_t *con, u32 fgcol, int fillbg, u32 bgcol); void gfx_con_setcol(gfx_con_t *con, u32 fgcol, int fillbg, u32 bgcol);
void gfx_con_getpos(gfx_con_t *con, u32 *x, u32 *y); void gfx_con_getpos(gfx_con_t *con, u32 *x, u32 *y);

View file

@ -394,7 +394,7 @@ int hos_launch(ini_sec_t *cfg)
memset(&ctxt, 0, sizeof(launch_ctxt_t)); memset(&ctxt, 0, sizeof(launch_ctxt_t));
list_init(&ctxt.kip1_list); list_init(&ctxt.kip1_list);
gfx_clear(&gfx_ctxt, 0xFF1B1B1B); gfx_clear_grey(&gfx_ctxt, 0x1B);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
if (cfg && !_config(&ctxt, cfg)) if (cfg && !_config(&ctxt, cfg))

View file

@ -336,7 +336,7 @@ void config_hw()
void print_fuseinfo() void print_fuseinfo()
{ {
gfx_clear(&gfx_ctxt, 0xFF1B1B1B); gfx_clear_grey(&gfx_ctxt, 0x1B);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
gfx_printf(&gfx_con, "%k(Unlocked) fuse cache:\n\n%k", 0xFFFFDD00, 0xFFCCCCCC); gfx_printf(&gfx_con, "%k(Unlocked) fuse cache:\n\n%k", 0xFFFFDD00, 0xFFCCCCCC);
@ -365,7 +365,7 @@ void print_fuseinfo()
void print_kfuseinfo() void print_kfuseinfo()
{ {
gfx_clear(&gfx_ctxt, 0xFF1B1B1B); gfx_clear_grey(&gfx_ctxt, 0x1B);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
gfx_printf(&gfx_con, "%kKFuse contents:\n\n%k", 0xFFFFDD00, 0xFFCCCCCC); gfx_printf(&gfx_con, "%kKFuse contents:\n\n%k", 0xFFFFDD00, 0xFFCCCCCC);
@ -398,7 +398,7 @@ void print_kfuseinfo()
void print_mmc_info() void print_mmc_info()
{ {
gfx_clear(&gfx_ctxt, 0xFF1B1B1B); gfx_clear_grey(&gfx_ctxt, 0x1B);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
static const u32 SECTORS_TO_MIB_COEFF = 11; static const u32 SECTORS_TO_MIB_COEFF = 11;
@ -541,7 +541,7 @@ out:
void print_sdcard_info() void print_sdcard_info()
{ {
gfx_clear(&gfx_ctxt, 0xFF1B1B1B); gfx_clear_grey(&gfx_ctxt, 0x1B);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
static const u32 SECTORS_TO_MIB_COEFF = 11; static const u32 SECTORS_TO_MIB_COEFF = 11;
@ -592,7 +592,7 @@ void print_sdcard_info()
void print_tsec_key() void print_tsec_key()
{ {
gfx_clear(&gfx_ctxt, 0xFF1B1B1B); gfx_clear_grey(&gfx_ctxt, 0x1B);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
sdmmc_storage_t storage; sdmmc_storage_t storage;
@ -1014,7 +1014,7 @@ static void dump_emmc_selected(dumpType_t dumpType)
{ {
int res = 0; int res = 0;
u32 timer = 0; u32 timer = 0;
gfx_clear(&gfx_ctxt, 0xFF1B1B1B); gfx_clear_grey(&gfx_ctxt, 0x1B);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
if (!sd_mount()) if (!sd_mount())
@ -1123,7 +1123,7 @@ void dump_package1()
memset(secmon, 0, 0x40000); memset(secmon, 0, 0x40000);
memset(loader, 0, 0x40000); memset(loader, 0, 0x40000);
gfx_clear(&gfx_ctxt, 0xFF1B1B1B); gfx_clear_grey(&gfx_ctxt, 0x1B);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
if (!sd_mount()) if (!sd_mount())
@ -1216,7 +1216,7 @@ void launch_firmware()
ini_sec_t *cfg_sec = NULL; ini_sec_t *cfg_sec = NULL;
LIST_INIT(ini_sections); LIST_INIT(ini_sections);
gfx_clear(&gfx_ctxt, 0xFF1B1B1B); gfx_clear_grey(&gfx_ctxt, 0x1B);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
if (sd_mount()) if (sd_mount())
@ -1257,8 +1257,8 @@ void launch_firmware()
if (!cfg_sec) if (!cfg_sec)
{ {
gfx_printf(&gfx_con, "\nUsing default launch configuration...\n");
sleep(3000000); sleep(3000000);
gfx_printf(&gfx_con, "Using default launch configuration...\n");
} }
if (!hos_launch(cfg_sec)) if (!hos_launch(cfg_sec))
@ -1328,7 +1328,7 @@ void about()
" (/` ( (` ) ) '-; %k[switchbrew]%k\n" " (/` ( (` ) ) '-; %k[switchbrew]%k\n"
" ` '-; (-'%k"; " ` '-; (-'%k";
gfx_clear(&gfx_ctxt, 0xFF1B1B1B); gfx_clear_grey(&gfx_ctxt, 0x1B);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
gfx_printf(&gfx_con, octopus, 0xFFFFCC00, 0xFFCCCCCC, gfx_printf(&gfx_con, octopus, 0xFFFFCC00, 0xFFCCCCCC,
@ -1435,9 +1435,12 @@ void ipl_main()
//display_color_screen(0xAABBCCDD); //display_color_screen(0xAABBCCDD);
u32 *fb = display_init_framebuffer(); u32 *fb = display_init_framebuffer();
gfx_init_ctxt(&gfx_ctxt, fb, 720, 1280, 768); gfx_init_ctxt(&gfx_ctxt, fb, 720, 1280, 768);
gfx_clear(&gfx_ctxt, 0xFF1B1B1B); gfx_clear_grey(&gfx_ctxt, 0x1B);
gfx_con_init(&gfx_con, &gfx_ctxt); gfx_con_init(&gfx_con, &gfx_ctxt);
//Enable backlight after initializing gfx
display_backlight(1);
while (1) while (1)
tui_do_menu(&gfx_con, &menu_top); tui_do_menu(&gfx_con, &menu_top);

View file

@ -174,8 +174,7 @@ static int _sdmmc_storage_readwrite(sdmmc_storage_t *storage, u32 sector, u32 nu
else else
retries--; retries--;
sleep(500000); sleep(100000);
} while (retries); } while (retries);
return 0; return 0;

View file

@ -43,7 +43,7 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu)
int idx = 0, cnt; int idx = 0, cnt;
int prev_idx = 0; int prev_idx = 0;
gfx_clear(con->gfx_ctxt, 0xFF1B1B1B); gfx_clear_grey(con->gfx_ctxt, 0x1B);
while (1) while (1)
{ {
@ -124,7 +124,7 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu)
default: default:
break; break;
} }
gfx_clear(con->gfx_ctxt, 0xFF1B1B1B); gfx_clear_grey(con->gfx_ctxt, 0x1B);
} }
} }