/****************************************************************************** * * Copyright (C) 2021-2021 amlogic 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. * ******************************************************************************/ #ifndef AML_COMM_H #define AML_COMM_H #ifdef __cplusplus extern "C" { #endif #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE (!FALSE) #endif #ifndef false #define false 0 #endif #ifndef true #define true (!false) #endif #ifndef ARRAY_SIZE #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #endif /* * LINUX_PUBLIC: default yocto STB/TV * AUDIO_PROJECT: audio buildroot/yocto * ROKU_PROJECT: roku system * CAMERA_PROJECT: camera buildroot */ #if !defined(ROKU_PROJECT) && !defined(AUDIO_PROJECT) && !defined(CAMERA_PROJECT) #define LINUX_PUBLIC #endif #define LOG_TAG "aml_hciattach" #define BT_MAC_LEN 6 #define BT_MAC_BUF_LEN 17 #ifdef ROKU_PROJECT #define AMLBT_NAME "amlbt_name" #define AMLBT_ADDR "addr" #define AMLBT_FW_VER "fw_version" #define AMLBT_INFO_PATH "/tmp/amlbt_info" // nvram path can be saved after power off #else #define AMLBT_NAME "amlbt_name" #define AMLBT_ADDR "addr" #define AMLBT_FW_VER "fw_version" #define AMLBT_INFO_PATH "/etc/bluetooth/amlbt_info" #endif #define AMLBT_RANDOM_DEV "/dev/urandom" #define AMLBT_FWLOG_EVENT 0x62 #define HCI_MAX_CMD_SIZE 260 #define HCI_MAX_EVENT_SIZE 260 /* HCI Packet types */ #define HCI_COMMAND_PKT 0x01 #define HCI_ACLDATA_PKT 0x02 #define HCI_SCODATA_PKT 0x03 #define HCI_EVENT_PKT 0x04 #define HCI_CMD_IND (1) #define HCI_COMMAND_HDR_SIZE (3) #define HCI_RESET 0x0C03 #define BTUSB_IOC_MAGIC 'x' #define IOCTL_SET_BT_POWER _IOW(BTUSB_IOC_MAGIC, 8, int) #define IOCTL_SET_BT_OPEN _IOW(BTUSB_IOC_MAGIC, 9, int) #define IOCTL_REGISTER_HCI0 _IOW(BTUSB_IOC_MAGIC, 17, int) enum addr_mode { ADDR_FIXED_PREFIX, // fixed prefix + random suffix ADDR_FULL_RANDOM // fully random address }; /* aml bt module index */ typedef enum { UNK_AML_IDX = 0, W1_UART, W1U_UART, W1U_USB, W2_UART, W2_USB, W2L_UART, W2L_USB, } amlbt_idx; typedef struct { unsigned int vid; unsigned int pid; } dev_id; typedef struct { char *dev_name; char power_type; amlbt_idx idx; unsigned short iccm_base; char *fw_file; } dev_item; typedef struct { dev_id mod_id; dev_item mod_item; } dev_info; int amlbt_write_file(const char* fpath, const char *str, int len); int amlbt_get_random_addr(unsigned char *bdaddr, enum addr_mode mode); int amlbt_info_update(const char *key, const char *new_val); int amlbt_get_fw_ver(const unsigned char *str); int amlbt_read_addr(unsigned char *addr); #ifdef __cplusplus } #endif #endif /* AML_COMM_H */