@@ -118,8 +118,19 @@ get_opaque_format(uint32_t format)
118118 }
119119}
120120
121+ static drmmode_format_ptr
122+ drmmode_crtc_get_format (drmmode_crtc_private_ptr drmmode_crtc ,
123+ Bool async_flip , int i )
124+ {
125+ if (async_flip && drmmode_crtc -> formats_async )
126+ return & drmmode_crtc -> formats_async [i ];
127+ else
128+ return & drmmode_crtc -> formats [i ];
129+ }
130+
121131Bool
122- drmmode_is_format_supported (ScrnInfoPtr scrn , uint32_t format , uint64_t modifier )
132+ drmmode_is_format_supported (ScrnInfoPtr scrn , uint32_t format ,
133+ uint64_t modifier , Bool async_flip )
123134{
124135 xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR (scrn );
125136 int c , i , j ;
@@ -139,7 +150,7 @@ drmmode_is_format_supported(ScrnInfoPtr scrn, uint32_t format, uint64_t modifier
139150 continue ;
140151
141152 for (i = 0 ; i < drmmode_crtc -> num_formats ; i ++ ) {
142- drmmode_format_ptr iter = & drmmode_crtc -> formats [ i ] ;
153+ drmmode_format_ptr iter = drmmode_crtc_get_format ( drmmode_crtc , async_flip , i ) ;
143154
144155 if (iter -> format != format )
145156 continue ;
@@ -170,7 +181,7 @@ drmmode_is_format_supported(ScrnInfoPtr scrn, uint32_t format, uint64_t modifier
170181#ifdef GBM_BO_WITH_MODIFIERS
171182static uint32_t
172183get_modifiers_set (ScrnInfoPtr scrn , uint32_t format , uint64_t * * modifiers ,
173- Bool enabled_crtc_only , Bool exclude_multiplane )
184+ Bool enabled_crtc_only , Bool exclude_multiplane , Bool async_flip )
174185{
175186 xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR (scrn );
176187 modesettingPtr ms = modesettingPTR (scrn );
@@ -190,7 +201,7 @@ get_modifiers_set(ScrnInfoPtr scrn, uint32_t format, uint64_t **modifiers,
190201 continue ;
191202
192203 for (i = 0 ; i < drmmode_crtc -> num_formats ; i ++ ) {
193- drmmode_format_ptr iter = & drmmode_crtc -> formats [ i ] ;
204+ drmmode_format_ptr iter = drmmode_crtc_get_format ( drmmode_crtc , async_flip , i ) ;
194205
195206 if (iter -> format != format )
196207 continue ;
@@ -245,7 +256,8 @@ get_drawable_modifiers(DrawablePtr draw, uint32_t format,
245256 return TRUE;
246257 }
247258
248- * num_modifiers = get_modifiers_set (scrn , format , modifiers , TRUE, FALSE);
259+ * num_modifiers = get_modifiers_set (scrn , format , modifiers ,
260+ TRUE, FALSE, FALSE);
249261 return TRUE;
250262}
251263#endif
@@ -2404,7 +2416,7 @@ is_plane_assigned(ScrnInfoPtr scrn, int plane_id)
24042416 */
24052417static Bool
24062418populate_format_modifiers (xf86CrtcPtr crtc , const drmModePlane * kplane ,
2407- uint32_t blob_id )
2419+ drmmode_format_rec * formats , uint32_t blob_id )
24082420{
24092421 drmmode_crtc_private_ptr drmmode_crtc = crtc -> driver_private ;
24102422 drmmode_ptr drmmode = drmmode_crtc -> drmmode ;
@@ -2450,9 +2462,9 @@ populate_format_modifiers(xf86CrtcPtr crtc, const drmModePlane *kplane,
24502462 modifiers [num_modifiers - 1 ] = mod -> modifier ;
24512463 }
24522464
2453- drmmode_crtc -> formats [i ].format = blob_formats [i ];
2454- drmmode_crtc -> formats [i ].modifiers = modifiers ;
2455- drmmode_crtc -> formats [i ].num_modifiers = num_modifiers ;
2465+ formats [i ].format = blob_formats [i ];
2466+ formats [i ].modifiers = modifiers ;
2467+ formats [i ].num_modifiers = num_modifiers ;
24562468 }
24572469
24582470 drmModeFreePropertyBlob (blob );
@@ -2624,7 +2636,7 @@ drmmode_crtc_create_planes(xf86CrtcPtr crtc, int num)
26242636 drmModePlaneRes * kplane_res ;
26252637 drmModePlane * kplane , * best_kplane = NULL ;
26262638 drmModeObjectProperties * props ;
2627- uint32_t i , type , blob_id ;
2639+ uint32_t i , type , blob_id , async_blob_id ;
26282640 int current_crtc , best_plane = 0 ;
26292641
26302642 static drmmode_prop_enum_info_rec plane_type_enums [] = {
@@ -2647,6 +2659,7 @@ drmmode_crtc_create_planes(xf86CrtcPtr crtc, int num)
26472659 [DRMMODE_PLANE_FB_ID ] = { .name = "FB_ID" , },
26482660 [DRMMODE_PLANE_CRTC_ID ] = { .name = "CRTC_ID" , },
26492661 [DRMMODE_PLANE_IN_FORMATS ] = { .name = "IN_FORMATS" , },
2662+ [DRMMODE_PLANE_IN_FORMATS_ASYNC ] = { .name = "IN_FORMATS_ASYNC" , },
26502663 [DRMMODE_PLANE_SRC_X ] = { .name = "SRC_X" , },
26512664 [DRMMODE_PLANE_SRC_Y ] = { .name = "SRC_Y" , },
26522665 [DRMMODE_PLANE_SRC_W ] = { .name = "SRC_W" , },
@@ -2723,6 +2736,8 @@ drmmode_crtc_create_planes(xf86CrtcPtr crtc, int num)
27232736 best_kplane = kplane ;
27242737 blob_id = drmmode_prop_get_value (& tmp_props [DRMMODE_PLANE_IN_FORMATS ],
27252738 props , 0 );
2739+ async_blob_id = drmmode_prop_get_value (& tmp_props [DRMMODE_PLANE_IN_FORMATS_ASYNC ],
2740+ props , 0 );
27262741 drmmode_prop_info_copy (drmmode_crtc -> props_plane , tmp_props ,
27272742 DRMMODE_PLANE__COUNT , 1 );
27282743 drmModeFreeObjectProperties (props );
@@ -2734,6 +2749,8 @@ drmmode_crtc_create_planes(xf86CrtcPtr crtc, int num)
27342749 best_kplane = kplane ;
27352750 blob_id = drmmode_prop_get_value (& tmp_props [DRMMODE_PLANE_IN_FORMATS ],
27362751 props , 0 );
2752+ async_blob_id = drmmode_prop_get_value (& tmp_props [DRMMODE_PLANE_IN_FORMATS_ASYNC ],
2753+ props , 0 );
27372754 drmmode_prop_info_copy (drmmode_crtc -> props_plane , tmp_props ,
27382755 DRMMODE_PLANE__COUNT , 1 );
27392756 } else {
@@ -2748,9 +2765,18 @@ drmmode_crtc_create_planes(xf86CrtcPtr crtc, int num)
27482765 drmmode_crtc -> num_formats = best_kplane -> count_formats ;
27492766 drmmode_crtc -> formats = calloc (best_kplane -> count_formats ,
27502767 sizeof (drmmode_format_rec ));
2751- if (!populate_format_modifiers (crtc , best_kplane , blob_id )) {
2768+ if (!populate_format_modifiers (crtc , best_kplane ,
2769+ drmmode_crtc -> formats , blob_id )) {
27522770 for (i = 0 ; i < best_kplane -> count_formats ; i ++ )
27532771 drmmode_crtc -> formats [i ].format = best_kplane -> formats [i ];
2772+ } else {
2773+ drmmode_crtc -> formats_async = calloc (best_kplane -> count_formats ,
2774+ sizeof (drmmode_format_rec ));
2775+ if (!populate_format_modifiers (crtc , best_kplane ,
2776+ drmmode_crtc -> formats_async , async_blob_id )) {
2777+ free (drmmode_crtc -> formats_async );
2778+ drmmode_crtc -> formats_async = NULL ;
2779+ }
27542780 }
27552781 drmModeFreePlane (best_kplane );
27562782 }
0 commit comments