~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/sof/intel/hda-bus.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
  2 //
  3 // This file is provided under a dual BSD/GPLv2 license.  When using or
  4 // redistributing this file, you may do so under either license.
  5 //
  6 // Copyright(c) 2018 Intel Corporation
  7 //
  8 // Authors: Keyon Jie <yang.jie@linux.intel.com>
  9 
 10 #include <linux/io.h>
 11 #include <sound/hdaudio.h>
 12 #include <sound/hda_i915.h>
 13 #include <sound/hda_codec.h>
 14 #include <sound/hda_register.h>
 15 #include "../sof-priv.h"
 16 #include "hda.h"
 17 
 18 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
 19 #include "../../codecs/hdac_hda.h"
 20 #define sof_hda_ext_ops snd_soc_hdac_hda_get_ops()
 21 
 22 static void update_codec_wake_enable(struct hdac_bus *bus, unsigned int addr, bool link_power)
 23 {
 24         unsigned int mask = snd_hdac_chip_readw(bus, WAKEEN);
 25 
 26         if (link_power)
 27                 mask &= ~BIT(addr);
 28         else
 29                 mask |= BIT(addr);
 30 
 31         snd_hdac_chip_updatew(bus, WAKEEN, STATESTS_INT_MASK, mask);
 32 }
 33 
 34 static void sof_hda_bus_link_power(struct hdac_device *codec, bool enable)
 35 {
 36         struct hdac_bus *bus = codec->bus;
 37         bool oldstate = test_bit(codec->addr, &bus->codec_powered);
 38 
 39         snd_hdac_ext_bus_link_power(codec, enable);
 40 
 41         if (enable == oldstate)
 42                 return;
 43 
 44         /*
 45          * Both codec driver and controller can hold references to
 46          * display power. To avoid unnecessary power-up/down cycles,
 47          * controller doesn't immediately release its reference.
 48          *
 49          * If the codec driver powers down the link, release
 50          * the controller reference as well.
 51          */
 52         if (codec->addr == HDA_IDISP_ADDR && !enable)
 53                 snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
 54 
 55         /* WAKEEN needs to be set for disabled links */
 56         update_codec_wake_enable(bus, codec->addr, enable);
 57 }
 58 
 59 static const struct hdac_bus_ops bus_core_ops = {
 60         .command = snd_hdac_bus_send_cmd,
 61         .get_response = snd_hdac_bus_get_response,
 62         .link_power = sof_hda_bus_link_power,
 63 };
 64 #endif
 65 
 66 /*
 67  * This can be used for both with/without hda link support.
 68  */
 69 void sof_hda_bus_init(struct snd_sof_dev *sdev, struct device *dev)
 70 {
 71         struct hdac_bus *bus = sof_to_bus(sdev);
 72 
 73 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_LINK)
 74 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
 75         const struct sof_intel_dsp_desc *chip = get_chip_info(sdev->pdata);
 76 
 77         snd_hdac_ext_bus_init(bus, dev, &bus_core_ops, sof_hda_ext_ops);
 78 
 79         if (chip && chip->hw_ip_version == SOF_INTEL_ACE_2_0)
 80                 bus->use_pio_for_commands = true;
 81 #else
 82         snd_hdac_ext_bus_init(bus, dev, NULL, NULL);
 83 #endif
 84 #else
 85 
 86         memset(bus, 0, sizeof(*bus));
 87         bus->dev = dev;
 88 
 89         INIT_LIST_HEAD(&bus->stream_list);
 90 
 91         bus->irq = -1;
 92 
 93         /*
 94          * There is only one HDA bus atm. keep the index as 0.
 95          * Need to fix when there are more than one HDA bus.
 96          */
 97         bus->idx = 0;
 98 
 99         spin_lock_init(&bus->reg_lock);
100 #endif /* CONFIG_SND_SOC_SOF_HDA_LINK */
101 }
102 EXPORT_SYMBOL_NS(sof_hda_bus_init, SND_SOC_SOF_INTEL_HDA_COMMON);
103 
104 void sof_hda_bus_exit(struct snd_sof_dev *sdev)
105 {
106 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_LINK)
107         struct hdac_bus *bus = sof_to_bus(sdev);
108 
109         snd_hdac_ext_bus_exit(bus);
110 #endif
111 }
112 EXPORT_SYMBOL_NS(sof_hda_bus_exit, SND_SOC_SOF_INTEL_HDA_COMMON);
113 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php