summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoward Yen <howardyen@google.com>2021-07-10 18:05:13 +0800
committerTreeHugger Robot <treehugger-gerrit@google.com>2021-07-15 10:08:28 +0000
commitcd5901bd98361e2b17204346e8869c9c8c59fd80 (patch)
tree2daa0fe4d021e1c4979440907a92a6443e99c8be
parent981c29604a819b43e97a67975a6deb1aaff906c6 (diff)
downloadaoc-cd5901bd98361e2b17204346e8869c9c8c59fd80.tar.gz
aoc: usb: apply new commands for notifying usb device connection
Replace CMD_USB_CONTROL_NOTIFY_CONN_STAT with CMD_USB_CONTROL_NOTIFY_CONN_STAT_V2 Also replace below new commands: CMD_USB_CONTROL_SET_DCBAA_PTR for aoc_usb_set_dcbaa_ptr() CMD_USB_CONTROL_SET_ISOC_TR_INFO for aoc_usb_set_isoc_tr_info() Bug: 188474265 Bug: 192858107 Test: build and boot pass Change-Id: I6d522f8a11498d394d07e0a47ff039a3114658d5 Signed-off-by: Howard Yen <howardyen@google.com>
-rw-r--r--usb/aoc_usb.h9
-rw-r--r--usb/aoc_usb_dev.c37
-rw-r--r--usb/xhci_hooks_impl_whi.c18
3 files changed, 45 insertions, 19 deletions
diff --git a/usb/aoc_usb.h b/usb/aoc_usb.h
index 89bfb52..780ae0a 100644
--- a/usb/aoc_usb.h
+++ b/usb/aoc_usb.h
@@ -72,7 +72,7 @@ struct aoc_usb_drvdata {
struct notifier_block nb;
long service_timeout;
- bool usb_conn_state;
+ unsigned int usb_conn_state;
};
struct get_dev_ctx_args {
@@ -81,6 +81,13 @@ struct get_dev_ctx_args {
u8 *dev_ctx;
};
+struct conn_stat_args {
+ u16 bus_id;
+ u16 dev_num;
+ u16 slot_id;
+ u32 conn_stat;
+};
+
struct get_isoc_tr_info_args {
u16 ep_id;
u16 dir;
diff --git a/usb/aoc_usb_dev.c b/usb/aoc_usb_dev.c
index ccfae9c..492b687 100644
--- a/usb/aoc_usb_dev.c
+++ b/usb/aoc_usb_dev.c
@@ -124,15 +124,14 @@ static int aoc_usb_set_dcbaa_ptr(struct aoc_usb_drvdata *drvdata,
u64 *aoc_dcbaa_ptr)
{
int ret = 0;
- struct CMD_USB_CONTROL_GET_DCBAA_PTR *cmd;
+ struct CMD_USB_CONTROL_SET_DCBAA_PTR *cmd;
- // TODO(b/192858107): Create a CMD_USB_CONTROL_SET_DCBAA_PTR instead.
- cmd = kzalloc(sizeof(struct CMD_USB_CONTROL_GET_DCBAA_PTR), GFP_KERNEL);
+ cmd = kzalloc(sizeof(struct CMD_USB_CONTROL_SET_DCBAA_PTR), GFP_KERNEL);
if (!cmd)
return -ENOMEM;
AocCmdHdrSet(&cmd->parent,
- CMD_USB_CONTROL_GET_DCBAA_PTR_ID,
+ CMD_USB_CONTROL_SET_DCBAA_PTR_ID,
sizeof(*cmd));
cmd->aoc_dcbaa_ptr = *aoc_dcbaa_ptr;
@@ -178,22 +177,32 @@ static int aoc_usb_setup_done(struct aoc_usb_drvdata *drvdata)
return 0;
}
-static int aoc_usb_notify_conn_stat(struct aoc_usb_drvdata *drvdata, u32 *conn_state)
+static int aoc_usb_notify_conn_stat(struct aoc_usb_drvdata *drvdata, void *data)
{
int ret = 0;
- struct CMD_USB_CONTROL_NOTIFY_CONN_STAT *cmd;
+ struct CMD_USB_CONTROL_NOTIFY_CONN_STAT_V2 *cmd;
+ struct conn_stat_args *args = data;
+
+ if (args->conn_stat)
+ drvdata->usb_conn_state++;
+ else
+ drvdata->usb_conn_state--;
- drvdata->usb_conn_state = *conn_state;
+ dev_dbg(&drvdata->adev->dev, "currently connected usb audio device count = %u\n",
+ drvdata->usb_conn_state);
- cmd = kzalloc(sizeof(struct CMD_USB_CONTROL_NOTIFY_CONN_STAT), GFP_KERNEL);
+ cmd = kzalloc(sizeof(struct CMD_USB_CONTROL_NOTIFY_CONN_STAT_V2), GFP_KERNEL);
if (!cmd)
return -ENOMEM;
AocCmdHdrSet(&cmd->parent,
- CMD_USB_CONTROL_NOTIFY_CONN_STAT_ID,
+ CMD_USB_CONTROL_NOTIFY_CONN_STAT_V2_ID,
sizeof(*cmd));
- cmd->conn_state = *conn_state;
+ cmd->bus_id = args->bus_id;
+ cmd->dev_num = args->dev_num;
+ cmd->slot_id = args->slot_id;
+ cmd->conn_state = args->conn_stat;
ret = aoc_usb_send_command(drvdata, cmd, sizeof(*cmd), cmd, sizeof(*cmd));
if (ret < 0) {
@@ -248,15 +257,14 @@ static int aoc_usb_set_isoc_tr_info(struct aoc_usb_drvdata *drvdata, void *args)
int ret;
struct get_isoc_tr_info_args *tr_info_args =
(struct get_isoc_tr_info_args *)args;
- struct CMD_USB_CONTROL_GET_ISOC_TR_INFO *cmd;
+ struct CMD_USB_CONTROL_SET_ISOC_TR_INFO *cmd;
- // TODO(b/192858107): Create a CMD_USB_CONTROL_SET_ISOC_TR_INFO instead.
- cmd = kzalloc(sizeof(struct CMD_USB_CONTROL_GET_ISOC_TR_INFO), GFP_KERNEL);
+ cmd = kzalloc(sizeof(struct CMD_USB_CONTROL_SET_ISOC_TR_INFO), GFP_KERNEL);
if (!cmd)
return -ENOMEM;
AocCmdHdrSet(&cmd->parent,
- CMD_USB_CONTROL_GET_ISOC_TR_INFO_ID,
+ CMD_USB_CONTROL_SET_ISOC_TR_INFO_ID,
sizeof(*cmd));
cmd->ep_id = tr_info_args->ep_id;
@@ -362,6 +370,7 @@ static int aoc_usb_probe(struct aoc_service_dev *adev)
if (!drvdata->ws)
return -ENOMEM;
+ drvdata->usb_conn_state = 0;
drvdata->service_timeout = msecs_to_jiffies(100);
drvdata->nb.notifier_call = aoc_usb_notify;
register_aoc_usb_notifier(&drvdata->nb);
diff --git a/usb/xhci_hooks_impl_whi.c b/usb/xhci_hooks_impl_whi.c
index d74a18f..8dfa064 100644
--- a/usb/xhci_hooks_impl_whi.c
+++ b/usb/xhci_hooks_impl_whi.c
@@ -113,9 +113,17 @@ static int xhci_setup_done(void)
return 0;
}
-static int xhci_sync_conn_stat(u32 conn_state)
+static int xhci_sync_conn_stat(unsigned int bus_id, unsigned int dev_num, unsigned int slot_id,
+ unsigned int conn_stat)
{
- blocking_notifier_call_chain(&aoc_usb_notifier_list, SYNC_CONN_STAT, &conn_state);
+ struct conn_stat_args args;
+
+ args.bus_id = bus_id;
+ args.dev_num = dev_num;
+ args.slot_id = slot_id;
+ args.conn_stat = conn_stat;
+ blocking_notifier_call_chain(&aoc_usb_notifier_list, SYNC_CONN_STAT, &args);
+
return 0;
}
@@ -313,7 +321,8 @@ static int xhci_udev_notify(struct notifier_block *self, unsigned long action,
USB_OFFLOAD_SIMPLE_AUDIO_ACCESSORY ||
vendor_data->op_mode ==
USB_OFFLOAD_DRAM) {
- xhci_sync_conn_stat(USB_CONNECTED);
+ xhci_sync_conn_stat(udev->bus->busnum, udev->devnum, udev->slot_id,
+ USB_CONNECTED);
}
}
vendor_data->usb_accessory_enabled = false;
@@ -324,7 +333,8 @@ static int xhci_udev_notify(struct notifier_block *self, unsigned long action,
USB_OFFLOAD_SIMPLE_AUDIO_ACCESSORY ||
vendor_data->op_mode ==
USB_OFFLOAD_DRAM)) {
- xhci_sync_conn_stat(USB_DISCONNECTED);
+ xhci_sync_conn_stat(udev->bus->busnum, udev->devnum, udev->slot_id,
+ USB_DISCONNECTED);
}
vendor_data->usb_accessory_enabled = false;
break;