Skip to content

Commit b89f3ab

Browse files
Documentation for the raw property value traits
1 parent 8082d12 commit b89f3ab

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

examples/modesetting-atomic.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,52 +72,52 @@ fn display_demo(card: &mut Card) -> Result<(), Error> {
7272
req.set_property(
7373
ObjectId::Connector(output.conn_id),
7474
output.conn_prop_ids.crtc_id,
75-
output.crtc_id as u64,
75+
output.crtc_id,
7676
);
7777
req.set_property(
7878
ObjectId::Crtc(output.crtc_id),
7979
output.crtc_prop_ids.active,
80-
1_u64,
80+
true,
8181
);
8282
req.set_property(
8383
ObjectId::Plane(output.plane_id),
8484
output.plane_prop_ids.fb_id,
85-
output.db.framebuffer_id() as u64,
85+
output.db.framebuffer_id(),
8686
);
8787
req.set_property(
8888
ObjectId::Plane(output.plane_id),
8989
output.plane_prop_ids.crtc_id,
90-
output.crtc_id as u64,
90+
output.crtc_id,
9191
);
9292
req.set_property(
9393
ObjectId::Plane(output.plane_id),
9494
output.plane_prop_ids.crtc_x,
95-
0_u64,
95+
0,
9696
);
9797
req.set_property(
9898
ObjectId::Plane(output.plane_id),
9999
output.plane_prop_ids.crtc_y,
100-
0_u64,
100+
0,
101101
);
102102
req.set_property(
103103
ObjectId::Plane(output.plane_id),
104104
output.plane_prop_ids.crtc_w,
105-
output.db.width() as u64,
105+
output.db.width(),
106106
);
107107
req.set_property(
108108
ObjectId::Plane(output.plane_id),
109109
output.plane_prop_ids.crtc_h,
110-
output.db.height() as u64,
110+
output.db.height(),
111111
);
112112
req.set_property(
113113
ObjectId::Plane(output.plane_id),
114114
output.plane_prop_ids.src_x,
115-
0_u64,
115+
0,
116116
);
117117
req.set_property(
118118
ObjectId::Plane(output.plane_id),
119119
output.plane_prop_ids.src_y,
120-
0_u64,
120+
0,
121121
);
122122
req.set_property(
123123
ObjectId::Plane(output.plane_id),

src/modeset/props.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,29 @@ impl ObjectPropEnumMember {
233233
}
234234
}
235235

236+
/// Trait implemented by types that can be borrowed as raw property values.
237+
///
238+
/// For types that represent references to other objects already known by
239+
/// the kernel, such as property blobs, the caller must keep the original
240+
/// object live for as long as the result is being used in requests to the
241+
/// kernel.
236242
pub trait AsRawPropertyValue {
237243
fn as_raw_property_value(&self) -> u64;
238244
}
239245

246+
/// Trait implemented by types that can be converted into raw property values
247+
/// while transferring ownership.
248+
///
249+
/// This is an extension of [`AsRawPropertyValue`] for situations where the
250+
/// recipient is taking ownership of the implementing object, so that the
251+
/// object can be kept live long enough to use its raw representation.
240252
pub trait IntoRawPropertyValue: AsRawPropertyValue {
253+
/// Return the raw `u64` representation to send to the kernel along with
254+
/// an optional object that needs to be kept live in order for that
255+
/// raw result to remain valid.
256+
///
257+
/// The first result should typically be the same as would be returned
258+
/// from [`AsRawPropertyValue::as_raw_property_value`].
241259
fn into_raw_property_value(self) -> (u64, Option<Box<dyn core::any::Any>>);
242260
}
243261

0 commit comments

Comments
 (0)