1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include <linux/kernel.h>
17#include "as102_drv.h"
18#include "as10x_cmd.h"
19
20
21
22
23
24
25
26
27int as10x_cmd_add_PID_filter(struct as10x_bus_adapter_t *adap,
28 struct as10x_ts_filter *filter)
29{
30 int error;
31 struct as10x_cmd_t *pcmd, *prsp;
32
33 pcmd = adap->cmd;
34 prsp = adap->rsp;
35
36
37 as10x_cmd_build(pcmd, (++adap->cmd_xid),
38 sizeof(pcmd->body.add_pid_filter.req));
39
40
41 pcmd->body.add_pid_filter.req.proc_id =
42 cpu_to_le16(CONTROL_PROC_SETFILTER);
43 pcmd->body.add_pid_filter.req.pid = cpu_to_le16(filter->pid);
44 pcmd->body.add_pid_filter.req.stream_type = filter->type;
45
46 if (filter->idx < 16)
47 pcmd->body.add_pid_filter.req.idx = filter->idx;
48 else
49 pcmd->body.add_pid_filter.req.idx = 0xFF;
50
51
52 if (adap->ops->xfer_cmd) {
53 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
54 sizeof(pcmd->body.add_pid_filter.req)
55 + HEADER_SIZE, (uint8_t *) prsp,
56 sizeof(prsp->body.add_pid_filter.rsp)
57 + HEADER_SIZE);
58 } else {
59 error = AS10X_CMD_ERROR;
60 }
61
62 if (error < 0)
63 goto out;
64
65
66 error = as10x_rsp_parse(prsp, CONTROL_PROC_SETFILTER_RSP);
67
68 if (error == 0) {
69
70 filter->idx = prsp->body.add_pid_filter.rsp.filter_id;
71 }
72
73out:
74 return error;
75}
76
77
78
79
80
81
82
83
84int as10x_cmd_del_PID_filter(struct as10x_bus_adapter_t *adap,
85 uint16_t pid_value)
86{
87 int error;
88 struct as10x_cmd_t *pcmd, *prsp;
89
90 pcmd = adap->cmd;
91 prsp = adap->rsp;
92
93
94 as10x_cmd_build(pcmd, (++adap->cmd_xid),
95 sizeof(pcmd->body.del_pid_filter.req));
96
97
98 pcmd->body.del_pid_filter.req.proc_id =
99 cpu_to_le16(CONTROL_PROC_REMOVEFILTER);
100 pcmd->body.del_pid_filter.req.pid = cpu_to_le16(pid_value);
101
102
103 if (adap->ops->xfer_cmd) {
104 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
105 sizeof(pcmd->body.del_pid_filter.req)
106 + HEADER_SIZE, (uint8_t *) prsp,
107 sizeof(prsp->body.del_pid_filter.rsp)
108 + HEADER_SIZE);
109 } else {
110 error = AS10X_CMD_ERROR;
111 }
112
113 if (error < 0)
114 goto out;
115
116
117 error = as10x_rsp_parse(prsp, CONTROL_PROC_REMOVEFILTER_RSP);
118
119out:
120 return error;
121}
122
123
124
125
126
127
128
129int as10x_cmd_start_streaming(struct as10x_bus_adapter_t *adap)
130{
131 int error;
132 struct as10x_cmd_t *pcmd, *prsp;
133
134 pcmd = adap->cmd;
135 prsp = adap->rsp;
136
137
138 as10x_cmd_build(pcmd, (++adap->cmd_xid),
139 sizeof(pcmd->body.start_streaming.req));
140
141
142 pcmd->body.start_streaming.req.proc_id =
143 cpu_to_le16(CONTROL_PROC_START_STREAMING);
144
145
146 if (adap->ops->xfer_cmd) {
147 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
148 sizeof(pcmd->body.start_streaming.req)
149 + HEADER_SIZE, (uint8_t *) prsp,
150 sizeof(prsp->body.start_streaming.rsp)
151 + HEADER_SIZE);
152 } else {
153 error = AS10X_CMD_ERROR;
154 }
155
156 if (error < 0)
157 goto out;
158
159
160 error = as10x_rsp_parse(prsp, CONTROL_PROC_START_STREAMING_RSP);
161
162out:
163 return error;
164}
165
166
167
168
169
170
171
172int as10x_cmd_stop_streaming(struct as10x_bus_adapter_t *adap)
173{
174 int8_t error;
175 struct as10x_cmd_t *pcmd, *prsp;
176
177 pcmd = adap->cmd;
178 prsp = adap->rsp;
179
180
181 as10x_cmd_build(pcmd, (++adap->cmd_xid),
182 sizeof(pcmd->body.stop_streaming.req));
183
184
185 pcmd->body.stop_streaming.req.proc_id =
186 cpu_to_le16(CONTROL_PROC_STOP_STREAMING);
187
188
189 if (adap->ops->xfer_cmd) {
190 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
191 sizeof(pcmd->body.stop_streaming.req)
192 + HEADER_SIZE, (uint8_t *) prsp,
193 sizeof(prsp->body.stop_streaming.rsp)
194 + HEADER_SIZE);
195 } else {
196 error = AS10X_CMD_ERROR;
197 }
198
199 if (error < 0)
200 goto out;
201
202
203 error = as10x_rsp_parse(prsp, CONTROL_PROC_STOP_STREAMING_RSP);
204
205out:
206 return error;
207}
208