Move device/hw/buffer.c to device/buffer.c

This commit is contained in:
Kamil Trzcinski
2022-04-10 11:11:50 +02:00
parent 20c48607c5
commit fd2f19270c
16 changed files with 15 additions and 15 deletions

37
device/buffer.c Normal file
View File

@@ -0,0 +1,37 @@
#include "device/buffer.h"
#include "device/hw/buffer_list.h"
#include "device/hw/device.h"
#include "device/hw/v4l2.h"
buffer_t *buffer_open(const char *name, buffer_list_t *buf_list, int index) {
buffer_t *buf = calloc(1, sizeof(buffer_t));
device_t *dev = buf_list->device;
buf->name = strdup(name);
buf->index = index;
buf->buf_list = buf_list;
buf->dma_fd = -1;
buf->mmap_reflinks = 1;
buf->used = 0;
if (dev->hw->buffer_open(buf) < 0) {
goto error;
}
return buf;
error:
buffer_close(buf);
return NULL;
}
void buffer_close(buffer_t *buf)
{
if (buf == NULL) {
return;
}
buf->buf_list->device->hw->buffer_close(buf);
free(buf->name);
free(buf);
}