view src/gpf/osl/os_sem_ir.c @ 273:5caa86ee2cfa

enable L1_NEW_AEC in l1_confg.h (bold change) The AEC function implemented in DSP ROM 3606 on the Calypso silicon we work with is the one that corresponds to L1_NEW_AEC; the same holds for DSP 34 and even for DSP 33 with more recent patch versions. However, TI shipped their TCS211 reference fw with L1_NEW_AEC set to 0, thus driving AEC the old way if anyone tried to enable it, either via AT%Nxxxx or via the audio mode facility. As a result, the fw would try to control features which no longer exist in the DSP (long vs short echo and the old echo suppression level bits), while providing no way to tune the 8 new parameter words added to the DSP's NDB page. The only sensible solution is to bite the bullet and enable L1_NEW_AEC in L1 config, with fallout propagating into RiViera Audio Service T_AUDIO_AEC_CFG structure and into /aud/*.cfg binary file format. The latter fallout will be addressed in further code changes.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 29 Jul 2021 18:32:40 +0000
parents 4e78acac3d88
children
line wrap: on
line source

/*
 * This C module is a reconstruction based on the disassembly of
 * os_sem.obj in frame_na7_db_ir.lib from the Leonardo package.
 */

/* set of included headers from COFF symtab: */
#include <stdio.h>
#include <string.h>
#include "nucleus.h"
#include "typedefs.h"
#include "os.h"
#include "gdi.h"
#include "os_types.h"
#include "os_glob.h"

extern T_OS_SEM_TABLE_ENTRY SemTable[];
extern unsigned os_time_to_tick_multiplier;

int
ReleaseSemaphoreCB(NU_SEMAPHORE *SemCB)
{
	if (NU_Release_Semaphore(SemCB) == NU_SUCCESS)
		return(OS_OK);
	else
		return(OS_ERROR);
}

GLOBAL LONG
os_ReleaseSemaphore(OS_HANDLE TaskHandle, OS_HANDLE SemHandle)
{
	if (NU_Release_Semaphore(&SemTable[SemHandle].SemCB) == NU_SUCCESS)
		return(OS_OK);
	else
		return(OS_ERROR);
}

int
ObtainSemaphoreCB(NU_SEMAPHORE *SemCB, ULONG Timeout, USHORT wait_check)
{
	UNSIGNED nu_timeout;
	STATUS sts;
	int ret;

	ret = OS_OK;
	if (Timeout != OS_SUSPEND)
		nu_timeout = TIME_TO_SYSTEM_TICKS(Timeout);
	else if (wait_check == 1)
		nu_timeout = 1;
	else
		nu_timeout = NU_SUSPEND;
	for (;;) {
		sts = NU_Obtain_Semaphore(SemCB, nu_timeout);
		switch (sts) {
		case NU_SUCCESS:
			return(ret);
		case NU_INVALID_SEMAPHORE:
			return(OS_ERROR);
		case NU_INVALID_SUSPEND:
			nu_timeout = 0;
			continue;
		case NU_TIMEOUT:
		case NU_UNAVAILABLE:
			if (nu_timeout == 1 && wait_check == 1) {
				nu_timeout = NU_SUSPEND;
				ret = OS_WAITED;
				continue;
			}
			return(OS_TIMEOUT);
		default:
			/*
			 * Disassembly reveals that the original code
			 * has an endless loop here, the equivalent
			 * of continue.  My guess is that they simply
			 * forgot the default case, and so control
			 * falls onto the closing brace of the switch
			 * and then onto the closing brace of the for
			 * loop.  But I prefer better error handling,
			 * hence the present addition. - Space Falcon
			 */
			return(OS_ERROR);
		}
	}
}

GLOBAL LONG
os_ObtainSemaphore(OS_HANDLE TaskHandle, OS_HANDLE SemHandle, ULONG Timeout)
{
	if (SemHandle > MaxSemaphores)
		return(OS_ERROR);
	return ObtainSemaphoreCB(&SemTable[SemHandle].SemCB, Timeout, 0);
}