Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions arch/arm64/boot/dts/qcom/sdm845-oneplus-fajita.dts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,17 @@
};

&i2c4 {
/* nxp,tfa9894 @ 0x34 */
clock-frequency = <400000>;

status = "okay";

tfa9894_codec: tfa9894@34 {
#sound-dai-cells = <1>;
compatible = "nxp,tfa9894";
reg = <0x34>;
reset-gpio = <&tlmm 69 GPIO_ACTIVE_HIGH>;
};

};

&bq27441_fg {
Expand All @@ -57,12 +67,11 @@
monitored-battery = <&battery>;
};

/*
* The TFA9894 codec is currently unsupported.
* We need to delete the node to allow the soundcard
* to probe for headphones/earpiece.
*/
/delete-node/ &speaker_playback_dai;
&speaker_playback_dai {
codec {
sound-dai = <&tfa9894_codec 0>;
};
};

&rmi4_f12 {
touchscreen-y-mm = <148>;
Expand Down
14 changes: 14 additions & 0 deletions sound/soc/codecs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ config SND_SOC_ALL_CODECS
imply SND_SOC_TAS5720
imply SND_SOC_TAS6424
imply SND_SOC_TDA7419
imply SND_SOC_TFA98xx
imply SND_SOC_TFA9879
imply SND_SOC_TFA989X
imply SND_SOC_TLV320ADC3XXX
Expand Down Expand Up @@ -2195,6 +2196,19 @@ config SND_SOC_TDA7419
depends on I2C
select REGMAP_I2C

config SND_SOC_TFA98XX
tristate "NXP/Goodix TFA98XX"
depends on I2C
select REGMAP_I2C
help
Enable support for NXP (now Goodix) second-generation TFA98XX speaker
amplifiers, e.g. TFA9872/TFA9873/TFA9874/TFA9875/TFA9878/TFA9888/
TFA9894/TFA9912. The downstream driver no longer loads DSP container
firmware via request_firmware(); board-specific software must provide
the configuration data before the codec probes or the driver will fail
to bind. The driver still needs a full rewrite before it can be
submitted upstream.

config SND_SOC_TFA9879
tristate "NXP Semiconductors TFA9879 amplifier"
depends on I2C
Expand Down
5 changes: 5 additions & 0 deletions sound/soc/codecs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ snd-soc-tas2781-i2c-y := tas2781-i2c.o
snd-soc-tas2783-sdw-y := tas2783-sdw.o
snd-soc-tfa9879-y := tfa9879.o
snd-soc-tfa989x-y := tfa989x.o
snd-soc-tfa98xx-objs += tfa98xx-downstream/tfa98xx.o
snd-soc-tfa98xx-objs += tfa98xx-downstream/tfa_container.o
snd-soc-tfa98xx-objs += tfa98xx-downstream/tfa_dsp.o
snd-soc-tfa98xx-objs += tfa98xx-downstream/tfa_init.o
snd-soc-tlv320adc3xxx-y := tlv320adc3xxx.o
snd-soc-tlv320aic23-y := tlv320aic23.o
snd-soc-tlv320aic23-i2c-y := tlv320aic23-i2c.o
Expand Down Expand Up @@ -754,6 +758,7 @@ obj-$(CONFIG_SND_SOC_TAS5805M) += snd-soc-tas5805m.o
obj-$(CONFIG_SND_SOC_TAS6424) += snd-soc-tas6424.o
obj-$(CONFIG_SND_SOC_TDA7419) += snd-soc-tda7419.o
obj-$(CONFIG_SND_SOC_TAS2770) += snd-soc-tas2770.o
obj-$(CONFIG_SND_SOC_TFA98XX) += snd-soc-tfa98xx.o
obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o
obj-$(CONFIG_SND_SOC_TFA989X) += snd-soc-tfa989x.o
obj-$(CONFIG_SND_SOC_TLV320ADC3XXX) += snd-soc-tlv320adc3xxx.o
Expand Down
37 changes: 37 additions & 0 deletions sound/soc/codecs/tfa98xx-downstream/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2014-2020 NXP Semiconductors, All Rights Reserved.
* Copyright 2021 GOODIX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/



/*
Linux kernel specific definitions used by code shared with
Linux/Windows user space.
*/

#ifndef __CONFIG_LINUX_KERNEL_INC__
#define __CONFIG_LINUX_KERNEL_INC__

#include <linux/ctype.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/crc32.h>
#include <linux/ftrace.h>

#define _ASSERT(e)
#define PRINT_ASSERT(e)if ((e)) printk(KERN_ERR "PrintAssert:%s (%s:%d) error code:%d\n",__FUNCTION__,__FILE__,__LINE__, e)

#if defined(CONFIG_TRACING) && defined(DEBUG)
#define tfa98xx_trace_printk(...) trace_printk(__VA_ARGS__)
#else
#define tfa98xx_trace_printk(...)
#endif

#endif /* __CONFIG_LINUX_KERNEL_INC__ */

160 changes: 160 additions & 0 deletions sound/soc/codecs/tfa98xx-downstream/dbgprint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
* Copyright (C) 2014-2020 NXP Semiconductors, All Rights Reserved.
* Copyright 2021 GOODIX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/


#ifndef _DBGPRINT_H
# define _DBGPRINT_H

/* Debugging macro's. */
# ifndef DEBUG
# define DEBUG
# endif

# ifndef ASSERT
//#define ASSERT
# endif
//TODO wwwim
# ifndef _ASSERT
#define _ASSERT(e)
# endif

# ifndef PREFIX
# define PREFIX "tfa98xx: "
# define DRIVER_NAME "tfa98xx"
# endif

#ifdef __KERNEL__

# ifdef DEBUG
# define _DEBUG(level,fmt,va...) do {\
if (unlikely(debug >= (level))) \
printk(KERN_INFO PREFIX "%s:%d: "fmt,__func__,__LINE__,##va); \
} while (0)

# else
# define _DEBUG(level,fmt,va...) do {} while(0)
# endif

# define MSG(fmt,va...) printk(KERN_INFO PREFIX "%s:%d: "fmt,__func__,__LINE__,##va)
# define _ERRORMSG(fmt,va...) printk(KERN_ERR PREFIX "ERROR %s:%d: "fmt,__func__,__LINE__, ##va)


# define DEBUG0(x...) MSG(x)
# define DEBUG1(x...) _DEBUG(1,x)
# define DEBUG2(x...) _DEBUG(2,x)
# define DEBUG3(x...) _DEBUG(3,x)
# define ERRORMSG(x...) _ERRORMSG(x)
# define PRINT(x...) printk(x)
# define PRINT_ERROR(x...) printk(KERN_INFO PREFIX " **ERROR** " x)
# define PRINT_ASSERT(e)if ((e)) printk(KERN_ERR "PrintAssert:%s (%s:%d) error code:%d\n",__FUNCTION__,__FILE__,__LINE__, e)

# define PRINT_ENTRY DEBUG2("+[%s]\n", __func__)
# define PRINT_EXIT DEBUG2("-[%s]\n", __func__)

# ifdef ASSERT
# define assert(cond,action) do { if (unlikely(!(cond))) { DEBUG0("Assert: %s\n",#cond); action; }} while(0)
# else
# define assert(cond,action) do { } while (0)
# endif

#else /* __KERNEL__ */
#if defined(WIN32) || defined(_X64)
#include <stdio.h>
/* user mode */
# ifdef DEBUG
# define _DEBUGMSG(level,fmt,...) printf(PREFIX "%s:%d: "fmt,__FUNCTION__,__LINE__,__VA_ARGS__);
# else
# define _DEBUGMSG(level,fmt,...) do {} while(0)
# endif

# define _ERRORMSG(fmt,...) printf(PREFIX "%s:%s:%d: "fmt,__FILE__,__FUNCTION__,__LINE__,__VA_ARGS__)

# define DEBUG0(...) MSG(__VA_ARGS__)
# define DEBUG1(...) _DEBUGMSG(1,__VA_ARGS__)
# define DEBUG2(...) _DEBUGMSG(2,__VA_ARGS__)
# define DEBUG3(...) _DEBUGMSG(3,__VA_ARGS__)
# define ERRORMSG(fmt,...) _ERRORMSG(fmt,__VA_ARGS__)
# define PRINT(...) printf(__VA_ARGS__)
/*
# define PRINT(...) { FILE *stream; \
if((stream = freopen("tfa_tfa.txt", "ab+", stdout)) == NULL) exit(-1); \
printf(__VA_ARGS__); \
freopen( "CON", "ab+", stdout ); \
}
*/
# define PRINT_ERROR(...) fprintf(stderr,__VA_ARGS__)
# define PRINT_FILE(file,...) fprintf(file,__VA_ARGS__)
# define PRINT_ASSERT(e)if ((e)) fprintf(stderr, "PrintAssert:%s (%s:%d) error code:%d\n",__FUNCTION__,__FILE__,__LINE__, e)
//# define PRINT_ASSERT(e) if ((e)) fprintf(stderr, "PrintAssert:%s (%s:%d) %s\n",__FUNCTION__,__FILE__,__LINE__, Tfa98xx_GetErrorString(e))

#elif defined(__CODE_RED)
#include "app_global.h"
# ifdef DEBUG
# define _DEBUG(level,fmt,va...) TB_TRACE_INF(TbTracePfx2("tfa",TB_FUNC,va))
//printf(PREFIX "%s:%d: "fmt,__func__,__LINE__,##va);
# else
# define _DEBUG(level,fmt,va...) do {} while(0)
# endif

# define MSG(fmt,...) TB_TRACE_INF(TbTracePfx2("tfa",TB_FUNC,__VA_ARGS__))
//printf(PREFIX "%s:%s:%d: "fmt,__FILE__,__func__,__LINE__,##va)
//TB_TRACE_INF(TbTracePfx2(APP_PFX,TB_FUNC,"path=%s, chan=%u, muted=%s, vol=%d\n",
// path->isRecording ? "recording" : "playback",
// i,
// channelVol.currentMuteValue ? "YES" : "NO",
// channelVol.currentVolumeValue
// ));
//# define _ERRORMSG(fmt,va...) TB_TRACE_INF(TbTracePfx2("tfa",TB_FUNC,va))
# define ERRORMSG(...) TB_TRACE_INF(TbTracePfx2("tfa",TB_FUNC,__VA_ARGS__))
//fprintf(stderr, PREFIX "ERROR %s:%s:%d: "fmt,__FILE__,__func__,__LINE__, ##va)

# define DEBUG0(x...) MSG(x)
# define DEBUG1(x...) _DEBUG(1,x)
# define DEBUG2(x...) _DEBUG(2,x)
# define DEBUG3(x...) _DEBUG(3,x)
//# define ERRORMSG(x...) _ERRORMSG(x)
# define PRINT(x...) TB_TRACE_INF(TbTracePfx2("tfa",TB_FUNC,x))
//printf(x)
# define PRINT_ERROR(x...) TB_TRACE_INF(TbTracePfx2("tfa",TB_FUNC,x))
//fprintf(stderr,__VA_ARGS__)
# define PRINT_FILE(file,x...) TB_TRACE_INF(TbTracePfx2("tfa",TB_FUNC,x))
//fprintf(file,__VA_ARGS__)
# define PRINT_ASSERT(e)
//TB_TRACE_INF(TbTracePfx2("tfa",TB_FUNC,Tfa98xx_GetErrorString(e)))
//if ((e)) fprintf(stderr, "PrintAssert:%s (%s:%d) %s\n",__FUNCTION__,__FILE__,__LINE__, Tfa98xx_GetErrorString(e))
#else
#include <stdio.h>
/* user mode */
# ifdef DEBUG
# define _DEBUG(level,fmt,va...) printf(PREFIX "%s:%d: "fmt,__func__,__LINE__,##va);
# else
# define _DEBUG(level,fmt,va...) do {} while(0)
# endif

# define MSG(fmt,va...) printf(PREFIX "%s:%s:%d: "fmt,__FILE__,__func__,__LINE__,##va)
# define _ERRORMSG(fmt,va...) fprintf(stderr, PREFIX "ERROR %s:%s:%d: "fmt,__FILE__,__func__,__LINE__, ##va)

# define DEBUG0(x...) MSG(x)
# define DEBUG1(x...) _DEBUG(1,x)
# define DEBUG2(x...) _DEBUG(2,x)
# define DEBUG3(x...) _DEBUG(3,x)
# define ERRORMSG(x...) _ERRORMSG(x)
# define PRINT(x...) printf(x)
# define PRINT_ERROR(...) fprintf(stderr,__VA_ARGS__)
# define PRINT_FILE(file,...) fprintf(file,__VA_ARGS__)
# define PRINT_ASSERT(e)if ((e)) fprintf(stderr, "PrintAssert:%s (%s:%d) error code:%d\n",__FUNCTION__,__FILE__,__LINE__, e)
//# define PRINT_ASSERT(e) if ((e)) fprintf(stderr, "PrintAssert:%s (%s:%d) %s\n",__FUNCTION__,__FILE__,__LINE__, Tfa98xx_GetErrorString(e))


#endif /* WIN32 */

#endif /* user */

#endif /* _DBGPRINT_H --------------- */
45 changes: 45 additions & 0 deletions sound/soc/codecs/tfa98xx-downstream/tfa.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2014-2020 NXP Semiconductors, All Rights Reserved.
* Copyright 2021 GOODIX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/


#ifndef TFA_H_
#define TFA_H_

/* set the limit for the container file length */
#define TFA_MAX_CNT_LENGTH (256*1024)

extern struct tfa_device **devs;

/**
* tfa error return codes
*/
enum tfa_error {
tfa_error_ok, /**< no error */
tfa_error_device, /**< no response from device */
tfa_error_bad_param,/**< parameter no accepted */
tfa_error_noclock, /**< required clock not present */
tfa_error_timeout, /**< a timeout occurred */
tfa_error_dsp, /**< a DSP error was returned */
tfa_error_container,/**< no or wrong container file */
tfa_error_max /**< impossible value, max enum */
};

enum Tfa98xx_Error tfa_write_filters(struct tfa_device *tfa, int prof_idx);

struct tfa_device ** tfa_devs_create(int count);
void tfa_devs_destroy(int count);

struct tfa_device ** tfa_get_device_struct(void);

int tfa_plop_noise_interrupt(struct tfa_device *tfa, int profile, int vstep);
void tfa_lp_mode_interrupt(struct tfa_device *tfa);
void tfa_adapt_noisemode(struct tfa_device *tfa);

#endif /* TFA_H_ */
Loading