Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASoC: tegra: event based gpio control does not work #130

Closed
clamor-s opened this issue Sep 23, 2022 · 9 comments
Closed

ASoC: tegra: event based gpio control does not work #130

clamor-s opened this issue Sep 23, 2022 · 9 comments

Comments

@clamor-s
Copy link
Contributor

static int tegra_machine_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event)
{
struct snd_soc_dapm_context *dapm = w->dapm;
struct tegra_machine *machine = snd_soc_card_get_drvdata(dapm->card);
if (machine->asoc->dapm_event) {
int ret = machine->asoc->dapm_event(w, k, event);
if (ret <= 0)
return ret;
}
if (!strcmp(w->name, "Int Spk") || !strcmp(w->name, "Speakers"))
gpiod_set_value_cansleep(machine->gpiod_spkr_en,
SND_SOC_DAPM_EVENT_ON(event));
if (!strcmp(w->name, "Mic Jack"))
gpiod_set_value_cansleep(machine->gpiod_ext_mic_en,
SND_SOC_DAPM_EVENT_ON(event));
if (!strcmp(w->name, "Int Mic"))
gpiod_set_value_cansleep(machine->gpiod_int_mic_en,
SND_SOC_DAPM_EVENT_ON(event));
if (!strcmp(w->name, "Headphone") || !strcmp(w->name, "Headphone Jack"))
gpiod_set_value_cansleep(machine->gpiod_hp_mute,
!SND_SOC_DAPM_EVENT_ON(event));
return 0;
}

I am binding here https://github.com/clamor-s/linux/blob/p895/arch/arm/boot/dts/tegra30-lge-p895.dts#L1825-L1826 gpios, required for mics to work. If I just bind them as hogs everything is fine, but once I bind them inside tegra_asoc both mics fail.

@clamor-s clamor-s changed the title Event based gpio control does not work ASoC: tegra: event based gpio control does not work Sep 24, 2022
@digetx
Copy link
Member

digetx commented Oct 1, 2022

You don't have Mic Jack and Int Mic in nvidia,audio-routing. DTB checker should tell you about the error.

@clamor-s
Copy link
Contributor Author

clamor-s commented Oct 1, 2022

So I need to route audio via those in dts? Isn't enabling those in alsa ucm enough?

@digetx
Copy link
Member

digetx commented Oct 1, 2022

Although, the DT seems okay. There are no event handlers set up for Internal Mic 1 and Internal Mic 2 in the machine driver.

You could either add tegra_machine_event() for Internal Mic 1 and Internal Mic 2 or use Mic Jack and Int Mic in the routing instead of Internal Mic 1/2.

@clamor-s
Copy link
Contributor Author

clamor-s commented Oct 1, 2022

I would like to, but I have too much audio devices to handle since it is a phone. I will add tegra_machine_event() if you do not mind.

@digetx
Copy link
Member

digetx commented Oct 1, 2022

The problem with Internal Mic 1/2 that you can't tell which one is internal or external mic. I assume you'll need to use a custom machine->asoc->dapm_event() handler in this case.

@digetx
Copy link
Member

digetx commented Oct 1, 2022

Maybe adding new nvidia,int-mic1-en-gpios nvidia,int-mic2-en-gpios won't be a bad solution.

@digetx
Copy link
Member

digetx commented Oct 1, 2022

I'm not sure what are those Internal Mic 1/2, it looks like you have three mics. Perhaps one is noise cancellation?

@clamor-s
Copy link
Contributor Author

clamor-s commented Oct 1, 2022

yes, mic2 is for noise cancellation. Mic1 is main and Mic Jack is headset.

As I told, I have quite few of audio devices, since it is a phone.

@clamor-s
Copy link
Contributor Author

clamor-s commented Oct 1, 2022

Adding tegra_machine_event worked perfectly

@clamor-s clamor-s closed this as completed Oct 1, 2022
okias pushed a commit to okias/linux that referenced this issue Jan 11, 2024
Like commit 1cf3bfc ("bpf: Support 64-bit pointers to kfuncs")
for s390x, add support for 64-bit pointers to kfuncs for LoongArch.
Since the infrastructure is already implemented in BPF core, the only
thing need to be done is to override bpf_jit_supports_far_kfunc_call().

Before this change, several test_verifier tests failed:

  # ./test_verifier | grep # | grep FAIL
  grate-driver#119/p calls: invalid kfunc call: ptr_to_mem to struct with non-scalar FAIL
  grate-driver#120/p calls: invalid kfunc call: ptr_to_mem to struct with nesting depth > 4 FAIL
  grate-driver#121/p calls: invalid kfunc call: ptr_to_mem to struct with FAM FAIL
  grate-driver#122/p calls: invalid kfunc call: reg->type != PTR_TO_CTX FAIL
  grate-driver#123/p calls: invalid kfunc call: void * not allowed in func proto without mem size arg FAIL
  grate-driver#124/p calls: trigger reg2btf_ids[reg->type] for reg->type > __BPF_REG_TYPE_MAX FAIL
  grate-driver#125/p calls: invalid kfunc call: reg->off must be zero when passed to release kfunc FAIL
  grate-driver#126/p calls: invalid kfunc call: don't match first member type when passed to release kfunc FAIL
  grate-driver#127/p calls: invalid kfunc call: PTR_TO_BTF_ID with negative offset FAIL
  grate-driver#128/p calls: invalid kfunc call: PTR_TO_BTF_ID with variable offset FAIL
  grate-driver#129/p calls: invalid kfunc call: referenced arg needs refcounted PTR_TO_BTF_ID FAIL
  grate-driver#130/p calls: valid kfunc call: referenced arg needs refcounted PTR_TO_BTF_ID FAIL
  #486/p map_kptr: ref: reference state created and released on xchg FAIL

This is because the kfuncs in the loaded module are far away from
__bpf_call_base:

  ffff800002009440 t bpf_kfunc_call_test_fail1    [bpf_testmod]
  9000000002e128d8 T __bpf_call_base

The offset relative to __bpf_call_base does NOT fit in s32, which breaks
the assumption in BPF core. Enable bpf_jit_supports_far_kfunc_call() lifts
this limit.

Note that to reproduce the above result, tools/testing/selftests/bpf/config
should be applied, and run the test with JIT enabled, unpriv BPF enabled.

With this change, the test_verifier tests now all passed:

  # ./test_verifier
  ...
  Summary: 777 PASSED, 0 SKIPPED, 0 FAILED

Tested-by: Tiezhu Yang <[email protected]>
Signed-off-by: Hengqi Chen <[email protected]>
Signed-off-by: Huacai Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants