mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
ac97: extract moving to next buffer into function
Create a function move_to_next_buffer which handles incrementing civ and piv properly. Set the PICB register when that function is called, not when we read a guest buffer. BUG=chromium:968724 TEST=playback on-device Change-Id: Ib384efceeac4be0e056c20591d93fe32b7305db6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1954207 Reviewed-by: Fletcher Woodruff <fletcherw@chromium.org> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org> Commit-Queue: Fletcher Woodruff <fletcherw@chromium.org> Tested-by: Fletcher Woodruff <fletcherw@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
bf433ea9f6
commit
65588b2535
2 changed files with 11 additions and 4 deletions
|
@ -621,7 +621,8 @@ fn play_buffer(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// Moves to the next buffer for the given function and registers.
|
||||
// Marks the current buffer completed and moves to the next buffer for the given
|
||||
// function and registers.
|
||||
fn buffer_completed(
|
||||
regs: &mut Ac97BusMasterRegs,
|
||||
mem: &GuestMemory,
|
||||
|
@ -645,13 +646,12 @@ fn buffer_completed(
|
|||
if civ == lvi {
|
||||
new_sr |= SR_DCH | SR_CELV | SR_LVBCI;
|
||||
} else {
|
||||
let func_regs = regs.func_regs_mut(func);
|
||||
func_regs.civ = func_regs.piv;
|
||||
func_regs.piv = (func_regs.piv + 1) % 32; // move piv to the next buffer.
|
||||
regs.func_regs_mut(func).move_to_next_buffer();
|
||||
}
|
||||
|
||||
update_sr(regs, func, new_sr);
|
||||
|
||||
regs.func_regs_mut(func).picb = current_buffer_size(regs.func_regs(func), &mem)? as u16;
|
||||
if func == Ac97Function::Output {
|
||||
regs.po_pointer_update_time = Instant::now();
|
||||
}
|
||||
|
|
|
@ -243,4 +243,11 @@ impl Ac97FunctionRegs {
|
|||
}
|
||||
int_mask
|
||||
}
|
||||
|
||||
/// Sets the current buffer to the next buffer by updating CIV to PIV, and
|
||||
/// updates related fields.
|
||||
pub fn move_to_next_buffer(&mut self) {
|
||||
self.civ = self.piv;
|
||||
self.piv = (self.piv + 1) % 32; // move piv to the next buffer.
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue