vitasdk
Documentation of the vitasdk

Exports for Kernel. More...

Data Structures

struct  SceHprmInternalState
 SceHpremote module state on FW 3.60. More...
 

Typedefs

typedef void(* SceHprmConnectCallback) (SceBool headphone_detect, SceBool audio_out_dock_exists, SceBool headphone_exists, SceHprmDeviceState remote_state, SceHprmDeviceState microphone_state, void *argp)
 Direct connection callback installed by ksceHprmSetConnectCallback.
 

Enumerations

enum  SceHprmDeviceState { SCE_HPRM_DEVICE_STATE_PENDING = -1 , SCE_HPRM_DEVICE_STATE_NOT_CONNECTED = 0 , SCE_HPRM_DEVICE_STATE_CONNECTED = 1 }
 Connection state reported for devices that require asynchronous detection. More...
 
enum  SceHprmConnectedDevice { SCE_HPRM_CONNECTED_DEVICE_HEADPHONE = 0x1 , SCE_HPRM_CONNECTED_DEVICE_REMOTE = 0x2 , SCE_HPRM_CONNECTED_DEVICE_MICROPHONE = 0x4 }
 Connected-device bits delivered to callbacks registered with ksceHprmRegisterCallback. More...
 

Functions

 VITASDK_BUILD_ASSERT_EQ (0xAC, SceHprmInternalState)
 
SceBool ksceHprmGetHpDetect (void)
 Get the debounced Syscon headphone-detect signal.
 
int ksceHprmGetInternalState (SceHprmInternalState **state)
 Get the module's internal state.
 
SceBool ksceHprmIsAudioOutDockExist (void)
 Check whether an audio-output dock is connected to the multiconnector.
 
SceBool ksceHprmIsHeadphoneExist (void)
 Check whether headphones are connected.
 
SceBool ksceHprmIsMicrophoneExist (void)
 Check whether a headset microphone is connected.
 
SceBool ksceHprmIsRemoteExist (void)
 Check whether a headset remote is connected.
 
int ksceHprmRegisterCallback (SceUID callback_id)
 Register a kernel callback UID for connection-state notifications.
 
int ksceHprmReset (void)
 Request a new headset connection probe.
 
int ksceHprmSetConnectCallback (SceHprmConnectCallback callback, void *argp)
 Install the direct connection callback.
 
int ksceHprmShutdown (void)
 Suspend headset probing.
 
int ksceHprmUnregisterCallback (SceUID callback_id)
 Unregister a kernel callback UID.
 

Variables

SceUID SceHprmInternalState::event_flag_id
 Event flag used by the detection state machine.
 
SceUID SceHprmInternalState::detection_thread_id
 Headset-detection worker thread.
 
SceInt32 SceHprmInternalState::detection_state
 Detection state-machine index described above.
 
SceUID SceHprmInternalState::callback_ids [32]
 Kernel callback UIDs, or a negative value for an unused slot.
 
SceUInt8 SceHprmInternalState::hardware_flags
 Model-specific headset-detection behavior flags.
 
SceUInt8 SceHprmInternalState::headphone_detect
 Debounced Syscon headphone-detect signal, 0 or 1.
 
SceUInt8 SceHprmInternalState::syscon_microphone_connect
 Latest Syscon microphone-connect signal, 0 or 1.
 
SceUInt8 SceHprmInternalState::pending_headphone_detect
 Latest raw headphone-detect signal awaiting debounce.
 
SceUInt32 SceHprmInternalState::headphone_debounce_history
 Shift register of recent headphone-detect samples.
 
SceUInt8 SceHprmInternalState::interface_connect
 Debounced Syscon interface-connect signal, 0 or 1.
 
SceUInt8 SceHprmInternalState::pending_interface_connect
 Latest raw interface-connect signal awaiting debounce.
 
SceUInt8 SceHprmInternalState::audio_out_dock_exists
 Whether the multiconnector is in audio-output mode.
 
SceUInt8 SceHprmInternalState::reserved0
 Set to 0 during initialization and otherwise unused on FW 3.60.
 
SceUInt32 SceHprmInternalState::interface_debounce_history
 Shift register of recent interface-connect samples.
 
SceUInt8 SceHprmInternalState::reserved1 [4]
 Set to 0 during initialization and otherwise unused on FW 3.60.
 
SceUInt8 SceHprmInternalState::notification_pending
 Whether connection callbacks need to be notified.
 
SceInt8 SceHprmInternalState::headphone_exists
 Headphone connection state reported by the module, 0 or 1.
 
SceInt8 SceHprmInternalState::remote_state
 One of SceHprmDeviceState; the FW 3.60 module only sets -1 or 0.
 
SceInt8 SceHprmInternalState::microphone_state
 One of SceHprmDeviceState.
 
SceHprmConnectCallback SceHprmInternalState::connect_callback
 Direct connection callback, or NULL.
 
void * SceHprmInternalState::connect_callback_arg
 Caller-owned argument passed to the direct connection callback.
 

Detailed Description

Exports for Kernel.


Using this library in your project

Include the header file in your project:


Link the library to the executable:

SceHpremoteForDriver_stub




Data Structure Documentation

◆ SceHprmInternalState

struct SceHprmInternalState

SceHpremote module state on FW 3.60.

ksceHprmGetInternalState returns a pointer to the module's state, not a copy. The detection thread, Syscon callbacks, the vblank subinterrupt handler, and the system-event handler update this state. The pointer remains valid for the lifetime of the module and must not be freed. Your reads and writes directly access the module's state and can race with these updates.

FW 3.60 initializes all 32 callback slots and examines all 32 when sending notifications, although ksceHprmRegisterCallback and ksceHprmUnregisterCallback manage only the first 16 slots.

FW 3.60 chooses the detection-behavior flags using bits 16 through 23 of the Syscon hardware information: 3 when this value is below 0x80, 0 from 0x80 through 0x81, and 5 from 0x82 onward. Mask 0x2 enables explicit Syscon HP-remote power control, mask 0x4 selects alternate disconnect debounce and settle timing, and mask 0x1 retains an additional no-microphone detection step.

The detection state machine uses the following states on FW 3.60:

  • 0 performs the shutdown cleanup requested by ksceHprmShutdown.
  • 1 is a cleanup transition with no path into it from within the module.
  • 2 performs disconnect cleanup before waiting for another headset.
  • 3 waits in the inactive state entered after shutdown cleanup.
  • 4 waits for the Syscon headphone-connect signal.
  • 5 disables Syscon headset-remote power, when required by the hardware, before restarting a probe.
  • 6 waits before enabling, or retries enabling, Syscon headset-remote power.
  • 7 waits for the Syscon microphone-connect signal.
  • 8 enables the codec microphone-detection circuit.
  • 9 samples the codec microphone-detection result for the first time.
  • 10 performs the optional delayed retry when a microphone was not detected.
  • 11 samples the codec microphone-detection result a second time.
  • 12 is the steady state that waits for disconnect or reset events.
Data Fields
SceUID event_flag_id Event flag used by the detection state machine.
SceUID detection_thread_id Headset-detection worker thread.
SceInt32 detection_state Detection state-machine index described above.
SceUID callback_ids[32] Kernel callback UIDs, or a negative value for an unused slot.
SceUInt8 hardware_flags Model-specific headset-detection behavior flags.
SceUInt8 headphone_detect Debounced Syscon headphone-detect signal, 0 or 1.
SceUInt8 syscon_microphone_connect Latest Syscon microphone-connect signal, 0 or 1.
SceUInt8 pending_headphone_detect Latest raw headphone-detect signal awaiting debounce.
SceUInt32 headphone_debounce_history Shift register of recent headphone-detect samples.
SceUInt8 interface_connect Debounced Syscon interface-connect signal, 0 or 1.
SceUInt8 pending_interface_connect Latest raw interface-connect signal awaiting debounce.
SceUInt8 audio_out_dock_exists Whether the multiconnector is in audio-output mode.
SceUInt8 reserved0 Set to 0 during initialization and otherwise unused on FW 3.60.
SceUInt32 interface_debounce_history Shift register of recent interface-connect samples.
SceUInt8 reserved1[4] Set to 0 during initialization and otherwise unused on FW 3.60.
SceUInt8 notification_pending Whether connection callbacks need to be notified.
SceInt8 headphone_exists Headphone connection state reported by the module, 0 or 1.
SceInt8 remote_state One of SceHprmDeviceState; the FW 3.60 module only sets -1 or 0.
SceInt8 microphone_state One of SceHprmDeviceState.
SceHprmConnectCallback connect_callback Direct connection callback, or NULL.
void * connect_callback_arg Caller-owned argument passed to the direct connection callback.

Typedef Documentation

◆ SceHprmConnectCallback

typedef void(* SceHprmConnectCallback) (SceBool headphone_detect, SceBool audio_out_dock_exists, SceBool headphone_exists, SceHprmDeviceState remote_state, SceHprmDeviceState microphone_state, void *argp)

Direct connection callback installed by ksceHprmSetConnectCallback.

On FW 3.60 this callback runs synchronously from the vblank subinterrupt handler and must use only operations that are safe from interrupt context.

Parameters
[in]headphone_detect- Debounced Syscon headphone-detect signal.
[in]audio_out_dock_exists- Whether the multiconnector is in its audio-output mode.
[in]headphone_exists- Headphone connection state reported by the module.
[in]remote_state- Remote connection state.
[in]microphone_state- Headset-microphone connection state.
[in]argp- Argument supplied to ksceHprmSetConnectCallback.

Enumeration Type Documentation

◆ SceHprmDeviceState

Connection state reported for devices that require asynchronous detection.

Enumerator
SCE_HPRM_DEVICE_STATE_PENDING 

Detection is still pending.

SCE_HPRM_DEVICE_STATE_NOT_CONNECTED 

The device is not connected.

SCE_HPRM_DEVICE_STATE_CONNECTED 

The device is connected.

◆ SceHprmConnectedDevice

Connected-device bits delivered to callbacks registered with ksceHprmRegisterCallback.

Enumerator
SCE_HPRM_CONNECTED_DEVICE_HEADPHONE 
SCE_HPRM_CONNECTED_DEVICE_REMOTE 
SCE_HPRM_CONNECTED_DEVICE_MICROPHONE 

Function Documentation

◆ VITASDK_BUILD_ASSERT_EQ()

VITASDK_BUILD_ASSERT_EQ ( 0xAC  ,
SceHprmInternalState   
)

◆ ksceHprmGetHpDetect()

SceBool ksceHprmGetHpDetect ( void  )

Get the debounced Syscon headphone-detect signal.

Returns
SCE_TRUE when the signal is asserted, otherwise SCE_FALSE.

◆ ksceHprmGetInternalState()

int ksceHprmGetInternalState ( SceHprmInternalState **  state)

Get the module's internal state.

The output pointer refers directly to the module's state, not a copy. It remains valid for the lifetime of the module and must not be freed. This function does not synchronize access with updates by the module.

Parameters
[out]state- Optional pointer that receives the module's internal state address.
Returns
The current FW 3.60 detection-state-machine index, from 0 through 12.

◆ ksceHprmIsAudioOutDockExist()

SceBool ksceHprmIsAudioOutDockExist ( void  )

Check whether an audio-output dock is connected to the multiconnector.

On FW 3.60 this is true when bits 8 through 15 of the Syscon multiconnector information equal 0x03.

Returns
SCE_TRUE when an audio-output dock is connected, otherwise SCE_FALSE.

◆ ksceHprmIsHeadphoneExist()

SceBool ksceHprmIsHeadphoneExist ( void  )

Check whether headphones are connected.

Returns
SCE_TRUE when headphones are connected, otherwise SCE_FALSE.

◆ ksceHprmIsMicrophoneExist()

SceBool ksceHprmIsMicrophoneExist ( void  )

Check whether a headset microphone is connected.

On FW 3.60, this returns SCE_FALSE while detection is pending.

Returns
SCE_TRUE when a headset microphone is connected, otherwise SCE_FALSE.

◆ ksceHprmIsRemoteExist()

SceBool ksceHprmIsRemoteExist ( void  )

Check whether a headset remote is connected.

On FW 3.60, this returns SCE_FALSE while detection is pending. The module never sets the remote state to SCE_HPRM_DEVICE_STATE_CONNECTED, so this function returns SCE_FALSE unless the internal state is modified externally.

Returns
SCE_TRUE when a headset remote is connected, otherwise SCE_FALSE.

◆ ksceHprmRegisterCallback()

int ksceHprmRegisterCallback ( SceUID  callback_id)

Register a kernel callback UID for connection-state notifications.

The callback's notification argument is the current connected-device mask, formed by bitwise OR of SceHprmConnectedDevice values. On FW 3.60, there are 16 registration slots. The function does not validate the UID or reject duplicate registrations. The caller owns the callback object and must unregister it before deleting it.

The vblank subinterrupt handler calls ksceKernelNotifyCallback; execution of the registered callback follows the kernel callback object's normal scheduling rules and does not occur synchronously in the subinterrupt.

Parameters
[in]callback_id- Kernel callback UID.
Returns
0 on success, or -1 when every registration slot is occupied.

◆ ksceHprmReset()

int ksceHprmReset ( void  )

Request a new headset connection probe.

This function posts an asynchronous reset event. It also resumes probing after ksceHprmShutdown.

Returns
0.

◆ ksceHprmSetConnectCallback()

int ksceHprmSetConnectCallback ( SceHprmConnectCallback  callback,
void *  argp 
)

Install the direct connection callback.

The module supports one direct callback. Installing another callback replaces the previous callback and argument. Pass NULL as callback to disable it. The module stores both pointers; it does not copy the argument data. Installing them does not send an immediate notification.

Parameters
[in]callback- Callback, or NULL.
[in]argp- Caller-supplied argument passed to callback.
Returns
0.

◆ ksceHprmShutdown()

int ksceHprmShutdown ( void  )

Suspend headset probing.

This function posts an asynchronous shutdown event. The detection thread disables codec microphone detection and, on hardware that requires it, Syscon headset-remote power. The thread then remains alive in an inactive wait state. ksceHprmReset resumes probing.

Returns
0.

◆ ksceHprmUnregisterCallback()

int ksceHprmUnregisterCallback ( SceUID  callback_id)

Unregister a kernel callback UID.

If the same UID was registered more than once, this function removes only the first matching registration.

Parameters
[in]callback_id- Kernel callback UID previously passed to ksceHprmRegisterCallback.
Returns
0 on success, or -1 when callback_id is not registered.

Variable Documentation

◆ event_flag_id

SceUID SceHprmInternalState::event_flag_id

Event flag used by the detection state machine.

◆ detection_thread_id

SceUID SceHprmInternalState::detection_thread_id

Headset-detection worker thread.

◆ detection_state

SceInt32 SceHprmInternalState::detection_state

Detection state-machine index described above.

◆ callback_ids

SceUID SceHprmInternalState::callback_ids[32]

Kernel callback UIDs, or a negative value for an unused slot.

◆ hardware_flags

SceUInt8 SceHprmInternalState::hardware_flags

Model-specific headset-detection behavior flags.

◆ headphone_detect

SceUInt8 SceHprmInternalState::headphone_detect

Debounced Syscon headphone-detect signal, 0 or 1.

◆ syscon_microphone_connect

SceUInt8 SceHprmInternalState::syscon_microphone_connect

Latest Syscon microphone-connect signal, 0 or 1.

◆ pending_headphone_detect

SceUInt8 SceHprmInternalState::pending_headphone_detect

Latest raw headphone-detect signal awaiting debounce.

◆ headphone_debounce_history

SceUInt32 SceHprmInternalState::headphone_debounce_history

Shift register of recent headphone-detect samples.

◆ interface_connect

SceUInt8 SceHprmInternalState::interface_connect

Debounced Syscon interface-connect signal, 0 or 1.

◆ pending_interface_connect

SceUInt8 SceHprmInternalState::pending_interface_connect

Latest raw interface-connect signal awaiting debounce.

◆ audio_out_dock_exists

SceUInt8 SceHprmInternalState::audio_out_dock_exists

Whether the multiconnector is in audio-output mode.

◆ reserved0

SceUInt8 SceHprmInternalState::reserved0

Set to 0 during initialization and otherwise unused on FW 3.60.

◆ interface_debounce_history

SceUInt32 SceHprmInternalState::interface_debounce_history

Shift register of recent interface-connect samples.

◆ reserved1

SceUInt8 SceHprmInternalState::reserved1[4]

Set to 0 during initialization and otherwise unused on FW 3.60.

◆ notification_pending

SceUInt8 SceHprmInternalState::notification_pending

Whether connection callbacks need to be notified.

◆ headphone_exists

SceInt8 SceHprmInternalState::headphone_exists

Headphone connection state reported by the module, 0 or 1.

◆ remote_state

SceInt8 SceHprmInternalState::remote_state

One of SceHprmDeviceState; the FW 3.60 module only sets -1 or 0.

◆ microphone_state

SceInt8 SceHprmInternalState::microphone_state

◆ connect_callback

SceHprmConnectCallback SceHprmInternalState::connect_callback

Direct connection callback, or NULL.

◆ connect_callback_arg

void* SceHprmInternalState::connect_callback_arg

Caller-owned argument passed to the direct connection callback.