2 * Abilis Systems Single DVB-T Receiver
3 * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #include <linux/kernel.h>
17 #include "as102_drv.h"
18 #include "as10x_cmd.h"
21 * as10x_cmd_add_PID_filter - send add filter command to AS10x
22 * @adap: pointer to AS10x bus adapter
23 * @filter: TSFilter filter for DVB-T
25 * Return 0 on success or negative value in case of error.
27 int as10x_cmd_add_PID_filter(struct as10x_bus_adapter_t
*adap
,
28 struct as10x_ts_filter
*filter
)
31 struct as10x_cmd_t
*pcmd
, *prsp
;
37 as10x_cmd_build(pcmd
, (++adap
->cmd_xid
),
38 sizeof(pcmd
->body
.add_pid_filter
.req
));
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
;
47 pcmd
->body
.add_pid_filter
.req
.idx
= filter
->idx
;
49 pcmd
->body
.add_pid_filter
.req
.idx
= 0xFF;
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
)
59 error
= AS10X_CMD_ERROR
;
66 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_SETFILTER_RSP
);
69 /* Response OK -> get response data */
70 filter
->idx
= prsp
->body
.add_pid_filter
.rsp
.filter_id
;
78 * as10x_cmd_del_PID_filter - Send delete filter command to AS10x
79 * @adap: pointer to AS10x bus adapte
80 * @pid_value: PID to delete
82 * Return 0 on success or negative value in case of error.
84 int as10x_cmd_del_PID_filter(struct as10x_bus_adapter_t
*adap
,
88 struct as10x_cmd_t
*pcmd
, *prsp
;
94 as10x_cmd_build(pcmd
, (++adap
->cmd_xid
),
95 sizeof(pcmd
->body
.del_pid_filter
.req
));
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
);
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
)
110 error
= AS10X_CMD_ERROR
;
117 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_REMOVEFILTER_RSP
);
124 * as10x_cmd_start_streaming - Send start streaming command to AS10x
125 * @adap: pointer to AS10x bus adapter
127 * Return 0 on success or negative value in case of error.
129 int as10x_cmd_start_streaming(struct as10x_bus_adapter_t
*adap
)
132 struct as10x_cmd_t
*pcmd
, *prsp
;
137 /* prepare command */
138 as10x_cmd_build(pcmd
, (++adap
->cmd_xid
),
139 sizeof(pcmd
->body
.start_streaming
.req
));
142 pcmd
->body
.start_streaming
.req
.proc_id
=
143 cpu_to_le16(CONTROL_PROC_START_STREAMING
);
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
)
153 error
= AS10X_CMD_ERROR
;
160 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_START_STREAMING_RSP
);
167 * as10x_cmd_stop_streaming - Send stop streaming command to AS10x
168 * @adap: pointer to AS10x bus adapter
170 * Return 0 on success or negative value in case of error.
172 int as10x_cmd_stop_streaming(struct as10x_bus_adapter_t
*adap
)
175 struct as10x_cmd_t
*pcmd
, *prsp
;
180 /* prepare command */
181 as10x_cmd_build(pcmd
, (++adap
->cmd_xid
),
182 sizeof(pcmd
->body
.stop_streaming
.req
));
185 pcmd
->body
.stop_streaming
.req
.proc_id
=
186 cpu_to_le16(CONTROL_PROC_STOP_STREAMING
);
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
)
196 error
= AS10X_CMD_ERROR
;
203 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_STOP_STREAMING_RSP
);