Merge branch 'for-linus' of git://git.kernel.dk/linux-block
[deliverable/linux.git] / drivers / staging / media / as102 / as10x_cmd_stream.c
CommitLineData
315cadc4
PH
1/*
2 * Abilis Systems Single DVB-T Receiver
3 * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com>
4 *
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)
8 * any later version.
9 *
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.
14 *
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.
18 */
f080c2ef 19
41b44e04
PH
20#include <linux/kernel.h>
21#include "as102_drv.h"
41b44e04
PH
22#include "as10x_cmd.h"
23
41b44e04 24/**
3b4544a3 25 * as10x_cmd_add_PID_filter - send add filter command to AS10x
34490a0a 26 * @adap: pointer to AS10x bus adapter
3b4544a3
SN
27 * @filter: TSFilter filter for DVB-T
28 *
29 * Return 0 on success or negative value in case of error.
30 */
34490a0a 31int as10x_cmd_add_PID_filter(struct as10x_bus_adapter_t *adap,
79848e9a
DH
32 struct as10x_ts_filter *filter)
33{
34 int error;
35 struct as10x_cmd_t *pcmd, *prsp;
36
37 ENTER();
38
34490a0a
SN
39 pcmd = adap->cmd;
40 prsp = adap->rsp;
79848e9a
DH
41
42 /* prepare command */
34490a0a 43 as10x_cmd_build(pcmd, (++adap->cmd_xid),
79848e9a
DH
44 sizeof(pcmd->body.add_pid_filter.req));
45
46 /* fill command */
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;
51
52 if (filter->idx < 16)
53 pcmd->body.add_pid_filter.req.idx = filter->idx;
54 else
55 pcmd->body.add_pid_filter.req.idx = 0xFF;
56
57 /* send command */
34490a0a
SN
58 if (adap->ops->xfer_cmd) {
59 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
79848e9a
DH
60 sizeof(pcmd->body.add_pid_filter.req)
61 + HEADER_SIZE, (uint8_t *) prsp,
62 sizeof(prsp->body.add_pid_filter.rsp)
63 + HEADER_SIZE);
64 } else {
65 error = AS10X_CMD_ERROR;
66 }
67
68 if (error < 0)
69 goto out;
70
71 /* parse response */
72 error = as10x_rsp_parse(prsp, CONTROL_PROC_SETFILTER_RSP);
73
74 if (error == 0) {
75 /* Response OK -> get response data */
76 filter->idx = prsp->body.add_pid_filter.rsp.filter_id;
77 }
41b44e04
PH
78
79out:
79848e9a
DH
80 LEAVE();
81 return error;
41b44e04
PH
82}
83
84/**
3b4544a3 85 * as10x_cmd_del_PID_filter - Send delete filter command to AS10x
34490a0a 86 * @adap: pointer to AS10x bus adapte
3b4544a3
SN
87 * @pid_value: PID to delete
88 *
89 * Return 0 on success or negative value in case of error.
90 */
34490a0a 91int as10x_cmd_del_PID_filter(struct as10x_bus_adapter_t *adap,
41b44e04
PH
92 uint16_t pid_value)
93{
79848e9a
DH
94 int error;
95 struct as10x_cmd_t *pcmd, *prsp;
41b44e04 96
79848e9a 97 ENTER();
41b44e04 98
34490a0a
SN
99 pcmd = adap->cmd;
100 prsp = adap->rsp;
41b44e04 101
79848e9a 102 /* prepare command */
34490a0a 103 as10x_cmd_build(pcmd, (++adap->cmd_xid),
79848e9a 104 sizeof(pcmd->body.del_pid_filter.req));
41b44e04 105
79848e9a
DH
106 /* fill command */
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);
41b44e04 110
79848e9a 111 /* send command */
34490a0a
SN
112 if (adap->ops->xfer_cmd) {
113 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
79848e9a
DH
114 sizeof(pcmd->body.del_pid_filter.req)
115 + HEADER_SIZE, (uint8_t *) prsp,
116 sizeof(prsp->body.del_pid_filter.rsp)
117 + HEADER_SIZE);
118 } else {
119 error = AS10X_CMD_ERROR;
120 }
41b44e04 121
79848e9a
DH
122 if (error < 0)
123 goto out;
41b44e04 124
79848e9a
DH
125 /* parse response */
126 error = as10x_rsp_parse(prsp, CONTROL_PROC_REMOVEFILTER_RSP);
41b44e04
PH
127
128out:
79848e9a
DH
129 LEAVE();
130 return error;
41b44e04
PH
131}
132
133/**
3b4544a3 134 * as10x_cmd_start_streaming - Send start streaming command to AS10x
34490a0a 135 * @adap: pointer to AS10x bus adapter
3b4544a3
SN
136 *
137 * Return 0 on success or negative value in case of error.
138 */
34490a0a 139int as10x_cmd_start_streaming(struct as10x_bus_adapter_t *adap)
41b44e04 140{
79848e9a
DH
141 int error;
142 struct as10x_cmd_t *pcmd, *prsp;
41b44e04 143
79848e9a 144 ENTER();
41b44e04 145
34490a0a
SN
146 pcmd = adap->cmd;
147 prsp = adap->rsp;
41b44e04 148
79848e9a 149 /* prepare command */
34490a0a 150 as10x_cmd_build(pcmd, (++adap->cmd_xid),
79848e9a 151 sizeof(pcmd->body.start_streaming.req));
41b44e04 152
79848e9a
DH
153 /* fill command */
154 pcmd->body.start_streaming.req.proc_id =
155 cpu_to_le16(CONTROL_PROC_START_STREAMING);
41b44e04 156
79848e9a 157 /* send command */
34490a0a
SN
158 if (adap->ops->xfer_cmd) {
159 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
79848e9a
DH
160 sizeof(pcmd->body.start_streaming.req)
161 + HEADER_SIZE, (uint8_t *) prsp,
162 sizeof(prsp->body.start_streaming.rsp)
163 + HEADER_SIZE);
164 } else {
165 error = AS10X_CMD_ERROR;
166 }
41b44e04 167
79848e9a
DH
168 if (error < 0)
169 goto out;
41b44e04 170
79848e9a
DH
171 /* parse response */
172 error = as10x_rsp_parse(prsp, CONTROL_PROC_START_STREAMING_RSP);
41b44e04
PH
173
174out:
79848e9a
DH
175 LEAVE();
176 return error;
41b44e04
PH
177}
178
179/**
3b4544a3 180 * as10x_cmd_stop_streaming - Send stop streaming command to AS10x
34490a0a 181 * @adap: pointer to AS10x bus adapter
3b4544a3
SN
182 *
183 * Return 0 on success or negative value in case of error.
184 */
34490a0a 185int as10x_cmd_stop_streaming(struct as10x_bus_adapter_t *adap)
41b44e04 186{
79848e9a
DH
187 int8_t error;
188 struct as10x_cmd_t *pcmd, *prsp;
41b44e04 189
79848e9a 190 ENTER();
41b44e04 191
34490a0a
SN
192 pcmd = adap->cmd;
193 prsp = adap->rsp;
41b44e04 194
79848e9a 195 /* prepare command */
34490a0a 196 as10x_cmd_build(pcmd, (++adap->cmd_xid),
79848e9a 197 sizeof(pcmd->body.stop_streaming.req));
41b44e04 198
79848e9a
DH
199 /* fill command */
200 pcmd->body.stop_streaming.req.proc_id =
201 cpu_to_le16(CONTROL_PROC_STOP_STREAMING);
41b44e04 202
79848e9a 203 /* send command */
34490a0a
SN
204 if (adap->ops->xfer_cmd) {
205 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
79848e9a
DH
206 sizeof(pcmd->body.stop_streaming.req)
207 + HEADER_SIZE, (uint8_t *) prsp,
208 sizeof(prsp->body.stop_streaming.rsp)
209 + HEADER_SIZE);
210 } else {
211 error = AS10X_CMD_ERROR;
212 }
41b44e04 213
79848e9a
DH
214 if (error < 0)
215 goto out;
41b44e04 216
79848e9a
DH
217 /* parse response */
218 error = as10x_rsp_parse(prsp, CONTROL_PROC_STOP_STREAMING_RSP);
41b44e04
PH
219
220out:
79848e9a
DH
221 LEAVE();
222 return error;
41b44e04 223}
This page took 0.05513 seconds and 5 git commands to generate.