Add device_hw_t and device_v4l2_open

This commit is contained in:
Kamil Trzcinski
2022-04-10 09:54:02 +02:00
parent 13528eff1d
commit 76f35f37c8
8 changed files with 35 additions and 18 deletions

View File

@ -3,10 +3,11 @@
#include "device/hw/buffer_list.h"
#include "device/hw/v4l2.h"
device_t *device_open(const char *name, const char *path) {
device_t *device_open(const char *name, const char *path, device_hw_t *hw) {
device_t *dev = calloc(1, sizeof(device_t));
dev->name = strdup(name);
dev->path = strdup(path);
dev->hw = hw;
dev->fd = open(path, O_RDWR|O_NONBLOCK);
dev->subdev_fd = -1;
dev->allow_dma = true;

View File

@ -7,6 +7,11 @@
typedef struct buffer_list_s buffer_list_t;
typedef struct device_s device_t;
typedef struct device_hw_s {
int (*device_hw_open)(device_t *device);
int (*device_hw_close)(device_t *device);
} device_hw_t;
typedef struct device_s {
char *name;
char *path;
@ -15,6 +20,7 @@ typedef struct device_s {
struct v4l2_capability v4l2_cap;
bool allow_dma;
device_hw_t *hw;
buffer_list_t *capture_list;
buffer_list_t *output_list;
@ -23,7 +29,8 @@ typedef struct device_s {
bool decoder_started;
} device_t;
device_t *device_open(const char *name, const char *path);
device_t *device_open(const char *name, const char *path, device_hw_t *hw);
device_t *device_v4l2_open(const char *name, const char *path);
int device_open_media_device(device_t *dev);
int device_open_v4l2_subdev(device_t *dev, int subdev);
void device_close(device_t *device);