2020-05-01 09:58:50 -05:00
|
|
|
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
|
2019-04-12 11:08:53 -05:00
|
|
|
//
|
|
|
|
// This file is provided under a dual BSD/GPLv2 license. When using or
|
|
|
|
// redistributing this file, you may do so under either license.
|
|
|
|
//
|
2024-05-03 09:03:51 -05:00
|
|
|
// Copyright(c) 2018 Intel Corporation
|
2019-04-12 11:08:53 -05:00
|
|
|
//
|
|
|
|
// Authors: Keyon Jie <yang.jie@linux.intel.com>
|
|
|
|
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <sound/hdaudio.h>
|
2021-02-05 20:46:30 +02:00
|
|
|
#include <sound/hda_i915.h>
|
2021-11-05 13:16:55 +02:00
|
|
|
#include <sound/hda_codec.h>
|
|
|
|
#include <sound/hda_register.h>
|
2019-04-12 11:08:53 -05:00
|
|
|
#include "../sof-priv.h"
|
|
|
|
#include "hda.h"
|
|
|
|
|
2019-08-07 20:50:50 +02:00
|
|
|
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
|
2019-08-09 19:01:00 +08:00
|
|
|
#include "../../codecs/hdac_hda.h"
|
2019-08-07 20:50:50 +02:00
|
|
|
#define sof_hda_ext_ops snd_soc_hdac_hda_get_ops()
|
2019-04-12 11:08:53 -05:00
|
|
|
|
2021-11-05 13:16:55 +02:00
|
|
|
static void update_codec_wake_enable(struct hdac_bus *bus, unsigned int addr, bool link_power)
|
|
|
|
{
|
|
|
|
unsigned int mask = snd_hdac_chip_readw(bus, WAKEEN);
|
|
|
|
|
|
|
|
if (link_power)
|
|
|
|
mask &= ~BIT(addr);
|
|
|
|
else
|
|
|
|
mask |= BIT(addr);
|
|
|
|
|
|
|
|
snd_hdac_chip_updatew(bus, WAKEEN, STATESTS_INT_MASK, mask);
|
|
|
|
}
|
|
|
|
|
2021-02-05 20:46:30 +02:00
|
|
|
static void sof_hda_bus_link_power(struct hdac_device *codec, bool enable)
|
|
|
|
{
|
|
|
|
struct hdac_bus *bus = codec->bus;
|
|
|
|
bool oldstate = test_bit(codec->addr, &bus->codec_powered);
|
|
|
|
|
|
|
|
snd_hdac_ext_bus_link_power(codec, enable);
|
|
|
|
|
|
|
|
if (enable == oldstate)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Both codec driver and controller can hold references to
|
|
|
|
* display power. To avoid unnecessary power-up/down cycles,
|
|
|
|
* controller doesn't immediately release its reference.
|
|
|
|
*
|
|
|
|
* If the codec driver powers down the link, release
|
|
|
|
* the controller reference as well.
|
|
|
|
*/
|
|
|
|
if (codec->addr == HDA_IDISP_ADDR && !enable)
|
|
|
|
snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
|
2021-11-05 13:16:55 +02:00
|
|
|
|
|
|
|
/* WAKEEN needs to be set for disabled links */
|
|
|
|
update_codec_wake_enable(bus, codec->addr, enable);
|
2021-02-05 20:46:30 +02:00
|
|
|
}
|
|
|
|
|
2021-02-05 20:46:29 +02:00
|
|
|
static const struct hdac_bus_ops bus_core_ops = {
|
|
|
|
.command = snd_hdac_bus_send_cmd,
|
|
|
|
.get_response = snd_hdac_bus_get_response,
|
2021-02-05 20:46:30 +02:00
|
|
|
.link_power = sof_hda_bus_link_power,
|
2021-02-05 20:46:29 +02:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2019-04-12 11:08:53 -05:00
|
|
|
/*
|
|
|
|
* This can be used for both with/without hda link support.
|
|
|
|
*/
|
2022-10-27 15:35:35 -04:00
|
|
|
void sof_hda_bus_init(struct snd_sof_dev *sdev, struct device *dev)
|
2019-04-12 11:08:53 -05:00
|
|
|
{
|
2022-10-27 15:35:35 -04:00
|
|
|
struct hdac_bus *bus = sof_to_bus(sdev);
|
|
|
|
|
2023-05-12 13:16:57 -05:00
|
|
|
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_LINK)
|
2022-10-27 15:35:35 -04:00
|
|
|
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
|
2024-04-09 11:38:12 +03:00
|
|
|
const struct sof_intel_dsp_desc *chip = get_chip_info(sdev->pdata);
|
|
|
|
|
2021-02-05 20:46:29 +02:00
|
|
|
snd_hdac_ext_bus_init(bus, dev, &bus_core_ops, sof_hda_ext_ops);
|
2024-04-09 11:38:12 +03:00
|
|
|
|
2025-05-09 11:13:08 +03:00
|
|
|
if (chip && chip->hw_ip_version >= SOF_INTEL_ACE_2_0)
|
2024-04-09 11:38:12 +03:00
|
|
|
bus->use_pio_for_commands = true;
|
2023-05-12 13:16:57 -05:00
|
|
|
#else
|
|
|
|
snd_hdac_ext_bus_init(bus, dev, NULL, NULL);
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
|
2019-04-12 11:08:53 -05:00
|
|
|
memset(bus, 0, sizeof(*bus));
|
|
|
|
bus->dev = dev;
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&bus->stream_list);
|
|
|
|
|
|
|
|
bus->irq = -1;
|
2019-04-30 18:09:23 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* There is only one HDA bus atm. keep the index as 0.
|
|
|
|
* Need to fix when there are more than one HDA bus.
|
|
|
|
*/
|
|
|
|
bus->idx = 0;
|
2019-04-12 11:08:53 -05:00
|
|
|
|
|
|
|
spin_lock_init(&bus->reg_lock);
|
2023-05-12 13:16:57 -05:00
|
|
|
#endif /* CONFIG_SND_SOC_SOF_HDA_LINK */
|
2022-10-27 15:35:35 -04:00
|
|
|
}
|
module: Convert symbol namespace to string literal
Clean up the existing export namespace code along the same lines of
commit 33def8498fdd ("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.
Scripted using
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
awk -i inplace '
/^#define EXPORT_SYMBOL_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/^#define MODULE_IMPORT_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/MODULE_IMPORT_NS/ {
$0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
}
/EXPORT_SYMBOL_NS/ {
if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
$0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
$0 !~ /^my/) {
getline line;
gsub(/[[:space:]]*\\$/, "");
gsub(/[[:space:]]/, "", line);
$0 = $0 " " line;
}
$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
"\\1(\\2, \"\\3\")", "g");
}
}
{ print }' $file;
done
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-12-02 15:59:47 +01:00
|
|
|
EXPORT_SYMBOL_NS(sof_hda_bus_init, "SND_SOC_SOF_INTEL_HDA_COMMON");
|
2022-10-27 15:35:35 -04:00
|
|
|
|
|
|
|
void sof_hda_bus_exit(struct snd_sof_dev *sdev)
|
|
|
|
{
|
2023-05-12 13:16:57 -05:00
|
|
|
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_LINK)
|
2022-10-27 15:35:35 -04:00
|
|
|
struct hdac_bus *bus = sof_to_bus(sdev);
|
|
|
|
|
|
|
|
snd_hdac_ext_bus_exit(bus);
|
|
|
|
#endif
|
2019-04-12 11:08:53 -05:00
|
|
|
}
|
module: Convert symbol namespace to string literal
Clean up the existing export namespace code along the same lines of
commit 33def8498fdd ("treewide: Convert macro and uses of __section(foo)
to __section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.
Scripted using
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
awk -i inplace '
/^#define EXPORT_SYMBOL_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/^#define MODULE_IMPORT_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/MODULE_IMPORT_NS/ {
$0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
}
/EXPORT_SYMBOL_NS/ {
if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
$0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
$0 !~ /^my/) {
getline line;
gsub(/[[:space:]]*\\$/, "");
gsub(/[[:space:]]/, "", line);
$0 = $0 " " line;
}
$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
"\\1(\\2, \"\\3\")", "g");
}
}
{ print }' $file;
done
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc
Acked-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-12-02 15:59:47 +01:00
|
|
|
EXPORT_SYMBOL_NS(sof_hda_bus_exit, "SND_SOC_SOF_INTEL_HDA_COMMON");
|