drv_mp_desp.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. #ifndef __DRV_MP_DESP_H__
  2. #define __DRV_MP_DESP_H__
  3. #include "drv_types.h"
  4. /* ----- main buffer descriptor ---------------------------------------- */
  5. /* Note: Currently mpeg, mp3, aac, and cook
  6. use this basical buffer descriptor. */
  7. typedef struct __MPBUF_DESP
  8. {
  9. /* mp buffer descriptor flag */
  10. UINT8 mp_flag;
  11. #define MP_FLAG_MEDIAPLAYER 0
  12. #define MP_FLAG_DECODE_ONLY 1
  13. #define MP_FLAG_NEWMEDIAPLAYER 2
  14. #define MP_FLAG_GENERAL_INFO 3
  15. #define MP_FLAG_DDP_LICENSE 4
  16. #define MP_FLAG_ENCODE_ONLY 5
  17. /* Aync dec/enc path */
  18. #define MP_FLAG_AUDIODSP 0x10
  19. /* audio type, used only for flag = MP_FLAG_SISMEDIA_PLAYER */
  20. /* please see enum MP_DATA_TYPE_T */
  21. UINT8 audio_type;
  22. /* sample rate, used only for flag = MP_FLAG_SISMEDIA_PLAYER */
  23. /* please see enum MP_SFREQ_T */
  24. UINT8 sfreq;
  25. /* used only for flag = MP_FLAG_DECODE_ONLY */
  26. union
  27. {
  28. /*according to differnet source, do some special rules*/
  29. /*please see enum MP_SOURCE_T*/
  30. UINT8 input_source;
  31. #define MP_SOURCE_FFMPEG 0
  32. #define MP_SOURCE_FLASH 1
  33. #define MP_SOURCE_UNKNOWN 0xff
  34. UINT8 reserved01;
  35. struct
  36. {
  37. UINT8 bUseMultiPcmBuf : 1;
  38. UINT8 Buf_FrameNo: 6;
  39. UINT8 unused : 1;
  40. };
  41. };
  42. union
  43. {
  44. /* input audio buffer address/offset */
  45. UINT32 buf_offset;
  46. UINT32 pcm_desp_idx; //for MultiPcmBuf
  47. UINT32 buf_addr;
  48. };
  49. /* input audio buffer size */
  50. UINT32 buf_size;
  51. union
  52. {
  53. #define MP_PTSCNT_PER_SEC (45000)
  54. /* used only for flag = MP_FLAG_SISMEDIA_PLAYER */
  55. UINT32 pts; /* 45000 per second */
  56. /* used only for flag = MP_FLAG_DECODE_ONLY */
  57. UINT32 decbuf_offset;
  58. /*used only for flag = MP_FLAG_ENCODE_ONLY*/
  59. UINT32 enc_outbuf_offset;
  60. };
  61. union
  62. {
  63. /* used only for flag = MP_FLAG_SISMEDIA_PLAYER */
  64. UINT32 sample_nb;
  65. /* used only for flag = MP_FLAG_DECODE_ONLY */
  66. UINT32 decbuf_size;
  67. };
  68. union
  69. {
  70. UINT32 last_video_pts; //45k unit
  71. struct
  72. {
  73. UINT32 bAD_stream : 8;
  74. UINT32 AD_fade : 8;
  75. UINT32 AD_pan : 8;
  76. UINT32 reserved : 8;
  77. };
  78. };
  79. UINT32 private_data_size;
  80. UINT8 private_data[4];
  81. } MPBUF_DESP, *MPBUF_DESP_PTR;
  82. /* Fixed field size include all fields except private_data */
  83. #define MPBUF_DESP_FIX_FIELD_SIZE (sizeof(MPBUF_DESP)-4)
  84. /* This type enum should be sync to sisaudio_cmdq.h */
  85. enum MP_DATA_TYPE_T
  86. {
  87. MP_DATA_TYPE_PCM = 0x00,
  88. MP_DATA_TYPE_MPEG = 0x01,
  89. MP_DATA_TYPE_AC3 = 0x02,
  90. MP_DATA_TYPE_DTS = 0x03,
  91. MP_DATA_TYPE_AAC = 0x04,
  92. MP_DATA_TYPE_MP3 = 0x05,
  93. MP_DATA_TYPE_REAL = 0x06,
  94. MP_DATA_TYPE_EAC3 = 0x07,
  95. MP_DATA_TYPE_WMA = 0x08,
  96. MP_DATA_TYPE_COOK = 0x09,
  97. MP_DATA_TYPE_AMRNB = 0x0a,
  98. MP_DATA_TYPE_AMRWB = 0x0b,
  99. MP_DATA_TYPE_VORBIS = 0x0c,
  100. MP_DATA_TYPE_SILK = 0x0d,
  101. MP_DATA_TYPE_ISAC = 0x0e,
  102. MP_DATA_TYPE_DRA = 0x0f,
  103. MP_DATA_TYPE_FLAC = 0x10,
  104. MP_DATA_TYPE_UNKNOW = 0xff
  105. };
  106. /* This type enum should be sync to sisaudio_cmdq.h */
  107. enum MP_SFREQ_T
  108. {
  109. MP_SFREQ_24000,
  110. MP_SFREQ_48000,
  111. MP_SFREQ_96000,
  112. MP_SFREQ_192000,
  113. MP_SFREQ_22050,
  114. MP_SFREQ_44100,
  115. MP_SFREQ_88200,
  116. MP_SFREQ_176400,
  117. MP_SFREQ_32000,
  118. MP_SFREQ_8000,
  119. MP_SFREQ_11025,
  120. MP_SFREQ_12000,
  121. MP_SFREQ_16000,
  122. MP_SFREQ_64000
  123. };
  124. enum eAUDIO_BUFFER
  125. {
  126. eAUDIO_CMD_BUFFER,
  127. eAUDIO_PCM_BUFFER,
  128. eAUDIO_DEC_BUFFER,
  129. };
  130. /* ----- pcm buffer descriptor ----------------------------------------- */
  131. typedef struct __MPBUF_DESP_PCM
  132. {
  133. union
  134. {
  135. MPBUF_DESP main;
  136. struct
  137. {
  138. UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
  139. /* Serveral bytes private data for PCM case */
  140. UINT8 chmask;
  141. UINT8 chcnt;
  142. UINT8 sample_bits;
  143. UINT8 endian;
  144. #define MP_PCM_ENDIAN_LITTLE (0)
  145. #define MP_PCM_ENDIAN_BIG (1)
  146. UINT8 bfloat;
  147. UINT8 bdown_half_sample;
  148. };
  149. };
  150. } MPBUF_DESP_PCM, *MPBUF_DESP_PCM_PTR;
  151. #define MPBUF_DESP_PCM_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_PCM)-MPBUF_DESP_FIX_FIELD_SIZE)
  152. /* ----- aac buffer descriptor ----------------------------------------- */
  153. typedef struct __MPBUF_DESP_AAC
  154. {
  155. union
  156. {
  157. MPBUF_DESP main;
  158. struct
  159. {
  160. UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
  161. /* private data for AAC case*/
  162. UINT8 ObjType;
  163. UINT8 ext_ObjType;
  164. UINT8 sbr;
  165. UINT32 sampling_freq;
  166. UINT32 ext_sampling_freq;
  167. UINT8 aac_fmt;
  168. #if !defined(AAC_LATM) || !defined(AAC_ADTS) || !defined(AAC_ADIF) || !defined(AAC_RAW)
  169. #define AAC_LATM (0)
  170. #define AAC_ADTS (1)
  171. #define AAC_ADIF (2)
  172. #define AAC_RAW (3)
  173. #endif
  174. UINT8 profile; // AAC PROFILE 0: AAC MAIN, 1 : AAC LC
  175. #if !defined(AAC_MAIN_PROFILE)
  176. #endif
  177. };
  178. };
  179. } MPBUF_DESP_AAC, *MPBUF_DESP_AAC_PTR;
  180. #define MPBUF_DESP_AAC_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_AAC)-MPBUF_DESP_FIX_FIELD_SIZE)
  181. /* Private codec info for AAC */
  182. typedef struct __CODEC_INFO_AAC
  183. {
  184. UINT8 fmt;
  185. UINT8 extra_data_size;
  186. UINT8 extra_data[256];
  187. } CODEC_INFO_AAC, * CODEC_INFO_AAC_PTR;
  188. /* ----- wma buffer descriptor ----------------------------------------- */
  189. typedef struct __MPBUF_DESP_WMA
  190. {
  191. union
  192. {
  193. MPBUF_DESP main;
  194. struct
  195. {
  196. UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
  197. /* private data for WMA case*/
  198. struct
  199. {
  200. UINT32 bitspersample : 8;
  201. UINT32 channels : 4;
  202. UINT32 codec_id : 2;
  203. UINT32 wma_reserved: 18;
  204. };
  205. UINT32 samplerate;
  206. UINT32 bitrate;
  207. UINT32 blockalign;
  208. UINT32 datalen;
  209. UINT8 data[6];
  210. UINT16 wEncodeOptions;
  211. UINT32 dwChannelMask;
  212. };
  213. };
  214. } MPBUF_DESP_WMA, *MPBUF_DESP_WMA_PTR;
  215. #define MPBUF_DESP_WMA_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_WMA)-MPBUF_DESP_FIX_FIELD_SIZE)
  216. /* ----- cook buffer descriptor ---------------------------------------- */
  217. /* data type Real use basical buffer descriptor */
  218. /* Private codec info for COOK */
  219. typedef struct __CODEC_INFO_COOK
  220. {
  221. /* Serveral bytes private data for Cook case */
  222. UINT32 SampleRate;
  223. UINT32 BitsPerSample;
  224. UINT32 NumOfChannel;
  225. UINT32 AudioQuality;
  226. UINT32 BitsPerFrame;
  227. UINT32 Granularity;
  228. UINT32 OpaqueDataSize;
  229. /* According to RealFormatSDK, Max ppaque data size for cook is 20 bytes */
  230. #define REAL_COOK_MAX_OPAQUE_DATA_SIZE (20)
  231. UINT8 OpaqueData[REAL_COOK_MAX_OPAQUE_DATA_SIZE];
  232. } CODEC_INFO_COOK, *CODEC_INFO_COOK_PTR;
  233. typedef CODEC_INFO_COOK RA_FORMAT_INFO;
  234. typedef CODEC_INFO_COOK_PTR RA_FORMAT_INFO_PTR;
  235. /* ----- EAC3 buffer descriptor ---------------------------------------- */
  236. typedef struct __MPBUF_DESP_DDP
  237. {
  238. union
  239. {
  240. MPBUF_DESP main;
  241. struct
  242. {
  243. UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
  244. /* Serveral bytes private data for DDP case */
  245. UINT8 private_data[0x20];
  246. //DOLBY_DIGITAL_SETTINGS_CMDQ ddpinfo;
  247. };
  248. };
  249. } MPBUF_DESP_DDP, *MPBUF_DESP_DDP_PTR;
  250. #define MPBUF_DESP_DDP_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_DDP)-MPBUF_DESP_FIX_FIELD_SIZE)
  251. /*------SILK descriptor-----------------------------------------------*/
  252. typedef struct __MPBUF_DESP_SILK
  253. {
  254. union
  255. {
  256. MPBUF_DESP main;
  257. struct
  258. {
  259. UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
  260. UINT8 silk_fmt;
  261. #define SILK_NB_V3 0
  262. #define SILK_MB_V3 1
  263. #define SILK_WB_V3 2
  264. #define SILK_SW_V3 3
  265. };
  266. };
  267. } MPBUF_DESP_SILK, *MPBUF_DESP_SILK_PTR;
  268. #define MPBUF_DESP_SILK_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_SILK)-MPBUF_DESP_FIX_FIELD_SIZE)
  269. /* ----- General Control descriptor ------------------------------------ */
  270. typedef struct __MPBUF_DESP_GENERAL_INFO
  271. {
  272. union
  273. {
  274. MPBUF_DESP main;
  275. struct
  276. {
  277. UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
  278. /* private data for general info case*/
  279. UINT32 payload_offset;
  280. UINT32 flashPTS_for_init_stc; //for resume_init_waiting used
  281. struct
  282. {
  283. UINT32 clean_flag : 1;
  284. UINT32 pause_flag : 1;
  285. UINT32 resume_flag : 1;
  286. UINT32 payload_offset_flag : 1;
  287. UINT32 init_waiting_flag : 1;
  288. UINT32 resume_init_waiting_flag : 1;
  289. UINT32 fast_slow_play_flag : 1;
  290. UINT32 enable_audio: 1;
  291. UINT32 disable_audio: 1;
  292. UINT32 reserved : 23;
  293. };
  294. };
  295. };
  296. } MPBUF_DESP_GENERAL_INFO, *MPBUF_DESP_GENERAL_INFO_PTR;
  297. #define MPBUF_DESP_GENERAL_INFO_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_GENERAL_INFO)-MPBUF_DESP_FIX_FIELD_SIZE)
  298. typedef struct __MPBUF_DESP_DSP
  299. {
  300. union
  301. {
  302. MPBUF_DESP main;
  303. /* NOTICE: Please filled these main mp buf desp fields
  304. mp_flag: should be MP_FLAG_AUDIODSP
  305. audio_type: input audio type
  306. sfreq: input audio sample frequency
  307. buf_addr: input buffer ptr, no use in mp driver
  308. buf_size: input buffer size, no use in mp driver
  309. Other fields: left empty. */
  310. struct
  311. {
  312. UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
  313. /* Private data for Audio dsp */
  314. union
  315. {
  316. UINT32 audio_dsp_info;
  317. struct
  318. {
  319. UINT32 operation: 8;
  320. #define MPDSP_OP_DECODE (0)
  321. #define MPDSP_OP_ENCODE (1)
  322. #define MPDSP_OP_POSTPROCESS (2)
  323. UINT32 outAudioType: 8; /* output audio type */
  324. UINT32 inbuf_type: 8;
  325. /* 0: inbuf contains normal data
  326. 1: inbuf contains codec config data */
  327. UINT32 desp_idx: 8; /* Filled by mpdsp */
  328. };
  329. };
  330. UINT32 desp_mgt_kbase; /* Filled by mpdsp */
  331. UINT32 outbuf_size;
  332. /* Expected output buffer size, no use in mp driver */
  333. };
  334. };
  335. } MPBUF_DESP_DSP, *MPBUF_DESP_DSP_PTR;
  336. #define MPBUF_DESP_DSP_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_DSP)-MPBUF_DESP_FIX_FIELD_SIZE)
  337. /* ----- Union of all descriptors -------------------------------------- */
  338. typedef struct MPBUF_DESP_UNION
  339. {
  340. union
  341. {
  342. MPBUF_DESP main;
  343. MPBUF_DESP_PCM pcm;
  344. MPBUF_DESP_AAC aac;
  345. MPBUF_DESP_WMA wma;
  346. MPBUF_DESP_DDP ddp;
  347. MPBUF_DESP_SILK silk;
  348. MPBUF_DESP_GENERAL_INFO gi;
  349. MPBUF_DESP_DSP dsp;
  350. };
  351. } MPBUF_DESP_UNION, *MPBUF_DESP_UNION_PTR;
  352. /* ----- Definitions for mp dsp module ---------------------------------*/
  353. typedef enum
  354. {
  355. MPDSP_BUFTYPE_NORMAL = 0,
  356. MPDSP_BUFTYPE_CONFIG,
  357. MPDSP_BUFTYPE_MOREDATA = 0x80,
  358. MPDSP_BUFTYPE_NUM
  359. } MPDSP_BUFTYPE;
  360. typedef volatile struct __MPDSP_DESP
  361. {
  362. #define MPDSP_DESP_MAJOR_VERSION (0x01)
  363. #define MPDSP_DESP_UPDATE_VERSION (0x00)
  364. union
  365. {
  366. UINT32 union_dw_00;
  367. struct
  368. {
  369. UINT32 state: 8;
  370. #define MPDSP_ST_INIT (0)
  371. #define MPDSP_ST_DESP_FILLED (1)
  372. #define MPDSP_ST_DSP_READY (2)
  373. #define MPDSP_ST_DSP_ERROR (3)
  374. UINT32 frame_cnt: 8; /* NO USE NOW */
  375. /* Input/output data type. Please check enum MPDSP_BUFTYPE */
  376. UINT32 inbuf_type: 8;
  377. UINT32 outbuf_type: 8;
  378. };
  379. };
  380. /* dword 01 02 */
  381. UINT32 reserved_dw[2];
  382. /* dword 03 */
  383. union
  384. {
  385. UINT32 union_dw_03;
  386. struct
  387. {
  388. UINT32 dsp_extra_info: 8;
  389. UINT32 reserved_d3_b13: 24;
  390. };
  391. };
  392. /* Input buffer offset and size */
  393. /* dword 04 05 */
  394. UINT32 inbuf_offset;
  395. UINT32 inbuf_size;
  396. /* Output buffer offset and size */
  397. /* dword 06 07 */
  398. UINT32 outbuf_offset;
  399. /* max size for output buffer,
  400. audio dsp may update this size to smaller size. */
  401. UINT32 outbuf_size;
  402. /* TODO: Outbuf may not be feed to requester at once
  403. and should be sperated copied, we need to handle
  404. this situation.
  405. Current solution: Get buffer at once.
  406. */
  407. } MPDSP_DESP, *pMPDSP_DESP;
  408. typedef volatile struct __MPDSP_DESP_MGT
  409. {
  410. #define MPDSP_MGT_MAJOR_VERSION (0x01)
  411. #define MPDSP_MGT_UPDATE_VERSION (0x00)
  412. /* Set to magic number 0xade5b3a6 */
  413. UINT32 syncword;
  414. #define MPDSP_DESP_MGT_SYNCWORD (0xade5b3a6)
  415. union
  416. {
  417. UINT32 version;
  418. #define MPDSP_VERSION \
  419. ((MPDSP_MGT_MAJOR_VERSION<<24)|(MPDSP_MGT_UPDATE_VERSION<<16)|\
  420. (MPDSP_DESP_MAJOR_VERSION<<8)|(MPDSP_DESP_UPDATE_VERSION))
  421. struct
  422. {
  423. UINT32 desp_update_ver: 8;
  424. UINT32 desp_major_ver: 8;
  425. UINT32 mgt_update_ver: 8;
  426. UINT32 mgt_major_ver: 8;
  427. };
  428. };
  429. union
  430. {
  431. UINT32 union_dw_02;
  432. struct
  433. {
  434. UINT32 inAudioType: 8;
  435. UINT32 outAudioType: 8;
  436. UINT32 reserved_dw2_00: 8;
  437. UINT32 operation: 8;
  438. #define MPDSP_OP_DECODE (0)
  439. #define MPDSP_OP_ENCODE (1)
  440. };
  441. };
  442. union
  443. {
  444. UINT32 union_dw_03;
  445. struct
  446. {
  447. UINT32 desp_num: 8; /* number of dsp desps */
  448. UINT32 desp_sz: 8; /* size of one dsp desp */
  449. UINT32 wp: 8; /* desp is empty and can be filled now */
  450. UINT32 rp: 8; /* desp is filled and ready for dsp */
  451. /* queue status:
  452. empty if (wp == rp),
  453. full if ((wp+1)%desp_num == rp) */
  454. };
  455. };
  456. /* Total buffer size: including desp mgt, desps, and used buffer */
  457. UINT32 dsp_buf_size;
  458. union
  459. {
  460. UINT32 union_dw_05;
  461. struct
  462. {
  463. UINT32 bInit: 1; /* 1: dsp initialized */
  464. UINT32 reserved_dw5_00: 7;
  465. UINT32 bCancelAll: 1; /* 1: Cancel all */
  466. UINT32 reserved_dw5_01: 23;
  467. };
  468. };
  469. /* MPDEV allocates buffer for audio codecs */
  470. UINT32 libbuf_offset;
  471. UINT32 libbuf_size;
  472. MPDSP_DESP desp[0];
  473. } MPDSP_DESP_MGT, *pMPDSP_DESP_MGT;
  474. typedef struct __MP_STATUS
  475. {
  476. UINT8 status;
  477. #define MPST_STOP (0)
  478. #define MPST_PLAYING (1)
  479. #define MPST_PAUSE (2)
  480. UINT32 lastpts;
  481. /* 45K stc clock */
  482. UINT32 cur_stc;
  483. } MP_STATUS, *pMP_STATUS;
  484. typedef enum __MPDEV_STATUS
  485. {
  486. MPDEV_ST_OK,
  487. MPDEV_ST_NOT_INIT,
  488. MPDEV_ST_INIT_FAIL,
  489. MPDEV_ST_INVALID_PARAM,
  490. MPDEV_ST_WRITE_FAIL,
  491. MPDEV_ST_READ_FAIL,
  492. MPDEV_ST_IOCTL_FAIL,
  493. MPDEV_ST_PLEASE_WAIT,
  494. MPDEV_ST_NO_MORE_BUFFER,
  495. MPDEV_ST_INBUF_TOO_SMALL,
  496. MPDEV_ST_UNKNOW_ERROR,
  497. MPDEV_ST_END /* DON'T USE IT */
  498. } MPDEV_STATUS;
  499. #endif /* __DRV_MP_DESP_H__ */