Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc83206e authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge changes Ieee5a2d5,I200ad8b4,Ie14ee76a

* changes:
  Remove second action on tBTA_DM_PM_SPEC
  Use system property for sniff idle time in HS
  Use lazy static initialization
parents 3121b79a d7feb1df
Loading
Loading
Loading
Loading
+249 −318

File changed.

Preview size limit exceeded, changes collapsed.

+10 −2
Original line number Diff line number Diff line
@@ -451,7 +451,7 @@ typedef struct {
typedef struct {
  uint8_t allow_mask; /* mask of sniff/hold/park modes to allow */
  uint8_t ssr; /* set SSR on conn open/unpark */
  tBTA_DM_PM_ACTN actn_tbl[BTA_DM_PM_NUM_EVTS][2];
  tBTA_DM_PM_ACTN actn_tbl[BTA_DM_PM_NUM_EVTS];

} tBTA_DM_PM_SPEC;

@@ -470,8 +470,16 @@ typedef struct {

extern const uint16_t bta_service_id_to_uuid_lkup_tbl[];

/* For Insight, PM cfg lookup tables are runtime configurable (to allow tweaking
 * of params for power consumption measurements) */
#ifndef BTE_SIM_APP
#define tBTA_DM_PM_TYPE_QUALIFIER const
#else
#define tBTA_DM_PM_TYPE_QUALIFIER
#endif

extern const tBTA_DM_PM_CFG* p_bta_dm_pm_cfg;
extern const tBTA_DM_PM_SPEC* p_bta_dm_pm_spec;
tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC* get_bta_dm_pm_spec();
extern const tBTM_PM_PWR_MD* p_bta_dm_pm_md;
extern tBTA_DM_SSR_SPEC* p_bta_dm_ssr_spec;

+11 −21
Original line number Diff line number Diff line
@@ -359,7 +359,8 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, uint8_t id,
      break;
  }

  /* if no entries are there for the app_id and subsystem in p_bta_dm_pm_spec*/
  /* if no entries are there for the app_id and subsystem in
   * get_bta_dm_pm_spec()*/
  if (i > p_bta_dm_pm_cfg[0].app_id) {
    LOG_DEBUG("Ignoring power management callback as no service entries exist");
    return;
@@ -380,19 +381,19 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, uint8_t id,
  int index = BTA_DM_PM_SSR0;
  if ((BTA_SYS_CONN_OPEN == status) && p_dev &&
      (p_dev->Info() & BTA_DM_DI_USE_SSR)) {
    index = p_bta_dm_pm_spec[p_bta_dm_pm_cfg[i].spec_idx].ssr;
    index = get_bta_dm_pm_spec()[p_bta_dm_pm_cfg[i].spec_idx].ssr;
  } else if (BTA_ID_AV == id) {
    if (BTA_SYS_CONN_BUSY == status) {
      /* set SSR4 for A2DP on SYS CONN BUSY */
      index = BTA_DM_PM_SSR4;
    } else if (BTA_SYS_CONN_IDLE == status) {
      index = p_bta_dm_pm_spec[p_bta_dm_pm_cfg[i].spec_idx].ssr;
      index = get_bta_dm_pm_spec()[p_bta_dm_pm_cfg[i].spec_idx].ssr;
    }
  }

  /* if no action for the event */
  if (p_bta_dm_pm_spec[p_bta_dm_pm_cfg[i].spec_idx]
          .actn_tbl[status][0]
  if (get_bta_dm_pm_spec()[p_bta_dm_pm_cfg[i].spec_idx]
          .actn_tbl[status]
          .power_mode == BTA_DM_PM_NO_ACTION) {
    if (BTA_DM_PM_SSR0 == index) /* and do not need to set SSR, return. */
      return;
@@ -410,8 +411,8 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, uint8_t id,

  /* if subsystem has no more preference on the power mode remove
 the cb */
  if (p_bta_dm_pm_spec[p_bta_dm_pm_cfg[i].spec_idx]
          .actn_tbl[status][0]
  if (get_bta_dm_pm_spec()[p_bta_dm_pm_cfg[i].spec_idx]
          .actn_tbl[status]
          .power_mode == BTA_DM_PM_NO_PREF) {
    if (j != bta_dm_conn_srvcs.count) {
      bta_dm_conn_srvcs.count--;
@@ -514,7 +515,6 @@ static void bta_dm_pm_set_mode(const RawAddress& peer_addr,
  const tBTA_DM_PM_CFG* p_pm_cfg;
  const tBTA_DM_PM_SPEC* p_pm_spec;
  const tBTA_DM_PM_ACTN* p_act0;
  const tBTA_DM_PM_ACTN* p_act1;
  tBTA_DM_SRVCS* p_srvcs = NULL;
  bool timer_started = false;
  uint8_t timer_idx, available_timer = BTA_DM_PM_MODE_TIMER_MAX;
@@ -547,9 +547,8 @@ static void bta_dm_pm_set_mode(const RawAddress& peer_addr,
      }

      p_pm_cfg = &p_bta_dm_pm_cfg[j];
      p_pm_spec = &p_bta_dm_pm_spec[p_pm_cfg->spec_idx];
      p_act0 = &p_pm_spec->actn_tbl[p_srvcs->state][0];
      p_act1 = &p_pm_spec->actn_tbl[p_srvcs->state][1];
      p_pm_spec = &get_bta_dm_pm_spec()[p_pm_cfg->spec_idx];
      p_act0 = &p_pm_spec->actn_tbl[p_srvcs->state];

      allowed_modes |= p_pm_spec->allow_mask;
      LOG_DEBUG(
@@ -574,15 +573,6 @@ static void bta_dm_pm_set_mode(const RawAddress& peer_addr,
          }
        }
      }
      /* if first preference has already failed, try second preference */
      else if (!(failed_pm & p_act1->power_mode)) {
        pref_modes |= p_act1->power_mode;

        if (p_act1->power_mode > pm_action) {
          pm_action = p_act1->power_mode;
          timeout_ms = p_act1->timeout;
        }
      }
    }
  }

@@ -850,7 +840,7 @@ static void bta_dm_pm_ssr(const RawAddress& peer_addr, const int ssr) {
    for (int j = 1; j <= p_bta_dm_pm_cfg[0].app_id; j++) {
      /* find the associated p_bta_dm_pm_cfg */
      const tBTA_DM_PM_CFG& config = p_bta_dm_pm_cfg[j];
      current_ssr_index = p_bta_dm_pm_spec[config.spec_idx].ssr;
      current_ssr_index = get_bta_dm_pm_spec()[config.spec_idx].ssr;
      if ((config.id == service.id) && ((config.app_id == BTA_ALL_APP_ID) ||
                                        (config.app_id == service.app_id))) {
        LOG_INFO("Found connected service:%s app_id:%d peer:%s spec_name:%s",