[media] staging: as102: Fix CodingStyle errors in file as10x_cmd_stream.c
[deliverable/linux.git] / drivers / staging / media / as102 / as10x_cmd_stream.c
CommitLineData
41b44e04
PH
1/**
2
3 \file as10x_cmd_stream.c
4
41b44e04
PH
5 \author: S. Martinelli
6
7 ----------------------------------------------------------------------------\n
8 (c) Copyright Abilis Systems SARL 2005-2009 All rigths reserved \n
9 www.abilis.com \n
10 ----------------------------------------------------------------------------\n
11
12 \brief AS10x CMD, stream services
13
14 AS10x CMD management: build command buffer, send command through
15 selected port and wait for the response when required.
16
17*/
18
19
20#if defined(LINUX) && defined(__KERNEL__) /* linux kernel implementation */
21#include <linux/kernel.h>
22#include "as102_drv.h"
23#elif defined(WIN32)
24 #if defined(DDK) /* win32 ddk implementation */
25 #include "wdm.h"
26 #include "Device.h"
27 #include "endian_mgmt.h" /* FIXME */
28 #else /* win32 sdk implementation */
29 #include <windows.h>
30 #include "types.h"
31 #include "util.h"
32 #include "as10x_handle.h"
33 #include "endian_mgmt.h"
34 #endif
35#else /* all other cases */
36 #include <string.h>
37 #include "types.h"
38 #include "util.h"
39 #include "as10x_handle.h"
40 #include "endian_mgmt.h" /* FIXME */
41#endif /* __KERNEL__ */
42
43#include "as10x_cmd.h"
44
45
46/**
47 \brief send add filter command to AS10x
48 \param phandle: pointer to AS10x handle
49 \param filter: TSFilter filter for DVB-T
50 \param pfilter_handle: pointer where to store filter handle
51 \return 0 when no error, < 0 in case of error.
52 \callgraph
53*/
79848e9a
DH
54int as10x_cmd_add_PID_filter(as10x_handle_t *phandle,
55 struct as10x_ts_filter *filter)
56{
57 int error;
58 struct as10x_cmd_t *pcmd, *prsp;
59
60 ENTER();
61
62 pcmd = phandle->cmd;
63 prsp = phandle->rsp;
64
65 /* prepare command */
66 as10x_cmd_build(pcmd, (++phandle->cmd_xid),
67 sizeof(pcmd->body.add_pid_filter.req));
68
69 /* fill command */
70 pcmd->body.add_pid_filter.req.proc_id =
71 cpu_to_le16(CONTROL_PROC_SETFILTER);
72 pcmd->body.add_pid_filter.req.pid = cpu_to_le16(filter->pid);
73 pcmd->body.add_pid_filter.req.stream_type = filter->type;
74
75 if (filter->idx < 16)
76 pcmd->body.add_pid_filter.req.idx = filter->idx;
77 else
78 pcmd->body.add_pid_filter.req.idx = 0xFF;
79
80 /* send command */
81 if (phandle->ops->xfer_cmd) {
82 error = phandle->ops->xfer_cmd(phandle, (uint8_t *) pcmd,
83 sizeof(pcmd->body.add_pid_filter.req)
84 + HEADER_SIZE, (uint8_t *) prsp,
85 sizeof(prsp->body.add_pid_filter.rsp)
86 + HEADER_SIZE);
87 } else {
88 error = AS10X_CMD_ERROR;
89 }
90
91 if (error < 0)
92 goto out;
93
94 /* parse response */
95 error = as10x_rsp_parse(prsp, CONTROL_PROC_SETFILTER_RSP);
96
97 if (error == 0) {
98 /* Response OK -> get response data */
99 filter->idx = prsp->body.add_pid_filter.rsp.filter_id;
100 }
41b44e04
PH
101
102out:
79848e9a
DH
103 LEAVE();
104 return error;
41b44e04
PH
105}
106
107/**
108 \brief Send delete filter command to AS10x
109 \param phandle: pointer to AS10x handle
110 \param filter_handle: filter handle
111 \return 0 when no error, < 0 in case of error.
112 \callgraph
113*/
79848e9a 114int as10x_cmd_del_PID_filter(as10x_handle_t *phandle,
41b44e04
PH
115 uint16_t pid_value)
116{
79848e9a
DH
117 int error;
118 struct as10x_cmd_t *pcmd, *prsp;
41b44e04 119
79848e9a 120 ENTER();
41b44e04 121
79848e9a
DH
122 pcmd = phandle->cmd;
123 prsp = phandle->rsp;
41b44e04 124
79848e9a
DH
125 /* prepare command */
126 as10x_cmd_build(pcmd, (++phandle->cmd_xid),
127 sizeof(pcmd->body.del_pid_filter.req));
41b44e04 128
79848e9a
DH
129 /* fill command */
130 pcmd->body.del_pid_filter.req.proc_id =
131 cpu_to_le16(CONTROL_PROC_REMOVEFILTER);
132 pcmd->body.del_pid_filter.req.pid = cpu_to_le16(pid_value);
41b44e04 133
79848e9a
DH
134 /* send command */
135 if (phandle->ops->xfer_cmd) {
136 error = phandle->ops->xfer_cmd(phandle, (uint8_t *) pcmd,
137 sizeof(pcmd->body.del_pid_filter.req)
138 + HEADER_SIZE, (uint8_t *) prsp,
139 sizeof(prsp->body.del_pid_filter.rsp)
140 + HEADER_SIZE);
141 } else {
142 error = AS10X_CMD_ERROR;
143 }
41b44e04 144
79848e9a
DH
145 if (error < 0)
146 goto out;
41b44e04 147
79848e9a
DH
148 /* parse response */
149 error = as10x_rsp_parse(prsp, CONTROL_PROC_REMOVEFILTER_RSP);
41b44e04
PH
150
151out:
79848e9a
DH
152 LEAVE();
153 return error;
41b44e04
PH
154}
155
156/**
157 \brief Send start streaming command to AS10x
158 \param phandle: pointer to AS10x handle
79848e9a 159 \return 0 when no error, < 0 in case of error.
41b44e04
PH
160 \callgraph
161*/
79848e9a 162int as10x_cmd_start_streaming(as10x_handle_t *phandle)
41b44e04 163{
79848e9a
DH
164 int error;
165 struct as10x_cmd_t *pcmd, *prsp;
41b44e04 166
79848e9a 167 ENTER();
41b44e04 168
79848e9a
DH
169 pcmd = phandle->cmd;
170 prsp = phandle->rsp;
41b44e04 171
79848e9a
DH
172 /* prepare command */
173 as10x_cmd_build(pcmd, (++phandle->cmd_xid),
174 sizeof(pcmd->body.start_streaming.req));
41b44e04 175
79848e9a
DH
176 /* fill command */
177 pcmd->body.start_streaming.req.proc_id =
178 cpu_to_le16(CONTROL_PROC_START_STREAMING);
41b44e04 179
79848e9a
DH
180 /* send command */
181 if (phandle->ops->xfer_cmd) {
182 error = phandle->ops->xfer_cmd(phandle, (uint8_t *) pcmd,
183 sizeof(pcmd->body.start_streaming.req)
184 + HEADER_SIZE, (uint8_t *) prsp,
185 sizeof(prsp->body.start_streaming.rsp)
186 + HEADER_SIZE);
187 } else {
188 error = AS10X_CMD_ERROR;
189 }
41b44e04 190
79848e9a
DH
191 if (error < 0)
192 goto out;
41b44e04 193
79848e9a
DH
194 /* parse response */
195 error = as10x_rsp_parse(prsp, CONTROL_PROC_START_STREAMING_RSP);
41b44e04
PH
196
197out:
79848e9a
DH
198 LEAVE();
199 return error;
41b44e04
PH
200}
201
202/**
203 \brief Send stop streaming command to AS10x
204 \param phandle: pointer to AS10x handle
79848e9a 205 \return 0 when no error, < 0 in case of error.
41b44e04
PH
206 \callgraph
207*/
79848e9a 208int as10x_cmd_stop_streaming(as10x_handle_t *phandle)
41b44e04 209{
79848e9a
DH
210 int8_t error;
211 struct as10x_cmd_t *pcmd, *prsp;
41b44e04 212
79848e9a 213 ENTER();
41b44e04 214
79848e9a
DH
215 pcmd = phandle->cmd;
216 prsp = phandle->rsp;
41b44e04 217
79848e9a
DH
218 /* prepare command */
219 as10x_cmd_build(pcmd, (++phandle->cmd_xid),
220 sizeof(pcmd->body.stop_streaming.req));
41b44e04 221
79848e9a
DH
222 /* fill command */
223 pcmd->body.stop_streaming.req.proc_id =
224 cpu_to_le16(CONTROL_PROC_STOP_STREAMING);
41b44e04 225
79848e9a
DH
226 /* send command */
227 if (phandle->ops->xfer_cmd) {
228 error = phandle->ops->xfer_cmd(phandle, (uint8_t *) pcmd,
229 sizeof(pcmd->body.stop_streaming.req)
230 + HEADER_SIZE, (uint8_t *) prsp,
231 sizeof(prsp->body.stop_streaming.rsp)
232 + HEADER_SIZE);
233 } else {
234 error = AS10X_CMD_ERROR;
235 }
41b44e04 236
79848e9a
DH
237 if (error < 0)
238 goto out;
41b44e04 239
79848e9a
DH
240 /* parse response */
241 error = as10x_rsp_parse(prsp, CONTROL_PROC_STOP_STREAMING_RSP);
41b44e04
PH
242
243out:
79848e9a
DH
244 LEAVE();
245 return error;
41b44e04
PH
246}
247
248
This page took 0.044743 seconds and 5 git commands to generate.