Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected behaviour of "graphics_get_display_size" in bcm_host? #14

Closed
benosteen opened this issue May 11, 2012 · 2 comments
Closed

Expected behaviour of "graphics_get_display_size" in bcm_host? #14

benosteen opened this issue May 11, 2012 · 2 comments

Comments

@benosteen
Copy link

Calling "graphics_get_display_size" seems to always return 1920x1080, regardless of the current display size. Is this expected behaviour?

Is there a way to get the true output resolution, in the same manner as the tvservice utility?

eg

#include "bcm_host.h"
...
success = graphics_get_display_size(0 /* LCD */, &width, &height);

width and height seem to return 1920 and 1080 respectively, regardless to output mode. My HDMI is currently set to "state 0x12001a, 1280x720 @ 50Hz, progressive". It returns 1920x1080 even when using composite out.

@popcornmix
Copy link
Contributor

It was fixed on 21 April in our source tree, so you need a libbcm_host.so newer than that.
If you are interested this is the implementation:

int32_t graphics_get_display_size( const uint16_t display_number,
                                                    uint32_t *width,
                                                    uint32_t *height)
{
   DISPMANX_DISPLAY_HANDLE_T display_handle = 0;
   DISPMANX_MODEINFO_T mode_info;
   int32_t success = -1;

   if (display_handle == 0) {
      // Display must be opened first.
      display_handle = vc_dispmanx_display_open(display_number);
      vcos_assert(display_handle);
   }
   if (display_handle) {
      success = vc_dispmanx_display_get_info(display_handle, &mode_info);

      if( success >= 0 )
      {
         if( NULL != width )
         {
            *width = mode_info.width;
         }

         if( NULL != height )
         {
            *height = mode_info.height;
         }
      }
   }

   if ( display_handle )
   {
      vc_dispmanx_display_close(display_handle);
      display_handle = 0;
   }

   return success;
}

@benosteen
Copy link
Author

Brilliant :) Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants