A710
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
00.00 ??.??.03 JR - initial version
00.01 09.01.04 RS - added aes support
      23.01.04 RS - added i2c support for read eeprom
      30.01.04 RS - added support for transmit ir
00.02 24.02.04 RS - fix for ir Raw send
      27.02.04 RS - added function to ckeck IR transmitting
                  - added nec repetition sending
                  - change ir raw output to 4byte hex per value
02.01 29.04.04 RS - only changed version to 02.01
02.02 04.05.04 RS - added get mp3 header fkt
      05.05.04 RS - added fkt for get current codec mp3 header info
                  - added fkt to get codec mask
      18.05.04 RS - added fkt to init i2c channels
                  - removed unnecessary set output calls in i2c
                  - added rtc DS1307 support
      04.06.04 RS - added fkt to get mpeg frame counter
02.03 11.08.04 RS - added hw compatibility for dstni-ex
      12.08.04 RS - fixed codec handling, locked access
      09.09.04 RS - added encoder functionality and workaround
02.04 16.09.04 RS - restart codec on select in on change input from/to s/pdif
      21.09.04 RS - fixed 5us delay in i2c driver
                  - fixed bug in ir send (memory overwrite -> use _fmemset
                    instead of memset)
      28.09.04 RS - send sony ir tg 3x every 45ms
      20.10.04 RS - changed volume scale (100% = +3db instead +12db)
                  - added volume offset gain
      09.11.04 RS - removed sonance support (don't influence dout for
                    annuncicom ic)
02.05 10.12.04 RS - added fkt for send i2c file
                  - use send i2c file for init codec
                  - added codec software download for ulaw/alow/uncompressed
                    streaming for 35x9 a2/b4 and 3587
                  - added fkt for codec init, select input with selectable
                    streamtype
      28.12.04 RS - added line in mix with stream
      07.01.05 RS - support for ulaw/alaw/uncompressed encoding/decoding
      25.01.05 RS - disable codec a/d for now noise via line in/mic in during
                    change of input source or en/decode
      26.01.05 RS - added fine pitch function for full range of codec register
      27.01.05 RS - pitch also available for encoder
02.06 11.07.05 KS - remove AES until needed.
      12.07.05 KS - update Makefile and song.bat   
02.07 18.08.05 PK - siospi moved to the song module
                  - interrupt routine optimalizations
02.08 14.10.05 PK - WMA support for VLSI
                  - added aux call
		  - correct codec autodetection
		  - VLSI codec: implemented balance, treble, bass and output mode
                  - locking in the song module
02.09 31.10.05 PK - WMA streaming (broadcast) fixed with VLSI rewind patch v0.7
02.10 11.01.06 PK - added detection of the VS1023 chip
                  - added I2S support for VS1023
02.11 08.02.06 PK - added support for 57kHz IR transmit (first byte is: 0=baseband, 1=38kHz, 2=57kHz(60kHz) )
                  - fixed IR output for EX chip
		  - fixed baseband transmit on IR
02.12 10.02.06 PK - CODEC_GETBITRATE call added
02.13 22.03.06 PK - IR output fix for second serial channel on EX hardware
      05.04.06 PK - enabled CLKO output for MP3
02.14 23.04.06 PK - Micronas download code from 12/10/05
                  - 10us interrupt for encoding
03.00 19.05.06 PK - full-duplex support
03.01 31.05.06 PK - MAX5479 I2C potentiometer supported
      02.06.06 PK - fixed bug: mask wasn't used in encoding
                  - fixed bug: stop encoding doesn't work after init in half-duplex mode
      15.06.06 PK - 5us interrupt for encoding
03.02 20.06.06 PK - STA323 and CS4806 support for Exstreamer200
                  - STA323 volume, loudnes and balance control
                  - MAX5479 volume bug fixed
03.03 23.06.06 PK - timer set back to 10us
                  - interrupt routine sends always ffff (silence) on buffer underrun
      26.07.06 KK - Added support for DES with 7-byte keys.
04.00 28.07.06 PK - new file-like audio interface
      12.08.06 PK - STA323 treble and bass control
04.01 13.08.06 PK - audio layer with file-style interface and RTP - bugs fixed and initial version created
      30.08.06 PK - fixed possible deadlock bug if close is called before delayed playback starts
      12.09.06 PK - missing STA323 on EX200 is NOT considered as an error, just the functions are disabled
      13.09.06 PK - software u-Law/A-Law for VLSI
      28.09.06 PK - initial version of ASF parser
                  - Micronas download code packed
04.02 14.11.06 PK - ST7036 display driver
      15.11.06 PK - ST7036: backlight setting
04.03 17.11.06 PK - build date information (CODEC_GET_BUILD_DATE call)
                  - fixed VLSI bug, DREQ not checked when sending commands
04.04 07.12.06 PK - asf parser accepts ASF2 and multiple streams
                  - asf parser properly handles multiple songs (new header and data)
		  - new VLSI rewind patch which properly handles infinite stream
04.05 18.01.07 PK - audio_init returns song date in the audio_init structure
                  - output mixer settings in audio_set_param structure
		  - added AUDIO_FLAG_REBUFFER to the open call, stops playback and rebuffers on buffer underrun
		  - MMS/HTTP and MMS/TCP parser and audio decoding mode - still alpha code
		  - stream number selection in MMS/ASF
04.06 27.02.07 PK - G711/RTP support - first version
                  - Barix dynamic payload types for PCM/8, PCM/24, PCM/32, ALaw/24, uLaw/24, ALaw/32, uLaw/32 added
      02.03.07 PK - flush buffer bug fixed

04.07 05.03.07 PK - INTERFACE CHANGE! (audio_init structure)
                  - RTP header extension support
      07.03.07 PK - RTP didn't play - fixed
      08.03.07 PK - fixed non working MP3 RTP decoding (crashed)
04.08 21.03.07 PK - "decoding" interrupt routine optimized and moved into RAM
04.09 29.03.07 PK - RTP extension flag corrected
                  - VLSI driver changed, low level command handshake rewritten, register access simplified
		  - faster command execution
		  - smaller delays at initialization
      03.04.07 PK - RTP extension data sending error corrected, works now
      13.04.07 PK - set output mixer call added to the old interface
      23.04.07 PK - bitrate call implemented on the micronas codec
      07.05.07 PK - Micronas I2C file upload timing error corrected
04.10 22.05.07 PK - RTP rewritten to use timestamps instead of sequence numbers
                  - better RTP balancing algorithm used
		  - RTP resync to a new sequence if buffer underruns
04.11 05.06.07 PK - new interface: G711 and PCM support for VLSI
04.12 08.06.07 PK - more relaxed I2C timing
                  - longer synchronization pattern for MAS to avoid bit desynchronization
		  - SPI speed setting depending on the encoding/mode used
		  - corrected wrong default SPI speed on LX 4MHz->1MHz
		  - EX CPU bug workaround to correct wrong SPI speed generation
		  - default SPI speed 1MHz for decoding and 4MHz for full-duplex modes
		  - SPI clock idles high on EX, clock idle low (which was used before) causes 
		    MAS bit desynchronization and incorrect playback of MPEG 2.5 files 
                  - get_bitrate call returns bitrate for PCM/G711 modes on VLSI
      25.06.07 PK - RTP full-duplex modes supported on the exstreamer
                  - RTP buffering starts at 3/4 of the requested level
      26.06.07 PK - removed error where audio_bytesfull returned wrong information in RTP mode
04.13 01.08.07 PK - DSTni-EX rev.C supported
      13.08.07 PK - SIO_SET_SPEED call added to the old interface
04.14 20.08.07 PK - added PCM stereo 44.1/48kHz decoding capability for the Micronas codec
                  - PCM stereo decoding data format changed to the big-endian by default instead of LE
                  - added AUDIO_FLAG_PCM_LE_DATA flag to switch endianity for all PCM modes

04.15 29.08.07 PK - INTERFACE CHANGE! (audio_init structure, audio_init, audio_get_status, audio_get_params)
                  - added size parameter to audio_init, audio_get_status, audio_get_params
                  - uncompressed stereo PCM encoding capability ("es44", "es48") added to the micronas codec and to audio_open,
                    but the codec firmware is too slow for that at the moment
		  - audio_init now returns direct pointers to codec fifos
      30.08.07 PK - audio_write returns EBADMSG on invalid payload type (instead of the original EINVAL)
      31.08.07 PK - fixed bug in reading ASF stream table
04.16 25.09.07 PK - VS1033 and VS1053 support added
                  - STA323 and CS4806 detection independent of the codec type
		  - vlsi: fixed "analog powerdown" when setting maximum volume in dB
		  - average bitrate calculated from 1024 values instead of 256
		  - fixed bug in 44.1/48kHz RTP decoding (lost frames calculation)
		  - added shoutcast support
		  - SPI speed selection by driver (more efficient SPI transfer)
      28.09.07 PK - added codec crash detection and recovery into the new interface; in case of a codec crash, audio is closed, the 
                    codec reinitialized and a flag for the application is set 
      03.10.07 PK - CS4806 renamed to CS8406, which is the correct name
                  - EX200 detection and initialisation (STA323W, CS8406) rewritten
		  - EX1000 support added
		  - hardware detection moved into separate object
		  - CS8406 driver rewritten to generic form (write/read register)

05.00 10.10.07 PK - device specific functions moved into a separate hardware driver (EX200, EX1000 etc.)
                  - space optimisations in VLSI driver
		  - basic EX1000 support
      12.10.07 PK - found and fixed a bug in volume control, "set volume to 0dB" after "set volume to 0%" was ignored
                  - volume control rewritten, one linear to logarithmic conversion function, one function to handle balance,
		    low level drivers (codecs and onboard chips) now work with dB volume only
                  - input selection on EX1000
      16.10.07 PK - input selection bug fixed on EX1000
                  - non-working input selection during MP3 encoding fixed
      17.10.07 PK - incorrect initialisation of EX1000 shift register fixed
                  - correct I2S Micronas output for EX1000
      18.10.07 PK - volume calibration on EX200 amplifier output
                  - extra 1ms delay after hard reset during VLSI initialisation 
		    to make sure DREQ stabilizes - VS1023 detection was not reliable
		  - fixed non-working balance control on Micronas
      19.10.07 PK - preenable and postenable functions added to hardware driver level
      24.10.07 PK - initial version of the ANN1000 driver 

05.01 06.11.07 PK - INTERFACE CHANGE! (audio_params structure, audio_set_params)
                  - size checking for audio_set_params call
05.02 14.11.07 PK - ST7036 display driver moved into bcl_io extension
      05.12.07 PK - VS1053: disabled PS and SBR in AAC+
                  - VS1053: upsampling of <24kHz streams disabled to avoid clicks in the audio
		  - VS1053: SPI speed set to 7MHz and clock multiplier to 4.5x + 0.0x
      06.12.07 PK - unused get_wav_status removed removed
                  - unused get_spdif_chan_status removed
      07.12.07 PK - unused set_fine_pitch removed
                  - unused CODEC_SETFINEPITCH removed from the legacy interface
      12.12.07 PK - external SPDIF control on LX based boards moved into the generic driver
      17.12.07 PK - unused CODEC_STREAMTYPE and set_stream_type removed
                  - unused CODEC_ENCODE_STREAMTYPE removed
		  - unused CODEC_INIT_STREAMTYPE removed
      08.01.08 PK - siospifd optimised, removed unused parts of the code
      14.01.08 PK - VLSI: fixed wrong timing of SDI 
                  - VLSI: fixed improper initialisation of XDCS during the init stage
05.03 25.01.08 PK - hardware type added to audio_init structure
                  - codec and hardware detection moved to the init function
                  - initial support of Annuncicom 200
      29.01.08 PK - added support for second microphone and AUX1 output
                  - Annuncicom 200 AIPhone support: speaker and microphone


06.00 31.01.08 PK - complete rewrite of the Micronas driver
                  - uses fast PIO program download procedure rather than I2C to load MAS firmware 
		  - format of the Micronas firmware changed to save space
		  - internal codec-driver interface simplified, audio format descriptor changed from string to binary 
		  - obsolete functions and calls removed
		  - siospifd merged with siospi
		  - new MAS3587 firmware with simplified interface, supporting 8-48kHz, any combination of stereo/mono/fdx
		  - implemented block transfer on PIO interface to MAS firmware to increase throughput
                  - merged the RAM area for all three timer interrupt routines to save memory
      01.02.08 PK - Annuncicom 100 amplifier control support
      08.02.08 PK - MAS driver bugfix: DA converter was by default off
                  - MAS: ADDA is not switched off between disable and enable
		  - MAS: buffer flush at disable to avoid end-of-song cuttoff
      11.02.08 PK - Digigram decoder driver added
      13.02.08 PK - old format translation bug: alaw instead of ulaw - fixed
      14.02.08 PK - RTP algorithm improved to keep constant delay
      15.02.08 PK - codec inactivity counter ignored when recording from SPDIF
      19.02.08 PK - MAS driver bugfix: device reset after reopening audio for encoding
      20.02.08 PK - added forgotten 22.05kHz sampling rate
      22.02.08 PK - LE/BE switching support on encoded data as well
      28.02.08 PK - VLSI driver: peak detection added
                  - bug #026.59 fixed: distorted WMA when playing DTMF tones on VS1003B
      04.03.08 PK - added call CODEC_INIT_HWTYPE
      07.03.08 PK - fixed extra zero byte bug in uncompressed audio with Micronas driver
                  - fixed SPDIF synchronisation bug in Micronas firmware
      10.03.08 PK - changed timing in Micronas PIO protocol, 575ns per byte transaction, removed extra 100ns delay
      11.03.08 PK - MAS encoder DMA bug workarounded
      12.03.08 PK - bug #019.18 fixed: Reset when switching from SPDIF coaxial to line input
      13.03.08 PK - fixed non-working 48kHz PCM on MAS35x9
      14.03.08 PK - I2C driver optimization and clean up
                  - added volume fader
      18.03.08 PK - bug #019.16 fixed: Distorted uLaw and ALaw on VLSI codecs
      19.03.08 PK - extended I2C delay in MAS driver
                  - proper locking in MAS driver 
		  - extended delay in MAS DMA bug workaround for safety
06.01 25.03.08 PK - EX200, EX1000 and ANN1000: hardware detection based only on hardware type - WILL NOT WORK IF TYPE NOT SPECIFIED!
      28.03.08 PK - 5% linear volume changed from -51dB to -57dB for better performance in fading
                  - codec buffer flush removed from audio_close and added into VLSI driver
                  - performance nice reduced from 3ms to 1ms
		  - Micronas: bitrate implemented in uncompressed modes as well
		  - I2C: increased transfer speed
		  - RTP bugfix: extra 12-14ms delay every 110ms
                  - maximum RTP frame size reduced from 1400 to 1300 bytes for better performance in ABCL
		  - VLSI: fixed the cut-off ends of song
      04.04.08 PK - fixed wrong bitrate calculation in uncompressed modes on MAS3587 and MAS35x9
      09.04.08 PK - perf_nice() called in sio_spi_send_recv_vlsi to avoid unnecessary CPU locking by slow data transfer
                  - STA323 driver functions made reentrant 
		  - fixed potential race and data inconsistency (frame read twice) in rtp_uncompressed_read_frame()
      13.04.08 PK - global lock removed
      15.04.08 PK - audio_write caches sample fragments if non-aligned data are written in PCM raw mode
      16.04.08 PK - bugfix: race condition in set_log_volume, volume not consistent between external circuits and codec
                  - bug #019.25 fixed: race condition in volume fader: set volume does not stop the fader
      17.04.08 PK - frame lost counter in RTP decoding
      18.04.08 PK - Digigram hardware type changed from the temporary type to a real value
      21.04.08 PK - temporary hardware type for Digigram put back in
      24.04.08 PK - fixed deadlock when rebuffering, bug #026.92
      29.04.08 PK - VLSI: I2S output enabled for any codec >VS1003
      08.05.08 PK - cs84x6 driver: added locking
      09.05.08 PK - input selection for EX1000
      15.05.08 PK - added VLSI Ogg Vorbis patch
                  - small optimisation in VLSI patch loading
      16.05.08 PK - VS1053: workaround to make I2S work also after soft reset
                  - MAS3587: new firmware from Micronas - fixed non-working 32kHz SPDIF input
      20.05.08 PK - Ex1000 driver: fixed improper I2S settings on the internal bus
06.02 27.05.08 PK/JR - irlib: automatic polarity detection
      29.05.08 PK - Ex1000: driver modified to support the latest hardware changes
                  - Ex1000: input selection works properly now
      18.06.08 PK - added support for unsigned 8-bit PCM
06.03 20.06.08 PK - bug #019.27 fixed: interrupt race in sio_spi_enable
      27.06.08 PK - VLSI: perf nice is not called during command send out - this was causing dropouts in uncompressed playback
06.04 08.07.08 PK - Micronas: fixed broken (clicking) 32kHz SPDIF input
                  - Ex1000: using external ADC at 32kHz
      11.07.08 PK - RTP sending directly from song
      28.08.08 PK - MAS driver: fixed crash with MP3 encoder and SPDIF input
      29.08.08 PK - Digigram PYKO IN driver
                  - PCM1807 drivers independent on the hardware
		  - input multiplexer support added
      02.09.08 PK - simplified handling of deprecated audio modes in audio_open
      05.09.08 PK - added zero_count, dupl_frames and drop_frames into audio_status structure
06.05 08.09.08 PK - added peak levels in dBFS
      11.09.08 PK - codec type and properties exported through the audio_init structure
      12.09.08 PK - added another codec data handler routine for PCM on MAS - inserts silence on buffer underrun
      18.09.08 PK - changed semantics of zero_count (audio_status) - monitored also during buffering or if playback is not active
      22.09.08 PK - added CODEC_SET_AIPHONE to the old interface
      23.09.08 PK - zero_count does not raise if data cached in the RTP buffering stage
                  - ad and mic gain boundary check in audio.c
      24.09.08 PK - current_buffer_level reflects also the RTP cache
                  - internal codec buffer correction in buffering
      26.09.08 PK - added support for the PS16 Paging Console
                  - audio peak levels scanned also if audio not open
      29.09.08 PK - fixed improper "delay" boundary check in RTP mode
                  - RTP: dropped frame counter increased also during replication
      01.10.08 PK - PYKO OUT: fixed volume control error
06.06 14.10.08 PK - VS1053 bitrate calculation bug workaround
                  - removed deprecated audio modes
		  - workaround for VS1053 bitrate counter overflow
      16.10.08 PK - new interface to audio_open
                  - RTP now accepts delay and drift parameters in uncompressed modes
      31.10.08 PK - added decoding speed adjustment - instable on Micronas!
      04.11.08 PK - fixed overrun error in RTP buffering calculation
      06.11.08 PK - improved RTP start threshold calculation
                  - VS1053: increased initial buffering
      11.11.08 PK - audio.c::set_params incorrect setting of % volume removed            
      14.11.08 PK - VS1053: adjusted internal codec buffer compensation for uncompressed mono
                  - MAS: adjusted internal codec buffer compensation for MP3
      02.12.08 PK - MAS: fixed bug #018.09: extra 128 garbage bytes when MP3 encoding starts
      03.12.08 PK - VLSI: enabled PS and SBR in AAC+
      16.12.08 PK - fixed bug #025.14: I2C bus is protected with lock against collisions
      17.12.08 PK - MAS: fixed bug #018.12: I2C race condition at uncompressed audio start
      19.12.08 PK - IR: added blocking IR_RECEIVE function
      16.01.09 PK - VS1053: compressed internal codec buffer size changed back to 2048
                  - VS1053: changed playback cancel procedure - now should be more reliable
		  - VLSI: discard data in the codec internal buffer if the audio buffer is empty, to prevent
		    audio artefacts on audio_close()
      20.01.09 PK - fixed bug #018.13: rare codec crash on VS1053 when reopening audio
      02.02.09 PK - Ann200: fixed inverted Aiphone microphone control pin
06.07 06.02.09 PK - fixed bug #018.19: Micronas: Aliasing at 32kHz PCM analog
                  - using a new download code from Micronas with different clock settings
      09.02.09 PK - AIphone interface by default off (aux1_out_ctl and mic2_ctl)
      10.02.09 PK - bug #018.19 reopen - the new download code is not reliable, though it has better audio quality
      13.02.09 PK - the "playing" status flag is reset during RTP playback if "rebuffer at underrun" flag is set and 
                    buffer underrun occurs
      16.02.09 PK - bugfix #018.18: fixed wrong initial RTP buffering on VLSI codecs in uncompressed modes: 
                  - bugfix #018.20: 44.1kHz MP3 stream generated by VLC has glitches every second
		    the MP3 RTP decoder resynchronises to encoder's timestamp if a timestamp rounding error is detected
      17.02.09 PK - linking new IR library with polarity autodetection
                  - IR input on VSC works now
06.08 18.02.09 PK - Micronas: don't flush the codec buffer if audio_close with immediate=1 is called
                    this reduces the close latency
      03.03.09 PK - removed nonsensious CODEC_INPUT_SERIALBIN: treated as line in
06.09 07.03.09 PK - added audio_rtp_dec_params() which autodetects a RTP PT and returns the proper audio_open parameters
      11.03.09 PK - fixed bug #053.02: RTP encoder: sequence number and timestamp should be initialised with a random number
                  - fixed bug #053.01: RTP encoder: audio glitches at 44.1kHz mono
06.10 12.03.09 PK - Aiphone interface simplified: mic2_ctl not used, aux1_ctl has 3 states: 0=off, 1=encoding, 2=decoding
                  - fixed bug #053.03: RTP decoder: frequent dropouts at sequence start at 48kHz PCM stereo

07.00 18.03.09 PK - IR moved from song to bcl_io
      21.04.09 PK - added CODEC_FLAG_BROKEN_ASF_PADDING into VLSI driver
                  - CODEC_GETINFO returns the codec flags in bits 16..31
		  - ASF parser: send padding CODEC_FLAG_BROKEN_ASF_PADDING is not set - to work on VS1053
		  - VLSI driver: do not use soft reset on VS1053 when switching streams (in ASF parser using old song interface) - it can crash the codec
		    using the proper cancel procedure now
07.01 28.04.09 PK - bugfix #047.07: device crash if PCM decoding and then encoding selected
07.02 17.06.09 PK - MAS driver: completely disabled clock fine tuning - causing codec crashes, noise, buzz, device reset 
		    and "codec bug resetting" message
07.03 29.06.09 PK - codec watchdog unified for all modes: triggers after 100ms of no response
      02.07.09 PK - Micronas: enable I2S output in uncompressed modes (AES output on Ex1000)
      20.07.09 PK - I2C RTC support removed to save space - not used anywhere
                  - removed save_pio and restore_pio from detection; detection is based only on the hardware type
      21.07.09 PK - removed licensing (lic.c)
                  - removed I2C EEPROM READ
      28.07.09 PK - fixed bug in avg_output_buf_level calculation; the value was not calculated every 50ms but about every millisecond
                  - variables in audio process allocated on the stack rather than in the static memory - saves data space
      04.08.09 PK - ASF parser: added support for MP3 encapsulated in ASF
                  - implemented parameter -1 in CODEC_ENABLE_STREAM: stop and flush codec's internal buffer
      05.08.09 PK - RTP: added SSRC lock; decoder ignores packets with a non-matching SSRC
      13.08.09 PK - fixed non-portable inline assembly use, which did not work with -k- option (bug #066.03)
      14.08.09 PK - RTP always restarts on buffer underrun; flag AUDIO_FLAG_REBUFFER is ignored in RTP mode
      05.11.09 KK - Song sometimes mutes during disable stream. Fixed. 53.06
07.04 28.12.09 PK - #53.08: added support for Ann155
07.05 26.02.10 PK - #053.12: added audio direction control for Annuncicom VME
---------------------------------
A7.10 15.03.10 PK - interim solution to solve the Micronas "codec bug" in analog modes
                  - Micronas firmware v38 with cleaned up audio modes
                  - uses lower DSP clock, stable analog modes without "codec bug"
                  - PCM 44.1kHz stereo full-duplex not working any more because of lack of MIPS
                  - Micronas DSP buffer reduced from 1280B to 320B => reduced latency
                  - bug #18.19 fixed: aliasing at 32kHz analog
                  - uncompressed switching SPDIF-> analog does not work
                  - CPU can be held up to 100ms when switching Micronas uncompressed modes - waiting for MAS demand signal before sending the sync pattern
                  - 32kHz SPDIF encoding losing data
*/
