summary refs log tree commit diff
path: root/resources
diff options
context:
space:
mode:
authorZach Reizner <zachr@google.com>2018-10-03 10:22:32 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-10-09 21:14:05 -0700
commit55a9e504beef368bd97e51ffd5a7fa6c034eb8ad (patch)
tree894d8685e2fdfa105ea35d1cb6cfceee06502c7a /resources
parent046df60760f3b0691f23c27a7f24a96c9afe8c05 (diff)
downloadcrosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.gz
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.bz2
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.lz
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.xz
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.tar.zst
crosvm-55a9e504beef368bd97e51ffd5a7fa6c034eb8ad.zip
cargo fmt all source code
Now that cargo fmt has landed, run it over everything at once to bring
rust source to the standard formatting.

TEST=cargo test
BUG=None

Change-Id: Ic95a48725e5a40dcbd33ba6d5aef2bd01e91865b
Reviewed-on: https://chromium-review.googlesource.com/1259287
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'resources')
-rw-r--r--resources/src/gpu_allocator.rs30
-rw-r--r--resources/src/system_allocator.rs37
2 files changed, 45 insertions, 22 deletions
diff --git a/resources/src/gpu_allocator.rs b/resources/src/gpu_allocator.rs
index ea38ba4..9f98bcf 100644
--- a/resources/src/gpu_allocator.rs
+++ b/resources/src/gpu_allocator.rs
@@ -42,8 +42,12 @@ pub trait GpuMemoryAllocator {
     /// * `width` - Width of buffer.
     /// * `height` - Height of buffer.
     /// * `format` - Fourcc format of buffer.
-    fn allocate(&self, width: u32, height: u32, format: u32)
-        -> sys_util::Result<(File, GpuMemoryDesc)>;
+    fn allocate(
+        &self,
+        width: u32,
+        height: u32,
+        format: u32,
+    ) -> sys_util::Result<(File, GpuMemoryDesc)>;
 }
 
 #[cfg(feature = "wl-dmabuf")]
@@ -53,9 +57,12 @@ pub struct GpuBufferDevice {
 
 #[cfg(feature = "wl-dmabuf")]
 impl GpuMemoryAllocator for GpuBufferDevice {
-    fn allocate(&self, width: u32, height: u32, format: u32) ->
-        sys_util::Result<(File, GpuMemoryDesc)>
-    {
+    fn allocate(
+        &self,
+        width: u32,
+        height: u32,
+        format: u32,
+    ) -> sys_util::Result<(File, GpuMemoryDesc)> {
         let buffer = match self.device.create_buffer(
             width,
             height,
@@ -66,7 +73,8 @@ impl GpuMemoryAllocator for GpuBufferDevice {
             // fall-back to a less efficient meachnisms for presentation if
             // neccesary. In practice, linear buffers for commonly used formats
             // will also support scanout and texturing.
-            gpu_buffer::Flags::empty().use_linear(true)) {
+            gpu_buffer::Flags::empty().use_linear(true),
+        ) {
             Ok(v) => v,
             Err(_) => return Err(sys_util::Error::new(EINVAL)),
         };
@@ -81,8 +89,10 @@ impl GpuMemoryAllocator for GpuBufferDevice {
         for i in 0..buffer.num_planes() {
             // Use stride and offset for plane if handle matches first plane.
             if buffer.plane_handle(i) == buffer.plane_handle(0) {
-                desc.planes[i] = GpuMemoryPlaneDesc { stride: buffer.plane_stride(i),
-                                                      offset: buffer.plane_offset(i) }
+                desc.planes[i] = GpuMemoryPlaneDesc {
+                    stride: buffer.plane_stride(i),
+                    offset: buffer.plane_offset(i),
+                }
             }
         }
 
@@ -95,8 +105,8 @@ pub fn create_gpu_memory_allocator() -> Result<Option<Box<GpuMemoryAllocator>>,
     let undesired: &[&str] = &["vgem", "pvr"];
     let fd = gpu_buffer::rendernode::open_device(undesired)
         .map_err(|_| GpuAllocatorError::OpenGpuBufferDevice)?;
-    let device = gpu_buffer::Device::new(fd)
-        .map_err(|_| GpuAllocatorError::CreateGpuBufferDevice)?;
+    let device =
+        gpu_buffer::Device::new(fd).map_err(|_| GpuAllocatorError::CreateGpuBufferDevice)?;
     Ok(Some(Box::new(GpuBufferDevice { device })))
 }
 
diff --git a/resources/src/system_allocator.rs b/resources/src/system_allocator.rs
index 4ca04ae..57618ac 100644
--- a/resources/src/system_allocator.rs
+++ b/resources/src/system_allocator.rs
@@ -43,11 +43,16 @@ impl SystemAllocator {
     /// * `mmio_size` - The size of MMIO space.
     /// * `create_gpu_allocator` - If true, enable gpu memory allocation.
     /// * `first_irq` - The first irq number to give out.
-    fn new(io_base: Option<u64>, io_size: Option<u64>,
-           dev_base: u64, dev_size: u64,
-           mmio_base: u64, mmio_size: u64,
-           create_gpu_allocator: bool,
-           first_irq: u32) -> Option<Self> {
+    fn new(
+        io_base: Option<u64>,
+        io_size: Option<u64>,
+        dev_base: u64,
+        dev_size: u64,
+        mmio_base: u64,
+        mmio_size: u64,
+        create_gpu_allocator: bool,
+        first_irq: u32,
+    ) -> Option<Self> {
         let page_size = pagesize() as u64;
         Some(SystemAllocator {
             io_address_space: if let (Some(b), Some(s)) = (io_base, io_size) {
@@ -137,12 +142,20 @@ impl AddressRanges {
         self
     }
 
-    pub fn create_allocator(&self, first_irq: u32,
-                            gpu_allocation: bool) -> Option<SystemAllocator> {
-        SystemAllocator::new(self.io_base, self.io_size,
-                             self.device_base?, self.device_size?,
-                             self.mmio_base?, self.mmio_size?,
-                             gpu_allocation,
-                             first_irq)
+    pub fn create_allocator(
+        &self,
+        first_irq: u32,
+        gpu_allocation: bool,
+    ) -> Option<SystemAllocator> {
+        SystemAllocator::new(
+            self.io_base,
+            self.io_size,
+            self.device_base?,
+            self.device_size?,
+            self.mmio_base?,
+            self.mmio_size?,
+            gpu_allocation,
+            first_irq,
+        )
     }
 }