Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf933b57 authored by Myles Watson's avatar Myles Watson
Browse files

hci: Apply clang-format

Remove double asterisks:
  cd hci/
  find . | grep "\.cc\|\.h\|\.c" | \
     xargs -I REPLACE sed 's/^[*][*]/ \*/' -i REPLACE

Run clang-format:
  find . | grep "\.cc\|\.h\|\.c" | xargs -I REPLACE \
     clang-format --style=file -i REPLACE

Test: mma -j32
Change-Id: Ie74244127c8a264dd087d199155274d4655ccf65
parent 713462c1
Loading
Loading
Loading
Loading
+33 −35
Original line number Diff line number Diff line
@@ -34,8 +34,8 @@
#endif

/******************************************************************************
**  Constants & Macros
******************************************************************************/
 *  Constants & Macros
 *****************************************************************************/

#include <stdbool.h>

@@ -56,7 +56,7 @@ typedef enum {
#define MSG_HC_TO_STACK_HCI_ACL 0x1100      /* eq. BT_EVT_TO_BTU_HCI_ACL */
#define MSG_HC_TO_STACK_HCI_SCO 0x1200      /* eq. BT_EVT_TO_BTU_HCI_SCO */
#define MSG_HC_TO_STACK_HCI_EVT 0x1000      /* eq. BT_EVT_TO_BTU_HCI_EVT */
#define MSG_HC_TO_STACK_L2C_SEG_XMIT   0x1900 /* eq. BT_EVT_TO_BTU_L2C_SEG_XMIT */
#define MSG_HC_TO_STACK_L2C_SEG_XMIT 0x1900 /* BT_EVT_TO_BTU_L2C_SEG_XMIT */

/* Message event ID passed from stack to vendor lib */
#define MSG_STACK_TO_HC_HCI_ACL 0x2100 /* eq. BT_EVT_TO_LM_HCI_ACL */
@@ -67,11 +67,10 @@ typedef enum {
#define LOCAL_BR_EDR_CONTROLLER_ID 0

/******************************************************************************
**  Type definitions and return values
******************************************************************************/
 *  Type definitions and return values
 *****************************************************************************/

typedef struct
{
typedef struct {
  uint16_t event;
  uint16_t len;
  uint16_t offset;
@@ -81,8 +80,7 @@ typedef struct

#define BT_HC_HDR_SIZE (sizeof(HC_BT_HDR))

typedef struct _hc_buffer_hdr
{
typedef struct _hc_buffer_hdr {
  struct _hc_buffer_hdr* p_next; /* next buffer in the queue */
  uint8_t reserved1;
  uint8_t reserved2;
@@ -93,12 +91,12 @@ typedef struct _hc_buffer_hdr
#define BT_HC_BUFFER_HDR_SIZE (sizeof(HC_BUFFER_HDR_T))

/******************************************************************************
**  Extern variables and functions
******************************************************************************/
 *  Extern variables and functions
 *****************************************************************************/

/******************************************************************************
**  Functions
******************************************************************************/
 *  Functions
 *****************************************************************************/

// Called when a buffer has been produced by the serial layer and should be
// processed by the HCI layer.
+239 −239
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ extern "C" {

/** Struct types */


/** Typedefs and defines */

/** Vendor specific operations OPCODE */
@@ -60,7 +59,8 @@ typedef enum {
  BT_VND_OP_FW_CFG,

  /*  [operation]
 *      Perform any vendor specific SCO/PCM configuration on the BT Controller.
   *      Perform any vendor specific SCO/PCM configuration on the BT
   * Controller.
   *      This is called after stack initialization.
   *  [input param]
   *      None.
@@ -79,7 +79,8 @@ typedef enum {
   *      A pointer to int array type for open file descriptors.
   *      The mapping of HCI channel to fd slot in the int array is given in
   *      bt_vendor_hci_channels_t.
 *      And, it requires the vendor lib to fill up the content before returning
   *      And, it requires the vendor lib to fill up the content before
   * returning
   *      the call.
   *      Typecasting conversion: (int (*)[]) param.
   *  [return]
@@ -318,9 +319,11 @@ typedef void (*tINT_CMD_CBACK)(void *p_mem);
 *  HCI Command packet. For example, opcode = 0x0c03 for the HCI_RESET command
 *  packet.
 */
typedef uint8_t (*cmd_xmit_cb)(uint16_t opcode, void *p_buf, tINT_CMD_CBACK p_cback);
typedef uint8_t (*cmd_xmit_cb)(uint16_t opcode, void* p_buf,
                               tINT_CMD_CBACK p_cback);

typedef void (*cfg_a2dp_cb)(bt_vendor_op_result_t result, bt_vendor_opcode_t op, uint8_t bta_av_handle);
typedef void (*cfg_a2dp_cb)(bt_vendor_op_result_t result, bt_vendor_opcode_t op,
                            uint8_t bta_av_handle);

typedef struct {
  /** set to sizeof(bt_vendor_callbacks_t) */
@@ -397,7 +400,6 @@ typedef struct {
  void (*cleanup)(void);
} bt_vendor_interface_t;


/*
 * External shared lib functions/data
 */
@@ -410,10 +412,8 @@ typedef struct {
 */
extern const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE;


#ifdef __cplusplus
}
#endif

#endif /* BT_VENDOR_LIB_H */
+3 −2
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@ extern "C" {

// Callback invoked for each HCI packet.
// Highlander mode - there can be only one...
typedef void (*btsnoop_data_cb)(const uint16_t type, const uint8_t *p_data, const size_t len);
typedef void (*btsnoop_data_cb)(const uint16_t type, const uint8_t* p_data,
                                const size_t len);

// This call sets the (one and only) callback that will
// be invoked once for each HCI packet/event.
+16 −12
Original line number Diff line number Diff line
@@ -52,8 +52,10 @@ typedef struct {
} hci_hal_callbacks_t;

typedef struct hci_hal_t {
  // Initialize the HAL, with |upper_callbacks| and |upper_thread| to run in the context of.
  bool (*init)(const hci_hal_callbacks_t *upper_callbacks, thread_t *upper_thread);
  // Initialize the HAL, with |upper_callbacks| and |upper_thread| to run in the
  // context of.
  bool (*init)(const hci_hal_callbacks_t* upper_callbacks,
               thread_t* upper_thread);

  // Connect to the underlying hardware, and let data start flowing.
  bool (*open)(void);
@@ -64,7 +66,8 @@ typedef struct hci_hal_t {
  // Retrieve up to |max_size| bytes for ACL, SCO, or EVENT data packets into
  // |buffer|. Only guaranteed to be correct in the context of a data_ready
  // callback of the corresponding type.
  size_t (*read_data)(serial_data_type_t type, uint8_t *buffer, size_t max_size);
  size_t (*read_data)(serial_data_type_t type, uint8_t* buffer,
                      size_t max_size);
  // The upper layer must call this to notify the HAL that it has finished
  // reading a packet of the specified |type|. Underlying implementations that
  // use shared channels for multiple data types depend on this to know when
@@ -79,7 +82,8 @@ typedef struct hci_hal_t {
  // and then restored to its original value.
  // This is safe in the bluetooth context, because there is always a buffer
  // header that prefixes data you're sending.
  uint16_t (*transmit_data)(serial_data_type_t type, uint8_t *data, uint16_t length);
  uint16_t (*transmit_data)(serial_data_type_t type, uint8_t* data,
                            uint16_t length);
} hci_hal_t;

// Gets the correct hal implementation, as compiled for.
+35 −36
Original line number Diff line number Diff line
@@ -20,12 +20,12 @@

#include <stdbool.h>

#include "bt_types.h"
#include "osi/include/allocator.h"
#include "osi/include/data_dispatcher.h"
#include "osi/include/fixed_queue.h"
#include "osi/include/future.h"
#include "osi/include/osi.h"
#include "bt_types.h"

#ifdef __cplusplus
extern "C" {
@@ -44,7 +44,7 @@ static const char HCI_MODULE[] = "hci_module";
#define MSG_HC_TO_STACK_HCI_ACL 0x1100      /* eq. BT_EVT_TO_BTU_HCI_ACL */
#define MSG_HC_TO_STACK_HCI_SCO 0x1200      /* eq. BT_EVT_TO_BTU_HCI_SCO */
#define MSG_HC_TO_STACK_HCI_EVT 0x1000      /* eq. BT_EVT_TO_BTU_HCI_EVT */
#define MSG_HC_TO_STACK_L2C_SEG_XMIT   0x1900 /* eq. BT_EVT_TO_BTU_L2C_SEG_XMIT */
#define MSG_HC_TO_STACK_L2C_SEG_XMIT 0x1900 /* BT_EVT_TO_BTU_L2C_SEG_XMIT */

/* Message event ID passed from stack to vendor lib */
#define MSG_STACK_TO_HC_HCI_ACL 0x2100 /* eq. BT_EVT_TO_LM_HCI_ACL */
@@ -75,28 +75,28 @@ typedef enum {
} low_power_command_t;

typedef void (*command_complete_cb)(BT_HDR* response, void* context);
typedef void (*command_status_cb)(uint8_t status, BT_HDR *command, void *context);
typedef void (*command_status_cb)(uint8_t status, BT_HDR* command,
                                  void* context);

typedef struct hci_t {
  // Send a low power command, if supported and the low power manager is enabled.
  // Send a low power command, if supported and the low power manager is
  // enabled.
  void (*send_low_power_command)(low_power_command_t command);

  // Do the postload sequence (call after the rest of the BT stack initializes).
  void (*do_postload)(void);

  // Register with this data dispatcher to receive events flowing upward out of the HCI layer
  // Register with this data dispatcher to receive events flowing upward out of
  // the HCI layer
  data_dispatcher_t* event_dispatcher;

  // Set the queue to receive ACL data in
  void (*set_data_queue)(fixed_queue_t* queue);

  // Send a command through the HCI layer
  void (*transmit_command)(
      BT_HDR *command,
  void (*transmit_command)(BT_HDR* command,
                           command_complete_cb complete_callback,
      command_status_cb status_cb,
      void *context
  );
                           command_status_cb status_cb, void* context);

  future_t* (*transmit_command_futured)(BT_HDR* command);

@@ -108,8 +108,7 @@ const hci_t *hci_layer_get_interface();

const hci_t* hci_layer_get_test_interface(
    const allocator_t* buffer_allocator_interface,
    const hci_hal_t *hal_interface,
    const btsnoop_t *btsnoop_interface,
    const hci_hal_t* hal_interface, const btsnoop_t* btsnoop_interface,
    const hci_inject_t* hci_inject_interface,
    const packet_fragmenter_t* packet_fragmenter_interface,
    const vendor_t* vendor_interface,
Loading