@@ -441,13 +441,14 @@ void modeset_output_destroy(int fd, struct modeset_output *out)
441441 free (out );
442442}
443443
444- struct modeset_output * modeset_output_create (int fd , drmModeRes * res , drmModeConnector * conn , uint16_t mode_width , uint16_t mode_height , uint32_t mode_vrefresh , uint32_t video_plane_id , uint32_t osd_plane_id )
444+ struct modeset_output * modeset_output_create (int fd , drmModeRes * res , drmModeConnector * conn , uint16_t mode_width , uint16_t mode_height , uint32_t mode_vrefresh , uint32_t video_plane_id , uint32_t osd_plane_id , float video_scale_factor )
445445{
446446 int ret ;
447447 struct modeset_output * out ;
448448
449449 out = malloc (sizeof (* out ));
450450 memset (out , 0 , sizeof (* out ));
451+ out -> video_scale_factor = video_scale_factor ;
451452 out -> connector .id = conn -> connector_id ;
452453
453454 if (conn -> connection != DRM_MODE_CONNECTED ) {
@@ -587,7 +588,7 @@ void *modeset_print_modes(int fd)
587588
588589}
589590
590- struct modeset_output * modeset_prepare (int fd , uint16_t mode_width , uint16_t mode_height , uint32_t mode_vrefresh , uint32_t video_plane_id , uint32_t osd_plane_id )
591+ struct modeset_output * modeset_prepare (int fd , uint16_t mode_width , uint16_t mode_height , uint32_t mode_vrefresh , uint32_t video_plane_id , uint32_t osd_plane_id , float video_scale_factor )
591592{
592593 drmModeRes * res ;
593594 drmModeConnector * conn ;
@@ -609,7 +610,7 @@ struct modeset_output *modeset_prepare(int fd, uint16_t mode_width, uint16_t mod
609610 continue ;
610611 }
611612
612- out = modeset_output_create (fd , res , conn , mode_width , mode_height , mode_vrefresh , video_plane_id , osd_plane_id );
613+ out = modeset_output_create (fd , res , conn , mode_width , mode_height , mode_vrefresh , video_plane_id , osd_plane_id , video_scale_factor );
613614 drmModeFreeConnector (conn );
614615 if (out ) {
615616 drmModeFreeResources (res );
@@ -671,16 +672,22 @@ int modeset_atomic_prepare_commit(int fd, struct modeset_output *out, drmModeAto
671672 if (set_drm_object_property (req , plane , "SRC_H" , height << 16 ) < 0 )
672673 return -1 ;
673674
674- uint32_t crtcw = out -> video_crtc_width ;
675- uint32_t crtch = out -> video_crtc_height ;
676- float video_ratio = (float )width / height ;
677- if (crtcw / video_ratio > crtch ) {
678- crtcw = crtch * video_ratio ;
679- crtch = crtch ;
675+ uint32_t orig_crtcw = out -> video_crtc_width ;
676+ uint32_t orig_crtch = out -> video_crtc_height ;
677+ float video_ratio = (float )width / height ;
678+ if (orig_crtcw / video_ratio > orig_crtch ) {
679+ orig_crtcw = orig_crtch * video_ratio ;
680+ orig_crtch = orig_crtch ;
680681 } else {
681- crtcw = crtcw ;
682- crtch = crtcw / video_ratio ;
682+ orig_crtcw = orig_crtcw ;
683+ orig_crtch = orig_crtcw / video_ratio ;
683684 }
685+
686+
687+ float scale_factor = out -> video_scale_factor ;
688+ uint32_t crtcw = (uint32_t )(orig_crtcw * scale_factor );
689+ uint32_t crtch = (uint32_t )(orig_crtch * scale_factor );
690+
684691 int crtcx = (out -> video_crtc_width - crtcw ) / 2 ;
685692 int crtcy = (out -> video_crtc_height - crtch ) / 2 ;
686693 if (set_drm_object_property (req , plane , "CRTC_X" , crtcx ) < 0 )
0 commit comments