|
| 1 | +//! Graphics ioctl constants |
| 2 | +
|
| 3 | +/// Clear the screen |
| 4 | +/// |
| 5 | +/// The corresponding value is the fill colour, which is taken modulo the number of on-screen colours. |
| 6 | +pub const COMMAND_CLEAR_SCREEN: u64 = 0; |
| 7 | + |
| 8 | +/// Plot a chunky pixel |
| 9 | +/// |
| 10 | +/// The command contains [ x | y | mode | colour ]. |
| 11 | +/// |
| 12 | +/// * `x` is 16 bits and marks the horizontal position (0 is left) |
| 13 | +/// * `y` is 16 bits and marks the vertical position (0 is top) |
| 14 | +/// * `mode` is 8 bits and is currently ignored |
| 15 | +/// * `colour` is 24 bits, and is taken modulo the number of on-screen colours |
| 16 | +/// |
| 17 | +/// Use [`chunky_plot_value`] to create a suitable value for this ioctl command. |
| 18 | +pub const COMMAND_CHUNKY_PLOT: u64 = 1; |
| 19 | + |
| 20 | +/// Change graphics mode |
| 21 | +/// |
| 22 | +/// The command contains the video mode in the upper 32 bits and a pointer to a |
| 23 | +/// framebuffer in the lower 32 bits. |
| 24 | +/// |
| 25 | +/// The framebuffer pointer must point to a 32-bit aligned region of memory |
| 26 | +/// that is large enough for the selected mode. If you pass `null`, then the OS |
| 27 | +/// will attempt to allocate a framebuffer for you. |
| 28 | +/// |
| 29 | +/// Use [`change_mode_value`] to construct a value. |
| 30 | +pub const COMMAND_CHANGE_MODE: u64 = 2; |
| 31 | + |
| 32 | +/// Calculate a 64-bit value argument for a gfx ioctl |
| 33 | +pub fn chunky_plot_value(x: u16, y: u16, colour: u32) -> u64 { |
| 34 | + (x as u64) << 48 | (y as u64) << 32 | (colour & 0xFFFFFF) as u64 |
| 35 | +} |
| 36 | + |
| 37 | +/// Calculate a 64-bit value argument for a gfx ioctl |
| 38 | +pub fn change_mode_value(mode: crate::VideoMode, fb_ptr: *mut u32) -> u64 { |
| 39 | + let fb_ptr = fb_ptr as usize as u64; |
| 40 | + let mode = mode.as_u8() as u64; |
| 41 | + mode << 32 | fb_ptr |
| 42 | +} |
| 43 | + |
| 44 | +// End of file |
0 commit comments