as10x_cmd.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  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. #ifndef _AS10X_CMD_H_
  16. #define _AS10X_CMD_H_
  17. #include <linux/kernel.h>
  18. #include "as102_fe_types.h"
  19. /*********************************/
  20. /* MACRO DEFINITIONS */
  21. /*********************************/
  22. #define AS10X_CMD_ERROR -1
  23. #define SERVICE_PROG_ID 0x0002
  24. #define SERVICE_PROG_VERSION 0x0001
  25. #define HIER_NONE 0x00
  26. #define HIER_LOW_PRIORITY 0x01
  27. #define HEADER_SIZE (sizeof(struct as10x_cmd_header_t))
  28. /* context request types */
  29. #define GET_CONTEXT_DATA 1
  30. #define SET_CONTEXT_DATA 2
  31. /* ODSP suspend modes */
  32. #define CFG_MODE_ODSP_RESUME 0
  33. #define CFG_MODE_ODSP_SUSPEND 1
  34. /* Dump memory size */
  35. #define DUMP_BLOCK_SIZE_MAX 0x20
  36. /*********************************/
  37. /* TYPE DEFINITION */
  38. /*********************************/
  39. enum control_proc {
  40. CONTROL_PROC_TURNON = 0x0001,
  41. CONTROL_PROC_TURNON_RSP = 0x0100,
  42. CONTROL_PROC_SET_REGISTER = 0x0002,
  43. CONTROL_PROC_SET_REGISTER_RSP = 0x0200,
  44. CONTROL_PROC_GET_REGISTER = 0x0003,
  45. CONTROL_PROC_GET_REGISTER_RSP = 0x0300,
  46. CONTROL_PROC_SETTUNE = 0x000A,
  47. CONTROL_PROC_SETTUNE_RSP = 0x0A00,
  48. CONTROL_PROC_GETTUNESTAT = 0x000B,
  49. CONTROL_PROC_GETTUNESTAT_RSP = 0x0B00,
  50. CONTROL_PROC_GETTPS = 0x000D,
  51. CONTROL_PROC_GETTPS_RSP = 0x0D00,
  52. CONTROL_PROC_SETFILTER = 0x000E,
  53. CONTROL_PROC_SETFILTER_RSP = 0x0E00,
  54. CONTROL_PROC_REMOVEFILTER = 0x000F,
  55. CONTROL_PROC_REMOVEFILTER_RSP = 0x0F00,
  56. CONTROL_PROC_GET_IMPULSE_RESP = 0x0012,
  57. CONTROL_PROC_GET_IMPULSE_RESP_RSP = 0x1200,
  58. CONTROL_PROC_START_STREAMING = 0x0013,
  59. CONTROL_PROC_START_STREAMING_RSP = 0x1300,
  60. CONTROL_PROC_STOP_STREAMING = 0x0014,
  61. CONTROL_PROC_STOP_STREAMING_RSP = 0x1400,
  62. CONTROL_PROC_GET_DEMOD_STATS = 0x0015,
  63. CONTROL_PROC_GET_DEMOD_STATS_RSP = 0x1500,
  64. CONTROL_PROC_ELNA_CHANGE_MODE = 0x0016,
  65. CONTROL_PROC_ELNA_CHANGE_MODE_RSP = 0x1600,
  66. CONTROL_PROC_ODSP_CHANGE_MODE = 0x0017,
  67. CONTROL_PROC_ODSP_CHANGE_MODE_RSP = 0x1700,
  68. CONTROL_PROC_AGC_CHANGE_MODE = 0x0018,
  69. CONTROL_PROC_AGC_CHANGE_MODE_RSP = 0x1800,
  70. CONTROL_PROC_CONTEXT = 0x00FC,
  71. CONTROL_PROC_CONTEXT_RSP = 0xFC00,
  72. CONTROL_PROC_DUMP_MEMORY = 0x00FD,
  73. CONTROL_PROC_DUMP_MEMORY_RSP = 0xFD00,
  74. CONTROL_PROC_DUMPLOG_MEMORY = 0x00FE,
  75. CONTROL_PROC_DUMPLOG_MEMORY_RSP = 0xFE00,
  76. CONTROL_PROC_TURNOFF = 0x00FF,
  77. CONTROL_PROC_TURNOFF_RSP = 0xFF00
  78. };
  79. union as10x_turn_on {
  80. /* request */
  81. struct {
  82. /* request identifier */
  83. __le16 proc_id;
  84. } __packed req;
  85. /* response */
  86. struct {
  87. /* response identifier */
  88. __le16 proc_id;
  89. /* error */
  90. uint8_t error;
  91. } __packed rsp;
  92. } __packed;
  93. union as10x_turn_off {
  94. /* request */
  95. struct {
  96. /* request identifier */
  97. __le16 proc_id;
  98. } __packed req;
  99. /* response */
  100. struct {
  101. /* response identifier */
  102. __le16 proc_id;
  103. /* error */
  104. uint8_t err;
  105. } __packed rsp;
  106. } __packed;
  107. union as10x_set_tune {
  108. /* request */
  109. struct {
  110. /* request identifier */
  111. __le16 proc_id;
  112. /* tune params */
  113. struct as10x_tune_args args;
  114. } __packed req;
  115. /* response */
  116. struct {
  117. /* response identifier */
  118. __le16 proc_id;
  119. /* response error */
  120. uint8_t error;
  121. } __packed rsp;
  122. } __packed;
  123. union as10x_get_tune_status {
  124. /* request */
  125. struct {
  126. /* request identifier */
  127. __le16 proc_id;
  128. } __packed req;
  129. /* response */
  130. struct {
  131. /* response identifier */
  132. __le16 proc_id;
  133. /* response error */
  134. uint8_t error;
  135. /* tune status */
  136. struct as10x_tune_status sts;
  137. } __packed rsp;
  138. } __packed;
  139. union as10x_get_tps {
  140. /* request */
  141. struct {
  142. /* request identifier */
  143. __le16 proc_id;
  144. } __packed req;
  145. /* response */
  146. struct {
  147. /* response identifier */
  148. __le16 proc_id;
  149. /* response error */
  150. uint8_t error;
  151. /* tps details */
  152. struct as10x_tps tps;
  153. } __packed rsp;
  154. } __packed;
  155. union as10x_common {
  156. /* request */
  157. struct {
  158. /* request identifier */
  159. __le16 proc_id;
  160. } __packed req;
  161. /* response */
  162. struct {
  163. /* response identifier */
  164. __le16 proc_id;
  165. /* response error */
  166. uint8_t error;
  167. } __packed rsp;
  168. } __packed;
  169. union as10x_add_pid_filter {
  170. /* request */
  171. struct {
  172. /* request identifier */
  173. __le16 proc_id;
  174. /* PID to filter */
  175. __le16 pid;
  176. /* stream type (MPE, PSI/SI or PES )*/
  177. uint8_t stream_type;
  178. /* PID index in filter table */
  179. uint8_t idx;
  180. } __packed req;
  181. /* response */
  182. struct {
  183. /* response identifier */
  184. __le16 proc_id;
  185. /* response error */
  186. uint8_t error;
  187. /* Filter id */
  188. uint8_t filter_id;
  189. } __packed rsp;
  190. } __packed;
  191. union as10x_del_pid_filter {
  192. /* request */
  193. struct {
  194. /* request identifier */
  195. __le16 proc_id;
  196. /* PID to remove */
  197. __le16 pid;
  198. } __packed req;
  199. /* response */
  200. struct {
  201. /* response identifier */
  202. __le16 proc_id;
  203. /* response error */
  204. uint8_t error;
  205. } __packed rsp;
  206. } __packed;
  207. union as10x_start_streaming {
  208. /* request */
  209. struct {
  210. /* request identifier */
  211. __le16 proc_id;
  212. } __packed req;
  213. /* response */
  214. struct {
  215. /* response identifier */
  216. __le16 proc_id;
  217. /* error */
  218. uint8_t error;
  219. } __packed rsp;
  220. } __packed;
  221. union as10x_stop_streaming {
  222. /* request */
  223. struct {
  224. /* request identifier */
  225. __le16 proc_id;
  226. } __packed req;
  227. /* response */
  228. struct {
  229. /* response identifier */
  230. __le16 proc_id;
  231. /* error */
  232. uint8_t error;
  233. } __packed rsp;
  234. } __packed;
  235. union as10x_get_demod_stats {
  236. /* request */
  237. struct {
  238. /* request identifier */
  239. __le16 proc_id;
  240. } __packed req;
  241. /* response */
  242. struct {
  243. /* response identifier */
  244. __le16 proc_id;
  245. /* error */
  246. uint8_t error;
  247. /* demod stats */
  248. struct as10x_demod_stats stats;
  249. } __packed rsp;
  250. } __packed;
  251. union as10x_get_impulse_resp {
  252. /* request */
  253. struct {
  254. /* request identifier */
  255. __le16 proc_id;
  256. } __packed req;
  257. /* response */
  258. struct {
  259. /* response identifier */
  260. __le16 proc_id;
  261. /* error */
  262. uint8_t error;
  263. /* impulse response ready */
  264. uint8_t is_ready;
  265. } __packed rsp;
  266. } __packed;
  267. union as10x_fw_context {
  268. /* request */
  269. struct {
  270. /* request identifier */
  271. __le16 proc_id;
  272. /* value to write (for set context)*/
  273. struct as10x_register_value reg_val;
  274. /* context tag */
  275. __le16 tag;
  276. /* context request type */
  277. __le16 type;
  278. } __packed req;
  279. /* response */
  280. struct {
  281. /* response identifier */
  282. __le16 proc_id;
  283. /* value read (for get context) */
  284. struct as10x_register_value reg_val;
  285. /* context request type */
  286. __le16 type;
  287. /* error */
  288. uint8_t error;
  289. } __packed rsp;
  290. } __packed;
  291. union as10x_set_register {
  292. /* request */
  293. struct {
  294. /* response identifier */
  295. __le16 proc_id;
  296. /* register description */
  297. struct as10x_register_addr reg_addr;
  298. /* register content */
  299. struct as10x_register_value reg_val;
  300. } __packed req;
  301. /* response */
  302. struct {
  303. /* response identifier */
  304. __le16 proc_id;
  305. /* error */
  306. uint8_t error;
  307. } __packed rsp;
  308. } __packed;
  309. union as10x_get_register {
  310. /* request */
  311. struct {
  312. /* response identifier */
  313. __le16 proc_id;
  314. /* register description */
  315. struct as10x_register_addr reg_addr;
  316. } __packed req;
  317. /* response */
  318. struct {
  319. /* response identifier */
  320. __le16 proc_id;
  321. /* error */
  322. uint8_t error;
  323. /* register content */
  324. struct as10x_register_value reg_val;
  325. } __packed rsp;
  326. } __packed;
  327. union as10x_cfg_change_mode {
  328. /* request */
  329. struct {
  330. /* request identifier */
  331. __le16 proc_id;
  332. /* mode */
  333. uint8_t mode;
  334. } __packed req;
  335. /* response */
  336. struct {
  337. /* response identifier */
  338. __le16 proc_id;
  339. /* error */
  340. uint8_t error;
  341. } __packed rsp;
  342. } __packed;
  343. struct as10x_cmd_header_t {
  344. __le16 req_id;
  345. __le16 prog;
  346. __le16 version;
  347. __le16 data_len;
  348. } __packed;
  349. #define DUMP_BLOCK_SIZE 16
  350. union as10x_dump_memory {
  351. /* request */
  352. struct {
  353. /* request identifier */
  354. __le16 proc_id;
  355. /* dump memory type request */
  356. uint8_t dump_req;
  357. /* register description */
  358. struct as10x_register_addr reg_addr;
  359. /* nb blocks to read */
  360. __le16 num_blocks;
  361. } __packed req;
  362. /* response */
  363. struct {
  364. /* response identifier */
  365. __le16 proc_id;
  366. /* error */
  367. uint8_t error;
  368. /* dump response */
  369. uint8_t dump_rsp;
  370. /* data */
  371. union {
  372. uint8_t data8[DUMP_BLOCK_SIZE];
  373. __le16 data16[DUMP_BLOCK_SIZE / sizeof(__le16)];
  374. __le32 data32[DUMP_BLOCK_SIZE / sizeof(__le32)];
  375. } __packed u;
  376. } __packed rsp;
  377. } __packed;
  378. union as10x_dumplog_memory {
  379. struct {
  380. /* request identifier */
  381. __le16 proc_id;
  382. /* dump memory type request */
  383. uint8_t dump_req;
  384. } __packed req;
  385. struct {
  386. /* request identifier */
  387. __le16 proc_id;
  388. /* error */
  389. uint8_t error;
  390. /* dump response */
  391. uint8_t dump_rsp;
  392. /* dump data */
  393. uint8_t data[DUMP_BLOCK_SIZE];
  394. } __packed rsp;
  395. } __packed;
  396. union as10x_raw_data {
  397. /* request */
  398. struct {
  399. __le16 proc_id;
  400. uint8_t data[64 - sizeof(struct as10x_cmd_header_t)
  401. - 2 /* proc_id */];
  402. } __packed req;
  403. /* response */
  404. struct {
  405. __le16 proc_id;
  406. uint8_t error;
  407. uint8_t data[64 - sizeof(struct as10x_cmd_header_t)
  408. - 2 /* proc_id */ - 1 /* rc */];
  409. } __packed rsp;
  410. } __packed;
  411. struct as10x_cmd_t {
  412. struct as10x_cmd_header_t header;
  413. union {
  414. union as10x_turn_on turn_on;
  415. union as10x_turn_off turn_off;
  416. union as10x_set_tune set_tune;
  417. union as10x_get_tune_status get_tune_status;
  418. union as10x_get_tps get_tps;
  419. union as10x_common common;
  420. union as10x_add_pid_filter add_pid_filter;
  421. union as10x_del_pid_filter del_pid_filter;
  422. union as10x_start_streaming start_streaming;
  423. union as10x_stop_streaming stop_streaming;
  424. union as10x_get_demod_stats get_demod_stats;
  425. union as10x_get_impulse_resp get_impulse_rsp;
  426. union as10x_fw_context context;
  427. union as10x_set_register set_register;
  428. union as10x_get_register get_register;
  429. union as10x_cfg_change_mode cfg_change_mode;
  430. union as10x_dump_memory dump_memory;
  431. union as10x_dumplog_memory dumplog_memory;
  432. union as10x_raw_data raw_data;
  433. } __packed body;
  434. } __packed;
  435. struct as10x_token_cmd_t {
  436. /* token cmd */
  437. struct as10x_cmd_t c;
  438. /* token response */
  439. struct as10x_cmd_t r;
  440. } __packed;
  441. /**************************/
  442. /* FUNCTION DECLARATION */
  443. /**************************/
  444. void as10x_cmd_build(struct as10x_cmd_t *pcmd, uint16_t proc_id,
  445. uint16_t cmd_len);
  446. int as10x_rsp_parse(struct as10x_cmd_t *r, uint16_t proc_id);
  447. /* as10x cmd */
  448. int as10x_cmd_turn_on(struct as10x_bus_adapter_t *adap);
  449. int as10x_cmd_turn_off(struct as10x_bus_adapter_t *adap);
  450. int as10x_cmd_set_tune(struct as10x_bus_adapter_t *adap,
  451. struct as10x_tune_args *ptune);
  452. int as10x_cmd_get_tune_status(struct as10x_bus_adapter_t *adap,
  453. struct as10x_tune_status *pstatus);
  454. int as10x_cmd_get_tps(struct as10x_bus_adapter_t *adap,
  455. struct as10x_tps *ptps);
  456. int as10x_cmd_get_demod_stats(struct as10x_bus_adapter_t *adap,
  457. struct as10x_demod_stats *pdemod_stats);
  458. int as10x_cmd_get_impulse_resp(struct as10x_bus_adapter_t *adap,
  459. uint8_t *is_ready);
  460. /* as10x cmd stream */
  461. int as10x_cmd_add_PID_filter(struct as10x_bus_adapter_t *adap,
  462. struct as10x_ts_filter *filter);
  463. int as10x_cmd_del_PID_filter(struct as10x_bus_adapter_t *adap,
  464. uint16_t pid_value);
  465. int as10x_cmd_start_streaming(struct as10x_bus_adapter_t *adap);
  466. int as10x_cmd_stop_streaming(struct as10x_bus_adapter_t *adap);
  467. /* as10x cmd cfg */
  468. int as10x_cmd_set_context(struct as10x_bus_adapter_t *adap,
  469. uint16_t tag,
  470. uint32_t value);
  471. int as10x_cmd_get_context(struct as10x_bus_adapter_t *adap,
  472. uint16_t tag,
  473. uint32_t *pvalue);
  474. int as10x_cmd_eLNA_change_mode(struct as10x_bus_adapter_t *adap, uint8_t mode);
  475. int as10x_context_rsp_parse(struct as10x_cmd_t *prsp, uint16_t proc_id);
  476. #endif