3 \file as10x_cmd_stream.c
9 ----------------------------------------------------------------------------\n
10 (c) Copyright Abilis Systems SARL 2005-2009 All rigths reserved \n
12 ----------------------------------------------------------------------------\n
14 \brief AS10x CMD, stream services
16 AS10x CMD management: build command buffer, send command through
17 selected port and wait for the response when required.
22 #if defined(LINUX) && defined(__KERNEL__) /* linux kernel implementation */
23 #include <linux/kernel.h>
24 #include "as102_drv.h"
26 #if defined(DDK) /* win32 ddk implementation */
29 #include "endian_mgmt.h" /* FIXME */
30 #else /* win32 sdk implementation */
34 #include "as10x_handle.h"
35 #include "endian_mgmt.h"
37 #else /* all other cases */
41 #include "as10x_handle.h"
42 #include "endian_mgmt.h" /* FIXME */
43 #endif /* __KERNEL__ */
45 #include "as10x_cmd.h"
49 \brief send add filter command to AS10x
50 \param phandle: pointer to AS10x handle
51 \param filter: TSFilter filter for DVB-T
52 \param pfilter_handle: pointer where to store filter handle
53 \return 0 when no error, < 0 in case of error.
56 int as10x_cmd_add_PID_filter(as10x_handle_t
* phandle
,
57 struct as10x_ts_filter
*filter
) {
59 struct as10x_cmd_t
*pcmd
, *prsp
;
67 as10x_cmd_build(pcmd
, (++phandle
->cmd_xid
),
68 sizeof(pcmd
->body
.add_pid_filter
.req
));
71 pcmd
->body
.add_pid_filter
.req
.proc_id
= 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
;
76 pcmd
->body
.add_pid_filter
.req
.idx
= filter
->idx
;
78 pcmd
->body
.add_pid_filter
.req
.idx
= 0xFF;
81 if(phandle
->ops
->xfer_cmd
) {
82 error
= phandle
->ops
->xfer_cmd(phandle
,
84 sizeof(pcmd
->body
.add_pid_filter
.req
) + HEADER_SIZE
,
86 sizeof(prsp
->body
.add_pid_filter
.rsp
) + HEADER_SIZE
);
89 error
= AS10X_CMD_ERROR
;
97 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_SETFILTER_RSP
);
100 /* Response OK -> get response data */
101 filter
->idx
= prsp
->body
.add_pid_filter
.rsp
.filter_id
;
110 \brief Send delete filter command to AS10x
111 \param phandle: pointer to AS10x handle
112 \param filter_handle: filter handle
113 \return 0 when no error, < 0 in case of error.
116 int as10x_cmd_del_PID_filter(as10x_handle_t
* phandle
,
121 struct as10x_cmd_t
*pcmd
, *prsp
;
128 /* prepare command */
129 as10x_cmd_build(pcmd
, (++phandle
->cmd_xid
),
130 sizeof(pcmd
->body
.del_pid_filter
.req
));
133 pcmd
->body
.del_pid_filter
.req
.proc_id
= cpu_to_le16(CONTROL_PROC_REMOVEFILTER
);
134 pcmd
->body
.del_pid_filter
.req
.pid
= cpu_to_le16(pid_value
);
137 if(phandle
->ops
->xfer_cmd
){
138 error
= phandle
->ops
->xfer_cmd(phandle
,
140 sizeof(pcmd
->body
.del_pid_filter
.req
) + HEADER_SIZE
,
142 sizeof(prsp
->body
.del_pid_filter
.rsp
) + HEADER_SIZE
);
145 error
= AS10X_CMD_ERROR
;
153 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_REMOVEFILTER_RSP
);
161 \brief Send start streaming command to AS10x
162 \param phandle: pointer to AS10x handle
163 \return 0 when no error, < 0 in case of error.
166 int as10x_cmd_start_streaming(as10x_handle_t
* phandle
)
169 struct as10x_cmd_t
*pcmd
, *prsp
;
176 /* prepare command */
177 as10x_cmd_build(pcmd
, (++phandle
->cmd_xid
),
178 sizeof(pcmd
->body
.start_streaming
.req
));
181 pcmd
->body
.start_streaming
.req
.proc_id
=
182 cpu_to_le16(CONTROL_PROC_START_STREAMING
);
185 if(phandle
->ops
->xfer_cmd
){
186 error
= phandle
->ops
->xfer_cmd(phandle
,
188 sizeof(pcmd
->body
.start_streaming
.req
) + HEADER_SIZE
,
190 sizeof(prsp
->body
.start_streaming
.rsp
) + HEADER_SIZE
);
193 error
= AS10X_CMD_ERROR
;
201 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_START_STREAMING_RSP
);
209 \brief Send stop streaming command to AS10x
210 \param phandle: pointer to AS10x handle
211 \return 0 when no error, < 0 in case of error.
214 int as10x_cmd_stop_streaming(as10x_handle_t
* phandle
)
217 struct as10x_cmd_t
*pcmd
, *prsp
;
224 /* prepare command */
225 as10x_cmd_build(pcmd
, (++phandle
->cmd_xid
),
226 sizeof(pcmd
->body
.stop_streaming
.req
));
229 pcmd
->body
.stop_streaming
.req
.proc_id
=
230 cpu_to_le16(CONTROL_PROC_STOP_STREAMING
);
233 if(phandle
->ops
->xfer_cmd
){
234 error
= phandle
->ops
->xfer_cmd(phandle
,
236 sizeof(pcmd
->body
.stop_streaming
.req
) + HEADER_SIZE
,
238 sizeof(prsp
->body
.stop_streaming
.rsp
) + HEADER_SIZE
);
241 error
= AS10X_CMD_ERROR
;
249 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_STOP_STREAMING_RSP
);