From 6ce5b5ce4adbf6d034e4675da8e694eb826b4249 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 11 Apr 2022 16:28:36 +0200 Subject: [PATCH] Add `device->opts.allow_dma` --- device/camera/camera.c | 4 ++-- device/device.c | 6 +++--- device/device.h | 5 ++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/device/camera/camera.c b/device/camera/camera.c index 2df0590..358b669 100644 --- a/device/camera/camera.c +++ b/device/camera/camera.c @@ -57,11 +57,11 @@ camera_t *camera_open(camera_options_t *options) goto error; } - camera->camera->allow_dma = camera->options.allow_dma; + camera->camera->opts.allow_dma = camera->options.allow_dma; if (strstr(camera->camera->bus_info, "usb")) { LOG_INFO(camera, "Disabling DMA since device uses USB (which is likely not working properly)."); - camera->camera->allow_dma = false; + camera->camera->opts.allow_dma = false; } // TODO: mpad format diff --git a/device/device.c b/device/device.c index f326c91..d3ff744 100644 --- a/device/device.c +++ b/device/device.c @@ -9,7 +9,7 @@ device_t *device_open(const char *name, const char *path, device_hw_t *hw) { dev->name = strdup(name); dev->path = strdup(path); dev->hw = hw; - dev->allow_dma = true; + dev->opts.allow_dma = true; if (dev->hw->device_open(dev) < 0) { LOG_ERROR(dev, "Can't open device: %s", path); @@ -53,7 +53,7 @@ int device_open_buffer_list(device_t *dev, bool do_capture, unsigned width, unsi return -1; } - if (!dev->allow_dma) { + if (!dev->opts.allow_dma) { do_mmap = true; } @@ -94,7 +94,7 @@ int device_open_buffer_list_output(device_t *dev, buffer_list_t *capture_list) capture_list->fmt_width, capture_list->fmt_height, capture_list->fmt_format, capture_list->fmt_bytesperline, capture_list->nbufs, - capture_list->dev->allow_dma ? !capture_list->do_mmap : true); + capture_list->dev->opts.allow_dma ? !capture_list->do_mmap : true); } int device_open_buffer_list_capture(device_t *dev, buffer_list_t *output_list, float div, unsigned format, bool do_mmap) diff --git a/device/device.h b/device/device.h index 3ad817d..d07b4b6 100644 --- a/device/device.h +++ b/device/device.h @@ -31,12 +31,15 @@ typedef struct device_s { char *name; char *path; char bus_info[64]; - bool allow_dma; device_hw_t *hw; buffer_list_t *capture_list; buffer_list_t *output_list; + struct { + bool allow_dma; + } opts; + union { struct device_v4l2_s *v4l2; struct device_dummy_s *dummy;