0001
0002
0003
0004
0005
0006
0007 #include <linux/kernel.h>
0008 #include "as102_drv.h"
0009 #include "as10x_cmd.h"
0010
0011
0012
0013
0014
0015
0016
0017
0018 int as10x_cmd_add_PID_filter(struct as10x_bus_adapter_t *adap,
0019 struct as10x_ts_filter *filter)
0020 {
0021 int error;
0022 struct as10x_cmd_t *pcmd, *prsp;
0023
0024 pcmd = adap->cmd;
0025 prsp = adap->rsp;
0026
0027
0028 as10x_cmd_build(pcmd, (++adap->cmd_xid),
0029 sizeof(pcmd->body.add_pid_filter.req));
0030
0031
0032 pcmd->body.add_pid_filter.req.proc_id =
0033 cpu_to_le16(CONTROL_PROC_SETFILTER);
0034 pcmd->body.add_pid_filter.req.pid = cpu_to_le16(filter->pid);
0035 pcmd->body.add_pid_filter.req.stream_type = filter->type;
0036
0037 if (filter->idx < 16)
0038 pcmd->body.add_pid_filter.req.idx = filter->idx;
0039 else
0040 pcmd->body.add_pid_filter.req.idx = 0xFF;
0041
0042
0043 if (adap->ops->xfer_cmd) {
0044 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
0045 sizeof(pcmd->body.add_pid_filter.req)
0046 + HEADER_SIZE, (uint8_t *) prsp,
0047 sizeof(prsp->body.add_pid_filter.rsp)
0048 + HEADER_SIZE);
0049 } else {
0050 error = AS10X_CMD_ERROR;
0051 }
0052
0053 if (error < 0)
0054 goto out;
0055
0056
0057 error = as10x_rsp_parse(prsp, CONTROL_PROC_SETFILTER_RSP);
0058
0059 if (error == 0) {
0060
0061 filter->idx = prsp->body.add_pid_filter.rsp.filter_id;
0062 }
0063
0064 out:
0065 return error;
0066 }
0067
0068
0069
0070
0071
0072
0073
0074
0075 int as10x_cmd_del_PID_filter(struct as10x_bus_adapter_t *adap,
0076 uint16_t pid_value)
0077 {
0078 int error;
0079 struct as10x_cmd_t *pcmd, *prsp;
0080
0081 pcmd = adap->cmd;
0082 prsp = adap->rsp;
0083
0084
0085 as10x_cmd_build(pcmd, (++adap->cmd_xid),
0086 sizeof(pcmd->body.del_pid_filter.req));
0087
0088
0089 pcmd->body.del_pid_filter.req.proc_id =
0090 cpu_to_le16(CONTROL_PROC_REMOVEFILTER);
0091 pcmd->body.del_pid_filter.req.pid = cpu_to_le16(pid_value);
0092
0093
0094 if (adap->ops->xfer_cmd) {
0095 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
0096 sizeof(pcmd->body.del_pid_filter.req)
0097 + HEADER_SIZE, (uint8_t *) prsp,
0098 sizeof(prsp->body.del_pid_filter.rsp)
0099 + HEADER_SIZE);
0100 } else {
0101 error = AS10X_CMD_ERROR;
0102 }
0103
0104 if (error < 0)
0105 goto out;
0106
0107
0108 error = as10x_rsp_parse(prsp, CONTROL_PROC_REMOVEFILTER_RSP);
0109
0110 out:
0111 return error;
0112 }
0113
0114
0115
0116
0117
0118
0119
0120 int as10x_cmd_start_streaming(struct as10x_bus_adapter_t *adap)
0121 {
0122 int error;
0123 struct as10x_cmd_t *pcmd, *prsp;
0124
0125 pcmd = adap->cmd;
0126 prsp = adap->rsp;
0127
0128
0129 as10x_cmd_build(pcmd, (++adap->cmd_xid),
0130 sizeof(pcmd->body.start_streaming.req));
0131
0132
0133 pcmd->body.start_streaming.req.proc_id =
0134 cpu_to_le16(CONTROL_PROC_START_STREAMING);
0135
0136
0137 if (adap->ops->xfer_cmd) {
0138 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
0139 sizeof(pcmd->body.start_streaming.req)
0140 + HEADER_SIZE, (uint8_t *) prsp,
0141 sizeof(prsp->body.start_streaming.rsp)
0142 + HEADER_SIZE);
0143 } else {
0144 error = AS10X_CMD_ERROR;
0145 }
0146
0147 if (error < 0)
0148 goto out;
0149
0150
0151 error = as10x_rsp_parse(prsp, CONTROL_PROC_START_STREAMING_RSP);
0152
0153 out:
0154 return error;
0155 }
0156
0157
0158
0159
0160
0161
0162
0163 int as10x_cmd_stop_streaming(struct as10x_bus_adapter_t *adap)
0164 {
0165 int8_t error;
0166 struct as10x_cmd_t *pcmd, *prsp;
0167
0168 pcmd = adap->cmd;
0169 prsp = adap->rsp;
0170
0171
0172 as10x_cmd_build(pcmd, (++adap->cmd_xid),
0173 sizeof(pcmd->body.stop_streaming.req));
0174
0175
0176 pcmd->body.stop_streaming.req.proc_id =
0177 cpu_to_le16(CONTROL_PROC_STOP_STREAMING);
0178
0179
0180 if (adap->ops->xfer_cmd) {
0181 error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
0182 sizeof(pcmd->body.stop_streaming.req)
0183 + HEADER_SIZE, (uint8_t *) prsp,
0184 sizeof(prsp->body.stop_streaming.rsp)
0185 + HEADER_SIZE);
0186 } else {
0187 error = AS10X_CMD_ERROR;
0188 }
0189
0190 if (error < 0)
0191 goto out;
0192
0193
0194 error = as10x_rsp_parse(prsp, CONTROL_PROC_STOP_STREAMING_RSP);
0195
0196 out:
0197 return error;
0198 }