Several fixes to ieee1275 and big-endian video.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-05-02 22:30:20 +02:00
parent 813c16222f
commit a8905e8ae8
18 changed files with 655 additions and 72 deletions

View file

@ -1,6 +1,9 @@
{ "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x7f1853ba, 0x7f1853ba, 0x7f1853ba, 0x7f1853ba, 0x7f1853ba, }, 5 },
{ "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xff1957f0, 0xff1957f0, 0xff1957f0, 0xff1957f0, 0xff1957f0, }, 5 },
{ "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xcb45d8c5, 0xcb45d8c5, 0xcb45d8c5, 0xcb45d8c5, 0xcb45d8c5, }, 5 },
{ "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x2d1b122b, 0x2d1b122b, 0x2d1b122b, 0x2d1b122b, 0x2d1b122b, }, 5 },
{ "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0x327d1082, 0x327d1082, 0x327d1082, 0x327d1082, 0x327d1082, }, 5 },
{ "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xadd0f186, 0xadd0f186, 0xadd0f186, 0xadd0f186, 0xadd0f186, }, 5 },
{ "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgb555 */, (grub_uint32_t []) { 0x2c97569c, 0x2c97569c, 0x2c97569c, 0x2c97569c, 0x2c97569c, }, 5 },
{ "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgb555 */, (grub_uint32_t []) { 0x9bd7a3ac, 0x9bd7a3ac, 0x9bd7a3ac, 0x9bd7a3ac, 0x9bd7a3ac, }, 5 },
{ "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgb555 */, (grub_uint32_t []) { 0xedbceb9c, 0xedbceb9c, 0xedbceb9c, 0xedbceb9c, 0xedbceb9c, }, 5 },

View file

@ -249,14 +249,16 @@ get_modename (void)
}
if (capt_mode_info.red_field_pos == 0)
{
grub_snprintf (buf, sizeof (buf), "bgr%d%d%d", capt_mode_info.blue_mask_size,
grub_snprintf (buf, sizeof (buf), "bgra%d%d%d%d", capt_mode_info.blue_mask_size,
capt_mode_info.green_mask_size,
capt_mode_info.red_mask_size);
capt_mode_info.red_mask_size,
capt_mode_info.reserved_mask_size);
return buf;
}
grub_snprintf (buf, sizeof (buf), "rgb%d%d%d", capt_mode_info.red_mask_size,
grub_snprintf (buf, sizeof (buf), "rgba%d%d%d%d", capt_mode_info.red_mask_size,
capt_mode_info.green_mask_size,
capt_mode_info.blue_mask_size);
capt_mode_info.blue_mask_size,
capt_mode_info.reserved_mask_size);
return buf;
}
@ -270,11 +272,81 @@ static void
checksum (void)
{
void *ptr;
grub_uint32_t crc;
grub_uint32_t crc = 0;
ptr = grub_video_capture_get_framebuffer ();
#ifdef GRUB_CPU_WORDS_BIGENDIAN
switch (capt_mode_info.bytes_per_pixel)
{
case 1:
crc = grub_getcrc32c (0, ptr, capt_mode_info.pitch
* capt_mode_info.height);
break;
case 2:
{
unsigned x, y, rowskip;
grub_uint8_t *iptr = ptr;
crc = 0;
rowskip = capt_mode_info.pitch - capt_mode_info.width * 2;
for (y = 0; y < capt_mode_info.height; y++)
{
for (x = 0; x < capt_mode_info.width; x++)
{
crc = grub_getcrc32c (crc, iptr + 1, 1);
crc = grub_getcrc32c (crc, iptr, 1);
iptr += 2;
}
crc = grub_getcrc32c (crc, iptr, rowskip);
iptr += rowskip;
}
break;
}
case 3:
{
unsigned x, y, rowskip;
grub_uint8_t *iptr = ptr;
crc = 0;
rowskip = capt_mode_info.pitch - capt_mode_info.width * 3;
for (y = 0; y < capt_mode_info.height; y++)
{
for (x = 0; x < capt_mode_info.width; x++)
{
crc = grub_getcrc32c (crc, iptr + 2, 1);
crc = grub_getcrc32c (crc, iptr + 1, 1);
crc = grub_getcrc32c (crc, iptr, 1);
iptr += 3;
}
crc = grub_getcrc32c (crc, iptr, rowskip);
iptr += rowskip;
}
break;
}
case 4:
{
unsigned x, y, rowskip;
grub_uint8_t *iptr = ptr;
crc = 0;
rowskip = capt_mode_info.pitch - capt_mode_info.width * 4;
for (y = 0; y < capt_mode_info.height; y++)
{
for (x = 0; x < capt_mode_info.width; x++)
{
crc = grub_getcrc32c (crc, iptr + 3, 1);
crc = grub_getcrc32c (crc, iptr + 2, 1);
crc = grub_getcrc32c (crc, iptr + 1, 1);
crc = grub_getcrc32c (crc, iptr, 1);
iptr += 4;
}
crc = grub_getcrc32c (crc, iptr, rowskip);
iptr += rowskip;
}
break;
}
}
#else
crc = grub_getcrc32c (0, ptr, capt_mode_info.pitch * capt_mode_info.height);
#endif
if (!checksums || ctr >= nchk)
{
grub_test_assert (0, "Unexpected checksum %s_%dx%dx%s:%d: 0x%x",

View file

@ -63,6 +63,42 @@ struct
.number_of_colors = GRUB_VIDEO_FBSTD_NUMCOLORS
},
},
{
.mode_info = {
.width = 640,
.height = 480,
.pitch = 640,
.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR,
.bpp = 8,
.bytes_per_pixel = 1,
.number_of_colors = GRUB_VIDEO_FBSTD_EXT_NUMCOLORS
},
},
{
.mode_info = {
.width = 800,
.height = 600,
.pitch = 800,
.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR,
.bpp = 8,
.bytes_per_pixel = 1,
.number_of_colors = GRUB_VIDEO_FBSTD_EXT_NUMCOLORS
},
},
{
.mode_info = {
.width = 1024,
.height = 768,
.pitch = 1024,
.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR,
.bpp = 8,
.bytes_per_pixel = 1,
.number_of_colors = GRUB_VIDEO_FBSTD_EXT_NUMCOLORS
},
},
{
.mode_info = {
.width = 640,
@ -275,7 +311,7 @@ videotest_checksum (void)
{
grub_video_capture_start (&tests[i].mode_info,
grub_video_fbstd_colors,
GRUB_VIDEO_FBSTD_NUMCOLORS);
tests[i].mode_info.number_of_colors);
grub_terminal_input_fake_sequence ((int []) { '\n' }, 1);
grub_video_checksum ("videotest");