kopia lustrzana https://github.com/hoglet67/RGBtoHDMI
Pi Firmware: experiments with an OSD
Change-Id: Id3919c5bba5894132a15b8012eb45c4100b34055issue_1022
rodzic
b74f86964c
commit
0c8fc0a4b5
|
@ -85,6 +85,8 @@ file( GLOB core_files
|
|||
cpld_normal.c
|
||||
cpld_alternative.h
|
||||
cpld_alternative.c
|
||||
osd.h
|
||||
osd.c
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#define BIT_CAL_COUNT 0x40
|
||||
#define BIT_INITIALIZE 0x80
|
||||
#define BIT_FIELD_TYPE 0x100
|
||||
#define BIT_CLEAR 0x200
|
||||
|
||||
// R0 return value bits
|
||||
#define RET_SW1 0x02
|
||||
|
|
|
@ -0,0 +1,240 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include "osd.h"
|
||||
#include "rpi-mailbox-interface.h"
|
||||
|
||||
uint8_t fontdata[] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x02, 0x1a, 0x26, 0x26, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x22, 0x3e, 0x22, 0x22, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3c, 0x12, 0x12, 0x1c, 0x12, 0x12, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x20, 0x20, 0x20, 0x22, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3c, 0x12, 0x12, 0x12, 0x12, 0x12, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3e, 0x20, 0x20, 0x38, 0x20, 0x20, 0x3e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3e, 0x20, 0x20, 0x38, 0x20, 0x20, 0x20, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x20, 0x20, 0x26, 0x22, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x3e, 0x22, 0x22, 0x22, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x22, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x22, 0x24, 0x28, 0x30, 0x28, 0x24, 0x22, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x22, 0x36, 0x2a, 0x2a, 0x22, 0x22, 0x22, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x22, 0x22, 0x32, 0x2a, 0x26, 0x22, 0x22, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3c, 0x22, 0x22, 0x3c, 0x20, 0x20, 0x20, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x2a, 0x24, 0x1a, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3c, 0x22, 0x22, 0x3c, 0x28, 0x24, 0x22, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x20, 0x1c, 0x02, 0x22, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x2a, 0x36, 0x22, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x22, 0x22, 0x14, 0x08, 0x14, 0x22, 0x22, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x22, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3e, 0x02, 0x04, 0x08, 0x10, 0x20, 0x3e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x1c, 0x2a, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x3e, 0x10, 0x08, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x14, 0x14, 0x3e, 0x14, 0x3e, 0x14, 0x14, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x1e, 0x28, 0x1c, 0x0a, 0x3c, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x30, 0x32, 0x04, 0x08, 0x10, 0x26, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x10, 0x28, 0x28, 0x10, 0x2a, 0x24, 0x1a, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x04, 0x08, 0x10, 0x10, 0x10, 0x08, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x10, 0x08, 0x04, 0x04, 0x04, 0x08, 0x10, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x08, 0x2a, 0x1c, 0x1c, 0x2a, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x3e, 0x08, 0x08, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x20, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x26, 0x2a, 0x32, 0x22, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x18, 0x08, 0x08, 0x08, 0x08, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x02, 0x1c, 0x20, 0x20, 0x3e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x02, 0x04, 0x02, 0x22, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x04, 0x0c, 0x14, 0x24, 0x3e, 0x04, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3e, 0x20, 0x3c, 0x02, 0x02, 0x22, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x20, 0x20, 0x3c, 0x22, 0x22, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3e, 0x02, 0x04, 0x08, 0x10, 0x20, 0x20, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x22, 0x1c, 0x22, 0x22, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x22, 0x1e, 0x02, 0x02, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x08, 0x10, 0x00,
|
||||
0x00, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x02, 0x04, 0x08, 0x00, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x14, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x02, 0x1e, 0x22, 0x1e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x20, 0x20, 0x2c, 0x32, 0x22, 0x32, 0x2c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x22, 0x20, 0x22, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x02, 0x02, 0x1a, 0x26, 0x22, 0x26, 0x1a, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x22, 0x3e, 0x20, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x04, 0x0a, 0x08, 0x1c, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x26, 0x22, 0x26, 0x1a, 0x02, 0x1c,
|
||||
0x00, 0x00, 0x00, 0x20, 0x20, 0x2c, 0x32, 0x22, 0x22, 0x22, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x00, 0x18, 0x08, 0x08, 0x08, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x22, 0x1c, 0x00,
|
||||
0x00, 0x00, 0x00, 0x20, 0x20, 0x24, 0x28, 0x30, 0x28, 0x24, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x2a, 0x2a, 0x2a, 0x2a, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x32, 0x22, 0x22, 0x22, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x1c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x22, 0x22, 0x22, 0x3c, 0x20, 0x20,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x22, 0x22, 0x22, 0x1e, 0x02, 0x02,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x32, 0x20, 0x20, 0x20, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x20, 0x1c, 0x02, 0x3c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x10, 0x10, 0x38, 0x10, 0x10, 0x12, 0x0c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x26, 0x1a, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x14, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x2a, 0x2a, 0x14, 0x14, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x14, 0x08, 0x14, 0x22, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x1e, 0x02, 0x1c, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x04, 0x08, 0x10, 0x3e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x04, 0x08, 0x08, 0x10, 0x08, 0x08, 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x00, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x10, 0x08, 0x08, 0x04, 0x08, 0x08, 0x10, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x10, 0x2a, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x08, 0x1c, 0x20, 0x20, 0x20, 0x1c, 0x08, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0c, 0x12, 0x10, 0x38, 0x10, 0x10, 0x3e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x1c, 0x14, 0x1c, 0x22, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x22, 0x14, 0x08, 0x3e, 0x08, 0x3e, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x00, 0x08, 0x08, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x20, 0x1c, 0x22, 0x1c, 0x02, 0x1c, 0x00, 0x00,
|
||||
0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3e, 0x41, 0x5d, 0x51, 0x51, 0x5d, 0x41, 0x3e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x02, 0x1e, 0x22, 0x1e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x0a, 0x14, 0x28, 0x14, 0x0a, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x02, 0x02, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3e, 0x41, 0x5d, 0x55, 0x59, 0x55, 0x41, 0x3e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x10, 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x08, 0x08, 0x3e, 0x08, 0x08, 0x00, 0x3e, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x18, 0x04, 0x08, 0x10, 0x1c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x18, 0x04, 0x18, 0x04, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x12, 0x12, 0x12, 0x1c, 0x10, 0x20,
|
||||
0x00, 0x00, 0x00, 0x1a, 0x2a, 0x2a, 0x1a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x18,
|
||||
0x00, 0x00, 0x00, 0x08, 0x18, 0x08, 0x08, 0x1c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1c, 0x22, 0x22, 0x22, 0x1c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x28, 0x14, 0x0a, 0x14, 0x28, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x22, 0x06, 0x0e, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x2e, 0x02, 0x04, 0x0e, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x70, 0x10, 0x70, 0x12, 0x76, 0x0e, 0x02, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x08, 0x10, 0x12, 0x0c, 0x00, 0x00
|
||||
};
|
||||
|
||||
|
||||
static char buffer[30];
|
||||
|
||||
static uint32_t mapping_table0[256];
|
||||
static uint32_t mapping_table1[256];
|
||||
|
||||
static int active = 0;
|
||||
|
||||
void osd_init() {
|
||||
// Precalculate character->screen mapping table
|
||||
// char bit 0 -> mapping_table1 bits 31, 27
|
||||
// ...
|
||||
// char bit 3 -> mapping_table1 bits 7, 3
|
||||
// char bit 4 -> mapping_table0 bits 31, 27
|
||||
// ...
|
||||
// char bit 7 -> mapping_table0 bits 7, 3
|
||||
for (int i = 0; i < 256; i++) {
|
||||
mapping_table0[i] = 0;
|
||||
mapping_table1[i] = 0;
|
||||
for (int j = 0; j < 8; j++) {
|
||||
if (i & (1 << j)) {
|
||||
if (j < 4) {
|
||||
mapping_table1[i] |= 0x88 << (8 * (3 - j));
|
||||
} else {
|
||||
mapping_table0[i] |= 0x88 << (8 * (7 - j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void osd_clear() {
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
active = 0;
|
||||
RPI_PropertyInit();
|
||||
RPI_PropertyAddTag( TAG_SET_PALETTE );
|
||||
RPI_PropertyProcess();
|
||||
}
|
||||
|
||||
void osd_set(char *text) {
|
||||
osd_clear();
|
||||
strcpy(buffer, text);
|
||||
active = 1;
|
||||
RPI_PropertyInit();
|
||||
RPI_PropertyAddTag( TAG_SET_PALETTE );
|
||||
RPI_PropertyProcess();
|
||||
}
|
||||
|
||||
|
||||
int osd_active() {
|
||||
return active;
|
||||
}
|
||||
|
||||
void osd_update(uint32_t *osd_base, int bytes_per_line) {
|
||||
// The character data is 8x12 cells (actually from the 6847!)
|
||||
// each character pixel gets mapped to 2x2 display pixels
|
||||
// this gives a effective resolution of 320x256 in Mode0..7 and 240x256 in Mode0
|
||||
uint32_t *line_ptr = osd_base;
|
||||
int words_per_line = bytes_per_line >> 2;
|
||||
for (int y = 0; y < 12; y++) {
|
||||
uint32_t *word_ptr = line_ptr;
|
||||
for (int i = 0; i < sizeof(buffer); i++) {
|
||||
int c = buffer[i];
|
||||
// Deal with unprintable characters
|
||||
if (c < 32 || c > 127) {
|
||||
c = 32;
|
||||
}
|
||||
|
||||
// Convert c to index into 6847 character generator ROM
|
||||
// chars 20-3F map to 20-3F
|
||||
// chars 40-5F map to 00-1F
|
||||
// chars 60-7F map to 40-5F
|
||||
int invert = c >= 0x80;
|
||||
c &= 0x7f;
|
||||
if (c < 0x20) {
|
||||
return;
|
||||
} else if (c >= 0x40 && c < 0x5F) {
|
||||
c -= 0x40;
|
||||
} else if (c >= 0x60) {
|
||||
c -= 0x20;
|
||||
}
|
||||
|
||||
// Row is 8 pixels
|
||||
int data = fontdata[12 * c + y];
|
||||
// Map to the screen pixel format
|
||||
uint32_t word0 = mapping_table0[data];
|
||||
uint32_t word1 = mapping_table1[data];
|
||||
if (invert) {
|
||||
word0 ^= 0x88888888;
|
||||
word1 ^= 0x88888888;
|
||||
}
|
||||
*word_ptr |= word0;
|
||||
*(word_ptr + words_per_line) |= word0;
|
||||
word_ptr++;
|
||||
*word_ptr |= word1;
|
||||
*(word_ptr + words_per_line) |= word1;
|
||||
word_ptr++;
|
||||
}
|
||||
line_ptr += 2 * words_per_line;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef OSD_H
|
||||
#define OSD_H
|
||||
|
||||
void osd_init();
|
||||
void osd_clear();
|
||||
void osd_set(char *text);
|
||||
void osd_update(uint32_t *osd_base, int bytes_per_line);
|
||||
int osd_active();
|
||||
|
||||
#endif
|
|
@ -109,8 +109,8 @@ rgb_to_fb:
|
|||
// Setup R4 as a constant
|
||||
ldr r4, =GPLEV0
|
||||
|
||||
tst r3, #(BIT_PROBE | BIT_CALIBRATE)
|
||||
bleq clear_screen
|
||||
tst r3, #BIT_CLEAR
|
||||
blne clear_screen
|
||||
|
||||
// clear all the state bits apart from the following:
|
||||
bic r3, r3, #~(BIT_MODE7 | BIT_PROBE | BIT_CALIBRATE | BIT_CAL_COUNT | BIT_INITIALIZE | BIT_ELK)
|
||||
|
@ -160,9 +160,9 @@ frame:
|
|||
and r0, r3, #(BIT_INITIALIZE | BIT_FIELD_TYPE)
|
||||
cmp r0, #BIT_INITIALIZE
|
||||
beq frame
|
||||
|
||||
|
||||
// Clear the initiaize flag so this is only done once
|
||||
bic r3, r3, #BIT_INITIALIZE
|
||||
bic r3, r3, #BIT_INITIALIZE
|
||||
|
||||
// Check for mode change:
|
||||
// Odd: Mode 0..6 should be 21us, Mode 7 should be 23us
|
||||
|
@ -191,7 +191,10 @@ skip_switch_test:
|
|||
moveq r5, #0 // Modes 0-6
|
||||
movne r5, #1 // Mode 7
|
||||
cmp r5, r0 // Check if we have changed mode
|
||||
bne exit // If not, then bail, as clock needs to be changed
|
||||
bne exit // If so, then bail, as the frame buffer needs to be resized
|
||||
|
||||
// Save a copy of the frame buffer base
|
||||
push {r11}
|
||||
|
||||
// Skip inactive lines
|
||||
mov r5, #NUM_INACTIVE
|
||||
|
@ -258,6 +261,7 @@ process_chars_loop:
|
|||
// Wait for 1-0 edge on PSYNC
|
||||
WAIT_FOR_PSYNC_0
|
||||
|
||||
|
||||
// Pixel 4 in GPIO 4.. 2 -> 23..20
|
||||
// Pixel 5 in GPIO 7.. 5 -> 19..16
|
||||
// Pixel 6 in GPIO 10.. 8 -> 31..28
|
||||
|
@ -281,6 +285,12 @@ process_chars_loop:
|
|||
tst r3, #BIT_MODE7
|
||||
streq r10, [r12, r2]
|
||||
#endif
|
||||
ldrne r0, [r12]
|
||||
bicne r0, #0x77000000
|
||||
bicne r0, #0x00770000
|
||||
bicne r0, #0x00007700
|
||||
bicne r0, #0x00000077
|
||||
orrne r10, r0
|
||||
str r10, [r12], #4
|
||||
|
||||
subs r6, r6, #1
|
||||
|
@ -292,6 +302,14 @@ process_chars_loop:
|
|||
subs r5, r5, #1
|
||||
bne process_line_loop
|
||||
|
||||
// Update the OSD
|
||||
pop {r11}
|
||||
push {r0-r12, lr}
|
||||
mov r0, r11 // start of current draw buffer
|
||||
mov r1, r2 // bytes per line
|
||||
bl osd_update
|
||||
pop {r0-r12, lr}
|
||||
|
||||
// Loop back if not calibrate mode...
|
||||
tst r3, #BIT_CALIBRATE
|
||||
beq frame
|
||||
|
@ -300,7 +318,7 @@ process_chars_loop:
|
|||
tst r3, #BIT_CAL_COUNT
|
||||
orr r3, #BIT_CAL_COUNT
|
||||
beq frame
|
||||
|
||||
|
||||
// Return
|
||||
exit:
|
||||
pop {r4-r12, lr}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "rpi-mailbox-interface.h"
|
||||
#include "startup.h"
|
||||
#include "rpi-mailbox.h"
|
||||
|
||||
#include "osd.h"
|
||||
#include "cpld.h"
|
||||
#include "cpld_normal.h"
|
||||
#include "cpld_alternative.h"
|
||||
|
@ -429,6 +429,8 @@ int *diff_N_frames(int sp, int n, int mode7, int elk, int chars_per_line) {
|
|||
uint32_t *lastp = (uint32_t *)last;
|
||||
for (int j = 0; j < SCREEN_HEIGHT * pitch; j += 4) {
|
||||
uint32_t d = (*fbp++) ^ (*lastp++);
|
||||
// Mask out OSD
|
||||
d &= 0x77777777;
|
||||
while (d) {
|
||||
if (d & 0x01) {
|
||||
diff[0]++;
|
||||
|
@ -502,6 +504,8 @@ int total_N_frames(int sp, int n, int mode7, int elk, int chars_per_line) {
|
|||
uint32_t *fbp = (uint32_t *)fb;
|
||||
for (int j = 0; j < SCREEN_HEIGHT * pitch; j += 4) {
|
||||
uint32_t f = *fbp++;
|
||||
// Mask out OSD
|
||||
f &= 0x77777777;
|
||||
while (f) {
|
||||
if (f & 0x0F) {
|
||||
total++;
|
||||
|
@ -627,19 +631,24 @@ void rgb_to_hdmi_main() {
|
|||
|
||||
int chars_per_line = mode7 ? MODE7_CHARS_PER_LINE : DEFAULT_CHARS_PER_LINE;
|
||||
|
||||
int clear = BIT_CLEAR;
|
||||
|
||||
do {
|
||||
|
||||
log_debug("Entering rgb_to_fb");
|
||||
result = rgb_to_fb(fb, chars_per_line, pitch, mode7 | BIT_INITIALIZE | (elk ? BIT_ELK : 0));
|
||||
result = rgb_to_fb(fb, chars_per_line, pitch, mode7 | BIT_INITIALIZE | (elk ? BIT_ELK : 0) | clear);
|
||||
log_debug("Leaving rgb_to_fb, result= %d", result);
|
||||
clear = 0;
|
||||
|
||||
if (result & RET_SW1) {
|
||||
// Calibrate
|
||||
osd_set("Calibrating");
|
||||
elk = test_for_elk(mode7, chars_per_line);
|
||||
log_debug("Elk mode = %d", elk);
|
||||
for (int c = 0; c < NUM_CAL_PASSES; c++) {
|
||||
cpld->calibrate(mode7, elk, chars_per_line);
|
||||
}
|
||||
osd_clear();
|
||||
wait_for_sw_release(SW1_PIN);
|
||||
}
|
||||
if (result & RET_SW2) {
|
||||
|
@ -702,6 +711,8 @@ void kernel_main(unsigned int r0, unsigned int r1, unsigned int atags)
|
|||
enable_MMU_and_IDCaches();
|
||||
_enable_unaligned_access();
|
||||
|
||||
osd_init();
|
||||
|
||||
#ifdef HAS_MULTICORE
|
||||
int i;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "rpi-mailbox-interface.h"
|
||||
#include "cache.h"
|
||||
#include "defs.h"
|
||||
#include "osd.h"
|
||||
|
||||
/* Make sure the property tag buffer is aligned to a 16-byte boundary because
|
||||
we only have 28-bits available in the property interface protocol to pass
|
||||
|
@ -205,17 +206,43 @@ void RPI_PropertyAddTag( rpi_mailbox_tag_t tag, ... )
|
|||
pt[pt_index++] = 40;
|
||||
pt[pt_index++] = 0; /* Request */
|
||||
pt[pt_index++] = 0; // Offset to first colour
|
||||
pt[pt_index++] = 8; // Number of colours
|
||||
pt[pt_index++] = 0xFF000000 | BLACK; // Colour 0 - Black
|
||||
pt[pt_index++] = 0xFF0000FF | BLACK; // Colour 1 - Red
|
||||
pt[pt_index++] = 0xFF00FF00 | BLACK; // Colour 2 - Green
|
||||
pt[pt_index++] = 0xFF00FFFF | BLACK; // Colour 3 - Yellow
|
||||
pt[pt_index++] = 0xFFFF0000 | BLACK; // Colour 4 - Blue
|
||||
pt[pt_index++] = 0xFFFF00FF | BLACK; // Colour 5 - Magenta
|
||||
pt[pt_index++] = 0xFFFFFF00 | BLACK; // Colour 6 - Cyan
|
||||
pt[pt_index++] = 0xFFFFFFFF | BLACK; // Colour 7 - White
|
||||
break;
|
||||
|
||||
pt[pt_index++] = 16; // Number of colours
|
||||
if (osd_active()) {
|
||||
pt[pt_index++] = 0xFF000000; // Colour 0 - Black
|
||||
pt[pt_index++] = 0xFF00007F; // Colour 1 - Red
|
||||
pt[pt_index++] = 0xFF007F00; // Colour 2 - Green
|
||||
pt[pt_index++] = 0xFF007F7F; // Colour 3 - Yellow
|
||||
pt[pt_index++] = 0xFF7F0000; // Colour 4 - Blue
|
||||
pt[pt_index++] = 0xFF7F007F; // Colour 5 - Magenta
|
||||
pt[pt_index++] = 0xFF7F7F00; // Colour 6 - Cyan
|
||||
pt[pt_index++] = 0xFF7F7F7F; // Colour 7 - White
|
||||
pt[pt_index++] = 0xFFFFFFFF; // Colour 8 - White
|
||||
pt[pt_index++] = 0xFFFFFFFF; // Colour 9 - White
|
||||
pt[pt_index++] = 0xFFFFFFFF; // Colour 10 - White
|
||||
pt[pt_index++] = 0xFFFFFFFF; // Colour 11 - White
|
||||
pt[pt_index++] = 0xFFFFFFFF; // Colour 12 - White
|
||||
pt[pt_index++] = 0xFFFFFFFF; // Colour 13 - White
|
||||
pt[pt_index++] = 0xFFFFFFFF; // Colour 14 - White
|
||||
pt[pt_index++] = 0xFFFFFFFF; // Colour 15 - White
|
||||
} else {
|
||||
pt[pt_index++] = 0xFF000000 | BLACK; // Colour 0 - Black
|
||||
pt[pt_index++] = 0xFF0000FF | BLACK; // Colour 1 - Red
|
||||
pt[pt_index++] = 0xFF00FF00 | BLACK; // Colour 2 - Green
|
||||
pt[pt_index++] = 0xFF00FFFF | BLACK; // Colour 3 - Yellow
|
||||
pt[pt_index++] = 0xFFFF0000 | BLACK; // Colour 4 - Blue
|
||||
pt[pt_index++] = 0xFFFF00FF | BLACK; // Colour 5 - Magenta
|
||||
pt[pt_index++] = 0xFFFFFF00 | BLACK; // Colour 6 - Cyan
|
||||
pt[pt_index++] = 0xFFFFFFFF | BLACK; // Colour 7 - White
|
||||
pt[pt_index++] = 0xFF000000 | BLACK; // Colour 8 - Black
|
||||
pt[pt_index++] = 0xFF0000FF | BLACK; // Colour 9 - Red
|
||||
pt[pt_index++] = 0xFF00FF00 | BLACK; // Colour 10 - Green
|
||||
pt[pt_index++] = 0xFF00FFFF | BLACK; // Colour 11 - Yellow
|
||||
pt[pt_index++] = 0xFFFF0000 | BLACK; // Colour 12 - Blue
|
||||
pt[pt_index++] = 0xFFFF00FF | BLACK; // Colour 13 - Magenta
|
||||
pt[pt_index++] = 0xFFFFFF00 | BLACK; // Colour 14 - Cyan
|
||||
pt[pt_index++] = 0xFFFFFFFF | BLACK; // Colour 15 - White
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Unsupported tags, just remove the tag from the list */
|
||||
|
|
Ładowanie…
Reference in New Issue