Skip to content

Commit

Permalink
update dma-heap to 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnurou committed Jun 3, 2023
1 parent c276f3e commit cb247e5
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 59 deletions.
131 changes: 76 additions & 55 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ v4l2r = { path = "../lib" }
thiserror = "1.0"
anyhow = "1.0"
log = "0.4.14"
dma-heap = { git = "https://github.com/mripard/dma-heap" }
dma-heap = "0.2.1"
7 changes: 4 additions & 3 deletions utils/src/dmabuf_exporter.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
use std::fs::File;

use dma_heap::{DmaBufHeap, DmaBufHeapType};
use dma_heap::{Heap, HeapKind};
use v4l2r::{memory::DmaBufHandle, Format};

use anyhow::Result;

pub fn export_dmabufs(format: &Format, nb_buffers: usize) -> Result<Vec<Vec<DmaBufHandle<File>>>> {
let heap = DmaBufHeap::new(DmaBufHeapType::System).unwrap();
let heap = Heap::new(HeapKind::System)?;

let fds: Vec<Vec<DmaBufHandle<File>>> = (0..nb_buffers)
.map(|_| {
format
.plane_fmt
.iter()
.map(|plane| {
DmaBufHandle::from(heap.allocate::<File>(plane.sizeimage as usize).unwrap())
let fd = File::from(heap.allocate(plane.sizeimage as usize).unwrap());
DmaBufHandle::from(fd)
})
.collect()
})
Expand Down

0 comments on commit cb247e5

Please sign in to comment.