mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
clean up the suspend/resume path for the screen and enforce redraw
This commit is contained in:
parent
c8382a671a
commit
1455ea6d8b
4 changed files with 44 additions and 89 deletions
|
|
@ -93,9 +93,6 @@ pub(crate) enum Opcode {
|
||||||
/// draws the sleep screen; assumes requests are vetted by GAM/xous-names
|
/// draws the sleep screen; assumes requests are vetted by GAM/xous-names
|
||||||
DrawSleepScreen,
|
DrawSleepScreen,
|
||||||
|
|
||||||
/// sets whether a sleep note should be rendered or not on suspend
|
|
||||||
SetSleepNote,
|
|
||||||
|
|
||||||
/// permanently turns on the Devboot mark
|
/// permanently turns on the Devboot mark
|
||||||
Devboot,
|
Devboot,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,11 +57,11 @@ impl XousDisplay {
|
||||||
.expect("couldn't map control port");
|
.expect("couldn't map control port");
|
||||||
|
|
||||||
let mut display = XousDisplay {
|
let mut display = XousDisplay {
|
||||||
fb: fb,
|
fb,
|
||||||
hwfb: hwfb,
|
hwfb,
|
||||||
csr: CSR::new(control.as_mut_ptr() as *mut u32),
|
csr: CSR::new(control.as_mut_ptr() as *mut u32),
|
||||||
susres: RegManager::new(control.as_mut_ptr() as *mut u32),
|
susres: RegManager::new(control.as_mut_ptr() as *mut u32),
|
||||||
srfb: ManagedMem::new(hwfb),
|
srfb: ManagedMem::new(fb),
|
||||||
};
|
};
|
||||||
|
|
||||||
display.set_clock(CONFIG_CLOCK_FREQUENCY);
|
display.set_clock(CONFIG_CLOCK_FREQUENCY);
|
||||||
|
|
@ -80,69 +80,62 @@ impl XousDisplay {
|
||||||
display
|
display
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn suspend(&mut self, draw_note: bool) {
|
pub fn suspend(&mut self) {
|
||||||
while self.busy() {
|
while self.busy() {
|
||||||
// just wait until any pending FB operations are done
|
// just wait until any pending FB operations are done
|
||||||
}
|
}
|
||||||
|
let fb: *mut [u32; FB_SIZE] = self.fb.as_mut_ptr() as *mut [u32; FB_SIZE];
|
||||||
|
for lines in 0..FB_LINES {
|
||||||
|
// set the dirty bits prior to stashing the frame buffer
|
||||||
|
unsafe {
|
||||||
|
(*fb)[lines * FB_WIDTH_WORDS + (FB_WIDTH_WORDS - 1)] |= 0x1_0000;
|
||||||
|
}
|
||||||
|
}
|
||||||
self.srfb.suspend();
|
self.srfb.suspend();
|
||||||
self.susres.suspend();
|
self.susres.suspend();
|
||||||
|
|
||||||
if draw_note {
|
let note = crate::sleep_note::LOGO_MAP;
|
||||||
let note = crate::sleep_note::LOGO_MAP;
|
let note_lines = note.len() / FB_WIDTH_WORDS;
|
||||||
let note_lines = note.len() / FB_WIDTH_WORDS;
|
let note_start_line = (FB_LINES - note_lines) / 2;
|
||||||
let note_start_line = (FB_LINES - note_lines) / 2;
|
let note_end_line = note_start_line + note_lines;
|
||||||
let note_end_line = note_start_line + note_lines;
|
let hwfb: *mut [u32; FB_SIZE] = self.hwfb.as_mut_ptr() as *mut [u32; FB_SIZE];
|
||||||
let hwfb: *mut [u32; FB_SIZE] = self.hwfb.as_mut_ptr() as *mut [u32; FB_SIZE];
|
|
||||||
|
|
||||||
for lines in 0..FB_LINES {
|
for lines in 0..FB_LINES {
|
||||||
for words in 0..FB_WIDTH_WORDS {
|
for words in 0..FB_WIDTH_WORDS {
|
||||||
if lines >= note_start_line && lines < note_end_line {
|
if lines >= note_start_line && lines < note_end_line {
|
||||||
// We're on a line that has the 'Sleeping...' note.
|
// We're on a line that has the 'Sleeping...' note.
|
||||||
// Draw it into the frame buffer.
|
// Draw it into the frame buffer.
|
||||||
let note_index = ((lines - note_start_line) * FB_WIDTH_WORDS) + words;
|
let note_index = ((lines - note_start_line) * FB_WIDTH_WORDS) + words;
|
||||||
unsafe {
|
unsafe {
|
||||||
(*hwfb)[words + lines * FB_WIDTH_WORDS] = note[note_index];
|
(*hwfb)[words + lines * FB_WIDTH_WORDS] = note[note_index];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// We're not on a line that has the note. Clear the pixels,
|
// We're not on a line that has the note. Clear the pixels,
|
||||||
// since we don't want any secrets to linger in the framebuffer
|
// since we don't want any secrets to linger in the framebuffer
|
||||||
// and stay visible on the persistent display while the device is
|
// and stay visible on the persistent display while the device is
|
||||||
// sleeping.
|
// sleeping.
|
||||||
unsafe {
|
unsafe {
|
||||||
(*hwfb)[words + lines * FB_WIDTH_WORDS] = 0xFFFF_FFFF;
|
(*hwfb)[words + lines * FB_WIDTH_WORDS] = 0xFFFF_FFFF;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the dirty bits
|
|
||||||
unsafe {
|
|
||||||
(*hwfb)[lines * FB_WIDTH_WORDS + (FB_WIDTH_WORDS - 1)] |= 0x1_0000;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.update_dirty();
|
// set the dirty bits
|
||||||
while self.busy() {
|
unsafe {
|
||||||
// busy wait, blocking suspend until this has happened
|
(*hwfb)[lines * FB_WIDTH_WORDS + (FB_WIDTH_WORDS - 1)] |= 0x1_0000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.update_dirty();
|
||||||
|
while self.busy() {
|
||||||
|
// busy wait, blocking suspend until this has happened
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn resume(&mut self, drew_note: bool) {
|
pub fn resume(&mut self) {
|
||||||
self.susres.resume();
|
self.susres.resume();
|
||||||
self.srfb.resume();
|
self.srfb.resume();
|
||||||
|
|
||||||
if drew_note {
|
self.redraw();
|
||||||
let hwfb: *mut [u32; FB_SIZE] = self.hwfb.as_mut_ptr() as *mut [u32; FB_SIZE];
|
|
||||||
for lines in 0..FB_LINES {
|
|
||||||
// set the dirty bits of all lines to force a redraw of the restored data
|
|
||||||
unsafe {
|
|
||||||
(*hwfb)[lines * FB_WIDTH_WORDS + (FB_WIDTH_WORDS - 1)] |= 0x1_0000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.update_dirty();
|
|
||||||
while self.busy() {
|
|
||||||
// busy wait, blocking resume until this has happened
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn screen_size(&self) -> Point {
|
pub fn screen_size(&self) -> Point {
|
||||||
|
|
|
||||||
|
|
@ -217,15 +217,6 @@ impl Gfx {
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_sleep_note(&self, flag: bool) -> Result<(), xous::Error> {
|
|
||||||
let arg = if flag { 1 } else { 0 };
|
|
||||||
send_message(
|
|
||||||
self.conn,
|
|
||||||
Message::new_scalar(Opcode::SetSleepNote.to_usize().unwrap(), arg, 0, 0, 0),
|
|
||||||
)
|
|
||||||
.map(|_| ())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// this is a one-way door, once you've set it, you can't unset it.
|
/// this is a one-way door, once you've set it, you can't unset it.
|
||||||
pub fn set_devboot(&self, enable: bool) -> Result<(), xous::Error> {
|
pub fn set_devboot(&self, enable: bool) -> Result<(), xous::Error> {
|
||||||
let ena = if enable { 1 } else { 0 };
|
let ena = if enable { 1 } else { 0 };
|
||||||
|
|
|
||||||
|
|
@ -111,25 +111,6 @@ fn xmain() -> ! {
|
||||||
draw_boot_logo(&mut display);
|
draw_boot_logo(&mut display);
|
||||||
|
|
||||||
let fontregion = map_fonts();
|
let fontregion = map_fonts();
|
||||||
|
|
||||||
let mut use_sleep_note = true;
|
|
||||||
if false {
|
|
||||||
// leave this test case around
|
|
||||||
// for some reason, the top right quadrant draws an extra pixel inside the fill area
|
|
||||||
// when a fill color of "Light" is specified. However, if `None` fill is specified, it
|
|
||||||
// works correctly. This is really puzzling, because the test for filled drawing happens
|
|
||||||
// after the test for border drawing.
|
|
||||||
use api::Point;
|
|
||||||
let mut r = Rectangle::new(Point::new(20, 200), Point::new(151, 301));
|
|
||||||
r.style = DrawStyle {
|
|
||||||
fill_color: Some(PixelColor::Light),
|
|
||||||
stroke_color: Some(PixelColor::Dark),
|
|
||||||
stroke_width: 1,
|
|
||||||
};
|
|
||||||
let rr = RoundedRectangle::new(r, 16);
|
|
||||||
op::rounded_rectangle(display.native_buffer(), rr, None);
|
|
||||||
}
|
|
||||||
|
|
||||||
let screen_clip = Rectangle::new(Point::new(0, 0), display.screen_size());
|
let screen_clip = Rectangle::new(Point::new(0, 0), display.screen_size());
|
||||||
|
|
||||||
display.redraw();
|
display.redraw();
|
||||||
|
|
@ -148,18 +129,11 @@ fn xmain() -> ! {
|
||||||
log::trace!("Message: {:?}", msg);
|
log::trace!("Message: {:?}", msg);
|
||||||
match FromPrimitive::from_usize(msg.body.id()) {
|
match FromPrimitive::from_usize(msg.body.id()) {
|
||||||
Some(Opcode::SuspendResume) => xous::msg_scalar_unpack!(msg, token, _, _, _, {
|
Some(Opcode::SuspendResume) => xous::msg_scalar_unpack!(msg, token, _, _, _, {
|
||||||
display.suspend(use_sleep_note);
|
display.suspend();
|
||||||
susres
|
susres
|
||||||
.suspend_until_resume(token)
|
.suspend_until_resume(token)
|
||||||
.expect("couldn't execute suspend/resume");
|
.expect("couldn't execute suspend/resume");
|
||||||
display.resume(use_sleep_note);
|
display.resume();
|
||||||
}),
|
|
||||||
Some(Opcode::SetSleepNote) => xous::msg_scalar_unpack!(msg, set_use, _, _, _, {
|
|
||||||
if set_use == 0 {
|
|
||||||
use_sleep_note = false;
|
|
||||||
} else {
|
|
||||||
use_sleep_note = true;
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
Some(Opcode::DrawClipObject) => {
|
Some(Opcode::DrawClipObject) => {
|
||||||
let buffer =
|
let buffer =
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue