Skip to content

Commit

Permalink
Some touch-ups on audio transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Jun 20, 2024
1 parent 9062686 commit 4658a62
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/hal/hisi/v3_aud.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef struct {
v3_aud_intf intf;
int stereoOn;
// 8-to-16 bit, expand mode
int expandOn;
unsigned int expandOn;
unsigned int frmNum;
unsigned int packNumPerFrm;
unsigned int chnNum;
Expand Down
21 changes: 13 additions & 8 deletions src/hal/hisi/v3_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ int v3_audio_init(void)

{
v3_aud_cnf config;
config.rate = 48000;
config.rate = 8000;
config.bit = V3_AUD_BIT_16;
config.intf = V3_AUD_INTF_I2S_SLAVE;
config.intf = V3_AUD_INTF_I2S_MASTER;
config.stereoOn = 0;
config.expandOn = 0;
config.frmNum = 0;
config.packNumPerFrm = config.rate / 16;
config.frmNum = 30;
config.packNumPerFrm = 320;
config.chnNum = 1;
config.syncRxClkOn = 1;
config.syncRxClkOn = 0;
if (ret = v3_aud.fnSetDeviceConfig(_v3_aud_dev, &config))
return ret;
}
Expand All @@ -110,14 +110,19 @@ void *v3_audio_thread(void)

while (keepRunning) {
if (ret = v3_aud.fnGetFrame(_v3_aud_dev, _v3_aud_chn,
&frame, &echoFrame, 100)) {
&frame, &echoFrame, 128)) {
fprintf(stderr, "[v3_aud] Getting the frame failed "
"with %#x!\n", ret);
break;
} else continue;
continue;
}

if (v3_aud_cb) {
hal_audframe outFrame;
outFrame.channelCnt = 1;
outFrame.data[0] = frame.addr[0];
outFrame.length[0] = frame.length;
outFrame.seq = frame.sequence;
outFrame.timestamp = frame.timestamp;
(v3_aud_cb)(&outFrame);
}

Expand Down
13 changes: 10 additions & 3 deletions src/hal/hisi/v4_aud.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ typedef enum {
V4_AUD_BIT_24
} v4_aud_bit;

typedef enum {
V4_AUD_I2ST_INNERCODEC,
V4_AUD_I2ST_INNERHDMI,
V4_AUD_I2ST_EXTERN
} v4_aud_i2st;

typedef enum {
V4_AUD_INTF_I2S_MASTER,
V4_AUD_INTF_I2S_SLAVE,
Expand All @@ -28,18 +34,19 @@ typedef struct {
v4_aud_intf intf;
int stereoOn;
// 8-to-16 bit, expand mode
int expandOn;
unsigned int expandOn;
unsigned int frmNum;
unsigned int packNumPerFrm;
unsigned int chnNum;
unsigned int syncRxClkOn;
v4_aud_i2st i2sType;
} v4_aud_cnf;

typedef struct {
v4_aud_bit bit;
int stereoOn;
void *addr[2];
unsigned int phy[2];
char *addr[2];
unsigned long long phy[2];
unsigned long long timestamp;
unsigned int sequence;
unsigned int length;
Expand Down
22 changes: 14 additions & 8 deletions src/hal/hisi/v4_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,16 @@ int v4_audio_init(void)

{
v4_aud_cnf config;
config.rate = 48000;
config.rate = 8000;
config.bit = V4_AUD_BIT_16;
config.intf = V4_AUD_INTF_I2S_SLAVE;
config.intf = V4_AUD_INTF_I2S_MASTER;
config.stereoOn = 0;
config.expandOn = 0;
config.frmNum = 0;
config.packNumPerFrm = config.rate / 16;
config.frmNum = 30;
config.packNumPerFrm = 320;
config.chnNum = 1;
config.syncRxClkOn = 1;
config.syncRxClkOn = 0;
config.i2sType = V4_AUD_I2ST_INNERCODEC;
if (ret = v4_aud.fnSetDeviceConfig(_v4_aud_dev, &config))
return ret;
}
Expand All @@ -111,14 +112,19 @@ void *v4_audio_thread(void)

while (keepRunning) {
if (ret = v4_aud.fnGetFrame(_v4_aud_dev, _v4_aud_chn,
&frame, &echoFrame, 100)) {
&frame, &echoFrame, 128)) {
fprintf(stderr, "[v4_aud] Getting the frame failed "
"with %#x!\n", ret);
break;
} else continue;
continue;
}

if (v4_aud_cb) {
hal_audframe outFrame;
outFrame.channelCnt = 1;
outFrame.data[0] = frame.addr[0];
outFrame.length[0] = frame.length;
outFrame.seq = frame.sequence;
outFrame.timestamp = frame.timestamp;
(v4_aud_cb)(&outFrame);
}

Expand Down
4 changes: 2 additions & 2 deletions src/hal/star/i6_aud.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ typedef struct {
typedef struct {
int bit24On;
i6_aud_snd sound;
int *addr[I6_AUD_CHN_NUM];
unsigned char *addr[I6_AUD_CHN_NUM];
unsigned long long timestamp;
unsigned int sequence;
unsigned int length;
unsigned int poolId[2];
int *pcmAddr[I6_AUD_CHN_NUM];
unsigned char *pcmAddr[I6_AUD_CHN_NUM];
unsigned int pcmLength;
} i6_aud_frm;

Expand Down
5 changes: 5 additions & 0 deletions src/hal/star/i6_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ void *i6_audio_thread(void)

if (i6_aud_cb) {
hal_audframe outFrame;
outFrame.channelCnt = 1;
outFrame.data[0] = frame.addr[0];
outFrame.length[0] = frame.length;
outFrame.seq = frame.sequence;
outFrame.timestamp = frame.timestamp;
(i6_aud_cb)(&outFrame);
}

Expand Down
5 changes: 5 additions & 0 deletions src/hal/star/i6c_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ void *i6c_audio_thread(void)

if (i6c_aud_cb) {
hal_audframe outFrame;
outFrame.channelCnt = 1;
outFrame.data[0] = frame.addr[0];
outFrame.length[0] = frame.length[0];
outFrame.seq = frame.sequence;
outFrame.timestamp = frame.timestamp;
(i6c_aud_cb)(&outFrame);
}

Expand Down
5 changes: 5 additions & 0 deletions src/hal/star/i6f_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ void *i6f_audio_thread(void)

if (i6f_aud_cb) {
hal_audframe outFrame;
outFrame.channelCnt = 1;
outFrame.data[0] = frame.addr[0];
outFrame.length[0] = frame.length[0];
outFrame.seq = frame.sequence;
outFrame.timestamp = frame.timestamp;
(i6f_aud_cb)(&outFrame);
}

Expand Down

0 comments on commit 4658a62

Please sign in to comment.