1 /* 2 * Copyright (c) 2026 Abdelkader Boudih <freebsd@seuros.com> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7 #ifndef _DEV_VIDEO_VIDEO_H_ 8 #define _DEV_VIDEO_VIDEO_H_ 9 10 #include <sys/types.h> 11 #include <sys/bus.h> 12 13 struct video_device; 14 struct video_buf; 15 16 struct video_format { 17 uint32_t pixelformat; /* V4L2 fourcc */ 18 uint32_t width; 19 uint32_t height; 20 uint32_t bytesperline; 21 uint32_t sizeimage; 22 uint32_t field; 23 uint32_t colorspace; 24 uint32_t xfer_func; 25 uint32_t ycbcr_enc; 26 uint32_t flags; /* V4L2_FMT_FLAG_* */ 27 char description[32]; 28 }; 29 30 struct video_fract { 31 uint32_t numerator; 32 uint32_t denominator; 33 }; 34 35 struct video_caps { 36 char driver[16]; 37 char card[32]; 38 char bus_info[32]; 39 uint32_t version; 40 uint32_t capabilities; 41 }; 42 43 #define VIDEO_CAP_CAPTURE 0x00000001 /* V4L2_CAP_VIDEO_CAPTURE */ 44 #define VIDEO_CAP_READWRITE 0x01000000 /* V4L2_CAP_READWRITE */ 45 #define VIDEO_CAP_STREAMING 0x04000000 /* V4L2_CAP_STREAMING */ 46 47 struct video_input { 48 uint32_t index; 49 char name[32]; 50 uint32_t type; 51 }; 52 53 #define VIDEO_INPUT_TYPE_CAMERA 2 54 55 struct video_control_desc { 56 uint32_t id; 57 uint32_t type; 58 char name[32]; 59 int32_t minimum; 60 int32_t maximum; 61 int32_t step; 62 int32_t default_value; 63 uint32_t flags; 64 }; 65 66 struct video_control { 67 uint32_t id; 68 int32_t value; 69 }; 70 71 struct video_frmsizeenum { 72 uint32_t index; 73 uint32_t pixelformat; 74 uint32_t type; 75 union { 76 struct { 77 uint32_t width; 78 uint32_t height; 79 } discrete; 80 struct { 81 uint32_t min_width; 82 uint32_t max_width; 83 uint32_t step_width; 84 uint32_t min_height; 85 uint32_t max_height; 86 uint32_t step_height; 87 } stepwise; 88 }; 89 }; 90 91 struct video_frmivalenum { 92 uint32_t index; 93 uint32_t pixelformat; 94 uint32_t width; 95 uint32_t height; 96 uint32_t type; 97 union { 98 struct video_fract discrete; 99 struct { 100 struct video_fract min; 101 struct video_fract max; 102 struct video_fract step; 103 } stepwise; 104 }; 105 }; 106 107 int video_register(device_t dev, struct video_device **vdp); 108 void video_unregister(struct video_device *vd); 109 110 struct video_buf *video_buf_acquire(struct video_device *vd); 111 int video_buf_write(struct video_buf *vb, 112 size_t offset, const void *src, size_t len); 113 void video_buf_done(struct video_buf *vb, 114 size_t bytesused, uint32_t sequence); 115 void video_buf_error(struct video_buf *vb); 116 117 #endif /* _DEV_VIDEO_VIDEO_H_ */ 118