From: Kamal Negi Date: Thu, 30 Apr 2015 15:53:06 +0530 Subject: [PATCH] Override IBS settings by reading configuration file Configure the IBS value in Firmware by reading the configuration file.This configuration value is provided in the config file which is read during the firmware download process and the default configuration value is overwritten with this value. Change-Id: I47992a573b3137ac9bfb80538727981f56b328c4 Signed-off-by: Kamal Negi --- tools/hciattach_rome.c | 42 +++++++++++++++++++++++++++++------------- tools/hciattach_rome.h | 24 ++++++++++++++++-------- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/tools/hciattach_rome.c b/tools/hciattach_rome.c index 574ceac6c750..6a3f33867c12 100644 --- a/tools/hciattach_rome.c +++ b/tools/hciattach_rome.c @@ -922,7 +922,8 @@ int rome_get_tlv_file(char *file_path) unsigned char data_buf[PRINT_BUF_SIZE]={0,}; unsigned char *nvm_byte_ptr; unsigned char bdaddr[6]; - unsigned short pcm_value; + unsigned short pcm_value, ibs_value; + fprintf(stderr, "File Open (%s)\n", file_path); pFile = fopen ( file_path , "r" ); if (pFile==NULL) {; @@ -1008,23 +1009,38 @@ int rome_get_tlv_file(char *file_path) *nvm_byte_ptr, *(nvm_byte_ptr+1), *(nvm_byte_ptr+2), *(nvm_byte_ptr+3), *(nvm_byte_ptr+4), *(nvm_byte_ptr+5)); } + + if (nvm_ptr->tag_id == TAG_NUM_17) { + if ((ibs_value = + get_value_from_config(FW_CONFIG_FILE_PATH, "IBS")) >= 0) { + if (ibs_value == FWCONF_IBS_DISABLE) { + nvm_byte_ptr[FWCONF_IBS_VAL_OFFSET] &= + (~(FWCONF_IBS_ENABLE << + FWCONF_IBS_VAL_BIT)); + } else if (ibs_value == FWCONF_IBS_ENABLE) { + nvm_byte_ptr[FWCONF_IBS_VAL_OFFSET] |= + (FWCONF_IBS_ENABLE << + FWCONF_IBS_VAL_BIT); + } + } + } /* Read from file and check what PCM Configuration is required: * Master = 0 /Slave = 1 */ /* Override PCM configuration */ if (nvm_ptr->tag_id == TAG_NUM_44) { if ((pcm_value = - get_value_from_config(PCM_CONFIG_FILE_PATH, "PCM")) >= 0) { - - if (pcm_value == PCM_SLAVE) { - nvm_byte_ptr[PCM_MS_OFFSET_1] |= - (1 << PCM_ROLE_BIT_OFFSET); - nvm_byte_ptr[PCM_MS_OFFSET_2] |= - (1 << PCM_ROLE_BIT_OFFSET); - } else if (pcm_value == PCM_MASTER) { - nvm_byte_ptr[PCM_MS_OFFSET_1] &= - (~(1 << PCM_ROLE_BIT_OFFSET)); - nvm_byte_ptr[PCM_MS_OFFSET_2] &= - (~(1 << PCM_ROLE_BIT_OFFSET)); + get_value_from_config(FW_CONFIG_FILE_PATH, "PCM")) >= 0) { + + if (pcm_value == FWCONF_PCM_SLAVE) { + nvm_byte_ptr[FWCONF_PCM_MS_OFFSET_1] |= + (1 << FWCONF_PCM_ROLE_BIT_OFFSET); + nvm_byte_ptr[FWCONF_PCM_MS_OFFSET_2] |= + (1 << FWCONF_PCM_ROLE_BIT_OFFSET); + } else if (pcm_value == FWCONF_PCM_MASTER) { + nvm_byte_ptr[FWCONF_PCM_MS_OFFSET_1] &= + (~(1 << FWCONF_PCM_ROLE_BIT_OFFSET)); + nvm_byte_ptr[FWCONF_PCM_MS_OFFSET_2] &= + (~(1 << FWCONF_PCM_ROLE_BIT_OFFSET)); } } } diff --git a/tools/hciattach_rome.h b/tools/hciattach_rome.h index 20264f9978d9..8eaeeed8bc96 100644 --- a/tools/hciattach_rome.h +++ b/tools/hciattach_rome.h @@ -203,16 +203,24 @@ typedef struct #define TAG_END 0xFF #define NVM_ACCESS_SET 0x01 #define TAG_NUM_OFFSET 5 -#define TAG_NUM_2 2 -#define TAG_NUM_44 44 +#define TAG_NUM_2 2 +#define TAG_NUM_17 (17) +#define TAG_NUM_44 44 #define TAG_BDADDR_OFFSET 7 -#define PCM_MS_OFFSET_1 9 -#define PCM_MS_OFFSET_2 33 +/* FW PCM Configuration */ +#define FWCONF_PCM_MS_OFFSET_1 9 +#define FWCONF_PCM_MS_OFFSET_2 33 +#define FWCONF_PCM_SLAVE 1 +#define FWCONF_PCM_MASTER 0 +#define FWCONF_PCM_ROLE_BIT_OFFSET 4 + +/* FW IBS Configuration */ +#define FWCONF_IBS_DISABLE (0) +#define FWCONF_IBS_ENABLE (1) +#define FWCONF_IBS_VAL_BIT (7) +#define FWCONF_IBS_VAL_OFFSET (0) -#define PCM_SLAVE 1 -#define PCM_MASTER 0 -#define PCM_ROLE_BIT_OFFSET 4 #define MAX_RETRY_CNT 1 #define SELECT_TIMEOUT 3 @@ -251,7 +259,7 @@ typedef struct #define ROME_SKIP_EVT_CC 0x02 #define ROME_SKIP_EVT_VSE_CC 0x03 -#define PCM_CONFIG_FILE_PATH "/etc/bluetooth/pcm.conf" +#define FW_CONFIG_FILE_PATH "/etc/bluetooth/firmware.conf" /****************************************************************************** ** Local type definitions ******************************************************************************/