@@ -89,13 +89,9 @@ pub struct DrmCrtcStateProps {
8989 pub gamma_lut_blob_id : Option < DrmPropertyValue < DrmBlob > > ,
9090}
9191
92- #[ derive( Default , Clone , Debug ) ]
92+ #[ derive( Clone , Debug , Reset ) ]
9393pub struct DrmConnectorState {
94- pub link_status : u64 ,
95- pub crtc_id : DrmCrtc ,
96- pub color_space : Option < u64 > ,
9794 pub hdr_metadata : Option < hdr_output_metadata > ,
98- pub hdr_metadata_blob_id : DrmBlob ,
9995 pub hdr_metadata_blob : Option < Rc < PropBlob > > ,
10096 pub locked : bool ,
10197 pub fb : DrmFb ,
@@ -111,6 +107,15 @@ pub struct DrmConnectorState {
111107 pub crtc_y : i32 ,
112108 pub crtc_w : i32 ,
113109 pub crtc_h : i32 ,
110+ pub props : DrmConnectorStateProps ,
111+ }
112+
113+ #[ derive( Clone , Debug , PrepareDrmObjectProperties ) ]
114+ pub struct DrmConnectorStateProps {
115+ pub link_status : DrmPropertyValue ,
116+ pub crtc_id : DrmPropertyValue < DrmCrtc > ,
117+ pub color_space : Option < DrmPropertyValue > ,
118+ pub hdr_metadata_blob_id : Option < DrmPropertyValue < DrmBlob > > ,
114119}
115120
116121struct PlaneConfig {
@@ -181,6 +186,7 @@ macro_rules! impl_props_deref {
181186
182187impl_props_deref ! ( DrmPlaneState , DrmPlaneStateProps ) ;
183188impl_props_deref ! ( DrmCrtcState , DrmCrtcStateProps ) ;
189+ impl_props_deref ! ( DrmConnectorState , DrmConnectorStateProps ) ;
184190
185191impl MetalConnector {
186192 pub fn create_transaction (
@@ -299,8 +305,8 @@ impl MetalDeviceTransaction {
299305 unused_crtcs. insert ( crtc. obj . id , ( ) ) ;
300306 }
301307 for ( _, connector) in & slf. connectors {
302- unused_crtcs. remove ( & connector. new . crtc_id ) ;
303- if let Some ( crtc) = slf. crtcs . get_mut ( & connector. new . crtc_id )
308+ unused_crtcs. remove ( & connector. new . crtc_id . value ) ;
309+ if let Some ( crtc) = slf. crtcs . get_mut ( & connector. new . crtc_id . value )
304310 && crtc. changed . is_empty ( )
305311 {
306312 crtc. changed . push ( connector. changed . clone ( ) ) ;
@@ -356,9 +362,9 @@ impl MetalDeviceTransaction {
356362 || dd. connection != ConnectorStatus :: Connected
357363 || state. non_desktop_override . unwrap_or ( dd. non_desktop )
358364 {
359- if connector. new . crtc_id . is_some ( ) {
360- unused_crtcs. insert ( connector. new . crtc_id , ( ) ) ;
361- if let Some ( crtc) = slf. crtcs . get ( & connector. new . crtc_id ) {
365+ if connector. new . crtc_id . value . is_some ( ) {
366+ unused_crtcs. insert ( connector. new . crtc_id . value , ( ) ) ;
367+ if let Some ( crtc) = slf. crtcs . get ( & connector. new . crtc_id . value ) {
362368 let planes = crtc_planes. get_mut ( & crtc. obj . id ) . unwrap ( ) ;
363369 for plane in [ & mut planes. primary , & mut planes. cursor ] {
364370 if plane. is_some ( ) {
@@ -371,11 +377,11 @@ impl MetalDeviceTransaction {
371377 * planes = CrtcPlanes :: default ( ) ;
372378 }
373379 }
374- connector. new = DrmConnectorState :: default ( ) ;
380+ connector. new . reset ( ) ;
375381 continue ;
376382 }
377- connector. new . link_status = DRM_LINK_STATUS_GOOD ;
378- if connector. new . crtc_id . is_none ( ) {
383+ connector. new . link_status . value = DRM_LINK_STATUS_GOOD ;
384+ if connector. new . crtc_id . value . is_none ( ) {
379385 let crtc_id = ' crtc_id: {
380386 for ( crtc, _) in & dd. crtcs {
381387 if unused_crtcs. contains ( crtc) {
@@ -387,9 +393,9 @@ impl MetalDeviceTransaction {
387393 ) ) ;
388394 } ;
389395 unused_crtcs. remove ( crtc_id) ;
390- connector. new . crtc_id = * crtc_id;
396+ connector. new . crtc_id . value = * crtc_id;
391397 }
392- let crtc = slf. crtcs . get_mut ( & connector. new . crtc_id ) . unwrap ( ) ;
398+ let crtc = slf. crtcs . get_mut ( & connector. new . crtc_id . value ) . unwrap ( ) ;
393399 crtc. new . active . value = state. active ;
394400 crtc. new . assigned_connector = connector. obj . id ;
395401 crtc. changed . push ( connector. changed . clone ( ) ) ;
@@ -767,9 +773,9 @@ impl MetalDeviceTransaction {
767773 }
768774 }
769775 if let Some ( cs) = & mut connector. new . color_space {
770- * cs = state. color_space . to_drm ( ) ;
776+ cs . value = state. color_space . to_drm ( ) ;
771777 }
772- if dd . hdr_metadata . is_some ( ) {
778+ if let Some ( prop ) = & mut connector . new . props . hdr_metadata_blob_id {
773779 let new = if state. eotf == BackendEotfs :: Default {
774780 None
775781 } else {
@@ -783,15 +789,15 @@ impl MetalDeviceTransaction {
783789 . master
784790 . create_blob ( new)
785791 . map_err ( BackendConnectorTransactionError :: CreateHdrMetadataBlob ) ?;
786- connector . new . hdr_metadata_blob_id = blob. id ( ) ;
792+ prop . value = blob. id ( ) ;
787793 connector. new . hdr_metadata_blob = Some ( Rc :: new ( blob) ) ;
788794 } else {
789- connector . new . hdr_metadata_blob_id = DrmBlob :: NONE ;
795+ prop . value = DrmBlob :: NONE ;
790796 connector. new . hdr_metadata_blob = None ;
791797 }
792798 connector. new . hdr_metadata = new;
793799 } else if new. is_none ( ) {
794- connector . new . hdr_metadata_blob_id = DrmBlob :: NONE ;
800+ prop . value = DrmBlob :: NONE ;
795801 connector. new . hdr_metadata_blob = None ;
796802 }
797803 }
@@ -815,18 +821,6 @@ impl MetalDeviceTransaction {
815821 }
816822}
817823
818- macro_rules! log_change {
819- ( $o: expr, $n: expr, $field: ident) => {
820- log:: log!(
821- LEVEL ,
822- "changed {}: {:?} -> {:?}" ,
823- stringify!( $field) ,
824- $o. $field,
825- $n. $field
826- ) ;
827- } ;
828- }
829-
830824impl MetalDeviceTransactionWithDrmState {
831825 pub fn calculate_change (
832826 mut self ,
@@ -870,43 +864,26 @@ impl MetalDeviceTransactionWithDrmState {
870864 let mut c = slf. dev . dev . master . change ( ) ;
871865 for ( _, connector) in & mut slf. connectors {
872866 let dd = & * connector. obj . display . borrow ( ) ;
873- let n = & mut connector. new ;
874- let o = & dd. drm_state ;
875- let changed = c. change_object ( connector. obj . id , |c| {
876- if n. link_status != o. link_status {
877- log_change ! ( o, n, link_status) ;
878- c. change ( dd. link_status , n. link_status ) ;
879- }
880- if n. crtc_id != o. crtc_id {
881- log_change ! ( o, n, crtc_id) ;
882- c. change ( dd. crtc_id , n. crtc_id ) ;
883- }
884- if let Some ( prop) = & dd. colorspace
885- && let Some ( new_cs) = n. color_space
886- && let Some ( old_cs) = o. color_space
887- && new_cs != old_cs
888- {
889- log_change ! ( o, n, color_space) ;
890- c. change ( * prop, new_cs) ;
891- }
892- if let Some ( prop) = & dd. hdr_metadata
893- && n. hdr_metadata_blob_id != o. hdr_metadata_blob_id
894- {
895- log_change ! ( o, n, hdr_metadata_blob_id) ;
896- c. change ( * prop, n. hdr_metadata_blob_id ) ;
897- }
898- reset_default_properties ! ( c, & dd. untyped_properties, & dd. default_properties) ;
899- } ) ;
900- if changed {
901- connector. changed . set ( true ) ;
902- }
867+ let n = & connector. new . props ;
868+ let o = & dd. drm_state . props ;
869+ let untyped_properties = & dd. untyped_properties ;
870+ let default_properties = & dd. default_properties ;
871+ let changed = n. differs ( o)
872+ || need_reset_default_properties ! ( untyped_properties, default_properties) ;
903873 log:: log!(
904874 LEVEL ,
905875 "connector {:?} (crtc {:?}) {}changed" ,
906- connector. obj. id,
907- connector. new. crtc_id,
876+ connector. obj. id. 0 ,
877+ connector. new. crtc_id. value . 0 ,
908878 if changed { "" } else { "un" } ,
909879 ) ;
880+ if changed {
881+ c. change_object ( connector. obj . id , |c| {
882+ n. prepare_conditional ( o, c, LOGGING ) ;
883+ reset_default_properties ! ( c, untyped_properties, default_properties) ;
884+ } ) ;
885+ connector. changed . set ( true ) ;
886+ }
910887 }
911888 for ( _, crtc) in & mut slf. crtcs {
912889 let n = & crtc. new . props ;
@@ -1023,14 +1000,14 @@ impl MetalDeviceTransactionWithChange {
10231000 continue ;
10241001 }
10251002 connector. obj . version . fetch_add ( 1 ) ;
1026- if connector. new . crtc_id . is_none ( ) {
1003+ if connector. new . crtc_id . value . is_none ( ) {
10271004 connector. obj . crtc . set ( None ) ;
10281005 connector. obj . primary_plane . set ( None ) ;
10291006 connector. obj . cursor_plane . set ( None ) ;
10301007 connector. obj . buffers . set ( None ) ;
10311008 connector. obj . cursor_buffers . set ( None ) ;
10321009 } else {
1033- let crtc = slf. crtcs . get ( & connector. new . crtc_id ) . unwrap ( ) ;
1010+ let crtc = slf. crtcs . get ( & connector. new . crtc_id . value ) . unwrap ( ) ;
10341011 crtc. obj . connector . set ( Some ( connector. obj . clone ( ) ) ) ;
10351012 connector. obj . crtc . set ( Some ( crtc. obj . clone ( ) ) ) ;
10361013 connector. obj . crtc_idle . set ( crtc. obj . pending_flip . is_none ( ) ) ;
0 commit comments