drm: add unique identifiers to dmabufs
This commit is contained in:
parent
3635ae0104
commit
fed2ceb8b5
17 changed files with 72 additions and 25 deletions
|
|
@ -5,15 +5,18 @@ use {
|
|||
uapi::{c::ioctl, OwnedFd, _IOW, _IOWR},
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct DmaBufPlane {
|
||||
pub offset: u32,
|
||||
pub stride: u32,
|
||||
pub fd: Rc<OwnedFd>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
linear_ids!(DmaBufIds, DmaBufId);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct DmaBuf {
|
||||
pub id: DmaBufId,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub format: &'static Format,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use {
|
|||
format::{formats, Format},
|
||||
utils::oserror::OsError,
|
||||
video::{
|
||||
dmabuf::{DmaBuf, DmaBufPlane, PlaneVec},
|
||||
dmabuf::{DmaBuf, DmaBufIds, DmaBufPlane, PlaneVec},
|
||||
drm::{Drm, DrmError},
|
||||
Modifier, INVALID_MODIFIER,
|
||||
},
|
||||
|
|
@ -150,8 +150,9 @@ impl GbmBoMap {
|
|||
}
|
||||
}
|
||||
|
||||
unsafe fn export_bo(bo: *mut Bo) -> Result<DmaBuf, GbmError> {
|
||||
unsafe fn export_bo(dmabuf_ids: &DmaBufIds, bo: *mut Bo) -> Result<DmaBuf, GbmError> {
|
||||
Ok(DmaBuf {
|
||||
id: dmabuf_ids.next(),
|
||||
width: gbm_bo_get_width(bo) as _,
|
||||
height: gbm_bo_get_height(bo) as _,
|
||||
modifier: gbm_bo_get_modifier(bo),
|
||||
|
|
@ -199,6 +200,7 @@ impl GbmDevice {
|
|||
|
||||
pub fn create_bo<'a>(
|
||||
&self,
|
||||
dma_buf_ids: &DmaBufIds,
|
||||
width: i32,
|
||||
height: i32,
|
||||
format: &Format,
|
||||
|
|
@ -229,7 +231,7 @@ impl GbmDevice {
|
|||
return Err(GbmError::CreateBo(OsError::default()));
|
||||
}
|
||||
let bo = BoHolder { bo };
|
||||
let dma = export_bo(bo.bo)?;
|
||||
let dma = export_bo(dma_buf_ids, bo.bo)?;
|
||||
Ok(GbmBo { bo, dmabuf: dma })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue