10199 loader: vbe should use bio_alloc for edid info

Review Request #1357 — Created Jan. 9, 2019 and submitted

tsoome
illumos-gate
10199
18552bc...
general
10199 loader: vbe should use bio_alloc for edid info


  • 0
  • 0
  • 1
  • 0
  • 1
Description From Last Updated
domag02
  1. 
      
  2. 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)
    
    1. Thanks, that was a bug I was looking for:D

  3. 
      
tsoome
citrus
  1. Ship It!
  2. 
      
tsoome
tsoome
tsoome
domag02
  1. Ship it!

    I'm thinking about a little further enhancement, to improve code readability and consistency:

    • Helper macros for handling detailed_timings through vesa_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 of int):
      /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?

    1. good idea. and the opinion is simple - you really should set up the development host for at least writing patches. I'm sure we will get a build host up for automated builds for RTI purposes.

  2. 
      
tsoome
tsoome
tsoome
aeon
  1. Ship It!
  2. 
      
tsoome
Review request changed

Status: Closed (submitted)

Loading...