Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: mt7921s: Add .btmtk_get_codec_config_data

add .btmtk_get_codec_config_data to get codec configuration data.

In HFP offload usecase, controllers need to be set codec details before
opening SCO. This callback function is used to fetch vendor specific codec
config data.

This is a preliminary patch to add the WBS support to the MT7921 driver.

Reviewed-by: Mark Chen <markyawenchen@gmail.com>
Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Yake Yang <yake.yang@mediatek.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Yake Yang and committed by
Marcel Holtmann
f41b91fa d786105e

+50
+50
drivers/bluetooth/btmtksdio.c
··· 943 943 return 0; 944 944 } 945 945 946 + static int btmtksdio_get_codec_config_data(struct hci_dev *hdev, 947 + __u8 link, struct bt_codec *codec, 948 + __u8 *ven_len, __u8 **ven_data) 949 + { 950 + int err = 0; 951 + 952 + if (!ven_data || !ven_len) 953 + return -EINVAL; 954 + 955 + *ven_len = 0; 956 + *ven_data = NULL; 957 + 958 + if (link != ESCO_LINK) { 959 + bt_dev_err(hdev, "Invalid link type(%u)", link); 960 + return -EINVAL; 961 + } 962 + 963 + *ven_data = kmalloc(sizeof(__u8), GFP_KERNEL); 964 + if (!ven_data) { 965 + err = -ENOMEM; 966 + goto error; 967 + } 968 + 969 + /* supports only CVSD and mSBC offload codecs */ 970 + switch (codec->id) { 971 + case 0x02: 972 + **ven_data = 0x00; 973 + break; 974 + case 0x05: 975 + **ven_data = 0x01; 976 + break; 977 + default: 978 + err = -EINVAL; 979 + bt_dev_err(hdev, "Invalid codec id(%u)", codec->id); 980 + goto error; 981 + } 982 + /* codec and its capabilities are pre-defined to ids 983 + * preset id = 0x00 represents CVSD codec with sampling rate 8K 984 + * preset id = 0x01 represents mSBC codec with sampling rate 16K 985 + */ 986 + *ven_len = sizeof(__u8); 987 + return err; 988 + 989 + error: 990 + kfree(*ven_data); 991 + *ven_data = NULL; 992 + return err; 993 + } 994 + 946 995 static int btmtksdio_sco_setting(struct hci_dev *hdev) 947 996 { 948 997 const struct btmtk_sco sco_setting = { ··· 1029 980 return err; 1030 981 1031 982 hdev->get_data_path_id = btmtksdio_get_data_path_id; 983 + hdev->get_codec_config_data = btmtksdio_get_codec_config_data; 1032 984 1033 985 return err; 1034 986 }