pub struct AtomicRequest { /* private fields */ }
Expand description
An atomic modesetting commit request.
Implementations§
Source§impl AtomicRequest
impl AtomicRequest
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/modesetting-atomic.rs (line 62)
60fn display_demo(card: &mut Card) -> Result<(), Error> {
61 let mut outputs = prepare_outputs(&card)?;
62 let mut req = linux_drm::modeset::AtomicRequest::new();
63
64 for output in &mut outputs {
65 println!("preparing output {output:#?}");
66 let conn = card.connector_state(output.conn_id)?;
67
68 let mode = &output.mode;
69 let mode_name = String::from_utf8_lossy(&mode.name);
70 println!(
71 "{:?} connector uses {mode_name} ({}x{}@{}Hz)",
72 conn.connector_type, mode.hdisplay, mode.vdisplay, mode.vrefresh,
73 );
74
75 let rows = output.db.height() as usize;
76 let pitch = output.db.pitch() as usize;
77 let data = output.db.buffer_mut();
78 for i in 0..rows {
79 if (i % 8) > 3 {
80 let row = &mut data[(i * pitch)..(i * pitch) + pitch];
81 row.fill(0xff);
82 }
83 }
84
85 println!(
86 "configuring CRTC {:?} for framebuffer {:?} and mode {mode_name} on connector {:?}",
87 output.crtc_id,
88 output.db.framebuffer_id(),
89 conn.id
90 );
91
92 req.set_property(
93 ObjectId::Connector(output.conn_id),
94 output.conn_prop_ids.crtc_id,
95 output.crtc_id,
96 );
97 req.set_property(
98 ObjectId::Crtc(output.crtc_id),
99 output.crtc_prop_ids.active,
100 true,
101 );
102 req.set_property(
103 ObjectId::Plane(output.plane_id),
104 output.plane_prop_ids.fb_id,
105 output.db.framebuffer_id(),
106 );
107 req.set_property(
108 ObjectId::Plane(output.plane_id),
109 output.plane_prop_ids.crtc_id,
110 output.crtc_id,
111 );
112 req.set_property(
113 ObjectId::Plane(output.plane_id),
114 output.plane_prop_ids.crtc_x,
115 0,
116 );
117 req.set_property(
118 ObjectId::Plane(output.plane_id),
119 output.plane_prop_ids.crtc_y,
120 0,
121 );
122 req.set_property(
123 ObjectId::Plane(output.plane_id),
124 output.plane_prop_ids.crtc_w,
125 output.db.width(),
126 );
127 req.set_property(
128 ObjectId::Plane(output.plane_id),
129 output.plane_prop_ids.crtc_h,
130 output.db.height(),
131 );
132 req.set_property(
133 ObjectId::Plane(output.plane_id),
134 output.plane_prop_ids.src_x,
135 0,
136 );
137 req.set_property(
138 ObjectId::Plane(output.plane_id),
139 output.plane_prop_ids.src_y,
140 0,
141 );
142 req.set_property(
143 ObjectId::Plane(output.plane_id),
144 output.plane_prop_ids.src_w,
145 (output.db.width() as u64) << 16,
146 );
147 req.set_property(
148 ObjectId::Plane(output.plane_id),
149 output.plane_prop_ids.src_h,
150 (output.db.height() as u64) << 16,
151 );
152 }
153
154 println!("atomic commit {req:#?}");
155 card.atomic_commit(
156 &req,
157 AtomicCommitFlags::ALLOW_MODESET | AtomicCommitFlags::PAGE_FLIP_EVENT,
158 0,
159 )?;
160
161 let mut evt_buf = vec![0_u8; 1024];
162 loop {
163 println!("waiting for events (send SIGINT to exit)");
164 for evt in card.read_events(&mut evt_buf)? {
165 println!("event {evt:?}");
166 match evt {
167 DrmEvent::Generic(GenericDrmEvent::FlipComplete(_)) => {
168 // In a real program this would be a time place to draw the next frame
169 // for the reported crtc.
170 }
171 _ => {
172 // Ignore any unrecognized event types.
173 }
174 }
175 }
176 }
177}
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Clear any previously-set properties, returning the object to empty.
This function does, however, retain any allocated capacity for property-set requests for existing objects, so callers can avoid making lots of dynamic memory allocations on every change by retaining and reusing a single request object. This optimization will only be productive if the object is reused to set a similar set of properties on a similar set of objects.
Sourcepub fn set_property(
&mut self,
obj_id: impl Into<ObjectId>,
prop_id: PropertyId,
value: impl IntoRawPropertyValue,
)
pub fn set_property( &mut self, obj_id: impl Into<ObjectId>, prop_id: PropertyId, value: impl IntoRawPropertyValue, )
Examples found in repository?
examples/modesetting-atomic.rs (lines 92-96)
60fn display_demo(card: &mut Card) -> Result<(), Error> {
61 let mut outputs = prepare_outputs(&card)?;
62 let mut req = linux_drm::modeset::AtomicRequest::new();
63
64 for output in &mut outputs {
65 println!("preparing output {output:#?}");
66 let conn = card.connector_state(output.conn_id)?;
67
68 let mode = &output.mode;
69 let mode_name = String::from_utf8_lossy(&mode.name);
70 println!(
71 "{:?} connector uses {mode_name} ({}x{}@{}Hz)",
72 conn.connector_type, mode.hdisplay, mode.vdisplay, mode.vrefresh,
73 );
74
75 let rows = output.db.height() as usize;
76 let pitch = output.db.pitch() as usize;
77 let data = output.db.buffer_mut();
78 for i in 0..rows {
79 if (i % 8) > 3 {
80 let row = &mut data[(i * pitch)..(i * pitch) + pitch];
81 row.fill(0xff);
82 }
83 }
84
85 println!(
86 "configuring CRTC {:?} for framebuffer {:?} and mode {mode_name} on connector {:?}",
87 output.crtc_id,
88 output.db.framebuffer_id(),
89 conn.id
90 );
91
92 req.set_property(
93 ObjectId::Connector(output.conn_id),
94 output.conn_prop_ids.crtc_id,
95 output.crtc_id,
96 );
97 req.set_property(
98 ObjectId::Crtc(output.crtc_id),
99 output.crtc_prop_ids.active,
100 true,
101 );
102 req.set_property(
103 ObjectId::Plane(output.plane_id),
104 output.plane_prop_ids.fb_id,
105 output.db.framebuffer_id(),
106 );
107 req.set_property(
108 ObjectId::Plane(output.plane_id),
109 output.plane_prop_ids.crtc_id,
110 output.crtc_id,
111 );
112 req.set_property(
113 ObjectId::Plane(output.plane_id),
114 output.plane_prop_ids.crtc_x,
115 0,
116 );
117 req.set_property(
118 ObjectId::Plane(output.plane_id),
119 output.plane_prop_ids.crtc_y,
120 0,
121 );
122 req.set_property(
123 ObjectId::Plane(output.plane_id),
124 output.plane_prop_ids.crtc_w,
125 output.db.width(),
126 );
127 req.set_property(
128 ObjectId::Plane(output.plane_id),
129 output.plane_prop_ids.crtc_h,
130 output.db.height(),
131 );
132 req.set_property(
133 ObjectId::Plane(output.plane_id),
134 output.plane_prop_ids.src_x,
135 0,
136 );
137 req.set_property(
138 ObjectId::Plane(output.plane_id),
139 output.plane_prop_ids.src_y,
140 0,
141 );
142 req.set_property(
143 ObjectId::Plane(output.plane_id),
144 output.plane_prop_ids.src_w,
145 (output.db.width() as u64) << 16,
146 );
147 req.set_property(
148 ObjectId::Plane(output.plane_id),
149 output.plane_prop_ids.src_h,
150 (output.db.height() as u64) << 16,
151 );
152 }
153
154 println!("atomic commit {req:#?}");
155 card.atomic_commit(
156 &req,
157 AtomicCommitFlags::ALLOW_MODESET | AtomicCommitFlags::PAGE_FLIP_EVENT,
158 0,
159 )?;
160
161 let mut evt_buf = vec![0_u8; 1024];
162 loop {
163 println!("waiting for events (send SIGINT to exit)");
164 for evt in card.read_events(&mut evt_buf)? {
165 println!("event {evt:?}");
166 match evt {
167 DrmEvent::Generic(GenericDrmEvent::FlipComplete(_)) => {
168 // In a real program this would be a time place to draw the next frame
169 // for the reported crtc.
170 }
171 _ => {
172 // Ignore any unrecognized event types.
173 }
174 }
175 }
176 }
177}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AtomicRequest
impl !RefUnwindSafe for AtomicRequest
impl !Send for AtomicRequest
impl !Sync for AtomicRequest
impl Unpin for AtomicRequest
impl !UnwindSafe for AtomicRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more