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 7386e3223766559de97cf81abe3cd91fd86905f075Hsin-Yu Chao device = cras_bt_device_create(NULL, 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; 8686e3223766559de97cf81abe3cd91fd86905f075Hsin-Yu Chao device = cras_bt_device_create(NULL, 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(); 12686e3223766559de97cf81abe3cd91fd86905f075Hsin-Yu Chao device = cras_bt_device_create(NULL, 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 2342232117de7c9542713986c95235bb088d0fa6c40Hsin-Yu Chaovoid cras_hfp_ag_suspend_connected_device(struct cras_bt_device *device) 2352232117de7c9542713986c95235bb088d0fa6c40Hsin-Yu Chao{ 2362232117de7c9542713986c95235bb088d0fa6c40Hsin-Yu Chao} 2372232117de7c9542713986c95235bb088d0fa6c40Hsin-Yu Chao 2382232117de7c9542713986c95235bb088d0fa6c40Hsin-Yu Chaovoid cras_a2dp_suspend_connected_device(struct cras_bt_device *device) 2392232117de7c9542713986c95235bb088d0fa6c40Hsin-Yu Chao{ 2402232117de7c9542713986c95235bb088d0fa6c40Hsin-Yu Chao} 2412232117de7c9542713986c95235bb088d0fa6c40Hsin-Yu Chao 2423b611c7f640f3ddc6ec1443958d4f0d9f805f10eHsin-Yu Chaovoid cras_a2dp_start(struct cras_bt_device *device) 2433b611c7f640f3ddc6ec1443958d4f0d9f805f10eHsin-Yu Chao{ 2443b611c7f640f3ddc6ec1443958d4f0d9f805f10eHsin-Yu Chao} 2453b611c7f640f3ddc6ec1443958d4f0d9f805f10eHsin-Yu Chao 246f6120d16bb048c25d4125e93aea0d1118483818bHsin-Yu Chaoint cras_hfp_ag_start(struct cras_bt_device *device) 247f6120d16bb048c25d4125e93aea0d1118483818bHsin-Yu Chao{ 248f6120d16bb048c25d4125e93aea0d1118483818bHsin-Yu Chao return 0; 249f6120d16bb048c25d4125e93aea0d1118483818bHsin-Yu Chao} 250f6120d16bb048c25d4125e93aea0d1118483818bHsin-Yu Chao 251cb2443d87983510f40c0abb61e4fea427c692a38Hsin-Yu Chaovoid cras_hfp_ag_suspend() 252cb2443d87983510f40c0abb61e4fea427c692a38Hsin-Yu Chao{ 253cb2443d87983510f40c0abb61e4fea427c692a38Hsin-Yu Chao} 254cb2443d87983510f40c0abb61e4fea427c692a38Hsin-Yu Chao 2555b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao/* From hfp_slc */ 2565b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chaoint hfp_event_speaker_gain(struct hfp_slc_handle *handle, int gain) 2575b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao{ 2585b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao return 0; 2595b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao} 2605b799f1d3f67c9db7d47b00dd8a8684c629862aaHsin-Yu Chao 261e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao/* From iodev_list */ 2620174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao 2632e14c232763ac89fd9d2fa5e9b3fdcf6581b2db8Chinyue Chenint cras_iodev_open(struct cras_iodev *dev, unsigned int cb_level) { 2644021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid return 0; 2654021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid} 2664021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid 2674021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reidint cras_iodev_close(struct cras_iodev *dev) { 2684021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid return 0; 2694021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid} 2704021be1c5d578d8f0d84dfc33fcfa1633964a970Dylan Reid 271ab692f0b051c25a94e30d25c906df321b3fc443dCheng-Yi Chiangint cras_iodev_list_dev_is_enabled(const struct cras_iodev *dev) 2720174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao{ 2730174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao return 0; 2740174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao} 2750174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao 2760174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chaovoid cras_iodev_list_disable_dev(struct cras_iodev *dev) 2770174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao{ 2780174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao} 2790174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao 2800174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chaovoid cras_iodev_list_enable_dev(struct cras_iodev *dev) 2810174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao{ 2820174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao} 2830174edfeae6ffed06a2a619e2a70cee2fe3fa777Hsin-Yu Chao 284fe893eec58b3cf3dcec71b3d5f2c814aa0cb7d9eHsin-Yu Chaovoid cras_iodev_list_notify_node_volume(struct cras_ionode *node) 285fe893eec58b3cf3dcec71b3d5f2c814aa0cb7d9eHsin-Yu Chao{ 286fe893eec58b3cf3dcec71b3d5f2c814aa0cb7d9eHsin-Yu Chao} 287fe893eec58b3cf3dcec71b3d5f2c814aa0cb7d9eHsin-Yu Chao 2880664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chaoint cras_main_message_send(struct cras_main_message *msg) 289e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao{ 2900664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_send_msg = msg; 2910664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao return 0; 2920664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao} 2930664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao 2940664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chaoint cras_main_message_add_handler(enum CRAS_MAIN_MESSAGE_TYPE type, 2950664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_message_callback callback, 2960664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao void *callback_data) 2970664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao{ 2980664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback = callback; 2990664381a1c7c1d8296635773734e9e205d845b8eHsin-Yu Chao cras_main_message_add_handler_callback_data = callback_data; 300e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao return 0; 301e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao} 302e02c0a29cd919867c024ae353010d537db7efa51Hsin-Yu Chao 303268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao/* From cras_system_state */ 304268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chaostruct cras_tm *cras_system_state_get_tm() 305268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao{ 306268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao return NULL; 307268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao} 308268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao 309268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao/* From cras_tm */ 3100e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chaostruct cras_timer *cras_tm_create_timer( 3110e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao struct cras_tm *tm, 3120e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao unsigned int ms, 3130e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao void (*cb)(struct cras_timer *t, void *data), 3140e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao void *cb_data) 3150e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao{ 3160e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao return NULL; 3170e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao} 3180e32f6c2540a34bf841955e8e0c814b43cec9532Hsin-Yu Chao 319268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chaovoid cras_tm_cancel_timer(struct cras_tm *tm, struct cras_timer *t) 320268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao{ 321268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao} 322268efdc1e2ca122cf96e814e883804edd59665afHsin-Yu Chao 3230d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} // extern "C" 3240d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} // namespace 3250d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 3260d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chaoint main(int argc, char **argv) { 3270d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao ::testing::InitGoogleTest(&argc, argv); 3280d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao return RUN_ALL_TESTS(); 3290d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao} 3300d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 3310d17ce053a25f0c1bb7c15573a4253372d95c8e9Hsin-Yu Chao 332