diff options
-rw-r--r-- | cli.c | 12 | ||||
-rw-r--r-- | dma.c | 18 | ||||
-rw-r--r-- | dma.h | 8 | ||||
-rw-r--r-- | dma/nwl.c | 18 | ||||
-rw-r--r-- | dma/nwl.h | 6 | ||||
-rw-r--r-- | event.h | 2 | ||||
-rw-r--r-- | ipecamera/image.c | 4 | ||||
-rw-r--r-- | ipecamera/image.h | 2 | ||||
-rw-r--r-- | pcilib.h | 36 |
9 files changed, 51 insertions, 55 deletions
@@ -308,7 +308,7 @@ void Info(pcilib_t *handle, pcilib_model_t model) { #define BENCH_MAX_DMA_SIZE 16 * 1024 * 1024 #define BENCH_MAX_FIFO_SIZE 1024 * 1024 -int Benchmark(pcilib_t *handle, ACCESS_MODE mode, pcilib_dma_addr_t dma, pcilib_bar_t bar, uintptr_t addr, size_t n, access_t access) { +int Benchmark(pcilib_t *handle, ACCESS_MODE mode, pcilib_dma_engine_addr_t dma, pcilib_bar_t bar, uintptr_t addr, size_t n, access_t access) { int err; int i, j, errors; void *data, *buf, *check; @@ -502,14 +502,14 @@ int Benchmark(pcilib_t *handle, ACCESS_MODE mode, pcilib_dma_addr_t dma, pcilib_ #define pci2host16(endianess, value) endianess? -int ReadData(pcilib_t *handle, ACCESS_MODE mode, pcilib_dma_addr_t dma, pcilib_bar_t bar, uintptr_t addr, size_t n, access_t access, int endianess) { +int ReadData(pcilib_t *handle, ACCESS_MODE mode, pcilib_dma_engine_addr_t dma, pcilib_bar_t bar, uintptr_t addr, size_t n, access_t access, int endianess) { void *buf; int i, err; size_t ret; int size = n * abs(access); int block_width, blocks_per_line; int numbers_per_block, numbers_per_line; - pcilib_dma_t dmaid; + pcilib_dma_engine_t dmaid; numbers_per_block = BLOCK_SIZE / access; @@ -672,13 +672,13 @@ int ReadRegisterRange(pcilib_t *handle, pcilib_model_t model, const char *bank, printf("\n\n"); } -int WriteData(pcilib_t *handle, ACCESS_MODE mode, pcilib_dma_addr_t dma, pcilib_bar_t bar, uintptr_t addr, size_t n, access_t access, int endianess, char ** data) { +int WriteData(pcilib_t *handle, ACCESS_MODE mode, pcilib_dma_engine_addr_t dma, pcilib_bar_t bar, uintptr_t addr, size_t n, access_t access, int endianess, char ** data) { int read_back = 0; void *buf, *check; int res, i, err; int size = n * abs(access); size_t ret; - pcilib_dma_t dmaid; + pcilib_dma_engine_t dmaid; err = posix_memalign( (void**)&buf, 256, size ); if (!err) err = posix_memalign( (void**)&check, 256, size ); @@ -841,7 +841,7 @@ int main(int argc, char **argv) { char **data = NULL; const char *event = NULL; - pcilib_dma_addr_t dma; + pcilib_dma_engine_addr_t dma; uintptr_t start = -1; size_t size = 1; access_t access = 4; @@ -33,8 +33,8 @@ const pcilib_dma_info_t *pcilib_get_dma_info(pcilib_t *ctx) { return &ctx->dma_info; } -pcilib_dma_t pcilib_find_dma_by_addr(pcilib_t *ctx, pcilib_dma_direction_t direction, pcilib_dma_addr_t dma) { - pcilib_dma_t i; +pcilib_dma_engine_t pcilib_find_dma_by_addr(pcilib_t *ctx, pcilib_dma_direction_t direction, pcilib_dma_engine_addr_t dma) { + pcilib_dma_engine_t i; const pcilib_dma_info_t *info = pcilib_get_dma_info(ctx); if (!info) { @@ -50,7 +50,7 @@ pcilib_dma_t pcilib_find_dma_by_addr(pcilib_t *ctx, pcilib_dma_direction_t direc return PCILIB_DMA_INVALID; } -int pcilib_set_dma_engine_description(pcilib_t *ctx, pcilib_dma_t engine, pcilib_dma_engine_description_t *desc) { +int pcilib_set_dma_engine_description(pcilib_t *ctx, pcilib_dma_engine_t engine, pcilib_dma_engine_description_t *desc) { ctx->dma_info.engines[engine] = desc; } @@ -79,7 +79,7 @@ static int pcilib_dma_skip_callback(void *arg, pcilib_dma_flags_t flags, size_t return 1; } -size_t pcilib_stream_dma(pcilib_t *ctx, pcilib_dma_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, pcilib_dma_callback_t cb, void *cbattr) { +size_t pcilib_stream_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, pcilib_dma_callback_t cb, void *cbattr) { int err; const pcilib_dma_info_t *info = pcilib_get_dma_info(ctx); @@ -111,7 +111,7 @@ size_t pcilib_stream_dma(pcilib_t *ctx, pcilib_dma_t dma, uintptr_t addr, size_t return ctx->model_info->dma_api->stream(ctx->dma_ctx, dma, addr, size, flags, timeout, cb, cbattr); } -size_t pcilib_read_dma(pcilib_t *ctx, pcilib_dma_t dma, uintptr_t addr, size_t size, void *buf) { +size_t pcilib_read_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, void *buf) { int err; pcilib_dma_read_callback_context_t opts = { @@ -121,7 +121,7 @@ size_t pcilib_read_dma(pcilib_t *ctx, pcilib_dma_t dma, uintptr_t addr, size_t s return pcilib_stream_dma(ctx, dma, addr, size, PCILIB_DMA_FLAGS_DEFAULT, PCILIB_DMA_TIMEOUT, pcilib_dma_read_callback, &opts); } -int pcilib_skip_dma(pcilib_t *ctx, pcilib_dma_t dma) { +int pcilib_skip_dma(pcilib_t *ctx, pcilib_dma_engine_t dma) { size_t skipped; do { // IMMEDIATE timeout is not working properly, so default is set @@ -132,7 +132,7 @@ int pcilib_skip_dma(pcilib_t *ctx, pcilib_dma_t dma) { } -size_t pcilib_push_dma(pcilib_t *ctx, pcilib_dma_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, void *buf) { +size_t pcilib_push_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, void *buf) { int err; const pcilib_dma_info_t *info = pcilib_get_dma_info(ctx); @@ -165,11 +165,11 @@ size_t pcilib_push_dma(pcilib_t *ctx, pcilib_dma_t dma, uintptr_t addr, size_t s } -size_t pcilib_write_dma(pcilib_t *ctx, pcilib_dma_t dma, uintptr_t addr, size_t size, void *buf) { +size_t pcilib_write_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, void *buf) { return pcilib_push_dma(ctx, dma, addr, size, PCILIB_DMA_FLAG_EOP, PCILIB_DMA_TIMEOUT, buf); } -double pcilib_benchmark_dma(pcilib_t *ctx, pcilib_dma_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction) { +double pcilib_benchmark_dma(pcilib_t *ctx, pcilib_dma_engine_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction) { int err; const pcilib_dma_info_t *info = pcilib_get_dma_info(ctx); @@ -7,12 +7,12 @@ struct pcilib_dma_api_description_s { pcilib_dma_context_t *(*init)(pcilib_t *ctx); void (*free)(pcilib_dma_context_t *ctx); - size_t (*push)(pcilib_dma_context_t *ctx, pcilib_dma_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, void *buf); - size_t (*stream)(pcilib_dma_context_t *ctx, pcilib_dma_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, pcilib_dma_callback_t cb, void *cbattr); + size_t (*push)(pcilib_dma_context_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, void *buf); + size_t (*stream)(pcilib_dma_context_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, pcilib_dma_callback_t cb, void *cbattr); - double (*benchmark)(pcilib_dma_context_t *ctx, pcilib_dma_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction); + double (*benchmark)(pcilib_dma_context_t *ctx, pcilib_dma_engine_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction); }; -int pcilib_set_dma_engine_description(pcilib_t *ctx, pcilib_dma_t engine, pcilib_dma_engine_description_t *desc); +int pcilib_set_dma_engine_description(pcilib_t *ctx, pcilib_dma_engine_t engine, pcilib_dma_engine_description_t *desc); #endif /* _PCILIB_DMA_H */ @@ -54,7 +54,7 @@ struct nwl_dma_s { pcilib_register_bank_description_t *dma_bank; char *base_addr; - pcilib_dma_t n_engines; + pcilib_dma_engine_t n_engines; pcilib_nwl_engine_description_t engines[PCILIB_MAX_DMA_ENGINES + 1]; }; @@ -96,7 +96,7 @@ static int nwl_read_engine_config(nwl_dma_t *ctx, pcilib_nwl_engine_description_ return 0; } -static int nwl_stop_engine(nwl_dma_t *ctx, pcilib_dma_t dma) { +static int nwl_stop_engine(nwl_dma_t *ctx, pcilib_dma_engine_t dma) { uint32_t val; struct timeval start, cur; @@ -173,7 +173,7 @@ pcilib_dma_context_t *dma_nwl_init(pcilib_t *pcilib) { int i; int err; uint32_t val; - pcilib_dma_t n_engines; + pcilib_dma_engine_t n_engines; pcilib_model_description_t *model_info = pcilib_get_model_description(pcilib); @@ -217,7 +217,7 @@ pcilib_dma_context_t *dma_nwl_init(pcilib_t *pcilib) { } void dma_nwl_free(pcilib_dma_context_t *vctx) { - pcilib_dma_t i; + pcilib_dma_engine_t i; nwl_dma_t *ctx = (nwl_dma_t*)vctx; if (ctx) { for (i = 0; i < ctx->n_engines; i++) nwl_stop_engine(vctx, i); @@ -532,7 +532,7 @@ static int dma_nwl_return_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_t } -size_t dma_nwl_write_fragment(pcilib_dma_context_t *vctx, pcilib_dma_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, void *data) { +size_t dma_nwl_write_fragment(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, void *data) { int err; size_t pos; size_t bufnum; @@ -560,7 +560,7 @@ size_t dma_nwl_write_fragment(pcilib_dma_context_t *vctx, pcilib_dma_t dma, uint return size; } -size_t dma_nwl_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, pcilib_dma_callback_t cb, void *cbattr) { +size_t dma_nwl_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, pcilib_dma_callback_t cb, void *cbattr) { int err, ret; size_t res = 0; size_t bufnum; @@ -600,7 +600,7 @@ size_t dma_nwl_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_t dma, uintptr return res; } -double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction) { +double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction) { int i; int res; int err; @@ -614,8 +614,8 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_addr_t dma, uint nwl_dma_t *ctx = (nwl_dma_t*)vctx; - pcilib_dma_t readid = pcilib_find_dma_by_addr(ctx->pcilib, PCILIB_DMA_FROM_DEVICE, dma); - pcilib_dma_t writeid = pcilib_find_dma_by_addr(ctx->pcilib, PCILIB_DMA_TO_DEVICE, dma); + pcilib_dma_engine_t readid = pcilib_find_dma_by_addr(ctx->pcilib, PCILIB_DMA_FROM_DEVICE, dma); + pcilib_dma_engine_t writeid = pcilib_find_dma_by_addr(ctx->pcilib, PCILIB_DMA_TO_DEVICE, dma); if (size%sizeof(uint32_t)) size = 1 + size / sizeof(uint32_t); else size /= sizeof(uint32_t); @@ -17,9 +17,9 @@ typedef struct { pcilib_dma_context_t *dma_nwl_init(pcilib_t *ctx); void dma_nwl_free(pcilib_dma_context_t *vctx); -size_t dma_nwl_write_fragment(pcilib_dma_context_t *vctx, pcilib_dma_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, void *data); -size_t dma_nwl_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, pcilib_dma_callback_t cb, void *cbattr); -double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction); +size_t dma_nwl_write_fragment(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, void *data); +size_t dma_nwl_stream_read(pcilib_dma_context_t *vctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, pcilib_dma_callback_t cb, void *cbattr); +double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction); #ifdef _PCILIB_DMA_NWL_C pcilib_dma_api_description_t nwl_dma_api = { @@ -9,7 +9,7 @@ struct pcilib_event_api_description_s { int (*reset)(pcilib_context_t *ctx); - int (*start)(pcilib_context_t *ctx, pcilib_event_t event_mask, pcilib_callback_t callback, void *user); + int (*start)(pcilib_context_t *ctx, pcilib_event_t event_mask, pcilib_event_callback_t callback, void *user); int (*stop)(pcilib_context_t *ctx); int (*trigger)(pcilib_context_t *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data); diff --git a/ipecamera/image.c b/ipecamera/image.c index d9a19cc..bf5faf9 100644 --- a/ipecamera/image.c +++ b/ipecamera/image.c @@ -53,7 +53,7 @@ struct ipecamera_s { char *data; size_t size; - pcilib_callback_t cb; + pcilib_event_callback_t cb; void *cb_user; pcilib_event_id_t event_id; @@ -259,7 +259,7 @@ int ipecamera_reset(pcilib_context_t *vctx) { return 0; } -int ipecamera_start(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_callback_t cb, void *user) { +int ipecamera_start(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_event_callback_t cb, void *user) { int err = 0; ipecamera_t *ctx = (ipecamera_t*)vctx; pcilib_t *pcilib = ctx->pcilib; diff --git a/ipecamera/image.h b/ipecamera/image.h index 0418be4..6863d09 100644 --- a/ipecamera/image.h +++ b/ipecamera/image.h @@ -10,7 +10,7 @@ pcilib_context_t *ipecamera_init(pcilib_t *pcilib); void ipecamera_free(pcilib_context_t *ctx); int ipecamera_reset(pcilib_context_t *ctx); -int ipecamera_start(pcilib_context_t *ctx, pcilib_event_t event_mask, pcilib_callback_t cb, void *user); +int ipecamera_start(pcilib_context_t *ctx, pcilib_event_t event_mask, pcilib_event_callback_t cb, void *user); int ipecamera_stop(pcilib_context_t *ctx); int ipecamera_trigger(pcilib_context_t *ctx, pcilib_event_t event, size_t trigger_size, void *trigger_data); pcilib_event_id_t ipecamera_next_event(pcilib_context_t *ctx, pcilib_event_t event_mask, const struct timespec *timeout); @@ -34,11 +34,13 @@ typedef uint8_t pcilib_register_bank_addr_t; /**< Type holding the register bank typedef uint8_t pcilib_register_size_t; /**< Type holding the size in bits of the register */ typedef uint32_t pcilib_register_value_t; /**< Type holding the register value */ typedef uint64_t pcilib_event_id_t; -typedef uint8_t pcilib_dma_addr_t; -typedef uint8_t pcilib_dma_t; - +typedef uint8_t pcilib_dma_engine_addr_t; +typedef uint8_t pcilib_dma_engine_t; typedef uint32_t pcilib_event_t; +typedef int (*pcilib_dma_callback_t)(void *ctx, pcilib_dma_flags_t flags, size_t bufsize, void *buf); +typedef int (*pcilib_event_callback_t)(pcilib_event_t event, pcilib_event_id_t event_id, void *user); + typedef enum { PCILIB_HOST_ENDIAN = 0, PCILIB_LITTLE_ENDIAN, @@ -80,7 +82,7 @@ typedef enum { #define PCILIB_BAR_INVALID ((pcilib_bar_t)-1) #define PCILIB_BAR0 0 #define PCILIB_BAR1 1 -#define PCILIB_DMA_INVALID ((pcilib_dma_t)-1) +#define PCILIB_DMA_INVALID ((pcilib_dma_engine_t)-1) #define PCILIB_REGISTER_INVALID ((pcilib_register_t)-1) #define PCILIB_ADDRESS_INVALID ((uintptr_t)-1) #define PCILIB_REGISTER_BANK_INVALID ((pcilib_register_bank_t)-1) @@ -157,11 +159,11 @@ typedef enum { PCILIB_DMA_TYPE_BLOCK, PCILIB_DMA_TYPE_PACKET, PCILIB_DMA_TYPE_UNKNOWN -} pcilib_dma_type_t; +} pcilib_dma_engine_type_t; typedef struct { - pcilib_dma_addr_t addr; - pcilib_dma_type_t type; + pcilib_dma_engine_addr_t addr; + pcilib_dma_engine_type_t type; pcilib_dma_direction_t direction; size_t addr_bits; } pcilib_dma_engine_description_t; @@ -170,8 +172,6 @@ typedef struct { pcilib_dma_engine_description_t *engines[PCILIB_MAX_DMA_ENGINES + 1]; } pcilib_dma_info_t; -typedef int (*pcilib_callback_t)(pcilib_event_t event, pcilib_event_id_t event_id, void *user); - typedef struct { uint8_t access; uint8_t endianess; @@ -208,23 +208,19 @@ pcilib_register_bank_t pcilib_find_bank_by_name(pcilib_t *ctx, const char *bankn pcilib_register_bank_t pcilib_find_bank(pcilib_t *ctx, const char *bank); pcilib_register_t pcilib_find_register(pcilib_t *ctx, const char *bank, const char *reg); pcilib_event_t pcilib_find_event(pcilib_t *ctx, const char *event); -pcilib_dma_t pcilib_find_dma_by_addr(pcilib_t *ctx, pcilib_dma_direction_t direction, pcilib_dma_addr_t dma); - +pcilib_dma_engine_t pcilib_find_dma_by_addr(pcilib_t *ctx, pcilib_dma_direction_t direction, pcilib_dma_engine_addr_t dma); int pcilib_read(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, size_t size, void *buf); int pcilib_write(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, size_t size, void *buf); int pcilib_write_fifo(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, uint8_t fifo_size, size_t n, void *buf); int pcilib_read_fifo(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, uint8_t fifo_size, size_t n, void *buf); - -typedef int (*pcilib_dma_callback_t)(void *ctx, pcilib_dma_flags_t flags, size_t bufsize, void *buf); - -int pcilib_skip_dma(pcilib_t *ctx, pcilib_dma_t dma); -size_t pcilib_stream_dma(pcilib_t *ctx, pcilib_dma_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, pcilib_dma_callback_t cb, void *cbattr); -size_t pcilib_push_dma(pcilib_t *ctx, pcilib_dma_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, void *buf); -size_t pcilib_read_dma(pcilib_t *ctx, pcilib_dma_t dma, uintptr_t addr, size_t size, void *buf); -size_t pcilib_write_dma(pcilib_t *ctx, pcilib_dma_t dma, uintptr_t addr, size_t size, void *buf); -double pcilib_benchmark_dma(pcilib_t *ctx, pcilib_dma_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction); +int pcilib_skip_dma(pcilib_t *ctx, pcilib_dma_engine_t dma); +size_t pcilib_stream_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, pcilib_dma_callback_t cb, void *cbattr); +size_t pcilib_push_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, pcilib_dma_flags_t flags, size_t timeout, void *buf); +size_t pcilib_read_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, void *buf); +size_t pcilib_write_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size_t size, void *buf); +double pcilib_benchmark_dma(pcilib_t *ctx, pcilib_dma_engine_addr_t dma, uintptr_t addr, size_t size, size_t iterations, pcilib_dma_direction_t direction); int pcilib_read_register_space(pcilib_t *ctx, const char *bank, pcilib_register_addr_t addr, size_t n, pcilib_register_value_t *buf); int pcilib_write_register_space(pcilib_t *ctx, const char *bank, pcilib_register_addr_t addr, size_t n, pcilib_register_value_t *buf); |