dma.c 1.92 KB
Newer Older
1
2
3
4
#include <aml.h>
#include <assert.h>

/*******************************************************************************
5
6
7
8
9
10
 * Generic DMA API:
 * Most of the stuff is dispatched to a different layer, using type-specific
 * functions.
 *
 * Note that the API is slightly different than the functions bellow, as we
 * abstract the request creation after this layer.
11
12
 ******************************************************************************/

13
int aml_dma_copy(struct aml_dma *dma, ...)
14
{
15
16
17
	assert(dma != NULL);
	va_list ap;
	int ret;
18
	struct aml_dma_request *req;
19
20
21
22
	va_start(ap, dma);
	ret = dma->ops->create_request(dma->data, &req,
				       AML_DMA_REQUEST_TYPE_COPY, ap);
	va_end(ap);
23
	ret = dma->ops->wait_request(dma->data, req);
24
	return ret;
25
26
}

27
int aml_dma_async_copy(struct aml_dma *dma, struct aml_dma_request **req, ...)
28
{
29
30
31
32
33
34
35
36
37
	assert(dma != NULL);
	assert(req != NULL);
	va_list ap;
	int ret;
	va_start(ap, req);
	ret = dma->ops->create_request(dma->data, req,
				       AML_DMA_REQUEST_TYPE_COPY, ap);
	va_end(ap);
	return ret;
38
39
}

40
int aml_dma_move(struct aml_dma *dma, ...)
41
{
42
	assert(dma != NULL);
43
	struct aml_dma_request *req;
44
45
46
47
48
49
	va_list ap;
	int ret;
	va_start(ap, dma);
	ret = dma->ops->create_request(dma->data, &req,
				       AML_DMA_REQUEST_TYPE_MOVE, ap);
	va_end(ap);
50
	ret = dma->ops->wait_request(dma->data, req);
51
	return ret;
52
53
}

54

55
int aml_dma_async_move(struct aml_dma *dma, struct aml_dma_request **req, ...)
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{
	assert(dma != NULL);
	assert(req != NULL);
	va_list ap;
	int ret;
	va_start(ap, req);
	ret = dma->ops->create_request(dma->data, req,
				       AML_DMA_REQUEST_TYPE_MOVE, ap);
	va_end(ap);
	return ret;
}

int aml_dma_cancel(struct aml_dma *dma, struct aml_dma_request *req)
{
	assert(dma != NULL);
	assert(req != NULL);
	return dma->ops->destroy_request(dma->data, req);
}

int aml_dma_wait(struct aml_dma *dma, struct aml_dma_request *req)
76
{
77
78
79
	assert(dma != NULL);
	assert(req != NULL);
	return dma->ops->wait_request(dma->data, req);
80
}