summaryrefslogtreecommitdiff
path: root/tfa9890/tfa9890.h
blob: c01e32abe124df422c3ce8d3a8d3866b375e8c11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * Copyright (C) 2014-2016 The CyanogenMod Project
 * Copyright (C) 2017-2019 The LineageOS Project
 *
 * 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.
 */

/* Kernel header */
#include <sound/tfa98xx.h>

#define TFA9890_DEVICE "/dev/tfa98xx"

/* All the files in /vendor/etc/tfa98xx */
#define PATCH_DSP_FILE "/vendor/etc/tfa98xx/TFA9890.patch"
#define PATCH_COLDBOOT_FILE "/vendor/etc/tfa98xx/coldboot.patch"

#define CONFIG_TOP "/vendor/etc/tfa98xx/TFA9890_top.config"
#define CONFIG_BOTTOM "/vendor/etc/tfa98xx/TFA9890_btm.config"
#define CONFIG_RECEIVER "/vendor/etc/tfa98xx/TFA9890_Receiver.config"

#define SPEAKER_TOP "/vendor/etc/tfa98xx/top.speaker"
#define SPEAKER_BOTTOM "/vendor/etc/tfa98xx/btm.speaker"

#define PRESET_HIFISPEAKER_TOP "/vendor/etc/tfa98xx/HiFiSpeaker_top.preset"
#define PRESET_HIFISPEAKER_BOTTOM "/vendor/etc/tfa98xx/HiFiSpeaker_btm.preset"
#define PRESET_HIFISPEAKER_RING_TOP "/vendor/etc/tfa98xx/HiFiSpeakerRing_top.preset"
#define PRESET_HIFISPEAKER_RING_BOTTOM "/vendor/etc/tfa98xx/HiFiSpeakerRing_btm.preset"
#define PRESET_HIFISPEAKER_SFORCE_TOP "/vendor/etc/tfa98xx/HiFiSpeakerSforce_top.preset"
#define PRESET_HIFISPEAKER_SFORCE_BOTTOM "/vendor/etc/tfa98xx/HiFiSpeakerSforce_btm.preset"
#define PRESET_VOICECALLSPEAKER_TOP "/vendor/etc/tfa98xx/VoiceCallSpeaker_top.preset"
#define PRESET_VOICECALLSPEAKER_BOTTOM "/vendor/etc/tfa98xx/VoiceCallSpeaker_btm.preset"
#define PRESET_FMSPEAKER_TOP "/vendor/etc/tfa98xx/FMSpeaker_top.preset"
#define PRESET_FMSPEAKER_BOTTOM "/vendor/etc/tfa98xx/FMSpeaker_btm.preset"
#define PRESET_VOICECALLEARPICE_TOP "/vendor/etc/tfa98xx/VoiceCallEarpice_top.preset"

#define EQ_HIFISPEAKER_TOP "/vendor/etc/tfa98xx/HiFiSpeaker_top.eq"
#define EQ_HIFISPEAKER_BOTTOM "/vendor/etc/tfa98xx/HiFiSpeaker_btm.eq"
#define EQ_HIFISPEAKER_RING_TOP "/vendor/etc/tfa98xx/HiFiSpeakerRing_top.eq"
#define EQ_HIFISPEAKER_RING_BOTTOM "/vendor/etc/tfa98xx/HiFiSpeakerRing_btm.eq"
#define EQ_HIFISPEAKER_SFORCE_TOP "/vendor/etc/tfa98xx/HiFiSpeakerSforce_top.eq"
#define EQ_HIFISPEAKER_SFORCE_BOTTOM "/vendor/etc/tfa98xx/HiFiSpeakerSforce_btm.eq"
#define EQ_VOICECALLSPEAKER_TOP "/vendor/etc/tfa98xx/VoiceCallSpeaker_top.eq"
#define EQ_VOICECALLSPEAKER_BOTTOM "/vendor/etc/tfa98xx/VoiceCallSpeaker_btm.eq"
#define EQ_FMSPEAKER_TOP "/vendor/etc/tfa98xx/FMSpeaker_top.eq"
#define EQ_FMSPEAKER_BOTTOM "/vendor/etc/tfa98xx/FMSpeaker_btm.eq"
#define EQ_VOICECALLEARPICE_TOP "/vendor/etc/tfa98xx/VoiceCallEarpice_top.eq"

/* Macros for ioctl with above files
 * This macro calls tfa9890_prepare_for_ioctl()
 * to setup the ioctl arg,
 * and then calls ioctl() */
#define TFA9890_IOCTL(ioctltype, filename, filetype) \
	ret = tfa9890_prepare_for_ioctl(filename, filetype); \
	if (ret > 0) { \
		ALOGV("ioctl %s", filename); \
		ret = ioctl(fd, ioctltype, &tfa9890_param_data); \
		if (ret == -1) { \
			ALOGE("ioctl failed for %s with %d", filename, errno); \
			goto error; \
		} \
	} else \
		goto error; \

/* Macro for only ".eq"/EQ_ files
 * Same as above but calls a different function
 * to setup the ioctl arg */
#define TFA9890_IOCTL_EQ(filename, filetype) \
	ret = tfa9890_prepare_for_ioctl_eq(filename, filetype); \
	if (!ret) { \
		ALOGV("ioctl %s", filename); \
		ret = ioctl(fd, TFA98XX_EQ_PARAM, &tfa9890_param_data); \
		if (ret == -1) { \
			ret = errno; \
			ALOGE("ioctl failed for %s with %d", filename, ret); \
			goto error; \
		} \
	} else \
		goto error; \

int tfa9890_prepare_for_ioctl(const char*, unsigned int);
int tfa9890_prepare_for_ioctl_eq(const char*, unsigned int);
int tfa9890_init(void);