diff mbox series

tools/hciattach_ath3k: Load BT board data based on country code

Message ID 20200331003355.14614-1-sonnysasaka@chromium.org (mailing list archive)
State Accepted
Delegated to: Marcel Holtmann
Headers show
Series tools/hciattach_ath3k: Load BT board data based on country code | expand

Commit Message

Sonny Sasaka March 31, 2020, 12:33 a.m. UTC
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(-)

Comments

Marcel Holtmann April 3, 2020, 1:53 p.m. UTC | #1
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
Sonny Sasaka April 3, 2020, 4:41 p.m. UTC | #2
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 <marcel@holtmann.org> 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
>
Marcel Holtmann April 3, 2020, 4:56 p.m. UTC | #3
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
Sonny Sasaka April 3, 2020, 5:18 p.m. UTC | #4
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 <marcel@holtmann.org> 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
>
Marcel Holtmann April 3, 2020, 5:58 p.m. UTC | #5
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
Sonny Sasaka April 3, 2020, 6:01 p.m. UTC | #6
Hi Marcel,

Ack, thanks.

On Fri, Apr 3, 2020 at 10:58 AM Marcel Holtmann <marcel@holtmann.org> 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
>
diff mbox series

Patch

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");