amixer.s 1.53 KB

/* 
 * amixer.s			
 *	
 * Single precision mixer. Takes an input buffer, output buffer,
 * count and a gain and mixes the input into the output.
 * Assumes double quad alignment.
 *
 */

/* Semi-permanent scalar registers */

.name	dm_in,		$20	# DMEM Input - points to samples
.name   dm_out,		$19	# DMEM output
.name	ocount,		$18	# Actual number of bytes (2 per sample)
.name	gain,		$17
.name	tmp0,		$16

/* Semi-permanent vector registers */

.name	vconst,		$v31
.name	vgain,		$v30
.name	vin0,		$v29
.name	vin1,		$v28
.name	vout0,		$v27
.name	vout1,		$v26

  # Get address of input and output

case_A_MIXER:

	lqv	vconst[0], VCONST_OFFSET(zero)
	lhu	ocount, RSP_PARAMETER_COUNT(parbase)
	beq	ocount, zero, MIXdone	
	nop
	andi	dm_out, aud1, 0xffff
	addi	dm_out, dm_out, RSP_BUFFER_OFFSET
	srl	dm_in, aud1, 16
	addi	dm_in, dm_in, RSP_BUFFER_OFFSET

	andi	gain, aud0, 0xffff
	mtc2	gain, vgain

	lqv	vout0[0], 0(dm_out)
	lqv	vin0[0], 0(dm_in)
	lqv	vout1[0], 16(dm_out)
	lqv	vin1[0], 16(dm_in)
MIXloop:
	vmulf	vout0, vout0, vconst[6]
			addi	ocount, ocount, -32
	vmacf	vout0, vin0, vgain[0]
			addi	dm_in, dm_in, 32
			sqv	vout0[0], 0(dm_out)
	vmulf	vout1, vout1, vconst[6]
			lqv	vin0[0], 0(dm_in)
	vmacf	vout1, vin1, vgain[0]
			lqv	vin1[0], 16(dm_in)
			sqv	vout1[0], 16(dm_out)

			addi	dm_out, dm_out, 32
			lqv	vout0[0], 0(dm_out)
			bgtz	ocount, MIXloop
			lqv	vout1[0], 16(dm_out)

MIXdone:
	j	AudDone
	nop

.unname	dm_in
.unname dm_out
.unname	ocount
.unname gain
.unname	tmp0

.unname	vconst
.unname	vgain
.unname	vin0
.unname	vin1
.unname vout0
.unname vout1