⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spf_pcm.s

📁 关于DVD上的PCM的解码的代码,PCM的DSP压缩,解调的算法,用RISC32指令来写.
💻 S
字号:
/************************************************************************/
; (c)1996 Copyright M-Pact, Inc. All rights reserved
;
; Revision 1.0
;
;	
;	Module:	PCM_OUT (PCM output routine)
;
;	Initial version: Jinshi Huang 3/17/97
;
;	Calling	:     	none
;	Called by:	top level
;	Return:		r26, LBPCM_flag
;	Param in:     
;	Temp reg:	
;	AGR  reg:	
;	Local buffer:
;************************************************************************
	.nolist
#include "regdef.h"
#include "globalv.h"
#include "user.h"
#include "sync.h"
	.list
	.extern	PCM_Config_Word
	.globl	SUB_SPF_pcm
SUB_SPF_pcm:
	
.if	PCM_OUT
	
	movb	r1, LBFIFO_flag
	movb	r4, LBblknum
#ifdef EXECTIVE
	subi	r4,1			// block count already increment
#endif
	tsti	r1, 0
	beq	no_checking_FIFO

	dlw	r10, FIFO_BLK_PTR
	movi	r8, PCM_FIFO_0_START	;  beginning of FIFO_0
	movi	r9, PCM_FIFO_0_END	;  to the end of FIFO being read
	tsti	r10, PCM_FIFO_0_START
	beq	toggle_ref_ptr
	movi	r8, PCM_FIFO_1_START	; beginning of FIFO_1
	movi	r9, PCM_FIFO_1_END	; end of FIFO_1
toggle_ref_ptr:
		
;; read location of read fifo

pcmout_wait:	
#ifdef	FILE_OUT
	dlw	r1,PCM_Rd_Ptr	; read current pointer assigned by host
	nop
#else
1:
	rlwi	r1, PCM_Rd_Ptr	; read current pointer register (28c)
	rlwi	r3, PCM_Rd_Ptr	; read current pointer register (28c)
	tst	r1,r3
	bne	1b
#endif
#ifdef STREAM_SIM
	shr	r1, 16		; make it just the current address portion
#else
	andi	r1,0xffff
#endif
	tst	r1, r8
	blt	write_to_FIFO
	
	tst	r1, r9		; 
	blte	pcm_not_out	; if begin <= ptr <= end, wait
		
	j	write_to_FIFO

		
/**********************************************************************/
// this code should be moved to the kernel later !!!!!
// write to the FIFO

;====write 256 words to main memory. pcmptr2 += offset
;this is modified to write 16-bit format of 6 channels to
;0 - 0x1800 of the DRAM which is the PCM output FIFO.


no_checking_FIFO:	
	tsti	r4, 0
	bne	second_FIFO_block

;;; set the size of the PCM output FIFO for 2 blocks
	movi	r1, PCM_FIFO_SIZE	; size of PCM output FIFO
#ifdef STREAM_SIM
				; 28c is PCM FIFO end address in real chip
				; and should contain full address,seg+offset
				; will be set by host for the time being.
	rswi	r1,PCM_End_Addr	; write to register
#endif
//	dlw	r1, PCM_Config_Word
//	nop				;pipeline 
//	rswi	r1, PCM_Out_Ctrl	; write to register

	movi	r10, PCM_FIFO_0_START
	j	write_to_FIFO

second_FIFO_block:
	movi	r1, 1
	movb	LBFIFO_flag,r1
	movi	r10, PCM_FIFO_1_START
write_to_FIFO:				
#ifdef	EXECTIVE
	tsti	r4,0
	bne	Lskip_PTS
#if	!LS388
	movh	r28,LIfrmsize
	shl	r28,1
	movw	r1,LWbytecount
	add	r1,r28
	movw	LWbytecount,r1
#endif	// LS388
	jsr	r28,SUB_check_PTS
Lskip_PTS:
#endif

// get the gain value by combining stream gain with user gain
	
	dlw	r20, USER_OCFG
	mupi	r0, OCFG_X_MASK_HI
	and	r1, r20, r0
	shr	r1, OCFG_X_SHIFT	//r1=X
	mupi	r0, OCFG_Y_MASK_HI
	and	r2, r20, r0
	shr	r2, OCFG_Y_SHIFT	//r2=Y
	mupi	r3, 0x007f
	ori	r3, 0xffff		//default unity gain
	tsti	r2, 15
	blt	Lgross_gain
	addi	r1, 1
Lgross_gain:
	subi	r1, 4
	tsti	r1, 0
	blte	Lno_gain		//do only attenuation for now
	shrv	r3, r1			//adjust gain value
Lno_gain:	
	movw	r2, LWpcmscale		//gain from user
	mulf	r4, r2, r3		//compound gain
	
	movi	DMASize, 31		;32 words each block
	movi	BlockSkip, 0	
	movi	BlockSize, 0		;block size = 1.

// apply the gain to the samples

	movi	r0, 0xffff		//lower 16-bit mask
	mupi	r1, 0xffff		//upper 16-bit mask
	movi	AGRAdr0, local_FApcm_buf_byte	
	movi	TrapReg,0
	nop
	nop
#ifdef	NON_DEF
	loop	24, Lpcm_gain_outer
	loop	32, Lpcm_gain_inner
	shl	r3, a0(0*4), 16		//get 16-bit sample
	shra	r3, 8			//sign-extented to 1.23 format
	mulf	r6, r4, r3
	nop
	rnd	r6
	nop
	nop
	nop
	shl	a0(1*4), r6, 7		//align to MSB with 1 right shift
Lpcm_gain_inner:
Lpcm_gain_outer:
#else
	loop	24, Lpcm_gain_outer
	loop	32, Lpcm_gain_inner
	and	r3, r1, a0(0*4)		//get upper 16-bit
	shra	r3, 8			//sign-extented to 1.23 format
	mulf	r6, r4, r3
	and	r3, r0, a0(0*4)		//get lower 16-bit; pipeline
	rnd	r6
	shl	r3, 16
	shra	r3, 8			//sign-extented to 1.23 format
	mulf	r8, r4, r3
	shl	r6, 8			//align to upper 16-bit; pipeline
	rnd	r8
	and	r6, r1			//keep only 16-bit data
	nop
	nop				//pipeline
	shr	r8, 8			//align to lower 16-bit
	and	r8, r0			//keep only 16-bit data
	or	a0(1*4), r6, r8		//put back 32-bit pair
Lpcm_gain_inner:
Lpcm_gain_outer:
#endif
	movi	TrapReg,1<<2

	
	movi	r3, local_FApcm_buf_word	; word addr
	shr	r9, r10, 2		; to word addr
	

	movi	TrapReg,0
	nop
	nop

	loop	24, write_pcm_buf	;total of 256*3 words
	
	mov	LocalAddr, r3	
	dmawr	r9			;r10=FPApcmbufptr[outchan]=pcmptr2(init)
wait_dma_21:
	mov	r2,StatusPort
	tsti	r2,DmaDoneBit
	bz	wait_dma_21		;wait for dma done

	addi	r3, 32			;32 words each block
	addi	r9, 32
	
write_pcm_buf:
	movi	TrapReg,1<<2
	movi	BlockSkip, 0	

	
;; Make sure PCMOUT is enabled. This is only necessary for the
;; first time.

//	dlw	r1, PCM_Config_Word
//	nop				;pipeline 
//	rswi	r1, PCM_Out_Ctrl	; write to register

	dlw	r0,MUTE_FLAG
	movi	r1, 0x1			; enable PCM output
	tsti	r0,1
	beq	Lalready_on
#if	!LS388
	rswi	r1, PCM_Run_Halt	; write to register
#endif	// LS388
	dsw	r1,MUTE_FLAG
Lalready_on:	

	movi	r9, PCM_FIFO_1_START
	tsti	r10, PCM_FIFO_0_START
	beq	toggle_FIFO_ptr
	movi	r9, PCM_FIFO_0_START
toggle_FIFO_ptr:
	dsw	r9, FIFO_BLK_PTR	;toggle block ptr 

	movi	r1, 1
	movb	LBPCM_flag, r1		;set the flag
	rlwi	r0,STC
	movw	LWStartPTS,r0

#ifdef	LS240_PM
	j	Lnot_sleep
pcm_not_out:	
	rlwi	r0,HOST_CTRL
	mupi	r1,0xffff
	ori	r1,0xffef	; DSP colck turned off
	and	r0,r1
	rswi	r1,HOST_CTRL
Lnot_sleep:	
#else
pcm_not_out:
#endif	
	.endif
	
	j	r27
	
	


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -