/**************************************************************************** NAME HfpSetLinkPolicy DESCRIPTION set the link policy requirements based on current device audio state RETURNS void */ void linkPolicyUseHfpSettings(hfp_link_priority priority, Sink slcSink) { Sink audioSink; /* determine if there are any sco sinks */ if(HfpLinkGetAudioSink(priority, &audioSink)&&(audioSink)) { /* Set up our sniff sub rate params for SCO */ ssr_params* sco_params = &theSink.conf2->ssr_data.sco_params; ConnectionSetSniffSubRatePolicy(slcSink, sco_params->max_remote_latency, sco_params->min_remote_timeout, sco_params->min_local_timeout); /* is there a user power table available from ps ? */ if((theSink.user_power_table) && (theSink.user_power_table->SCOEntries)) { LP_DEBUG(("LP: SetLinkP - sco user table \n" )); /* User supplied power table for SCO role */ ConnectionSetLinkPolicy(slcSink, theSink.user_power_table->SCOEntries , &theSink.user_power_table->powertable[ theSink.user_power_table->normalEntries ] ); } /* no user power table so use default SCO table */ else { LP_DEBUG(("LP: SetLinkP - sco default table \n" )); ConnectionSetLinkPolicy(slcSink, 2 ,lp_powertable_sco); } } /* default of no a2dp streaming and no sco link */ else { /* set normal link policy settings */ linkPolicyUseDefaultSettings(slcSink); } }
/**************************************************************************** NAME linkPolicyUseAvrcpSettings DESCRIPTION set the link policy requirements for AVRCP alone active connections RETURNS void */ void linkPolicyUseAvrcpSettings( Sink slcSink ) { if(slcSink) { ConnectionSetLinkPolicy(slcSink, 2 ,lp_powertable_avrcp); } }
/**************************************************************************** NAME linkPolicySetLinkinActiveMode DESCRIPTION set the link as active mode for phonebook access RETURNS void */ void linkPolicySetLinkinActiveMode(Sink sink) { LP_DEBUG(("LP: Set Link in Active Mode for Pbapc Access\n")); if(SinkIsValid(sink)) { ConnectionSetLinkPolicy(sink, 1 , lp_powertable_pbap_access); } }
static void linkPolicySetDataActiveMode(Sink sink) { LP_DEBUG(("LP: Set Link in Active Mode for data access\n")); if(SinkIsValid(sink)) { ConnectionSetLinkPolicy(sink, 1 , lp_powertable_data_access); } }
/**************************************************************************** NAME linkPolicyUseDefaultSettings DESCRIPTION set the link policy based on no a2dp streaming or sco RETURNS void */ static void linkPolicyUseDefaultSettings(Sink sink) { /* Set up our sniff sub rate params for SLC */ ssr_params* slc_params = &theSink.conf2->ssr_data.slc_params; ConnectionSetSniffSubRatePolicy(sink, slc_params->max_remote_latency, slc_params->min_remote_timeout, slc_params->min_local_timeout); /* audio not active, normal role, check for user defined power table */ if((theSink.user_power_table)&&(theSink.user_power_table->normalEntries)) { LP_DEBUG(("LP: SetLinkP - norm user table \n" )); /* User supplied power table */ ConnectionSetLinkPolicy(sink, theSink.user_power_table->normalEntries ,&theSink.user_power_table->powertable[0]); } /* no user defined power table so use default normal power table */ else { LP_DEBUG(("LP: SetLinkP - norm default table \n" )); ConnectionSetLinkPolicy(sink, 2 ,lp_powertable_default); } }
/**************************************************************************** NAME linkPolicyUpdateSwatLink DESCRIPTION this function checks the current swat connection state and updates the link policy of the link RETURNS void */ void linkPolicyUpdateSwatLink(void) { #ifdef ENABLE_SUBWOOFER /* attempt to get subwoofer signalling sink */ Sink sink = SwatGetSignallingSink(theSink.rundata->subwoofer.dev_id); /* determine if subwoofer is available */ if(sink) { LP_DEBUG(("LP: SetLinkPolicy Swat\n" )); ConnectionSetLinkPolicy(sink, 2 , lp_powertable_subwoofer); } else { /* no swat link */ LP_DEBUG(("LP: SetLinkPolicy Swat - no link\n" )); } #endif }
/**************************************************************************** NAME linkPolicyUseA2dpSettings DESCRIPTION set the link policy requirements based on current device audio state RETURNS void */ void linkPolicyUseA2dpSettings(uint16 DeviceId, uint16 StreamId, Sink sink ) { Sink sinkAG1,sinkAG2 = NULL; bool faster_poll = FALSE; /* obtain any sco sinks */ HfpLinkGetAudioSink(hfp_primary_link, &sinkAG1); HfpLinkGetAudioSink(hfp_secondary_link, &sinkAG2); /* determine if the connection is currently streaming and there are no scos currently open */ if ((!sinkAG1 && !sinkAG2) && (A2dpMediaGetState(DeviceId, StreamId) == a2dp_stream_streaming)) { /* is there a user power table available from ps ? */ if((theSink.user_power_table) && (theSink.user_power_table->A2DPStreamEntries)) { LP_DEBUG(("LP: SetLinkP - A2dp user table \n")) /* User supplied power table for A2DP role */ ConnectionSetLinkPolicy(sink, theSink.user_power_table->A2DPStreamEntries , &theSink.user_power_table->powertable[ theSink.user_power_table->normalEntries + theSink.user_power_table->SCOEntries ] ); } /* no user power table so use default A2DP table */ else { if (A2dpMediaGetRole(DeviceId, StreamId) == a2dp_source) { LP_DEBUG(("LP: SetLinkP - A2dp default source table \n" )); ConnectionSetLinkPolicy(sink, 1 ,lp_powertable_a2dp_stream_source); faster_poll = TRUE; } else { LP_DEBUG(("LP: SetLinkP - A2dp default sink table \n" )); ConnectionSetLinkPolicy(sink, 1 ,lp_powertable_a2dp_stream_sink); } } } /* if not streaming a2dp check for the prescence of sco data and if none found go to normal settings */ else if ((!sinkAG1 && !sinkAG2) && (A2dpMediaGetState(DeviceId, StreamId) != a2dp_stream_streaming)) { uint16 priority; if (getA2dpIndex(DeviceId, &priority) && (theSink.a2dp_link_data->peer_device[priority] == remote_device_peer)) { LP_DEBUG(("LP: SetLinkP - a2dp default table \n" )); ConnectionSetLinkPolicy(sink, 2 ,lp_powertable_a2dp_default); } else { /* set normal link policy settings */ linkPolicyUseDefaultSettings(sink); } } #ifdef ENABLE_PEER { /* Set a reasonable poll interval for the relay link to help if we ever get into a */ /* scatternet situation due to an AV SRC refusing to be slave. */ typed_bdaddr tbdaddr; if (A2dpDeviceGetBdaddr(DeviceId, &tbdaddr.addr)) { MESSAGE_MAKE(prim, DM_HCI_QOS_SETUP_REQ_T); prim->common.op_code = DM_HCI_QOS_SETUP_REQ; prim->common.length = sizeof(DM_HCI_QOS_SETUP_REQ_T); prim->bd_addr.lap = tbdaddr.addr.lap; prim->bd_addr.uap = tbdaddr.addr.uap; prim->bd_addr.nap = tbdaddr.addr.nap; /* latency is the only thing used in the request and sets the poll interval */ prim->service_type = HCI_QOS_GUARANTEED; prim->token_rate = 0xffffffff; prim->peak_bandwidth = 0x0000aaaa; prim->latency = faster_poll ? 10000 : 25000; prim->delay_variation = 0xffffffff; DEBUG(("LP: SetLinkP - Set QoS %lums\n",prim->latency)); VmSendDmPrim(prim); } /* Check connection role is suitable too */ linkPolicyGetRole(&sink); } #endif }