vitasdk
Documentation of the vitasdk

Exports for Kernel. More...

Enumerations

enum  SceCodecOutputRoute { SCE_CODEC_OUTPUT_ROUTE_NONE = 0x0000 , SCE_CODEC_OUTPUT_ROUTE_HEADPHONE = 0x0400 , SCE_CODEC_OUTPUT_ROUTE_DOCK = 0x0500 , SCE_CODEC_OUTPUT_ROUTE_SPEAKER = 0x1100 }
 Complete output-route configurations used by SceAVConfig on FW 3.60. More...
 
enum  SceCodecAudioOutMode { SCE_CODEC_AUDIO_OUT_MODE_COMPRESSED = 0x0100 , SCE_CODEC_AUDIO_OUT_MODE_NORMAL = 0x0200 }
 External-codec audio-output profiles used by SceAudio. More...
 
enum  SceCodecAudioInputMode { SCE_CODEC_AUDIO_INPUT_MODE_INACTIVE = -1 , SCE_CODEC_AUDIO_INPUT_MODE_BUILTIN_MIC = 0 , SCE_CODEC_AUDIO_INPUT_MODE_HEADSET_MIC = 1 , SCE_CODEC_AUDIO_INPUT_MODE_UNK_2 = 2 }
 External-codec audio-input profiles used by SceAudioIn. More...
 

Functions

int ksceCodecReadRegister (SceUInt32 reg)
 Read a raw register from the external audio codec.
 
int ksceCodecWriteRegister (SceUInt32 reg, SceUInt32 value)
 Write a raw register in the external audio codec.
 
int ksceCodecGetOutputState (SceInt32 *speaker_gain_db, SceInt32 *headphone_gain_db)
 Get the current external-codec output state.
 
int ksceCodecSetOutputRoute (SceUInt32 output_mask)
 Set the external-codec output route.
 
int ksceCodecSetVolume (SceUInt32 volume_level)
 Set the external-codec playback volume.
 
int ksceCodecSetAudioInputMode (SceCodecAudioInputMode mode)
 Select the external-codec audio-input configuration used by SceAudioIn.
 
int ksceCodecSetAudioOutMode (SceCodecAudioOutMode mode)
 Select the external-codec audio-output mode used by SceAudio.
 
int ksceCodecGetMicrophoneDetectStatus (void)
 Get the headset-microphone detection state.
 
int ksceCodecSetMicrophoneDetectPower (SceBool enable)
 Enable or disable the codec circuitry used for headset-microphone detection.
 

Detailed Description

Exports for Kernel.


Using this library in your project

Include the header file in your project:


Link the library to the executable:

SceCodecForDriver_stub



On handheld FW 3.60 systems, this library controls the external WM audio codec. On Vita TV, no codec driver is installed: these functions return 0 and do not write to output pointers.

Enumeration Type Documentation

◆ SceCodecOutputRoute

Complete output-route configurations used by SceAVConfig on FW 3.60.

Each value specifies a complete output-route configuration, not an individual output flag. The WM driver independently checks mask bits 0x0100, 0x0400, and 0x1000; all other bits are ignored. Other combinations of the three bits are accepted but are not used by FW 3.60 SceAVConfig.

Enumerator
SCE_CODEC_OUTPUT_ROUTE_NONE 

Disable all local codec outputs.

SCE_CODEC_OUTPUT_ROUTE_HEADPHONE 

Route output to connected headphones.

SCE_CODEC_OUTPUT_ROUTE_DOCK 

Route output to the multiconnector audio-output dock.

SCE_CODEC_OUTPUT_ROUTE_SPEAKER 

Route output to the built-in speaker.

◆ SceCodecAudioOutMode

External-codec audio-output profiles used by SceAudio.

The FW 3.60 WM driver examines only bits 8 through 15. If that byte is neither 0x01 nor 0x02, the current profile is left unchanged.

Enumerator
SCE_CODEC_AUDIO_OUT_MODE_COMPRESSED 

Compressed SceAudio output profile.

SCE_CODEC_AUDIO_OUT_MODE_NORMAL 

Normal SceAudio output profile.

◆ SceCodecAudioInputMode

External-codec audio-input profiles used by SceAudioIn.

Enumerator
SCE_CODEC_AUDIO_INPUT_MODE_INACTIVE 

Inactive WM register profile.

SCE_CODEC_AUDIO_INPUT_MODE_BUILTIN_MIC 

Handheld built-in microphone.

SCE_CODEC_AUDIO_INPUT_MODE_HEADSET_MIC 

Wired headset microphone.

SCE_CODEC_AUDIO_INPUT_MODE_UNK_2 

WM profile with no known first-party FW 3.60 caller.

Function Documentation

◆ ksceCodecReadRegister()

int ksceCodecReadRegister ( SceUInt32  reg)

Read a raw register from the external audio codec.

The FW 3.60 WM driver sends the low 16 bits of the address as a big-endian word to I2C bus 0, device address 0x34. This function does not lock the codec mutex. Do not call it concurrently with another codec operation.

Parameters
[in]reg- Register address; only the low 16 bits are used.
Returns
The 16-bit register value on success, or a negative error code.

◆ ksceCodecWriteRegister()

int ksceCodecWriteRegister ( SceUInt32  reg,
SceUInt32  value 
)

Write a raw register in the external audio codec.

The FW 3.60 WM driver sends the address and value as big-endian 16-bit words to I2C bus 0, device address 0x34. It waits for a preceding special register write to complete and retries a failed transfer up to three times. This function does not lock the codec mutex. Do not call it concurrently with another codec operation.

Parameters
[in]reg- Register address; only the low 16 bits are used.
[in]value- Register value; only the low 16 bits are used.
Returns
0 on success, or a negative error code.

◆ ksceCodecGetOutputState()

int ksceCodecGetOutputState ( SceInt32 *  speaker_gain_db,
SceInt32 *  headphone_gain_db 
)

Get the current external-codec output state.

Parameters
[out]speaker_gain_db- Receives the cached speaker gain in dB, or -121 while the speaker route is inactive on FW 3.60. May be NULL.
[out]headphone_gain_db- Receives the cached headphone gain in dB. May be NULL.
Returns
The complete current output-route mask composed of bits 0x0100, 0x0400, and 0x1000; known route configurations are listed in SceCodecOutputRoute. Returns a negative mutex error on failure.

◆ ksceCodecSetOutputRoute()

int ksceCodecSetOutputRoute ( SceUInt32  output_mask)

Set the external-codec output route.

The new mask replaces the route configuration; it is not ORed with the current mask. The FW 3.60 WM driver independently enables or disables the paths selected by bits 0x0100, 0x0400, and 0x1000 and ignores all other bits. Known complete route configurations are listed in SceCodecOutputRoute.

Parameters
[in]output_mask- New output-route mask.
Returns
0 on success, or a nonzero error code.

◆ ksceCodecSetVolume()

int ksceCodecSetVolume ( SceUInt32  volume_level)

Set the external-codec playback volume.

Parameters
[in]volume_level- Volume level from 0 through 30. Level 0 is silence on FW 3.60.
Returns
0 on success, 0x80261000 when volume_level is greater than 30, a negative mutex or I2C error for a headphone-path failure, or 1 for a speaker-path lock or programming failure on the FW 3.60 WM driver.

◆ ksceCodecSetAudioInputMode()

int ksceCodecSetAudioInputMode ( SceCodecAudioInputMode  mode)

Select the external-codec audio-input configuration used by SceAudioIn.

FW 3.60 SceAVConfig selects the built-in-microphone profile at handheld initialization and changes to the headset-microphone profile when a wired headset microphone is selected. The WM driver also implements mode 2, but no first-party FW 3.60 caller was found that selects it. Other signed values return 0x80261000.

Parameters
[in]mode- Audio-input profile.
Returns
1 after successfully selecting mode 1, 0 after successfully selecting mode -1, 0, or 2, or a negative error code.

◆ ksceCodecSetAudioOutMode()

int ksceCodecSetAudioOutMode ( SceCodecAudioOutMode  mode)

Select the external-codec audio-output mode used by SceAudio.

If the speaker path is active, changing profiles temporarily disables that path, reconfigures the codec, and restores it. On the FW 3.60 WM driver a compressed-profile request made while the speaker path is inactive is not saved.

Parameters
[in]mode- One of SceCodecAudioOutMode.
Returns
0 on success, or a nonzero error code.

◆ ksceCodecGetMicrophoneDetectStatus()

int ksceCodecGetMicrophoneDetectStatus ( void  )

Get the headset-microphone detection state.

The FW 3.60 WM driver returns codec register 0x30 bit 7. After microphone detection power is enabled, SceHpremote interprets 0 as microphone present and every nonzero result as microphone absent.

Returns
0 or 0x80 on success, or a negative error code.

◆ ksceCodecSetMicrophoneDetectPower()

int ksceCodecSetMicrophoneDetectPower ( SceBool  enable)

Enable or disable the codec circuitry used for headset-microphone detection.

Parameters
[in]enable- A nonzero value enables detection power; zero disables it.
Returns
0 on success, or a negative error code.