From 013254128b3ea57fa54b2bad9b79557ce43bf7ab Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Mon, 7 Oct 2024 23:18:52 +0900 Subject: [PATCH] device/queue: move implementations for generic buffers to the generic module --- lib/src/device/queue.rs | 23 ----------------------- lib/src/device/queue/generic.rs | 29 ++++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/lib/src/device/queue.rs b/lib/src/device/queue.rs index bdd41dd..2cc15ec 100644 --- a/lib/src/device/queue.rs +++ b/lib/src/device/queue.rs @@ -19,7 +19,6 @@ use crate::{Format, PixelFormat, QueueType}; use buffer::*; use direction::*; use dqbuf::*; -use generic::{GenericBufferHandles, GenericQBuffer, GenericSupportedMemoryType}; use log::debug; use qbuf::*; @@ -563,28 +562,6 @@ mod private { } } - impl<'a, D: Direction> QueueableProvider<'a> for Queue> { - type Queueable = GenericQBuffer; - } - - impl<'a, D: Direction> GetBufferByIndex<'a> for Queue> { - fn try_get_buffer(&'a self, index: usize) -> Result { - let buffer_info = self.try_obtain_buffer(index)?; - - Ok(match self.state.memory_type { - GenericSupportedMemoryType::Mmap => { - GenericQBuffer::Mmap(QBuffer::new(self, buffer_info)) - } - GenericSupportedMemoryType::UserPtr => { - GenericQBuffer::User(QBuffer::new(self, buffer_info)) - } - GenericSupportedMemoryType::DmaBuf => { - GenericQBuffer::DmaBuf(QBuffer::new(self, buffer_info)) - } - }) - } - } - impl<'a, D, P, Q> QueueableProvider<'a> for Q where D: Direction, diff --git a/lib/src/device/queue/generic.rs b/lib/src/device/queue/generic.rs index c8e822c..a590fc9 100644 --- a/lib/src/device/queue/generic.rs +++ b/lib/src/device/queue/generic.rs @@ -1,8 +1,9 @@ use crate::{ device::queue::{ direction::{Capture, Direction, Output}, + private, qbuf::{QBuffer, QueueResult}, - BuffersAllocated, CaptureQueueable, OutputQueueable, Queue, + BuffersAllocated, CaptureQueueable, OutputQueueable, Queue, TryGetBufferError, }, memory::DmaBufHandle, }; @@ -122,6 +123,32 @@ where } } +impl<'a, D: Direction> private::QueueableProvider<'a> + for Queue> +{ + type Queueable = GenericQBuffer; +} + +impl<'a, D: Direction> private::GetBufferByIndex<'a> + for Queue> +{ + fn try_get_buffer(&'a self, index: usize) -> Result { + let buffer_info = self.try_obtain_buffer(index)?; + + Ok(match self.state.memory_type { + GenericSupportedMemoryType::Mmap => { + GenericQBuffer::Mmap(QBuffer::new(self, buffer_info)) + } + GenericSupportedMemoryType::UserPtr => { + GenericQBuffer::User(QBuffer::new(self, buffer_info)) + } + GenericSupportedMemoryType::DmaBuf => { + GenericQBuffer::DmaBuf(QBuffer::new(self, buffer_info)) + } + }) + } +} + /// Any CAPTURE GenericQBuffer implements CaptureQueueable. impl CaptureQueueable for GenericQBuffer where