as10x_cmd_stream.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. #include <linux/kernel.h>
  16. #include "as102_drv.h"
  17. #include "as10x_cmd.h"
  18. /**
  19. * as10x_cmd_add_PID_filter - send add filter command to AS10x
  20. * @adap: pointer to AS10x bus adapter
  21. * @filter: TSFilter filter for DVB-T
  22. *
  23. * Return 0 on success or negative value in case of error.
  24. */
  25. int as10x_cmd_add_PID_filter(struct as10x_bus_adapter_t *adap,
  26. struct as10x_ts_filter *filter)
  27. {
  28. int error;
  29. struct as10x_cmd_t *pcmd, *prsp;
  30. pcmd = adap->cmd;
  31. prsp = adap->rsp;
  32. /* prepare command */
  33. as10x_cmd_build(pcmd, (++adap->cmd_xid),
  34. sizeof(pcmd->body.add_pid_filter.req));
  35. /* fill command */
  36. pcmd->body.add_pid_filter.req.proc_id =
  37. cpu_to_le16(CONTROL_PROC_SETFILTER);
  38. pcmd->body.add_pid_filter.req.pid = cpu_to_le16(filter->pid);
  39. pcmd->body.add_pid_filter.req.stream_type = filter->type;
  40. if (filter->idx < 16)
  41. pcmd->body.add_pid_filter.req.idx = filter->idx;
  42. else
  43. pcmd->body.add_pid_filter.req.idx = 0xFF;
  44. /* send command */
  45. if (adap->ops->xfer_cmd) {
  46. error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
  47. sizeof(pcmd->body.add_pid_filter.req)
  48. + HEADER_SIZE, (uint8_t *) prsp,
  49. sizeof(prsp->body.add_pid_filter.rsp)
  50. + HEADER_SIZE);
  51. } else {
  52. error = AS10X_CMD_ERROR;
  53. }
  54. if (error < 0)
  55. goto out;
  56. /* parse response */
  57. error = as10x_rsp_parse(prsp, CONTROL_PROC_SETFILTER_RSP);
  58. if (error == 0) {
  59. /* Response OK -> get response data */
  60. filter->idx = prsp->body.add_pid_filter.rsp.filter_id;
  61. }
  62. out:
  63. return error;
  64. }
  65. /**
  66. * as10x_cmd_del_PID_filter - Send delete filter command to AS10x
  67. * @adap: pointer to AS10x bus adapte
  68. * @pid_value: PID to delete
  69. *
  70. * Return 0 on success or negative value in case of error.
  71. */
  72. int as10x_cmd_del_PID_filter(struct as10x_bus_adapter_t *adap,
  73. uint16_t pid_value)
  74. {
  75. int error;
  76. struct as10x_cmd_t *pcmd, *prsp;
  77. pcmd = adap->cmd;
  78. prsp = adap->rsp;
  79. /* prepare command */
  80. as10x_cmd_build(pcmd, (++adap->cmd_xid),
  81. sizeof(pcmd->body.del_pid_filter.req));
  82. /* fill command */
  83. pcmd->body.del_pid_filter.req.proc_id =
  84. cpu_to_le16(CONTROL_PROC_REMOVEFILTER);
  85. pcmd->body.del_pid_filter.req.pid = cpu_to_le16(pid_value);
  86. /* send command */
  87. if (adap->ops->xfer_cmd) {
  88. error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
  89. sizeof(pcmd->body.del_pid_filter.req)
  90. + HEADER_SIZE, (uint8_t *) prsp,
  91. sizeof(prsp->body.del_pid_filter.rsp)
  92. + HEADER_SIZE);
  93. } else {
  94. error = AS10X_CMD_ERROR;
  95. }
  96. if (error < 0)
  97. goto out;
  98. /* parse response */
  99. error = as10x_rsp_parse(prsp, CONTROL_PROC_REMOVEFILTER_RSP);
  100. out:
  101. return error;
  102. }
  103. /**
  104. * as10x_cmd_start_streaming - Send start streaming command to AS10x
  105. * @adap: pointer to AS10x bus adapter
  106. *
  107. * Return 0 on success or negative value in case of error.
  108. */
  109. int as10x_cmd_start_streaming(struct as10x_bus_adapter_t *adap)
  110. {
  111. int error;
  112. struct as10x_cmd_t *pcmd, *prsp;
  113. pcmd = adap->cmd;
  114. prsp = adap->rsp;
  115. /* prepare command */
  116. as10x_cmd_build(pcmd, (++adap->cmd_xid),
  117. sizeof(pcmd->body.start_streaming.req));
  118. /* fill command */
  119. pcmd->body.start_streaming.req.proc_id =
  120. cpu_to_le16(CONTROL_PROC_START_STREAMING);
  121. /* send command */
  122. if (adap->ops->xfer_cmd) {
  123. error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
  124. sizeof(pcmd->body.start_streaming.req)
  125. + HEADER_SIZE, (uint8_t *) prsp,
  126. sizeof(prsp->body.start_streaming.rsp)
  127. + HEADER_SIZE);
  128. } else {
  129. error = AS10X_CMD_ERROR;
  130. }
  131. if (error < 0)
  132. goto out;
  133. /* parse response */
  134. error = as10x_rsp_parse(prsp, CONTROL_PROC_START_STREAMING_RSP);
  135. out:
  136. return error;
  137. }
  138. /**
  139. * as10x_cmd_stop_streaming - Send stop streaming command to AS10x
  140. * @adap: pointer to AS10x bus adapter
  141. *
  142. * Return 0 on success or negative value in case of error.
  143. */
  144. int as10x_cmd_stop_streaming(struct as10x_bus_adapter_t *adap)
  145. {
  146. int8_t error;
  147. struct as10x_cmd_t *pcmd, *prsp;
  148. pcmd = adap->cmd;
  149. prsp = adap->rsp;
  150. /* prepare command */
  151. as10x_cmd_build(pcmd, (++adap->cmd_xid),
  152. sizeof(pcmd->body.stop_streaming.req));
  153. /* fill command */
  154. pcmd->body.stop_streaming.req.proc_id =
  155. cpu_to_le16(CONTROL_PROC_STOP_STREAMING);
  156. /* send command */
  157. if (adap->ops->xfer_cmd) {
  158. error = adap->ops->xfer_cmd(adap, (uint8_t *) pcmd,
  159. sizeof(pcmd->body.stop_streaming.req)
  160. + HEADER_SIZE, (uint8_t *) prsp,
  161. sizeof(prsp->body.stop_streaming.rsp)
  162. + HEADER_SIZE);
  163. } else {
  164. error = AS10X_CMD_ERROR;
  165. }
  166. if (error < 0)
  167. goto out;
  168. /* parse response */
  169. error = as10x_rsp_parse(prsp, CONTROL_PROC_STOP_STREAMING_RSP);
  170. out:
  171. return error;
  172. }