bt_device_unittest.cc revision 50cf4aec95391fb7768d9a98e35e618edc7443f3
10d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao// Copyright (c) 2014 The Chromium OS Authors. All rights reserved. 20d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao// Use of this source code is governed by a BSD-style license that can be 30d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao// found in the LICENSE file. 40d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 50d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao#include <gtest/gtest.h> 60d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 70d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoextern "C" { 80d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao#include "cras_bt_io.h" 90d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao#include "cras_bt_device.h" 100d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao#include "cras_iodev.h" 110664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao#include "cras_main_message.h" 120d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 130d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao#define FAKE_OBJ_PATH "/obj/path" 140d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 150d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 160d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic struct cras_iodev *cras_bt_io_create_profile_ret; 170d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic struct cras_iodev *cras_bt_io_append_btio_val; 18971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chaostatic struct cras_ionode* cras_bt_io_get_profile_ret; 190d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic unsigned int cras_bt_io_create_called; 200d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic unsigned int cras_bt_io_append_called; 210d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic unsigned int cras_bt_io_remove_called; 220d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic unsigned int cras_bt_io_destroy_called; 230d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic enum cras_bt_device_profile cras_bt_io_create_profile_val; 240d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostatic enum cras_bt_device_profile cras_bt_io_append_profile_val; 25b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chaostatic unsigned int cras_bt_io_try_remove_ret; 260d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 270664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chaostatic cras_main_message *cras_main_message_send_msg; 280664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chaostatic cras_message_callback cras_main_message_add_handler_callback; 290664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chaostatic void *cras_main_message_add_handler_callback_data; 30e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 310d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaovoid ResetStubData() { 32971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chao cras_bt_io_get_profile_ret = NULL; 330d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_create_called = 0; 340d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_append_called = 0; 350d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_remove_called = 0; 360d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_destroy_called = 0; 37b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao cras_bt_io_try_remove_ret = 0; 380d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 390d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 400d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaonamespace { 410d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 420d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoclass BtDeviceTestSuite : public testing::Test { 430d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao protected: 440d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao virtual void SetUp() { 450d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao ResetStubData(); 46e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao bt_iodev1.direction = CRAS_STREAM_OUTPUT; 47e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao bt_iodev1.update_active_node = update_active_node; 48e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao bt_iodev2.direction = CRAS_STREAM_INPUT; 49e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao bt_iodev2.update_active_node = update_active_node; 500d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao d1_.direction = CRAS_STREAM_OUTPUT; 51e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao d1_.update_active_node = update_active_node; 520d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao d2_.direction = CRAS_STREAM_OUTPUT; 53e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao d2_.update_active_node = update_active_node; 54e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao d3_.direction = CRAS_STREAM_INPUT; 55e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao d3_.update_active_node = update_active_node; 560d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao } 5750cf4aec95391fb7768d9a98e35e618edc7443f3Cheng-Yi Chiang 58bb28140f38fdf6627ec26696c943dfa4f9188450Hsin-Yu Chao static void update_active_node(struct cras_iodev *iodev, 590def72b968591065f56e88d67e5c83234184811bHsin-Yu Chao unsigned node_idx, 600def72b968591065f56e88d67e5c83234184811bHsin-Yu Chao unsigned dev_enabled) { 61e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao } 620d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 630d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_iodev bt_iodev1; 64e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao struct cras_iodev bt_iodev2; 65e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao struct cras_iodev d3_; 660d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_iodev d2_; 670d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_iodev d1_; 680d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao}; 690d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 700d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu ChaoTEST(BtDeviceSuite, CreateBtDevice) { 710d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_bt_device *device; 720d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 730d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao device = cras_bt_device_create(FAKE_OBJ_PATH); 740d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_NE((void *)NULL, device); 750d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 760d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao device = cras_bt_device_get(FAKE_OBJ_PATH); 770d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_NE((void *)NULL, device); 780d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 790d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_device_destroy(device); 800d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao device = cras_bt_device_get(FAKE_OBJ_PATH); 810d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ((void *)NULL, device); 820d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 830d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 840d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu ChaoTEST_F(BtDeviceTestSuite, AppendRmIodev) { 850d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_bt_device *device; 860d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao device = cras_bt_device_create(FAKE_OBJ_PATH); 870d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao bt_iodev1.nodes = reinterpret_cast<struct cras_ionode*>(0x123); 880d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_create_profile_ret = &bt_iodev1; 890d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_device_append_iodev(device, &d1_, 900d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao CRAS_BT_DEVICE_PROFILE_A2DP_SOURCE); 910d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(1, cras_bt_io_create_called); 920d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(0, cras_bt_io_append_called); 930d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(CRAS_BT_DEVICE_PROFILE_A2DP_SOURCE, 940d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_create_profile_val); 958401cbaa8d5bf558960d30ea8fc7a521ca92a1feHsin-Yu Chao cras_bt_device_set_active_profile(device, 968401cbaa8d5bf558960d30ea8fc7a521ca92a1feHsin-Yu Chao CRAS_BT_DEVICE_PROFILE_A2DP_SOURCE); 970d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 980d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_device_append_iodev(device, &d2_, 990d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao CRAS_BT_DEVICE_PROFILE_HFP_AUDIOGATEWAY); 1000d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(1, cras_bt_io_create_called); 1010d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(1, cras_bt_io_append_called); 1020d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(CRAS_BT_DEVICE_PROFILE_HFP_AUDIOGATEWAY, 1030d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_append_profile_val); 1040d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(&bt_iodev1, cras_bt_io_append_btio_val); 1050d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 106b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao /* Test HFP disconnected and switch to A2DP. */ 107971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chao cras_bt_io_get_profile_ret = bt_iodev1.nodes; 108b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao cras_bt_io_try_remove_ret = CRAS_BT_DEVICE_PROFILE_A2DP_SOURCE; 109b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao cras_bt_device_set_active_profile( 110b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao device, CRAS_BT_DEVICE_PROFILE_HFP_AUDIOGATEWAY); 1110d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_device_rm_iodev(device, &d2_); 1120d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(1, cras_bt_io_remove_called); 113b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao 114b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao /* Test A2DP disconnection will cause bt_io destroy. */ 115b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao cras_bt_io_try_remove_ret = 0; 1160d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_device_rm_iodev(device, &d1_); 117b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao EXPECT_EQ(1, cras_bt_io_remove_called); 1180d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao EXPECT_EQ(1, cras_bt_io_destroy_called); 1198401cbaa8d5bf558960d30ea8fc7a521ca92a1feHsin-Yu Chao EXPECT_EQ(0, cras_bt_device_get_active_profile(device)); 1200d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 1210d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 122e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu ChaoTEST_F(BtDeviceTestSuite, SwitchProfile) { 123e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao struct cras_bt_device *device; 124e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 125e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao ResetStubData(); 126e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao device = cras_bt_device_create(FAKE_OBJ_PATH); 127e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao cras_bt_io_create_profile_ret = &bt_iodev1; 128e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao cras_bt_device_append_iodev(device, &d1_, 129e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao CRAS_BT_DEVICE_PROFILE_A2DP_SOURCE); 130e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao cras_bt_io_create_profile_ret = &bt_iodev2; 131e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao cras_bt_device_append_iodev(device, &d3_, 132e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao CRAS_BT_DEVICE_PROFILE_HFP_AUDIOGATEWAY); 133e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 134e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao cras_bt_device_start_monitor(); 135dace0e596c97dfa4b0a2b3baa3004376eb2fd2c0Hsin-Yu Chao cras_bt_device_switch_profile_enable_dev(device, &bt_iodev1); 136e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 137e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao /* Two bt iodevs were all active. */ 1380664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback( 1390664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_send_msg, 1400664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback_data); 141e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 142e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao /* One bt iodev was active, the other was not. */ 143dace0e596c97dfa4b0a2b3baa3004376eb2fd2c0Hsin-Yu Chao cras_bt_device_switch_profile_enable_dev(device, &bt_iodev2); 1440664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback( 1450664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_send_msg, 1460664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback_data); 147e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 148e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao /* Output bt iodev wasn't active, close the active input iodev. */ 149dace0e596c97dfa4b0a2b3baa3004376eb2fd2c0Hsin-Yu Chao cras_bt_device_switch_profile(device, &bt_iodev2); 1500664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback( 1510664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_send_msg, 1520664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback_data); 153e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao} 154e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 1550d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao/* Stubs */ 1560d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoextern "C" { 1570d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 1580d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao/* From bt_io */ 1590d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostruct cras_iodev *cras_bt_io_create( 1600d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_bt_device *device, 1610d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_iodev *dev, 1620d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao enum cras_bt_device_profile profile) 1630d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 1640d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_create_called++; 1650d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_create_profile_val = profile; 1660d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return cras_bt_io_create_profile_ret; 1670d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 1680d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaovoid cras_bt_io_destroy(struct cras_iodev *bt_iodev) 1690d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 1700d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_destroy_called++; 1710d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 172971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chaostruct cras_ionode* cras_bt_io_get_profile( 173971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chao struct cras_iodev *bt_iodev, 174971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chao enum cras_bt_device_profile profile) 1750d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 176971f1da15d17fe613cf83e59beb84d0b66a1faddHsin-Yu Chao return cras_bt_io_get_profile_ret; 1770d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 1780d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoint cras_bt_io_append(struct cras_iodev *bt_iodev, 1790d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_iodev *dev, 1800d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao enum cras_bt_device_profile profile) 1810d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 1820d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_append_called++; 1830d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_append_profile_val = profile; 1840d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_append_btio_val = bt_iodev; 1850d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return 0; 1860d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 187ba771746acf979c111c5f79694258e455d1dae7cHsin-Yu Chaoint cras_bt_io_on_profile(struct cras_iodev *bt_iodev, 188ba771746acf979c111c5f79694258e455d1dae7cHsin-Yu Chao enum cras_bt_device_profile profile) 189ba771746acf979c111c5f79694258e455d1dae7cHsin-Yu Chao{ 190ba771746acf979c111c5f79694258e455d1dae7cHsin-Yu Chao return 0; 191ba771746acf979c111c5f79694258e455d1dae7cHsin-Yu Chao} 1925f01b1beb131b2c1e184970bba53d748a077f7e8Hsin-Yu Chaoint cras_bt_io_update_buffer_size(struct cras_iodev *bt_iodev) 1935f01b1beb131b2c1e184970bba53d748a077f7e8Hsin-Yu Chao{ 1945f01b1beb131b2c1e184970bba53d748a077f7e8Hsin-Yu Chao return 0; 1955f01b1beb131b2c1e184970bba53d748a077f7e8Hsin-Yu Chao} 196b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chaounsigned int cras_bt_io_try_remove(struct cras_iodev *bt_iodev, 197b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao struct cras_iodev *dev) 198b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao{ 199b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao return cras_bt_io_try_remove_ret; 200b514951036b0ca233d4405c0fd6310ad021f2062Hsin-Yu Chao} 2010d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoint cras_bt_io_remove(struct cras_iodev *bt_iodev, 2020d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao struct cras_iodev *dev) 2030d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 2040d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao cras_bt_io_remove_called++; 2050d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return 0; 2060d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 2070d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 2080d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao/* From bt_adapter */ 2090d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaostruct cras_bt_adapter *cras_bt_adapter_get(const char *object_path) 2100d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 2110d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return NULL; 2120d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 2130d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoconst char *cras_bt_adapter_address(const struct cras_bt_adapter *adapter) 2140d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 2150d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return NULL; 2160d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 2170d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 2181668d94b1813ef49aae6dfce1d59fbeeafbf1b80Hsin-Yu Chaoint cras_bt_adapter_on_usb(struct cras_bt_adapter *adapter) 2191668d94b1813ef49aae6dfce1d59fbeeafbf1b80Hsin-Yu Chao{ 2201668d94b1813ef49aae6dfce1d59fbeeafbf1b80Hsin-Yu Chao return 1; 2211668d94b1813ef49aae6dfce1d59fbeeafbf1b80Hsin-Yu Chao} 2221668d94b1813ef49aae6dfce1d59fbeeafbf1b80Hsin-Yu Chao 2230d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao/* From bt_profile */ 2240d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaovoid cras_bt_profile_on_device_disconnected(struct cras_bt_device *device) 2250d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao{ 2260d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 227e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 2285b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao/* From hfp_ag_profile */ 2295b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chaostruct hfp_slc_handle *cras_hfp_ag_get_slc(struct cras_bt_device *device) 2305b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao{ 2315b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao return NULL; 2325b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao} 2335b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao 2345b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao/* From hfp_slc */ 2355b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chaoint hfp_event_speaker_gain(struct hfp_slc_handle *handle, int gain) 2365b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao{ 2375b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao return 0; 2385b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao} 2395b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao 240e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao/* From iodev_list */ 2410174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao 24224cd7e982a045254b20e9a84830072ffa8f18180Hsin-Yu Chaoint cras_iodev_open(struct cras_iodev *dev, unsigned int cb_level) { 2434021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid return 0; 2444021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid} 2454021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid 2464021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reidint cras_iodev_close(struct cras_iodev *dev) { 2474021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid return 0; 2484021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid} 2494021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid 2500174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chaoint cras_iodev_list_dev_is_enabled(struct cras_iodev *dev) 2510174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao{ 2520174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao return 0; 2530174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao} 2540174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao 2550174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chaovoid cras_iodev_list_disable_dev(struct cras_iodev *dev) 2560174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao{ 2570174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao} 2580174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao 2590174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chaovoid cras_iodev_list_enable_dev(struct cras_iodev *dev) 2600174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao{ 2610174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao} 2620174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao 263fe893eec58b3cf3dcec71b3d5f2c814aa0cb7d9eHsin-Yu Chaovoid cras_iodev_list_notify_node_volume(struct cras_ionode *node) 264fe893eec58b3cf3dcec71b3d5f2c814aa0cb7d9eHsin-Yu Chao{ 265fe893eec58b3cf3dcec71b3d5f2c814aa0cb7d9eHsin-Yu Chao} 266fe893eec58b3cf3dcec71b3d5f2c814aa0cb7d9eHsin-Yu Chao 2670664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chaoint cras_main_message_send(struct cras_main_message *msg) 268e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao{ 2690664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_send_msg = msg; 2700664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao return 0; 2710664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao} 2720664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao 2730664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chaoint cras_main_message_add_handler(enum CRAS_MAIN_MESSAGE_TYPE type, 2740664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_message_callback callback, 2750664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao void *callback_data) 2760664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao{ 2770664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback = callback; 2780664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback_data = callback_data; 279e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao return 0; 280e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao} 281e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 282268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao/* From cras_system_state */ 283268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chaostruct cras_tm *cras_system_state_get_tm() 284268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao{ 285268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao return NULL; 286268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao} 287268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao 288268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao/* From cras_tm */ 2890e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chaostruct cras_timer *cras_tm_create_timer( 2900e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao struct cras_tm *tm, 2910e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao unsigned int ms, 2920e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao void (*cb)(struct cras_timer *t, void *data), 2930e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao void *cb_data) 2940e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao{ 2950e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao return NULL; 2960e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao} 2970e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao 298268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chaovoid cras_tm_cancel_timer(struct cras_tm *tm, struct cras_timer *t) 299268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao{ 300268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao} 301268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao 3020d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} // extern "C" 3030d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} // namespace 3040d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 3050d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoint main(int argc, char **argv) { 3060d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao ::testing::InitGoogleTest(&argc, argv); 3070d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return RUN_ALL_TESTS(); 3080d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 3090d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 3100d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 311