Expected behaviour of "graphics_get_display_size" in bcm_host? #14

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

Comments

Projects
None yet
2 participants
@benosteen

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

This comment has been minimized.

Show comment
Hide comment
@popcornmix

popcornmix May 11, 2012

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;
}
Contributor

popcornmix commented May 11, 2012

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

This comment has been minimized.

Show comment
Hide comment
@benosteen

benosteen May 11, 2012

Brilliant :) Thanks!

Brilliant :) Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment