diff options
| author | Kabilan Kannan <kabilank@codeaurora.org> | 2016-12-02 18:25:56 -0800 |
|---|---|---|
| committer | qcabuildsw <qcabuildsw@localhost> | 2016-12-16 16:08:09 -0800 |
| commit | 7cd045f8e88b2eb3af366276a888b177f8b1341a (patch) | |
| tree | fdcc3cc99574bda12a76799d1b1f7443a7c45eb4 | |
| parent | a7d28855c5491a38491f9cf2224c3d8db0d9f373 (diff) | |
qcacmn: Add SAR power limit configuration
There is a regulatory requirement for Specific Absorption
Rate (SAR) whereby the phone transmit power is reduced
when it is determined that the phone is in close
proximity to the body.
Implement a vendor command interface to set SAR power
limts dynamically.
Change-Id: I0a214a2af780e9dd8c381c4e9eaa7d8cab6ef853
CRs-Fixed: 1098102
| -rw-r--r-- | wmi/inc/wmi_unified_api.h | 2 | ||||
| -rw-r--r-- | wmi/inc/wmi_unified_param.h | 32 | ||||
| -rw-r--r-- | wmi/inc/wmi_unified_priv.h | 3 | ||||
| -rw-r--r-- | wmi/src/wmi_unified_api.c | 19 | ||||
| -rw-r--r-- | wmi/src/wmi_unified_tlv.c | 83 |
5 files changed, 139 insertions, 0 deletions
diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index f1d20922d6ca..580edda584ea 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -1277,6 +1277,8 @@ QDF_STATUS wmi_extract_vdev_extd_stats(void *wmi_hdl, void *evt_buf, QDF_STATUS wmi_unified_send_power_dbg_cmd(void *wmi_hdl, struct wmi_power_dbg_params *param); +QDF_STATUS wmi_unified_send_sar_limit_cmd(void *wmi_hdl, + struct sar_limit_cmd_params *params); QDF_STATUS wmi_unified_send_adapt_dwelltime_params_cmd(void *wmi_hdl, struct wmi_adaptive_dwelltime_params * wmi_param); diff --git a/wmi/inc/wmi_unified_param.h b/wmi/inc/wmi_unified_param.h index a219568bc460..6b24fa743abc 100644 --- a/wmi/inc/wmi_unified_param.h +++ b/wmi/inc/wmi_unified_param.h @@ -6616,5 +6616,37 @@ struct encrypt_decrypt_req_params { uint8_t *data; }; +#define MAX_SAR_LIMIT_ROWS_SUPPORTED 64 +/** + * struct sar_limit_cmd_row - sar limts row + * @band_id: Optional param for frequency band + * @chain_id: Optional param for antenna chain id + * @mod_id: Optional param for modulation scheme + * @limit_value: Mandatory param providing power limits in steps of 0.5 dbm + * @validity_bitmap: bitmap of valid optional params in sar_limit_cmd_row struct + */ +struct sar_limit_cmd_row { + uint32_t band_id; + uint32_t chain_id; + uint32_t mod_id; + uint32_t limit_value; + uint32_t validity_bitmap; +}; + +/** + * struct sar_limit_cmd_params - sar limts params + * @sar_enable: flag to enable SAR + * @num_limit_rows: number of items in sar_limits + * @commit_limits: indicates firmware to start apply new SAR values + * @sar_limit_row_list: pointer to array of sar limit rows + */ +struct sar_limit_cmd_params { + uint32_t sar_enable; + uint32_t num_limit_rows; + uint32_t commit_limits; + struct sar_limit_cmd_row *sar_limit_row_list; +}; + + #endif /* _WMI_UNIFIED_PARAM_H_ */ diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 3c376ff0a382..0bafe462c2e8 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -1136,6 +1136,9 @@ QDF_STATUS (*send_fw_test_cmd)(wmi_unified_t wmi_handle, QDF_STATUS (*send_encrypt_decrypt_send_cmd)(wmi_unified_t wmi_handle, struct encrypt_decrypt_req_params *params); + +QDF_STATUS (*send_sar_limit_cmd)(wmi_unified_t wmi_handle, + struct sar_limit_cmd_params *params); }; struct target_abi_version { diff --git a/wmi/src/wmi_unified_api.c b/wmi/src/wmi_unified_api.c index 681748772b50..3d686796b564 100644 --- a/wmi/src/wmi_unified_api.c +++ b/wmi/src/wmi_unified_api.c @@ -6124,6 +6124,25 @@ QDF_STATUS wmi_unified_send_power_dbg_cmd(void *wmi_hdl, } /** + * wmi_unified_send_sar_limit_cmd() - send sar limit cmd to fw + * @wmi_hdl: wmi handle + * @params: sar limit command params + * + * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure + */ +QDF_STATUS wmi_unified_send_sar_limit_cmd(void *wmi_hdl, + struct sar_limit_cmd_params *params) +{ + wmi_unified_t wmi_handle = (wmi_unified_t) wmi_hdl; + + if (wmi_handle->ops->send_sar_limit_cmd) + return wmi_handle->ops->send_sar_limit_cmd( + wmi_handle, + params); + return QDF_STATUS_E_FAILURE; +} + +/** * wmi_unified_encrypt_decrypt_send_cmd() - send encryptdecrypt cmd to fw * @wmi_hdl: wmi handle * @params: encrypt/decrypt params diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index fb3dbdf83bc4..fbf8d68765f6 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -3715,6 +3715,88 @@ QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle, } /** + * send_sar_limit_cmd_tlv() - send sar limit cmd to fw + * @wmi_handle: wmi handle + * @params: sar limit params + * + * Return: QDF_STATUS_SUCCESS for success or error code + */ +static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle, + struct sar_limit_cmd_params *sar_limit_params) +{ + wmi_buf_t buf; + QDF_STATUS qdf_status; + wmi_sar_limits_cmd_fixed_param *cmd; + int i; + uint8_t *buf_ptr; + wmi_sar_limit_cmd_row *wmi_sar_rows_list; + struct sar_limit_cmd_row *sar_rows_list; + uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE; + + len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows; + buf = wmi_buf_alloc(wmi_handle, len); + if (!buf) { + WMI_LOGE("Failed to allocate memory"); + qdf_status = QDF_STATUS_E_NOMEM; + goto end; + } + + buf_ptr = (uint8_t *) wmi_buf_data(buf); + cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr; + WMITLV_SET_HDR(&cmd->tlv_header, + WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param, + WMITLV_GET_STRUCT_TLVLEN + (wmi_sar_limits_cmd_fixed_param)); + cmd->sar_enable = sar_limit_params->sar_enable; + cmd->commit_limits = sar_limit_params->commit_limits; + cmd->num_limit_rows = sar_limit_params->num_limit_rows; + + WMI_LOGD("no of sar rows = %d, len = %d", + sar_limit_params->num_limit_rows, len); + buf_ptr += sizeof(*cmd); + WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, + sizeof(wmi_sar_limit_cmd_row) * + sar_limit_params->num_limit_rows); + if (cmd->num_limit_rows == 0) + goto send_sar_limits; + + wmi_sar_rows_list = (wmi_sar_limit_cmd_row *) + (buf_ptr + WMI_TLV_HDR_SIZE); + sar_rows_list = sar_limit_params->sar_limit_row_list; + + for (i = 0; i < sar_limit_params->num_limit_rows; i++) { + WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header, + WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row, + WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row)); + wmi_sar_rows_list->band_id = sar_rows_list->band_id; + wmi_sar_rows_list->chain_id = sar_rows_list->chain_id; + wmi_sar_rows_list->mod_id = sar_rows_list->mod_id; + wmi_sar_rows_list->limit_value = sar_rows_list->limit_value; + wmi_sar_rows_list->validity_bitmap = + sar_rows_list->validity_bitmap; + WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d", + i, wmi_sar_rows_list->band_id, + wmi_sar_rows_list->chain_id, + wmi_sar_rows_list->mod_id, + wmi_sar_rows_list->limit_value, + wmi_sar_rows_list->validity_bitmap); + sar_rows_list++; + wmi_sar_rows_list++; + } +send_sar_limits: + qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len, + WMI_SAR_LIMITS_CMDID); + + if (QDF_IS_STATUS_ERROR(qdf_status)) { + WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID"); + wmi_buf_free(buf); + } + +end: + return qdf_status; +} + +/** * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw * @wmi_handle: wmi handle * @params: encrypt/decrypt params @@ -12379,6 +12461,7 @@ struct wmi_ops tlv_ops = { .send_power_dbg_cmd = send_power_dbg_cmd_tlv, .send_encrypt_decrypt_send_cmd = send_encrypt_decrypt_send_cmd_tlv, + .send_sar_limit_cmd = send_sar_limit_cmd_tlv, }; #ifdef WMI_TLV_AND_NON_TLV_SUPPORT |
