-
Notifications
You must be signed in to change notification settings - Fork 2
/
ca0132-send-dsp-scp-cmd.c
83 lines (66 loc) · 1.34 KB
/
ca0132-send-dsp-scp-cmd.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* ca0132-send-dsp-scp-cmd:
* Sends a single DSP scp command.
*/
#include "ca0132_defs.h"
static void usage(char *pname)
{
fprintf(stderr, "usage: %s <hwdep-device>\n", pname);
}
int main(int argc, char **argv)
{
uint32_t src_id, req, size, mid, i, tmp, hdr;
struct scp_data scp_cmd;
uint32_t data[0x20];
int fd, ret;
if (argc < 2) {
usage(argv[0]);
return 1;
}
ret = open_hwdep(argv[1], &fd);
if (ret)
return ret;
while (1) {
printf("Enter src_id:\n");
if (!scanf("%x", &src_id))
break;
printf("Enter mid:\n");
if (!scanf("%x", &mid))
break;
printf("Enter req:\n");
if (!scanf("%x", &req))
break;
printf("Enter data size:\n");
if (!scanf("%x", &size))
break;
if (size > 0x1f) {
printf("Data size too large, try again.\n");
continue;
}
tmp = 0;
for (i = 0; i < size; i++) {
printf("Enter data[%d]:\n", i);
if (!scanf("%x", &data[i])) {
tmp = 1;
break;
}
}
if (tmp)
break;
pack_scp_data(&scp_cmd, size, req, src_id, mid);
hdr = create_scp_header(&scp_cmd);
if (dspio_write(fd, hdr)) {
printf("DSP busy, try again.\n");
continue;
}
for (i = 0; i < size; i++) {
if (dspio_write(fd, data[i])) {
printf("DSP busy, try again.\n");
break;
}
}
}
printf("Invalid data entry, exiting.\n");
close(fd);
return 0;
}