3 \file as10x_cmd_stream.c
7 ----------------------------------------------------------------------------\n
8 (c) Copyright Abilis Systems SARL 2005-2009 All rigths reserved \n
10 ----------------------------------------------------------------------------\n
12 \brief AS10x CMD, stream services
14 AS10x CMD management: build command buffer, send command through
15 selected port and wait for the response when required.
20 #if defined(LINUX) && defined(__KERNEL__) /* linux kernel implementation */
21 #include <linux/kernel.h>
22 #include "as102_drv.h"
24 #if defined(DDK) /* win32 ddk implementation */
27 #include "endian_mgmt.h" /* FIXME */
28 #else /* win32 sdk implementation */
32 #include "as10x_handle.h"
33 #include "endian_mgmt.h"
35 #else /* all other cases */
39 #include "as10x_handle.h"
40 #include "endian_mgmt.h" /* FIXME */
41 #endif /* __KERNEL__ */
43 #include "as10x_cmd.h"
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.
54 int as10x_cmd_add_PID_filter(as10x_handle_t
*phandle
,
55 struct as10x_ts_filter
*filter
)
58 struct as10x_cmd_t
*pcmd
, *prsp
;
66 as10x_cmd_build(pcmd
, (++phandle
->cmd_xid
),
67 sizeof(pcmd
->body
.add_pid_filter
.req
));
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
;
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
, (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
)
88 error
= AS10X_CMD_ERROR
;
95 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_SETFILTER_RSP
);
98 /* Response OK -> get response data */
99 filter
->idx
= prsp
->body
.add_pid_filter
.rsp
.filter_id
;
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.
114 int as10x_cmd_del_PID_filter(as10x_handle_t
*phandle
,
118 struct as10x_cmd_t
*pcmd
, *prsp
;
125 /* prepare command */
126 as10x_cmd_build(pcmd
, (++phandle
->cmd_xid
),
127 sizeof(pcmd
->body
.del_pid_filter
.req
));
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
);
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
)
142 error
= AS10X_CMD_ERROR
;
149 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_REMOVEFILTER_RSP
);
157 \brief Send start streaming command to AS10x
158 \param phandle: pointer to AS10x handle
159 \return 0 when no error, < 0 in case of error.
162 int as10x_cmd_start_streaming(as10x_handle_t
*phandle
)
165 struct as10x_cmd_t
*pcmd
, *prsp
;
172 /* prepare command */
173 as10x_cmd_build(pcmd
, (++phandle
->cmd_xid
),
174 sizeof(pcmd
->body
.start_streaming
.req
));
177 pcmd
->body
.start_streaming
.req
.proc_id
=
178 cpu_to_le16(CONTROL_PROC_START_STREAMING
);
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
)
188 error
= AS10X_CMD_ERROR
;
195 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_START_STREAMING_RSP
);
203 \brief Send stop streaming command to AS10x
204 \param phandle: pointer to AS10x handle
205 \return 0 when no error, < 0 in case of error.
208 int as10x_cmd_stop_streaming(as10x_handle_t
*phandle
)
211 struct as10x_cmd_t
*pcmd
, *prsp
;
218 /* prepare command */
219 as10x_cmd_build(pcmd
, (++phandle
->cmd_xid
),
220 sizeof(pcmd
->body
.stop_streaming
.req
));
223 pcmd
->body
.stop_streaming
.req
.proc_id
=
224 cpu_to_le16(CONTROL_PROC_STOP_STREAMING
);
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
)
234 error
= AS10X_CMD_ERROR
;
241 error
= as10x_rsp_parse(prsp
, CONTROL_PROC_STOP_STREAMING_RSP
);