dsp_hal.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. /*
  2. * Copyright (c) 1997-2015, Actions Semi Co., Inc.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef __DSP_HAL_H__
  7. #define __DSP_HAL_H__
  8. #include <zephyr.h>
  9. #include <mem_manager.h>
  10. #include <string.h>
  11. #include <errno.h>
  12. #include <soc_dsp.h>
  13. #include <dsp_hal_defs.h>
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. typedef int (*dsp_session_buf_read_fn)(void *, void *, unsigned int);
  18. typedef int (*dsp_session_buf_write_fn)(void *, const void *, unsigned int);
  19. /* session information to initialize a session */
  20. struct dsp_session_info {
  21. /* session id */
  22. unsigned int type;
  23. /* allowed functions (bitfield) */
  24. unsigned int func_allowed;
  25. /* dsp image name */
  26. const char *main_dsp;
  27. const char *sub_dsp;
  28. };
  29. struct dsp_session;
  30. struct dsp_session_buf;
  31. /* dsp session ops */
  32. /**
  33. * @brief open the global session
  34. *
  35. * session can be open multiple times, thus, the parameter "info" will be
  36. * ignored if this is not the first open.
  37. *
  38. * @param info session information
  39. *
  40. * @return Address of global session
  41. */
  42. struct dsp_session *dsp_open_global_session(struct dsp_session_info *info);
  43. /**
  44. * @brief close the global session
  45. *
  46. * @return N/A
  47. */
  48. void dsp_close_global_session(struct dsp_session *session);
  49. /**
  50. * @brief get session (task) state
  51. *
  52. * @param session Address of session
  53. *
  54. * @return the state (DSP_TASK_x) of session
  55. */
  56. int dsp_session_get_state(struct dsp_session *session);
  57. /**
  58. * @brief get session run error
  59. *
  60. * @param session Address of session
  61. *
  62. * @return the error code of session
  63. */
  64. int dsp_session_get_error(struct dsp_session *session);
  65. /**
  66. * @brief get session run debug info
  67. *
  68. * @param session Address of session
  69. * @param index debug info index
  70. *
  71. * @return the debug info of the index
  72. */
  73. uint32_t dsp_session_get_debug_info(struct dsp_session *session, uint32_t index);
  74. /**
  75. * @brief get session run pcmbuf info
  76. *
  77. * @param session Address of session
  78. *
  79. * @param pcmbuf Address of pcmbuf info
  80. *
  81. * @return 0 if succeed, the others if failed
  82. */
  83. int dsp_session_get_pcmbuf_info(struct dsp_session *session, struct streamout_dspfunc_runtime_pcmbuf *pcmbuf);
  84. /**
  85. * @brief dump session information
  86. *
  87. * @param session Address of session
  88. *
  89. * @return N/A
  90. */
  91. void dsp_session_dump(struct dsp_session *session);
  92. /**
  93. * @brief submit session command
  94. *
  95. * @param session Address of session
  96. * @param command Command to submit
  97. *
  98. * @return 0 if succeed, the others if failed
  99. */
  100. int dsp_session_submit_command(struct dsp_session *session, struct dsp_command *command);
  101. /**
  102. * @brief submit session command without data
  103. *
  104. * @param session Address of session
  105. * @param command Command to submit
  106. *
  107. * @return 0 if succeed, the others if failed
  108. */
  109. static inline int dsp_session_submit_simple_command(struct dsp_session *session, unsigned int id, struct k_sem *sem)
  110. {
  111. struct dsp_command command = {
  112. .id = id,
  113. .sem = (uint32_t)sem,
  114. .size = 0,
  115. };
  116. return dsp_session_submit_command(session, &command);;
  117. }
  118. /**
  119. * @brief query session command finished
  120. *
  121. * @param session Address of session
  122. * @param command Command to query
  123. *
  124. * @return the query result
  125. */
  126. bool dsp_session_command_finished(struct dsp_session *session, struct dsp_command *command);
  127. /**
  128. * @brief kick dsp, since data ready
  129. *
  130. * @param session Address of session
  131. *
  132. * @return 0 if succeed, the others if failed
  133. */
  134. int dsp_session_kick(struct dsp_session *session);
  135. /**
  136. * @brief wait dsp for data output
  137. *
  138. * @param session Address of session
  139. * @param timout Waiting period to take the semaphore (in milliseconds),
  140. * or one of the special values K_NO_WAIT and K_FOREVER.
  141. *
  142. * @retval 0 Wait succeed.
  143. * @retval -ENOTSUP Waiting not supported, since wait_sem of sessoin_info
  144. * not configured when opening session.
  145. * @retval -EBUSY Returned without waiting.
  146. * @retval -EAGAIN Waiting period timed out.
  147. */
  148. int dsp_session_wait(struct dsp_session *session, int timout);
  149. /**
  150. * @brief Define and initialize a dsp command without data.
  151. *
  152. * The command can be accessed outside the module where it is defined using:
  153. *
  154. * @code extern struct dsp_command <name>; @endcode
  155. *
  156. * @param name Name of the command.
  157. * @param cmd_id Command id.
  158. * @param sem_obj Semaphore object for synchronization.
  159. */
  160. #define DSP_COMMAND_DEFINE(name, cmd_id, sem_obj) \
  161. struct dsp_command name = { \
  162. .id = cmd_id, \
  163. .sem = (uint32_t)sem_obj, \
  164. .size = 0, \
  165. }
  166. /**
  167. * @brief Initialize allocate and initialize a dsp command.
  168. *
  169. * This routine allocate and initializes a dsp command.
  170. *
  171. * @param id Command id.
  172. * @param sem Address of semaphore object for synchronization.
  173. * @param size Size of command data.
  174. * @param data Address of command data.
  175. *
  176. * @return Address of command.
  177. */
  178. static inline struct dsp_command *dsp_command_alloc(unsigned int id,
  179. struct k_sem *sem, size_t size, const void *data)
  180. {
  181. struct dsp_command *command = mem_malloc(sizeof(*command) + size);
  182. if (command) {
  183. command->id = (uint16_t)id;
  184. command->sem = (uint32_t)sem;
  185. command->size = size;
  186. if (data)
  187. memcpy(command->data, data, size);
  188. }
  189. return command;
  190. }
  191. /**
  192. * @brief Free a dsp command.
  193. *
  194. * This routine free a dsp command.
  195. *
  196. * @param command Address of command.
  197. *
  198. * @return N/A
  199. */
  200. static inline void dsp_command_free(struct dsp_command *command)
  201. {
  202. mem_free((void *)command);
  203. }
  204. /**
  205. * @brief submit command DSP_CMD_NULL.
  206. *
  207. * This routine submit command DSP_CMD_NULL.
  208. *
  209. * @param session Address of the session.
  210. * @param sem Address of semaphore object for synchronization.
  211. *
  212. * @return Command result.
  213. */
  214. static inline int dsp_session_submit_null(struct dsp_session *session, struct k_sem *sem)
  215. {
  216. DSP_COMMAND_DEFINE(command, DSP_CMD_NULL, sem);
  217. return dsp_session_submit_command(session, &command);
  218. }
  219. /**
  220. * @brief Initialize a session with command DSP_CMD_SESSION_INIT
  221. *
  222. * This routine initialize a session using command DSP_CMD_SESSION_INIT.
  223. *
  224. * @param session Address of the session.
  225. * @param size Size of prarameters.
  226. * @param params Address of prarameters.
  227. *
  228. * @return Command result.
  229. */
  230. static inline int dsp_session_init(struct dsp_session *session, size_t size, const void *params)
  231. {
  232. struct dsp_command *command = dsp_command_alloc(DSP_CMD_SESSION_INIT, NULL, size, params);
  233. int res = -ENOMEM;
  234. if (command) {
  235. res = dsp_session_submit_command(session, command);
  236. dsp_command_free(command);
  237. }
  238. return res;
  239. }
  240. /**
  241. * @brief Begin a session with command DSP_CMD_SESSION_BEGIN
  242. *
  243. * This routine begin a session using command DSP_CMD_SESSION_BEGIN without params.
  244. *
  245. * @param session Address of the session.
  246. * @param sem Address of semaphore object for synchronization.
  247. *
  248. * @return Command result.
  249. */
  250. static inline int dsp_session_begin(struct dsp_session *session, struct k_sem *sem)
  251. {
  252. DSP_COMMAND_DEFINE(command, DSP_CMD_SESSION_BEGIN, sem);
  253. return dsp_session_submit_command(session, &command);
  254. }
  255. /**
  256. * @brief End a session with command DSP_CMD_SESSION_END.
  257. *
  258. * This routine end a session using command DSP_CMD_SESSION_END without params.
  259. *
  260. * @param session Address of the session.
  261. * @param sem Address of semaphore object for synchronization.
  262. *
  263. * @return Command result.
  264. */
  265. static inline int dsp_session_end(struct dsp_session *session, struct k_sem *sem)
  266. {
  267. DSP_COMMAND_DEFINE(command, DSP_CMD_SESSION_END, sem);
  268. return dsp_session_submit_command(session, &command);
  269. }
  270. /**
  271. * @brief Configure a session function with command DSP_CMD_FUNCTION_CONFIG.
  272. *
  273. * This routine configure a function using command DSP_CMD_FUNCTION_CONFIG.
  274. *
  275. * @param session Address of the session.
  276. * @param func Session function ID.
  277. * @param conf Function specific configure ID.
  278. * @param size Size of prarameters.
  279. * @param params Address of prarameters.
  280. *
  281. * @return Command result.
  282. */
  283. static inline int dsp_session_config_func_sync(struct dsp_session *session,
  284. unsigned int func, unsigned int conf, size_t size, const void *params, struct k_sem *sem)
  285. {
  286. struct dsp_command *command = dsp_command_alloc(DSP_CMD_FUNCTION_CONFIG, sem, size + 8, NULL);
  287. int res = -ENOMEM;
  288. if (command) {
  289. command->data[0] = func;
  290. command->data[1] = conf;
  291. memcpy(&command->data[2], params, size);
  292. res = dsp_session_submit_command(session, command);
  293. dsp_command_free(command);
  294. }
  295. return res;
  296. }
  297. static inline int dsp_session_config_func(struct dsp_session *session,
  298. unsigned int func, unsigned int conf, size_t size, const void *params)
  299. {
  300. return dsp_session_config_func_sync(session, func, conf, size, params, NULL);
  301. }
  302. /**
  303. * @brief Enable a session function with command DSP_CMD_FUNCTION_ENABLE.
  304. *
  305. * This routine enable a function using command DSP_CMD_FUNCTION_ENABLE without params.
  306. *
  307. * @param session Address of the session.
  308. * @param func Session function ID.
  309. * @param sem Address of semaphore object for synchronization.
  310. *
  311. * @return Command result.
  312. */
  313. static inline int dsp_session_enable_func_sync(struct dsp_session *session, unsigned int func, struct k_sem *sem)
  314. {
  315. struct dsp_command *command = dsp_command_alloc(DSP_CMD_FUNCTION_ENABLE, sem, 4, &func);
  316. int res = -ENOMEM;
  317. if (command) {
  318. res = dsp_session_submit_command(session, command);
  319. dsp_command_free(command);
  320. }
  321. return res;
  322. }
  323. /**
  324. * @brief Enable a session function with command DSP_CMD_FUNCTION_ENABLE.
  325. *
  326. * This routine enable a function using command DSP_CMD_FUNCTION_ENABLE without params.
  327. *
  328. * @param session Address of the session.
  329. * @param func Session function ID.
  330. *
  331. * @return Command result.
  332. */
  333. static inline int dsp_session_enable_func(struct dsp_session *session, unsigned int func)
  334. {
  335. return dsp_session_enable_func_sync(session, func, NULL);
  336. }
  337. /**
  338. * @brief Disable a session function with command DSP_CMD_FUNCTION_DISABLE.
  339. *
  340. * This routine disable a function using command DSP_CMD_FUNCTION_DISABLE without params.
  341. *
  342. * @param session Address of the session.
  343. * @param func Session function ID.
  344. * @param sem Address of semaphore object for synchronization.
  345. *
  346. * @return Command result.
  347. */
  348. static inline int dsp_session_disable_func_sync(struct dsp_session *session, unsigned int func, struct k_sem *sem)
  349. {
  350. struct dsp_command *command = dsp_command_alloc(DSP_CMD_FUNCTION_DISABLE, sem, 4, &func);
  351. int res = -ENOMEM;
  352. if (command) {
  353. res = dsp_session_submit_command(session, command);
  354. dsp_command_free(command);
  355. }
  356. return res;
  357. }
  358. /**
  359. * @brief Disable a session function with command DSP_CMD_FUNCTION_DISABLE.
  360. *
  361. * This routine disable a function using command DSP_CMD_FUNCTION_DISABLE without params.
  362. *
  363. * @param session Address of the session.
  364. * @param func Session function ID.
  365. *
  366. * @return Command result.
  367. */
  368. static inline int dsp_session_disable_func(struct dsp_session *session, unsigned int func)
  369. {
  370. return dsp_session_disable_func_sync(session, func, NULL);
  371. }
  372. /**
  373. * @brief Pause a session function with command DSP_CMD_FUNCTION_PAUSE.
  374. *
  375. * This routine pause a function using command DSP_CMD_FUNCTION_PAUSE without params.
  376. *
  377. * @param session Address of the session.
  378. * @param func Session function ID.
  379. * @param sem Address of semaphore object for synchronization.
  380. *
  381. * @return Command result.
  382. */
  383. static inline int dsp_session_pause_func_sync(struct dsp_session *session, unsigned int func, struct k_sem *sem)
  384. {
  385. struct dsp_command *command = dsp_command_alloc(DSP_CMD_FUNCTION_PAUSE, sem, 4, &func);
  386. int res = -ENOMEM;
  387. if (command) {
  388. res = dsp_session_submit_command(session, command);
  389. dsp_command_free(command);
  390. }
  391. return res;
  392. }
  393. /**
  394. * @brief Pause a session function with command DSP_CMD_FUNCTION_PAUSE.
  395. *
  396. * This routine pause a function using command DSP_CMD_FUNCTION_PAUSE without params.
  397. *
  398. * @param session Address of the session.
  399. * @param func Session function ID.
  400. *
  401. * @return Command result.
  402. */
  403. static inline int dsp_session_pause_func(struct dsp_session *session, unsigned int func)
  404. {
  405. return dsp_session_pause_func_sync(session, func, NULL);
  406. }
  407. /**
  408. * @brief Resume a session function with command DSP_CMD_FUNCTION_RESUME.
  409. *
  410. * This routine resume a function using command DSP_CMD_FUNCTION_RESUME without params.
  411. *
  412. * @param session Address of the session.
  413. * @param func Session function ID.
  414. * @param sem Address of semaphore object for synchronization.
  415. *
  416. * @return Command result.
  417. */
  418. static inline int dsp_session_resume_func_sync(struct dsp_session *session, unsigned int func, struct k_sem *sem)
  419. {
  420. struct dsp_command *command = dsp_command_alloc(DSP_CMD_FUNCTION_RESUME, sem, 4, &func);
  421. int res = -ENOMEM;
  422. if (command) {
  423. res = dsp_session_submit_command(session, command);
  424. dsp_command_free(command);
  425. }
  426. return res;
  427. }
  428. /**
  429. * @brief Resume a session function with command DSP_CMD_FUNCTION_RESUME.
  430. *
  431. * This routine resume a function using command DSP_CMD_FUNCTION_RESUME without params.
  432. *
  433. * @param session Address of the session.
  434. * @param func Session function ID.
  435. *
  436. * @return Command result.
  437. */
  438. static inline int dsp_session_resume_func(struct dsp_session *session, unsigned int func)
  439. {
  440. return dsp_session_resume_func_sync(session, func, NULL);
  441. }
  442. /**
  443. * @brief Debug a session function with command DSP_CMD_FUNCTION_DEBUG.
  444. *
  445. * This routine debug a function using command DSP_CMD_FUNCTION_DEBUG.
  446. *
  447. * @param session Address of the session.
  448. * @param func Session function ID.
  449. * @param size Size of debug options.
  450. * @param options Address of debug options.
  451. *
  452. * @return Command result.
  453. */
  454. static inline int dsp_session_debug_func(struct dsp_session *session,
  455. unsigned int func, size_t size, const void *options)
  456. {
  457. struct dsp_command *command = dsp_command_alloc(DSP_CMD_FUNCTION_DEBUG, NULL, size + 4, NULL);
  458. int res = -ENOMEM;
  459. if (command) {
  460. command->data[0] = func;
  461. memcpy(&command->data[1], options, size);
  462. res = dsp_session_submit_command(session, command);
  463. dsp_command_free(command);
  464. }
  465. return res;
  466. }
  467. /**
  468. * @brief get samples count of specific function
  469. *
  470. * This function must export samples_count information to cpu side.
  471. *
  472. * @param session Address of session
  473. * @param func Session function ID
  474. *
  475. * @return samples count
  476. */
  477. unsigned int dsp_session_get_samples_count(struct dsp_session *session, unsigned int func);
  478. /**
  479. * @brief get lost count of specific function
  480. *
  481. * This function must export datalost_count information to cpu side.
  482. *
  483. * @param session Address of session
  484. * @param func Session function ID
  485. *
  486. * @return lost count
  487. */
  488. unsigned int dsp_session_get_datalost_count(struct dsp_session *session, unsigned int func);
  489. /**
  490. * @brief get raw stream count of specific function
  491. *
  492. * This function must export raw_count information to cpu side.
  493. * For encoder, this is the encoded stream amount.
  494. * For decoder, this is the decoded stream amount.
  495. *
  496. * @param session Address of session
  497. * @param func Session function ID
  498. *
  499. * @return lost count
  500. */
  501. unsigned int dsp_session_get_raw_count(struct dsp_session *session, unsigned int func);
  502. /**
  503. * @brief get dsp session recoder param
  504. *
  505. * This function must export recoder param to cpu side.
  506. *
  507. * @param session Address of session
  508. * @param param_type encoder sub module type
  509. * @param param param address
  510. *
  511. * @return lost count
  512. */
  513. int dsp_session_get_recoder_param(struct dsp_session *session, int param_type, void *param);
  514. /**
  515. * @brief get dsp session recoder param
  516. *
  517. * This function must export recoder param to cpu side.
  518. *
  519. * @param session Address of session
  520. * @param function_type function type
  521. *
  522. * @return function is runable or not
  523. */
  524. int dsp_session_get_function_runable(struct dsp_session *session, int function_type);
  525. /**
  526. * @brief get dsp session recoder param
  527. *
  528. * This function must export recoder param to cpu side.
  529. *
  530. * @param session Address of session
  531. * @param function_type function type
  532. *
  533. * @return function is enabled or not
  534. */
  535. int dsp_session_get_function_enable(struct dsp_session *session, int function_type);
  536. /* dsp session buffer ops */
  537. /**
  538. * @brief Initialiize a dsp session buffer.
  539. *
  540. * This routine initialize a dsp session buffer with external buffer backstore.
  541. *
  542. * @param session Address of session.
  543. * @param data Address of external buffer backstore.
  544. * @param size Size of session buffer, must be mutiple of 2.
  545. *
  546. * @return Address of session buffer
  547. */
  548. struct dsp_session_buf *dsp_session_buf_init(struct dsp_session *session, void *data, unsigned int size);
  549. /* dsp session buffer ops */
  550. /**
  551. * @brief clone a dsp session buffer.
  552. *
  553. * This routine clone a dsp session buffer from external buffer backstore.
  554. *
  555. * @param session Address of session.
  556. * @param buf external dsp session buf
  557. *
  558. * @return Address of new session buffer
  559. */
  560. struct dsp_session_buf *dsp_session_buf_clone(struct dsp_session *session, struct dsp_session_buf *buf);
  561. /**
  562. * @brief Destroy a dsp session buffer
  563. *
  564. * This routine dstroy a dsp session buffer, which has external buffer backstore.
  565. *
  566. * @param session Address of session.
  567. *
  568. * @return Address of session buffer
  569. */
  570. void dsp_session_buf_destroy(struct dsp_session_buf *buf);
  571. /* dsp session buffer ops */
  572. /**
  573. * @brief Allocate a dsp session buffer.
  574. *
  575. * This routine allocate a dsp session buffer.
  576. *
  577. * @param session Address of session.
  578. * @param size Size of session buffer, must be mutiple of 2.
  579. *
  580. * @return Address of session buffer
  581. */
  582. struct dsp_session_buf *dsp_session_buf_alloc(struct dsp_session *session, unsigned int size);
  583. /**
  584. * @brief Free a dsp session buffer.
  585. *
  586. * This routine free a dsp session buffer.
  587. *
  588. * @param buf Address of session buffer.
  589. *
  590. * @return N/A
  591. */
  592. void dsp_session_buf_free(struct dsp_session_buf *buf);
  593. /**
  594. * @brief Reset a dsp session buffer.
  595. *
  596. * This routine reset a dsp session buffer.
  597. *
  598. * @param buf Address of session buffer.
  599. *
  600. * @return N/A.
  601. */
  602. void dsp_session_buf_reset(struct dsp_session_buf *buf);
  603. /**
  604. * @brief Read a dsp session buffer.
  605. *
  606. * This routine read a dsp session buffer.
  607. *
  608. * @param buf Address of session buffer.
  609. * @param data Address of data buffer.
  610. * @param size Size of data.
  611. *
  612. * @return number of bytes successfully read.
  613. */
  614. int dsp_session_buf_read(struct dsp_session_buf *buf, void *data, unsigned int size);
  615. /**
  616. * @brief Write a dsp session buffer.
  617. *
  618. * This routine write a dsp session buffer.
  619. *
  620. * @param buf Address of session buffer.
  621. * @param data Address of data buffer.
  622. * @param size Size of data..
  623. *
  624. * @return number of bytes successfully written.
  625. */
  626. int dsp_session_buf_write(struct dsp_session_buf *buf, const void *data, unsigned int size);
  627. /**
  628. * @brief Read a dsp session buffer to stream.
  629. *
  630. * This routine read a dsp session buffer.
  631. *
  632. * @param buf Address of session buffer.
  633. * @param stream Handle of stream.
  634. * @param size Size of data.
  635. * @param stream_write Stream write ops.
  636. *
  637. * @return number of bytes successfully read.
  638. */
  639. int dsp_session_buf_read_to_stream(struct dsp_session_buf *buf,
  640. void *stream, unsigned int size,
  641. dsp_session_buf_write_fn stream_write);
  642. /**
  643. * @brief Write a dsp session buffer from stream.
  644. *
  645. * This routine read a dsp session buffer.
  646. *
  647. * @param buf Address of session buffer.
  648. * @param stream Handle of stream.
  649. * @param size Size of data.
  650. * @param stream_write Stream read ops.
  651. *
  652. * @return number of bytes successfully written.
  653. */
  654. int dsp_session_buf_write_from_stream(struct dsp_session_buf *buf,
  655. void *stream, unsigned int size,
  656. dsp_session_buf_read_fn stream_read);
  657. /**
  658. * @brief Determine size of a dsp session buffer.
  659. *
  660. * @param buf Address of session buffer.
  661. *
  662. * @return Session buffer size.
  663. */
  664. unsigned int dsp_session_buf_size(struct dsp_session_buf *buf);
  665. /**
  666. * @brief Determine free space a dsp session buffer.
  667. *
  668. * @param buf Address of session buffer.
  669. *
  670. * @return Session buffer free space.
  671. */
  672. unsigned int dsp_session_buf_space(struct dsp_session_buf *buf);
  673. /**
  674. * @brief Determine length of a dsp session buffer.
  675. *
  676. * @param buf Address of session buffer.
  677. *
  678. * @return Session buffer data length.
  679. */
  680. unsigned int dsp_session_buf_length(struct dsp_session_buf *buf);
  681. /**
  682. * @brief Drop all data of a dsp session buffer
  683. *
  684. * @param buf Address of ring buffer.
  685. *
  686. * @return number of elements dropped in elements.
  687. */
  688. size_t dsp_session_buf_drop_all(struct dsp_session_buf *buf);
  689. int dsp_session_buf_read_to_buffer(struct dsp_session_buf *buf, void *buffer, unsigned int size);
  690. int dsp_session_buf_write_from_buffer(struct dsp_session_buf *buf, void *buffer, unsigned int size);
  691. #ifdef __cplusplus
  692. }
  693. #endif
  694. #endif /* __DSP_HAL_H__ */