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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
#include <stdio.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/poll.h>
#include <fcntl.h>
#include <ctype.h>
#include <termios.h>
#include <signal.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include "test-client.h"
#include <vs4l.h>
char node_name[30] = "/dev/vertex0";
int vpu_open(struct client *client)
{
int ret = 0;
client->fd = open(node_name, O_RDWR, 0);
if (client->fd <= 0) {
printf("%s():%d\n", __func__, client->fd);
ret = client->fd;
}
return ret;
}
int vpu_s_graph(struct client *client, struct vs4l_graph *graph)
{
int ret = 0;
if (graph->id == 0) graph->id = client->fd;
ret = ioctl(client->fd, VS4L_VERTEXIOC_S_GRAPH, graph);
if (ret)
printf("%s():%d\n", __func__, ret);
return ret;
}
int vpu_s_format(struct client *client, struct vs4l_format_list *flist)
{
int ret = 0;
ret = ioctl(client->fd, VS4L_VERTEXIOC_S_FORMAT, flist);
if (ret)
printf("%s():%d\n", __func__, ret);
return ret;
}
int vpu_s_param(struct client *client, struct vs4l_param_list *plist)
{
int ret = 0;
ret = ioctl(client->fd, VS4L_VERTEXIOC_S_PARAM, plist);
if (ret)
printf("%s():%d\n", __func__, ret);
return ret;
}
int vpu_s_ctrl(struct client *client, struct vs4l_ctrl *ctrl)
{
int ret = 0;
ret = ioctl(client->fd, VS4L_VERTEXIOC_S_CTRL, ctrl);
if (ret)
printf("%s():%d\n", __func__, ret);
return ret;
}
int vpu_stream_on(struct client *client)
{
int ret = 0;
ret = ioctl(client->fd, VS4L_VERTEXIOC_STREAM_ON, NULL);
if (ret)
printf("%s():%d\n", __func__, ret);
return ret;
}
int vpu_stream_off(struct client *client)
{
int ret = 0;
ret = ioctl(client->fd, VS4L_VERTEXIOC_STREAM_OFF, NULL);
if (ret)
printf("%s():%d\n", __func__, ret);
return ret;
}
int vpu_poll(struct client *client)
{
int ret = 0;
struct pollfd poll_events;
poll_events.fd = client->fd;
poll_events.events = POLLIN | POLLOUT | POLLERR;
poll_events.revents = 0;
ret = poll(&poll_events, 1, 1000);
if (!ret) {
printf("%s():%d\n", __func__, ret);
goto p_err;
}
if (!(poll_events.revents & POLLIN)) {
printf("POLLIN error\n");
ret = -EINVAL;
goto p_err;
}
if (!(poll_events.revents & POLLOUT)) {
printf("POLLOUT error\n");
ret = -EINVAL;
goto p_err;
}
p_err:
return ret;
}
int vpu_qbuf(struct client *client, struct vs4l_container_list *c)
{
int ret = 0;
ret = ioctl(client->fd, VS4L_VERTEXIOC_QBUF, c);
if (ret)
printf("%s():%d\n", __func__, ret);
return ret;
}
int vpu_dqbuf(struct client *client, struct vs4l_container_list *c)
{
int ret = 0;
ret = ioctl(client->fd, VS4L_VERTEXIOC_DQBUF, c);
if (ret) {
printf("%s():%d\n", __func__, ret);
goto p_err;
}
if (c->flags & (1 << VS4L_CL_FLAG_INVALID)) {
printf("%s(%d):INVALID(0x%X)\n", __func__, c->index, c->flags);
ret = -EINVAL;
goto p_err;
}
p_err:
return ret;
}
int vpu_close(struct client *client)
{
close(client->fd);
return 0;
}
|