Raspberry Pi driver reported refresh rate

Hi,

I noticed that SDL_rpivideo.c always reports 60Hz refresh rate and even has a question about getting the correct refresh rate. I need refresh rate for my project and I tried to answer that question myself using the code from userland app tvservice:

Based on this procedure I have my attempt to resolve this:

RPI_GetRefreshRate()
{
    TV_DISPLAY_STATE_T tvstate;
    if (vc_tv_get_display_state( &tvstate ) == 0) {
        //The width/height parameters are in the same position in the union
        //for HDMI and SDTV
        HDMI_PROPERTY_PARAM_T property;
        property.property = HDMI_PROPERTY_PIXEL_CLOCK_TYPE;
        vc_tv_hdmi_get_property(&property);
        return property.param1 == HDMI_PIXEL_CLOCK_TYPE_NTSC ?
            tvstate.display.hdmi.frame_rate * (1000.0f/1001.0f) :
            tvstate.display.hdmi.frame_rate;
    }
    return 60;  /* Failed to get display state, default to 60 */
}

and in RPI_VideoInit():

current_mode.w = w;
current_mode.h = h;
current_mode.refresh_rate = RPI_GetRefreshRate();
/* 32 bpp for default */
current_mode.format = SDL_PIXELFORMAT_ABGR8888;

I’m sorry if I’m trying to contribute in the wrong place.