Skip to content

Commit

Permalink
Bump bitflags to 2.4
Browse files Browse the repository at this point in the history
The move from bitflags 1 to 2 made bits into a function, and removed the
default derives so I added back Clone, Copy and Debug to all structs.
  • Loading branch information
linkmauve authored and Gnurou committed Sep 5, 2023
1 parent 2da6a99 commit 7c38c0e
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "MIT"

[dependencies]
nix = "0.24.0"
bitflags = "1.2.1"
bitflags = "2.4"
thiserror = "1.0"
anyhow = "1.0"
log = "0.4.14"
Expand Down
1 change: 1 addition & 0 deletions lib/src/ioctl/enum_fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl EnumFmt for bindings::v4l2_fmtdesc {
bitflags! {
/// Flags returned by the `VIDIOC_ENUM_FMT` ioctl into the `flags` field of
/// `struct v4l2_fmtdesc`.
#[derive(Clone, Copy, Debug)]
pub struct FormatFlags: u32 {
const COMPRESSED = bindings::V4L2_FMT_FLAG_COMPRESSED;
const EMULATED = bindings::V4L2_FMT_FLAG_EMULATED;
Expand Down
1 change: 1 addition & 0 deletions lib/src/ioctl/expbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{bindings, QueueType};

bitflags! {
/// Flags that can be passed when exporting the buffer.
#[derive(Clone, Copy, Debug)]
pub struct ExpbufFlags: u32 {
const CLOEXEC = OFlag::O_CLOEXEC.bits() as u32;
const RDONLY = OFlag::O_RDONLY.bits() as u32;
Expand Down
4 changes: 4 additions & 0 deletions lib/src/ioctl/g_ext_ctrls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub enum Quantization {

bitflags! {
/// FWHT Flags.
#[derive(Clone, Copy, Debug)]
pub struct FwhtFlags: u32 {
const INTERLACED = bindings::V4L2_FWHT_FL_IS_INTERLACED as u32;
const BOTTOM_FIRST = bindings::V4L2_FWHT_FL_IS_BOTTOM_FIRST as u32;
Expand Down Expand Up @@ -113,6 +114,7 @@ pub struct FwhtParams {

bitflags! {
/// VP8 Segment Flags.
#[derive(Clone, Copy, Debug)]
pub struct VP8SegmentFlags: u32 {
const ENABLED = bindings::V4L2_VP8_SEGMENT_FLAG_ENABLED;
const UPDATE_MAP = bindings::V4L2_VP8_SEGMENT_FLAG_UPDATE_MAP;
Expand Down Expand Up @@ -154,6 +156,7 @@ impl From<VP8Segment> for bindings::v4l2_vp8_segment {

bitflags! {
/// VP8 Loop Filter Flags.
#[derive(Clone, Copy, Debug)]
pub struct VP8LoopFilterFlags: u32 {
const ADJ_ENABLE = bindings::V4L2_VP8_LF_ADJ_ENABLE;
const DELTA_UPDATE = bindings::V4L2_VP8_LF_DELTA_UPDATE;
Expand Down Expand Up @@ -293,6 +296,7 @@ impl From<VP8EntropyCoderState> for bindings::v4l2_vp8_entropy_coder_state {

bitflags! {
/// VP8 Frame Flags.
#[derive(Clone, Copy, Debug)]
pub struct VP8FrameFlags: u32 {
const KEY_FRAME = bindings::V4L2_VP8_FRAME_FLAG_KEY_FRAME;
const EXPERIMENTAL = bindings::V4L2_VP8_FRAME_FLAG_EXPERIMENTAL;
Expand Down
1 change: 1 addition & 0 deletions lib/src/ioctl/g_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub enum SelectionTarget {
}

bitflags! {
#[derive(Clone, Copy, Debug)]
pub struct SelectionFlags: u32 {
const GE = bindings::V4L2_SEL_FLAG_GE;
const LE = bindings::V4L2_SEL_FLAG_LE;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ioctl/qbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bitflags! {
/// Flags corresponding to the `flags` field of `struct v4l2_buffer`.
/// TODO split into two types, one for the user -> kernel and another for
/// the kernel -> user direction to filter invalid flags?
#[derive(Default)]
#[derive(Clone, Copy, Debug, Default)]
pub struct BufferFlags: u32 {
const MAPPED = bindings::V4L2_BUF_FLAG_MAPPED;
const QUEUED = bindings::V4L2_BUF_FLAG_QUEUED;
Expand Down Expand Up @@ -161,7 +161,7 @@ impl<H: PlaneHandle> Default for QBuffer<H> {
impl<H: PlaneHandle> QBuffer<H> {
fn fill_common_v4l2_data(&self, v4l2_buf: &mut bindings::v4l2_buffer) {
v4l2_buf.memory = H::Memory::MEMORY_TYPE as u32;
v4l2_buf.flags = self.flags.bits;
v4l2_buf.flags = self.flags.bits();
v4l2_buf.field = self.field;
v4l2_buf.sequence = self.sequence;
v4l2_buf.timestamp.tv_sec = self.timestamp.tv_sec();
Expand Down
1 change: 1 addition & 0 deletions lib/src/ioctl/querycap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ impl QueryCap for bindings::v4l2_capability {
bitflags! {
/// Flags returned by the `VIDIOC_QUERYCAP` ioctl into the `capabilities`
/// or `device_capabilities` field of `v4l2_capability`.
#[derive(Clone, Copy, Debug)]
pub struct Capabilities: u32 {
const VIDEO_CAPTURE = bindings::V4L2_CAP_VIDEO_CAPTURE;
const VIDEO_OUTPUT = bindings::V4L2_CAP_VIDEO_OUTPUT;
Expand Down
1 change: 1 addition & 0 deletions lib/src/ioctl/queryctrl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ impl CtrlId {
}

bitflags! {
#[derive(Clone, Copy, Debug)]
pub struct QueryCtrlFlags: u32 {
const NEXT = bindings::V4L2_CTRL_FLAG_NEXT_CTRL;
const COMPOUND = bindings::V4L2_CTRL_FLAG_NEXT_COMPOUND;
Expand Down
1 change: 1 addition & 0 deletions lib/src/ioctl/reqbufs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ impl ReqBufs for bindings::v4l2_requestbuffers {
bitflags! {
/// Flags returned by the `VIDIOC_REQBUFS` ioctl into the `capabilities`
/// field of `struct v4l2_requestbuffers`.
#[derive(Clone, Copy, Debug)]
pub struct BufferCapabilities: u32 {
const SUPPORTS_MMAP = bindings::V4L2_BUF_CAP_SUPPORTS_MMAP;
const SUPPORTS_USERPTR = bindings::V4L2_BUF_CAP_SUPPORTS_USERPTR;
Expand Down
2 changes: 2 additions & 0 deletions lib/src/ioctl/subscribe_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::bindings;
use bitflags::bitflags;

bitflags! {
#[derive(Clone, Copy, Debug)]
pub struct SubscribeEventFlags: u32 {
const SEND_INITIAL = bindings::V4L2_EVENT_SUB_FL_SEND_INITIAL;
const ALLOW_FEEDBACK = bindings::V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK;
Expand Down Expand Up @@ -55,6 +56,7 @@ impl TryFrom<&bindings::v4l2_event_subscription> for EventType {
}

bitflags! {
#[derive(Clone, Copy, Debug)]
pub struct SrcChanges: u32 {
const RESOLUTION = bindings::V4L2_EVENT_SRC_CH_RESOLUTION;
}
Expand Down

0 comments on commit 7c38c0e

Please sign in to comment.