@@ -182,13 +182,36 @@ static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image,
182182 goto err ;
183183 }
184184
185- ret = drmModeSetPlane (p -> kms -> fd , p -> kms -> plane_id , p -> kms -> crtc_id , next_frame .fb_id , 0 ,
186- MP_ALIGN_DOWN (p -> dst .x0 , 2 ), MP_ALIGN_DOWN (p -> dst .y0 , 2 ), dstw , dsth ,
187- p -> src .x0 << 16 , p -> src .y0 << 16 , srcw << 16 , srch << 16 );
188- if (ret < 0 ) {
189- MP_ERR (hw , "Failed to set the plane %d (buffer %d).\n" , p -> kms -> plane_id ,
190- next_frame .fb_id );
191- goto err ;
185+ if (p -> kms -> hasAtomic ) {
186+ drmModeAtomicReq * req = drmModeAtomicAlloc ();
187+
188+ if (req ) {
189+ drm_add_plane_property (p -> kms , req , p -> kms -> plane_id , "FB_ID" , next_frame .fb_id );
190+ drm_add_plane_property (p -> kms , req , p -> kms -> plane_id , "CRTC_ID" , p -> kms -> crtc_id );
191+ drm_add_plane_property (p -> kms , req , p -> kms -> plane_id , "SRC_X" , p -> src .x0 << 16 );
192+ drm_add_plane_property (p -> kms , req , p -> kms -> plane_id , "SRC_Y" , p -> src .y0 << 16 );
193+ drm_add_plane_property (p -> kms , req , p -> kms -> plane_id , "SRC_W" , srcw << 16 );
194+ drm_add_plane_property (p -> kms , req , p -> kms -> plane_id , "SRC_H" , srch << 16 );
195+ drm_add_plane_property (p -> kms , req , p -> kms -> plane_id , "CRTC_X" , MP_ALIGN_DOWN (p -> dst .x0 , 2 ));
196+ drm_add_plane_property (p -> kms , req , p -> kms -> plane_id , "CRTC_Y" , MP_ALIGN_DOWN (p -> dst .y0 , 2 ));
197+ drm_add_plane_property (p -> kms , req , p -> kms -> plane_id , "CRTC_W" , dstw );
198+ drm_add_plane_property (p -> kms , req , p -> kms -> plane_id , "CRTC_H" , dsth );
199+
200+ ret = drmModeAtomicCommit (p -> kms -> fd , req , DRM_MODE_ATOMIC_NONBLOCK , NULL );
201+ if (ret )
202+ MP_ERR (hw , "Atomic commit failed with error code %d.\n" , ret );
203+ } else
204+ MP_ERR (hw , "Failed to create Atomic request\n" );
205+
206+ } else {
207+ ret = drmModeSetPlane (p -> kms -> fd , p -> kms -> plane_id , p -> kms -> crtc_id , next_frame .fb_id , 0 ,
208+ MP_ALIGN_DOWN (p -> dst .x0 , 2 ), MP_ALIGN_DOWN (p -> dst .y0 , 2 ), dstw , dsth ,
209+ p -> src .x0 << 16 , p -> src .y0 << 16 , srcw << 16 , srch << 16 );
210+ if (ret < 0 ) {
211+ MP_ERR (hw , "Failed to set the plane %d (buffer %d).\n" , p -> kms -> plane_id ,
212+ next_frame .fb_id );
213+ goto err ;
214+ }
192215 }
193216
194217 next_frame .image = hw_image ;
0 commit comments