Skip to content
This repository has been archived by the owner on Sep 18, 2018. It is now read-only.

Commit

Permalink
Send HCI command using hci_send_command
Browse files Browse the repository at this point in the history
The previous way probably doesn't work because the response ends up
with userspace.
  • Loading branch information
ASerbinski committed Jan 29, 2018
1 parent c8a7b77 commit 2f5ab1a
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions sound/soc/codecs/wilink8.c
Expand Up @@ -17,7 +17,6 @@

#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include <linux/skbuff.h>

static const struct snd_soc_dapm_widget bt_sco_widgets[] = {
SND_SOC_DAPM_INPUT("RX"),
Expand All @@ -33,28 +32,26 @@ static int bt_sco_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *cpu_dai)
{
u8 rate8k = 1;
u8 pcm8k[34] = {0x00, 0x02, 0x01, 0x40, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x21, 0x00, 0x01, 0x10, 0x00, 0x21, 0x00, 0x00, 0x00};
u8 pcm16k[34] = {0x00, 0x04, 0x01, 0x80, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x21, 0x00, 0x01, 0x10, 0x00, 0x21, 0x00, 0x00, 0x00};
u8 *pcm;
struct hci_dev *hdev;

switch (params_rate(params)) {
case 8000:
rate8k = 1;
pcm = pcm8k;
break;
case 16000:
rate8k = 0;
pcm = pcm16k;
break;
default:
dev_err(cpu_dai->dev, "Bad rate: %d\n", params_rate(params));
return -EINVAL;
}

printk("WILINK-PCM Setting rate=%d\n",params_rate(params));
if ((hdev = hci_dev_get(0))){
const u8 pcm8k[34] = {0x00, 0x02, 0x01, 0x40, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x21, 0x00, 0x01, 0x10, 0x00, 0x21, 0x00, 0x00, 0x00};
const u8 pcm16k[34] = {0x00, 0x04, 0x01, 0x80, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x21, 0x00, 0x01, 0x10, 0x00, 0x21, 0x00, 0x00, 0x00};
struct sk_buff *skb = __hci_cmd_sync(hdev, 0xfd06, 34, (rate8k ? pcm8k : pcm16k), HCI_INIT_TIMEOUT);
if (!IS_ERR(skb)) {
kfree_skb(skb);
}
printk("WILINK-PCM Got HCI0, sending VS Command\n");
hci_send_cmd(hdev, 0xfd06, 34, pcm);
}

return 0;
Expand Down

0 comments on commit 2f5ab1a

Please sign in to comment.