Skip to content

Commit

Permalink
os/arch/arm/src/amebasmart: stop sending i2s data if there is no pend…
Browse files Browse the repository at this point in the history
…ing buffer containing in tx.pend list

1. pause i2s send when there is no buffer in tx.pend list
2. it removes noise, (mute instead) if there is insufficient time to get the next buffer from application due to heavy loading
  • Loading branch information
zhongnuo-tang authored and sunghan-chang committed Nov 1, 2024
1 parent 7e675f5 commit 57a3a88
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion os/arch/arm/src/amebasmart/amebasmart_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ static int amebasmart_i2s_tx(struct amebasmart_i2s_s *priv, struct amebasmart_bu
/* Start sending first page, after that the txdma callback will be called in the tx irq handler */
while ((priv->apb_tx->nbytes - priv->apb_tx->curbyte) > 0) {
ptx_buf = i2s_get_tx_page(priv->i2s_object);
i2s_enable(priv->i2s_object);
if (ptx_buf) {
if ((apb->nbytes - apb->curbyte) <= tx_size) {
tx_size = apb->nbytes - apb->curbyte;
Expand All @@ -412,7 +413,7 @@ static int amebasmart_i2s_tx(struct amebasmart_i2s_s *priv, struct amebasmart_bu
}
apb->curbyte += tx_size; /* No padding, ptx_buf is big enough to fill the whole tx_size */

i2s_enable(priv->i2s_object);

i2s_send_page(priv->i2s_object, (uint32_t *)ptx_buf);
} else {
break;
Expand Down Expand Up @@ -557,6 +558,8 @@ static void i2s_tx_schedule(struct amebasmart_i2s_s *priv, int result)

/* Start next transfer */
amebasmart_i2s_tx(priv, bfcontainer);
} else if ((priv->apb_tx->nbytes - priv->apb_tx->curbyte) <= 0) {
ameba_i2s_pause(priv->i2s_object);
}

/* If the worker has completed running, then reschedule the working thread.
Expand Down

0 comments on commit 57a3a88

Please sign in to comment.