mic device figured out?

i have satisfied seaman.
its just constantly polling for data.
next step: pipe in some audio!
This commit is contained in:
Bryan Barnes 2014-01-14 00:38:59 -05:00
parent 8284f55b68
commit babaf41482
1 changed files with 65 additions and 6 deletions

View File

@ -4,6 +4,7 @@
#include "maple_devs.h"
#include "maple_cfg.h"
#include <time.h>
#include <android/log.h>
#include "deps/zlib/zlib.h"
@ -18,6 +19,7 @@ const char* maple_sega_mic_name = "MicDevice for Dreameye";
const char* maple_sega_brand = "Produced By or Under License From SEGA ENTERPRISES,LTD.";
#define HAS_VMU
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "maple_devs", __VA_ARGS__)
enum MapleFunctionID
{
@ -655,10 +657,13 @@ struct maple_microphone: maple_base
{
virtual u32 dma(u32 cmd)
{
printf("maple_microphone::dma Called 0x%X;Command %d\n",this->maple_port,cmd);
//printf("maple_microphone::dma Called 0x%X;Command %d\n",this->maple_port,cmd);
//LOGD("maple_microphone::dma Called 0x%X;Command %d\n",this->maple_port,cmd);
switch (cmd)
{
case MDC_DeviceRequest:
LOGD("maple_microphone::dma MDC_DeviceRequest");
//caps
//4
w32(MFID_4_Mic);
@ -722,14 +727,68 @@ struct maple_microphone: maple_base
w8(0x80);
}
return MDRS_DataTransfer;
return MDRS_DataTransfer;
case MDC_DeviceReset:
return MDRS_DeviceReply;
//uhhh do nothing?
LOGD("maple_microphone::dma MDC_DeviceReset");
return MDRS_DeviceReply;
case MDCF_MICControl:
{
//MONEY
u32 function=r32();
LOGD("maple_microphone::dma MDCF_MICControl function (1st word) %#010x\n", function);
LOGD("maple_microphone::dma MDCF_MICControl words: %d\n", dma_count_in);
switch(function)
{
case MFID_4_Mic:
{
//MAGIC HERE
//http://dcemulation.org/phpBB/viewtopic.php?f=34&t=69600
// <3 <3 BlueCrab <3 <3
/*
2nd word What it does:
0x0000??03 Sets the amplifier gain, ?? can be from 00 to 1F
0x0f = default
0x00008002 Enables recording
0x00000001 Returns sampled data while recording is enabled
While not enabled, returns status of the mic.
0x00000002 Disables recording
*
*/
u32 subcommand=r32();
LOGD("maple_microphone::dma MDCF_MICControl subcommand (2nd word) %#010x\n", subcommand);
//u32 cmd = (number >> (8*n)) & 0xff
u32 cmd = subcommand & 0xFF;
LOGD("maple_microphone::dma MDCF_MICControl (3rd word) %#010x\n", r32());
LOGD("maple_microphone::dma MDCF_MICControl (4th word) %#010x\n", r32());
switch(cmd)
{
case 0x01:
LOGD("maple_microphone::dma MDCF_MICControl someone wants some data!");
return MDRS_DataTransfer;
break;
case 0x02:
LOGD("maple_microphone::dma MDCF_MICControl toggle recording!");
return MDRS_DeviceReply;
break;
case 0x03:
return MDRS_DeviceReply;
break;
default:
break;
}
}
default:
break;
}
}
default:
printf("maple_microphone::dma UNHANDLED MAPLE COMMAND %d\n",cmd);
LOGD("maple_microphone::dma UNHANDLED MAPLE COMMAND %d\n",cmd);
return MDRE_UnknownFunction;
}
}