X-Git-Url: http://www.pilppa.org/gitweb/gitweb.cgi?p=linux-2.6-omap-h63xx.git;a=blobdiff_plain;f=drivers%2Fbluetooth%2Fhci_h4p%2Ffw-ti.c;fp=drivers%2Fbluetooth%2Fhci_h4p%2Ffw-ti.c;h=b98b579bff5601d8b13fad883aee3e3791c81f74;hp=0000000000000000000000000000000000000000;hb=b934c987ee1764eb09b8843a3ee00eabc24bd52c;hpb=14fc69723d3442ef46f8f82b3f481e82f06a346d diff --git a/drivers/bluetooth/hci_h4p/fw-ti.c b/drivers/bluetooth/hci_h4p/fw-ti.c new file mode 100644 index 00000000000..b98b579bff5 --- /dev/null +++ b/drivers/bluetooth/hci_h4p/fw-ti.c @@ -0,0 +1,90 @@ +/* + * This file is part of hci_h4p bluetooth driver + * + * Copyright (C) 2005, 2006 Nokia Corporation. + * + * Contact: Ville Tervo + * + * 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. + * + * 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 + * + */ + +#include + +#include "hci_h4p.h" + +void hci_h4p_brf6150_parse_fw_event(struct hci_h4p_info *info, + struct sk_buff *skb) +{ + struct hci_fw_event *ev; + int err = 0; + + if (bt_cb(skb)->pkt_type != H4_EVT_PKT) { + dev_err(info->dev, "Got non event fw packet.\n"); + err = -EPROTO; + goto ret; + } + + ev = (struct hci_fw_event *)skb->data; + if (ev->hev.evt != HCI_EV_CMD_COMPLETE) { + dev_err(info->dev, "Got non cmd complete fw event\n"); + err = -EPROTO; + goto ret; + } + + if (ev->status != 0) { + dev_err(info->dev, "Got error status from fw command\n"); + err = -EPROTO; + goto ret; + } + +ret: + info->fw_error = err; + complete(&info->fw_completion); +} + +int hci_h4p_brf6150_send_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue) +{ + struct sk_buff *skb; + int err = 0; + + info->fw_error = 0; + + while ((skb = skb_dequeue(fw_queue)) != NULL) { + /* We should allways send word aligned data to h4+ devices */ + if (skb->len % 2) { + err = skb_pad(skb, 1); + } + if (err) + return err; + + init_completion(&info->fw_completion); + skb_queue_tail(&info->txq, skb); + tasklet_schedule(&info->tx_task); + + if (!wait_for_completion_timeout(&info->fw_completion, HZ)) { + dev_err(info->dev, "Timeout while sending brf6150 fw\n"); + return -ETIMEDOUT; + } + + if (info->fw_error) { + dev_err(info->dev, "There was fw_error while sending bfr6150 fw\n"); + return -EPROTO; + } + } + NBT_DBG_FW("Firmware sent\n"); + + return 0; +}