2 * Copyright (C) 2017 Christopher N. Hesse <raymanfx@gmail.com>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <stdatomic.h>
24 #define TFA_LIBRARY_PATH "/system/lib/libtfa98xx.so"
28 * Amplifier audio modes for different usecases.
32 Audio_Mode_Music_Normal
,
38 * It doesn't really matter what this is, apparently we just need a continuous
43 volatile unsigned char a2
[500];
44 } __attribute__((packed
)) tfa_handle_t
;
47 * Vendor functions that we dlsym.
49 typedef int (*tfa_device_open_t
)(tfa_handle_t
*, int);
50 typedef int (*tfa_enable_t
)(tfa_handle_t
*, int);
53 * TFA Amplifier device abstraction.
55 * lib_handle: The prebuilt vendor blob, loaded into memory
56 * tfa_handle: Misc data we need to pass to the vendor function calls
57 * tfa_lock: A mutex guarding amplifier enable/disable operations
58 * tfa_device_open: Vendor function for initializing the amplifier
59 * tfa_enable: Vendor function for enabling/disabling the amplifier
60 * mode: Audio mode for the current audio device
64 tfa_handle_t
* tfa_handle
;
65 pthread_mutex_t tfa_lock
;
66 tfa_device_open_t tfa_device_open
;
67 tfa_enable_t tfa_enable
;
71 atomic_bool initializing
;
74 pthread_t write_thread
;
75 pthread_mutex_t mutex
;
82 int tfa_power(tfa_device_t
*tfa_dev
, bool on
);
83 tfa_device_t
* tfa_device_open();
84 void tfa_device_close(tfa_device_t
*tfa_dev
);