Skip to content

Commit

Permalink
staging: fix rustfmt lints from previous commit
Browse files Browse the repository at this point in the history
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
  • Loading branch information
epilys committed Nov 24, 2023
1 parent 25ef9da commit 61d211d
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 52 deletions.
11 changes: 5 additions & 6 deletions staging/vhost-device-sound/src/audio_backends/alsa.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// Alsa backend
//
// Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
// SPDX-License-Identifier: Apache-2.0 or BSD-3-Clause
use std::{
Expand Down Expand Up @@ -734,6 +733,11 @@ impl AudioBackend for AlsaBackend {
start Start,
}

send_action! {
ctrl set_parameters SetParameters,
ctrl release Release,
}

fn stop(&self, id: u32) -> CrateResult<()> {
if let Some(Err(err)) = self
.streams
Expand All @@ -746,9 +750,4 @@ impl AudioBackend for AlsaBackend {
}
Ok(())
}

send_action! {
ctrl set_parameters SetParameters,
ctrl release Release,
}
}
2 changes: 1 addition & 1 deletion staging/vhost-device-sound/src/audio_backends/pipewire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl AudioBackend for PwBackend {
}
let mut param = [Pod::from_bytes(&value_clone).unwrap()];

//callback to negotiate new set of streams
// callback to negotiate new set of streams
stream
.update_params(&mut param)
.expect("could not update params");
Expand Down
4 changes: 2 additions & 2 deletions staging/vhost-device-sound/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,8 +698,8 @@ impl VhostUserSoundBackend {
}

impl VhostUserBackend for VhostUserSoundBackend {
type Vring = VringRwLock;
type Bitmap = ();
type Vring = VringRwLock;

fn num_queues(&self) -> usize {
NUM_QUEUES as usize
Expand Down Expand Up @@ -1104,7 +1104,7 @@ mod tests {

let queues_per_thread = backend.queues_per_thread();
assert_eq!(queues_per_thread.len(), 1);
assert_eq!(queues_per_thread[0], 0xf);
assert_eq!(queues_per_thread[0], 0xF);

let config = backend.get_config(0, 8);
assert_eq!(config.len(), 8);
Expand Down
8 changes: 4 additions & 4 deletions staging/vhost-device-sound/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ macro_rules! set_new_state {
}

impl PCMState {
pub fn new() -> Self {
Self::default()
}

set_new_state!(
set_parameters,
Self::SetParameters,
Expand All @@ -142,6 +138,10 @@ impl PCMState {
set_new_state!(stop, Self::Stop, Self::Start);

set_new_state!(release, Self::Release, Self::Prepare | Self::Stop);

pub fn new() -> Self {
Self::default()
}
}

impl std::fmt::Display for PCMState {
Expand Down
12 changes: 6 additions & 6 deletions staging/vhost-device-sound/src/virtio_sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ pub struct VirtioSoundJackInfo {
// reading its content from byte array.
unsafe impl ByteValued for VirtioSoundJackInfo {}

///If the VIRTIO_SND_JACK_F_REMAP feature bit is set in the jack information
/// If the VIRTIO_SND_JACK_F_REMAP feature bit is set in the jack information
/// Remap control request
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
#[repr(C)]
pub struct VirtioSoundJackRemap {
pub hdr: VirtioSoundJackHeader, /* .code = VIRTIO_SND_R_JACK_REMAP */
pub hdr: VirtioSoundJackHeader, // .code = VIRTIO_SND_R_JACK_REMAP
pub association: Le32,
pub sequence: Le32,
}
Expand All @@ -279,9 +279,9 @@ unsafe impl ByteValued for VirtioSoundPcmHeader {}
#[repr(C)]
pub struct VirtioSoundPcmInfo {
pub hdr: VirtioSoundInfo,
pub features: Le32, /* 1 << VIRTIO_SND_PCM_F_XXX */
pub formats: Le64, /* 1 << VIRTIO_SND_PCM_FMT_XXX */
pub rates: Le64, /* 1 << VIRTIO_SND_PCM_RATE_XXX */
pub features: Le32, // 1 << VIRTIO_SND_PCM_F_XXX
pub formats: Le64, // 1 << VIRTIO_SND_PCM_FMT_XXX
pub rates: Le64, // 1 << VIRTIO_SND_PCM_RATE_XXX
pub direction: u8,
pub channels_min: u8,
pub channels_max: u8,
Expand All @@ -299,7 +299,7 @@ pub struct VirtioSndPcmSetParams {
pub hdr: VirtioSoundPcmHeader,
pub buffer_bytes: Le32,
pub period_bytes: Le32,
pub features: Le32, /* 1 << VIRTIO_SND_PCM_F_XXX */
pub features: Le32, // 1 << VIRTIO_SND_PCM_F_XXX
pub channels: u8,
pub format: u8,
pub rate: u8,
Expand Down
8 changes: 5 additions & 3 deletions staging/vhost-device-video/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,11 @@ mod tests {
assert!(stream.is_queue_streaming(QueueType::InputQueue));
assert!(stream.all_resources_state(QueueType::InputQueue, ResourceState::Queued));
// Resource can be found by index
assert!(stream
.find_resource_mut_by_index(0, QueueType::InputQueue)
.is_some());
assert!(
stream
.find_resource_mut_by_index(0, QueueType::InputQueue)
.is_some()
);
{
let res = stream
.find_resource_mut(resource_id, QueueType::InputQueue)
Expand Down
2 changes: 1 addition & 1 deletion staging/vhost-device-video/src/vhu_video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ impl VuVideoBackend {

/// VhostUserBackend trait methods
impl VhostUserBackendMut for VuVideoBackend {
type Vring = VringRwLock;
type Bitmap = ();
type Vring = VringRwLock;

fn num_queues(&self) -> usize {
NUM_QUEUES
Expand Down
26 changes: 16 additions & 10 deletions staging/vhost-device-video/src/vhu_video_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,16 @@ mod tests {
#[rstest]
fn test_video_poller(dummy_fd: EventFd) {
let poller = VideoPoller::new().unwrap();
assert!(poller
.add(dummy_fd.as_raw_fd(), PollerEvent::new(EventType::Write, 1))
.is_ok());
assert!(poller
.modify(dummy_fd.as_raw_fd(), PollerEvent::new(EventType::Read, 1))
.is_ok());
assert!(
poller
.add(dummy_fd.as_raw_fd(), PollerEvent::new(EventType::Write, 1))
.is_ok()
);
assert!(
poller
.modify(dummy_fd.as_raw_fd(), PollerEvent::new(EventType::Read, 1))
.is_ok()
);

// Poller captures a read event.
dummy_fd.write(1).unwrap();
Expand Down Expand Up @@ -786,10 +790,12 @@ mod tests {
);
thread.mem = Some(mem.clone());

assert!(thread
.poller
.add(dummy_fd.as_raw_fd(), PollerEvent::new(EventType::Read, 1))
.is_ok());
assert!(
thread
.poller
.add(dummy_fd.as_raw_fd(), PollerEvent::new(EventType::Read, 1))
.is_ok()
);

let vring = VringRwLock::new(mem, 0x1000).unwrap();
vring.set_queue_info(0x100, 0x200, 0x300).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions staging/vhost-device-video/src/video.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0 or BSD-3-Clause
#![allow(dead_code)] //TODO: remove
#![allow(dead_code)] // TODO: remove
// Struct definitions use the kernel-style naming for consistency
#![allow(non_camel_case_types)]

Expand Down Expand Up @@ -311,7 +311,7 @@ impl VideoCmd {
) -> vhu_video::Result<Self> {
use self::VideoCmd::*;
macro_rules! read_body {
($a: expr) => {
($a:expr) => {
desc_chain.read_body(0, $a)
};
}
Expand Down
32 changes: 15 additions & 17 deletions staging/vhost-device-video/src/video_backends/v4l2_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,18 +398,16 @@ impl VideoBackend for V4L2Decoder {
for resource in stream.queued_resources_mut(queue_type) {
resource.ready_with(video::BufferFlags::ERR, 0);
}
/*
* QUEUE_CLEAR behaviour from virtio-video spec
* Return already queued buffers back from the input or the output queue
* of the device. The device SHOULD return all of the buffers from the
* respective queue as soon as possible without pushing the buffers through
* the processing pipeline.
*
* From v4l2 PoV we issue a VIDIOC_STREAMOFF on the queue which will abort
* or finish any DMA in progress, unlocks any user pointer buffers locked
* in physical memory, and it removes all buffers from the incoming and
* outgoing queues.
*/
// QUEUE_CLEAR behaviour from virtio-video spec
// Return already queued buffers back from the input or the output queue
// of the device. The device SHOULD return all of the buffers from the
// respective queue as soon as possible without pushing the buffers through
// the processing pipeline.
//
// From v4l2 PoV we issue a VIDIOC_STREAMOFF on the queue which will abort
// or finish any DMA in progress, unlocks any user pointer buffers locked
// in physical memory, and it removes all buffers from the incoming and
// outgoing queues.
if let Err(e) = v4l2r::ioctl::streamoff(stream, queue) {
warn!("streamoff failed: {}", e);
return Sync(video::CmdResponse::Error(InvalidParameter));
Expand Down Expand Up @@ -492,9 +490,9 @@ impl VideoBackend for V4L2Decoder {
return Sync(video::CmdResponse::Error(InvalidParameter));
};

/*if queue_type.direction() == v4l2r::QueueDirection::Capture {
todo!("compose on CAPTURE");
}*/
// if queue_type.direction() == v4l2r::QueueDirection::Capture {
// todo!("compose on CAPTURE");
// }

Sync(video::CmdResponse::OkNoData)
}
Expand Down Expand Up @@ -891,7 +889,7 @@ mod tests {
Some(v4l2_fmtdesc {
index,
type_: v4l2r::bindings::v4l2_buf_type_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
pixelformat: 0x3231564e, // NV12
pixelformat: 0x3231564E, // NV12
// SAFETY: test environment only.
..unsafe { mem::zeroed() }
})
Expand Down Expand Up @@ -1106,7 +1104,7 @@ mod tests {
fn test_v4l2_backend_helpers(test_dir: TempDir) {
let v4l2_device = VideoDeviceMock::new(&test_dir);
let decoder = V4L2Decoder::new(Path::new(&v4l2_device.path)).unwrap();
let nv12 = u32::from_le(0x3231564e);
let nv12 = u32::from_le(0x3231564E);
assert_matches!(
V4L2Decoder::v4l2_get_selection(&decoder.video_device, video::QueueType::InputQueue),
None
Expand Down

0 comments on commit 61d211d

Please sign in to comment.