Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2980523ybb; Mon, 30 Mar 2020 17:34:42 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuerXIJj/sLaOzy7N4kxmn0+k+ix+Ix3IE74QNllxrikGFDXZyZ2FDfWjDwFfCLP8jgIHZz X-Received: by 2002:a9d:3a62:: with SMTP id j89mr10303432otc.45.1585614882309; Mon, 30 Mar 2020 17:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585614882; cv=none; d=google.com; s=arc-20160816; b=u8IX4WDHmRLotoSOqa5UItqs4ugBoVH/QpqDkR5txtAijVI938Gyt+XiXPwedv7axK 1mm89UnQvWNMBtIOuux6AIOL2rzJvAjspZ3XxowvdF51a76hiiltxIDssp2rIYdwkeWi WfX/xE7s9twa0kqjlMp0JbkllkZp8YeIV+OjyB5uXiwIDAxPAbqA5FsIWSiIxrghr+Ci KgAD7112rebYUFbzwo7Kv0yiHs2afdG8fEBW/Gu7svddwnFAgPaGXAXnNRYQudZbqhxK fRC8NE2Hy0pUoTdXsq6LWlfAht7pRPiFid71g9kWAl4BFS9A/zjLa/+PgIB3GIgDoGS+ SfFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=3qxZru9KFV/H4CA3I/H9rD3aYl/9PNxkMPKPgwvdbSU=; b=U5wLUM3OklHnVRJXjARX+NbgEdahPWmScZ7rI1qFHWesunL+8I719RkAz/HU12vR/q jt6C6duW8xieUiScBnGjpJHKEy7g+91pzhK5ai//owMttKSyTp6b0qZYdAW2fQMjyRAp 0xVUKqcddn6mjYGb2qIUPectVZaBTlgyx9Zj0VcPF6Ry8Inz+TSiiDheJoceJKUGdOBZ Yywo2ViQIHru9ofSlQVTmd/1vMXQJxwVcts8pu15YxFqqOGNJ/Cy7SUMRu8vw3xqnQBs yI8S50Re58vYaCVUsUxVP8iYQk4SI9zd2FIarH/Vo64Uc3tkgMw85SsjNWMU6rMmnE6G bD2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RsTAlFgt; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m9si4534590otp.239.2020.03.30.17.34.19; Mon, 30 Mar 2020 17:34:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RsTAlFgt; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729398AbgCaAeP (ORCPT + 99 others); Mon, 30 Mar 2020 20:34:15 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:40254 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729299AbgCaAeP (ORCPT ); Mon, 30 Mar 2020 20:34:15 -0400 Received: by mail-pf1-f193.google.com with SMTP id c20so6925059pfi.7 for ; Mon, 30 Mar 2020 17:34:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=3qxZru9KFV/H4CA3I/H9rD3aYl/9PNxkMPKPgwvdbSU=; b=RsTAlFgtIAWcZ4zhL2iNKdHxkeaT9E7D+dL6l1OJ+6rk1NIL72eWzu/WxxKliZgVCq 8kQu5qw1hKyC9DGfkgs1YAXSjMmnU5W5qpM81/lie/9lVlq2c9NbVSGGWlFh0RwrXlbx X8BAfdiEsQcIt1hYixc8RGp/aqP4/+JwRS0SY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3qxZru9KFV/H4CA3I/H9rD3aYl/9PNxkMPKPgwvdbSU=; b=SGFi/h3diAsbZREmbJ52nIYQ9sZL0WQzyv5My9/ZSZjQivHaGAulYnt9HuRK6D5t7m TCsg9jolb8Y6CRE8W/EsBKeWduCd3ocKGwU08LRi1zvv9vmkP5xr4GIUj/q4vbSYh0Cv Vu3VzbOuKGBSEEIo4pWbMYCMESEtsxLR9QCLabu698ENW08xINFcEd/2zZTOV9f0H77d CbPHLrferyfKnHoYlVhOdK4zZi8A1URb79dx8NcF1W0gAQQxvGwkgZH8zngD5kgjC+kc Dk2TSFgr4nX0yp2BaYEeFWn9OFoVxdWb4R23raMRt74DI/Ae/mGa/OagBXDYKtwrolaf EtCg== X-Gm-Message-State: AGi0PubJxxneBXQ5uxXfwIA+crxC4WuzFHK04ahYuvyhnIM28XV4DfVY Rs/Ww2WItpebE3f6/2xRpuxsxvygigY= X-Received: by 2002:aa7:87c1:: with SMTP id i1mr1812154pfo.44.1585614853766; Mon, 30 Mar 2020 17:34:13 -0700 (PDT) Received: from localhost.localdomain (c-73-231-41-185.hsd1.ca.comcast.net. [73.231.41.185]) by smtp.googlemail.com with ESMTPSA id g4sm11170906pfb.169.2020.03.30.17.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 17:34:13 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: yixiang@google.com, caiz@google.com, Sonny Sasaka Subject: [PATCH] tools/hciattach_ath3k: Load BT board data based on country code Date: Mon, 30 Mar 2020 17:33:55 -0700 Message-Id: <20200331003355.14614-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.17.1 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org BT board data file PS_ASIC-.pst is loaded based on country code. If not exist, default BT board data file PS_ASIC.pst would be loaded. This patch doesn't define how to get the country code at the moment, but future patches can supply the country code in the region parameter of get_ps_file_name. --- tools/hciattach_ath3k.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/tools/hciattach_ath3k.c b/tools/hciattach_ath3k.c index d920050f6..eb2a2aeb6 100644 --- a/tools/hciattach_ath3k.c +++ b/tools/hciattach_ath3k.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -573,20 +574,33 @@ static int ps_config_download(int fd, int tag_count) return 0; } -#define PS_ASIC_FILE "PS_ASIC.pst" -#define PS_FPGA_FILE "PS_FPGA.pst" +#define PS_ASIC_FILE_PREFIX "PS_ASIC" +#define PS_FPGA_FILE_PREFIX "PS_FPGA" -static void get_ps_file_name(uint32_t devtype, uint32_t rom_version, - char *path) +static void get_ps_file_name(uint32_t devtype, uint32_t rom_version, char *path, + char *region) { - char *filename; + char *file_prefix; + struct stat st; if (devtype == 0xdeadc0de) - filename = PS_ASIC_FILE; + file_prefix = PS_ASIC_FILE_PREFIX; else - filename = PS_FPGA_FILE; + file_prefix = PS_FPGA_FILE_PREFIX; - snprintf(path, MAXPATHLEN, "%s%x/%s", FW_PATH, rom_version, filename); + if (!region) + goto default_ps_file; + + snprintf(path, MAXPATHLEN, "%s%x/%s-%s.pst", FW_PATH, rom_version, + file_prefix, region); + if (stat(path, &st) == 0) + return; + + perror("PS file with region code not exist, use default PS file\n"); + +default_ps_file: + snprintf(path, MAXPATHLEN, "%s%x/%s.pst", FW_PATH, rom_version, + file_prefix); } #define PATCH_FILE "RamPatch.txt" @@ -823,7 +837,7 @@ static int ath_ps_download(int fd) goto download_cmplete; } - get_ps_file_name(dev_type, rom_version, ps_file); + get_ps_file_name(dev_type, rom_version, ps_file, NULL); get_patch_file_name(dev_type, rom_version, build_version, patch_file); stream = fopen(ps_file, "r"); -- 2.17.1