From a710557ef4f33bc286d8240fff950b974c9d5b01 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Sat, 22 Oct 2011 01:44:28 +0200 Subject: Provide information about active DMA engines & buffers --- dma.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'dma.c') diff --git a/dma.c b/dma.c index 1bab0f9..9527c0b 100644 --- a/dma.c +++ b/dma.c @@ -235,7 +235,7 @@ int pcilib_read_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size pcilib_dma_read_callback_context_t opts = { size, buf, 0 }; - + err = pcilib_stream_dma(ctx, dma, addr, size, PCILIB_DMA_FLAGS_DEFAULT, PCILIB_DMA_TIMEOUT, pcilib_dma_read_callback, &opts); if (read_bytes) *read_bytes = opts.pos; return err; @@ -325,3 +325,31 @@ double pcilib_benchmark_dma(pcilib_t *ctx, pcilib_dma_engine_addr_t dma, uintptr return ctx->model_info.dma_api->benchmark(ctx->dma_ctx, dma, addr, size, iterations, direction); } + +int pcilib_get_dma_status(pcilib_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_engine_status_t *status, size_t n_buffers, pcilib_dma_buffer_status_t *buffers) { + int err; + + const pcilib_dma_info_t *info = pcilib_get_dma_info(ctx); + if (!info) { + pcilib_error("DMA is not supported by the device"); + return 0; + } + + if (!ctx->model_info.dma_api) { + pcilib_error("DMA Engine is not configured in the current model"); + return -1; + } + + if (!ctx->model_info.dma_api->status) { + memset(status, 0, sizeof(pcilib_dma_engine_status_t)); + return -1; + } + + if (!info->engines[dma]) { + pcilib_error("The DMA engine (%i) is not supported by device", dma); + return -1; + } + + return ctx->model_info.dma_api->status(ctx->dma_ctx, dma, status, n_buffers, buffers); + +} -- cgit v1.2.3