예제 #1
0
/****************************************************************************
NAME
    loadFstab  -  Load FSTAB data from the requested store

DESCRIPTION
    Checks whether the store requested is one of those that we support, then
    finds the length of the allocated data (if any), and loads the data from 
    Persistent store into the supplied structure (fixed size).

RETURNS
    TRUE if store was supported and an entry was found.
*/
static bool loadFstab(FSTAB_COPY *fstab,PsStores store)
{
PsStores    old_store;

    if (   (store == ps_store_implementation)
        || (store == ps_store_transient))
    {
        /* Since we are a library, get the old persistent store
         * so we can restore it  */
        old_store = PsGetStore();
        PsSetStore(store);

        /* Find size of storage */
        fstab->length = PsFullRetrieve(PSKEY_FSTAB,NULL,0);
        if (   (FSTAB_MINIMUM_SIZE <= fstab->length) 
            && (fstab->length <= sizeof(fstab->ram_copy)))
        {
            fstab->length = PsFullRetrieve(PSKEY_FSTAB,fstab->ram_copy,fstab->length);
            PsSetStore(old_store);
            return TRUE;
        }
        PsSetStore(old_store);
    }

    return FALSE;
}
void pioInit(PioState *pioState, Task client)
{
    MessagePioChanged *m = malloc(sizeof(MessagePioChanged));
    uint16 pio_get = PioGet();
    uint16 pskey_wakeup = 0xFFFF;

    pioState->task.handler = pioHandler;
    pioState->client       = client;

    PsFullRetrieve(PSKEY_PIO_WAKEUP_STATE, &pskey_wakeup, sizeof(pskey_wakeup));

    pskey_wakeup = ~pskey_wakeup;

    pioState->pio_states.store_held = Unknown;
    pioState->pio_states.double_press = Unknown;
    pioState->pio_states.store_count = 0;
    pioState->pio_states.store_bits = 0;
    pioState->pio_states.timed_id = 0;
    pioState->pio_states.pskey_wakeup = pskey_wakeup;
    pioState->pio_states.pio_raw_bits = ~(pio_get^pskey_wakeup) & (0);

    (void) MessagePioTask(&pioState->task);
    PioDebounce((1UL<<0), 2, 20);

    m->state = pio_get & ((1UL<<0));
    m->time  = 0;
    MessageSend(&pioState->task, MESSAGE_PIO_CHANGED, m);
}
예제 #3
0
/****************************************************************************
NAME    
    powerManagerConfig
    
DESCRIPTION
    Configure power management
    
RETURNS
    void
*/
void powerManagerConfig(const power_config* config, const power_pmu_temp_mon_config* pmu_mon_config)
{
    uint16 level = 0;
    
    PM_DEBUG(("PM: Power Library Init\n"));
    PowerInit(&theSink.task, config, pmu_mon_config);
    theSink.battery_state = POWER_BATT_LEVEL3;   
    
    if ((theSink.conf1 != NULL) && (config != NULL))
    {
        /* store the charger termination voltage as the max battery voltage */
        theSink.rundata->battery_limits.max_battery_v = 0;
        PsFullRetrieve(PSKEY_CHARGER_CALC_VTERM, &theSink.rundata->battery_limits.max_battery_v, sizeof(uint16));    
        /* store the critical voltage as the min battery voltage */
        theSink.rundata->battery_limits.min_battery_v = 0;
    
        for (level = 0; level < POWER_MAX_VBAT_LIMITS; level++)
        {
            if ((theSink.conf1->power.bat_events[level].event) == EventSysBatteryCritical)
            {
                theSink.rundata->battery_limits.min_battery_v = config->vbat.limits[level].limit * POWER_VSCALE;
                break;
            }
        }
    }
}
예제 #4
0
파일: sink_init.c 프로젝트: jrryu/HW--FW
/****************************************************************************
NAME    
    SetupPowerTable

DESCRIPTION
    Attempts to obtain a low power table from the Ps Key store.  If no table 
    (or an incomplete one) is found in Ps Keys then the default is used.
    
RETURNS
    void
*/
void SetupPowerTable( void )
{
    uint16 size_ps_key;
    power_table *PowerTable;
    
    /* obtain the size of memory in words required to hold the contents of the pskey */
    size_ps_key = PsFullRetrieve(PS_HFP_POWER_TABLE, NULL, 0);

    /* initialise user power table */
    theSink.user_power_table = 0;

    /* check whether any pskey data exists */    
    if (size_ps_key)
    {
        /* malloc storage for power table entries */ 
        PowerTable = (power_table*)mallocPanic(size_ps_key);
        
        /* attempt to retrieve all power table entries from ps */
        size_ps_key = PsFullRetrieve(PS_HFP_POWER_TABLE, PowerTable, ((sizeof(lp_power_table) * MAX_POWER_TABLE_ENTRIES) + sizeof(uint16)));
     
        /* sanity check the number of entried and length of pskey data to ensure entries are complete */
        if(size_ps_key == ((sizeof(lp_power_table)*PowerTable->normalEntries)+
                           (sizeof(lp_power_table)*PowerTable->SCOEntries)+
                           (sizeof(lp_power_table)*PowerTable->A2DPStreamEntries)+                                 
                           (sizeof(uint16)))
          )
        {   
            /* Use user defined power table */
            theSink.user_power_table = PowerTable;
            /* pskey format is correct */
            INIT_DEBUG(("User Power Table - Norm[%x] Sco[%x] Stream[%x]\n",PowerTable->normalEntries,PowerTable->SCOEntries,PowerTable->A2DPStreamEntries));
        }
        else
        {   /* No/incorrect power table defined in Ps Keys - use default table */
            freePanic(PowerTable);
            PowerTable = NULL;
            INIT_DEBUG(("No User Power Table\n"));
        }
    }
    
}
예제 #5
0
void headsetHandlePinCodeInd(const CL_SM_PIN_CODE_IND_T* ind)
{
    uint16 pin_length = 0;
    uint8 pin[16];
    
    if ( AuthCanHeadsetPair () )
    {
	    
		AUTH_DEBUG(("auth: Can Pin\n")) ;
			
    	/* Do we have a fixed pin in PS, if not reject pairing */
    	if ((pin_length = PsFullRetrieve(PSKEY_FIXED_PIN, pin, 16)) == 0 || pin_length > 16)
    	{
        	/* Set length to 0 indicating we're rejecting the PIN request */
        	AUTH_DEBUG(("auth : failed to get pin\n")) ;
        	pin_length = 0; 
    	}	
	} 
    /* Respond to the PIN code request */
    ConnectionSmPinCodeResponse(&ind->bd_addr, pin_length, pin); 
}
/****************************************************************************
DESCRIPTION
	This function connects a synchronous audio stream to the pcm subsystem
*/
void CsrA2dpDecoderPluginConnect( A2dpPluginTaskdata *task, Sink audio_sink , Task codec_task , uint16 volume , uint32 rate , bool stereo , AUDIO_MODE_T mode , const void * params , Task app_task )
{
	FILE_INDEX index = FILE_NONE;
	char* kap_file = NULL ;

	/* Only need to read the PS Key value once */
    if (!pskey_read)
    {
        if (PsFullRetrieve(PSKEY_MAX_CLOCK_MISMATCH, &val_pskey_max_mismatch, sizeof(uint16)) == 0)
            val_pskey_max_mismatch = 0;
        pskey_read = TRUE;
    }

    switch ((A2DP_DECODER_PLUGIN_TYPE_T)task->a2dp_plugin_variant)
	{
	case SBC_DECODER:
		kap_file = "sbc_decoder/sbc_decoder.kap";
      break;
	case MP3_DECODER:
		kap_file = "mp3_decoder/mp3_decoder.kap";
		break;
	case AAC_DECODER:
		kap_file = "aac_decoder/aac_decoder.kap";
		break;
	case FASTSTREAM_SINK:
		kap_file = "faststream_sink/faststream_sink.kap";
		break;
	default:
		Panic();
		break;
	}


   /*ensure that the messages received are from the correct kap file*/
   (void) MessageCancelAll( (TaskData*) task, MESSAGE_FROM_KALIMBA);
   MessageKalimbaTask( (TaskData*) task );


	index = FileFind(FILE_ROOT,(const char *) kap_file ,strlen(kap_file));

	if (index == FILE_NONE)
		Panic();
	if (!KalimbaLoad(index))
		Panic();

    DECODER = (DECODER_t*)PanicUnlessMalloc (sizeof (DECODER_t) ) ;

    DECODER->media_sink = audio_sink ;
    DECODER->codec_task = codec_task ;
    DECODER->volume     = volume;
    DECODER->mode       = mode;
    DECODER->stereo     = stereo;
    DECODER->params     = (uint16) params;
    DECODER->rate       = rate;
    DECODER->app_task	= app_task;

	if ((A2DP_DECODER_PLUGIN_TYPE_T)task->a2dp_plugin_variant == AAC_DECODER)
	{
		/* Workaround for AAC+ sources that negotiate sampling frequency at half the actual value */
		if (rate < 32000)
			DECODER->rate = rate * 2;
	}

   CodecSetOutputGainNow(DECODER->codec_task, 0, left_and_right_ch);

   StreamDisconnect(StreamPcmSource(0), StreamPcmSink(0));
   StreamDisconnect(StreamPcmSource(1), StreamPcmSink(1));

   PanicFalse(PcmClearRouting(0));
   PanicFalse(PcmClearRouting(1));

   /* For sinks disconnect the source in case its currently being disposed. */
   StreamDisconnect(StreamSourceFromSink(audio_sink), 0);

	PRINT(("DECODER: CsrA2dpDecoderPluginConnect completed\n"));
}