add c1 evb init script && add c1_evb workmode to netease voice
This commit is contained in:
parent
0bb64ed8e2
commit
3e2d8c6e03
|
@ -47,9 +47,6 @@ enable_soundcard() {
|
|||
amixer cset iface=MIXER,name='DACR Mixer AIF1DA0R Switch' 1
|
||||
amixer cset iface=MIXER,name='DACL Mixer AIF1DA0L Switch' 1
|
||||
amixer cset iface=MIXER,name='Headphone Switch' 1
|
||||
echo 4 > /sys/netease/cpld_control/cpld_init
|
||||
adau1761 2 0
|
||||
adau1761 0 8
|
||||
}
|
||||
|
||||
start_voice() {
|
||||
|
|
|
@ -47,10 +47,10 @@ start_voice() {
|
|||
echo $DBUS_SESSION_BUS_ADDRESS >> $LOG
|
||||
procd_open_instance
|
||||
procd_set_param oom_adj $OOM_ADJ
|
||||
procd_set_param command $PROG_VOICE --work-mode=1
|
||||
procd_set_param command $PROG_VOICE --work-mode=2
|
||||
procd_set_param respawn
|
||||
procd_append_param limits core=unlimited
|
||||
procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS --work-mode=0
|
||||
procd_set_param env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS --work-mode=2
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,15 @@ type PlatformConfig struct {
|
|||
MicAdc bool
|
||||
LedMcuInit bool
|
||||
InputKeyPath string
|
||||
FakeVersion bool
|
||||
}
|
||||
var (
|
||||
platformConfigs = map[string]PlatformConfig{
|
||||
"default": PlatformConfig{MicAdc:false, LedMcuInit:true,IconSwitch:true, TopLight:true, InputKeyPath:"/dev/input/event2"},
|
||||
"EVT":PlatformConfig{MicAdc:true,LedMcuInit:true,IconSwitch:true, TopLight:true, InputKeyPath:"/dev/input/event2"},
|
||||
"r311-pv1":PlatformConfig{MicAdc:false, LedMcuInit:true, IconSwitch:true, TopLight:true, InputKeyPath:"/dev/input/event1"},
|
||||
"r311-pv1c":PlatformConfig{MicAdc:true, LedMcuInit:false, IconSwitch:false, TopLight:false, InputKeyPath:"/dev/input/event1"},
|
||||
"r311-pv1c":PlatformConfig{MicAdc:true, LedMcuInit:false, IconSwitch:false, TopLight:false, FakeVersion:true, InputKeyPath:"/dev/input/event1"},
|
||||
"r311-c1-evb":PlatformConfig{MicAdc:false, LedMcuInit:false, IconSwitch:false, TopLight:false, FakeVersion:true, InputKeyPath:"/dev/input/event1"},
|
||||
}
|
||||
curPlatformConfig *PlatformConfig
|
||||
)
|
||||
|
|
|
@ -34,7 +34,7 @@ func main() {
|
|||
ActualHv = Hv
|
||||
globals.ActualHv = &ActualHv
|
||||
|
||||
if Hv == "r311-pv1c" {
|
||||
if globals.GetCurPlatformConfig().FakeVersion {
|
||||
Hv = "EVT"
|
||||
globals.GitTag = new(string)
|
||||
*globals.GitTag = "1.1.19"
|
||||
|
|
|
@ -61,6 +61,7 @@ typedef enum {
|
|||
typedef enum {
|
||||
WorkMode_R311_PV1 = 0,
|
||||
WorkMode_R311_PV1_CES = 1,
|
||||
WorkMode_R311_C1_EVB = 2,
|
||||
} WorkMode;
|
||||
|
||||
void setVss(VoiceSessionStatus st);
|
||||
|
|
|
@ -568,7 +568,7 @@ static void usage() {
|
|||
"-l, --list-devices list all soundcards and digital audio "
|
||||
"devices\n"
|
||||
"-L, --list-pcms list device names\n"
|
||||
"-w, --work-mode=# work mode: 0: r311_pv1(dmic) 1:r311_pv1_ces(nmic)\n"
|
||||
"-w, --work-mode=# work mode: 0: r311_pv1(dmic) 1:r311_pv1_ces(nmic) 2: r311_c1evb\n"
|
||||
"-f, --list-format list all format in alsa\n"
|
||||
"-r, --just-record Only record voice to file\n"
|
||||
"-t, --type=# sample format (case insensitive): raw,wav\n"
|
||||
|
|
|
@ -122,7 +122,7 @@ static void *QueueReadThread(void *param) {
|
|||
if (record->buff_size != readLen) {
|
||||
// printf("\nqueue_read readLen %d\n", readLen);
|
||||
}
|
||||
//printf("\nqueue_read readLen %d\n", readLen);
|
||||
// printf("\nqueue_read readLen %d\n", readLen);
|
||||
|
||||
if (record->cb)
|
||||
record->cb(data_buff, readLen, NETEASE_SUCCESS, record->queue);
|
||||
|
@ -427,6 +427,9 @@ static void *RecordThread(void *param) {
|
|||
int ret = 0;
|
||||
int i = 0;
|
||||
long long max_file_size = 2147483648LL;
|
||||
char *tmpbuf = NULL;
|
||||
int tmpbufsize = 0;
|
||||
char *p = NULL;
|
||||
|
||||
// cpu_set_t mask;
|
||||
n_toast("RecordThread record:%p, running:%d\n", record, record->runing);
|
||||
|
@ -436,6 +439,22 @@ static void *RecordThread(void *param) {
|
|||
// CPU_SET(0,&mask);
|
||||
// ret = sched_setaffinity(0, sizeof(mask), &mask);
|
||||
// printf("sched_setaffinity return = %d\n", ret);
|
||||
|
||||
//prepare
|
||||
switch (getWorkMode()) {
|
||||
case WorkMode_R311_C1_EVB:
|
||||
#define ADC_CH_NUM 6
|
||||
#define VIRTUAL_CH 2
|
||||
#define BIT_PER_CH 16
|
||||
tmpbufsize = record->chunk_size * (ADC_CH_NUM + VIRTUAL_CH) * BIT_PER_CH/8;
|
||||
tmpbuf = (char *)calloc(1, tmpbufsize);
|
||||
if (!tmpbuf) {
|
||||
n_error("Can not malloc space for tmpbuf,exit!\n");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (record->backupfilefd > 0 &&
|
||||
record->pcm_cfg->backupfile_waveformat > 0) {
|
||||
begin_wave(record, record->backupfilefd, (size_t)max_file_size);
|
||||
|
@ -447,6 +466,64 @@ static void *RecordThread(void *param) {
|
|||
n_toast("Running:%d, work mode:%d\n", record->runing, getWorkMode());
|
||||
while (!!record->runing) {
|
||||
switch (getWorkMode()) {
|
||||
case WorkMode_R311_C1_EVB:
|
||||
if (pcm_read(record->pcm_cfg->adc) ==
|
||||
record->pcm_cfg->adc->chunk_size) {
|
||||
if (pcm_read(record) == record->chunk_size) {
|
||||
short *mic = (short *)record->buffer;
|
||||
short *resample = (short *)record->pcm_cfg->adc->buffer;
|
||||
short *p = (short *)tmpbuf;
|
||||
for (i = 0; i < record->chunk_size; i++) {
|
||||
//mic
|
||||
// mic no, actual sofware no
|
||||
p[1 - 1] = mic[2 -1];
|
||||
p[2 - 1] = mic[4 - 1];
|
||||
p[3 - 1] = mic[3 - 1];
|
||||
p[4 - 1] = mic[1 - 1];
|
||||
|
||||
#if VIRTUAL_CH > 0
|
||||
//fack two ch data
|
||||
p[5 - 1] = mic[1 - 1];
|
||||
p[6 - 1] = mic[1 - 1];
|
||||
|
||||
//resample
|
||||
p[7 - 1] = resample[0];
|
||||
p[8 - 1] = resample[1];
|
||||
|
||||
resample += 2;
|
||||
p += 8;
|
||||
mic += 4;
|
||||
#else
|
||||
//resample
|
||||
p[5 - 1] = resample[0];
|
||||
p[6 - 1] = resample[1];
|
||||
|
||||
resample += 2;
|
||||
p += 6;
|
||||
mic += 4;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (record->backupfilefd > 0) {
|
||||
xwrite(record->backupfilefd, tmpbuf,
|
||||
tmpbufsize);
|
||||
fdcount += tmpbufsize;
|
||||
}
|
||||
queue_write(record->queue, tmpbuf,
|
||||
tmpbufsize);
|
||||
memset(tmpbuf, 0, tmpbufsize);
|
||||
} else {
|
||||
fprintf(stderr, "short read, read %d frames/n", ret);
|
||||
LOG_EX(LOG_Error, "ALSA Short Read, Read %d Frames: %d\n",
|
||||
ret);
|
||||
}
|
||||
} else {
|
||||
// read dmic data and throw
|
||||
pcm_read(record);
|
||||
printf("Read adc codec error!\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case WorkMode_R311_PV1:
|
||||
if (pcm_read(record->pcm_cfg->adc) ==
|
||||
record->pcm_cfg->adc->chunk_size) {
|
||||
|
@ -533,7 +610,8 @@ static void *RecordThread(void *param) {
|
|||
xwrite(record->backupfilefd, newbuf, len);
|
||||
fdcount += len;
|
||||
#else
|
||||
xwrite(record->backupfilefd, record->buffer, record->chunk_bytes);
|
||||
xwrite(record->backupfilefd, record->buffer,
|
||||
record->chunk_bytes);
|
||||
fdcount += record->chunk_bytes;
|
||||
#endif
|
||||
}
|
||||
|
@ -565,6 +643,16 @@ static void *RecordThread(void *param) {
|
|||
record->backupfilefd = 0;
|
||||
n_debug("Write backup file end finish!\n");
|
||||
}
|
||||
|
||||
//exit, clear
|
||||
switch (getWorkMode()) {
|
||||
case WorkMode_R311_C1_EVB:
|
||||
if (tmpbuf) {
|
||||
free(tmpbuf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
n_debug("RecordThread end, running:%d\n", record->runing);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -627,6 +715,44 @@ int Neteasae_record_start(struct pcm_config *pcm_cfg) {
|
|||
|
||||
break;
|
||||
|
||||
case WorkMode_R311_C1_EVB:
|
||||
// sndes7210.0-0040 for 4 mic
|
||||
pcm_cfg->device_name = "hw:1,0";
|
||||
pcm_cfg->channels = 2;
|
||||
pcm_cfg->rate = 16000;
|
||||
pcm_cfg->period_size = 1535;
|
||||
pcm_cfg->format = "S32_LE";
|
||||
|
||||
printf("Begin to init es7210 for 4 mic!\n");
|
||||
init_params(pcm_cfg, 1);
|
||||
tmp = (struct pcm_config *)calloc(1, sizeof(struct pcm_config));
|
||||
if (tmp == NULL) {
|
||||
printf("alloc fail!\n");
|
||||
exit(0);
|
||||
} else {
|
||||
printf("Begin to init adc codec!\n");
|
||||
// es7243 for 2 resample
|
||||
tmp->device_name = "hw:2,0";
|
||||
tmp->channels = 2;
|
||||
tmp->rate = 16000;
|
||||
tmp->period_size = 1535;
|
||||
tmp->format = "S16_LE";
|
||||
init_params(tmp, 0);
|
||||
}
|
||||
pcm_cfg->adc = tmp->recordata;
|
||||
pcm_cfg->recordata->adc = tmp;
|
||||
|
||||
pthread_attr_init(&thread_attr);
|
||||
pthread_attr_setschedpolicy(&thread_attr, SCHED_RR);
|
||||
thread_param.sched_priority = sched_get_priority_max(SCHED_RR);
|
||||
pthread_attr_setschedparam(&thread_attr, &thread_param);
|
||||
|
||||
pthread_create(&pcm_cfg->recordata->tid_pcm_read, &thread_attr,
|
||||
RecordThread, (void *)pcm_cfg->recordata);
|
||||
pthread_create(&pcm_cfg->recordata->tid_queue_read, NULL,
|
||||
QueueReadThread, (void *)pcm_cfg->recordata);
|
||||
break;
|
||||
|
||||
case WorkMode_R311_PV1_CES:
|
||||
pcm_cfg->device_name = "hw:1,0";
|
||||
pcm_cfg->channels = 2;
|
||||
|
|
Loading…
Reference in New Issue