commit
730899bee6
@ -9,8 +9,9 @@
|
|||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
IPC_BUFFER_R = 0x2,
|
IPC_BUFFER_R = BIT(1),
|
||||||
IPC_BUFFER_W = 0x4,
|
IPC_BUFFER_W = BIT(2),
|
||||||
|
IPC_BUFFER_RW = IPC_BUFFER_R | IPC_BUFFER_W
|
||||||
} IPC_BufferRights;
|
} IPC_BufferRights;
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ typedef enum {
|
|||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
DSP_PIPE_INPUT = 0, ///< DSP to ARM
|
DSP_PIPE_INPUT = 0, ///< DSP to ARM
|
||||||
DSP_PIPE_OUTPUT = 1 ///< ARM to DSP
|
DSP_PIPE_OUTPUT = 1 ///< ARM to DSP
|
||||||
} DSP_PipeDirection;
|
} DSP_PipeDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,17 +90,18 @@ Result DSP_RegisterInterruptEvents(Handle handle,u32 interrupt,u32 channel);
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param channel ?????? TODO usually 2
|
* @param channel unknown. Usually 2
|
||||||
* @param buffer The buffer that will store the values read from the pipe
|
* @param peer unknown. Usually 0
|
||||||
* @param length Length of the buffer
|
* @param buffer The buffer that will store the values read from the pipe
|
||||||
|
* @param length Length of the buffer
|
||||||
* @param length_read Number of bytes read by the command
|
* @param length_read Number of bytes read by the command
|
||||||
*/
|
*/
|
||||||
Result DSP_ReadPipeIfPossible(u32 channel, u8 const *buffer, u16 length, u16* length_read);
|
Result DSP_ReadPipeIfPossible(u32 channel,u32 peer, u8 const *buffer, u16 length, u16* length_read);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param channel ?????? TODO usually 2
|
* @param channel unknown. Usually 2
|
||||||
* @param buffer The message to send to the DSP process
|
* @param buffer The message to send to the DSP process
|
||||||
* @param length Length of the message
|
* @param length Length of the message
|
||||||
*/
|
*/
|
||||||
Result DSP_WriteProcessPipe(u32 channel,u8 const* buffer,u32 length);
|
Result DSP_WriteProcessPipe(u32 channel,u8 const* buffer,u32 length);
|
||||||
|
|
||||||
|
@ -4,19 +4,17 @@
|
|||||||
#include <3ds/ipc.h>
|
#include <3ds/ipc.h>
|
||||||
#include <3ds/services/dsp.h>
|
#include <3ds/services/dsp.h>
|
||||||
|
|
||||||
Handle dspHandle = 0;
|
static Handle dspHandle = 0;
|
||||||
|
|
||||||
|
|
||||||
Result dspInit(void)
|
Result dspInit(void)
|
||||||
{
|
{
|
||||||
Result ret = 0;
|
Result ret = 0;
|
||||||
|
|
||||||
if (dspHandle == 0)
|
if (dspHandle == 0)
|
||||||
{
|
{
|
||||||
ret = srvGetServiceHandle(&dspHandle, "dsp::DSP");
|
ret = srvGetServiceHandle(&dspHandle, "dsp::DSP");
|
||||||
if (ret < 0) return ret;
|
if (ret < 0) return ret;
|
||||||
}
|
}
|
||||||
if (ret < 0) return ret;
|
|
||||||
DSP_UnloadComponent();
|
DSP_UnloadComponent();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -40,7 +38,7 @@ Result DSP_GetHeadphoneStatus(bool* is_inserted)
|
|||||||
{
|
{
|
||||||
Result ret = 0;
|
Result ret = 0;
|
||||||
u32* cmdbuf = getThreadCommandBuffer();
|
u32* cmdbuf = getThreadCommandBuffer();
|
||||||
cmdbuf[0] = IPC_MakeHeader(0x001F,0,0);
|
cmdbuf[0] = IPC_MakeHeader(0x1F,0,0);
|
||||||
if ((ret = svcSendSyncRequest(dspHandle)) != 0) return ret;
|
if ((ret = svcSendSyncRequest(dspHandle)) != 0) return ret;
|
||||||
*is_inserted = cmdbuf[2] & 0xFF;
|
*is_inserted = cmdbuf[2] & 0xFF;
|
||||||
return cmdbuf[1];
|
return cmdbuf[1];
|
||||||
@ -148,44 +146,37 @@ Result DSP_RegisterInterruptEvents(Handle handle, u32 interrupt, u32 channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Result DSP_ReadPipeIfPossibleEx(u32 channel,u32 unk1, u8 const *buffer, u16 length, u16* length_read)
|
Result DSP_ReadPipeIfPossible(u32 channel,u32 peer, u8 const *buffer, u16 length, u16* length_read)
|
||||||
{
|
{
|
||||||
Result ret = 0;
|
Result ret = 0;
|
||||||
u32* cmdbuf = getThreadCommandBuffer();
|
u32* cmdbuf = getThreadCommandBuffer();
|
||||||
cmdbuf[0] = IPC_MakeHeader(0x10,3,0);
|
cmdbuf[0] = IPC_MakeHeader(0x10,3,0);
|
||||||
cmdbuf[1] = channel;
|
cmdbuf[1] = channel;
|
||||||
cmdbuf[2] = unk1;
|
cmdbuf[2] = peer;
|
||||||
cmdbuf[3] = length;
|
cmdbuf[3] = length;
|
||||||
|
|
||||||
u32 * staticbufs = cmdbuf + 0x100;
|
u32 * staticbufs = getThreadStaticBuffers();
|
||||||
|
|
||||||
u32 saved1 = staticbufs[0x0];
|
u32 saved1 = staticbufs[0];
|
||||||
u32 saved2 = staticbufs[0x4];
|
u32 saved2 = staticbufs[1];
|
||||||
|
|
||||||
staticbufs[0] = (length<<14) | 2;
|
staticbufs[0] = IPC_Desc_StaticBuffer(length,0);
|
||||||
staticbufs[4] = (u32)buffer;
|
staticbufs[1] = (u32)buffer;
|
||||||
|
|
||||||
if ((ret = svcSendSyncRequest(dspHandle)) != 0) return ret;
|
if ((ret = svcSendSyncRequest(dspHandle)) != 0) return ret;
|
||||||
|
|
||||||
staticbufs[0] = saved1;
|
staticbufs[0] = saved1;
|
||||||
staticbufs[4] = saved2;
|
staticbufs[1] = saved2;
|
||||||
|
|
||||||
*length_read = cmdbuf[2] & 0xFFFF;
|
*length_read = cmdbuf[2] & 0xFFFF;
|
||||||
return cmdbuf[1];
|
return cmdbuf[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO change DSP_ReadPipeIfPossibleEx into DSP_ReadPipeIfPossible once unk1 is figured out
|
|
||||||
//However it seems that it is always used with value 0
|
|
||||||
Result DSP_ReadPipeIfPossible(u32 channel, u8 const *buffer, u16 length, u16* length_read)
|
|
||||||
{
|
|
||||||
return DSP_ReadPipeIfPossibleEx(channel,0,buffer,length, length_read);
|
|
||||||
}
|
|
||||||
|
|
||||||
Result DSP_WriteProcessPipe(u32 channel, u8 const *buffer, u32 length)
|
Result DSP_WriteProcessPipe(u32 channel, u8 const *buffer, u32 length)
|
||||||
{
|
{
|
||||||
Result ret = 0;
|
Result ret = 0;
|
||||||
u32* cmdbuf = getThreadCommandBuffer();
|
u32* cmdbuf = getThreadCommandBuffer();
|
||||||
cmdbuf[0] = IPC_MakeHeader(0xd,2,2);
|
cmdbuf[0] = IPC_MakeHeader(0xD,2,2);
|
||||||
cmdbuf[1] = channel;
|
cmdbuf[1] = channel;
|
||||||
cmdbuf[2] = length;
|
cmdbuf[2] = length;
|
||||||
cmdbuf[3] = IPC_Desc_StaticBuffer(length,1);
|
cmdbuf[3] = IPC_Desc_StaticBuffer(length,1);
|
||||||
@ -198,7 +189,7 @@ Result DSP_ConvertProcessAddressFromDspDram(u32 dsp_address, u32 *arm_address)
|
|||||||
{
|
{
|
||||||
Result ret = 0;
|
Result ret = 0;
|
||||||
u32* cmdbuf = getThreadCommandBuffer();
|
u32* cmdbuf = getThreadCommandBuffer();
|
||||||
cmdbuf[0] = IPC_MakeHeader(0xc,1,0);
|
cmdbuf[0] = IPC_MakeHeader(0xC,1,0);
|
||||||
cmdbuf[1] = dsp_address;
|
cmdbuf[1] = dsp_address;
|
||||||
if ((ret = svcSendSyncRequest(dspHandle)) != 0) return ret;
|
if ((ret = svcSendSyncRequest(dspHandle)) != 0) return ret;
|
||||||
*arm_address = cmdbuf[2];
|
*arm_address = cmdbuf[2];
|
||||||
|
Loading…
Reference in New Issue
Block a user