1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Abilis Systems Single DVB-T Receiver
4 * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com>
7 #include <linux/kernel.h>
12 * as10x_cmd_add_PID_filter - send add filter command to AS10x
13 * @adap: pointer to AS10x bus adapter
14 * @filter: TSFilter filter for DVB-T
16 * Return 0 on success or negative value in case of error.
18 int as10x_cmd_add_PID_filter(struct as10x_bus_adapter_t
*adap
,
19 struct as10x_ts_filter
*filter
)
22 struct as10x_cmd_t
*pcmd
, *prsp
;
28 as10x_cmd_build(pcmd
, (++adap
->cmd_xid
),
29 sizeof(pcmd
->body
.add_pid_filter
.req
));
32 pcmd
->body
.add_pid_filter
.req
.proc_id
=
33 cpu_to_le16(CONTROL_PROC_SETFILTER
);
34 pcmd
->body
.add_pid_filter
.req
.pid
= cpu_to_le16(filter
->pid
);
35 pcmd
->body
.add_pid_filter
.req
.stream_type
= filter
->type
;
38 pcmd
->body
.add_pid_filter
.req
.idx
= filter
->idx
;
40 pcmd
->body
.add_pid_filter
.req
.idx
= 0xFF;
43 if (adap
->ops
->xfer_cmd
) {
44 error
= adap
->ops
->xfer_cmd(adap
, (uint8_t *) pcmd
,
45 sizeof(pcmd
->body
.add_pid_filter
.req
)
46 + HEADER_SIZE
, (uint8_t *) prsp
,
47 sizeof(prsp
->body
.add_pid_filter
.rsp
)
50 error
= AS10X_CMD_ERROR
;
57 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_SETFILTER_RSP
);
60 /* Response OK -> get response data */
61 filter
->idx
= prsp
->body
.add_pid_filter
.rsp
.filter_id
;
69 * as10x_cmd_del_PID_filter - Send delete filter command to AS10x
70 * @adap: pointer to AS10x bus adapte
71 * @pid_value: PID to delete
73 * Return 0 on success or negative value in case of error.
75 int as10x_cmd_del_PID_filter(struct as10x_bus_adapter_t
*adap
,
79 struct as10x_cmd_t
*pcmd
, *prsp
;
85 as10x_cmd_build(pcmd
, (++adap
->cmd_xid
),
86 sizeof(pcmd
->body
.del_pid_filter
.req
));
89 pcmd
->body
.del_pid_filter
.req
.proc_id
=
90 cpu_to_le16(CONTROL_PROC_REMOVEFILTER
);
91 pcmd
->body
.del_pid_filter
.req
.pid
= cpu_to_le16(pid_value
);
94 if (adap
->ops
->xfer_cmd
) {
95 error
= adap
->ops
->xfer_cmd(adap
, (uint8_t *) pcmd
,
96 sizeof(pcmd
->body
.del_pid_filter
.req
)
97 + HEADER_SIZE
, (uint8_t *) prsp
,
98 sizeof(prsp
->body
.del_pid_filter
.rsp
)
101 error
= AS10X_CMD_ERROR
;
108 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_REMOVEFILTER_RSP
);
115 * as10x_cmd_start_streaming - Send start streaming command to AS10x
116 * @adap: pointer to AS10x bus adapter
118 * Return 0 on success or negative value in case of error.
120 int as10x_cmd_start_streaming(struct as10x_bus_adapter_t
*adap
)
123 struct as10x_cmd_t
*pcmd
, *prsp
;
128 /* prepare command */
129 as10x_cmd_build(pcmd
, (++adap
->cmd_xid
),
130 sizeof(pcmd
->body
.start_streaming
.req
));
133 pcmd
->body
.start_streaming
.req
.proc_id
=
134 cpu_to_le16(CONTROL_PROC_START_STREAMING
);
137 if (adap
->ops
->xfer_cmd
) {
138 error
= adap
->ops
->xfer_cmd(adap
, (uint8_t *) pcmd
,
139 sizeof(pcmd
->body
.start_streaming
.req
)
140 + HEADER_SIZE
, (uint8_t *) prsp
,
141 sizeof(prsp
->body
.start_streaming
.rsp
)
144 error
= AS10X_CMD_ERROR
;
151 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_START_STREAMING_RSP
);
158 * as10x_cmd_stop_streaming - Send stop streaming command to AS10x
159 * @adap: pointer to AS10x bus adapter
161 * Return 0 on success or negative value in case of error.
163 int as10x_cmd_stop_streaming(struct as10x_bus_adapter_t
*adap
)
166 struct as10x_cmd_t
*pcmd
, *prsp
;
171 /* prepare command */
172 as10x_cmd_build(pcmd
, (++adap
->cmd_xid
),
173 sizeof(pcmd
->body
.stop_streaming
.req
));
176 pcmd
->body
.stop_streaming
.req
.proc_id
=
177 cpu_to_le16(CONTROL_PROC_STOP_STREAMING
);
180 if (adap
->ops
->xfer_cmd
) {
181 error
= adap
->ops
->xfer_cmd(adap
, (uint8_t *) pcmd
,
182 sizeof(pcmd
->body
.stop_streaming
.req
)
183 + HEADER_SIZE
, (uint8_t *) prsp
,
184 sizeof(prsp
->body
.stop_streaming
.rsp
)
187 error
= AS10X_CMD_ERROR
;
194 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_STOP_STREAMING_RSP
);