vs10xx.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. #ifndef _DEV_VS10XX_H_
  2. #define _DEV_VS10XX_H_
  3. /*
  4. * Copyright (C) 2001-2007 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. /*
  35. * $Log: vs10xx.h,v $
  36. * Revision 1.1 2007/04/12 08:59:55 haraldkipp
  37. * VS10XX decoder support added.
  38. *
  39. */
  40. #include <cfg/audio.h>
  41. #include <sys/types.h>
  42. /*!
  43. * \file dev/vs10xx.h
  44. * \brief Network interface controller definitions.
  45. */
  46. /*!
  47. * \addtogroup xgVs10xx
  48. */
  49. /*@{*/
  50. /*
  51. * Instruction opcodes.
  52. */
  53. #define VS_OPCODE_READ 3
  54. #define VS_OPCODE_WRITE 2
  55. /*!
  56. * \name Mode Control Register
  57. */
  58. /* ------------------------------------------------------------- */
  59. /*@{*/
  60. /*! \brief Register index. */
  61. #define VS_MODE_REG 0
  62. /*! \brief Left channel inverted. */
  63. #define VS_SM_DIFF 0x0001
  64. /*! \brief Allow MPEG Layers I & II.
  65. *
  66. * Determines whether it is allowed to decode MPEG 1 and 2 Layers I and II
  67. * in addition to Layer III. If you enable Layer I and Layer II decoding,
  68. * you are liable for any patent issues that may arise. Joint licensing of
  69. * MPEG 1.0 / 2.0 Layer III does not cover all patents pertaining to
  70. * Layers I and II.
  71. */
  72. #define VS_SM_LAYER12 0x0002
  73. /*! \brief VS1001K fast forward.
  74. *
  75. * By setting this bit, the player starts to accept data at a high speed, and
  76. * just decodes the audio headers silently without playing any audio data.
  77. * This can be used to fast-forward data with safe landing.
  78. * Register \ref VS_DECODE_TIME_REG is updated during a fast-forward just as
  79. * normal.
  80. *
  81. * Note, that this bit is available on the VS1001K only and is used as MPEG
  82. * Layer I & II enable on other members of the VS10xx family.
  83. */
  84. #define VS_SM_FFWD 0x0002
  85. /*! \brief Soft reset.
  86. *
  87. * Bit is cleared automatically.
  88. */
  89. #define VS_SM_RESET 0x0004
  90. /*! \brief VS1001 MPEG Layers I & II enable.
  91. *
  92. * May not work reliable due to firmware problems.
  93. *
  94. * If you enable Layer I and Layer II decoding, you are liable for any patent
  95. * issues that may arise.
  96. */
  97. #define VS_SM_MP12 0x0008
  98. /*! \brief Jump out of wave decoding.
  99. *
  100. * Set this bit to stop WAV, WMA and MIDI file playing before the end of
  101. * the file has been reached. Continue sending zeros for WAV and more data
  102. * for MIDI and WMA until this bit is cleared again.
  103. *
  104. * Not available on the VS1001K.
  105. */
  106. #define VS_SM_OUTOFWAV 0x0008
  107. /*! \brief Power down.
  108. *
  109. * During powerdown, no audio is played and no SDI operations are performed.
  110. * It is recommended to set \ref VS_VOL_REG to 0xFFFF before setting this
  111. * bit.
  112. *
  113. * For best power down efficiency, activate hardware reset.
  114. *
  115. * Not available on the VS1011. Although defined, this is not implemented
  116. * in the VS1001K firmware.
  117. */
  118. #define VS_SM_PDOWN 0x0010
  119. /*! \brief VS1001K unknown function. */
  120. #define VS_SM_DAC 0x0020
  121. /*! \brief Allow SDI tests.
  122. *
  123. * Not required for the VS1001K, where tests are enabled by default.
  124. */
  125. #define VS_SM_TESTS 0x0020
  126. /*! \brief VS1001K unknown function. */
  127. #define VS_SM_DACMONO 0x0040
  128. /*! \brief Stream mode.
  129. *
  130. * When stream mode is activated, data should be sent with as even
  131. * intervals as possible (and preferable with data blocks of less
  132. * than 512 bytes). The decoder makes every attempt to keep its input
  133. * buffer half full by changing its playback speed upto 5%. For best
  134. * quality sound, the average speed error should be within 0.5%, the
  135. * bitrate should not exceed 160 kbit/s and VBR should not be used.
  136. *
  137. * Not available on the VS1001K.
  138. */
  139. #define VS_SM_STREAM 0x0040
  140. /*! \brief VS1001K bass/treble enhancer. */
  141. #define VS_SM_BASS 0x0080
  142. /*! \brief Active edge of the data clock.
  143. *
  144. * If clear data is read at the rising edge, and if set data is read
  145. * at the falling edge.
  146. */
  147. #define VS_SM_DACT 0x0100
  148. /*! \brief . */
  149. #define VS_SM_BYTEORD 0x0200
  150. /*! \brief SDI most significant bit last.
  151. *
  152. * Bytes are, however, still sent in default order.
  153. */
  154. #define VS_SM_SDIORD 0x0200
  155. /*! \brief VS1001K master mode.
  156. *
  157. * Untested and not recommended.
  158. */
  159. #define VS_SM_IBMODE 0x0400
  160. /*! \brief Share SPI chip select. */
  161. #define VS_SM_SDISHARE 0x0400
  162. /*! \brief VS1001K master mode clock speed.
  163. *
  164. * Untested and not recommended.
  165. */
  166. #define VS_SM_IBCLK 0x0800
  167. /*! \brief VS1002 native SDI mode.
  168. *
  169. * Default is 0 on the VS1011E and 1 on the VS1002.
  170. *
  171. * Not available on the VS1001K.
  172. */
  173. #define VS_SM_SDINEW 0x0800
  174. /*! \brief ADPCM recording.
  175. *
  176. * Available on VS1033.
  177. */
  178. #define VS_SM_ADPCM 0x1000
  179. /*! \brief ADPCM high pass filter.
  180. *
  181. * If set at the same time as \ref VS_SM_ADPCM and \ref VS_SM_RESET,
  182. * ADPCM mode will start with a high-pass filter. This may help
  183. * intelligibility of speech when there is lots of background noise.
  184. *
  185. * Available on VS1033.
  186. */
  187. #define VS_SM_ADPCM_HP 0x2000
  188. /*! \brief ADPCM recording selector.
  189. *
  190. * Used to select the input for ADPCM recording. If cleared, microphone
  191. * input is used. If set to 1, LINEIN is used instead.
  192. *
  193. * Available on VS1033.
  194. */
  195. #define VS_SM_LINE_IN 0x4000
  196. /*! \brief Input clock range.
  197. *
  198. * Activates a clock divider at the XTAL input. Should be set as soon
  199. * as possible after a chip reset.
  200. *
  201. * Available on VS1033.
  202. */
  203. #define VS_SM_CLK_RANGE 0x8000
  204. /*@}*/
  205. /*!
  206. * \name Status Register
  207. */
  208. /*@{*/
  209. /* ------------------------------------------------------------- */
  210. /*! \brief Register index. */
  211. #define VS_STATUS_REG 1
  212. /*! \brief Internal analog volume control mask.
  213. *
  214. * These bits is meant to be used by the internal firmware only.
  215. *
  216. * - 0 for 0 dB
  217. * - 1 for -6 dB
  218. * - 3 for -12 dB
  219. */
  220. #define VS_SS_AVOL 0x0003
  221. /*! \brief Internal analog volume control LSB. */
  222. #define VS_SS_AVOL_LSB 0
  223. /*! \brief Internal analog power down.
  224. *
  225. * This bit is meant to be used by the internal firmware only.
  226. */
  227. #define VS_SS_APDOWM1 0x0004
  228. /*! \brief Analog driver power down.
  229. *
  230. * This bit is typically controlled by the internal firmware. However,
  231. * if the application wants to power down the decoder with a minimum
  232. * power-off transient, this bit should be set to 1 a few milliseconds
  233. * before activating reset.
  234. */
  235. #define VS_SS_APDOWN2 0x0008
  236. /*! \brief Version mask.
  237. *
  238. * - 0 for VS1001
  239. * - 1 for VS1011
  240. * - 2 for VS1002 and VS1011E, see \ref VS_SM_SDINEW
  241. * - 3 for VS1003
  242. */
  243. #define VS_SS_VER 0x0070
  244. /*! \brief Version LSB. */
  245. #define VS_SS_VER_LSB 4
  246. /*@}*/
  247. /*!
  248. * \name VS1001 internal frequency control register.
  249. */
  250. /* ------------------------------------------------------------- */
  251. /*@{*/
  252. /*! \brief Register index.
  253. *
  254. * Use only on older chip revisions?
  255. */
  256. #define VS_INT_FCTLH_REG 2
  257. /*@}*/
  258. /*!
  259. * \name Bass/Treble Enhancer Register
  260. */
  261. /* ------------------------------------------------------------- */
  262. /*@{*/
  263. /*! \brief Register index.
  264. *
  265. * For the VS1001K see \ref VS_SM_BASS.
  266. */
  267. #define VS_BASS_REG 2
  268. /*! \brief Bass enhancer lower limit frequency mask.
  269. *
  270. * Specified in 10 Hz steps.
  271. */
  272. #define VS_SB_FREQLIMIT 0x000F
  273. /*! \brief Lower limit frequency LSB. */
  274. #define VS_SB_FREQLIMIT_LSB 0
  275. /*! \brief Bass enhancement mask.
  276. *
  277. * Bass enhancement in 1 dB steps, or disabled when zero.
  278. */
  279. #define VS_SB_AMPLITUDE 0x00F0
  280. /*! \brief Bass enhancement LSB. */
  281. #define VS_SB_AMPLITUDE_LSB 4
  282. /*! \brief Treble control lower limit frequency mask.
  283. *
  284. * Specified in 1 kHz steps.
  285. */
  286. #define VS_ST_FREQLIMIT 0x000F
  287. /*! \brief Lower limit frequency LSB. */
  288. #define VS_ST_FREQLIMIT_LSB 0
  289. /*! \brief Treble control mask.
  290. *
  291. * Treble control in 1.5 dB steps, or disabled when zero.
  292. */
  293. #define VS_ST_AMPLITUDE 0x00F0
  294. /*! \brief Bass enhancement LSB. */
  295. #define VS_ST_AMPLITUDE_LSB 4
  296. /*@}*/
  297. /*!
  298. * \name Clock Frequency and Multiplier Register
  299. */
  300. /* ------------------------------------------------------------- */
  301. /*@{*/
  302. /*! \brief Register index. */
  303. #define VS_CLOCKF_REG 3
  304. /*! \brief Clock frequency mask.
  305. *
  306. * Should be set to crystal clock divided by 2000, if the clock
  307. * is not 24.576 MHz.
  308. *
  309. * Used for the VS1001, VS1011 and VS1002.
  310. */
  311. #define VS_SC_FREQ 0x7FFF
  312. /*! \brief VS1003/VS1033 clock frequency mask.
  313. *
  314. * Should be set to crystal clock divided by 4000, if the clock
  315. * is not 12.288 MHz.
  316. *
  317. * Used for the VS1003 and VS1033.
  318. */
  319. #define VS_SC_X3FREQ 0x07FF
  320. /*! \brief Clock frequency LSB. */
  321. #define VS_SC_FREQ_LSB 0
  322. /*! \brief Allowed multiplier addition.
  323. *
  324. * Used for WMA decoding with the VS1003 and VS1033.
  325. */
  326. #define VS_SC_ADD 0x1800
  327. /*! \brief Clock multiplier.
  328. *
  329. * Used for the VS1003 and VS1033.
  330. */
  331. #define VS_SC_MULT 0xE000
  332. /*! \brief Clock doubler enable.
  333. *
  334. * Used for the VS1001, VS1011 and VS1002.
  335. */
  336. #define VS_CF_DOUBLER 0x8000
  337. /*@}*/
  338. /*!
  339. * \name Decode Time Register
  340. */
  341. /* ------------------------------------------------------------- */
  342. /*@{*/
  343. /*! \brief Register index.
  344. *
  345. * This read-only register contains the decode time in full seconds or
  346. * zero after resetting the decoder.
  347. */
  348. #define VS_DECODE_TIME_REG 4
  349. /*@}*/
  350. /*!
  351. * \name Miscellaneous Audio Data Register
  352. */
  353. /* ------------------------------------------------------------- */
  354. /*@{*/
  355. /*! \brief Register index.
  356. *
  357. * Usage on the VS1001K differs.
  358. */
  359. #define VS_AUDATA_REG 5
  360. /*! \brief Stereo flag.
  361. *
  362. * Set to 1 for stereo and 0 for mono. Read-only.
  363. */
  364. #define VS_AD_STEREO 0x0001
  365. /*! \brief Current sampling rate mask.
  366. *
  367. * Value is sample rate divided by 2. Writing to this register will
  368. * change the sample rate on the run.
  369. */
  370. #define VS_AD_SRATE 0xFFFE
  371. /*! \brief Crystal clock LSB. */
  372. #define VS_AD_SRATE_LSB 1
  373. /*@}*/
  374. /*!
  375. * \name RAM Read/Write Register
  376. */
  377. /* ------------------------------------------------------------- */
  378. /*@{*/
  379. /*! \brief Register index.
  380. *
  381. * Used to upload application programs and data to instruction and data RAM.
  382. */
  383. #define VS_WRAM_REG 6
  384. /*@}*/
  385. /*!
  386. * \name RAM Read/Write Base Address Register
  387. */
  388. /* ------------------------------------------------------------- */
  389. /*@{*/
  390. /*! \brief Register index.
  391. *
  392. * Used to upload application programs and data to instruction and data RAM.
  393. */
  394. #define VS_WRAMADDR_REG 7
  395. /*@}*/
  396. /*!
  397. * \name Stream Header Data Register 0
  398. */
  399. /* ------------------------------------------------------------- */
  400. /*@{*/
  401. /*! \brief Register index.
  402. *
  403. * Not available in the VS1103.
  404. */
  405. #define VS_HDAT0_REG 8
  406. /*@}*/
  407. /*!
  408. * \name VS1103 Input Register 0
  409. */
  410. /* ------------------------------------------------------------- */
  411. /*@{*/
  412. /*! \brief Register index. */
  413. #define VS_IN0_REG 8
  414. /*@}*/
  415. /*!
  416. * \name Stream Header Data Register 1
  417. */
  418. /* ------------------------------------------------------------- */
  419. /*@{*/
  420. /*! \brief Register index.
  421. *
  422. * Not available in the VS1103.
  423. */
  424. #define VS_HDAT1_REG 9
  425. /*@}*/
  426. /*!
  427. * \name VS1103 Input Register 1
  428. */
  429. /* ------------------------------------------------------------- */
  430. /*@{*/
  431. /*! \brief Register index. */
  432. #define VS_IN1_REG 9
  433. /*@}*/
  434. /*!
  435. * \name Application Start Address Register
  436. *
  437. * Used to activate previously uploaded application programs.
  438. */
  439. /* ------------------------------------------------------------- */
  440. /*@{*/
  441. /*! \brief Register index. */
  442. #define VS_AIADDR_REG 10
  443. /*@}*/
  444. /*!
  445. * \name Volume Control Register
  446. */
  447. /* ------------------------------------------------------------- */
  448. /*@{*/
  449. /*! \brief Register index. */
  450. #define VS_VOL_REG 11
  451. /*! \brief Right channel volume mask.
  452. *
  453. * Attenuation is given in 0.5 dB steps or 255 for mute.
  454. */
  455. #define VS_VOL_RIGHT 0x00FF
  456. /*! \brief Right channel volume LSB. */
  457. #define VS_VOL_RIGHT_LSB 0
  458. /*! \brief Right channel volume mask.
  459. *
  460. * Attenuation is given in 0.5 dB steps or 255 for mute.
  461. */
  462. #define VS_VOL_LEFT 0xFF00
  463. /*! \brief Right channel volume LSB. */
  464. #define VS_VOL_LEFT_LSB 8
  465. /*@}*/
  466. /*!
  467. * \name VS1103 Mixer Volume Register
  468. */
  469. /* ------------------------------------------------------------- */
  470. /*@{*/
  471. /*! \brief Register index.
  472. *
  473. */
  474. #define VS_MIXERVOL_REG 12
  475. #define VS_SMV_GAIN1 0x001F
  476. #define VS_SMV_GAIN2 0x03E0
  477. #define VS_SMV_GAIN3 0x7C00
  478. #define VS_SMV_ACTIVE 0x8000
  479. /*@}*/
  480. /*!
  481. * \name VS1103 IMA ADPCM Record Control Register
  482. */
  483. /* ------------------------------------------------------------- */
  484. /*@{*/
  485. /*! \brief Register index.
  486. *
  487. */
  488. #define VS_ADPCMRECCTL_REG 13
  489. #define VS_SARC_GAIN4 0x003F
  490. #define VS_SARC_MANUALGAIN 0x0040
  491. #define VS_SARC_OUTOFADPCM 0x0080
  492. /*@}*/
  493. /*!
  494. * \name Application Control Registers
  495. */
  496. /* ------------------------------------------------------------- */
  497. /*@{*/
  498. /*! \brief Application register 0 index.
  499. *
  500. * Do not use with VS1001. Also used for mixer volume on the VS1103.
  501. */
  502. #define VS_AICTRL0_REG 12
  503. /*! \brief VS1001K application register 0 index.
  504. *
  505. * A second register is available at VS_AICTRL0_REG + 1.
  506. */
  507. #define VS_AICTRL_REG 13
  508. /*! \brief Application register 1 index.
  509. *
  510. * Register 0 on the VS1001. Also used for IMA ADPCM record control in
  511. * the VS1103.
  512. */
  513. #define VS_AICTRL1_REG 13
  514. /*! \brief Application register 2 index.
  515. *
  516. * Register 1 on the VS1001.
  517. */
  518. #define VS_AICTRL2_REG 14
  519. /*! \brief Application register 3 index.
  520. *
  521. * Do not use with VS1001.
  522. */
  523. #define VS_AICTRL3_REG 15
  524. /*@}*/
  525. /*
  526. * Bytes needed to flush internal VS buffer (size of VS interbal buffer)
  527. */
  528. #define VS_FLUSH_BYTES 2048
  529. /*
  530. * Status of the decoder
  531. */
  532. #define VS_STATUS_STOPPED 0
  533. #define VS_STATUS_RUNNING 1
  534. #define VS_STATUS_EOF 2
  535. #define VS_STATUS_EMPTY 4
  536. /*
  537. * Header info filled by VsGetHeaderInfo.
  538. */
  539. #ifdef __GNUC__
  540. typedef struct __attribute__((packed)) {
  541. u_short vshi_no_crc:1;
  542. u_short vshi_layer:2;
  543. u_short vshi_id:2;
  544. u_short vshi_syncword:11;
  545. u_short vshi_emphasis:2;
  546. u_short vshi_original:1;
  547. u_short vshi_copyright:1;
  548. u_short vshi_extension:2;
  549. u_short vshi_mode:2;
  550. u_short vshi_private_bit:1;
  551. u_short vshi_pad_bit:1;
  552. u_short vshi_sample_rate:2;
  553. u_short vshi_bitrate:4;
  554. } VS_HEADERINFO;
  555. #endif
  556. __BEGIN_DECLS
  557. /* Function prototypes */
  558. extern int VsPlayerInit(void);
  559. extern int VsPlayerReset(u_short mode);
  560. extern int VsPlayerSetMode(u_short mode);
  561. extern int VsPlayerKick(void);
  562. extern int VsPlayerStop(void);
  563. extern int VsPlayerFlush(void);
  564. extern ureg_t VsPlayerInterrupts(ureg_t enable);
  565. extern ureg_t VsPlayerThrottle(ureg_t on);
  566. extern u_short VsPlayTime(void);
  567. extern u_int VsGetStatus(void);
  568. #ifdef __GNUC__
  569. extern int VsGetHeaderInfo(VS_HEADERINFO *vshi);
  570. #endif
  571. extern u_short VsMemoryTest(void);
  572. extern int VsSetVolume(ureg_t left, ureg_t right);
  573. extern int VsBeep(u_char fsin, u_char ms);
  574. /*@}*/
  575. __END_DECLS
  576. /* End of prototypes */
  577. #endif