2020-03-31 00:34:42

by Sonny Sasaka

[permalink] [raw]
Subject: [PATCH] tools/hciattach_ath3k: Load BT board data based on country code

BT board data file PS_ASIC-<country-code>.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 <string.h>
#include <ctype.h>
#include <time.h>
+#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/param.h>
@@ -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


2020-04-03 13:54:17

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] tools/hciattach_ath3k: Load BT board data based on country code

Hi Sonny,

> BT board data file PS_ASIC-<country-code>.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(-)

while we can fix parts of hciattach, but I rather remove that tool at some point.

Do you still require it with serdev kernel support? I mean all UART based Bluetooth controllers should be handled via serdev.

Regards

Marcel

2020-04-03 16:43:14

by Sonny Sasaka

[permalink] [raw]
Subject: Re: [PATCH] tools/hciattach_ath3k: Load BT board data based on country code

Hi Marcel,

Thanks for your feedback. I will take note of this deprecation plan.
For now, Chromium OS can have a local patch to accomplish this and in
the future we will migrate to serdev instead of hciattach.

On Fri, Apr 3, 2020 at 6:53 AM Marcel Holtmann <[email protected]> wrote:
>
> Hi Sonny,
>
> > BT board data file PS_ASIC-<country-code>.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(-)
>
> while we can fix parts of hciattach, but I rather remove that tool at some point.
>
> Do you still require it with serdev kernel support? I mean all UART based Bluetooth controllers should be handled via serdev.
>
> Regards
>
> Marcel
>

2020-04-03 16:58:40

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] tools/hciattach_ath3k: Load BT board data based on country code

Hi Sonny,

> Thanks for your feedback. I will take note of this deprecation plan.
> For now, Chromium OS can have a local patch to accomplish this and in
> the future we will migrate to serdev instead of hciattach.

I can apply the patch if you are still using it, but be aware of that fact that we are going to kill hciattach latest when we move to the 6.x major version number.

Using serdev is a lot better, cleaner and simpler in the end. So I would urge to make that change rather sooner than later.

In addition, I would really like to kill hci_uart.ko driver as well. That one has become a beast with a bunch of hacks that will eventually backfire. Since we have serdev now, I think each vendor should get their own driver. I have posted examples to btuart.ko and bt3wire.ko drivers that could be used as base.

Regards

Marcel

2020-04-03 17:19:56

by Sonny Sasaka

[permalink] [raw]
Subject: Re: [PATCH] tools/hciattach_ath3k: Load BT board data based on country code

Hi Marcel,

There is no need to apply the patch. I sent the patch because I didn't
know of the deprecation plan. Thank you for the feedback.

On Fri, Apr 3, 2020 at 9:56 AM Marcel Holtmann <[email protected]> wrote:
>
> Hi Sonny,
>
> > Thanks for your feedback. I will take note of this deprecation plan.
> > For now, Chromium OS can have a local patch to accomplish this and in
> > the future we will migrate to serdev instead of hciattach.
>
> I can apply the patch if you are still using it, but be aware of that fact that we are going to kill hciattach latest when we move to the 6.x major version number.
>
> Using serdev is a lot better, cleaner and simpler in the end. So I would urge to make that change rather sooner than later.
>
> In addition, I would really like to kill hci_uart.ko driver as well. That one has become a beast with a bunch of hacks that will eventually backfire. Since we have serdev now, I think each vendor should get their own driver. I have posted examples to btuart.ko and bt3wire.ko drivers that could be used as base.
>
> Regards
>
> Marcel
>

2020-04-03 17:58:50

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] tools/hciattach_ath3k: Load BT board data based on country code

Hi Sonny,

> There is no need to apply the patch. I sent the patch because I didn't
> know of the deprecation plan. Thank you for the feedback.

actually I did apply the patch. I really dislike if distribution carry too many patches. Just remember that this tool will go away eventually. So make a plan to upgrade to serdev.

Regards

Marcel

2020-04-03 18:03:41

by Sonny Sasaka

[permalink] [raw]
Subject: Re: [PATCH] tools/hciattach_ath3k: Load BT board data based on country code

Hi Marcel,

Ack, thanks.

On Fri, Apr 3, 2020 at 10:58 AM Marcel Holtmann <[email protected]> wrote:
>
> Hi Sonny,
>
> > There is no need to apply the patch. I sent the patch because I didn't
> > know of the deprecation plan. Thank you for the feedback.
>
> actually I did apply the patch. I really dislike if distribution carry too many patches. Just remember that this tool will go away eventually. So make a plan to upgrade to serdev.
>
> Regards
>
> Marcel
>