| 1 |
// SPDX-License-Identifier: GPL-2.0 |
| 2 |
/* |
| 3 |
* Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights reserved. |
| 4 |
*/ |
| 5 |
#include <dt-bindings/sound/qcom,q6afe.h> |
| 6 |
#include <linux/module.h> |
| 7 |
#include <sound/jack.h> |
| 8 |
#include <sound/soc-usb.h> |
| 9 |
|
| 10 |
#include "usb_offload_utils.h" |
| 11 |
|
| 12 |
int qcom_snd_usb_offload_jack_setup(struct snd_soc_pcm_runtime *rtd, |
| 13 |
struct snd_soc_jack *jack, bool *jack_setup) |
| 14 |
{ |
| 15 |
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); |
| 16 |
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); |
| 17 |
int ret = 0; |
| 18 |
|
| 19 |
if (cpu_dai->id != USB_RX) |
| 20 |
return -EINVAL; |
| 21 |
|
| 22 |
if (!*jack_setup) { |
| 23 |
ret = snd_soc_usb_setup_offload_jack(codec_dai->component, jack); |
| 24 |
if (ret) |
| 25 |
return ret; |
| 26 |
} |
| 27 |
|
| 28 |
*jack_setup = true; |
| 29 |
|
| 30 |
return 0; |
| 31 |
} |
| 32 |
EXPORT_SYMBOL_GPL(qcom_snd_usb_offload_jack_setup); |
| 33 |
|
| 34 |
int qcom_snd_usb_offload_jack_remove(struct snd_soc_pcm_runtime *rtd, |
| 35 |
bool *jack_setup) |
| 36 |
{ |
| 37 |
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); |
| 38 |
struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); |
| 39 |
int ret = 0; |
| 40 |
|
| 41 |
if (cpu_dai->id != USB_RX) |
| 42 |
return -EINVAL; |
| 43 |
|
| 44 |
if (*jack_setup) { |
| 45 |
ret = snd_soc_component_set_jack(codec_dai->component, NULL, NULL); |
| 46 |
if (ret) |
| 47 |
return ret; |
| 48 |
} |
| 49 |
|
| 50 |
*jack_setup = false; |
| 51 |
|
| 52 |
return 0; |
| 53 |
} |
| 54 |
EXPORT_SYMBOL_GPL(qcom_snd_usb_offload_jack_remove); |
| 55 |
MODULE_DESCRIPTION("ASoC Q6 USB offload controls"); |
| 56 |
MODULE_LICENSE("GPL"); |