-
-
usr/src/boot/sys/boot/i386/libi386/vbe.c (Diff revision 1) edid_info
is already a pointer.
Should be:if (memcmp(edid_info, magic, sizeof (magic)) != 0)
or
if (memcmp(edid_info->header.header, magic, sizeof (magic)) != 0)
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 2 (+25 -16) |
Change Summary:
biosvbe_ddc_read_edid() returns int, we should not mix it with ret which is bool.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 3 (+25 -17) |
-
Ship it!
I'm thinking about a little further enhancement, to improve code readability and consistency:
- Helper macros for handling
detailed_timings
throughvesa_edid_info
:
/usr/src/boot/sys/boot/common/gfx_fb.h:
#define GET_EDID_INFO_WIDTH(edid_info, timings_num) \ ((edid_info).detailed_timings[(timings_num)].horizontal_active_lo | \ (((uint_t)(edid_info).detailed_timings[(timings_num)].horizontal_hi & \ 0xf0) << 4)) #define GET_EDID_INFO_HEIGHT(edid_info, timings_num) \ ((edid_info).detailed_timings[(timings_num)].vertical_active_lo | \ (((uint_t)(edid_info)->detailed_timings[(timings_num)].vertical_hi & \ 0xf0) << 4))
/usr/src/boot/sys/boot/i386/libi386/vbe.c:
static bool vbe_get_edid(uint_t *pwidth, uint_t *pheight) { struct vesa_edid_info *edid_info; const uint8_t magic[] = EDID_MAGIC; int ddc_caps; bool ret = false; ddc_caps = biosvbe_ddc_caps(); if (ddc_caps == 0) { return (ret); } edid_info = bio_alloc(sizeof (*edid_info)); if (edid_info == NULL) return (ret); if (VBE_ERROR(biosvbe_ddc_read_edid(0, edid_info))) goto done; if (memcmp(edid_info, magic, sizeof (magic)) != 0) goto done; if (!(edid_info->header.version == 1 && (edid_info->display.supported_features & EDID_FEATURE_PREFERRED_TIMING_MODE) && edid_info->detailed_timings[0].pixel_clock)) goto done; *pwidth = GET_EDID_INFO_WIDTH(edid_info, 0); *pheight = GET_EDID_INFO_HEIGHT(edid_info, 0); ret = true; done: bio_free(edid_info, sizeof (*edid_info)); return (ret); }
*timings
variable removed + consistently using cast (uint_t
used in the macro instead ofint
):
/usr/src/boot/sys/boot/efi/loader/framebuffer.c:
static int efifb_get_edid(UINT32 *pwidth, UINT32 *pheight) { extern EFI_GRAPHICS_OUTPUT *gop; struct vesa_edid_info *edid_info; int rv = 1; edid_info = efifb_gop_get_edid(gop); if (edid_info != NULL) { *pwidth = GET_EDID_INFO_WIDTH(edid_info, 0); *pheight = GET_EDID_INFO_HEIGHT(edid_info, 0); rv = 0; } free(edid_info); return (rv); }
What are the opinions about this?
- Helper macros for handling
Change Summary:
Suggestion from Gergő Mihály Doma
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 4 (+34 -24) |
Change Summary:
version up as we did touch loader.efi
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 5 (+35 -25) |
Change Summary:
mess about . and -> operators
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 6 (+35 -25) |