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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <linux/kernel.h>
21 #include "as102_drv.h"
22 #include "as10x_cmd.h"
25 * as10x_cmd_add_PID_filter - send add filter command to AS10x
26 * @adap: pointer to AS10x bus adapter
27 * @filter: TSFilter filter for DVB-T
29 * Return 0 on success or negative value in case of error.
31 int as10x_cmd_add_PID_filter(struct as10x_bus_adapter_t *adap,
32 struct as10x_ts_filter *filter)
35 struct as10x_cmd_t *pcmd, *prsp;
43 as10x_cmd_build(pcmd, (++adap->cmd_xid),
44 sizeof(pcmd->body.add_pid_filter.req));
47 pcmd->body.add_pid_filter.req.proc_id =
48 cpu_to_le16(CONTROL_PROC_SETFILTER);
49 pcmd->body.add_pid_filter.req.pid = cpu_to_le16(filter->pid);
50 pcmd->body.add_pid_filter.req.stream_type = filter->type;
53 pcmd->body.add_pid_filter.req.idx = filter->idx;
55 pcmd->body.add_pid_filter.req.idx = 0xFF;
58 if (adap->ops->xfer_cmd) {
59 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
60 sizeof(pcmd->body.add_pid_filter.req)
61 + HEADER_SIZE, (uint8_t *) prsp,
62 sizeof(prsp->body.add_pid_filter.rsp)
65 error = AS10X_CMD_ERROR;
72 error = as10x_rsp_parse(prsp, CONTROL_PROC_SETFILTER_RSP);
75 /* Response OK -> get response data */
76 filter->idx = prsp->body.add_pid_filter.rsp.filter_id;
85 * as10x_cmd_del_PID_filter - Send delete filter command to AS10x
86 * @adap: pointer to AS10x bus adapte
87 * @pid_value: PID to delete
89 * Return 0 on success or negative value in case of error.
91 int as10x_cmd_del_PID_filter(struct as10x_bus_adapter_t *adap,
95 struct as10x_cmd_t *pcmd, *prsp;
102 /* prepare command */
103 as10x_cmd_build(pcmd, (++adap->cmd_xid),
104 sizeof(pcmd->body.del_pid_filter.req));
107 pcmd->body.del_pid_filter.req.proc_id =
108 cpu_to_le16(CONTROL_PROC_REMOVEFILTER);
109 pcmd->body.del_pid_filter.req.pid = cpu_to_le16(pid_value);
112 if (adap->ops->xfer_cmd) {
113 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
114 sizeof(pcmd->body.del_pid_filter.req)
115 + HEADER_SIZE, (uint8_t *) prsp,
116 sizeof(prsp->body.del_pid_filter.rsp)
119 error = AS10X_CMD_ERROR;
126 error = as10x_rsp_parse(prsp, CONTROL_PROC_REMOVEFILTER_RSP);
134 * as10x_cmd_start_streaming - Send start streaming command to AS10x
135 * @adap: pointer to AS10x bus adapter
137 * Return 0 on success or negative value in case of error.
139 int as10x_cmd_start_streaming(struct as10x_bus_adapter_t *adap)
142 struct as10x_cmd_t *pcmd, *prsp;
149 /* prepare command */
150 as10x_cmd_build(pcmd, (++adap->cmd_xid),
151 sizeof(pcmd->body.start_streaming.req));
154 pcmd->body.start_streaming.req.proc_id =
155 cpu_to_le16(CONTROL_PROC_START_STREAMING);
158 if (adap->ops->xfer_cmd) {
159 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
160 sizeof(pcmd->body.start_streaming.req)
161 + HEADER_SIZE, (uint8_t *) prsp,
162 sizeof(prsp->body.start_streaming.rsp)
165 error = AS10X_CMD_ERROR;
172 error = as10x_rsp_parse(prsp, CONTROL_PROC_START_STREAMING_RSP);
180 * as10x_cmd_stop_streaming - Send stop streaming command to AS10x
181 * @adap: pointer to AS10x bus adapter
183 * Return 0 on success or negative value in case of error.
185 int as10x_cmd_stop_streaming(struct as10x_bus_adapter_t *adap)
188 struct as10x_cmd_t *pcmd, *prsp;
195 /* prepare command */
196 as10x_cmd_build(pcmd, (++adap->cmd_xid),
197 sizeof(pcmd->body.stop_streaming.req));
200 pcmd->body.stop_streaming.req.proc_id =
201 cpu_to_le16(CONTROL_PROC_STOP_STREAMING);
204 if (adap->ops->xfer_cmd) {
205 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
206 sizeof(pcmd->body.stop_streaming.req)
207 + HEADER_SIZE, (uint8_t *) prsp,
208 sizeof(prsp->body.stop_streaming.rsp)
211 error = AS10X_CMD_ERROR;
218 error = as10x_rsp_parse(prsp, CONTROL_PROC_STOP_STREAMING_RSP);