view src/gpf/osl/os_com_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_com.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 TC_PROTECT TCD_System_Protect;
extern VOID TCT_Protect(TC_PROTECT *protect);
extern VOID TCT_Unprotect(VOID);
extern VOID TCT_Unprotect_Specific(TC_PROTECT *protect);

#define My_System_Protect()   TCT_Protect(&TCD_System_Protect)
#define My_System_Unprotect() TCT_Unprotect_Specific(&TCD_System_Protect)

extern T_OS_COM_TABLE_ENTRY ComTable[];
extern unsigned os_tick_to_time_multiplier;

extern int ObtainSemaphoreCB(NU_SEMAPHORE *SemCB, ULONG Timeout,
				USHORT wait_check);
extern int ReleaseSemaphoreCB(NU_SEMAPHORE *SemCB);

GLOBAL LONG
os_SendToQueue(OS_HANDLE TaskHandle, OS_HANDLE ComHandle, USHORT Priority,
		ULONG Suspend, OS_QDATA *Msg)
{
	T_OS_COM_TABLE_ENTRY *pTable;
	T_QDATA_ELEMENT *elem;
	T_QUEUE *queue;
	int ret;
	NU_SEMAPHORE *CBPtr;
	USHORT watmark;

	if (ComHandle <= 0 || ComHandle > MaxCommunications)
		return(OS_INVALID_QUEUE);
	pTable = ComTable + ComHandle;
	if (!pTable->Name[0])
		return(OS_INVALID_QUEUE);
	CBPtr = &pTable->FreeSemCB;
	ret = ObtainSemaphoreCB(CBPtr, Suspend, 1);
	if (ret == OS_ERROR || ret == OS_TIMEOUT)
		return(ret);
	My_System_Protect();
	elem = pTable->pFreeElement;
	pTable->pFreeElement = elem->pNext;
	memcpy(&elem->Data, Msg, sizeof(OS_QDATA));
	queue = &pTable->Queue[Priority - OS_MIN_PRIORITY];
	*queue->pWrite++ = &elem->Data;
	if (queue->pWrite - queue->pStart >= pTable->Entries + 1)
		queue->pWrite = queue->pStart;
	watmark = pTable->Entries - CBPtr->sm_semaphore_count;
	if (pTable->MaxUsed < watmark)
		pTable->MaxUsed = watmark;
	My_System_Unprotect();
	ReleaseSemaphoreCB(&pTable->UsedSemCB);
	return(ret);
}

GLOBAL LONG
os_ReceiveFromQueue(OS_HANDLE TaskHandle, OS_HANDLE ComHandle,
			OS_QDATA *Msg, ULONG Timeout)
{
	T_QDATA_ELEMENT *pElem;
	UNSIGNED c_time;
	int ret;
	USHORT i;
	T_QUEUE *pQueue;
	T_OS_COM_TABLE_ENTRY *pTable;

	pTable = ComTable + ComHandle;
	if (!pTable->Name[0])
		return(OS_ERROR);
	pTable->current_msg.type = 0;
	ret = ObtainSemaphoreCB(&pTable->UsedSemCB, Timeout, 0);
	if (ret == OS_ERROR || ret == OS_TIMEOUT)
		return(ret);
	My_System_Protect();
	for (i = OS_MAX_PRIORITY; i >= OS_MIN_PRIORITY; i--) {
		pQueue = &pTable->Queue[i - OS_MIN_PRIORITY];
		if (pQueue->pWrite != pQueue->pRead)
			break;
	}
	if (i < OS_MIN_PRIORITY) {
		My_System_Unprotect();
		ReleaseSemaphoreCB(&pTable->FreeSemCB);
		return(OS_ERROR);
	}
	memcpy(Msg, *pQueue->pRead, sizeof(OS_QDATA));
	pElem = (T_QDATA_ELEMENT *)*pQueue->pRead++;
	pElem->Data.data16 = 0;
	pElem->pNext = pTable->pFreeElement;
	pTable->pFreeElement = pElem;
	if (pQueue->pRead - pQueue->pStart >= pTable->Entries + 1)
		pQueue->pRead = pQueue->pStart;
	pTable->current_msg.type = Msg->data16;
	pTable->current_msg.opc = Msg->data32;
	c_time = NU_Retrieve_Clock();
	pTable->current_msg.time = SYSTEM_TICKS_TO_TIME(c_time);
	pTable->current_msg.ptr = Msg->ptr;
	My_System_Unprotect();
	ReleaseSemaphoreCB(&pTable->FreeSemCB);
	return(OS_OK);
}