Commit c1302501 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Change audio device to API v2.0

For stereo reversal.
Comment corrections and extensions.
Added range check to gain controls.
Submission from Willi Theiss, built but not tested here.

Version 0.26. Tagged as 'OMAP4-0_26'
parent eb46a3ca
/* (0.25)
/* (0.26)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.25
#define Module_MajorVersion_CMHG 0.26
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 12 Nov 2013
#define Module_Date_CMHG 16 Nov 2013
#define Module_MajorVersion "0.25"
#define Module_Version 25
#define Module_MajorVersion "0.26"
#define Module_Version 26
#define Module_MinorVersion ""
#define Module_Date "12 Nov 2013"
#define Module_Date "16 Nov 2013"
#define Module_ApplicationDate "12-Nov-13"
#define Module_ApplicationDate "16-Nov-13"
#define Module_ComponentName "OMAP4"
#define Module_ComponentPath "castle/RiscOS/Sources/HAL/OMAP4"
#define Module_FullVersion "0.25"
#define Module_HelpVersion "0.25 (12 Nov 2013)"
#define Module_LibraryVersionInfo "0:25"
#define Module_FullVersion "0.26"
#define Module_HelpVersion "0.26 (16 Nov 2013)"
#define Module_LibraryVersionInfo "0:26"
......@@ -321,7 +321,7 @@ AUDIO_IRQ * OMAP44XX_IRQ_MCPDM
; Audio device
^ 0, a1
; Public bits
AudioDevice # HALDevice_Audio_Size_1
AudioDevice # HALDevice_Audio_Size_2 ; API 2.0
; Private bits
AudioRegs # 4 ; L4_McPDM_Log
AudioWorkspace # 4 ; HAL workspace pointer
......@@ -345,7 +345,7 @@ MixerChannels * :INDEX: @
^ 0, a1
; Public bits
MixerDevice # HALDevice_Mixer_Size + 4 ; +4 for API 0.1
MixerDevice # HALDevice_Mixer_Size_0_1 ; API 0.1
; Private bits
MixerSettings # 8 * MixerChannels
MixerHeadsetGain # 2 ; Cached HSGAIN value
......
......@@ -151,9 +151,22 @@
; Stereo FM/aux input LINE_IN
; For the pandaboard, the TWL6040 is connected to the OMAP4 via I2C1 & McPDM
; The audio out header is connected to the headset L/R channels on the TWL
; The audio in header is connected to the aux L/R channels on the TWL
; For all pandaboards the TWL6040 is connected to the OMAP4 via I2C1 & McPDM.
;
; The OMAP4430 Pandaboard provides a stacked audio connector, which provides two 3.5 mm audio
; jack connections. The upper jack on this stacked connector (J16A) is connected to the
; Headset Microphone Plus and Minus inputs of the TWL6040 Audio Companion IC. The lower jack on
; this stacked connector (J16B) is connected to the Headset Left and Right outputs of the
; TWL6040 Audio Companion IC. For expansion purposes the left and right Hands-Free speaker
; outputs of the TWL6040 are connected to the Expansion Connector J6 [Pin 13,14,15,16].
;
; The OMAP4460 Pandaboard ES provides a stacked audio connector, which provides two 3.5 mm audio
; jack connections. The upper jack on this stacked connector (J16A) is connected to the
; FM Audio Left and Right inputs of the TWL6040 Audio Companion IC (AFML/AFMR). The lower jack
; on this stacked connector (J16B) is connected to the Headset Left and Right outputs of the
; TWL6040 Audio Companion IC. For expansion purposes the left Hands-Free speaker
; outputs of the TWL6040 are connected to the Expansion Connector J6 [Pin 13,15].
;
; Flag to enable gobs of debug output
......@@ -328,8 +341,13 @@ Audio_Init
ORR a2, a3, a2
STR a2, [v3, #MCPDM_DN_OFFSET]
; configure downlink threshold
; MOV a2, #1 ; this does work with OMAP4430 bot not OMAP4460
MOV a2, #(8 - 2)
[ {TRUE}
MOV a2, #(8 - 1)
; MOV a2, #(8 - 2)
|
; MOV a2, #1 ; this does work with OMAP4430 but not OMAP4460
MOV a2, #3
]
STR a2, [v3, #MCPDM_FIFO_CTRL_DN]
30
......@@ -388,7 +406,7 @@ AudioTemplate
DCW HALDeviceType_Audio + HALDeviceAudio_AudC
DCW HALDeviceID_AudC_TWL6040
DCD HALDeviceBus_Ser + HALDeviceSerBus_IIC
DCD 1:SHL:16 ; API version
DCD 2:SHL:16 ; API version 2.0
DCD AudioDesc
DCD 0 ; Address - N/A
% 12 ; Reserved
......@@ -404,7 +422,7 @@ AudioTemplate
DCD 0 ; Input channels (supported so far)
ASSERT (.-AudioTemplate) = HALDevice_Audio_Size
; DMA channel parameters
DCD 0 ; flags
DCD 0 ; flags
DCD AUDIO_DMA_CHAN + 1 ; logical channel
DCD 0 ; 'cycle speed'
DCD 2 ; transfer unit size: 16 bit (2 byte)
......@@ -419,7 +437,12 @@ AudioTemplate
DCD numrate ; Number of sample rates
DCD ratetab ; Sample rate table
DCD AudioSetRate ; SetRate function
ASSERT (. - AudioTemplate) = HALDevice_Audio_Size_1
; extra fields for API 2.0
DCD 0 ; AudioCustomDMAEnable
DCD HALDevice_AudioFlag_StereoReverse ; map R-L to L-R
DCD 0 ; AudioMinBuffSize
DCD 0 ; AudioBuffAlign
ASSERT (. - AudioTemplate) = HALDevice_Audio_Size_2
DCD 0 ; AudioRegs: filled in during init
DCD 0 ; AudioWorkspace: filled in during init
DCB 0 ; AudioMode
......@@ -917,11 +940,7 @@ SetMixTab
DCD SetMixMainMic
SetMixHeadsetOut ; HS_* regs
; If the codec is on, go through to UpdateHeadset
; Else do nothing
; TST v4, #TWL6040_LPLLENA
; MOVNE a1, v5
; BLNE UpdateHeadset
; Go through to UpdateHeadset
MOV a3, v4
MOV a1, v5
BL UpdateHeadset
......@@ -932,6 +951,11 @@ SetMixEarphone ; TWL6040 has no predriver regs ==> use earphone instead
TST v2, #MixerMixFlag_Mute
MOVNE v4, #0 ; disable everything
BNE %FT10
; limit gain to allowed range
CMP v3, #-24*16
LDRLT v3, =(-24*16)
CMP v3, #6*16
MOVGT v3, #6*16
; calculate gain value
MOV lr, v3, ASR #(4+1) ; div by step width (2 dB)
RSB v4, lr, #3 ; negate at zero point
......@@ -955,43 +979,16 @@ SetMixEarphone ; TWL6040 has no predriver regs ==> use earphone instead
EXIT
SetMixHandsFree ; HF* regs
; If the codec is on, go through to UpdateHandsFree
; Else do nothing
TST v4, #TWL6040_LPLLENA
MOVNE a1, v5
BLNE UpdateHandsFree
; Go through to UpdateHandsFree
MOV a1, v5
BL UpdateHandsFree
EXIT
SetMixAuxOutput ; PRECK* regs
[ {FALSE}
; adapt for TWL6040 !?
SetMixAuxOutput
; Aux Output path has no separate control registers in TWL6040
; it is internally connected to handsfree path
MOV a3, #2
MOV a4, #PRECKL_CTL
MOV v4, #&64 ; 0dB gain, AL2
CMP v3, #6*16
MOVGE v4, #&54 ; 6dB gain, AL2
CMP v3, #-6*16
MOVLE v4, #&74 ; -6dB gain, AL2
TST v2, #MixerMixFlag_Mute
ORREQ v4, v4, v4, LSL #8 ; R channel settings
MOVNE v4, #0 ; Else disable everything
ADD a2, v5, #:INDEX:MixerCarkitOutGain
LDRH ip, [a2]
CMP ip, v4
EXIT EQ
STRH v4, [a2]
BL TPSWrite
[ AudioDebug
CMP a1, #0
EXIT EQ
DebugTX "SetMixAuxOutput: TPS write failed!"
]
]
EXIT
B SetMixHandsFree
SetMixSystem
; there is no such thing for output in TWL6040
......@@ -1003,6 +1000,11 @@ SetMixSystem
TST v2, #MixerMixFlag_Mute
MOVNE v4, #0 ; disable everything
BNE %FT10
; limit gain to allowed range
CMP v3, #-18*16
LDRLT v3, =(-18*16)
CMP v3, #24*16
MOVGT v3, #24*16
STR v3, [v7] ; remember used gain value
; calculate scaled gain value
CMP v3, #0
......@@ -1059,6 +1061,11 @@ UpdateHeadset
MOV ip, #0
B %FT05
02
; limit gain to allowed range
CMP v1, #-30*16
LDRLT v1, =(-30*16)
CMP v1, #0
MOVGT v1, #0
; Calculate HSGAIN: 0x0 == 0 dB, 0x1 == -2 dB, ... 0xF == -30dB
MOV a2, v1, ASR #(4+1) ; div by step width (2 dB)
RSB ip, a2, #0 ; negate
......@@ -1154,6 +1161,12 @@ UpdateHandsFree
; gain is in HFLGAIN and HFRGAIN each with the following values:
; 0x00 == 6 dB, 0x01 == 4 dB, 0x02 == 2 dB, 0x03 == 0 dB, 0x04 == -2 dB,
; ... 0x1C == -50 dB, 0x1D == -52 dB (0x1E and 0x1F not valid)
; limit gain to allowed range
CMP v1, #-52*16
LDRLT v1, =(-52*16)
CMP v1, #6*16
MOVGT v1, #6*16
; calculate gain value
MOV a3, v1, ASR #(4+1) ; div by step width (2 dB)
RSB ip, a3, #3 ; negate at zero point
; Copy enable sequence to stack so we can modify it with the correct gain
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment