1
0
Fork 0
forked from wry/wry

video: move dma-buf types into workspace crate

This commit is contained in:
kossLAN 2026-05-29 11:27:02 -04:00
parent f456905231
commit ebaccd8762
No known key found for this signature in database
6 changed files with 77 additions and 14 deletions

11
Cargo.lock generated
View file

@ -721,6 +721,7 @@ dependencies = [
"jay-tree-types",
"jay-units",
"jay-utils",
"jay-video-types",
"jay-wheel",
"jay-wire-buf",
"jay-wire-types",
@ -978,6 +979,16 @@ dependencies = [
"uapi",
]
[[package]]
name = "jay-video-types"
version = "0.1.0"
dependencies = [
"arrayvec",
"jay-formats",
"jay-utils",
"uapi",
]
[[package]]
name = "jay-wheel"
version = "0.1.0"

View file

@ -42,6 +42,7 @@ members = [
"pr-caps",
"bugs",
"logger",
"video-types",
"toml-config",
"algorithms",
"toml-spec",
@ -85,6 +86,7 @@ jay-sighand = { version = "0.1.0", path = "sighand" }
jay-pr-caps = { version = "0.1.0", path = "pr-caps" }
jay-bugs = { version = "0.1.0", path = "bugs" }
jay-logger = { version = "0.1.0", path = "logger" }
jay-video-types = { version = "0.1.0", path = "video-types" }
uapi = "0.2.13"
thiserror = "2.0.11"

View file

@ -1,11 +1,4 @@
pub mod dmabuf;
pub mod drm;
pub mod gbm;
pub type Modifier = u64;
pub const INVALID_MODIFIER: Modifier = 0x00ff_ffff_ffff_ffff;
pub const LINEAR_MODIFIER: Modifier = 0;
// This is required by AMD and therefore everyone else uses this too.
pub const LINEAR_STRIDE_ALIGN: u64 = 256;
pub use jay_video_types::*;

12
video-types/Cargo.toml Normal file
View file

@ -0,0 +1,12 @@
[package]
name = "jay-video-types"
version = "0.1.0"
edition = "2024"
license = "GPL-3.0-only"
[dependencies]
jay-formats = { version = "0.1.0", path = "../formats" }
jay-utils = { version = "0.1.0", path = "../utils" }
arrayvec = "0.7.4"
uapi = "0.2.13"

View file

@ -1,10 +1,8 @@
use {
crate::{
format::Format,
utils::{compat::IoctlNumber, oserror::OsError},
video::{LINEAR_MODIFIER, Modifier},
},
crate::{LINEAR_MODIFIER, Modifier},
arrayvec::ArrayVec,
jay_formats::Format,
jay_utils::{compat::IoctlNumber, numcell::NumCell, oserror::OsError},
std::{cell::OnceCell, rc::Rc, sync::OnceLock},
uapi::{
_IOW, _IOWR, OwnedFd,
@ -20,7 +18,45 @@ pub struct DmaBufPlane {
pub fd: Rc<OwnedFd>,
}
linear_ids!(DmaBufIds, DmaBufId);
#[derive(Debug)]
pub struct DmaBufIds {
next: NumCell<u32>,
}
impl Default for DmaBufIds {
fn default() -> Self {
Self {
next: NumCell::new(1),
}
}
}
impl DmaBufIds {
pub fn next(&self) -> DmaBufId {
DmaBufId(self.next.fetch_add(1))
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct DmaBufId(u32);
impl DmaBufId {
#[allow(dead_code)]
pub fn raw(&self) -> u32 {
self.0
}
#[allow(dead_code)]
pub fn from_raw(id: u32) -> Self {
Self(id)
}
}
impl std::fmt::Display for DmaBufId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}
#[derive(Debug, Clone)]
pub struct DmaBuf {

9
video-types/src/lib.rs Normal file
View file

@ -0,0 +1,9 @@
pub mod dmabuf;
pub type Modifier = u64;
pub const INVALID_MODIFIER: Modifier = 0x00ff_ffff_ffff_ffff;
pub const LINEAR_MODIFIER: Modifier = 0;
// This is required by AMD and therefore everyone else uses this too.
pub const LINEAR_STRIDE_ALIGN: u64 = 256;