Skip to content

Commit b98fce8

Browse files
author
respeaker
committed
Add: compatible to linux-4.18 or higher
1 parent 6c6b9ab commit b98fce8

File tree

7 files changed

+91
-13
lines changed

7 files changed

+91
-13
lines changed

Makefile

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
#
2+
# Peter Yang <turmary@126.com>
3+
# Copyright (c) 2019 Seeed Studio
4+
#
5+
# MIT License
6+
#
7+
8+
uname_r=$(shell uname -r)
9+
10+
# If KERNELRELEASE is defined, we've been invoked from the
11+
# kernel build system and can use its language
12+
ifneq ($(KERNELRELEASE),)
13+
# $(warning KERNELVERSION=$(KERNELVERSION))
14+
115
snd-soc-wm8960-objs := wm8960.o
216
snd-soc-ac108-objs := ac108.o ac101.o
317
snd-soc-seeed-voicecard-objs := seeed-voicecard.o
@@ -14,14 +28,25 @@ endif
1428
endif
1529

1630

31+
32+
else
33+
34+
DEST := /lib/modules/$(uname_r)/kernel
35+
1736
all:
18-
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
37+
make -C /lib/modules/$(uname_r)/build M=$(PWD) modules
1938

2039
clean:
21-
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
40+
make -C /lib/modules/$(uname_r)/build M=$(PWD) clean
2241

2342
install:
24-
sudo cp snd-soc-ac108.ko /lib/modules/$(shell uname -r)/kernel/sound/soc/codecs/
25-
sudo cp snd-soc-wm8960.ko /lib/modules/$(shell uname -r)/kernel/sound/soc/codecs/
26-
sudo cp snd-soc-seeed-voicecard.ko /lib/modules/$(shell uname -r)/kernel/sound/soc/bcm/
43+
sudo cp snd-soc-ac108.ko ${DEST}/sound/soc/codecs/
44+
sudo cp snd-soc-wm8960.ko ${DEST}/sound/soc/codecs/
45+
sudo cp snd-soc-seeed-voicecard.ko ${DEST}/sound/soc/bcm/
2746
sudo depmod -a
47+
48+
49+
.PHONY: all clean install
50+
51+
endif
52+

ac101.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ static irqreturn_t audio_hmic_irq(int irq, void *para)
363363

364364
static int ac101_switch_probe(struct ac10x_priv *ac10x) {
365365
struct i2c_client *i2c = ac10x->i2c101;
366-
int ret;
366+
long ret;
367367

368368
ac10x->gpiod_irq = devm_gpiod_get_optional(&i2c->dev, "switch-irq", GPIOD_IN);
369369
if (IS_ERR(ac10x->gpiod_irq)) {
@@ -376,15 +376,15 @@ static int ac101_switch_probe(struct ac10x_priv *ac10x) {
376376

377377
ac10x->irq = gpiod_to_irq(ac10x->gpiod_irq);
378378
if (IS_ERR_VALUE(ac10x->irq)) {
379-
pr_info("[ac101] map gpio to irq failed, errno = %d\n", ac10x->irq);
379+
pr_info("[ac101] map gpio to irq failed, errno = %ld\n", ac10x->irq);
380380
ac10x->irq = 0;
381381
goto _err_irq;
382382
}
383383

384384
/* request irq, set irq type to falling edge trigger */
385385
ret = devm_request_irq(ac10x->codec->dev, ac10x->irq, audio_hmic_irq, IRQF_TRIGGER_FALLING, "SWTICH_EINT", ac10x);
386386
if (IS_ERR_VALUE(ret)) {
387-
pr_info("[ac101] request virq %d failed, errno = %d\n", ac10x->irq, ret);
387+
pr_info("[ac101] request virq %ld failed, errno = %ld\n", ac10x->irq, ret);
388388
goto _err_irq;
389389
}
390390

ac108.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,12 @@ int ac108_codec_remove(struct snd_soc_codec *codec) {
12711271
}
12721272
return ac101_codec_remove(codec);
12731273
}
1274+
#if __NO_SND_SOC_CODEC_DRV
1275+
void ac108_codec_remove_void(struct snd_soc_codec *codec) {
1276+
ac108_codec_remove(codec);
1277+
}
1278+
#define ac108_codec_remove ac108_codec_remove_void
1279+
#endif
12741280

12751281
int ac108_codec_suspend(struct snd_soc_codec *codec) {
12761282
struct ac10x_priv *ac10x = snd_soc_codec_get_drvdata(codec);

ac10x.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
#endif
4141

4242

43+
#include "sound-compatible-4.18.h"
44+
4345
#ifdef CONFIG_AC101_SWITCH_DETECT
4446
enum headphone_mode_u {
4547
HEADPHONE_IDLE,
@@ -78,7 +80,7 @@ struct ac10x_priv {
7880

7981
#ifdef CONFIG_AC101_SWITCH_DETECT
8082
struct gpio_desc* gpiod_irq;
81-
int irq;
83+
long irq;
8284
volatile int irq_cntr;
8385
volatile int pullout_cntr;
8486
volatile int state;

install.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if [ "x${is_Raspberry}" != "xRaspberry" ] ; then
1212
fi
1313

1414
ver="0.3"
15-
15+
uname_r=$(uname -r)
1616

1717
# we create a dir with this version to ensure that 'dkms remove' won't delete
1818
# the sources during kernel updates
@@ -35,7 +35,6 @@ fi
3535
# locate currently installed kernels (may be different to running kernel if
3636
# it's just been updated)
3737
kernels=$(ls /lib/modules | sed "s/^/-k /")
38-
uname_r=$(uname -r)
3938

4039
function install_module {
4140
src=$1
@@ -67,7 +66,7 @@ cp seeed-8mic-voicecard.dtbo /boot/overlays
6766

6867
#install alsa plugins
6968
# no need this plugin now
70-
# install -D ac108_plugin/libasound_module_pcm_ac108.so /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_pcm_ac108.so
69+
# install -D ac108_plugin/libasound_module_pcm_ac108.so /usr/lib/arm-linux-gnueabihf/alsa-lib/
7170
rm -f /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_pcm_ac108.so
7271

7372
#set kernel moduels

sound-compatible-4.18.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* (C) Copyright 2017-2018
3+
* Seeed Technology Co., Ltd. <www.seeedstudio.com>
4+
*
5+
* PeterYang <linsheng.yang@seeed.cc>
6+
*/
7+
#ifndef __SOUND_COMPATIBLE_4_18_H__
8+
#define __SOUND_COMPATIBLE_4_18_H__
9+
10+
#include <linux/version.h>
11+
12+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,18,0)
13+
#define __NO_SND_SOC_CODEC_DRV 1
14+
#else
15+
#define __NO_SND_SOC_CODEC_DRV 0
16+
#endif
17+
18+
#if __NO_SND_SOC_CODEC_DRV
19+
#define codec component
20+
#define snd_soc_codec snd_soc_component
21+
#define snd_soc_codec_driver snd_soc_component_driver
22+
#define snd_soc_codec_get_drvdata snd_soc_component_get_drvdata
23+
#define snd_soc_codec_get_dapm snd_soc_component_get_dapm
24+
#define snd_soc_codec_get_bias_level snd_soc_component_get_bias_level
25+
#define snd_soc_kcontrol_codec snd_soc_kcontrol_component
26+
#define snd_soc_read snd_soc_component_read32
27+
#define snd_soc_register_codec snd_soc_register_component
28+
#define snd_soc_unregister_codec snd_soc_unregister_component
29+
#define snd_soc_update_bits snd_soc_component_update_bits
30+
#define snd_soc_write snd_soc_component_write
31+
#define snd_soc_add_codec_controls snd_soc_add_component_controls
32+
#endif
33+
34+
#endif//__SOUND_COMPATIBLE_4_18_H__
35+

wm8960.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <sound/initval.h>
2626
#include <sound/tlv.h>
2727
#include <sound/wm8960.h>
28+
#include "sound-compatible-4.18.h"
2829

2930
#include "wm8960.h"
3031

@@ -507,7 +508,11 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec)
507508
* list each time to find the desired power state do so now
508509
* and save the result.
509510
*/
511+
#if __NO_SND_SOC_CODEC_DRV
512+
list_for_each_entry(w, &codec->card->widgets, list) {
513+
#else
510514
list_for_each_entry(w, &codec->component.card->widgets, list) {
515+
#endif
511516
if (w->dapm != dapm)
512517
continue;
513518
if (strcmp(w->name, "LOUT1 PGA") == 0)
@@ -1275,7 +1280,13 @@ static int wm8960_probe(struct snd_soc_codec *codec)
12751280
static const struct snd_soc_codec_driver soc_codec_dev_wm8960 = {
12761281
.probe = wm8960_probe,
12771282
.set_bias_level = wm8960_set_bias_level,
1278-
.suspend_bias_off = true,
1283+
.suspend_bias_off = true,
1284+
#if __NO_SND_SOC_CODEC_DRV
1285+
.idle_bias_on = 1,
1286+
.use_pmdown_time = 1,
1287+
.endianness = 1,
1288+
.non_legacy_dai_naming = 1,
1289+
#endif
12791290
};
12801291

12811292
static const struct regmap_config wm8960_regmap = {

0 commit comments

Comments
 (0)