Pi Firmware: Palette now supports 256 colours

Change-Id: I4ff9982ec035f6cb690e82b89d159b0d382728e1
pull/11/head
David Banks 2018-11-27 14:56:25 +00:00
rodzic a07b3bc009
commit 20465e78fc
4 zmienionych plików z 44 dodań i 45 usunięć

Wyświetl plik

@ -387,14 +387,6 @@ static int return_at_end = 1;
// Private Methods
// =============================================================
static void update_palette() {
// Flush the previous swapBuffer() response from the GPU->ARM mailbox
RPI_Mailbox0Flush( MB0_TAGS_ARM_TO_VC );
RPI_PropertyInit();
RPI_PropertyAddTag( TAG_SET_PALETTE, osd_get_palette());
RPI_PropertyProcess();
}
static int get_feature(int num) {
switch (num) {
case F_PALETTE:
@ -427,7 +419,7 @@ static void set_feature(int num, int value) {
switch (num) {
case F_PALETTE:
palette = value;
update_palette();
osd_update_palette();
break;
case F_DEINTERLACE:
set_deinterlace(value);
@ -455,7 +447,7 @@ static void set_feature(int num, int value) {
#endif
case F_DEBUG:
set_debug(value);
update_palette();
osd_update_palette();
break;
case F_M7DISABLE:
set_m7disable(value);
@ -694,14 +686,17 @@ static int get_key_down_duration(int key) {
return 0;
}
// =============================================================
// Public Methods
// =============================================================
uint32_t *osd_get_palette() {
static uint32_t palette_data[256];
void osd_update_palette() {
int m;
static uint32_t palette_data[16];
for (int i = 0; i < 16; i++) {
int num_colours = (capinfo->bpp == 8) ? 256 : 16;
for (int i = 0; i < num_colours; i++) {
int r = (i & 1) ? 255 : 0;
int g = (i & 2) ? 255 : 0;
int b = (i & 4) ? 255 : 0;
@ -748,7 +743,7 @@ uint32_t *osd_get_palette() {
break;
}
if (active) {
if (i >= 8) {
if (i >= (num_colours >> 1)) {
palette_data[i] = 0xFFFFFFFF;
} else {
r >>= 1; g >>= 1; b >>= 1;
@ -761,7 +756,12 @@ uint32_t *osd_get_palette() {
palette_data[i] |= 0x00101010;
}
}
return palette_data;
// Flush the previous swapBuffer() response from the GPU->ARM mailbox
RPI_Mailbox0Flush( MB0_TAGS_ARM_TO_VC );
RPI_PropertyInit();
RPI_PropertyAddTag(TAG_SET_PALETTE, num_colours, palette_data);
RPI_PropertyProcess();
}
void osd_clear() {
@ -770,7 +770,7 @@ void osd_clear() {
osd_update((uint32_t *)capinfo->fb, capinfo->pitch);
active = 0;
RPI_SetGpioValue(LED1_PIN, active);
update_palette();
osd_update_palette();
}
}
@ -778,7 +778,7 @@ void osd_set(int line, int attr, char *text) {
if (!active) {
active = 1;
RPI_SetGpioValue(LED1_PIN, active);
update_palette();
osd_update_palette();
}
attributes[line] = attr;
memset(buffer + line * LINELEN, 0, LINELEN);
@ -1041,27 +1041,27 @@ void osd_init() {
// Normal size
// aaaaaaaa bbbbbbbb cccccccc
if (j < 4) {
normal_size_map_8bpp[i * 3 + 2] |= 0x08 << (8 * (3 - j)); // cccccccc
normal_size_map_8bpp[i * 3 + 2] |= 0x80 << (8 * (3 - j)); // cccccccc
} else if (j < 8) {
normal_size_map_8bpp[i * 3 + 1] |= 0x08 << (8 * (7 - j)); // bbbbbbbb
normal_size_map_8bpp[i * 3 + 1] |= 0x80 << (8 * (7 - j)); // bbbbbbbb
} else {
normal_size_map_8bpp[i * 3 ] |= 0x08 << (8 * (11 - j)); // aaaaaaaa
normal_size_map_8bpp[i * 3 ] |= 0x80 << (8 * (11 - j)); // aaaaaaaa
}
// Double size
// aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff
if (j < 2) {
double_size_map_8bpp[i * 6 + 5] |= 0x0808 << (16 * (1 - j)); // ffffffff
double_size_map_8bpp[i * 6 + 5] |= 0x8080 << (16 * (1 - j)); // ffffffff
} else if (j < 4) {
double_size_map_8bpp[i * 6 + 4] |= 0x0808 << (16 * (3 - j)); // eeeeeeee
double_size_map_8bpp[i * 6 + 4] |= 0x8080 << (16 * (3 - j)); // eeeeeeee
} else if (j < 6) {
double_size_map_8bpp[i * 6 + 3] |= 0x0808 << (16 * (5 - j)); // dddddddd
double_size_map_8bpp[i * 6 + 3] |= 0x8080 << (16 * (5 - j)); // dddddddd
} else if (j < 8) {
double_size_map_8bpp[i * 6 + 2] |= 0x0808 << (16 * (7 - j)); // cccccccc
double_size_map_8bpp[i * 6 + 2] |= 0x8080 << (16 * (7 - j)); // cccccccc
} else if (j < 10) {
double_size_map_8bpp[i * 6 + 1] |= 0x0808 << (16 * (9 - j)); // bbbbbbbb
double_size_map_8bpp[i * 6 + 1] |= 0x8080 << (16 * (9 - j)); // bbbbbbbb
} else {
double_size_map_8bpp[i * 6 ] |= 0x0808 << (16 * (11 - j)); // aaaaaaaa
double_size_map_8bpp[i * 6 ] |= 0x8080 << (16 * (11 - j)); // aaaaaaaa
}
}
}
@ -1251,9 +1251,9 @@ void osd_update(uint32_t *osd_base, int bytes_per_line) {
if (attr & ATTR_DOUBLE_SIZE) {
uint32_t *map_ptr = double_size_map_8bpp + data * 6;
for (int k = 0; k < 6; k++) {
*word_ptr &= 0xf7f7f7f7;
*word_ptr &= 0x7f7f7f7f;
*word_ptr |= *map_ptr;
*(word_ptr + words_per_line) &= 0xf7f7f7f7;
*(word_ptr + words_per_line) &= 0x7f7f7f7f;
*(word_ptr + words_per_line) |= *map_ptr;
word_ptr++;
map_ptr++;
@ -1261,7 +1261,7 @@ void osd_update(uint32_t *osd_base, int bytes_per_line) {
} else {
uint32_t *map_ptr = normal_size_map_8bpp + data * 3;
for (int k = 0; k < 3; k++) {
*word_ptr &= 0xf7f7f7f7;
*word_ptr &= 0x7f7f7f7f;
*word_ptr |= *map_ptr;
word_ptr++;
map_ptr++;

Wyświetl plik

@ -52,7 +52,7 @@ void osd_update(uint32_t *osd_base, int bytes_per_line);
void osd_update_fast(uint32_t *osd_base, int bytes_per_line);
int osd_active();
int osd_key(int key);
uint32_t *osd_get_palette();
void osd_update_palette();
void action_calibrate_clocks();
void action_calibrate_auto();

Wyświetl plik

@ -171,7 +171,6 @@ static void init_framebuffer(capture_info_t *capinfo) {
RPI_PropertyAddTag(TAG_SET_VIRTUAL_SIZE, capinfo->width, capinfo->height);
#endif
RPI_PropertyAddTag(TAG_SET_DEPTH, capinfo->bpp);
RPI_PropertyAddTag(TAG_SET_PALETTE, osd_get_palette());
RPI_PropertyAddTag(TAG_GET_PITCH);
RPI_PropertyAddTag(TAG_GET_PHYSICAL_SIZE);
RPI_PropertyAddTag(TAG_GET_DEPTH);
@ -199,6 +198,9 @@ static void init_framebuffer(capture_info_t *capinfo) {
}
// On the Pi 2/3 the mailbox returns the address with bits 31..30 set, which is wrong
capinfo->fb = (unsigned char *)(((unsigned int) capinfo->fb) & 0x3fffffff);
// Initialize the palette
osd_update_palette();
}
#else
@ -259,13 +261,11 @@ static void init_framebuffer(capture_info_t *capinfo) {
log_info("Pitch: %d bytes", capinfo->pitch);
log_info("Framebuffer address: %8.8X", (unsigned int)capinfo->fb);
// Initialize the palette
RPI_PropertyInit();
RPI_PropertyAddTag(TAG_SET_PALETTE, osd_get_palette());
RPI_PropertyProcess();
// On the Pi 2/3 the mailbox returns the address with bits 31..30 set, which is wrong
capinfo->fb = (unsigned char *)(((unsigned int) capinfo->fb) & 0x3fffffff);
// Initialize the palette
osd_update_palette();
}
#endif

Wyświetl plik

@ -47,6 +47,7 @@ void RPI_PropertyInit( void )
*/
void RPI_PropertyAddTag( rpi_mailbox_tag_t tag, ... )
{
int num_colours;
va_list vl;
va_start( vl, tag );
@ -117,7 +118,7 @@ void RPI_PropertyAddTag( rpi_mailbox_tag_t tag, ... )
pt[pt_index++] = va_arg( vl, int ); // R3
pt[pt_index++] = va_arg( vl, int ); // R4
pt[pt_index++] = va_arg( vl, int ); // R5
break;
break;
case TAG_ALLOCATE_BUFFER:
pt[pt_index++] = 8;
@ -194,16 +195,14 @@ void RPI_PropertyAddTag( rpi_mailbox_tag_t tag, ... )
}
break;
// Hack to allow 8 colours to be set
case TAG_SET_PALETTE:
pt[pt_index++] = 40;
num_colours = va_arg( vl, int);
pt[pt_index++] = 8 + num_colours * 4;
pt[pt_index++] = 0; /* Request */
pt[pt_index++] = 0; // Offset to first colour
pt[pt_index++] = 16; // Number of colours
pt[pt_index++] = 0; // Offset to first colour
pt[pt_index++] = num_colours; // Number of colours
uint32_t *palette = va_arg( vl, uint32_t *);
for (int i = 0; i < 16; i++) {
for (int i = 0; i < num_colours; i++) {
pt[pt_index++] = palette[i];
}
break;
@ -224,7 +223,7 @@ void RPI_PropertyAddTag( rpi_mailbox_tag_t tag, ... )
int RPI_PropertyProcess( void )
{
int result;
#if( PRINT_PROP_DEBUG == 1 )
int i;
log_info( "%s Length: %d", __func__, pt[PT_OSIZE] );