@ -414,19 +414,6 @@ drm_property_info_free(struct drm_property_info *info, int num_props)
memset ( info , 0 , sizeof ( * info ) * num_props ) ;
memset ( info , 0 , sizeof ( * info ) * num_props ) ;
}
}
static inline uint32_t *
formats_ptr ( struct drm_format_modifier_blob * blob )
{
return ( uint32_t * ) ( ( ( char * ) blob ) + blob - > formats_offset ) ;
}
static inline struct drm_format_modifier *
modifiers_ptr ( struct drm_format_modifier_blob * blob )
{
return ( struct drm_format_modifier * )
( ( ( char * ) blob ) + blob - > modifiers_offset ) ;
}
/**
/**
* Populates the plane ' s formats array , using either the IN_FORMATS blob
* Populates the plane ' s formats array , using either the IN_FORMATS blob
* property ( if available ) , or the plane ' s format list if not .
* property ( if available ) , or the plane ' s format list if not .
@ -437,13 +424,10 @@ drm_plane_populate_formats(struct drm_plane *plane, const drmModePlane *kplane,
const bool use_modifiers )
const bool use_modifiers )
{
{
struct drm_device * device = plane - > device ;
struct drm_device * device = plane - > device ;
unsigned i , j ;
uint32_t i , blob_id , fmt_prev = DRM_FORMAT_INVALID ;
drmModeFormatModifierIterator drm_iter = { 0 } ;
struct weston_drm_format * fmt = NULL ;
drmModePropertyBlobRes * blob = NULL ;
drmModePropertyBlobRes * blob = NULL ;
struct drm_format_modifier_blob * fmt_mod_blob ;
struct drm_format_modifier * blob_modifiers ;
uint32_t * blob_formats ;
uint32_t blob_id ;
struct weston_drm_format * fmt ;
int ret = 0 ;
int ret = 0 ;
if ( ! use_modifiers )
if ( ! use_modifiers )
@ -459,35 +443,22 @@ drm_plane_populate_formats(struct drm_plane *plane, const drmModePlane *kplane,
if ( ! blob )
if ( ! blob )
goto fallback ;
goto fallback ;
fmt_mod_blob = blob - > data ;
while ( drmModeFormatModifierBlobIterNext ( blob , & drm_iter ) ) {
blob_formats = formats_ptr ( fmt_mod_blob ) ;
if ( fmt_prev ! = drm_iter . fmt ) {
blob_modifiers = modifiers_ptr ( fmt_mod_blob ) ;
fmt = weston_drm_format_array_add_format ( & plane - > formats ,
drm_iter . fmt ) ;
assert ( kplane - > count_formats = = fmt_mod_blob - > count_formats ) ;
if ( ! fmt ) {
ret = - 1 ;
goto out ;
}
for ( i = 0 ; i < fmt_mod_blob - > count_formats ; i + + ) {
fmt_prev = drm_iter . fmt ;
fmt = weston_drm_format_array_add_format ( & plane - > formats ,
blob_formats [ i ] ) ;
if ( ! fmt ) {
ret = - 1 ;
goto out ;
}
}
for ( j = 0 ; j < fmt_mod_blob - > count_modifiers ; j + + ) {
ret = weston_drm_format_add_modifier ( fmt , drm_iter . mod ) ;
struct drm_format_modifier * mod = & blob_modifiers [ j ] ;
if ( ret < 0 )
goto out ;
if ( ( i < mod - > offset ) | | ( i > mod - > offset + 63 ) )
continue ;
if ( ! ( mod - > formats & ( 1 < < ( i - mod - > offset ) ) ) )
continue ;
ret = weston_drm_format_add_modifier ( fmt , mod - > modifier ) ;
if ( ret < 0 )
goto out ;
}
if ( fmt - > modifiers . size = = 0 )
weston_drm_format_array_remove_latest_format ( & plane - > formats ) ;
}
}
out :
out :