* [PATCH 3/4] android/hidhost: Move get_report parameter check to daemon
From: Szymon Janc @ 2013-12-30 22:56 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388444180-13683-1-git-send-email-szymon.janc@gmail.com>
HAL library is to be as simple as possible and parameters values should
be verified by daemon for robustness anyway. Move this check to daemon.
---
android/hal-hidhost.c | 15 ++-------------
android/hidhost.c | 10 ++++++++++
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index b331145..371250a 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -268,19 +268,8 @@ static bt_status_t get_report(bt_bdaddr_t *bd_addr,
cmd.id = report_id;
cmd.buf_size = buffer_size;
- switch (report_type) {
- case BTHH_INPUT_REPORT:
- cmd.type = HAL_HIDHOST_INPUT_REPORT;
- break;
- case BTHH_OUTPUT_REPORT:
- cmd.type = HAL_HIDHOST_OUTPUT_REPORT;
- break;
- case BTHH_FEATURE_REPORT:
- cmd.type = HAL_HIDHOST_FEATURE_REPORT;
- break;
- default:
- return BT_STATUS_PARM_INVALID;
- }
+ /* type match IPC type */
+ cmd.type = report_type;
return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_GET_REPORT,
sizeof(cmd), &cmd, 0, NULL, NULL);
diff --git a/android/hidhost.c b/android/hidhost.c
index 76e65b8..1cf85b1 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -991,6 +991,16 @@ static void bt_hid_get_report(const void *buf, uint16_t len)
DBG("");
+ switch (cmd->type) {
+ case HAL_HIDHOST_INPUT_REPORT:
+ case HAL_HIDHOST_OUTPUT_REPORT:
+ case HAL_HIDHOST_FEATURE_REPORT:
+ break;
+ default:
+ status = HAL_STATUS_INVALID;
+ goto failed;
+ }
+
android2bdaddr(&cmd->bdaddr, &dst);
l = g_slist_find_custom(devices, &dst, device_cmp);
--
1.8.5.2
^ permalink raw reply related
* [PATCH 2/4] android/hidhost: Move set_protocol parameter check to daemon
From: Szymon Janc @ 2013-12-30 22:56 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388444180-13683-1-git-send-email-szymon.janc@gmail.com>
HAL library is to be as simple as possible and parameters values should
be verified by daemon for robustness anyway. Move this check to daemon.
---
android/hal-hidhost.c | 12 ++----------
android/hidhost.c | 9 +++++++++
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 5d05f9b..b331145 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -241,16 +241,8 @@ static bt_status_t set_protocol(bt_bdaddr_t *bd_addr,
memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- switch (protocol_mode) {
- case BTHH_REPORT_MODE:
- cmd.mode = HAL_HIDHOST_REPORT_PROTOCOL;
- break;
- case BTHH_BOOT_MODE:
- cmd.mode = HAL_HIDHOST_BOOT_PROTOCOL;
- break;
- default:
- return BT_STATUS_PARM_INVALID;
- }
+ /* type match IPC type */
+ cmd.mode = protocol_mode;
return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST,
HAL_OP_HIDHOST_SET_PROTOCOL,
diff --git a/android/hidhost.c b/android/hidhost.c
index 4635e53..76e65b8 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -935,6 +935,15 @@ static void bt_hid_set_protocol(const void *buf, uint16_t len)
DBG("");
+ switch (cmd->mode) {
+ case HAL_HIDHOST_REPORT_PROTOCOL:
+ case HAL_HIDHOST_BOOT_PROTOCOL:
+ break;
+ default:
+ status = HAL_STATUS_INVALID;
+ goto failed;
+ }
+
android2bdaddr(&cmd->bdaddr, &dst);
l = g_slist_find_custom(devices, &dst, device_cmp);
--
1.8.5.2
^ permalink raw reply related
* [PATCH 1/4] android/hidhost: Move get_protocol parameter check to daemon
From: Szymon Janc @ 2013-12-30 22:56 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
HAL library is to be as simple as possible and parameters values should
be verified by daemon for robustness anyway. Move this check to daemon.
---
android/hal-hidhost.c | 12 ++----------
android/hidhost.c | 9 +++++++++
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
index 6a6b682..5d05f9b 100644
--- a/android/hal-hidhost.c
+++ b/android/hal-hidhost.c
@@ -218,16 +218,8 @@ static bt_status_t get_protocol(bt_bdaddr_t *bd_addr,
memcpy(cmd.bdaddr, bd_addr, sizeof(cmd.bdaddr));
- switch (protocol_mode) {
- case BTHH_REPORT_MODE:
- cmd.mode = HAL_HIDHOST_REPORT_PROTOCOL;
- break;
- case BTHH_BOOT_MODE:
- cmd.mode = HAL_HIDHOST_BOOT_PROTOCOL;
- break;
- default:
- return BT_STATUS_PARM_INVALID;
- }
+ /* type match IPC type */
+ cmd.mode = protocol_mode;
return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST,
HAL_OP_HIDHOST_GET_PROTOCOL,
diff --git a/android/hidhost.c b/android/hidhost.c
index 0e0391a..4635e53 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -880,6 +880,15 @@ static void bt_hid_get_protocol(const void *buf, uint16_t len)
DBG("");
+ switch (cmd->mode) {
+ case HAL_HIDHOST_REPORT_PROTOCOL:
+ case HAL_HIDHOST_BOOT_PROTOCOL:
+ break;
+ default:
+ status = HAL_STATUS_INVALID;
+ goto failed;
+ }
+
android2bdaddr(&cmd->bdaddr, &dst);
l = g_slist_find_custom(devices, &dst, device_cmp);
--
1.8.5.2
^ permalink raw reply related
* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Pavel Machek @ 2013-12-30 22:48 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Pali Rohár,
Ивайло Димитров,
Gustavo F. Padovan, Johan Hedberg, linux-kernel,
linux-bluetooth@vger.kernel.org development, Ville Tervo,
Sebastian Reichel
In-Reply-To: <C8D1F470-7964-4EAC-82E0-D53CF54DE086@holtmann.org>
Hi!
> > +#define NBT_DBG(fmt, arg...) \
> > + pr_debug("%s: " fmt "" , __func__ , ## arg)
> > +
> > +#define NBT_DBG_FW(fmt, arg...) \
> > + pr_debug("%s: " fmt "" , __func__ , ## arg)
> > +
> > +#define NBT_DBG_POWER(fmt, arg...) \
> > + pr_debug("%s: " fmt "" , __func__ , ## arg)
> > +
> > +#define NBT_DBG_TRANSFER(fmt, arg...) \
> > + pr_debug("%s: " fmt "" , __func__ , ## arg)
> > +
> > +#define NBT_DBG_TRANSFER_NF(fmt, arg...) \
> > + pr_debug(fmt "" , ## arg)
> > +
> > +#define NBT_DBG_DMA(fmt, arg...) \
> > + pr_debug("%s: " fmt "" , __func__ , ## arg)
>
>
> I rather not introduce another ton of new debug helpers. Either use the BT_ ones or just spell this out if you need something that is not common.
>
It looks like idea here is that separate macros may be defined out
separately.
That debugging level should not be neccessary these days, so:
Regards,
Pavel
commit 1978475804807d6e17015c8aa53ad5606a82a71c
Author: Pavel <pavel@ucw.cz>
Date: Mon Dec 30 23:47:00 2013 +0100
Remove custom debugging helpers.
Signed-off-by: Pavel Machek <pavel@ucw.cz>
diff --git a/drivers/bluetooth/hci_h4p.h b/drivers/bluetooth/hci_h4p.h
index d1d313b..a2174ea 100644
--- a/drivers/bluetooth/hci_h4p.h
+++ b/drivers/bluetooth/hci_h4p.h
@@ -1,10 +1,8 @@
/*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
*
* Copyright (C) 2005-2008 Nokia Corporation.
*
- * Contact: Ville Tervo <ville.tervo@nokia.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
@@ -48,24 +46,6 @@
#define UART_OMAP_SYSC_NO_IDLE (1 << UART_OMAP_SYSC_IDLEMODE)
#define UART_OMAP_SYSC_SMART_IDLE (2 << UART_OMAP_SYSC_IDLEMODE)
-#define NBT_DBG(fmt, arg...) \
- pr_debug("%s: " fmt "" , __func__ , ## arg)
-
-#define NBT_DBG_FW(fmt, arg...) \
- pr_debug("%s: " fmt "" , __func__ , ## arg)
-
-#define NBT_DBG_POWER(fmt, arg...) \
- pr_debug("%s: " fmt "" , __func__ , ## arg)
-
-#define NBT_DBG_TRANSFER(fmt, arg...) \
- pr_debug("%s: " fmt "" , __func__ , ## arg)
-
-#define NBT_DBG_TRANSFER_NF(fmt, arg...) \
- pr_debug(fmt "" , ## arg)
-
-#define NBT_DBG_DMA(fmt, arg...) \
- pr_debug("%s: " fmt "" , __func__ , ## arg)
-
#define H4P_TRANSFER_MODE 1
#define H4P_SCHED_TRANSFER_MODE 2
#define H4P_ACTIVE_MODE 3
diff --git a/drivers/bluetooth/nokia_core.c b/drivers/bluetooth/nokia_core.c
index 6dbd3b7..85dd106 100644
--- a/drivers/bluetooth/nokia_core.c
+++ b/drivers/bluetooth/nokia_core.c
@@ -54,7 +54,7 @@ static void hci_h4p_set_clk(struct hci_h4p_info *info, int *clock, int enable)
spin_lock_irqsave(&info->clocks_lock, flags);
if (enable && !*clock) {
- NBT_DBG_POWER("Enabling %p\n", clock);
+ BT_DBG("Enabling %p\n", clock);
clk_prepare_enable(info->uart_fclk);
clk_prepare_enable(info->uart_iclk);
if (atomic_read(&info->clk_users) == 0)
@@ -63,7 +63,7 @@ static void hci_h4p_set_clk(struct hci_h4p_info *info, int *clock, int enable)
}
if (!enable && *clock) {
- NBT_DBG_POWER("Disabling %p\n", clock);
+ BT_DBG("Disabling %p\n", clock);
if (atomic_dec_and_test(&info->clk_users))
hci_h4p_store_regs(info);
clk_disable_unprepare(info->uart_fclk);
@@ -114,7 +114,7 @@ static inline void h4p_schedule_pm(struct hci_h4p_info *info)
static void hci_h4p_disable_tx(struct hci_h4p_info *info)
{
- NBT_DBG_POWER("\n");
+ BT_DBG("\n");
if (!info->pm_enabled)
return;
@@ -130,7 +130,7 @@ static void hci_h4p_disable_tx(struct hci_h4p_info *info)
void hci_h4p_enable_tx(struct hci_h4p_info *info)
{
unsigned long flags;
- NBT_DBG_POWER("\n");
+ BT_DBG("\n");
if (!info->pm_enabled)
return;
@@ -197,7 +197,7 @@ int hci_h4p_send_alive_packet(struct hci_h4p_info *info)
unsigned long flags;
int len;
- NBT_DBG("Sending alive packet\n");
+ BT_DBG("Sending alive packet\n");
len = H4_TYPE_SIZE + sizeof(*hdr) + sizeof(*pkt);
skb = bt_skb_alloc(len, GFP_KERNEL);
@@ -217,7 +217,7 @@ int hci_h4p_send_alive_packet(struct hci_h4p_info *info)
UART_IER_THRI);
spin_unlock_irqrestore(&info->lock, flags);
- NBT_DBG("Alive packet sent\n");
+ BT_DBG("Alive packet sent\n");
return 0;
}
@@ -228,7 +228,7 @@ static void hci_h4p_alive_packet(struct hci_h4p_info *info,
struct hci_h4p_alive_hdr *hdr;
struct hci_h4p_alive_pkt *pkt;
- NBT_DBG("Received alive packet\n");
+ BT_DBG("Received alive packet\n");
hdr = (struct hci_h4p_alive_hdr *)skb->data;
if (hdr->dlen != sizeof(*pkt)) {
dev_err(info->dev, "Corrupted alive message\n");
@@ -256,7 +256,7 @@ static int hci_h4p_send_negotiation(struct hci_h4p_info *info)
int err, len;
u16 sysclk;
- NBT_DBG("Sending negotiation..\n");
+ BT_DBG("Sending negotiation..\n");
switch (info->bt_sysclk) {
case 1:
@@ -326,7 +326,7 @@ static int hci_h4p_send_negotiation(struct hci_h4p_info *info)
if (info->init_error < 0)
return info->init_error;
- NBT_DBG("Negotiation succesful\n");
+ BT_DBG("Negotiation succesful\n");
return 0;
}
@@ -448,14 +448,14 @@ static inline void hci_h4p_recv_frame(struct hci_h4p_info *info,
}
if (!test_bit(HCI_UP, &info->hdev->flags)) {
- NBT_DBG("fw_event\n");
+ BT_DBG("fw_event\n");
hci_h4p_parse_fw_event(info, skb);
return;
}
}
hci_recv_frame(skb);
- NBT_DBG("Frame sent to upper layer\n");
+ BT_DBG("Frame sent to upper layer\n");
}
static inline void hci_h4p_handle_byte(struct hci_h4p_info *info, u8 byte)
@@ -514,8 +514,8 @@ static void hci_h4p_rx_tasklet(unsigned long data)
u8 byte;
struct hci_h4p_info *info = (struct hci_h4p_info *)data;
- NBT_DBG("tasklet woke up\n");
- NBT_DBG_TRANSFER("rx_tasklet woke up\ndata ");
+ BT_DBG("tasklet woke up\n");
+ BT_DBG("rx_tasklet woke up\ndata ");
while (hci_h4p_inb(info, UART_LSR) & UART_LSR_DR) {
byte = hci_h4p_inb(info, UART_RX);
@@ -535,7 +535,7 @@ static void hci_h4p_rx_tasklet(unsigned long data)
info->rx_skb->dev = (void *)info->hdev;
}
info->hdev->stat.byte_rx++;
- NBT_DBG_TRANSFER_NF("0x%.2x ", byte);
+ pr_debug("0x%.2x ", byte);
hci_h4p_handle_byte(info, byte);
}
@@ -551,8 +551,8 @@ static void hci_h4p_rx_tasklet(unsigned long data)
}
finish_rx:
- NBT_DBG_TRANSFER_NF("\n");
- NBT_DBG("rx_ended\n");
+ pr_debug("\n");
+ BT_DBG("rx_ended\n");
}
static void hci_h4p_tx_tasklet(unsigned long data)
@@ -561,8 +561,8 @@ static void hci_h4p_tx_tasklet(unsigned long data)
struct sk_buff *skb;
struct hci_h4p_info *info = (struct hci_h4p_info *)data;
- NBT_DBG("tasklet woke up\n");
- NBT_DBG_TRANSFER("tx_tasklet woke up\n data ");
+ BT_DBG("tasklet woke up\n");
+ BT_DBG("tx_tasklet woke up\n data ");
if (info->autorts != info->rx_enabled) {
if (hci_h4p_inb(info, UART_LSR) & UART_LSR_TEMT) {
@@ -587,7 +587,7 @@ static void hci_h4p_tx_tasklet(unsigned long data)
skb = skb_dequeue(&info->txq);
if (!skb) {
/* No data in buffer */
- NBT_DBG("skb ready\n");
+ BT_DBG("skb ready\n");
if (hci_h4p_inb(info, UART_LSR) & UART_LSR_TEMT) {
hci_h4p_outb(info, UART_IER,
hci_h4p_inb(info, UART_IER) &
@@ -605,13 +605,13 @@ static void hci_h4p_tx_tasklet(unsigned long data)
/* Copy data to tx fifo */
while (!(hci_h4p_inb(info, UART_OMAP_SSR) & UART_OMAP_SSR_TXFULL) &&
(sent < skb->len)) {
- NBT_DBG_TRANSFER_NF("0x%.2x ", skb->data[sent]);
+ pr_debug("0x%.2x ", skb->data[sent]);
hci_h4p_outb(info, UART_TX, skb->data[sent]);
sent++;
}
info->hdev->stat.byte_tx += sent;
- NBT_DBG_TRANSFER_NF("\n");
+ pr_debug("\n");
if (skb->len == sent) {
kfree_skb(skb);
} else {
@@ -642,7 +642,7 @@ static irqreturn_t hci_h4p_interrupt(int irq, void *data)
if (iir & UART_IIR_NO_INT)
return IRQ_HANDLED;
- NBT_DBG("In interrupt handler iir 0x%.2x\n", iir);
+ BT_DBG("In interrupt handler iir 0x%.2x\n", iir);
iir &= UART_IIR_ID;
@@ -688,7 +688,7 @@ static irqreturn_t hci_h4p_wakeup_interrupt(int irq, void *dev_inst)
return IRQ_HANDLED;
}
- NBT_DBG_POWER("gpio interrupt %d\n", should_wakeup);
+ BT_DBG("gpio interrupt %d\n", should_wakeup);
/* Check if wee have missed some interrupts */
if (info->rx_enabled == should_wakeup)
@@ -970,7 +970,7 @@ again:
info->alive_cmd_skb = NULL;
set_bit(HCI_RUNNING, &hdev->flags);
- NBT_DBG("hci up and running\n");
+ BT_DBG("hci up and running\n");
return 0;
err_clean:
@@ -1030,7 +1030,7 @@ static int hci_h4p_hci_send_frame(struct sk_buff *skb)
return -ENODEV;
}
- NBT_DBG("dev %p, skb %p\n", hdev, skb);
+ BT_DBG("dev %p, skb %p\n", hdev, skb);
info = hci_get_drvdata(hdev);
@@ -1188,10 +1188,10 @@ static int hci_h4p_probe(struct platform_device *pdev)
info->reset_gpio_shared = bt_plat_data->reset_gpio_shared;
info->bt_sysclk = bt_plat_data->bt_sysclk;
- NBT_DBG("RESET gpio: %d\n", info->reset_gpio);
- NBT_DBG("BTWU gpio: %d\n", info->bt_wakeup_gpio);
- NBT_DBG("HOSTWU gpio: %d\n", info->host_wakeup_gpio);
- NBT_DBG("sysclk: %d\n", info->bt_sysclk);
+ BT_DBG("RESET gpio: %d\n", info->reset_gpio);
+ BT_DBG("BTWU gpio: %d\n", info->bt_wakeup_gpio);
+ BT_DBG("HOSTWU gpio: %d\n", info->host_wakeup_gpio);
+ BT_DBG("sysclk: %d\n", info->bt_sysclk);
init_completion(&info->test_completion);
complete_all(&info->test_completion);
diff --git a/drivers/bluetooth/nokia_fw-bcm.c b/drivers/bluetooth/nokia_fw-bcm.c
index 9c01a6a..0cf8535 100644
--- a/drivers/bluetooth/nokia_fw-bcm.c
+++ b/drivers/bluetooth/nokia_fw-bcm.c
@@ -73,7 +73,7 @@ void hci_h4p_bcm_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb)
}
if (fw_skb->data[1] == 0x01 && fw_skb->data[2] == 0xfc && fw_skb->len >= 10) {
- NBT_DBG_FW("Setting bluetooth address\n");
+ BT_DBG("Setting bluetooth address\n");
err = hci_h4p_bcm_set_bdaddr(info, fw_skb);
if (err < 0) {
kfree_skb(fw_skb);
@@ -99,7 +99,7 @@ int hci_h4p_bcm_send_fw(struct hci_h4p_info *info,
info->fw_error = 0;
- NBT_DBG_FW("Sending firmware\n");
+ BT_DBG("Sending firmware\n");
time = jiffies;
@@ -108,7 +108,7 @@ int hci_h4p_bcm_send_fw(struct hci_h4p_info *info,
if (!skb)
return -ENODATA;
- NBT_DBG_FW("Sending commands\n");
+ BT_DBG("Sending commands\n");
/*
* Disable smart-idle as UART TX interrupts
@@ -135,7 +135,7 @@ int hci_h4p_bcm_send_fw(struct hci_h4p_info *info,
return -EPROTO;
}
- NBT_DBG_FW("Firmware sent in %d msecs\n",
+ BT_DBG("Firmware sent in %d msecs\n",
jiffies_to_msecs(jiffies-time));
hci_h4p_set_auto_ctsrts(info, 0, UART_EFR_RTS);
diff --git a/drivers/bluetooth/nokia_fw-csr.c b/drivers/bluetooth/nokia_fw-csr.c
index 23c5fc5..886b721 100644
--- a/drivers/bluetooth/nokia_fw-csr.c
+++ b/drivers/bluetooth/nokia_fw-csr.c
@@ -53,7 +53,7 @@ int hci_h4p_bc4_send_fw(struct hci_h4p_info *info,
info->fw_error = 0;
- NBT_DBG_FW("Sending firmware\n");
+ BT_DBG("Sending firmware\n");
skb = skb_dequeue(fw_queue);
if (!skb)
@@ -90,7 +90,7 @@ int hci_h4p_bc4_send_fw(struct hci_h4p_info *info,
}
for (count = 1; ; count++) {
- NBT_DBG_FW("Sending firmware command %d\n", count);
+ BT_DBG("Sending firmware command %d\n", count);
init_completion(&info->fw_completion);
skb_queue_tail(&info->txq, skb);
spin_lock_irqsave(&info->lock, flags);
diff --git a/drivers/bluetooth/nokia_fw-ti1273.c b/drivers/bluetooth/nokia_fw-ti1273.c
index 2825504..fd82494 100644
--- a/drivers/bluetooth/nokia_fw-ti1273.c
+++ b/drivers/bluetooth/nokia_fw-ti1273.c
@@ -63,7 +63,7 @@ int hci_h4p_ti1273_send_fw(struct hci_h4p_info *info,
info->fw_error = 0;
- NBT_DBG_FW("Sending firmware\n");
+ BT_DBG("Sending firmware\n");
time = jiffies;
@@ -72,7 +72,7 @@ int hci_h4p_ti1273_send_fw(struct hci_h4p_info *info,
if (!skb)
return -ENODATA;
- NBT_DBG_FW("Sending commands\n");
+ BT_DBG("Sending commands\n");
/* Check if this is bd_address packet */
init_completion(&info->fw_completion);
hci_h4p_smart_idle(info, 0);
@@ -93,7 +93,7 @@ int hci_h4p_ti1273_send_fw(struct hci_h4p_info *info,
return -EPROTO;
}
- NBT_DBG_FW("Firmware sent in %d msecs\n",
+ BT_DBG("Firmware sent in %d msecs\n",
jiffies_to_msecs(jiffies-time));
hci_h4p_set_auto_ctsrts(info, 0, UART_EFR_RTS);
diff --git a/drivers/bluetooth/nokia_fw.c b/drivers/bluetooth/nokia_fw.c
index b3d39f9..f69efd8 100644
--- a/drivers/bluetooth/nokia_fw.c
+++ b/drivers/bluetooth/nokia_fw.c
@@ -38,7 +38,7 @@ static int hci_h4p_open_firmware(struct hci_h4p_info *info,
int err;
fw_pos = 0;
- NBT_DBG_FW("Opening firmware man_id 0x%.2x ver_id 0x%.2x\n",
+ BT_DBG("Opening firmware man_id 0x%.2x ver_id 0x%.2x\n",
info->man_id, info->ver_id);
switch (info->man_id) {
case H4P_ID_TI1271:
diff --git a/drivers/bluetooth/nokia_uart.c b/drivers/bluetooth/nokia_uart.c
index fd94a98..c19b8d2 100644
--- a/drivers/bluetooth/nokia_uart.c
+++ b/drivers/bluetooth/nokia_uart.c
@@ -100,7 +100,7 @@ void hci_h4p_change_speed(struct hci_h4p_info *info, unsigned long speed)
unsigned int divisor;
u8 lcr, mdr1;
- NBT_DBG("Setting speed %lu\n", speed);
+ BT_DBG("Setting speed %lu\n", speed);
if (speed >= 460800) {
divisor = UART_CLOCK / 13 / speed;
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply related
* [PATCH 7/7] android/build: Fix building HAL library on Linux
From: Szymon Janc @ 2013-12-30 22:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388443421-6295-1-git-send-email-szymon.janc@gmail.com>
PLATFORM_SDK_VERSION was not passed while building HAL library on Linux
host resulting in 4.3+ features not being build.
---
android/Makefile.am | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/android/Makefile.am b/android/Makefile.am
index 36210b9..7d9b580 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -59,7 +59,8 @@ android_libhal_internal_la_SOURCES = android/hal.h android/hal-bluetooth.c \
android/hal-log.h \
android/hal-ipc.h android/hal-ipc.c
-android_libhal_internal_la_CPPFLAGS = -I$(srcdir)/android
+android_libhal_internal_la_CPPFLAGS = -I$(srcdir)/android \
+ -DPLATFORM_SDK_VERSION=19
noinst_PROGRAMS += android/haltest
--
1.8.5.2
^ permalink raw reply related
* [PATCH 6/7] android/haltest: Implement missing functions from bluetooth HAL
From: Szymon Janc @ 2013-12-30 22:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388443421-6295-1-git-send-email-szymon.janc@gmail.com>
Implement functions added in Android 4.3+ to Bluetooth HAL.
---
android/client/if-bt.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index 0cd43db..10b79f1 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -797,6 +797,36 @@ static void dut_mode_configure_p(int argc, const char **argv)
EXEC(if_bluetooth->dut_mode_configure, mode);
}
+static void dut_mode_send_p(int argc, const char **argv)
+{
+ haltest_error("not implemented\n");
+}
+
+#if PLATFORM_SDK_VERSION > 17
+static void le_test_mode_p(int argc, const char **argv)
+{
+ haltest_error("not implemented\n");
+}
+#endif
+
+#if PLATFORM_SDK_VERSION > 18
+static void config_hci_snoop_log_p(int argc, const char **argv)
+{
+ uint8_t mode;
+
+ RETURN_IF_NULL(if_bluetooth);
+
+ if (argc <= 2) {
+ haltest_error("No mode specified\n");
+ return;
+ }
+
+ mode = strtol(argv[2], NULL, 0);
+
+ EXEC(if_bluetooth->config_hci_snoop_log, mode);
+}
+#endif
+
static struct method methods[] = {
STD_METHOD(init),
STD_METHOD(cleanup),
@@ -820,6 +850,13 @@ static struct method methods[] = {
STD_METHODCH(ssp_reply, "<address> <ssp_veriant> 1|0 [<passkey>]"),
STD_METHODCH(get_profile_interface, "<profile id>"),
STD_METHODH(dut_mode_configure, "<dut mode>"),
+ STD_METHOD(dut_mode_send),
+#if PLATFORM_SDK_VERSION > 17
+ STD_METHOD(le_test_mode),
+#endif
+#if PLATFORM_SDK_VERSION > 18
+ STD_METHODH(config_hci_snoop_log, "<mode>"),
+#endif
END_METHOD
};
--
1.8.5.2
^ permalink raw reply related
* [PATCH 5/7] android/haltest: Improve EXEC macro robustness
From: Szymon Janc @ 2013-12-30 22:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388443421-6295-1-git-send-email-szymon.janc@gmail.com>
Print info about method being NULL instead of crashing.
---
android/client/if-main.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/android/client/if-main.h b/android/client/if-main.h
index a83f48b..4a5d4cc 100644
--- a/android/client/if-main.h
+++ b/android/client/if-main.h
@@ -147,8 +147,12 @@ const struct method *get_interface_method(const char *iname,
/* Helper macro for executing function on interface and printing BT_STATUS */
#define EXEC(f, ...) \
{ \
- int err = f(__VA_ARGS__); \
- haltest_info("%s: %s\n", #f, bt_status_t2str(err)); \
+ if (f) { \
+ int err = f(__VA_ARGS__); \
+ haltest_info("%s: %s\n", #f, bt_status_t2str(err)); \
+ } else { \
+ haltest_info("%s is NULL\n", #f); \
+ } \
}
/* Helper macro for executing void function on interface */
--
1.8.5.2
^ permalink raw reply related
* [PATCH 4/7] android/hal-bluetooth: Add debug print to config_hci_snoop_log
From: Szymon Janc @ 2013-12-30 22:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388443421-6295-1-git-send-email-szymon.janc@gmail.com>
Improves debugs and make it consistent with other methods.
---
android/hal-bluetooth.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index a95c4ea..7accdcc 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -829,6 +829,8 @@ static int le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t len)
#if PLATFORM_SDK_VERSION > 18
static int config_hci_snoop_log(uint8_t enable)
{
+ DBG("enable %u", enable);
+
if (enable && property_set("ctl.start", SNOOP_SERVICE_NAME) < 0) {
error("Failed to start service %s", SNOOP_SERVICE_NAME);
return BT_STATUS_FAIL;
--
1.8.5.2
^ permalink raw reply related
* [PATCH 3/7] android: Add support for bluetoothd-snoop service in system-emulator
From: Szymon Janc @ 2013-12-30 22:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388443421-6295-1-git-send-email-szymon.janc@gmail.com>
This allows to test bluetoothd-snoop service on Linux host.
---
android/system-emulator.c | 61 +++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 56 insertions(+), 5 deletions(-)
diff --git a/android/system-emulator.c b/android/system-emulator.c
index 611e46e..2dc9ad8 100644
--- a/android/system-emulator.c
+++ b/android/system-emulator.c
@@ -45,6 +45,7 @@
static char exec_dir[PATH_MAX + 1];
static pid_t daemon_pid = -1;
+static pid_t snoop_pid = -1;
static void ctl_start(void)
{
@@ -81,6 +82,47 @@ static void ctl_start(void)
daemon_pid = pid;
}
+static void snoop_start(void)
+{
+ char prg_name[PATH_MAX + 1];
+ char *prg_argv[3];
+ char *prg_envp[1];
+ pid_t pid;
+
+ snprintf(prg_name, sizeof(prg_name), "%s/%s", exec_dir,
+ "bluetoothd-snoop");
+
+ prg_argv[0] = prg_name;
+ prg_argv[1] = "/tmp/btsnoop_hci.log";
+ prg_argv[2] = NULL;
+
+ prg_envp[0] = NULL;
+
+ printf("Starting %s\n", prg_name);
+
+ pid = fork();
+ if (pid < 0) {
+ perror("Failed to fork new process");
+ return;
+ }
+
+ if (pid == 0) {
+ execve(prg_argv[0], prg_argv, prg_envp);
+ exit(0);
+ }
+
+ printf("New process %d created\n", pid);
+
+ snoop_pid = pid;
+}
+
+static void snoop_stop(void)
+{
+ printf("Stoping %s/%s\n", exec_dir, "bluetoothd-snoop");
+
+ kill(snoop_pid, SIGTERM);
+}
+
static void system_socket_callback(int fd, uint32_t events, void *user_data)
{
char buf[4096];
@@ -97,13 +139,20 @@ static void system_socket_callback(int fd, uint32_t events, void *user_data)
printf("Received %s\n", buf);
- if (strcmp(buf, "ctl.start=bluetoothd"))
- return;
+ if (!strcmp(buf, "ctl.start=bluetoothd")) {
+ if (daemon_pid > 0)
+ return;
- if (daemon_pid > 0)
- return;
+ ctl_start();
+ } else if (!strcmp(buf, "ctl.start=bluetoothd-snoop")) {
+ if (snoop_pid > 0)
+ return;
- ctl_start();
+ snoop_start();
+ } else if (!strcmp(buf, "ctl.stop=bluetoothd-snoop")) {
+ if (snoop_pid > 0)
+ snoop_stop();
+ }
}
static void signal_callback(int signum, void *user_data)
@@ -127,6 +176,8 @@ static void signal_callback(int signum, void *user_data)
if (pid == daemon_pid)
daemon_pid = -1;
+ else if (pid == snoop_pid)
+ snoop_pid = -1;
}
break;
}
--
1.8.5.2
^ permalink raw reply related
* [PATCH 2/7] android/hal-bluetooth: Update snoop service name
From: Szymon Janc @ 2013-12-30 22:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1388443421-6295-1-git-send-email-szymon.janc@gmail.com>
Match service name with android snoop binary name. It is more common
to use '-' instead of '_' in the code for binaries name.
---
android/hal-bluetooth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 9f9814a..a95c4ea 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -28,7 +28,7 @@
#include "hal-ipc.h"
#include "hal-utils.h"
-#define SNOOP_SERVICE_NAME "bluetoothd_snoop"
+#define SNOOP_SERVICE_NAME "bluetoothd-snoop"
static const bt_callbacks_t *bt_hal_cbacks = NULL;
--
1.8.5.2
^ permalink raw reply related
* [PATCH 1/7] android: Add HCI snooping tool
From: Szymon Janc @ 2013-12-30 22:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This tool is intended to be run as Android service. It supports
writing HCI snoop data in old btsnoop format only. By default traffic
is stored in /sdcard/btsnoop_hci.log file (can be overridded with
option - mainly for testing on Linux host). Only index 0 is sniffed.
---
.gitignore | 1 +
android/Android.mk | 23 +++++
android/Makefile.am | 6 ++
android/bluetoothd-snoop.c | 219 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 249 insertions(+)
create mode 100644 android/bluetoothd-snoop.c
diff --git a/.gitignore b/.gitignore
index b97546e..1447c90 100644
--- a/.gitignore
+++ b/.gitignore
@@ -109,3 +109,4 @@ android/system-emulator
android/bluetoothd
android/haltest
android/android-tester
+android/bluetoothd-snoop
diff --git a/android/Android.mk b/android/Android.mk
index 7e29899..1720823 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -253,3 +253,26 @@ LOCAL_MODULE_TAGS := debug
LOCAL_MODULE := l2test
include $(BUILD_EXECUTABLE)
+
+#
+# bluetoothd-snoop
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ bluetoothd-snoop.c \
+ ../monitor/mainloop.c \
+ ../src/shared/btsnoop.c \
+
+LOCAL_C_INCLUDES := \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../lib \
+
+LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := bluetoothd-snoop
+
+include $(BUILD_EXECUTABLE)
diff --git a/android/Makefile.am b/android/Makefile.am
index dec81ce..36210b9 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -4,6 +4,12 @@ noinst_PROGRAMS += android/system-emulator
android_system_emulator_SOURCES = android/system-emulator.c \
monitor/mainloop.h monitor/mainloop.c
+noinst_PROGRAMS += android/bluetoothd-snoop
+
+android_bluetoothd_snoop_SOURCES = android/bluetoothd-snoop.c \
+ monitor/mainloop.h monitor/mainloop.c \
+ src/shared/btsnoop.h src/shared/btsnoop.c
+
noinst_PROGRAMS += android/bluetoothd
android_bluetoothd_SOURCES = android/main.c \
diff --git a/android/bluetoothd-snoop.c b/android/bluetoothd-snoop.c
new file mode 100644
index 0000000..02f44e9
--- /dev/null
+++ b/android/bluetoothd-snoop.c
@@ -0,0 +1,219 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "lib/bluetooth.h"
+#include "lib/hci.h"
+#include "lib/mgmt.h"
+
+#include "monitor/mainloop.h"
+#include "src/shared/btsnoop.h"
+
+#define DEAULT_SNOOP_FILE "/sdcard/btsnoop_hci.log"
+
+#define MAX_PACKET_SIZE (1486 + 4)
+
+static struct btsnoop *snoop = NULL;
+static uint8_t monitor_buf[MAX_PACKET_SIZE];
+static int monitor_fd = -1;
+
+static void signal_callback(int signum, void *user_data)
+{
+ switch (signum) {
+ case SIGINT:
+ case SIGTERM:
+ mainloop_quit();
+ break;
+ }
+}
+
+static uint32_t get_flags_from_opcode(uint16_t opcode)
+{
+ switch (opcode) {
+ case BTSNOOP_OPCODE_NEW_INDEX:
+ case BTSNOOP_OPCODE_DEL_INDEX:
+ break;
+ case BTSNOOP_OPCODE_COMMAND_PKT:
+ return 0x02;
+ case BTSNOOP_OPCODE_EVENT_PKT:
+ return 0x03;
+ case BTSNOOP_OPCODE_ACL_TX_PKT:
+ return 0x00;
+ case BTSNOOP_OPCODE_ACL_RX_PKT:
+ return 0x01;
+ case BTSNOOP_OPCODE_SCO_TX_PKT:
+ case BTSNOOP_OPCODE_SCO_RX_PKT:
+ break;
+ }
+
+ return 0xff;
+}
+
+static void data_callback(int fd, uint32_t events, void *user_data)
+{
+ unsigned char control[32];
+ struct mgmt_hdr hdr;
+ struct msghdr msg;
+ struct iovec iov[2];
+
+ if (events & (EPOLLERR | EPOLLHUP)) {
+ mainloop_remove_fd(monitor_fd);
+ return;
+ }
+
+ iov[0].iov_base = &hdr;
+ iov[0].iov_len = MGMT_HDR_SIZE;
+ iov[1].iov_base = monitor_buf;
+ iov[1].iov_len = sizeof(monitor_buf);
+
+ memset(&msg, 0, sizeof(msg));
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 2;
+ msg.msg_control = control;
+ msg.msg_controllen = sizeof(control);
+
+ while (true) {
+ struct cmsghdr *cmsg;
+ struct timeval *tv = NULL;
+ struct timeval ctv;
+ uint16_t opcode, index, pktlen;
+ uint32_t flags;
+ ssize_t len;
+
+ len = recvmsg(monitor_fd, &msg, MSG_DONTWAIT);
+ if (len < 0)
+ break;
+
+ if (len < MGMT_HDR_SIZE)
+ break;
+
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
+ cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ if (cmsg->cmsg_level != SOL_SOCKET)
+ continue;
+
+ if (cmsg->cmsg_type == SCM_TIMESTAMP) {
+ memcpy(&ctv, CMSG_DATA(cmsg), sizeof(ctv));
+ tv = &ctv;
+ }
+ }
+
+ opcode = btohs(hdr.opcode);
+ index = btohs(hdr.index);
+ pktlen = btohs(hdr.len);
+
+ if (index)
+ continue;
+
+ flags = get_flags_from_opcode(opcode);
+ if (flags != 0xff)
+ btsnoop_write(snoop, tv, flags, monitor_buf, pktlen);
+ }
+}
+
+static int open_monitor(const char *path)
+{
+ struct sockaddr_hci addr;
+ int opt = 1;
+
+ snoop = btsnoop_create(path, BTSNOOP_TYPE_HCI);
+ if (!snoop)
+ return -1;
+
+ monitor_fd = socket(AF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC, BTPROTO_HCI);
+ if (monitor_fd < 0)
+ goto failed;
+
+ memset(&addr, 0, sizeof(addr));
+ addr.hci_family = AF_BLUETOOTH;
+ addr.hci_dev = HCI_DEV_NONE;
+ addr.hci_channel = HCI_CHANNEL_MONITOR;
+
+ if (bind(monitor_fd, (struct sockaddr *) &addr, sizeof(addr)) < 0)
+ goto failed_close;
+
+ if (setsockopt(monitor_fd, SOL_SOCKET, SO_TIMESTAMP, &opt, sizeof(opt))
+ < 0)
+ goto failed_close;
+
+ mainloop_add_fd(monitor_fd, EPOLLIN, data_callback, NULL, NULL);
+
+ return 0;
+
+failed_close:
+ close(monitor_fd);
+ monitor_fd = -1;
+
+failed:
+ btsnoop_unref(snoop);
+ snoop = NULL;
+
+ return -1;
+}
+
+static void close_monitor(void)
+{
+ btsnoop_unref(snoop);
+ snoop = NULL;
+
+ close(monitor_fd);
+ monitor_fd = -1;
+}
+
+int main(int argc, char *argv[])
+{
+ const char *path;
+ sigset_t mask;
+
+ if (argc > 1)
+ path = argv[1];
+ else
+ path = DEAULT_SNOOP_FILE;
+
+ mainloop_init();
+
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGINT);
+ sigaddset(&mask, SIGTERM);
+
+ mainloop_set_signal(&mask, signal_callback, NULL, NULL);
+
+ if (open_monitor(path) < 0) {
+ printf("Failed to start bluetoothd_snoop\n");
+ return EXIT_FAILURE;
+ }
+
+ mainloop_run();
+
+ close_monitor();
+
+ return EXIT_SUCCESS;
+}
--
1.8.5.2
^ permalink raw reply related
* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Pavel Machek @ 2013-12-30 22:28 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Pali Rohár,
Ивайло Димитров,
Gustavo F. Padovan, Johan Hedberg, linux-kernel,
linux-bluetooth@vger.kernel.org development, Ville Tervo,
Sebastian Reichel
In-Reply-To: <C8D1F470-7964-4EAC-82E0-D53CF54DE086@holtmann.org>
Hi!
> > +++ b/drivers/bluetooth/hci_h4p/core.c
> > @@ -0,0 +1,1357 @@
> > +/*
> > + * This file is part of hci_h4p bluetooth driver
> > + *
> > + * Copyright (C) 2005-2008 Nokia Corporation.
> > + *
> > + * Contact: Ville Tervo <ville.tervo@nokia.com>
>
> I think you can just remove the contact names since I think nobody of the original authors is still working at Nokia and I bet this emails addresses just do not work anymore.
>
What about this?
commit 3f18ca6cd02a13baf4be9beb89b1470ad1ce008c
Author: Pavel <pavel@ucw.cz>
Date: Mon Dec 30 23:27:21 2013 +0100
Update comments, remove no longer relevant contacts.
Signed-off-by: Pavel Machek <pavel@ucw.cz>
diff --git a/drivers/bluetooth/nokia_core.c b/drivers/bluetooth/nokia_core.c
index a91bd7b..6dbd3b7 100644
--- a/drivers/bluetooth/nokia_core.c
+++ b/drivers/bluetooth/nokia_core.c
@@ -1,10 +1,8 @@
/*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
*
* Copyright (C) 2005-2008 Nokia Corporation.
*
- * Contact: Ville Tervo <ville.tervo@nokia.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
@@ -19,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
+ * Thanks to all the Nokia people that helped with this driver,
+ * including Ville Tervo and Roger Quadros.
*/
#include <linux/module.h>
diff --git a/drivers/bluetooth/nokia_fw-bcm.c b/drivers/bluetooth/nokia_fw-bcm.c
index 390d021..9c01a6a 100644
--- a/drivers/bluetooth/nokia_fw-bcm.c
+++ b/drivers/bluetooth/nokia_fw-bcm.c
@@ -1,10 +1,8 @@
/*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
*
* Copyright (C) 2005-2008 Nokia Corporation.
*
- * Contact: Ville Tervo <ville.tervo@nokia.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
diff --git a/drivers/bluetooth/nokia_fw-csr.c b/drivers/bluetooth/nokia_fw-csr.c
index af880d9..23c5fc5 100644
--- a/drivers/bluetooth/nokia_fw-csr.c
+++ b/drivers/bluetooth/nokia_fw-csr.c
@@ -1,10 +1,8 @@
/*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
*
* Copyright (C) 2005-2008 Nokia Corporation.
*
- * Contact: Ville Tervo <ville.tervo@nokia.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
diff --git a/drivers/bluetooth/nokia_fw-ti1273.c b/drivers/bluetooth/nokia_fw-ti1273.c
index 32e5fa0..2825504 100644
--- a/drivers/bluetooth/nokia_fw-ti1273.c
+++ b/drivers/bluetooth/nokia_fw-ti1273.c
@@ -1,10 +1,8 @@
/*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
*
* Copyright (C) 2009 Nokia Corporation.
*
- * Contact: Ville Tervo <ville.tervo@nokia.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
diff --git a/drivers/bluetooth/nokia_uart.c b/drivers/bluetooth/nokia_uart.c
index 8e0a93c..fd94a98 100644
--- a/drivers/bluetooth/nokia_uart.c
+++ b/drivers/bluetooth/nokia_uart.c
@@ -1,10 +1,8 @@
/*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
*
* Copyright (C) 2005, 2006 Nokia Corporation.
*
- * Contact: Ville Tervo <ville.tervo@nokia.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
diff --git a/include/linux/bluetooth/hci_h4p.h b/include/linux/bluetooth/hci_h4p.h
index daf83fc..30d169d 100644
--- a/include/linux/bluetooth/hci_h4p.h
+++ b/include/linux/bluetooth/hci_h4p.h
@@ -1,10 +1,8 @@
/*
- * This file is part of hci_h4p bluetooth driver
+ * This file is part of Nokia H4P bluetooth driver
*
* Copyright (C) 2010 Nokia Corporation.
*
- * Contact: Roger Quadros <roger.quadros@nokia.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply related
* [PATCH] wilink: mention name of module in help text
From: Pavel Machek @ 2013-12-30 22:19 UTC (permalink / raw)
To: Marcel Holtmann, trivial
Cc: Pali Rohár,
Ивайло Димитров,
Gustavo F. Padovan, Johan Hedberg, linux-kernel,
linux-bluetooth@vger.kernel.org development, Ville Tervo,
Sebastian Reichel
In-Reply-To: <C8D1F470-7964-4EAC-82E0-D53CF54DE086@holtmann.org>
Mention module name in Kconfig.
Signed-off-by: Pavel Machek <pavel@ucw.cz>
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 9d46f23..a53e8c7 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -241,7 +241,7 @@ config BT_WILINK
core driver to communicate with the BT core of the combo chip.
Say Y here to compile support for Texas Instrument's WiLink7 driver
- into the kernel or say M to compile it as module.
+ into the kernel or say M to compile it as module (btwilink).
config BT_NOKIA_H4P
tristate "HCI driver with H4 Nokia extensions"
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply related
* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Pavel Machek @ 2013-12-30 22:18 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Pali Rohár,
Ивайло Димитров,
Gustavo F. Padovan, Johan Hedberg, linux-kernel,
linux-bluetooth@vger.kernel.org development, Ville Tervo,
Sebastian Reichel
In-Reply-To: <C8D1F470-7964-4EAC-82E0-D53CF54DE086@holtmann.org>
Hi!
> > +config BT_HCIH4P
> > + tristate "HCI driver with H4 Nokia extensions"
> > + depends on BT && ARCH_OMAP
>
> Since then we moved away from doing hci_* prefix of drivers since that is misleading. See btusb.ko, btmrvl_sdio.ko etc.
>
> So this might be better named BT_NOK_H4P or BT_NOKIA_H4P and the module named btnok_h4p.ko or btnokia_h4p.ko.
>
Pali, please apply :-).
Pavel
commit b724166911dcdae2c43170ce4040427c00e834e3
Author: Pavel <pavel@ucw.cz>
Date: Mon Dec 30 23:16:25 2013 +0100
Rename nokia h4p driver object to btnokia_h4p.ko.
Signed-off-by: Pavel Machek <pavel@ucw.cz>
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 9d46f23..a53e8c7 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -251,5 +251,5 @@ config BT_NOKIA_H4P
support for H4+ Bluetooth chip with vendor-specific H4 extensions.
Say Y here to compile support for h4 extended devices into the kernel
- or say M to compile it as module (hci_h4p).
+ or say M to compile it as module (btnokia_h4p).
endmenu
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index c286dbe..a5ed271 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -31,7 +31,7 @@ hci_uart-$(CONFIG_BT_HCIUART_ATH3K) += hci_ath.o
hci_uart-$(CONFIG_BT_HCIUART_3WIRE) += hci_h5.o
hci_uart-objs := $(hci_uart-y)
-obj-$(CONFIG_BT_NOKIA_H4P) += hci_h4p.o
-hci_h4p-objs := nokia_core.o nokia_fw.o nokia_uart.o nokia_fw-csr.o \
+obj-$(CONFIG_BT_NOKIA_H4P) += btnokia_h4p.o
+btnokia_h4p-objs := nokia_core.o nokia_fw.o nokia_uart.o nokia_fw-csr.o \
nokia_fw-bcm.o nokia_fw-ti1273.o
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply related
* PATCH hid2hci for CSR 8510 A10
From: Gordon @ 2013-12-30 21:59 UTC (permalink / raw)
To: linux-bluetooth
[-- Attachment #1: Type: text/plain, Size: 551 bytes --]
Hi,
ich had a problem with the Sitecom CNT-524 as described by someone else
here:
http://blog.ruecker.fi/2013/10/06/adventures-in-bluetooth-4-0-part-i/
so i tried to fix that by introducing --mode csr2 for hid2hci
I neither know how to switch back to hid nor how to detect the EALREADY
state, otherwise the patch is very small.
I works on my machine in ubuntu 13.04 with bluez 4.101-0ubuntu8b1 and
said sitecom usb dongle. the patch is against bluez commit
fd00064e0bb2c81e53e9d0b7d22ce919b41dbe60
Could someone please review.
Cheers,
Gordon
[-- Attachment #2: bluez_hid2hci.patch --]
[-- Type: text/x-patch, Size: 2471 bytes --]
diff --git a/tools/hid2hci.1 b/tools/hid2hci.1
index 8c5d520..c6876a3 100644
--- a/tools/hid2hci.1
+++ b/tools/hid2hci.1
@@ -32,7 +32,7 @@ mode and back.
.B --mode= [hid, hci]
Sets the mode to switch the device into
.TP
-.B --method= [csr, logitech-hid, dell]
+.B --method= [csr, csr2, logitech-hid, dell]
Which vendor method to use for switching the device.
.TP
.B --devpath=
diff --git a/tools/hid2hci.c b/tools/hid2hci.c
index 95b4abf..514accc 100644
--- a/tools/hid2hci.c
+++ b/tools/hid2hci.c
@@ -118,6 +118,41 @@ static int usb_switch_csr(int fd, enum mode mode)
return err;
}
+static int usb_switch_csr2(int fd, enum mode mode)
+{
+ int err = 0;
+ struct usbfs_disconnect disconnect;
+ char report[] = { 0x1 , 0x5 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 };
+ switch (mode) {
+ case HCI:
+ //send report as is
+ disconnect.interface = 0;
+ disconnect.flags = USBFS_DISCONNECT_EXCEPT_DRIVER;
+ strcpy(disconnect.driver, "usbfs");
+
+ if (ioctl(fd, USBFS_IOCTL_DISCONNECT, &disconnect) < 0) {
+ fprintf(stderr, "Can't claim interface: %s (%d)\n",
+ strerror(errno), errno);
+ return -1;
+ }
+
+ err = control_message(fd, USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+ USB_REQ_SET_CONFIGURATION, //Set_Report Request
+ 0x01 | (0x03 << 8), //report id: 0x01, report type: feature (0x03)
+ 0, //interface
+ report, sizeof(report), 5000);
+ //unable to detect EALREADY
+ break;
+ case HID:
+ // currently unknown what to do here
+ fprintf(stderr, "csr2: Switching to hid mode is not implemented\n");
+ return -1;
+ break;
+ }
+
+ return err;
+}
+
static int hid_logitech_send_report(int fd, const char *buf, size_t size)
{
struct hiddev_report_info rinfo;
@@ -257,7 +292,7 @@ static void usage(const char *error)
printf("Usage: hid2hci [options]\n"
" --mode= mode to switch to [hid|hci] (default hci)\n"
" --devpath= sys device path\n"
- " --method= method to use to switch [csr|logitech-hid|dell]\n"
+ " --method= method to use to switch [csr|csr2|logitech-hid|dell]\n"
" --help\n\n");
}
@@ -310,6 +345,9 @@ int main(int argc, char *argv[])
if (!strcmp(optarg, "csr")) {
method = METHOD_CSR;
usb_switch = usb_switch_csr;
+ } else if (!strcmp(optarg, "csr2")) {
+ method = METHOD_CSR;
+ usb_switch = usb_switch_csr2;
} else if (!strcmp(optarg, "logitech-hid")) {
method = METHOD_LOGITECH_HID;
} else if (!strcmp(optarg, "dell")) {
^ permalink raw reply related
* Re: [RFC 6/6] android/audio: Add listener thread on the Audio HAL socket
From: Lukasz Rymanowski @ 2013-12-30 20:57 UTC (permalink / raw)
To: Luiz Augusto von Dentz
Cc: Lukasz Rymanowski, linux-bluetooth@vger.kernel.org, Johan Hedberg
In-Reply-To: <CABBYNZK-c_AD2ZkxGs0XE4SkNwGnVxNByv-c-erV9DFJ9mry_w@mail.gmail.com>
Hi Luiz,
On Mon, Dec 30, 2013 at 2:07 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Lukasz,
>
> On Mon, Dec 30, 2013 at 1:40 PM, Lukasz Rymanowski
> <lukasz.rymanowski@tieto.com> wrote:
>> Hi Luiz,
>>
>> On 30 December 2013 12:31, Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote:
>>> Hi Lukasz,
>>>
>>> On Mon, Dec 30, 2013 at 12:17 PM, Lukasz Rymanowski
>>> <lukasz.rymanowski@tieto.com> wrote:
>>>> This patch add thread which is reponsible for listen on audio HAL
>>>> socket, register a2dp endpoint(s) and maintain socket.
>>>> When bluetooth daemon goes down, HAL audio plugin starts to listen on Audio HAL
>>>> socket again.
>>>>
>>>> ---
>>>> android/Makefile.am | 2 +
>>>> android/hal-audio.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>> android/hal-audio.h | 18 +++++++
>>>> 3 files changed, 165 insertions(+)
>>>> create mode 100644 android/hal-audio.h
>>>>
>>>> diff --git a/android/Makefile.am b/android/Makefile.am
>>>> index eaf39bd..bd90c13 100644
>>>> --- a/android/Makefile.am
>>>> +++ b/android/Makefile.am
>>>> @@ -112,6 +112,8 @@ android_libaudio_internal_la_SOURCES = android/hal-audio.c \
>>>>
>>>> android_libaudio_internal_la_CFLAGS = -I$(srcdir)/android
>>>>
>>>> +android_libaudio_internal_la_LDFLAGS = -pthread
>>>> +
>>>> endif
>>>>
>>>> EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
>>>> diff --git a/android/hal-audio.c b/android/hal-audio.c
>>>> index 011a699..0e3bc70 100644
>>>> --- a/android/hal-audio.c
>>>> +++ b/android/hal-audio.c
>>>> @@ -16,18 +16,30 @@
>>>> */
>>>>
>>>> #include <errno.h>
>>>> +#include <pthread.h>
>>>> +#include <poll.h>
>>>> #include <stdio.h>
>>>> #include <stdlib.h>
>>>> #include <string.h>
>>>> +#include <sys/socket.h>
>>>> +#include <sys/un.h>
>>>> +#include <unistd.h>
>>>>
>>>> #include <hardware/audio.h>
>>>> #include <hardware/hardware.h>
>>>>
>>>> +#include "hal-audio.h"
>>>> #include "hal-log.h"
>>>>
>>>> struct a2dp_audio_dev {
>>>> struct audio_hw_device dev;
>>>> struct a2dp_stream_out *stream_out;
>>>> +
>>>> + pthread_t bt_watcher;
>>>> + pthread_mutex_t hal_sk_mutex;
>>>> + pthread_cond_t bt_watcher_cond;
>>>> +
>>>> + int hal_sk;
>>>> };
>>>>
>>>> struct a2dp_stream_out {
>>>> @@ -384,15 +396,135 @@ static int audio_dump(const audio_hw_device_t *device, int fd)
>>>>
>>>> static int audio_close(hw_device_t *device)
>>>> {
>>>> + struct audio_hw_device *dev = (struct audio_hw_device *)device;
>>>> + struct a2dp_audio_dev *a2dp_dev = (struct a2dp_audio_dev *)dev;
>>>> +
>
> Hmm, Im afraid these are not the same pointers as you do *device =
> &a2dp_dev->dev.common; so this will probably cause invalid accesses.
>
Actually this is same pointer and even I could do here direct cast
from hw_device_t to a2dp_audio_dev with some comment why I can do it.
Is that fine?
Also in audio_open(), to make code less confusing, will do *device =
(hw_device_t *)a2dp_dev
Is that fine for you? Not sure how discussion ends or IRC about that
as I had to go.
>>>> DBG("");
>>>> +
>>>> + if (a2dp_dev) {
>>>> + /* TODO: We could try to unregister Endpoint here */
>>>> + shutdown(a2dp_dev->hal_sk, 2);
>>>> +
>>>> + pthread_mutex_lock(&a2dp_dev->hal_sk_mutex);
>>>> + pthread_cond_signal(&a2dp_dev->bt_watcher_cond);
>>>> + pthread_mutex_unlock(&a2dp_dev->hal_sk_mutex);
>>>> +
>>>> + (void) pthread_join(a2dp_dev->bt_watcher, NULL);
>>>> + free(a2dp_dev);
>>>> + }
>>>> +
>>>> free(device);
>>>> return 0;
>>>> }
>>>>
>>>> +static int wait_for_client(void)
>>>> +{
>>>> + struct sockaddr_un addr;
>>>> + int err;
>>>> + int sk;
>>>> + int new_sk;
>>>> +
>>>> + DBG("");
>>>> +
>>>> + sk = socket(PF_LOCAL, SOCK_SEQPACKET, 0);
>>>> + if (sk < 0) {
>>>> + err = errno;
>>>> + error("Failed to create socket: %d (%s)", err, strerror(err));
>>>> + return -1;
>>>> + }
>>>> +
>>>> + memset(&addr, 0, sizeof(addr));
>>>> + addr.sun_family = AF_UNIX;
>>>> +
>>>> + memcpy(addr.sun_path, BLUEZ_AUDIO_HAL_SK_PATH,
>>>> + sizeof(BLUEZ_AUDIO_HAL_SK_PATH));
>>>> +
>>>> + if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
>>>> + err = errno;
>>>> + error("Failed to bind socket: %d (%s)", err, strerror(err));
>>>> + goto error;
>>>> + }
>>>> +
>>>> + if (listen(sk, 1) < 0) {
>>>> + err = errno;
>>>> + error("Failed to bind socket: %d (%s)", err, strerror(err));
>>>> + goto error;
>>>> + }
>>>> +
>>>> + new_sk = accept(sk, NULL, NULL);
>>>> + if (new_sk < 0) {
>>>> + err = errno;
>>>> + error("Failed to accept socket: %d (%s)", err, strerror(err));
>>>> + goto error;
>>>> + }
>>>> +
>>>> + close(sk);
>>>> + return new_sk;
>>>> +
>>>> +error:
>>>> + close(sk);
>>>> + return -1;
>>>> +}
>>>> +
>>>> +static void *bluetoothd_watcher(void *data)
>>>> +{
>>>> + int err;
>>>> + struct a2dp_audio_dev *a2dp_dev = (struct a2dp_audio_dev *)data;
>>>> + struct pollfd pfd;
>>>> + struct timeval now;
>>>> + struct timespec timeout;
>>>> +
>>>> + DBG("");
>>>> +
>>>> + while (1) {
>>>> + a2dp_dev->hal_sk = wait_for_client();
>>>> + if (a2dp_dev->hal_sk < 0) {
>>>> + error("Failed to create listening socket");
>>>> + continue;
>>>> + }
>>>> +
>>>> + DBG("Audio IPC: Connected");
>>>> +
>>>> + /* TODO: Register ENDPOINT here */
>>>> +
>>>> + memset(&pfd, 0, sizeof(pfd));
>>>> + pfd.fd = a2dp_dev->hal_sk;
>>>> + pfd.events = POLLHUP | POLLERR | POLLNVAL;
>>>> +
>>>> + pthread_mutex_lock(&a2dp_dev->hal_sk_mutex);
>>>> +
>>>> + /* Check if socket is still alive */
>>>> + err = poll(&pfd, 1, -1);
>>>> + if (pfd.revents & (POLLHUP | POLLERR | POLLNVAL)) {
>>>> + info("Audio HAL: Socket closed");
>>>> + a2dp_dev->hal_sk = -1;
>>>> + }
>>>> +
>>>> + /* Maybe audio system is closing and audio_close() has been called? */
>>>> + gettimeofday(&now, NULL);
>>>> + timeout.tv_sec = now.tv_sec;
>>>> + timeout.tv_nsec = now.tv_usec * 1000;
>>>> + timeout.tv_sec += 1;
>>>> +
>>>> + err = pthread_cond_timedwait(&a2dp_dev->bt_watcher_cond,
>>>> + &a2dp_dev->hal_sk_mutex, &timeout);
>>>> +
>>>> + pthread_mutex_unlock(&a2dp_dev->hal_sk_mutex);
>>>> + if (err != ETIMEDOUT)
>>>> + /* Seems that device has been closed */
>>>> + break;
>>>> + }
>>>> +
>>>> + info("Closing bluetooth_watcher thread");
>>>> + pthread_exit(NULL);
>>>> + return NULL;
>>>> +}
>>>> +
>>>> static int audio_open(const hw_module_t *module, const char *name,
>>>> hw_device_t **device)
>>>> {
>>>> struct a2dp_audio_dev *a2dp_dev;
>>>> + int err;
>>>>
>>>> DBG("");
>>>>
>>>> @@ -427,6 +559,19 @@ static int audio_open(const hw_module_t *module, const char *name,
>>>>
>>>> *device = &a2dp_dev->dev.common;
>>>>
>>>> + a2dp_dev->hal_sk = -1;
>>>> +
>>>> + pthread_mutex_init(&a2dp_dev->hal_sk_mutex, NULL);
>>>> + pthread_cond_init(&a2dp_dev->bt_watcher_cond, NULL);
>>>> +
>>>> + err = pthread_create(&a2dp_dev->bt_watcher, NULL, bluetoothd_watcher, a2dp_dev);
>>>> + if (err < 0) {
>>>> + a2dp_dev->bt_watcher = 0;
>>>> + error("Failed to start bluetoothd watcher thread: %d (%s)", -err,
>>>> + strerror(-err));
>>>> + return (-err);
>>>> + }
>>>> +
>>>> return 0;
>>>> }
>>>>
>>>> diff --git a/android/hal-audio.h b/android/hal-audio.h
>>>> new file mode 100644
>>>> index 0000000..93e49f6
>>>> --- /dev/null
>>>> +++ b/android/hal-audio.h
>>>> @@ -0,0 +1,18 @@
>>>> +/*
>>>> + *
>>>> + * Copyright (C) 2013 Intel Corporation
>>>> + *
>>>> + * Licensed under the Apache License, Version 2.0 (the "License");
>>>> + * you may not use this file except in compliance with the License.
>>>> + * You may obtain a copy of the License at
>>>> + *
>>>> + * http://www.apache.org/licenses/LICENSE-2.0
>>>> + *
>>>> + * Unless required by applicable law or agreed to in writing, software
>>>> + * distributed under the License is distributed on an "AS IS" BASIS,
>>>> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>>>> + * See the License for the specific language governing permissions and
>>>> + * limitations under the License.
>>>> + *
>>>> + */
>>>> +static const char BLUEZ_AUDIO_HAL_SK_PATH[] = "\0bluez_audio_socket";
>>>> --
>>>> 1.8.4
>>>
>>> Ive started working on the daemon side and should be able to post some
>>> patches today, Im not really sure we are going to need a thread for
>>> command handling since all the commands will be sent by the plugin
>>> side so they can be synchronous, the only problem would be if the
>>> plugin cannot really block even for a short period.
>>>
>>
>> This Thread is only going to be used for accept, endpoint register and
>> then listening for socket close (so we can start listen for connection
>> from new bluetoothd).
>>
>> Commands and response will be handled in main thread (ex.
>> audio_open(), out_write()) and we can block there for a while - no
>> problem with that
>
> Well it seems the init/listen stage needs to be non-blocking so we
> don't interrupt the audio init procedure which may block bluetooth HAL
> to initialized, the endpoint then should be registered whenever
> bluetoothd connects.
>
>
\Łukasz
> --
> Luiz Augusto von Dentz
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [RFC BlueZ 9/9] android: Add hal_audio_ipc_init and hal_audio_ipc_cleanup
From: Lukasz Rymanowski @ 2013-12-30 20:50 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1388406855-8809-9-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Mon, Dec 30, 2013 at 1:34 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> These function initialize the audio IPC in the HAL side.
> ---
> android/hal-audio.c | 9 +++++++++
> android/hal-ipc.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> android/hal-ipc.h | 3 +++
> 3 files changed, 68 insertions(+)
>
> diff --git a/android/hal-audio.c b/android/hal-audio.c
> index 7f4a3f2..2e7dcca 100644
> --- a/android/hal-audio.c
> +++ b/android/hal-audio.c
> @@ -24,6 +24,7 @@
> #include <hardware/hardware.h>
>
> #include "hal-log.h"
> +#include "hal-ipc.h"
>
> static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
> size_t bytes)
> @@ -374,6 +375,9 @@ static int audio_dump(const audio_hw_device_t *device, int fd)
> static int audio_close(hw_device_t *device)
> {
> DBG("");
> +
> + hal_audio_ipc_cleanup();
> +
> free(device);
> return 0;
> }
> @@ -391,6 +395,11 @@ static int audio_open(const hw_module_t *module, const char *name,
> return -EINVAL;
> }
>
> + if (!hal_audio_ipc_init()) {
> + error("Unable to initialize audio IPC");
> + return -ENOTCONN;
> + }
> +
> audio = calloc(1, sizeof(struct audio_hw_device));
> if (!audio)
> return -ENOMEM;
> diff --git a/android/hal-ipc.c b/android/hal-ipc.c
> index b19704a..3a1fcc7 100644
> --- a/android/hal-ipc.c
> +++ b/android/hal-ipc.c
> @@ -38,6 +38,7 @@
>
> static int cmd_sk = -1;
> static int notif_sk = -1;
> +static int audio_sk = -1;
>
> static pthread_mutex_t cmd_sk_mutex = PTHREAD_MUTEX_INITIALIZER;
>
> @@ -449,3 +450,58 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
>
> return BT_STATUS_SUCCESS;
> }
> +
> +bool hal_audio_ipc_init(void)
> +{
> + struct sockaddr_un addr;
> + int sk;
> + int err;
> +
> + sk = socket(AF_LOCAL, SOCK_SEQPACKET, 0);
> + if (sk < 0) {
> + err = errno;
> + error("Failed to create socket: %d (%s)", err,
> + strerror(err));
> + return false;
> + }
> +
> + memset(&addr, 0, sizeof(addr));
> + addr.sun_family = AF_UNIX;
> +
> + memcpy(addr.sun_path, BLUEZ_AUDIO_SK_PATH, sizeof(BLUEZ_AUDIO_SK_PATH));
> +
> + if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
> + err = errno;
> + error("Failed to bind socket: %d (%s)", err, strerror(err));
> + close(sk);
> + return false;
> + }
> +
> + if (listen(sk, 2) < 0) {
Backlog = 1 should be enough here.
> + err = errno;
> + error("Failed to listen on socket: %d (%s)", err,
> + strerror(err));
> + close(sk);
> + return false;
> + }
> +
> + audio_sk = accept_connection(sk);
We can not block audio_open(), so as we discussed on IRC and as I
proposed in my patches, we need to call hal_audio_ipc_init in thread.
> + if (audio_sk < 0) {
> + close(sk);
> + return false;
> + }
> +
> + info("audio connected");
> +
> + close(sk);
> +
> + return true;
> +}
> +
> +void hal_audio_ipc_cleanup(void)
> +{
> + close(audio_sk);
> + audio_sk = -1;
> +
> + shutdown(audio_sk, SHUT_RD);
> +}
> diff --git a/android/hal-ipc.h b/android/hal-ipc.h
> index 2fbf30f..bd1682d 100644
> --- a/android/hal-ipc.h
> +++ b/android/hal-ipc.h
> @@ -30,3 +30,6 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param,
> void hal_ipc_register(uint8_t service, const struct hal_ipc_handler *handlers,
> uint8_t size);
> void hal_ipc_unregister(uint8_t service);
> +
> +bool hal_audio_ipc_init(void);
> +void hal_audio_ipc_cleanup(void);
> --
> 1.8.4.2
>
\Lukasz
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 1/5] android/tester: Add BDADDR set prop fail test case
From: Szymon Janc @ 2013-12-30 15:30 UTC (permalink / raw)
To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth
In-Reply-To: <1388413509-31265-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
Hi Grzegorz,
On Monday 30 December 2013 15:25:05 Grzegorz Kolodziejczyk wrote:
> This adds BDADDR set property fail test case due to only get
> possibility.
> ---
> android/android-tester.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/android/android-tester.c b/android/android-tester.c
> index ee23fff..d7ebc02 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -798,6 +798,17 @@ static const struct generic_data
> .set_property.len = sizeof(setprop_remote_service),
> };
>
> +static bt_bdaddr_t setprop_bdaddr = {
> + .address = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
> +};
> +
> +static const struct generic_data bluetooth_setprop_bdaddr_invalid_test = {
> + .expected_adapter_status = BT_STATUS_FAIL,
> + .set_property.type = BT_PROPERTY_BDADDR,
> + .set_property.val = &setprop_bdaddr,
> + .set_property.len = sizeof(setprop_bdaddr),
> +};
> +
> static const struct generic_data bluetooth_discovery_start_success_test = {
> .expected_hal_cb.discovery_state_changed_cb =
> discovery_start_success_cb,
> @@ -1134,6 +1145,19 @@ static void test_setprop_service_record_invalid(const
> void *test_data) check_expected_status(adapter_status);
> }
>
> +static void test_setprop_bdaddr_invalid(const void *test_data)
> +{
> + struct test_data *data = tester_get_data();
> + const struct generic_data *test = data->test_data;
> + const bt_property_t *prop = &test->expected_property;
> + bt_status_t adapter_status;
> +
> + init_test_conditions(data);
> +
> + adapter_status = data->if_bluetooth->set_adapter_property(prop);
> + check_expected_status(adapter_status);
> +}
> +
> static void test_discovery_start_success(const void *test_data)
> {
> struct test_data *data = tester_get_data();
> @@ -1693,6 +1717,11 @@ int main(int argc, char *argv[])
> setup_enabled_adapter,
> test_setprop_service_record_invalid, teardown);
>
> + test_bredrle("Bluetooth Set BDADDR - Invalid",
> + &bluetooth_setprop_bdaddr_invalid_test,
> + setup_enabled_adapter,
> + test_setprop_bdaddr_invalid, teardown);
> +
> test_bredrle("Bluetooth BREDR Discovery Start - Success",
> &bluetooth_discovery_start_success_test,
> setup_enabled_adapter,
All patches applied, thanks.
--
Szymon K. Janc
szymon.janc@gmail.com
^ permalink raw reply
* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Sebastian Reichel @ 2013-12-30 14:52 UTC (permalink / raw)
To: Pali Rohár
Cc: Marcel Holtmann,
Ивайло Димитров,
Gustavo F. Padovan, Johan Hedberg, Pavel Machek, linux-kernel,
linux-bluetooth@vger.kernel.org development
In-Reply-To: <201312301531.29768@pali>
[-- Attachment #1: Type: text/plain, Size: 3112 bytes --]
Hi,
On Mon, Dec 30, 2013 at 03:31:25PM +0100, Pali Rohár wrote:
> [...] I think that correct commit message is not needed now.
Please add patch descriptions as early as possible. Patches without
descriptions are anoying for misc. reasons. It's not too much work
to do and helps everyone to understand what's going on. Especially
if the patch gets forgotten for some reason and somebody wants to
pick it up at a later time.
Wolfram Sang gave a talk about that at 30C3 yesterday. Official
recordings of his talk are not yet ready, but the live stream
has been recorded and uploaded to youtube:
http://www.youtube.com/watch?v=DjI7IFbvU0s (starting at 14:30)
> > > diff --git a/drivers/bluetooth/Kconfig
> > > b/drivers/bluetooth/Kconfig index 11a6104..95155c3 100644
> > > --- a/drivers/bluetooth/Kconfig
> > > +++ b/drivers/bluetooth/Kconfig
> > > @@ -242,4 +242,14 @@ config BT_WILINK
> > >
> > > Say Y here to compile support for Texas Instrument's
> > > WiLink7 driver into the kernel or say M to compile it as
> > > module.
> > >
> > > +
> > > +config BT_HCIH4P
> > > + tristate "HCI driver with H4 Nokia extensions"
> > > + depends on BT && ARCH_OMAP
> >
> > Since then we moved away from doing hci_* prefix of drivers
> > since that is misleading. See btusb.ko, btmrvl_sdio.ko etc.
> >
> > So this might be better named BT_NOK_H4P or BT_NOKIA_H4P and
> > the module named btnok_h4p.ko or btnokia_h4p.ko.
> >
> > I still never understood what “p” was for.
> >
>
> I do not know too, I did not invent that name. I just copied
> kernel driver from nokia kernel and patched it to work with 3.12.
>
> Maybe 'p' means plus (+) as H4+.
AFAIR there is a H4+ reference in the code, so I also guess H4P =
H4+. Apart from that I assume, that it's meant as a short for "H4
plus some extensions"
> > Can we also make this just depend on some device tree
> > information and not on a specific architecture. I know that
> > this driver is pretty much OMAP specific, but if we want this
> > upstream, we should at least try to make it more generic.
> >
>
> Sebastian, can you look at code how hard is to add DT support?
I already have it on my TODO list.
> > > +MODULE_DESCRIPTION("Bluetooth h4 driver with nokia
> > > extensions"); +MODULE_LICENSE("GPL");
> > > +MODULE_AUTHOR("Ville Tervo");
> > > +MODULE_FIRMWARE(FW_NAME_TI1271_PRELE);
> > > +MODULE_FIRMWARE(FW_NAME_TI1271_LE);
> > > +MODULE_FIRMWARE(FW_NAME_TI1271);
> > > +MODULE_FIRMWARE(FW_NAME_BCM2048);
> > > +MODULE_FIRMWARE(FW_NAME_CSR);
> >
> > Do we actually have all these firmware files still available.
> > If not, then focus on the ones we have.
>
> Firmware files are available for download from nemo project:
>
> https://api.merproject.org/public/source/nemo:devel:hw:ti:omap3:n900/bcm-bt-firmware/bcm-bt-firmware-0.21rc3.tar.bz2
> https://api.merproject.org/public/source/nemo:devel:hw:ti:omap3:n950-n9/ti-wl1273-bt-firmware/bt-firmware-ti1273_0.23+0m6.tar.gz
Would be nice to have them added to the linux-firmware.git.
-- Sebastian
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply
* [PATCH] tools/bluetooth-player: Formatting commands
From: Sebastian Chlad @ 2013-12-30 14:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sebastian Chlad
In-Reply-To: <1388153434-8459-1-git-send-email-sebastianx.chlad@intel.com>
Formatting commands passed to bluetooth player.
Whitespace character trimmed.
---
tools/bluetooth-player.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/bluetooth-player.c b/tools/bluetooth-player.c
index 622d391..2afdd17 100644
--- a/tools/bluetooth-player.c
+++ b/tools/bluetooth-player.c
@@ -1080,6 +1080,7 @@ static void rl_handler(char *input)
if (!strlen(input))
goto done;
+ g_strstrip(input);
add_history(input);
argv = g_strsplit(input, " ", -1);
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH v2] Bluetooth: Add hci_h4p driver
From: Pali Rohár @ 2013-12-30 14:31 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Ивайло Димитров,
Gustavo F. Padovan, Johan Hedberg, Pavel Machek, linux-kernel,
linux-bluetooth@vger.kernel.org development, Sebastian Reichel
In-Reply-To: <C8D1F470-7964-4EAC-82E0-D53CF54DE086@holtmann.org>
[-- Attachment #1: Type: Text/Plain, Size: 2963 bytes --]
On Saturday 28 December 2013 02:21:23 Marcel Holtmann wrote:
> Hi Pali,
>
> > I'm sending updated version of hci_h4p bluetooth driver. It
> > is needed for Nokia N900 bluetooth hardware. This (v2) is
> > older version of hci_h4p driver, but I tested it with
> > v3.13-rc3 kernel on Nokia N900 and working without any
> > problems. Previous (v1) version had some problems. So for
> > future development please use this (v2) version of hci_h4p
> > driver.
>
> please create a proper commit message explaining this driver.
> Revision updates should go between the diffstat and the patch
> itself. Use git format-patch and you see what I mean.
>
Ok. First what I wanted was to have working driver with new kernel. I sent it so other people can look at code and fix what is
needed... I think that correct commit message is not needed now.
> > diff --git a/drivers/bluetooth/Kconfig
> > b/drivers/bluetooth/Kconfig index 11a6104..95155c3 100644
> > --- a/drivers/bluetooth/Kconfig
> > +++ b/drivers/bluetooth/Kconfig
> > @@ -242,4 +242,14 @@ config BT_WILINK
> >
> > Say Y here to compile support for Texas Instrument's
> > WiLink7 driver into the kernel or say M to compile it as
> > module.
> >
> > +
> > +config BT_HCIH4P
> > + tristate "HCI driver with H4 Nokia extensions"
> > + depends on BT && ARCH_OMAP
>
> Since then we moved away from doing hci_* prefix of drivers
> since that is misleading. See btusb.ko, btmrvl_sdio.ko etc.
>
> So this might be better named BT_NOK_H4P or BT_NOKIA_H4P and
> the module named btnok_h4p.ko or btnokia_h4p.ko.
>
> I still never understood what “p” was for.
>
I do not know too, I did not invent that name. I just copied
kernel driver from nokia kernel and patched it to work with 3.12.
Maybe 'p' means plus (+) as H4+.
> Can we also make this just depend on some device tree
> information and not on a specific architecture. I know that
> this driver is pretty much OMAP specific, but if we want this
> upstream, we should at least try to make it more generic.
>
Sebastian, can you look at code how hard is to add DT support?
> > +MODULE_DESCRIPTION("Bluetooth h4 driver with nokia
> > extensions"); +MODULE_LICENSE("GPL");
> > +MODULE_AUTHOR("Ville Tervo");
> > +MODULE_FIRMWARE(FW_NAME_TI1271_PRELE);
> > +MODULE_FIRMWARE(FW_NAME_TI1271_LE);
> > +MODULE_FIRMWARE(FW_NAME_TI1271);
> > +MODULE_FIRMWARE(FW_NAME_BCM2048);
> > +MODULE_FIRMWARE(FW_NAME_CSR);
>
> Do we actually have all these firmware files still available.
> If not, then focus on the ones we have.
>
Firmware files are available for download from nemo project:
https://api.merproject.org/public/source/nemo:devel:hw:ti:omap3:n900/bcm-bt-firmware/bcm-bt-firmware-0.21rc3.tar.bz2
https://api.merproject.org/public/source/nemo:devel:hw:ti:omap3:n950-n9/ti-wl1273-bt-firmware/bt-firmware-ti1273_0.23+0m6.tar.gz
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply
* [PATCH 5/5] android/tester: Add TYPE_OF_DEVICE get prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-30 14:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1388413509-31265-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds TYPE_OF_DEVICE get property success test case.
---
android/android-tester.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index c548e35..c89b97a 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -844,6 +844,17 @@ static const struct generic_data bluetooth_getprop_cod_success_test = {
.expected_property.len = sizeof(getprop_cod),
};
+static bt_device_type_t getprop_tod = BT_DEVICE_DEVTYPE_BREDR;
+
+static const struct generic_data bluetooth_getprop_tod_success_test = {
+ .expected_hal_cb.adapter_properties_cb = getprop_success_cb,
+ .expected_cb_count = 1,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+ .expected_property.type = BT_PROPERTY_TYPE_OF_DEVICE,
+ .expected_property.val = &getprop_tod,
+ .expected_property.len = sizeof(getprop_tod),
+};
+
static const struct generic_data bluetooth_discovery_start_success_test = {
.expected_hal_cb.discovery_state_changed_cb =
discovery_start_success_cb,
@@ -1232,6 +1243,19 @@ static void test_getprop_cod_success(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_getprop_tod_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t prop = test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->get_adapter_property(prop.type);
+ check_expected_status(adapter_status);
+}
+
static void test_discovery_start_success(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1811,6 +1835,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_getprop_cod_success, teardown);
+ test_bredrle("Bluetooth Get TYPE_OF_DEVICE - Success",
+ &bluetooth_getprop_tod_success_test,
+ setup_enabled_adapter,
+ test_getprop_tod_success, teardown);
+
test_bredrle("Bluetooth BREDR Discovery Start - Success",
&bluetooth_discovery_start_success_test,
setup_enabled_adapter,
--
1.8.4.2
^ permalink raw reply related
* [PATCH 4/5] android/tester: Add CLASS_OF_DEVICE get prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-30 14:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1388413509-31265-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds CLASS_OF_DEVICE get property success test case.
---
android/android-tester.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 15f427c..c548e35 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -833,6 +833,17 @@ static const struct generic_data
.set_property.len = sizeof(setprop_bonded_devices),
};
+static uint32_t getprop_cod = 0;
+
+static const struct generic_data bluetooth_getprop_cod_success_test = {
+ .expected_hal_cb.adapter_properties_cb = getprop_success_cb,
+ .expected_cb_count = 1,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+ .expected_property.type = BT_PROPERTY_CLASS_OF_DEVICE,
+ .expected_property.val = &getprop_cod,
+ .expected_property.len = sizeof(getprop_cod),
+};
+
static const struct generic_data bluetooth_discovery_start_success_test = {
.expected_hal_cb.discovery_state_changed_cb =
discovery_start_success_cb,
@@ -1208,6 +1219,19 @@ static void test_setprop_bonded_devices_invalid(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_getprop_cod_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t prop = test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->get_adapter_property(prop.type);
+ check_expected_status(adapter_status);
+}
+
static void test_discovery_start_success(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1782,6 +1806,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_bonded_devices_invalid, teardown);
+ test_bredrle("Bluetooth Get CLASS_OF_DEVICE - Success",
+ &bluetooth_getprop_cod_success_test,
+ setup_enabled_adapter,
+ test_getprop_cod_success, teardown);
+
test_bredrle("Bluetooth BREDR Discovery Start - Success",
&bluetooth_discovery_start_success_test,
setup_enabled_adapter,
--
1.8.4.2
^ permalink raw reply related
* [PATCH 3/5] android/tester: Add BONDED_DEVICES set prop fail test case
From: Grzegorz Kolodziejczyk @ 2013-12-30 14:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1388413509-31265-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds BONDED_DEVICES set property fail test case due to only
get possibility.
---
android/android-tester.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 358c58b..15f427c 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -821,6 +821,18 @@ static const struct generic_data
.expected_property.len = sizeof(setprop_scanmode_connectable),
};
+static bt_bdaddr_t setprop_bonded_devices = {
+ .address = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 },
+};
+
+static const struct generic_data
+ bluetooth_setprop_bonded_devices_invalid_test = {
+ .expected_adapter_status = BT_STATUS_FAIL,
+ .set_property.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
+ .set_property.val = &setprop_bonded_devices,
+ .set_property.len = sizeof(setprop_bonded_devices),
+};
+
static const struct generic_data bluetooth_discovery_start_success_test = {
.expected_hal_cb.discovery_state_changed_cb =
discovery_start_success_cb,
@@ -1183,6 +1195,19 @@ static void test_setprop_scanmode_connectable_success(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_bonded_devices_invalid(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
static void test_discovery_start_success(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1752,6 +1777,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_scanmode_connectable_success, teardown);
+ test_bredrle("Bluetooth Set BONDED_DEVICES - Invalid",
+ &bluetooth_setprop_bonded_devices_invalid_test,
+ setup_enabled_adapter,
+ test_setprop_bonded_devices_invalid, teardown);
+
test_bredrle("Bluetooth BREDR Discovery Start - Success",
&bluetooth_discovery_start_success_test,
setup_enabled_adapter,
--
1.8.4.2
^ permalink raw reply related
* [PATCH 2/5] android/tester: Add SCAN_MODE=CONNECTABLE set prop success test case
From: Grzegorz Kolodziejczyk @ 2013-12-30 14:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1388413509-31265-1-git-send-email-grzegorz.kolodziejczyk@tieto.com>
This adds SCAN_MODE property set to CONNECTABLE - success test case.
---
android/android-tester.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index d7ebc02..358c58b 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -809,6 +809,18 @@ static const struct generic_data bluetooth_setprop_bdaddr_invalid_test = {
.set_property.len = sizeof(setprop_bdaddr),
};
+static bt_scan_mode_t setprop_scanmode_connectable = BT_SCAN_MODE_CONNECTABLE;
+
+static const struct generic_data
+ bluetooth_setprop_scanmode_connectable_success_test = {
+ .expected_hal_cb.adapter_properties_cb = getprop_success_cb,
+ .expected_cb_count = 1,
+ .expected_adapter_status = BT_STATUS_SUCCESS,
+ .expected_property.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+ .expected_property.val = &setprop_scanmode_connectable,
+ .expected_property.len = sizeof(setprop_scanmode_connectable),
+};
+
static const struct generic_data bluetooth_discovery_start_success_test = {
.expected_hal_cb.discovery_state_changed_cb =
discovery_start_success_cb,
@@ -1158,6 +1170,19 @@ static void test_setprop_bdaddr_invalid(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_scanmode_connectable_success(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
static void test_discovery_start_success(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1722,6 +1747,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_bdaddr_invalid, teardown);
+ test_bredrle("Bluetooth Set SCAN_MODE CONNECTABLE - Success",
+ &bluetooth_setprop_scanmode_connectable_success_test,
+ setup_enabled_adapter,
+ test_setprop_scanmode_connectable_success, teardown);
+
test_bredrle("Bluetooth BREDR Discovery Start - Success",
&bluetooth_discovery_start_success_test,
setup_enabled_adapter,
--
1.8.4.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox